Scilab: if -Wextra, warning at generation for too long identifier names
This commit is contained in:
parent
40a5fe1224
commit
3ebd3da30e
2 changed files with 24 additions and 3 deletions
|
|
@ -35,14 +35,14 @@ include $(srcdir)/../common.mk
|
||||||
swig_and_compile_cpp = \
|
swig_and_compile_cpp = \
|
||||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
|
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
|
||||||
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
|
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
|
||||||
INCLUDES="$(INCLUDES)" SWIGOPT= OUTDIR="$(OUTDIR)" \
|
INCLUDES="$(INCLUDES)" OUTDIR="$(OUTDIR)" \
|
||||||
TARGET="$(OUTDIR)/$*_wrap.cxx" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
|
TARGET="$(OUTDIR)/$*_wrap.cxx" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
|
||||||
scilab_cpp
|
scilab_cpp
|
||||||
|
|
||||||
swig_and_compile_c = \
|
swig_and_compile_c = \
|
||||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CSRCS="$(CSRCS)" \
|
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CSRCS="$(CSRCS)" \
|
||||||
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
|
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
|
||||||
INCLUDES="$(INCLUDES)" SWIGOPT= OUTDIR="$(OUTDIR)" \
|
INCLUDES="$(INCLUDES)" OUTDIR="$(OUTDIR)" \
|
||||||
TARGET="$(OUTDIR)/$*_wrap.c" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
|
TARGET="$(OUTDIR)/$*_wrap.c" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
|
||||||
scilab
|
scilab
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ swig_and_compile_multi_cpp = \
|
||||||
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
|
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
|
||||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
|
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
|
||||||
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
|
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
|
||||||
INCLUDES="$(INCLUDES)" SWIGOPT= OUTDIR="$(OUTDIR)" \
|
INCLUDES="$(INCLUDES)" OUTDIR="$(OUTDIR)" \
|
||||||
TARGET="$(OUTDIR)/$*_wrap.cxx" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
|
TARGET="$(OUTDIR)/$*_wrap.cxx" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
|
||||||
scilab_cpp; \
|
scilab_cpp; \
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ protected:
|
||||||
String *buildFlagsScript;
|
String *buildFlagsScript;
|
||||||
|
|
||||||
bool generateBuilder;
|
bool generateBuilder;
|
||||||
|
bool extraWarning;
|
||||||
public:
|
public:
|
||||||
/* ------------------------------------------------------------------------
|
/* ------------------------------------------------------------------------
|
||||||
* main()
|
* main()
|
||||||
|
|
@ -62,6 +63,7 @@ public:
|
||||||
verboseBuildLevel = NULL;
|
verboseBuildLevel = NULL;
|
||||||
buildFlagsScript = NULL;
|
buildFlagsScript = NULL;
|
||||||
generateBuilder = true;
|
generateBuilder = true;
|
||||||
|
extraWarning = false;
|
||||||
|
|
||||||
/* Manage command line arguments */
|
/* Manage command line arguments */
|
||||||
for (int argIndex = 1; argIndex < argc; argIndex++) {
|
for (int argIndex = 1; argIndex < argc; argIndex++) {
|
||||||
|
|
@ -101,6 +103,9 @@ public:
|
||||||
} else if (strcmp(argv[argIndex], "-nobuilder") == 0) {
|
} else if (strcmp(argv[argIndex], "-nobuilder") == 0) {
|
||||||
Swig_mark_arg(argIndex);
|
Swig_mark_arg(argIndex);
|
||||||
generateBuilder = false;
|
generateBuilder = false;
|
||||||
|
}
|
||||||
|
else if (strcmp(argv[argIndex], "-Wextra") == 0) {
|
||||||
|
extraWarning = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -242,6 +247,8 @@ public:
|
||||||
SwigType *functionReturnType = Getattr(node, "type");
|
SwigType *functionReturnType = Getattr(node, "type");
|
||||||
ParmList *functionParamsList = Getattr(node, "parms");
|
ParmList *functionParamsList = Getattr(node, "parms");
|
||||||
|
|
||||||
|
checkIdentifierName(functionName);
|
||||||
|
|
||||||
int paramIndex = 0; // Used for loops over ParmsList
|
int paramIndex = 0; // Used for loops over ParmsList
|
||||||
Parm *param = NULL; // Used for loops over ParamsList
|
Parm *param = NULL; // Used for loops over ParamsList
|
||||||
|
|
||||||
|
|
@ -491,6 +498,8 @@ public:
|
||||||
String *origVariableName = Getattr(node, "name"); // Ex: Shape::nshapes
|
String *origVariableName = Getattr(node, "name"); // Ex: Shape::nshapes
|
||||||
String *variableName = Getattr(node, "sym:name"); // Ex; Shape_nshapes (can be used for function names, ...)
|
String *variableName = Getattr(node, "sym:name"); // Ex; Shape_nshapes (can be used for function names, ...)
|
||||||
|
|
||||||
|
checkIdentifierName(variableName);
|
||||||
|
|
||||||
/* Manage GET function */
|
/* Manage GET function */
|
||||||
Wrapper *getFunctionWrapper = NewWrapper();
|
Wrapper *getFunctionWrapper = NewWrapper();
|
||||||
String *getFunctionName = Swig_name_get(NSPACE_TODO, variableName);
|
String *getFunctionName = Swig_name_get(NSPACE_TODO, variableName);
|
||||||
|
|
@ -559,6 +568,8 @@ public:
|
||||||
String *constantValue = rawValue ? rawValue : Getattr(node, "value");
|
String *constantValue = rawValue ? rawValue : Getattr(node, "value");
|
||||||
String *constantTypemap = NULL;
|
String *constantTypemap = NULL;
|
||||||
|
|
||||||
|
checkIdentifierName(constantName);
|
||||||
|
|
||||||
// If feature scilab:const enabled, constants & enums are wrapped to Scilab variables
|
// If feature scilab:const enabled, constants & enums are wrapped to Scilab variables
|
||||||
if (GetFlag(node, "feature:scilab:const")) {
|
if (GetFlag(node, "feature:scilab:const")) {
|
||||||
bool isConstant = ((SwigType_issimple(type)) || (SwigType_type(type) == T_STRING));
|
bool isConstant = ((SwigType_issimple(type)) || (SwigType_type(type) == T_STRING));
|
||||||
|
|
@ -653,6 +664,16 @@ public:
|
||||||
return Language::enumvalueDeclaration(node);
|
return Language::enumvalueDeclaration(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void checkIdentifierName(String *name) {
|
||||||
|
if (Len(name) > 24) {
|
||||||
|
if (extraWarning) {
|
||||||
|
// Warning on too long identifiers
|
||||||
|
Swig_warning(WARN_LANG_IDENTIFIER, input_file, line_number,
|
||||||
|
"Identifier %s exceeds 24 characters, it may be impossible to use it.\n", name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void createBuilderFile() {
|
void createBuilderFile() {
|
||||||
String *builderFilename = NewStringf("%sbuilder.sce", SWIG_output_directory());
|
String *builderFilename = NewStringf("%sbuilder.sce", SWIG_output_directory());
|
||||||
builderFile = NewFile(builderFilename, "w", SWIG_output_files());
|
builderFile = NewFile(builderFilename, "w", SWIG_output_files());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue