diff --git a/Examples/scilab/constants/makefile b/Examples/scilab/constants/makefile index f35cee60e..3cd8d9074 100644 --- a/Examples/scilab/constants/makefile +++ b/Examples/scilab/constants/makefile @@ -7,9 +7,10 @@ INTERFACE = example.i all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab + scilab -nwni < runme.sci clean:: $(MAKE) -f $(TOP)/Makefile scilab_clean - rm -f *.sce *.so lib*lib.c + rm -f *.sce *.so lib*lib.c *_wrap.c check: all diff --git a/Examples/scilab/contract/makefile b/Examples/scilab/contract/makefile index e9a70a676..663acc8e7 100644 --- a/Examples/scilab/contract/makefile +++ b/Examples/scilab/contract/makefile @@ -7,9 +7,10 @@ INTERFACE = example.i all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab + scilab -nwni < runme.sci clean:: $(MAKE) -f $(TOP)/Makefile scilab_clean - rm -f *.sce *.so lib*lib.c + rm -f *.sce *.so lib*lib.c *_wrap.c check: all diff --git a/Examples/scilab/enum/makefile b/Examples/scilab/enum/makefile index e9a70a676..663acc8e7 100644 --- a/Examples/scilab/enum/makefile +++ b/Examples/scilab/enum/makefile @@ -7,9 +7,10 @@ INTERFACE = example.i all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab + scilab -nwni < runme.sci clean:: $(MAKE) -f $(TOP)/Makefile scilab_clean - rm -f *.sce *.so lib*lib.c + rm -f *.sce *.so lib*lib.c *_wrap.c check: all diff --git a/Examples/scilab/pointer/makefile b/Examples/scilab/pointer/makefile index e9a70a676..663acc8e7 100644 --- a/Examples/scilab/pointer/makefile +++ b/Examples/scilab/pointer/makefile @@ -7,9 +7,10 @@ INTERFACE = example.i all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab + scilab -nwni < runme.sci clean:: $(MAKE) -f $(TOP)/Makefile scilab_clean - rm -f *.sce *.so lib*lib.c + rm -f *.sce *.so lib*lib.c *_wrap.c check: all diff --git a/Examples/scilab/simple/makefile b/Examples/scilab/simple/makefile index e9a70a676..663acc8e7 100644 --- a/Examples/scilab/simple/makefile +++ b/Examples/scilab/simple/makefile @@ -7,9 +7,10 @@ INTERFACE = example.i all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab + scilab -nwni < runme.sci clean:: $(MAKE) -f $(TOP)/Makefile scilab_clean - rm -f *.sce *.so lib*lib.c + rm -f *.sce *.so lib*lib.c *_wrap.c check: all diff --git a/Examples/scilab/variables/makefile b/Examples/scilab/variables/makefile index e9a70a676..663acc8e7 100644 --- a/Examples/scilab/variables/makefile +++ b/Examples/scilab/variables/makefile @@ -7,9 +7,10 @@ INTERFACE = example.i all:: $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab + scilab -nwni < runme.sci clean:: $(MAKE) -f $(TOP)/Makefile scilab_clean - rm -f *.sce *.so lib*lib.c + rm -f *.sce *.so lib*lib.c *_wrap.c check: all diff --git a/Lib/scilab/scitypemaps.swg b/Lib/scilab/scitypemaps.swg index a76b8a05e..b11d8ab1b 100644 --- a/Lib/scilab/scitypemaps.swg +++ b/Lib/scilab/scitypemaps.swg @@ -337,35 +337,35 @@ * ----------------------------------------------------------------------------- */ /* Basic C types */ -%typemap(out) signed char (int iRowsOut,int iColsOut,int* _piAddress) { +%typemap(out) signed char (int iRowsOut,int iColsOut) { char temp; temp=(char)($result); iRowsOut=1; iColsOut=1; - createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, &temp, &_piAddress); + createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, &temp); LhsVar(iOutNum)=iVarOut; } -%typemap(out) short (int iRowsOut,int iColsOut,int* _piAddress), - unsigned char (int iRowsOut,int iColsOut,int* _piAddress) { +%typemap(out) short (int iRowsOut,int iColsOut), + unsigned char (int iRowsOut,int iColsOut) { short temp; temp=(short)($result); iRowsOut=1; iColsOut=1; - createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &temp, &_piAddress); + createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &temp); LhsVar(iOutNum)=iVarOut; } -%typemap(out) int (int iRowsOut,int iColsOut,int* _piAddress), - unsigned int (int iRowsOut,int iColsOut,int* _piAddress), - unsigned short (int iRowsOut,int iColsOut,int* _piAddress), - unsigned long (int iRowsOut,int iColsOut,int* _piAddress), - long (int iRowsOut,int iColsOut,int* _piAddress) { +%typemap(out) int (int iRowsOut,int iColsOut), + unsigned int (int iRowsOut,int iColsOut), + unsigned short (int iRowsOut,int iColsOut), + unsigned long (int iRowsOut,int iColsOut), + long (int iRowsOut,int iColsOut) { int temp; temp=(int)($result); iRowsOut=1; iColsOut=1; - createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, &temp, &_piAddress); + createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, &temp); LhsVar(iOutNum)=iVarOut; } @@ -392,35 +392,35 @@ } /* Pointers */ -%typemap(out) signed char *(int iRowsOut,int iColsOut,int* _piAddress) { +%typemap(out) signed char *(int iRowsOut,int iColsOut) { char *temp; temp=(char *)($result); iRowsOut=1; iColsOut=1; - createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, temp, &_piAddress); + createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, temp); LhsVar(iOutNum)=iVarOut; } -%typemap(out) short *(int iRowsOut,int iColsOut,int* _piAddress), - unsigned char *(int iRowsOut,int iColsOut,int* _piAddress) { +%typemap(out) short *(int iRowsOut,int iColsOut), + unsigned char *(int iRowsOut,int iColsOut) { short *temp; temp=(short *)($result); iRowsOut=1; iColsOut=1; - createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, temp, &_piAddress); + createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, temp); LhsVar(iOutNum)=iVarOut; } -%typemap(out) int *(int iRowsOut,int iColsOut,int* _piAddress), - unsigned int *(int iRowsOut,int iColsOut,int* _piAddress), - unsigned short *(int iRowsOut,int iColsOut,int* _piAddress), - unsigned long *(int iRowsOut,int iColsOut,int* _piAddress), - long *(int iRowsOut,int iColsOut,int* _piAddress) { +%typemap(out) int *(int iRowsOut,int iColsOut), + unsigned int *(int iRowsOut,int iColsOut), + unsigned short *(int iRowsOut,int iColsOut), + unsigned long *(int iRowsOut,int iColsOut), + long *(int iRowsOut,int iColsOut) { int *temp; temp=(int *)($result); iRowsOut=1; iColsOut=1; - createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, temp, &_piAddress); + createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, temp); LhsVar(iOutNum)=iVarOut; } @@ -549,22 +549,19 @@ * ----------------------------------------------------------------------------- */ /* Basic C types */ %typemap(varout,noblock=1) signed char { - int* _piAddress; - createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, &$result, &_piAddress); + createMatrixOfInteger8(iVarOut, iRowsOut, iColsOut, &$result); LhsVar(iOutNum)=iVarOut; } %typemap(varout,noblock=1) short { - int* _piAddress; - createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &$result, &_piAddress); + createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &$result); LhsVar(iOutNum)=iVarOut; } %typemap(varout,noblock=1) unsigned char { - int* _piAddress; short temp; temp=$result; - createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &temp, &_piAddress); + createMatrixOfInteger16(iVarOut, iRowsOut, iColsOut, &temp); LhsVar(iOutNum)=iVarOut; } @@ -573,8 +570,7 @@ unsigned short, unsigned long, long { - int* _piAddress; - createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, &$result, &_piAddress); + createMatrixOfInteger32(iVarOut, iRowsOut, iColsOut, &$result); LhsVar(iOutNum)=iVarOut; } diff --git a/Source/Modules/scilab.cxx b/Source/Modules/scilab.cxx index 7b041b5c7..f73b52e77 100644 --- a/Source/Modules/scilab.cxx +++ b/Source/Modules/scilab.cxx @@ -161,7 +161,7 @@ public: virtual int functionWrapper(Node *n) { - hasfunction_flag=true; + hasfunction_flag = true; /* A new wrapper function object */ Wrapper *f = NewWrapper(); @@ -299,19 +299,19 @@ public: /* Insert the code checking for the number of input and output */ int flag; - if(out_required==0) { - out_required=1; - flag=0; + if(out_required == 0) { + out_required = 1; + flag = 0; } else { - flag=1; + flag = 1; } - Printf(f->def,"CheckRhs(%d,%d);\n",num_required,num_required); - Printf(f->def,"CheckLhs(%d,%d);\n",out_required,out_required); + Printf(f->def, "CheckRhs(%d,%d);\n",num_required,num_required); + Printf(f->def, "CheckLhs(%d,%d);\n",out_required,out_required); /* Insert the order of output parameters*/ if(flag) - Printf(f->def,"\nint iOutNum=1;\nint iVarOut=Rhs+1;"); + Printf(f->def, "\nint iOutNum=1;\nint iVarOut=Rhs+1;"); /* Finish the the code for the function */ Printf(f->code, "return 0;\n"); @@ -322,7 +322,7 @@ public: /* Dump the wrapper function */ Wrapper_print(f, f_wrappers); DelWrapper(f); - Printf(f_builder_code, "\"%s\",\"%s\";",iname,wname); + Printf(f_builder_code, "\"%s\",\"%s\";", iname, wname); Delete(overname); Delete(wname); @@ -337,7 +337,7 @@ public: virtual int variableWrapper(Node *n) { - hasfunction_flag=true; + hasfunction_flag = true; /* Get the useful information from the node */ String *name = Getattr(n, "name"); @@ -347,33 +347,33 @@ public: if (!addSymbol(iname, n)) return SWIG_ERROR; - String *rowname=NewString(""); - String *colname=NewString(""); - String *iscomplexname=NewString(""); - Printf(rowname,"iRows_%s",iname); - Printf(colname,"iCols_%s",iname); - Printf(iscomplexname,"isComplex_%s",iname); + String *rowname = NewString(""); + String *colname = NewString(""); + String *iscomplexname = NewString(""); + Printf(rowname, "iRows_%s", iname); + Printf(colname, "iCols_%s", iname); + Printf(iscomplexname, "isComplex_%s", iname); /* two wrapper function to get and set the variable */ String *tm; - String *globalVar=NewString(""); + String *globalVar = NewString(""); Wrapper *getf = NewWrapper(); Wrapper *setf = NewWrapper(); String *getname = Swig_name_get(iname); String *setname = Swig_name_set(iname); - Printf(globalVar, "int %s=0;\n",rowname); - Printf(globalVar, "int %s=0;\n",colname); - if(!Strcmp(t,"p.double")) - Printf(globalVar, "int %s=0;\n\n",iscomplexname); + Printf(globalVar, "int %s=0;\n", rowname); + Printf(globalVar, "int %s=0;\n", colname); + if(!Strcmp(t, "p.double")) + Printf(globalVar, "int %s=0;\n\n", iscomplexname); else - Printf(globalVar,"\n"); + Printf(globalVar, "\n"); Printv(setf->def, "int ", setname, " (char *fname,unsigned long fname_len) {\n", NIL); /* Check the number of input and output */ - Printf(setf->def,"CheckRhs(1,1);\n"); - Printf(setf->def,"CheckLhs(1,1);\n"); + Printf(setf->def, "CheckRhs(1,1);\n"); + Printf(setf->def, "CheckLhs(1,1);\n"); /* add the local variable */ Wrapper_add_local(setf, "piAddrVar", "int *piAddrVar"); @@ -383,9 +383,9 @@ public: Setattr(n, "wrap:name", setname); if ((tm = Swig_typemap_lookup("varin", n, name, 0))) { Replaceall(tm, "$argnum", "1"); - Replaceall(tm,"iRows",rowname); - Replaceall(tm,"iCols",colname); - Replaceall(tm,"isComplex",iscomplexname); + Replaceall(tm, "iRows", rowname); + Replaceall(tm, "iCols", colname); + Replaceall(tm, "isComplex", iscomplexname); emit_action_code(n, setf->code, tm); Delete(tm); } else { @@ -396,7 +396,7 @@ public: } Append(setf->code, "}\n"); Wrapper_print(setf, f_wrappers); - Printf(f_builder_code, "\"%s\",\"%s\";",setname,setname); + Printf(f_builder_code, "\"%s\",\"%s\";", setname, setname); /* deal with the get function */ Setattr(n, "wrap:name", getname); @@ -404,17 +404,17 @@ public: Printv(getf->def, "int ", getname, " (char *fname,unsigned long fname_len){\n", NIL); /* Check the number of input and output */ - Printf(getf->def,"CheckRhs(0,0);\n"); - Printf(getf->def,"CheckLhs(1,1);\n"); + Printf(getf->def, "CheckRhs(0,0);\n"); + Printf(getf->def, "CheckLhs(1,1);\n"); /* Insert the order of output parameters*/ - Printf(getf->def,"\nint iOutNum=1;\nint iVarOut=Rhs+1;"); + Printf(getf->def, "\nint iOutNum=1;\nint iVarOut=Rhs+1;"); if ((tm = Swig_typemap_lookup("varout", n, name, 0))) { Replaceall(tm, "$result", name); - Replaceall(tm,"iRowsOut",rowname); - Replaceall(tm,"iColsOut",colname); - Replaceall(tm,"isComplex",iscomplexname); + Replaceall(tm, "iRowsOut", rowname); + Replaceall(tm, "iColsOut", colname); + Replaceall(tm, "isComplex", iscomplexname); addfail = emit_action_code(n, getf->code, tm); Delete(tm); } else { @@ -424,8 +424,16 @@ public: /*Dump the wrapper function */ Append(getf->code, "}\n"); Wrapper_print(getf, f_wrappers); - Printf(f_header,"%s",globalVar); - Printf(f_builder_code, "\"%s\",\"%s\";",getname,getname); + Printf(f_header,"%s", globalVar); + Printf(f_builder_code, "\"%s\",\"%s\";", getname, getname); + + Delete(rowname); + Delete(colname); + Delete(iscomplexname); + Delete(globalVar); + DelWrapper(setf); + DelWrapper(getf); + return SWIG_OK; } @@ -437,40 +445,42 @@ public: virtual int constantWrapper(Node *n) { /* set the flag so to generate the example.sce */ - hasconstant_flag=true; + hasconstant_flag = true; /* Get the useful information from the node */ String *iname = Getattr(n, "sym:name"); SwigType *type = Getattr(n, "type"); String *rawval = Getattr(n, "rawval"); String *value = rawval ? rawval : Getattr(n, "value"); - String *tempvalue=NewString(""); + String *tempvalue = NewString(""); /* set the value format to be the scilab format */ - if(!Strcmp(type,"char")){ - value=Getattr(n,"rawvalue"); - char *temp=(Char(value)); - tempvalue=NewString("ascii"); - Printf(tempvalue,"(%i)",(int)*temp); - value=Copy(tempvalue); + if(!Strcmp(type, "char")){ + value = Getattr(n, "rawvalue"); + char *temp = (Char(value)); + tempvalue = NewString("ascii"); + Printf(tempvalue, "(%i)", (int)*temp); + value = Copy(tempvalue); + Delete(tempvalue); } else{ - if(!Strcmp(type,"p.char")){ - char *temp=(Char(value)); - int len=strlen(temp); - for(int i=0;i