diff --git a/.gitignore b/.gitignore index eb3aa012c..253d5e6fb 100644 --- a/.gitignore +++ b/.gitignore @@ -128,3 +128,11 @@ Examples/test-suite/uffi/*/ # Scratch directories Examples/scratch + +# Scilab generated files +builder.sce +loader.sce +cleaner.sce +*_wrap.c +*_wrap.cxx +lib*lib*.c diff --git a/Examples/Makefile.in b/Examples/Makefile.in index 30c7718f0..b6deb1ae8 100644 --- a/Examples/Makefile.in +++ b/Examples/Makefile.in @@ -1528,7 +1528,7 @@ R_SCRIPT=$(RUNME).R r: $(SRCS) $(SWIG) -r $(SWIGOPT) $(INTERFACEPATH) ifneq ($(SRCS),) - $(CC) -g -c $(CFLAGS) $(R_CFLAGS) $(SRCS) $(INCLUDES) + $(CC) -g -c $(CFLAGS) $(R_CFLAGS) $(SRCS) $(INCLUDES) endif +( PKG_CPPFLAGS="$(INCLUDES)" $(COMPILETOOL) $(R) CMD SHLIB -o $(LIBPREFIX)$(TARGET)$(SO) $(ISRCS) $(OBJS) > /dev/null ) @@ -1572,9 +1572,10 @@ r_clean: ################################################################## # Make sure these locate your Scilab installation -SCILAB_INCLUDE= $(DEFS) @SCILABINCLUDE@ -SCILAB_LIB = @SCILABLIB@ -SCILAB = @SCILAB@ +SCILAB_INCLUDE = $(DEFS) @SCILABINCLUDE@ +SCILAB_LIB = @SCILABLIB@ +SCILAB = @SCILAB@ +SCILABOPT = # ---------------------------------------------------------------- # Build a C dynamically loadable module @@ -1583,15 +1584,15 @@ SCILAB = @SCILAB@ scilab: $(SRCS) @if test ! -z "$(SRCS)"; then \ if test ! -z "$(INCLUDES)"; then \ - $(SWIG) -scilab -addsrc $(SRCS) -addcflag $(INCLUDES) $(SWIGOPT) $(INTERFACEPATH); \ + $(SWIG) -scilab $(SWIGOPT) $(SCILABOPT) -addsrc $(SRCS) -addcflag $(INCLUDES) $(INTERFACEPATH); \ else \ - $(SWIG) -scilab -addsrc $(SRCS) $(SWIGOPT) $(INTERFACEPATH); \ + $(SWIG) -scilab $(SWIGOPT) $(SCILABOPT) -addsrc $(SRCS) $(INTERFACEPATH); \ fi \ else \ if test ! -z "$(INCLUDES)"; then \ - $(SWIG) -scilab -addcflag $(INCLUDES) $(SWIGOPT) $(INTERFACEPATH); \ + $(SWIG) -scilab $(SWIGOPT) $(SCILABOPT) -addcflag $(INCLUDES) $(INTERFACEPATH); \ else \ - $(SWIG) -scilab $(SWIGOPT) $(INTERFACEPATH); \ + $(SWIG) -scilab $(SWIGOPT) $(SCILABOPT) $(INTERFACEPATH); \ fi \ fi @if [ -f builder.sce ]; then \ @@ -1605,15 +1606,15 @@ scilab: $(SRCS) scilab_cpp: $(SRCS) @if test ! -z "$(SRCS)"; then \ if test ! -z "$(INCLUDES)"; then \ - $(SWIG) -scilab -c++ -addsrc $(SRCS) -addcflag $(INCLUDES) $(SWIGOPT) $(INTERFACEPATH); \ + $(SWIG) -scilab -c++ $(SWIGOPT) $(SCILABOPT) -addsrc $(SRCS) -addcflag $(INCLUDES) $(INTERFACEPATH); \ else \ - $(SWIG) -scilab -c++ -addsrc $(SRCS) $(SWIGOPT) $(INTERFACEPATH); \ + $(SWIG) -scilab -c++ $(SWIGOPT) $(SCILABOPT) -addsrc $(SRCS) $(INTERFACEPATH); \ fi \ else \ if test ! -z "$(INCLUDES)"; then \ - $(SWIG) -scilab -c++ -addcflag $(INCLUDES) $(SWIGOPT) $(INTERFACEPATH); \ + $(SWIG) -scilab -c++ $(SWIGOPT) $(SCILABOPT) -addcflag $(INCLUDES) $(INTERFACEPATH); \ else \ - $(SWIG) -scilab -c++ $(SWIGOPT) $(INTERFACEPATH); \ + $(SWIG) -scilab -c++ $(SWIGOPT) $(SCILABOPT) $(INTERFACEPATH); \ fi \ fi @if [ -f builder.sce ]; then \ diff --git a/Examples/test-suite/scilab/Makefile.in b/Examples/test-suite/scilab/Makefile.in index 75fef2199..6f11d930f 100644 --- a/Examples/test-suite/scilab/Makefile.in +++ b/Examples/test-suite/scilab/Makefile.in @@ -38,11 +38,11 @@ include $(srcdir)/../common.mk run_testcase = \ if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) echo 'exit(1)' |$(SCILAB) -nwni -nb -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ; ) \ - fi; + fi; -# Clean: remove the generated .sci file +# Clean: remove the generated files %.clean: - @rm -f $*.sci *_wrap.c *.h *_wrap.cxx + @rm -f builder.sce loader.sce cleaner.sce $*_wrap.c $*_wrap.cxx lib$*lib.* clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile scilab_clean diff --git a/Lib/scilab/scisequence.swg b/Lib/scilab/scisequence.swg index 2319f811c..9eefd94fb 100644 --- a/Lib/scilab/scisequence.swg +++ b/Lib/scilab/scisequence.swg @@ -23,7 +23,6 @@ #define SWIG_From_SequenceItem_frag(Type...) %fragment_name(From_SequenceItem, Type) #define SWIG_From_SequenceItem_dec(Type...) %symbol_name(From_SequenceItem, Type) - %include %include %include @@ -39,10 +38,35 @@ fragment=SWIG_AsGet_Sequence_frag(ptr), fragment=SWIG_AsSize_Sequence_frag(ptr), fragment=SWIG_FromCreate_Sequence_frag(ptr), - fragment=SWIG_FromSet_Sequence_frag(ptr)) { + fragment=SWIG_FromSet_Sequence_frag(ptr), + fragment="StdTraits") { namespace swig { + // Returns an error for default (not specialized) value containers + template struct traits_as_sequence { + static int check(SciObject obj) { + SWIG_Error(SWIG_TypeError, type_name()); + } + static int get(SciObject obj, void **sequence) { + SWIG_Error(SWIG_TypeError, type_name()); + } + static int size(SciObject obj, int *size) { + SWIG_Error(SWIG_TypeError, type_name()); + } + }; + template struct traits_from_sequence { + static int create(int size, void **sequence) { + SWIG_Error(SWIG_TypeError, type_name()); + } + static SciObject set(int size, void *sequence) { + SWIG_Error(SWIG_TypeError, type_name()); + } + }; + + // But supports containers of pointers + + template struct traits_as_sequence { static int check(SciObject obj) { return SWIG_AsCheck_Sequence_dec(ptr)(obj); } @@ -53,12 +77,12 @@ namespace swig { return SWIG_AsSize_Sequence_dec(ptr)(obj, size); } }; - template struct traits_from_sequence { + template struct traits_from_sequence { static int create(int size, void **sequence) { - return SWIG_FromCreate_Sequence_dec(ptr)(size, (int ***)sequence); + return SWIG_FromCreate_Sequence_dec(ptr)(size, (long long **)sequence); } static SciObject set(int size, void *sequence) { - return SWIG_FromSet_Sequence_dec(ptr)(size, (int **)sequence); + return SWIG_FromSet_Sequence_dec(ptr)(size, (long long *)sequence); } }; } @@ -104,19 +128,35 @@ namespace swig { %fragment(SWIG_Traits_SequenceItem_frag(ptr), "header", fragment=SWIG_AsVal_SequenceItem_frag(ptr), - fragment=SWIG_From_SequenceItem_frag(ptr)) { + fragment=SWIG_From_SequenceItem_frag(ptr), + fragment="StdTraits") { namespace swig { + // Returns an error for default (not specialized) value containers + template struct traits_asval_sequenceitem { static int asval(SciObject obj, void *pSequence, int iItemIndex, T *pItemValue) { - return SWIG_AsVal_SequenceItem_dec(ptr)(obj, (int *)pSequence, iItemIndex, (int **)pItemValue); + SWIG_Error(SWIG_TypeError, type_name()); } }; template struct traits_from_sequenceitem { static int from(void *pSequence, int iItemIndex, T itemValue) { - return SWIG_From_SequenceItem_dec(ptr)((int **)pSequence, iItemIndex, (int*)itemValue); + SWIG_Error(SWIG_TypeError, type_name()); } }; + + // But supports containers of pointers + + template struct traits_asval_sequenceitem { + static int asval(SciObject obj, void *pSequence, int iItemIndex, T **pItemValue) { + return SWIG_AsVal_SequenceItem_dec(ptr)(obj, (int *)pSequence, iItemIndex, (void **)pItemValue); + } + }; + template struct traits_from_sequenceitem { + static int from(void *pSequence, int iItemIndex, T *itemValue) { + return SWIG_From_SequenceItem_dec(ptr)((long long *)pSequence, iItemIndex, (long long) itemValue); + } + }; } } diff --git a/Lib/scilab/scisequencepointer.swg b/Lib/scilab/scisequencepointer.swg index 36f6ca2d5..332b5fb7e 100644 --- a/Lib/scilab/scisequencepointer.swg +++ b/Lib/scilab/scisequencepointer.swg @@ -36,8 +36,8 @@ SWIG_AsSize_Sequence_dec(ptr)(SciObject _obj, int *_piSize) { %fragment(SWIG_FromCreate_Sequence_frag(ptr), "header") { SWIGINTERN int -SWIG_FromCreate_Sequence_dec(ptr)(int _size, int ***_sequence) { - *_sequence = new int*[_size]; +SWIG_FromCreate_Sequence_dec(ptr)(int _size, long long **_sequence) { + *_sequence = new long long[_size]; return *_sequence != NULL ? SWIG_OK : SWIG_ERROR; } } @@ -45,7 +45,7 @@ SWIG_FromCreate_Sequence_dec(ptr)(int _size, int ***_sequence) { %fragment(SWIG_FromSet_Sequence_frag(ptr), "header") { SWIGINTERN SciObject -SWIG_FromSet_Sequence_dec(ptr)(int _size, int **_sequence) { +SWIG_FromSet_Sequence_dec(ptr)(int _size, long long *_sequence) { SciErr sciErr; int *piListAddr; @@ -75,7 +75,7 @@ SWIG_FromSet_Sequence_dec(ptr)(int _size, int **_sequence) { %fragment(SWIG_AsVal_SequenceItem_frag(ptr), "header") { SWIGINTERN int -SWIG_AsVal_SequenceItem_dec(ptr)(SciObject _obj, int* _piSequence, int _itemIndex, int **_pItemValue) +SWIG_AsVal_SequenceItem_dec(ptr)(SciObject _obj, int *_piSequence, int _itemIndex, void **_pItemValue) { SciErr sciErr; int *piItemAddr; @@ -115,7 +115,7 @@ SWIG_AsVal_SequenceItem_dec(ptr)(SciObject _obj, int* _piSequence, int _itemInde %fragment(SWIG_From_SequenceItem_frag(ptr), "header") { SWIGINTERN int -SWIG_From_SequenceItem_dec(ptr)(int **_pSequence, int _iItemIndex, int *_itemValue) { +SWIG_From_SequenceItem_dec(ptr)(long long *_pSequence, int _iItemIndex, long long _itemValue) { _pSequence[_iItemIndex] = _itemValue; } } diff --git a/Source/Modules/scilab.cxx b/Source/Modules/scilab.cxx index 6d406f314..84abc1b13 100644 --- a/Source/Modules/scilab.cxx +++ b/Source/Modules/scilab.cxx @@ -18,9 +18,10 @@ static const char *usage = (char*) "\ Scilab options\n\ - -addsrc additionnal source files (separated by comma) to include in build script (ex: myfile.cxx myfile2.cxx)\n\ + -addsrc additionnal source files (separated by space) to include in build script (ex: myfile.cxx myfile2.cxx)\n\ -addcflag -I additionnal include path to include in build script (ex: -I/usr/includes/)\n\ - -addldlag additionnal link flag to include in build script (ex: -lm)\n\n"; + -addldlag additionnal link flag to include in build script (ex: -lm)\n\ + -vbl sets the build verbose level (default 0)\n\n"; const char* SWIG_INIT_FUNCTION_NAME = "SWIG_Init"; @@ -41,6 +42,8 @@ protected: String *cflag; String *ldflag; + String* verboseBuildLevel; + public: /* ------------------------------------------------------------------------ * main() @@ -50,6 +53,7 @@ public: sourceFileList = NewList(); ldflag = NULL; cflag = NULL; + verboseBuildLevel = NULL; /* Manage command line arguments */ for (int argIndex = 1; argIndex < argc; argIndex++) { @@ -82,10 +86,18 @@ public: ldflag = NewString(argv[argIndex+1]); Swig_mark_arg(argIndex+1); } + } else if (strcmp(argv[argIndex], "-vbl") == 0) { + Swig_mark_arg(argIndex); + verboseBuildLevel = NewString(argv[argIndex+1]); + Swig_mark_arg(argIndex+1); } } } + if (verboseBuildLevel == NULL) { + verboseBuildLevel = NewString("0"); + } + /* Set language-specific subdirectory in SWIG library */ SWIG_library_directory("scilab"); @@ -138,12 +150,9 @@ public: builderCode = NewString(""); Printf(builderCode, "mode(-1);\n"); Printf(builderCode, "lines(0);\n"); /* Useful for automatic tests */ - #ifdef SWIG_DEBUG - Printf(builderCode, "try\n"); - Printf(builderCode, "ilib_verbose(1);\n"); - #else - Printf(builderCode, "ilib_verbose(0);\n"); - #endif + + Printf(builderCode, "ilib_verbose(%s);\n", verboseBuildLevel); + Printf(builderCode, "ilib_name = \"%slib\";\n", moduleName); Printf(builderCode, "libs = [];\n"); @@ -197,11 +206,7 @@ public: Printf(builderCode, "if ~isempty(table) then\n"); Printf(builderCode, " ilib_build(ilib_name, table, files, libs, [], ldflags, cflags);\n"); Printf(builderCode, "end\n"); - #ifdef SWIG_DEBUG - Printf(builderCode, "catch\n"); - Printf(builderCode, " printf(\"\"*** builder.sce file execution FAILED ***\"\");\n"); - Printf(builderCode, "end\n"); - #endif + Printf(builderCode, "exit"); builderFile = NewFile(NewStringf("%sbuilder.sce", SWIG_output_directory()), "w", SWIG_output_files()); Printv(builderFile, builderCode, NIL);