Built environment of test-suit and add two test-suit:enum, struct_rename
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11497 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
21671f7534
commit
b81ec23048
13 changed files with 160 additions and 30 deletions
|
|
@ -1,5 +1,5 @@
|
|||
// builder the *.so
|
||||
exec builder.sce;
|
||||
exec example_builder.sce;
|
||||
|
||||
// loader the *.so
|
||||
exec loader.sce;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// builder the *.so
|
||||
exec builder.sce;
|
||||
exec example_builder.sce;
|
||||
|
||||
// loader the *.so
|
||||
exec loader.sce;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// builder the *.so
|
||||
exec builder.sce;
|
||||
exec example_builder.sce;
|
||||
|
||||
// loader the *.so
|
||||
exec loader.sce;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// builder the *.so
|
||||
exec builder.sce
|
||||
exec example_builder.sce
|
||||
|
||||
// loader the *.so
|
||||
exec loader.sce
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// builder the *.so
|
||||
exec builder.sce
|
||||
exec example_builder.sce
|
||||
|
||||
// loader the *.so
|
||||
exec loader.sce
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// builder the *.so
|
||||
exec builder.sce;
|
||||
exec example_builder.sce;
|
||||
|
||||
// loader the *.so
|
||||
exec loader.sce;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// builder the *.so
|
||||
exec builder.sce
|
||||
exec example_builder.sce
|
||||
|
||||
//loader the *.so
|
||||
exec loader.sce
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
// builder the *.so
|
||||
exec builder.sce
|
||||
exec example_builder.sce
|
||||
|
||||
//loader the *.so
|
||||
exec loader.sce
|
||||
|
|
|
|||
40
Examples/test-suite/scilab/Makefile
Normal file
40
Examples/test-suite/scilab/Makefile
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#######################################################################
|
||||
# Makefile for scilab test-suite
|
||||
#######################################################################
|
||||
|
||||
LANGUAGE = scilab
|
||||
SCILAB = scilab
|
||||
SCRIPTSUFFIX = _runme.sci
|
||||
srcdir = .
|
||||
top_srcdir = ../../..
|
||||
top_builddir = ../../..
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
# none!
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
|
||||
%.ctest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_c)
|
||||
$(run_testcase)
|
||||
|
||||
%.multicpptest:
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.sci appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(SCILAB) -nwni < $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ; ) \
|
||||
fi; \
|
||||
|
||||
|
||||
# Clean: remove the generated .sci file
|
||||
%.clean:
|
||||
@rm -f $*.sci *_wrap.c
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile scilab_clean
|
||||
45
Examples/test-suite/scilab/Makefile.in
Normal file
45
Examples/test-suite/scilab/Makefile.in
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
#######################################################################
|
||||
# Makefile for scilab test-suite
|
||||
#######################################################################
|
||||
|
||||
LANGUAGE = scilab
|
||||
SCILAB = @SCILAB@
|
||||
SCRIPTSUFFIX = _runme.sci
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
C_TEST_CASES += \
|
||||
integers \
|
||||
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
# Overridden variables here
|
||||
# none!
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.ctest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_c)
|
||||
$(run_testcase)
|
||||
|
||||
%.multicpptest:
|
||||
$(setup)
|
||||
+$(swig_and_compile_multi_cpp)
|
||||
$(run_testcase)
|
||||
|
||||
# Runs the testcase. A testcase is only run if
|
||||
# a file is found which has _runme.sci appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then ( \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(SCILAB) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ; ) \
|
||||
fi; \
|
||||
|
||||
|
||||
# Clean: remove the generated .sci file
|
||||
%.clean:
|
||||
@rm -f $*.sci *_wrap.c
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile scilab_clean
|
||||
9
Examples/test-suite/scilab/enums_runme.sci
Normal file
9
Examples/test-suite/scilab/enums_runme.sci
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
exec enums_builder.sce
|
||||
exec loader.sce
|
||||
exec enums.sce
|
||||
|
||||
bar1(foo1.CSP_ITERATION_BWD)
|
||||
bar2(foo3.ABCDE)
|
||||
bar3(foo3.FGHJI)
|
||||
|
||||
exit
|
||||
8
Examples/test-suite/scilab/struct_rename_runme.sci
Normal file
8
Examples/test-suite/scilab/struct_rename_runme.sci
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
exec struct_rename_builder.sce
|
||||
exec loader.sce
|
||||
|
||||
a = new_Bar();
|
||||
Bar_x_set(100);
|
||||
Bar_x_get();
|
||||
|
||||
exit
|
||||
|
|
@ -116,7 +116,7 @@ public:
|
|||
if(hasfunction_flag) {
|
||||
Printf(f_builder_code,"];\n");
|
||||
Printf(f_builder_code,"ilib_build(ilib_name,table,files,libs);");
|
||||
File *f_builder=NewFile(NewStringf("%sbuilder.sce",SWIG_output_directory()),"w",SWIG_output_files());
|
||||
File *f_builder=NewFile(NewStringf("%s%s_builder.sce",SWIG_output_directory(),module),"w",SWIG_output_files());
|
||||
Printv(f_builder,f_builder_code,NIL);
|
||||
Close(f_builder);
|
||||
Delete(f_builder);
|
||||
|
|
@ -363,10 +363,10 @@ public:
|
|||
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);
|
||||
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\n", iscomplexname);
|
||||
else
|
||||
Printf(globalVar, "\n");
|
||||
Printv(setf->def, "int ", setname, " (char *fname,unsigned long fname_len) {\n", NIL);
|
||||
|
|
@ -381,6 +381,8 @@ public:
|
|||
/* deal with the set function */
|
||||
if (is_assignable(n)) {
|
||||
Setattr(n, "wrap:name", setname);
|
||||
if (Getattr(n, "unnamedinstance"))
|
||||
Setattr(n, "type", "int");
|
||||
if ((tm = Swig_typemap_lookup("varin", n, name, 0))) {
|
||||
Replaceall(tm, "$argnum", "1");
|
||||
Replaceall(tm, "iRows", rowname);
|
||||
|
|
@ -461,7 +463,7 @@ public:
|
|||
String *tempvalue = NewString("");
|
||||
|
||||
/* set the value format to be the scilab format */
|
||||
if(!Strcmp(type, "char")){
|
||||
if (!Strcmp(type, "char")) {
|
||||
value = Getattr(n, "rawvalue");
|
||||
char *temp = (Char(value));
|
||||
tempvalue = NewString("ascii");
|
||||
|
|
@ -469,12 +471,12 @@ public:
|
|||
value = Copy(tempvalue);
|
||||
Delete(tempvalue);
|
||||
}
|
||||
else{
|
||||
if(!Strcmp(type, "p.char")){
|
||||
else {
|
||||
if (!Strcmp(type, "p.char")) {
|
||||
char *temp = (Char(value));
|
||||
int len = strlen(temp);
|
||||
for(int i=0; i<len; ++i){
|
||||
if(temp[i] == '\\'){
|
||||
for (int i = 0; i < len; ++i) {
|
||||
if (temp[i] == '\\') {
|
||||
temp[i] = '"';
|
||||
++i;
|
||||
}
|
||||
|
|
@ -486,7 +488,7 @@ public:
|
|||
}
|
||||
|
||||
/* write into the code string */
|
||||
Printf(f_example_code, "example.%s = %s\n", iname, value);
|
||||
Printf(f_example_code, "%s = %s\n", iname, value);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -515,22 +517,49 @@ public:
|
|||
String *parentName = Getattr(parentNode(n), "sym:name");
|
||||
|
||||
/* set the name to be the enum.enumvalue format */
|
||||
String *temp = Copy(parentName);
|
||||
Printf(temp, ".%s", iname);
|
||||
Setattr(n, "sym:name", temp);
|
||||
|
||||
if (parentName) {
|
||||
/*if the enum has a name*/
|
||||
if(!Getattr(parentNode(n), "unnamedinstance")) {
|
||||
String *temp = Copy(parentName);
|
||||
Printf(temp, ".%s", iname);
|
||||
Setattr(n, "sym:name", temp);
|
||||
Delete(temp);
|
||||
iname = Getattr(n, "sym:name");
|
||||
}
|
||||
}
|
||||
|
||||
/* set the value attribute to be the integer */
|
||||
String *value;
|
||||
String *enumvalue = Getattr(n, "enumvalue");
|
||||
if(enumvalue) {
|
||||
Setattr(n, "value", enumvalue);
|
||||
if (enumvalue) {
|
||||
if (Len(enumvalue) == 1) {
|
||||
char *temp = (Char(enumvalue));
|
||||
/*set the value of char into the format of integer*/
|
||||
if (((*temp <= 'z') && (*temp >= 'a')) || ((*temp <= 'Z') && (*temp >= 'A'))) {
|
||||
String *tempInteger = NewString("");
|
||||
Printf(tempInteger, "%i", int(*temp));
|
||||
Setattr(n, "value", tempInteger);
|
||||
Delete(tempInteger);
|
||||
}
|
||||
else {
|
||||
Setattr(n, "value", enumvalue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Setattr(n, "value", enumvalue);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(n != firstChild(parentNode(n))) {
|
||||
if (n != firstChild(parentNode(n))) {
|
||||
enumvalue = Getattr(n, "enumvalueex");
|
||||
value = Copy(parentName);
|
||||
Printf(value, ".%s", enumvalue);
|
||||
Setattr(n, "value", value);
|
||||
if (parentName) {
|
||||
if (!Getattr(parentNode(n), "unnamedinstance")) {
|
||||
String *temp = Copy(parentName);
|
||||
Printf(temp, ".%s", enumvalue);
|
||||
enumvalue = Copy(temp);
|
||||
}
|
||||
}
|
||||
Setattr(n, "value", enumvalue);
|
||||
}
|
||||
else {
|
||||
Setattr(n, "value", Getattr(n, "enumvalueex"));
|
||||
|
|
@ -539,8 +568,7 @@ public:
|
|||
value = Getattr(n, "value");
|
||||
|
||||
/* write into the code string */
|
||||
Printf(f_example_code, "%s.%s = %s;\n", parentName, iname, value);
|
||||
|
||||
Printf(f_example_code, "%s = %s;\n", iname, value);
|
||||
return SWIG_OK;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue