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 = \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
|
||||
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
|
||||
INCLUDES="$(INCLUDES)" SWIGOPT= OUTDIR="$(OUTDIR)" \
|
||||
INCLUDES="$(INCLUDES)" OUTDIR="$(OUTDIR)" \
|
||||
TARGET="$(OUTDIR)/$*_wrap.cxx" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
|
||||
scilab_cpp
|
||||
|
||||
swig_and_compile_c = \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CSRCS="$(CSRCS)" \
|
||||
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
|
||||
INCLUDES="$(INCLUDES)" SWIGOPT= OUTDIR="$(OUTDIR)" \
|
||||
INCLUDES="$(INCLUDES)" OUTDIR="$(OUTDIR)" \
|
||||
TARGET="$(OUTDIR)/$*_wrap.c" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$*.i" \
|
||||
scilab
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ swig_and_compile_multi_cpp = \
|
|||
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
|
||||
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" \
|
||||
INCLUDES="$(INCLUDES)" SWIGOPT= OUTDIR="$(OUTDIR)" \
|
||||
INCLUDES="$(INCLUDES)" OUTDIR="$(OUTDIR)" \
|
||||
TARGET="$(OUTDIR)/$*_wrap.cxx" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
|
||||
scilab_cpp; \
|
||||
done
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ protected:
|
|||
String *buildFlagsScript;
|
||||
|
||||
bool generateBuilder;
|
||||
bool extraWarning;
|
||||
public:
|
||||
/* ------------------------------------------------------------------------
|
||||
* main()
|
||||
|
|
@ -62,6 +63,7 @@ public:
|
|||
verboseBuildLevel = NULL;
|
||||
buildFlagsScript = NULL;
|
||||
generateBuilder = true;
|
||||
extraWarning = false;
|
||||
|
||||
/* Manage command line arguments */
|
||||
for (int argIndex = 1; argIndex < argc; argIndex++) {
|
||||
|
|
@ -101,6 +103,9 @@ public:
|
|||
} else if (strcmp(argv[argIndex], "-nobuilder") == 0) {
|
||||
Swig_mark_arg(argIndex);
|
||||
generateBuilder = false;
|
||||
}
|
||||
else if (strcmp(argv[argIndex], "-Wextra") == 0) {
|
||||
extraWarning = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -242,6 +247,8 @@ public:
|
|||
SwigType *functionReturnType = Getattr(node, "type");
|
||||
ParmList *functionParamsList = Getattr(node, "parms");
|
||||
|
||||
checkIdentifierName(functionName);
|
||||
|
||||
int paramIndex = 0; // Used for loops over ParmsList
|
||||
Parm *param = NULL; // Used for loops over ParamsList
|
||||
|
||||
|
|
@ -491,6 +498,8 @@ public:
|
|||
String *origVariableName = Getattr(node, "name"); // Ex: Shape::nshapes
|
||||
String *variableName = Getattr(node, "sym:name"); // Ex; Shape_nshapes (can be used for function names, ...)
|
||||
|
||||
checkIdentifierName(variableName);
|
||||
|
||||
/* Manage GET function */
|
||||
Wrapper *getFunctionWrapper = NewWrapper();
|
||||
String *getFunctionName = Swig_name_get(NSPACE_TODO, variableName);
|
||||
|
|
@ -559,6 +568,8 @@ public:
|
|||
String *constantValue = rawValue ? rawValue : Getattr(node, "value");
|
||||
String *constantTypemap = NULL;
|
||||
|
||||
checkIdentifierName(constantName);
|
||||
|
||||
// If feature scilab:const enabled, constants & enums are wrapped to Scilab variables
|
||||
if (GetFlag(node, "feature:scilab:const")) {
|
||||
bool isConstant = ((SwigType_issimple(type)) || (SwigType_type(type) == T_STRING));
|
||||
|
|
@ -653,6 +664,16 @@ public:
|
|||
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() {
|
||||
String *builderFilename = NewStringf("%sbuilder.sce", SWIG_output_directory());
|
||||
builderFile = NewFile(builderFilename, "w", SWIG_output_files());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue