summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Zeitlin <vz-swig@zeitlins.org>2015-02-16 23:46:39 +0100
committerVadim Zeitlin <vz-swig@zeitlins.org>2015-02-16 23:46:39 +0100
commit300ccce46c7a6f893d71a9614654c7c4e3e2d117 (patch)
treed7d5b2708afeb4507e4b530b6bd12f86c671d28f
parentb7160d92c9323fc6585c511f369c41e06e0c5865 (diff)
parent9842bada7c2009fdda73c61a15ddbaf6def658d3 (diff)
downloadswig-300ccce46c7a6f893d71a9614654c7c4e3e2d117.tar.gz
Another merge with master.
Change Doxygen error codes to start at 740 instead of at 720 as the latter was taken by Scilab in the meanwhile. Resolve conflicts in autodoc_runme.py once again.
-rw-r--r--.gitignore24
-rw-r--r--.travis.yml51
-rw-r--r--ANNOUNCE19
-rw-r--r--CHANGES209
-rw-r--r--CHANGES.current128
-rw-r--r--COPYRIGHT105
-rw-r--r--Doc/Manual/Contents.html74
-rw-r--r--Doc/Manual/Extending.html100
-rw-r--r--Doc/Manual/Go.html77
-rw-r--r--Doc/Manual/Introduction.html3
-rw-r--r--Doc/Manual/Php.html2
-rw-r--r--Doc/Manual/Preprocessor.html3
-rw-r--r--Doc/Manual/Python.html52
-rw-r--r--Doc/Manual/Ruby.html26
-rw-r--r--Doc/Manual/SWIG.html3
-rw-r--r--Doc/Manual/SWIGPlus.html60
-rw-r--r--Doc/Manual/Scilab.html2051
-rw-r--r--Doc/Manual/Sections.html3
-rw-r--r--Doc/Manual/Tcl.html92
-rw-r--r--Doc/Manual/Warnings.html4
-rw-r--r--Doc/Manual/chapters1
-rw-r--r--Examples/Makefile.in66
-rw-r--r--Examples/d/example.mk.in15
-rw-r--r--Examples/scilab/check.list16
-rw-r--r--Examples/scilab/class/Makefile15
-rw-r--r--Examples/scilab/class/example.cxx28
-rw-r--r--Examples/scilab/class/example.h34
-rw-r--r--Examples/scilab/class/example.i9
-rw-r--r--Examples/scilab/class/runme.sci52
-rw-r--r--Examples/scilab/constants/Makefile15
-rw-r--r--Examples/scilab/constants/example.i30
-rw-r--r--Examples/scilab/constants/runme.sci18
-rw-r--r--Examples/scilab/contract/Makefile15
-rw-r--r--Examples/scilab/contract/example.c23
-rw-r--r--Examples/scilab/contract/example.i21
-rw-r--r--Examples/scilab/contract/runme.sci46
-rw-r--r--Examples/scilab/enum/Makefile15
-rw-r--r--Examples/scilab/enum/example.cxx37
-rw-r--r--Examples/scilab/enum/example.h13
-rw-r--r--Examples/scilab/enum/example.i10
-rw-r--r--Examples/scilab/enum/runme.sci36
-rw-r--r--Examples/scilab/funcptr/Makefile15
-rw-r--r--Examples/scilab/funcptr/example.c19
-rw-r--r--Examples/scilab/funcptr/example.h9
-rw-r--r--Examples/scilab/funcptr/example.i11
-rw-r--r--Examples/scilab/funcptr/runme.sci22
-rw-r--r--Examples/scilab/matrix/Makefile15
-rw-r--r--Examples/scilab/matrix/example.c61
-rw-r--r--Examples/scilab/matrix/example.i36
-rw-r--r--Examples/scilab/matrix/runme.sci43
-rw-r--r--Examples/scilab/matrix2/Makefile15
-rw-r--r--Examples/scilab/matrix2/example.c118
-rwxr-xr-xExamples/scilab/matrix2/example.i26
-rw-r--r--Examples/scilab/matrix2/main.c24
-rw-r--r--Examples/scilab/matrix2/runme.sci51
-rw-r--r--Examples/scilab/pointer/Makefile15
-rw-r--r--Examples/scilab/pointer/example.c16
-rw-r--r--Examples/scilab/pointer/example.i30
-rw-r--r--Examples/scilab/pointer/runme.sci47
-rw-r--r--Examples/scilab/simple/Makefile15
-rw-r--r--Examples/scilab/simple/example.c18
-rw-r--r--Examples/scilab/simple/example.i7
-rw-r--r--Examples/scilab/simple/runme.sci29
-rw-r--r--Examples/scilab/std_list/Makefile15
-rw-r--r--Examples/scilab/std_list/example.cxx61
-rw-r--r--Examples/scilab/std_list/example.h14
-rw-r--r--Examples/scilab/std_list/example.i19
-rw-r--r--Examples/scilab/std_list/runme.sci39
-rw-r--r--Examples/scilab/std_vector/Makefile15
-rw-r--r--Examples/scilab/std_vector/example.h25
-rw-r--r--Examples/scilab/std_vector/example.i19
-rw-r--r--Examples/scilab/std_vector/runme.sci37
-rw-r--r--Examples/scilab/struct/Makefile15
-rw-r--r--Examples/scilab/struct/example.i11
-rw-r--r--Examples/scilab/struct/runme.sci18
-rw-r--r--Examples/scilab/template/Makefile15
-rw-r--r--Examples/scilab/template/example.h32
-rw-r--r--Examples/scilab/template/example.i17
-rw-r--r--Examples/scilab/template/runme.sci45
-rw-r--r--Examples/scilab/variables/Makefile15
-rw-r--r--Examples/scilab/variables/example.c95
-rw-r--r--Examples/scilab/variables/example.h6
-rw-r--r--Examples/scilab/variables/example.i52
-rw-r--r--Examples/scilab/variables/runme.sci73
-rw-r--r--Examples/test-suite/allprotected.i5
-rw-r--r--Examples/test-suite/apply_signed_char.i4
-rw-r--r--Examples/test-suite/apply_strings.i13
-rw-r--r--Examples/test-suite/array_member.i4
-rw-r--r--Examples/test-suite/array_typedef_memberin.i5
-rw-r--r--Examples/test-suite/arrays.i4
-rw-r--r--Examples/test-suite/bloody_hell.i14
-rw-r--r--Examples/test-suite/bools.i5
-rw-r--r--Examples/test-suite/callback.i16
-rw-r--r--Examples/test-suite/char_strings.i4
-rw-r--r--Examples/test-suite/common.mk4
-rw-r--r--Examples/test-suite/constant_directive.i28
-rw-r--r--Examples/test-suite/constant_pointers.i5
-rw-r--r--Examples/test-suite/constructor_copy.i18
-rw-r--r--Examples/test-suite/constructor_exception.i6
-rw-r--r--Examples/test-suite/conversion_ns_template.i4
-rw-r--r--Examples/test-suite/cpp11_constexpr.i6
-rw-r--r--Examples/test-suite/cpp11_director_enums.i14
-rw-r--r--Examples/test-suite/csharp_exceptions.i2
-rw-r--r--Examples/test-suite/csharp_typemaps.i6
-rw-r--r--Examples/test-suite/default_args.i28
-rw-r--r--Examples/test-suite/director_frob.i14
-rw-r--r--Examples/test-suite/director_overload2.i8
-rw-r--r--Examples/test-suite/director_property.i6
-rw-r--r--Examples/test-suite/enum_forward.i24
-rw-r--r--Examples/test-suite/enum_macro.i7
-rw-r--r--Examples/test-suite/enum_missing.i6
-rw-r--r--Examples/test-suite/errors/.gitignore4
-rw-r--r--Examples/test-suite/errors/c_extra_rblock.stderr2
-rw-r--r--Examples/test-suite/errors/c_missing_semi.stderr2
-rw-r--r--Examples/test-suite/errors/cpp_extra_brackets.stderr2
-rw-r--r--Examples/test-suite/errors/doxygen_unknown_command.stderr2
-rw-r--r--Examples/test-suite/errors/pp_missing_enddef.stderr2
-rw-r--r--Examples/test-suite/errors/pp_missing_endif.stderr2
-rw-r--r--Examples/test-suite/errors/pp_missing_endoffile.i7
-rw-r--r--Examples/test-suite/errors/pp_missing_endoffile.stderr1
-rw-r--r--Examples/test-suite/errors/pp_missing_rblock.stderr2
-rw-r--r--Examples/test-suite/errors/pp_unknowndirective.i7
-rw-r--r--Examples/test-suite/errors/pp_unknowndirective.stderr1
-rw-r--r--Examples/test-suite/errors/pp_unknowndirective2.i11
-rw-r--r--Examples/test-suite/errors/pp_unknowndirective2.stderr1
-rw-r--r--Examples/test-suite/errors/pp_unterm_char.stderr2
-rw-r--r--Examples/test-suite/errors/pp_unterm_comment.stderr2
-rw-r--r--Examples/test-suite/errors/pp_unterm_string.stderr2
-rw-r--r--Examples/test-suite/errors/pp_unterminated_block.i5
-rw-r--r--Examples/test-suite/errors/pp_unterminated_block.stderr1
-rw-r--r--Examples/test-suite/extend_special_variables.i5
-rw-r--r--Examples/test-suite/go/contract_runme.go4
-rw-r--r--Examples/test-suite/java/constant_directive_runme.java22
-rw-r--r--Examples/test-suite/java/nested_template_base_runme.java27
-rw-r--r--Examples/test-suite/java/preproc_line_file_runme.java2
-rw-r--r--Examples/test-suite/java/smart_pointer_const_overload_runme.java2
-rw-r--r--Examples/test-suite/java/template_default_class_parms_runme.java5
-rw-r--r--Examples/test-suite/javascript/Makefile.in6
-rw-r--r--Examples/test-suite/kwargs_feature.i4
-rw-r--r--Examples/test-suite/li_attribute_template.i28
-rw-r--r--Examples/test-suite/li_boost_shared_ptr.i36
-rw-r--r--Examples/test-suite/li_std_auto_ptr.i2
-rw-r--r--Examples/test-suite/li_std_combinations.i12
-rw-r--r--Examples/test-suite/li_std_container_typemaps.i132
-rw-r--r--Examples/test-suite/li_std_string.i10
-rw-r--r--Examples/test-suite/li_std_vector_extra.i11
-rw-r--r--Examples/test-suite/li_stdint.i6
-rw-r--r--Examples/test-suite/li_swigtype_inout.i12
-rw-r--r--Examples/test-suite/nested.i55
-rw-r--r--Examples/test-suite/nested_class.i40
-rw-r--r--Examples/test-suite/nested_extend_c.i2
-rw-r--r--Examples/test-suite/nested_scope.i29
-rw-r--r--Examples/test-suite/nested_template_base.i38
-rw-r--r--Examples/test-suite/octave/li_boost_shared_ptr_runme.m566
-rw-r--r--Examples/test-suite/operator_overload.i7
-rw-r--r--Examples/test-suite/overload_arrays.i148
-rw-r--r--Examples/test-suite/php/director_exception_runme.php2
-rw-r--r--Examples/test-suite/php/director_thread_runme.php3
-rw-r--r--Examples/test-suite/php/exception_order_runme.php2
-rw-r--r--Examples/test-suite/php/import_nomodule_runme.php2
-rw-r--r--Examples/test-suite/php/threads_exception_runme.php4
-rw-r--r--Examples/test-suite/preproc.i28
-rw-r--r--Examples/test-suite/preproc_constants.i8
-rw-r--r--Examples/test-suite/preproc_line_file.i4
-rw-r--r--Examples/test-suite/primitive_types.i21
-rw-r--r--Examples/test-suite/python/Makefile.in5
-rw-r--r--Examples/test-suite/python/autodoc_runme.py7
-rw-r--r--Examples/test-suite/python/constant_directive_runme.py15
-rw-r--r--Examples/test-suite/python/cpp_static_runme.py15
-rw-r--r--Examples/test-suite/python/default_args_runme.py163
-rw-r--r--Examples/test-suite/python/director_abstract_runme.py15
-rw-r--r--Examples/test-suite/python/global_namespace_runme.py39
-rw-r--r--Examples/test-suite/python/implicittest_runme.py15
-rw-r--r--Examples/test-suite/python/kwargs_feature_runme.py16
-rw-r--r--Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py8
-rw-r--r--Examples/test-suite/python/li_boost_shared_ptr_runme.py2
-rw-r--r--Examples/test-suite/python/li_std_auto_ptr_runme.py6
-rw-r--r--Examples/test-suite/python/namespace_class_runme.py15
-rw-r--r--Examples/test-suite/python/nested_template_base_runme.py13
-rw-r--r--Examples/test-suite/python/overload_template_fast_runme.py9
-rw-r--r--Examples/test-suite/python/preproc_runme.py2
-rw-r--r--Examples/test-suite/python/python_append_runme.py8
-rw-r--r--Examples/test-suite/python/refcount_runme.py6
-rw-r--r--Examples/test-suite/python/return_const_value_runme.py4
-rw-r--r--Examples/test-suite/python/smart_pointer_const_overload_runme.py2
-rw-r--r--Examples/test-suite/python/smart_pointer_member_runme.py8
-rw-r--r--Examples/test-suite/python/typemap_out_optimal_runme.py2
-rw-r--r--Examples/test-suite/rename.h14
-rw-r--r--Examples/test-suite/rename4.i12
-rw-r--r--Examples/test-suite/scilab/Makefile.in90
-rw-r--r--Examples/test-suite/scilab/abstract_access_runme.sci16
-rw-r--r--Examples/test-suite/scilab/abstract_inherit_ok_runme.sci11
-rw-r--r--Examples/test-suite/scilab/abstract_inherit_runme.sci10
-rw-r--r--Examples/test-suite/scilab/abstract_signature_runme.sci10
-rw-r--r--Examples/test-suite/scilab/abstract_typedef2_runme.sci15
-rw-r--r--Examples/test-suite/scilab/abstract_typedef_runme.sci17
-rw-r--r--Examples/test-suite/scilab/abstract_virtual_runme.sci27
-rw-r--r--Examples/test-suite/scilab/access_change_runme.sci39
-rw-r--r--Examples/test-suite/scilab/add_link_runme.sci27
-rw-r--r--Examples/test-suite/scilab/aggregate_runme.sci21
-rw-r--r--Examples/test-suite/scilab/allowexcept_runme.sci5
-rw-r--r--Examples/test-suite/scilab/allprotected_runme.sci80
-rw-r--r--Examples/test-suite/scilab/anonymous_bitfield_runme.sci60
-rw-r--r--Examples/test-suite/scilab/apply_signed_char_runme.sci43
-rw-r--r--Examples/test-suite/scilab/apply_strings_runme.sci45
-rw-r--r--Examples/test-suite/scilab/array_member_runme.sci16
-rw-r--r--Examples/test-suite/scilab/arrays_dimensionless_runme.sci55
-rw-r--r--Examples/test-suite/scilab/arrays_global_runme.sci54
-rw-r--r--Examples/test-suite/scilab/arrays_global_twodim_runme.sci12
-rw-r--r--Examples/test-suite/scilab/bools_runme.sci20
-rw-r--r--Examples/test-suite/scilab/char_constant_runme.sci9
-rw-r--r--Examples/test-suite/scilab/constover_runme.sci22
-rw-r--r--Examples/test-suite/scilab/constructor_copy_runme.sci36
-rw-r--r--Examples/test-suite/scilab/cpp_basic_runme.sci64
-rw-r--r--Examples/test-suite/scilab/cpp_enum_runme.sci10
-rw-r--r--Examples/test-suite/scilab/default_args_runme.sci67
-rw-r--r--Examples/test-suite/scilab/default_constructor_runme.sci113
-rw-r--r--Examples/test-suite/scilab/empty_runme.sci3
-rw-r--r--Examples/test-suite/scilab/enums_runme.sci39
-rw-r--r--Examples/test-suite/scilab/funcptr_cpp_runme.sci7
-rw-r--r--Examples/test-suite/scilab/funcptr_runme.sci6
-rw-r--r--Examples/test-suite/scilab/global_vars_runme.sci31
-rw-r--r--Examples/test-suite/scilab/inctest_runme.sci20
-rw-r--r--Examples/test-suite/scilab/inherit_missing_runme.sci15
-rw-r--r--Examples/test-suite/scilab/inout_runme.sci15
-rw-r--r--Examples/test-suite/scilab/integers_runme.sci29
-rw-r--r--Examples/test-suite/scilab/li_carrays_runme.sci11
-rw-r--r--Examples/test-suite/scilab/li_cpointer_runme.sci8
-rw-r--r--Examples/test-suite/scilab/li_math_runme.sci9
-rw-r--r--Examples/test-suite/scilab/li_std_container_typemaps_runme.sci108
-rw-r--r--Examples/test-suite/scilab/li_std_deque_runme.sci49
-rw-r--r--Examples/test-suite/scilab/li_std_except_runme.sci33
-rw-r--r--Examples/test-suite/scilab/li_std_pair_runme.sci38
-rw-r--r--Examples/test-suite/scilab/li_std_string_extra_runme.sci58
-rw-r--r--Examples/test-suite/scilab/li_std_vector_runme.sci12
-rw-r--r--Examples/test-suite/scilab/li_typemaps_runme.sci116
-rw-r--r--Examples/test-suite/scilab/member_pointer_runme.sci20
-rw-r--r--Examples/test-suite/scilab/name_runme.sci11
-rw-r--r--Examples/test-suite/scilab/nested_structs_runme.sci34
-rw-r--r--Examples/test-suite/scilab/newobject2_runme.sci31
-rw-r--r--Examples/test-suite/scilab/null_pointer_runme.sci7
-rw-r--r--Examples/test-suite/scilab/operator_overload_runme.sci82
-rw-r--r--Examples/test-suite/scilab/overload_arrays_runme.sci46
-rw-r--r--Examples/test-suite/scilab/overload_complicated_runme.sci25
-rw-r--r--Examples/test-suite/scilab/overload_copy_runme.sci10
-rw-r--r--Examples/test-suite/scilab/overload_extend_runme.sci13
-rw-r--r--Examples/test-suite/scilab/overload_extendc_runme.sci15
-rw-r--r--Examples/test-suite/scilab/overload_numeric_runme.sci16
-rw-r--r--Examples/test-suite/scilab/overload_simple_runme.sci73
-rw-r--r--Examples/test-suite/scilab/preproc_constants_runme.sci30
-rw-r--r--Examples/test-suite/scilab/preproc_runme.sci8
-rw-r--r--Examples/test-suite/scilab/primitive_ref_runme.sci24
-rw-r--r--Examples/test-suite/scilab/primitive_types_runme.sci57
-rw-r--r--Examples/test-suite/scilab/ret_by_value_runme.sci28
-rw-r--r--Examples/test-suite/scilab/return_const_value_runme.sci11
-rw-r--r--Examples/test-suite/scilab/scilab_consts_runme.sci35
-rw-r--r--Examples/test-suite/scilab/scilab_enums_runme.sci27
-rw-r--r--Examples/test-suite/scilab/scilab_identifier_name_runme.sci29
-rw-r--r--Examples/test-suite/scilab/scilab_li_matrix_runme.sci67
-rw-r--r--Examples/test-suite/scilab/scilab_multivalue_runme.sci87
-rw-r--r--Examples/test-suite/scilab/scilab_pointer_conversion_functions_runme.sci18
-rw-r--r--Examples/test-suite/scilab/simple_array_runme.sci12
-rw-r--r--Examples/test-suite/scilab/sizet_runme.sci11
-rw-r--r--Examples/test-suite/scilab/smart_pointer_simple_runme.sci13
-rw-r--r--Examples/test-suite/scilab/sneaky1_runme.sci31
-rw-r--r--Examples/test-suite/scilab/struct_initialization_runme.sci15
-rw-r--r--Examples/test-suite/scilab/struct_rename_runme.sci11
-rw-r--r--Examples/test-suite/scilab/struct_value_runme.sci16
-rw-r--r--Examples/test-suite/scilab/swigtest.quit2
-rw-r--r--Examples/test-suite/scilab/swigtest.start57
-rw-r--r--Examples/test-suite/scilab/template_classes_runme.sci8
-rw-r--r--Examples/test-suite/scilab/template_ns_runme.sci15
-rw-r--r--Examples/test-suite/scilab/template_rename_runme.sci15
-rw-r--r--Examples/test-suite/scilab/template_static_runme.sci8
-rw-r--r--Examples/test-suite/scilab/throw_exception_runme.sci23
-rw-r--r--Examples/test-suite/scilab/typedef_struct_runme.sci29
-rw-r--r--Examples/test-suite/scilab/union_parameter_runme.sci35
-rw-r--r--Examples/test-suite/scilab/unions_runme.sci23
-rw-r--r--Examples/test-suite/scilab/varargs_overload_runme.sci21
-rw-r--r--Examples/test-suite/scilab/varargs_runme.sci17
-rw-r--r--Examples/test-suite/scilab/voidtest_runme.sci22
-rw-r--r--Examples/test-suite/scilab_consts.i52
-rw-r--r--Examples/test-suite/scilab_enums.i38
-rw-r--r--Examples/test-suite/scilab_identifier_name.i53
-rw-r--r--Examples/test-suite/scilab_li_matrix.i161
-rw-r--r--Examples/test-suite/scilab_multivalue.i123
-rw-r--r--Examples/test-suite/scilab_pointer_conversion_functions.i18
-rw-r--r--Examples/test-suite/sizeof_pointer.i5
-rw-r--r--Examples/test-suite/smart_pointer_const_overload.i2
-rw-r--r--Examples/test-suite/template_default_class_parms.i46
-rw-r--r--Examples/test-suite/template_nested.i13
-rw-r--r--Examples/test-suite/template_template_parameters.i6
-rw-r--r--Examples/test-suite/throw_exception.i32
-rw-r--r--Examples/test-suite/typemap_array_qualifiers.i6
-rw-r--r--Examples/test-suite/typemap_variables.i13
-rw-r--r--Examples/test-suite/unions.i10
-rw-r--r--Examples/test-suite/varargs_overload.i2
-rw-r--r--Examples/test-suite/voidtest.i2
-rw-r--r--Lib/csharp/enums.swg4
-rw-r--r--Lib/csharp/enumsimple.swg4
-rw-r--r--Lib/csharp/enumtypesafe.swg4
-rw-r--r--Lib/d/dhead.swg2
-rw-r--r--Lib/go/cdata.i45
-rw-r--r--Lib/go/go.swg190
-rw-r--r--Lib/go/goruntime.swg75
-rw-r--r--Lib/go/gostring.swg29
-rw-r--r--Lib/go/std_string.i28
-rw-r--r--Lib/go/typemaps.i6
-rw-r--r--Lib/java/java.swg4
-rw-r--r--Lib/javascript/jsc/javascriptcode.swg3
-rw-r--r--Lib/javascript/jsc/javascriptprimtypes.swg6
-rw-r--r--Lib/javascript/jsc/javascriptstrings.swg3
-rw-r--r--Lib/lua/lua.swg3
-rw-r--r--Lib/lua/luarun.swg8
-rw-r--r--Lib/octave/boost_shared_ptr.i6
-rw-r--r--Lib/octave/octrun.swg41
-rw-r--r--Lib/octave/std_shared_ptr.i2
-rw-r--r--Lib/perl5/perlinit.swg2
-rw-r--r--Lib/php/director.swg3
-rw-r--r--Lib/pointer.i2
-rw-r--r--Lib/python/pyinit.swg3
-rw-r--r--Lib/python/pyuserdir.swg1
-rw-r--r--Lib/scilab/boost_shared_ptr.i318
-rw-r--r--Lib/scilab/carrays.i5
-rw-r--r--Lib/scilab/cmalloc.i1
-rw-r--r--Lib/scilab/cpointer.i1
-rw-r--r--Lib/scilab/exception.i6
-rw-r--r--Lib/scilab/matrix.i11
-rw-r--r--Lib/scilab/sciarray.swg115
-rw-r--r--Lib/scilab/scibool.swg157
-rw-r--r--Lib/scilab/scichar.swg285
-rw-r--r--Lib/scilab/scicontainer.swg445
-rw-r--r--Lib/scilab/scidouble.swg108
-rw-r--r--Lib/scilab/scienum.swg31
-rw-r--r--Lib/scilab/sciexception.swg60
-rw-r--r--Lib/scilab/scifloat.swg83
-rw-r--r--Lib/scilab/sciint.swg202
-rw-r--r--Lib/scilab/sciiterators.swg363
-rw-r--r--Lib/scilab/scilab.swg6
-rw-r--r--Lib/scilab/scilist.swg91
-rw-r--r--Lib/scilab/scilong.swg123
-rw-r--r--Lib/scilab/scilonglong.swg54
-rw-r--r--Lib/scilab/scimacros.swg5
-rw-r--r--Lib/scilab/scimatrixbool.swg170
-rw-r--r--Lib/scilab/scimatrixchar.swg199
-rw-r--r--Lib/scilab/scimatrixdouble.swg170
-rw-r--r--Lib/scilab/scimatrixint.swg175
-rw-r--r--Lib/scilab/scimisctypes.swg69
-rw-r--r--Lib/scilab/scipointer.swg32
-rw-r--r--Lib/scilab/sciprimtypes.swg23
-rw-r--r--Lib/scilab/scirun.swg318
-rw-r--r--Lib/scilab/sciruntime.swg33
-rw-r--r--Lib/scilab/scisequence.swg195
-rw-r--r--Lib/scilab/scisequencebool.swg98
-rw-r--r--Lib/scilab/scisequencedouble.swg99
-rw-r--r--Lib/scilab/scisequencefloat.swg98
-rw-r--r--Lib/scilab/scisequenceint.swg104
-rw-r--r--Lib/scilab/scisequencepointer.swg123
-rw-r--r--Lib/scilab/scisequencestring.swg97
-rw-r--r--Lib/scilab/scishort.swg188
-rw-r--r--Lib/scilab/scisignedchar.swg185
-rw-r--r--Lib/scilab/scistdcommon.swg226
-rw-r--r--Lib/scilab/scitypemaps.swg243
-rw-r--r--Lib/scilab/sciunsignedchar.swg190
-rw-r--r--Lib/scilab/sciunsignedint.swg204
-rw-r--r--Lib/scilab/sciunsignedlong.swg53
-rw-r--r--Lib/scilab/sciunsignedshort.swg189
-rw-r--r--Lib/scilab/std_alloc.i2
-rw-r--r--Lib/scilab/std_basic_string.i47
-rw-r--r--Lib/scilab/std_char_traits.i1
-rw-r--r--Lib/scilab/std_common.i72
-rw-r--r--Lib/scilab/std_container.i3
-rw-r--r--Lib/scilab/std_deque.i31
-rw-r--r--Lib/scilab/std_except.i1
-rw-r--r--Lib/scilab/std_list.i30
-rw-r--r--Lib/scilab/std_map.i69
-rw-r--r--Lib/scilab/std_multiset.i30
-rw-r--r--Lib/scilab/std_pair.i34
-rw-r--r--Lib/scilab/std_set.i32
-rw-r--r--Lib/scilab/std_string.i39
-rw-r--r--Lib/scilab/std_vector.i31
-rw-r--r--Lib/scilab/stl.i6
-rw-r--r--Lib/scilab/typemaps.i62
-rw-r--r--Lib/swigarch.i4
-rw-r--r--Lib/swiginit.swg12
-rw-r--r--Lib/swiglabels.swg4
-rw-r--r--Lib/typemaps/strings.swg2
-rw-r--r--Makefile.in12
-rw-r--r--README10
-rw-r--r--RELEASENOTES14
-rw-r--r--Source/CParse/cparse.h1
-rw-r--r--Source/CParse/cscanner.c11
-rw-r--r--Source/CParse/parser.y18
-rw-r--r--Source/Include/swigwarn.h16
-rw-r--r--Source/Makefile.am1
-rw-r--r--Source/Modules/csharp.cxx11
-rw-r--r--Source/Modules/d.cxx11
-rw-r--r--Source/Modules/go.cxx769
-rw-r--r--Source/Modules/guile.cxx20
-rw-r--r--Source/Modules/java.cxx13
-rw-r--r--Source/Modules/javascript.cxx1
-rw-r--r--Source/Modules/main.cxx25
-rw-r--r--Source/Modules/modula3.cxx13
-rw-r--r--Source/Modules/ocaml.cxx3
-rw-r--r--Source/Modules/octave.cxx31
-rw-r--r--Source/Modules/perl5.cxx4
-rw-r--r--Source/Modules/php.cxx90
-rw-r--r--Source/Modules/python.cxx205
-rw-r--r--Source/Modules/scilab.cxx1122
-rw-r--r--Source/Modules/swigmain.cxx7
-rw-r--r--Source/Preprocessor/cpp.c18
-rw-r--r--Source/Swig/cwrap.c9
-rw-r--r--Source/Swig/scanner.c3
-rw-r--r--Source/Swig/symbol.c12
-rw-r--r--Tools/javascript/Makefile.in4
-rwxr-xr-xTools/obs-buildlogs.py34
-rw-r--r--configure.ac273
-rwxr-xr-xpreinst-swig.in2
-rwxr-xr-xtestflags.py52
419 files changed, 18684 insertions, 1324 deletions
diff --git a/.gitignore b/.gitignore
index a1b9d5e94..400ce4469 100644
--- a/.gitignore
+++ b/.gitignore
@@ -67,6 +67,7 @@ CCache/config.h
CCache/config.log
CCache/config.status
Examples/Makefile
+Examples/d/example.mk
Examples/guile/Makefile
Examples/test-suite/*/Makefile
Examples/xml/Makefile
@@ -121,16 +122,29 @@ Examples/test-suite/pike/*/
Examples/test-suite/python/*/
Examples/test-suite/r/*/
Examples/test-suite/ruby/*/
+Examples/test-suite/scilab/*/
Examples/test-suite/tcl/*/
Examples/test-suite/uffi/*/
*_wrap.c
*_wrap.cxx
*-gypcopy.cxx
+# Scratch directories
+Examples/scratch
+
+# Out of source tree build directories
+*build*/
+
+########## Language specific files ##########
+
# C# generated files
*_runme.exe.mdb
*_runme.exe
+# Go generated files
+*.[5689]
+*_gc.c
+
# Javascript generated files
*.gyp
@@ -144,12 +158,6 @@ Examples/test-suite/octave/*.oct
*/__pycache__/
/__pycache__/
-# Go generated files
-*.[5689]
-*_gc.c
+# Scilab generated files
+loader.sce
-# Scratch directories
-Examples/scratch
-
-# Out of source tree build directories
-*build*/
diff --git a/.travis.yml b/.travis.yml
index 65008f623..8d814e7f8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -51,11 +51,20 @@ matrix:
- compiler: gcc
env: SWIGLANG=python SWIG_FEATURES=-builtin PY3=3
- compiler: gcc
+ env: SWIGLANG=python SWIG_FEATURES=-classic
+ - compiler: gcc
env: SWIGLANG=ruby
- compiler: gcc
+ env: SWIGLANG=scilab
+ - compiler: gcc
env: SWIGLANG=tcl
allow_failures:
- # None
+ # Occasional gcc internal compiler error
+ - compiler: gcc
+ env: SWIGLANG=octave SWIGJOBS=-j3 VER=3.8
+ # Not quite working yet
+ - compiler: gcc
+ env: SWIGLANG=python SWIG_FEATURES=-classic
before_install:
- date -u
- uname -a
@@ -77,40 +86,13 @@ before_install:
- if test "$SWIGLANG" = "python"; then git clone https://github.com/jcrocholl/pep8.git && pushd pep8 && git checkout tags/1.5.7 && python ./setup.py build && sudo python ./setup.py install && popd; fi
- if test "$SWIGLANG" = "python" -a "$PY3" -a -z "$VER"; then sudo apt-get install -qq python3-dev; fi
- if test "$SWIGLANG" = "python" -a "$VER"; then sudo add-apt-repository -y ppa:fkrull/deadsnakes && sudo apt-get -qq update && sudo apt-get -qq install python${VER}-dev && export CONFIGOPTS="--with-python${PY3}=python${VER}"; fi
+ - if test "$SWIGLANG" = "scilab"; then sudo apt-get -qq install scilab; fi
- if test "$SWIGLANG" = "tcl"; then sudo apt-get -qq install tcl8.4-dev; fi
- # Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic.
- - declare -A CFLAGS_EXAMPLES && CFLAGS_EXAMPLES=(
- ["csharp"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["d"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["go"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["guile"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["java"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["javascript"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["lua"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["octave"]="-Werror -std=gnu89 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["perl5"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["php"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["python"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["ruby"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["tcl"]="-Werror -std=gnu89 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- )
- - declare -A CXXFLAGS_EXAMPLES && CXXFLAGS_EXAMPLES=(
- ["csharp"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["d"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["go"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["guile"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["java"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["javascript"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["lua"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["octave"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["perl5"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- ["php"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["python"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["ruby"]="-Werror -std=c++98 -fdiagnostics-show-option -pedantic -Wno-long-long -Wreturn-type"
- ["tcl"]="-Werror -std=c++98 -fdiagnostics-show-option -Wno-long-long -Wreturn-type"
- )
- $CC --version
- $CXX --version
+ # Stricter compile flags for examples. Various headers and SWIG generated code prevents full use of -pedantic.
+ - export cflags=$(./testflags.py --language $SWIGLANG --cflags) && echo $cflags
+ - export cxxflags=$(./testflags.py --language $SWIGLANG --cxxflags) && echo $cxxflags
script:
- echo 'Configuring...' && echo -en 'travis_fold:start:script.1\\r'
- ./autogen.sh && mkdir -p build/build && cd build/build && ../../configure $CONFIGOPTS
@@ -123,11 +105,12 @@ script:
- if test -z "$SWIGLANG"; then sudo make -s install && swig -version && ccache-swig -V; fi
- echo -en 'travis_fold:end:script.2\\r'
- if test -n "$SWIGLANG"; then make -s check-$SWIGLANG-version; fi
- - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-examples CFLAGS="${CFLAGS_EXAMPLES[$SWIGLANG]}" CXXFLAGS="${CXXFLAGS_EXAMPLES[$SWIGLANG]}"; fi
- - if test -n "$SWIGLANG"; then make -k $SWIGJOBS check-$SWIGLANG-test-suite; fi
+ - if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-examples CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi
+ - if test -n "$SWIGLANG"; then make $SWIGJOBS check-$SWIGLANG-test-suite CFLAGS="$cflags" CXXFLAGS="$cxxflags"; fi
- echo 'Cleaning...' && echo -en 'travis_fold:start:script.3\\r'
- make check-maintainer-clean && ../../configure $CONFIGOPTS
- echo -en 'travis_fold:end:script.3\\r'
branches:
only:
- master
+ - error-declaration-after-statement
diff --git a/ANNOUNCE b/ANNOUNCE
index 95261b2bd..96b1904ac 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,8 +1,8 @@
-*** ANNOUNCE: SWIG 3.0.3 (in progress) ***
+*** ANNOUNCE: SWIG 3.0.6 (in progress) ***
http://www.swig.org
-We're pleased to announce SWIG-3.0.3, the latest SWIG release.
+We're pleased to announce SWIG-3.0.6, the latest SWIG release.
What is SWIG?
=============
@@ -11,21 +11,22 @@ SWIG is a software development tool that reads C/C++ header files and
generates the wrapper code needed to make C and C++ code accessible
from other programming languages including Perl, Python, Tcl, Ruby,
PHP, C#, Go, Java, Javascript, Lua, Scheme (Guile, MzScheme, CHICKEN),
-D, Ocaml, Pike, Modula-3, Octave, R, Common Lisp (CLISP, Allegro CL,
-CFFI, UFFI). SWIG can also export its parse tree in the form of XML
-and Lisp s-expressions. Major applications of SWIG include generation
-of scripting language extension modules, rapid prototyping, testing,
-and user interface development for large C/C++ systems.
+D, Ocaml, Pike, Modula-3, Octave, R, Scilab, Common Lisp (CLISP,
+Allegro CL, CFFI, UFFI). SWIG can also export its parse tree in
+the form of XML and Lisp s-expressions. Major applications of SWIG
+include generation of scripting language extension modules, rapid
+prototyping, testing, and user interface development for large
+C/C++ systems.
Availability
============
The release is available for download on Sourceforge at
- http://prdownloads.sourceforge.net/swig/swig-3.0.3.tar.gz
+ http://prdownloads.sourceforge.net/swig/swig-3.0.6.tar.gz
A Windows version is also available at
- http://prdownloads.sourceforge.net/swig/swigwin-3.0.3.zip
+ http://prdownloads.sourceforge.net/swig/swigwin-3.0.6.zip
Please report problems with this release to the swig-devel mailing list,
details at http://www.swig.org/mail.html.
diff --git a/CHANGES b/CHANGES
index 33b2b5942..8bea8c1c2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,211 @@ SWIG (Simplified Wrapper and Interface Generator)
See the CHANGES.current file for changes in the current version.
See the RELEASENOTES file for a summary of changes in each release.
+Version 3.0.5 (31 Jan 2015)
+===========================
+
+2015-01-30: wsfulton
+ [Python] Fix Python -classic and property setting. Setting properties on classic classes
+ was broken in swig-3.0.3 by attempting to use __setattr__. This regression is fixed now
+ by using __dict__ again when using -classic.
+ Fixes patch #232.
+
+2015-01-27: smarchetto
+ [Scilab] Support for the Scilab language has been added
+
+2015-01-23: olly
+ [PHP] When wrapping a returned resource as an object, check if all
+ cases wrap it in the same class, and if so eliminate the pointless
+ switch statement wrapper we previously generated.
+
+2015-01-22: wsfulton
+ [Octave] Merge patch #297 for SF bug #1277 - Octave shared_ptr support
+
+2015-01-15: wsfulton
+ [Python] Merge patch #250 - Fixes for using %constant and objects (non-primitive types)
+
+2015-01-15: wsfulton
+ [C# Go] Merge patch #308 and fix #307 - C++11 strongly typed enum support
+ in directors
+
+2015-01-15: wsfulton
+ [Python] Second fix for #294 #296 - Regression introduced in SWIG-3.0.3 when
+ wrapping functions with default arguments, this time when using kwargs.
+
+Version 3.0.4 (14 Jan 2015)
+===========================
+
+2015-01-12: olly
+ [PHP] Fix segfault in director upcall check when using PHP built with
+ ZTS enabled. Fixes #155, reported by Pierre Labastie.
+
+2015-01-12: vadz
+ [Python] Fix #294 #296 - Regression introduced in SWIG-3.0.3 when
+ wrapping functions with default arguments. Invalid or missing default
+ arguments were sometimes being generated into the python layer.
+
+2015-01-08: olly
+ Allow C++11 "explicit constexpr". Fixes github issue #284 reported
+ by Pawel Tomulik. Also handle "constexpr explicit" and "constexpr
+ static".
+
+2015-01-08: olly
+ When reporting an error for a construct which hasn't been
+ terminated when the end of the file is reached, report it at the
+ start line rather than "EOF" as then tools like editors and IDEs
+ will take you to a generally more useful place for fixing the
+ problem.
+
+2015-01-08: olly
+ Improve error messages for a few cases which previously gave the
+ one of the cryptic catch-all errors "Syntax error in input".
+
+2015-01-08: olly
+ Provide -cppext as a general command line option for setting the
+ extension used for generated C++ files (previously it was specific
+ to the PHP backend). Deprecate the equivalent -suffix option
+ provided by the Ocaml backend, but continue to support that for
+ now.
+
+Version 3.0.3 (30 Dec 2014)
+===========================
+
+2014-12-27: wsfulton
+ Fix #280 - abort using all default template parameters within other template
+ parameters.
+
+2014-12-27: talby
+ [Perl] Issue #282 perl5 archlib vs archlibexp
+ [Perl] tidy "warning: duplicate 'extern' declaration specifier" when building generated code
+ under clang
+
+2014-12-18: wsfulton
+ Add support for %constant and structs/classes - issue #272
+
+2014-12-09: wsfulton
+ Fix #245 - regression (since swig-3.0.0) in templated constructors.
+ Templated constructors could not be instantiated - they were incorrectly ignored with a warning 504:
+ "Function: xyz must have a return type. Ignored."
+
+2014-12-07: wsfulton
+ Add support for C++11 strongly typed enumerations.
+
+2014-11-21: wsfulton
+ [Java C#] Fix multiply defined error when using %rename of enum items when using the "simple enum"
+ wrappers.
+
+2014-10-28: vadz
+ [Python] Patch #201 The generated .py file no longer uses *args for all Python parameters.
+ Instead, the parameters are named using the C++ parameter names.
+
+2014-10-24: timotheecour
+ [D] Patch #204 Use core.atomic.atomicOp to mutate shared variables
+
+2014-10-21: wsfulton
+ Fix issue #242 - Use of the "kwargs" feature no longer automatically turns on the
+ "compactdefaultargs" feature if the target language does not support kwargs.
+ Only Java and Python support kwargs, so this affects all the other languages.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2014-10-10: diorcety
+ [Python] Patch #232 Fix property access using directors
+
+2014-10-06: wsfulton
+ [Python] Fixes when using -builtin and std::vector/std::list wrappers to allow deletion
+ of single elements, such as 'del vec[0]'.
+
+2014-09-30: oliverb
+ [Javascript] Merge patch #216 by Richie765 - Added support for many versions of v8 javascript.
+
+2014-09-30: oliverb
+ [Javascript] Merge patch #195 by zittix - Fixed JSClassRef declaration not using the static one.
+
+2014-09-30: ianlancetaylor
+ [Go] In configure script, require Go 1.1 or later.
+
+2014-09-30: wsfulton
+ [Python] Patch #207 - Fix No module error with -relativeimport when using single
+ header file import.
+
+2014-09-27: wsfulton
+ Patch #208 - Initialise newly created array when using array_functions in the
+ carrays.i library (C++ usage).
+
+2014-09-27: wsfulton
+ [Ruby] Patch #187 - Fix crash on shutdown of the Ruby interpreter if more than one
+ module was loaded at a time when data is being shared between modules.
+
+2014-09-27: wsfulton
+ [Java] Patch #168 - Fix leak in Java director string handling after the Java
+ upcall when called from a native thread.
+
+2014-09-25: ianlancetaylor
+ [Go] Adjust generated code to work with upcoming Go 1.4
+ release.
+
+2014-09-23: wsfulton
+ [Python] Add patch from Thomas Maslach to fix crash in wrappers when using -threads in
+ the STL iterators (SwigPyIterator destructor).
+
+2014-09-17: wsfulton
+ [C#] Merge patch #229 from contre - Add bool array types to arrays_csharp.i
+
+2014-09-12: olly
+ [PHP] Add support for specifying any PHP interfaces a wrapped class
+ implements, e.g.: %typemap("phpinterfaces") MyIterator "Iterator";
+
+2014-09-11: olly
+ [PHP] Fix throwing a PHP exception through C++ from a subclassed
+ director method - PHP NULL gets returned by the subclassed method
+ in this case, so the directorout typemap needs to allow that (at
+ least if an exception is active).
+
+2014-09-09: ianlancetaylor
+ [Go] Add goargout typemap.
+
+2014-09-09: olly
+ [PHP] Fix segmentation faults with directors in PHP >= 5.4, and
+ reenable runme tests for director_basic testcase. Fix from
+ pavel-charvat in issue#164.
+
+2014-09-05: ianlancetaylor
+ [Go] Add imtype, goin, goout, godirectorin, and
+ godirectorout typemaps, to support writing Go code to
+ convert between types.
+
+2014-09-02: olly
+ [Python] Fix regression in indentation of python code produced with
+ -modern, introduced by changes in #188. Reported by fabiencastan
+ in #218.
+
+2014-09-01: olly
+ Issue an error for unknown SWIG preprocessor directives, rather
+ than quietly ignoring them. Reported by jrhelsey in issue#217.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2014-08-15: talby
+ [Perl] Include guard fix for nested modules from Anthony Heading (SF Patch #350).
+
+2014-08-04: wsfulton
+ [C#] Merge patch #200 from gpetrou - Changed CSharp license header to include auto-generated
+ tag so that StyleCop ignores the files.
+
+2014-08-04: wsfulton
+ [Java] Merge patch #198 from Yuval Kashtan - Support for java.nio.ByteBuffer mapping to
+ unsigned char * in various.i in NIOBUFFER typemaps.
+
+2014-07-14: ianlancetaylor
+ [Go] Change struct definition to use void *, not uint8, so
+ that the type is recorded as possibly containing
+ pointers. This ensures that the 1.3 garbage collector
+ does not collect pointers passed to C++ code.
+
+2014-07-01: wsfulton
+ Fix SF Bug #1375 - Expansion of the $parentclassname special variable incorrectly contains
+ brackets in the expanded name.
+
Version 3.0.2 (4 Jun 2014)
==========================
@@ -40,7 +245,7 @@ Version 3.0.1 (27 May 2014)
symbol comprising the outer structure name and unnamed variable instance name.
2014-05-15: kwwette
- Add #166 - 'make check' now works out of source. This required te examples to build
+ Add #166 - 'make check' now works out of source. This required the examples to build
out of source. The main languages have been tested - C#, Go, Guile, Java, Javascript,
Lua, Octave, Perl, PHP, Python, Ruby and Tcl.
@@ -4308,7 +4513,7 @@ Version 1.3.32 (November 15, 2007)
%attributeref(Class, AttributeType, AttributeName, AccessorMethod)
10/16/2007: olly
- [Tcl] Fix several ocurrences of "warning: deprecated conversion
+ [Tcl] Fix several occurrences of "warning: deprecated conversion
from string constant to 'char*'" from GCC 4.2 in generated C/C++
code.
diff --git a/CHANGES.current b/CHANGES.current
index 941e575a7..4679e8d63 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -2,126 +2,16 @@ Below are the changes for the current release.
See the CHANGES file for changes in older releases.
See the RELEASENOTES file for a summary of changes in each release.
-Version 3.0.3 (in progress)
+Version 3.0.6 (in progress)
===========================
-2014-12-09: wsfulton
- Fix #245 - regression (since swig-3.0.0) in templated constructors.
- Templated constructors could not be instantiated - they were incorrectly ignored with a warning 504:
- "Function: xyz must have a return type. Ignored."
+2015-02-09: wsfulton
+ [Guile] Fix generated code for static const char member variables when
+ defined and declared inline.
-2014-12-07: wsfulton
- Add support for C++11 strongly typed enumerations.
+2015-02-05: ianlancetaylor
+ [Go] Ignore Go specific type maps (goin, goout, etc.) if they are empty.
-2014-11-21: wsfulton
- [Java C#] Fix multiply defined error when using %rename of enum items when using the "simple enum" wrappers.
-
-2014-10-28: vadz
- [Python] Patch #201 The generated .py file no longer uses *args for all Python parameters.
- Instead, the parameters are named using the C++ parameter names.
-
-2014-10-24: timotheecour
- [D] Patch #204 Use core.atomic.atomicOp to mutate shared variables
-
-2014-10-21: wsfulton
- Fix issue #242 - Use of the "kwargs" feature no longer automatically turns on the
- "compactdefaultargs" feature if the target language does not support kwargs.
- Only Java and Python support kwargs, so this affects all the other languages.
-
- *** POTENTIAL INCOMPATIBILITY ***
-
-2014-10-10: diorcety
- [Python] Patch #232 Fix property access using directors
-
-2014-10-06: wsfulton
- [Python] Fixes when using -builtin and std::vector/std::list wrappers to allow deletion
- of single elements, such as 'del vec[0]'.
-
-2014-09-30: oliverb
- [Javascript] Merge patch #216 by Richie765 - Added support for many versions of v8 javascript.
-
-2014-09-30: oliverb
- [Javascript] Merge patch #195 by zittix - Fixed JSClassRef declaration not using the static one.
-
-2014-09-30: ianlancetaylor
- [Go] In configure script, require Go 1.1 or later.
-
-2014-09-30: wsfulton
- [Python] Patch #207 - Fix No module error with -relativeimport when using single
- header file import.
-
-2014-09-27: wsfulton
- Patch #208 - Initialise newly created array when using array_functions in the
- carrays.i library (C++ usage).
-
-2014-09-27: wsfulton
- [Ruby] Patch #187 - Fix crash on shutdown of the Ruby interpreter if more than one
- module was loaded at a time when data is being shared between modules.
-
-2014-09-27: wsfulton
- [Java] Patch #168 - Fix leak in Java director string handling after the Java
- upcall when called from a native thread.
-
-2014-09-25: ianlancetaylor
- [Go] Adjust generated code to work with upcoming Go 1.4
- release.
-
-2014-09-23: wsfulton
- [Python] Add patch from Thomas Maslach to fix crash in wrappers when using -threads in
- the STL iterators (SwigPyIterator destructor).
-
-2014-09-17: wsfulton
- [C#] Merge patch #229 from contre - Add bool array types to arrays_csharp.i
-
-2014-09-12: olly
- [PHP] Add support for specifying any PHP interfaces a wrapped class
- implements, e.g.: %typemap("phpinterfaces") MyIterator "Iterator";
-
-2014-09-11: olly
- [PHP] Fix throwing a PHP exception through C++ from a subclassed
- director method - PHP NULL gets returned by the subclassed method
- in this case, so the directorout typemap needs to allow that (at
- least if an exception is active).
-
-2014-09-09: ianlancetaylor
- [Go] Add goargout typemap.
-
-2014-09-09: olly
- [PHP] Fix segmentation faults with directors in PHP >= 5.4, and
- reenable runme tests for director_basic testcase. Fix from
- pavel-charvat in issue#164.
-
-2014-09-05: ianlancetaylor
- [Go] Add imtype, goin, goout, godirectorin, and
- godirectorout typemaps, to support writing Go code to
- convert between types.
-
-2014-09-02: olly
- [Python] Fix regression in indentation of python code produced with
- -modern, introduced by changes in #188. Reported by fabiencastan
- in #218.
-
-2014-09-01: olly
- Issue an error for unknown SWIG preprocessor directives, rather
- than quietly ignoring them. Reported by jrhelsey in issue#217.
-
-2014-08-15: talby
- [Perl] Include guard fix for nested modules from Anthony Heading (SF Patch #350).
-
-2014-08-04: wsfulton
- [C#] Merge patch #200 from gpetrou - Changed CSharp license header to include auto-generated
- tag so that StyleCop ignores the files.
-
-2014-08-04: wsfulton
- [Java] Merge patch #198 from Yuval Kashtan - Support for java.nio.ByteBuffer mapping to
- unsigned char * in various.i in NIOBUFFER typemaps.
-
-2014-07-14: ianlancetaylor
- [Go] Change struct definition to use void *, not uint8, so
- that the type is recorded as possibly containing
- pointers. This ensures that the 1.3 garbage collector
- does not collect pointers passed to C++ code.
-
-2014-07-01: wsfulton
- Fix SF Bug #1375 - Expansion of the $parentclassname special variable incorrectly contains
- brackets in the expanded name.
+2015-02-05: ianlancetaylor
+ [Go] Generated Go code no longer calls _swig_goallocate or
+ _swig_makegostring, as they will no longer work as of Go 1.5.
diff --git a/COPYRIGHT b/COPYRIGHT
index 6fbf6c0b0..baf15a5db 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -11,58 +11,63 @@ Portions also copyrighted by:
Information-technology Promotion Agency, Japan
Active SWIG Developers:
- William Fulton (wsf@fultondesigns.co.uk) (SWIG core, Java, C#, Windows, Cygwin)
- Olly Betts (olly@survex.com) (PHP)
- Joseph Wang (joequant@gmail.com) (R)
- Xavier Delacour (xavier.delacour@gmail.com) (Octave)
- David Nadlinger (code@klickverbot.at) (D)
- Oliver Buchtala (oliver.buchtala@gmail.com) (Javascript)
- Neha Narang (narangneha03@gmail.com) (Javascript)
+ William Fulton (wsf@fultondesigns.co.uk) (SWIG core, Java, C#, Windows, Cygwin)
+ Olly Betts (olly@survex.com) (PHP)
+ Joseph Wang (joequant@gmail.com) (R)
+ Xavier Delacour (xavier.delacour@gmail.com) (Octave)
+ David Nadlinger (code@klickverbot.at) (D)
+ Oliver Buchtala (oliver.buchtala@gmail.com) (Javascript)
+ Neha Narang (narangneha03@gmail.com) (Javascript)
+ Simon Marchetto (simon.marchetto@scilab-enterprises.com) (Scilab)
Past SWIG developers and major contributors include:
- Dave Beazley (dave-swig@dabeaz.com) (SWIG core, Python, Tcl, Perl)
- Dmitry Kabak (userdima@gmail.com) (Doxygen)
- Henning Thielemann (swig@henning-thielemann.de) (Modula3)
- Matthias Köppe (mkoeppe@mail.math.uni-magdeburg.de) (Guile, MzScheme)
- Luigi Ballabio (luigi.ballabio@fastwebnet.it) (STL wrapping)
- Mikel Bancroft (mikel@franz.com) (Allegro CL)
- Surendra Singhi (efuzzyone@netscape.net) (CLISP, CFFI)
- Marcelo Matus (mmatus@acms.arizona.edu) (SWIG core, Python, UTL[python,perl,tcl,ruby])
- Art Yerkes (ayerkes@speakeasy.net) (Ocaml)
- Lyle Johnson (lyle@users.sourceforge.net) (Ruby)
- Charlie Savage (cfis@interserv.com) (Ruby)
- Thien-Thi Nguyen (ttn@glug.org) (build/test/misc)
- Richard Palmer (richard@magicality.org) (PHP)
- Sam Liddicott - Ananova Ltd (saml@liddicott.com) (PHP)
- Tim Hockin - Sun Microsystems (thockin@sun.com) (PHP)
- Kevin Ruland (PHP)
- Shibukawa Yoshiki (Japanese Translation)
- Jason Stewart (jason@openinformatics.com) (Perl5)
- Loic Dachary (Perl5)
- David Fletcher (Perl5)
- Gary Holt (Perl5)
- Masaki Fukushima (Ruby)
- Scott Michel (scottm@cs.ucla.edu) (Java directors)
- Tiger Feng (songyanf@cs.uchicago.edu) (SWIG core)
- Mark Rose (mrose@stm.lbl.gov) (Directors)
- Jonah Beckford (beckford@usermail.com) (CHICKEN)
- Ahmon Dancy (dancy@franz.com) (Allegro CL)
- Dirk Gerrits (Allegro CL)
- Neil Cawse (C#)
- Harco de Hilster (Java)
- Alexey Dyachenko (dyachenko@fromru.com) (Tcl)
- Bob Techentin (Tcl)
- Martin Froehlich <MartinFroehlich@ACM.org> (Guile)
- Marcio Luis Teixeira <marciot@holly.colostate.edu> (Guile)
- Duncan Temple Lang (R)
- Miklos Vajna <vmiklos@frugalware.org> (PHP directors)
- Mark Gossage (mark@gossage.cjb.net) (Lua)
- Raman Gopalan (ramangopalan@gmail.com) (eLua)
- Gonzalo Garramuno (ggarra@advancedsl.com.ar) (Ruby, Ruby's UTL)
- John Lenz (Guile, MzScheme updates, Chicken module, runtime system)
- Ian Lance Taylor (Go)
- Vadim Zeitlin (PCRE)
- Stefan Zager (szager@gmail.com) (Python)
+ Dave Beazley (dave-swig@dabeaz.com) (SWIG core, Python, Tcl, Perl)
+ Henning Thielemann (swig@henning-thielemann.de) (Modula3)
+ Matthias Köppe (mkoeppe@mail.math.uni-magdeburg.de) (Guile, MzScheme)
+ Luigi Ballabio (luigi.ballabio@fastwebnet.it) (STL wrapping)
+ Mikel Bancroft (mikel@franz.com) (Allegro CL)
+ Surendra Singhi (efuzzyone@netscape.net) (CLISP, CFFI)
+ Marcelo Matus (mmatus@acms.arizona.edu) (SWIG core, Python, UTL[python,perl,tcl,ruby])
+ Art Yerkes (ayerkes@speakeasy.net) (Ocaml)
+ Lyle Johnson (lyle@users.sourceforge.net) (Ruby)
+ Charlie Savage (cfis@interserv.com) (Ruby)
+ Thien-Thi Nguyen (ttn@glug.org) (build/test/misc)
+ Richard Palmer (richard@magicality.org) (PHP)
+ Sam Liddicott - Ananova Ltd (saml@liddicott.com) (PHP)
+ Tim Hockin - Sun Microsystems (thockin@sun.com) (PHP)
+ Kevin Ruland (PHP)
+ Shibukawa Yoshiki (Japanese Translation)
+ Jason Stewart (jason@openinformatics.com) (Perl5)
+ Loic Dachary (Perl5)
+ David Fletcher (Perl5)
+ Gary Holt (Perl5)
+ Masaki Fukushima (Ruby)
+ Scott Michel (scottm@cs.ucla.edu) (Java directors)
+ Tiger Feng (songyanf@cs.uchicago.edu) (SWIG core)
+ Mark Rose (mrose@stm.lbl.gov) (Directors)
+ Jonah Beckford (beckford@usermail.com) (CHICKEN)
+ Ahmon Dancy (dancy@franz.com) (Allegro CL)
+ Dirk Gerrits (Allegro CL)
+ Neil Cawse (C#)
+ Harco de Hilster (Java)
+ Alexey Dyachenko (dyachenko@fromru.com) (Tcl)
+ Bob Techentin (Tcl)
+ Martin Froehlich <MartinFroehlich@ACM.org> (Guile)
+ Marcio Luis Teixeira <marciot@holly.colostate.edu> (Guile)
+ Duncan Temple Lang (R)
+ Miklos Vajna <vmiklos@frugalware.org> (PHP directors)
+ Mark Gossage (mark@gossage.cjb.net) (Lua)
+ Raman Gopalan (ramangopalan@gmail.com) (eLua)
+ Gonzalo Garramuno (ggarra@advancedsl.com.ar) (Ruby, Ruby's UTL)
+ John Lenz (Guile, MzScheme updates, Chicken module, runtime system)
+ Baozeng Ding <sploving1@163.com> (Scilab)
+ Ian Lance Taylor (Go)
+ Dmitry Kabak (userdima@gmail.com) (Doxygen)
+ Vadim Zeitlin (PCRE, Python, Doxygen)
+ Stefan Zager (szager@gmail.com) (Python)
+ Vincent Couvert (Scilab)
+ Sylvestre Ledru (Scilab)
+ Wolfgang Frisch (Scilab)
Past contributors include:
James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index 60d05f981..ae00a6617 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -841,6 +841,7 @@
<div class="sectiontoc">
<ul>
<li><a href="Go.html#Go_overview">Overview</a>
+<li><a href="Go.html#Go_examples">Examples</a>
<li><a href="Go.html#Go_running_swig">Running SWIG with Go</a>
<ul>
<li><a href="Go.html#Go_commandline">Additional Commandline Options</a>
@@ -1726,7 +1727,76 @@
</div>
<!-- INDEX -->
-<h3><a href="Tcl.html#Tcl">39 SWIG and Tcl</a></h3>
+<h3><a href="Scilab.html#Scilab">39 SWIG and Scilab</a></h3>
+
+<!-- INDEX -->
+<div class="sectiontoc">
+<ul>
+<li><a href="Scilab.html#Scilab_preliminaries">Preliminaries</a>
+<li><a href="Scilab.html#Scilab_running_swig">Running SWIG</a>
+<ul>
+<li><a href="Scilab.html#Scilab_running_swig_generating_module">Generating the module</a>
+<li><a href="Scilab.html#Scilab_running_swig_building_module">Building the module</a>
+<li><a href="Scilab.html#Scilab_running_swig_loading_module">Loading the module</a>
+<li><a href="Scilab.html#Scilab_running_swig_using_module">Using the module</a>
+<li><a href="Scilab.html#Scilab_running_swig_options">Scilab command line options</a>
+</ul>
+<li><a href="Scilab.html#Scilab_wrapping">A basic tour of C/C++ wrapping</a>
+<ul>
+<li><a href="Scilab.html#Scilab_wrapping_overview">Overview</a>
+<li><a href="Scilab.html#Scilab_wrapping_identifiers">Identifiers</a>
+<li><a href="Scilab.html#Scilab_wrapping_functions">Functions</a>
+<ul>
+<li><a href="Scilab.html#Scilab_nn13">Argument passing</a>
+<li><a href="Scilab.html#Scilab_nn14">Multiple output arguments</a>
+</ul>
+<li><a href="Scilab.html#Scilab_wrapping_global_variables">Global variables</a>
+<li><a href="Scilab.html#Scilab_wrapping_constants_and_enums">Constants and enumerations</a>
+<ul>
+<li><a href="Scilab.html#Scilab_wrapping_constants">Constants</a>
+<li><a href="Scilab.html#Scilab_wrapping_enums">Enumerations</a>
+</ul>
+<li><a href="Scilab.html#Scilab_wrapping_pointers">Pointers</a>
+<ul>
+<li><a href="Scilab.html#Scilab_wrapping_pointers_pointer_adresses">Utility functions</a>
+<li><a href="Scilab.html#Scilab_wrapping_pointers_null_pointers">Null pointers</a>
+</ul>
+<li><a href="Scilab.html#Scilab_wrapping_structs">Structures</a>
+<li><a href="Scilab.html#Scilab_wrapping_cpp_classes">C++ Classes</a>
+<li><a href="Scilab.html#Scilab_wrapping_cpp_inheritance">C++ inheritance</a>
+<li><a href="Scilab.html#Scilab_wrapping_pointers_references_values_arrays">Pointers, references, values, and arrays</a>
+<li><a href="Scilab.html#Scilab_wrapping_cpp_templates">C++ templates</a>
+<li><a href="Scilab.html#Scilab_wrapping_cpp_operators">C++ operators</a>
+<li><a href="Scilab.html#Scilab_wrapping_cpp_namespaces">C++ namespaces</a>
+<li><a href="Scilab.html#Scilab_wrapping_cpp_exceptions">C++ exceptions</a>
+<li><a href="Scilab.html#Scilab_wrapping_cpp_stl">C++ STL</a>
+</ul>
+<li><a href="Scilab.html#Scilab_typemaps">Type mappings and libraries</a>
+<ul>
+<li><a href="Scilab.html#Scilab_typemaps_primitive_types">Default primitive type mappings</a>
+<li><a href="Scilab.html#Scilab_typemaps_non-primitive_types">Default type mappings for non-primitive types</a>
+<li><a href="Scilab.html#Scilab_typemaps_arrays">Arrays</a>
+<li><a href="Scilab.html#Scilab_typemaps_pointer-to-pointers">Pointer-to-pointers</a>
+<li><a href="Scilab.html#Scilab_typemaps_matrices">Matrices</a>
+<li><a href="Scilab.html#Scilab_typemaps_stl">STL</a>
+</ul>
+<li><a href="Scilab.html#Scilab_module_initialization">Module initialization</a>
+<li><a href="Scilab.html#Scilab_building_modes">Building modes</a>
+<ul>
+<li><a href="Scilab.html#Scilab_building_modes_nobuilder_mode">No-builder mode</a>
+<li><a href="Scilab.html#Scilab_building_modes_builder_mode">Builder mode</a>
+</ul>
+<li><a href="Scilab.html#Scilab_generated_scripts">Generated scripts</a>
+<ul>
+<li><a href="Scilab.html#Scilab_generated_scripts_builder_script">Builder script</a>
+<li><a href="Scilab.html#Scilab_generated_scripts_loader_script">Loader script</a>
+</ul>
+<li><a href="Scilab.html#Scilab_other_resources">Other resources</a>
+</ul>
+</div>
+<!-- INDEX -->
+
+<h3><a href="Tcl.html#Tcl">40 SWIG and Tcl</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -1792,7 +1862,7 @@
</div>
<!-- INDEX -->
-<h3><a href="Extending.html#Extending">40 Extending SWIG to support new languages</a></h3>
+<h3><a href="Extending.html#Extending">41 Extending SWIG to support new languages</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html
index 00302d7b5..59c63403d 100644
--- a/Doc/Manual/Extending.html
+++ b/Doc/Manual/Extending.html
@@ -6,7 +6,7 @@
</head>
<body bgcolor="#ffffff">
-<H1><a name="Extending"></a>40 Extending SWIG to support new languages</H1>
+<H1><a name="Extending"></a>41 Extending SWIG to support new languages</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -75,7 +75,7 @@
-<H2><a name="Extending_nn2"></a>40.1 Introduction</H2>
+<H2><a name="Extending_nn2"></a>41.1 Introduction</H2>
<p>
@@ -91,7 +91,7 @@ Also, this chapter is not meant to be a hand-holding tutorial. As a starting po
you should probably look at one of SWIG's existing modules.
</p>
-<H2><a name="Extending_nn3"></a>40.2 Prerequisites</H2>
+<H2><a name="Extending_nn3"></a>41.2 Prerequisites</H2>
<p>
@@ -121,7 +121,7 @@ obvious, but almost all SWIG directives as well as the low-level generation of
wrapper code are driven by C++ datatypes.
</p>
-<H2><a name="Extending_nn4"></a>40.3 The Big Picture</H2>
+<H2><a name="Extending_nn4"></a>41.3 The Big Picture</H2>
<p>
@@ -158,7 +158,7 @@ role in making the system work. For example, both typemaps and declaration anno
based on pattern matching and interact heavily with the underlying type system.
</p>
-<H2><a name="Extending_nn5"></a>40.4 Execution Model</H2>
+<H2><a name="Extending_nn5"></a>41.4 Execution Model</H2>
<p>
@@ -203,7 +203,7 @@ latter stage of compilation.
The next few sections briefly describe some of these stages.
</p>
-<H3><a name="Extending_nn6"></a>40.4.1 Preprocessing</H3>
+<H3><a name="Extending_nn6"></a>41.4.1 Preprocessing</H3>
<p>
@@ -284,7 +284,7 @@ been expanded as well as everything else that goes into the low-level
construction of the wrapper code.
</p>
-<H3><a name="Extending_nn7"></a>40.4.2 Parsing</H3>
+<H3><a name="Extending_nn7"></a>41.4.2 Parsing</H3>
<p>
@@ -385,7 +385,7 @@ returning a <tt>foo</tt> and taking types <tt>a</tt> and <tt>b</tt> as
arguments).
</p>
-<H3><a name="Extending_nn8"></a>40.4.3 Parse Trees</H3>
+<H3><a name="Extending_nn8"></a>41.4.3 Parse Trees</H3>
<p>
@@ -640,7 +640,7 @@ $ swig -c++ -python -debug-module 4 example.i
</pre>
</div>
-<H3><a name="Extending_nn9"></a>40.4.4 Attribute namespaces</H3>
+<H3><a name="Extending_nn9"></a>41.4.4 Attribute namespaces</H3>
<p>
@@ -659,7 +659,7 @@ that matches the name of the target language. For example, <tt>python:foo</tt>
<tt>perl:foo</tt>.
</p>
-<H3><a name="Extending_nn10"></a>40.4.5 Symbol Tables</H3>
+<H3><a name="Extending_nn10"></a>41.4.5 Symbol Tables</H3>
<p>
@@ -750,7 +750,7 @@ example.i:5. Previous declaration is foo_i(int )
</pre>
</div>
-<H3><a name="Extending_nn11"></a>40.4.6 The %feature directive</H3>
+<H3><a name="Extending_nn11"></a>41.4.6 The %feature directive</H3>
<p>
@@ -806,7 +806,7 @@ For example, the exception code above is simply
stored without any modifications.
</p>
-<H3><a name="Extending_nn12"></a>40.4.7 Code Generation</H3>
+<H3><a name="Extending_nn12"></a>41.4.7 Code Generation</H3>
<p>
@@ -928,7 +928,7 @@ public :
The role of these functions is described shortly.
</p>
-<H3><a name="Extending_nn13"></a>40.4.8 SWIG and XML</H3>
+<H3><a name="Extending_nn13"></a>41.4.8 SWIG and XML</H3>
<p>
@@ -941,7 +941,7 @@ internal data structures, it may be useful to keep XML in the back of
your mind as a model.
</p>
-<H2><a name="Extending_nn14"></a>40.5 Primitive Data Structures</H2>
+<H2><a name="Extending_nn14"></a>41.5 Primitive Data Structures</H2>
<p>
@@ -987,7 +987,7 @@ typedef Hash Typetab;
</pre>
</div>
-<H3><a name="Extending_nn15"></a>40.5.1 Strings</H3>
+<H3><a name="Extending_nn15"></a>41.5.1 Strings</H3>
<p>
@@ -1128,7 +1128,7 @@ Returns the number of replacements made (if any).
</div>
-<H3><a name="Extending_nn16"></a>40.5.2 Hashes</H3>
+<H3><a name="Extending_nn16"></a>41.5.2 Hashes</H3>
<p>
@@ -1205,7 +1205,7 @@ Returns the list of hash table keys.
</div>
-<H3><a name="Extending_nn17"></a>40.5.3 Lists</H3>
+<H3><a name="Extending_nn17"></a>41.5.3 Lists</H3>
<p>
@@ -1294,7 +1294,7 @@ If <tt>t</tt> is not a standard object, it is assumed to be a <tt>char *</tt>
and is used to create a String object.
</div>
-<H3><a name="Extending_nn18"></a>40.5.4 Common operations</H3>
+<H3><a name="Extending_nn18"></a>41.5.4 Common operations</H3>
The following operations are applicable to all datatypes.
@@ -1349,7 +1349,7 @@ objects and report errors.
Gets the line number associated with <tt>x</tt>.
</div>
-<H3><a name="Extending_nn19"></a>40.5.5 Iterating over Lists and Hashes</H3>
+<H3><a name="Extending_nn19"></a>41.5.5 Iterating over Lists and Hashes</H3>
To iterate over the elements of a list or a hash table, the following functions are used:
@@ -1394,7 +1394,7 @@ for (j = First(j); j.item; j= Next(j)) {
</div>
-<H3><a name="Extending_nn20"></a>40.5.6 I/O</H3>
+<H3><a name="Extending_nn20"></a>41.5.6 I/O</H3>
Special I/O functions are used for all internal I/O. These operations
@@ -1528,7 +1528,7 @@ Printf(f, "%s\n", s);
Similarly, the preprocessor and parser all operate on string-files.
</p>
-<H2><a name="Extending_nn21"></a>40.6 Navigating and manipulating parse trees</H2>
+<H2><a name="Extending_nn21"></a>41.6 Navigating and manipulating parse trees</H2>
Parse trees are built as collections of hash tables. Each node is a hash table in which
@@ -1662,7 +1662,7 @@ Deletes a node from the parse tree. Deletion reconnects siblings and properly u
the parent so that sibling nodes are unaffected.
</div>
-<H2><a name="Extending_nn22"></a>40.7 Working with attributes</H2>
+<H2><a name="Extending_nn22"></a>41.7 Working with attributes</H2>
<p>
@@ -1779,7 +1779,7 @@ the attribute is optional. <tt>Swig_restore()</tt> must always be called after
function.
</div>
-<H2><a name="Extending_nn23"></a>40.8 Type system</H2>
+<H2><a name="Extending_nn23"></a>41.8 Type system</H2>
<p>
@@ -1788,7 +1788,7 @@ pointers, references, and pointers to members. A detailed discussion of
type theory is impossible here. However, let's cover the highlights.
</p>
-<H3><a name="Extending_nn24"></a>40.8.1 String encoding of types</H3>
+<H3><a name="Extending_nn24"></a>41.8.1 String encoding of types</H3>
<p>
@@ -1889,7 +1889,7 @@ make the final type, the two parts are just joined together using
string concatenation.
</p>
-<H3><a name="Extending_nn25"></a>40.8.2 Type construction</H3>
+<H3><a name="Extending_nn25"></a>41.8.2 Type construction</H3>
<p>
@@ -2058,7 +2058,7 @@ Returns the prefix of a type. For example, if <tt>ty</tt> is
<tt>ty</tt> is unmodified.
</div>
-<H3><a name="Extending_nn26"></a>40.8.3 Type tests</H3>
+<H3><a name="Extending_nn26"></a>41.8.3 Type tests</H3>
<p>
@@ -2145,7 +2145,7 @@ Checks if <tt>ty</tt> is a varargs type.
Checks if <tt>ty</tt> is a templatized type.
</div>
-<H3><a name="Extending_nn27"></a>40.8.4 Typedef and inheritance</H3>
+<H3><a name="Extending_nn27"></a>41.8.4 Typedef and inheritance</H3>
<p>
@@ -2247,7 +2247,7 @@ Fully reduces <tt>ty</tt> according to typedef rules. Resulting datatype
will consist only of primitive typenames.
</div>
-<H3><a name="Extending_nn28"></a>40.8.5 Lvalues</H3>
+<H3><a name="Extending_nn28"></a>41.8.5 Lvalues</H3>
<p>
@@ -2284,7 +2284,7 @@ Literal y; // type = 'Literal', ltype='p.char'
</pre>
</div>
-<H3><a name="Extending_nn29"></a>40.8.6 Output functions</H3>
+<H3><a name="Extending_nn29"></a>41.8.6 Output functions</H3>
<p>
@@ -2346,7 +2346,7 @@ SWIG, but is most commonly associated with type-descriptor objects
that appear in wrappers (e.g., <tt>SWIGTYPE_p_double</tt>).
</div>
-<H2><a name="Extending_nn30"></a>40.9 Parameters</H2>
+<H2><a name="Extending_nn30"></a>41.9 Parameters</H2>
<p>
@@ -2445,7 +2445,7 @@ included. Used to emit prototypes.
Returns the number of required (non-optional) arguments in <tt>p</tt>.
</div>
-<H2><a name="Extending_nn31"></a>40.10 Writing a Language Module</H2>
+<H2><a name="Extending_nn31"></a>41.10 Writing a Language Module</H2>
<p>
@@ -2460,7 +2460,7 @@ describes the creation of a minimal Python module. You should be able to extra
this to other languages.
</p>
-<H3><a name="Extending_nn32"></a>40.10.1 Execution model</H3>
+<H3><a name="Extending_nn32"></a>41.10.1 Execution model</H3>
<p>
@@ -2470,7 +2470,7 @@ the parsing of command line options, all aspects of code generation are controll
different methods of the <tt>Language</tt> that must be defined by your module.
</p>
-<H3><a name="Extending_starting_out"></a>40.10.2 Starting out</H3>
+<H3><a name="Extending_starting_out"></a>41.10.2 Starting out</H3>
<p>
@@ -2578,7 +2578,7 @@ that activates your module. For example, <tt>swig -python foo.i</tt>. The
messages from your new module should appear.
</p>
-<H3><a name="Extending_nn34"></a>40.10.3 Command line options</H3>
+<H3><a name="Extending_nn34"></a>41.10.3 Command line options</H3>
<p>
@@ -2637,7 +2637,7 @@ to mark the option as valid. If you forget to do this, SWIG will terminate wit
unrecognized command line option error.
</p>
-<H3><a name="Extending_nn35"></a>40.10.4 Configuration and preprocessing</H3>
+<H3><a name="Extending_nn35"></a>41.10.4 Configuration and preprocessing</H3>
<p>
@@ -2686,7 +2686,7 @@ an implementation file <tt>python.cxx</tt> and a configuration file
<tt>python.swg</tt>.
</p>
-<H3><a name="Extending_nn36"></a>40.10.5 Entry point to code generation</H3>
+<H3><a name="Extending_nn36"></a>41.10.5 Entry point to code generation</H3>
<p>
@@ -2744,7 +2744,7 @@ int Python::top(Node *n) {
</pre>
</div>
-<H3><a name="Extending_nn37"></a>40.10.6 Module I/O and wrapper skeleton</H3>
+<H3><a name="Extending_nn37"></a>41.10.6 Module I/O and wrapper skeleton</H3>
<!-- please report bugs in this section to mgossage -->
@@ -2892,7 +2892,7 @@ functionWrapper : void Shape_y_set(Shape *self,double y)
</pre>
</div>
-<H3><a name="Extending_nn38"></a>40.10.7 Low-level code generators</H3>
+<H3><a name="Extending_nn38"></a>41.10.7 Low-level code generators</H3>
<!-- please report bugs in this section to mgossage -->
@@ -3046,7 +3046,7 @@ but without the typemaps, there is still work to do.
</p>
-<H3><a name="Extending_configuration_files"></a>40.10.8 Configuration files</H3>
+<H3><a name="Extending_configuration_files"></a>41.10.8 Configuration files</H3>
<!-- please report bugs in this section to ttn -->
@@ -3190,7 +3190,7 @@ politely displays the ignoring language message.
</dl>
-<H3><a name="Extending_nn40"></a>40.10.9 Runtime support</H3>
+<H3><a name="Extending_nn40"></a>41.10.9 Runtime support</H3>
<p>
@@ -3199,7 +3199,7 @@ Discuss the kinds of functions typically needed for SWIG runtime support (e.g.
the SWIG files that implement those functions.
</p>
-<H3><a name="Extending_nn41"></a>40.10.10 Standard library files</H3>
+<H3><a name="Extending_nn41"></a>41.10.10 Standard library files</H3>
<p>
@@ -3218,7 +3218,7 @@ The following are the minimum that are usually supported:
Please copy these and modify for any new language.
</p>
-<H3><a name="Extending_nn42"></a>40.10.11 User examples</H3>
+<H3><a name="Extending_nn42"></a>41.10.11 User examples</H3>
<p>
@@ -3247,7 +3247,7 @@ during this process, see the section on <a href="#Extending_configuration_files"
files</a>.
</p>
-<H3><a name="Extending_test_suite"></a>40.10.12 Test driven development and the test-suite</H3>
+<H3><a name="Extending_test_suite"></a>41.10.12 Test driven development and the test-suite</H3>
<p>
@@ -3306,7 +3306,7 @@ It is therefore essential that the runtime tests are written in a manner that di
but error/exception out with an error message on stderr on failure.
</p>
-<H4><a name="Extending_running_test_suite"></a>40.10.12.1 Running the test-suite</H4>
+<H4><a name="Extending_running_test_suite"></a>41.10.12.1 Running the test-suite</H4>
<p>
@@ -3498,7 +3498,7 @@ It can be run in the same way as the other language test-suites, replacing [lang
The test cases used and the way it works is described in <tt>Examples/test-suite/errors/Makefile.in</tt>.
</p>
-<H3><a name="Extending_nn43"></a>40.10.13 Documentation</H3>
+<H3><a name="Extending_nn43"></a>41.10.13 Documentation</H3>
<p>
@@ -3530,7 +3530,7 @@ Some topics that you'll want to be sure to address include:
if available.
</ul>
-<H3><a name="Extending_prerequisites"></a>40.10.14 Prerequisites for adding a new language module to the SWIG distribution</H3>
+<H3><a name="Extending_prerequisites"></a>41.10.14 Prerequisites for adding a new language module to the SWIG distribution</H3>
<p>
@@ -3587,7 +3587,7 @@ should be added should there be an area not already covered by
the existing tests.
</p>
-<H3><a name="Extending_coding_style_guidelines"></a>40.10.15 Coding style guidelines</H3>
+<H3><a name="Extending_coding_style_guidelines"></a>41.10.15 Coding style guidelines</H3>
<p>
@@ -3611,7 +3611,7 @@ The generated C/C++ code should also follow this style as close as possible. How
should be avoided as unlike the SWIG developers, users will never have consistent tab settings.
</p>
-<H2><a name="Extending_debugging_options"></a>40.11 Debugging Options</H2>
+<H2><a name="Extending_debugging_options"></a>41.11 Debugging Options</H2>
<p>
@@ -3638,7 +3638,7 @@ There are various command line options which can aid debugging a SWIG interface
The complete list of command line options for SWIG are available by running <tt>swig -help</tt>.
</p>
-<H2><a name="Extending_nn46"></a>40.12 Guide to parse tree nodes</H2>
+<H2><a name="Extending_nn46"></a>41.12 Guide to parse tree nodes</H2>
<p>
@@ -4046,7 +4046,7 @@ extern "X" { ... } declaration.
</pre>
</div>
-<H2><a name="Extending_further_info"></a>40.13 Further Development Information</H2>
+<H2><a name="Extending_further_info"></a>41.13 Further Development Information</H2>
<p>
diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html
index 03b48d40c..895e6c581 100644
--- a/Doc/Manual/Go.html
+++ b/Doc/Manual/Go.html
@@ -10,6 +10,7 @@
<div class="sectiontoc">
<ul>
<li><a href="#Go_overview">Overview</a>
+<li><a href="#Go_examples">Examples</a>
<li><a href="#Go_running_swig">Running SWIG with Go</a>
<ul>
<li><a href="#Go_commandline">Additional Commandline Options</a>
@@ -69,7 +70,22 @@ checking and runtime library are not used with Go. This should be
borne in mind when reading the rest of the SWIG documentation.
</p>
-<H2><a name="Go_running_swig"></a>23.2 Running SWIG with Go</H2>
+<H2><a name="Go_examples"></a>23.2 Examples</H2>
+
+
+<p>
+Working examples can be found here:
+</p>
+<ul>
+<li><a href="https://golang.org/misc/swig">Examples from the Go source tree</a>
+<li><a href="https://github.com/swig/swig/tree/master/Examples/go">Examples from the SWIG source tree</a>
+</ul>
+<p>
+The examples in the 2nd link are shipped with the SWIG distribution under the Examples/go directory.
+</p>
+
+
+<H2><a name="Go_running_swig"></a>23.3 Running SWIG with Go</H2>
<p>
@@ -78,7 +94,7 @@ default SWIG will generate code for the gc compilers. To generate
code for gccgo, you should also use the <tt>-gccgo</tt> option.
</p>
-<H3><a name="Go_commandline"></a>23.2.1 Additional Commandline Options</H3>
+<H3><a name="Go_commandline"></a>23.3.1 Additional Commandline Options</H3>
<p>
@@ -152,7 +168,7 @@ swig -go -help
</table>
-<H3><a name="Go_outputs"></a>23.2.2 Go Output Files</H3>
+<H3><a name="Go_outputs"></a>23.3.2 Go Output Files</H3>
<p> When generating Go code, SWIG will generate the following
@@ -228,7 +244,7 @@ this:
% go tool 6l main.6
</pre></div>
-<H2><a name="Go_basic_tour"></a>23.3 A tour of basic C/C++ wrapping</H2>
+<H2><a name="Go_basic_tour"></a>23.4 A tour of basic C/C++ wrapping</H2>
<p>
@@ -238,7 +254,7 @@ modifications have to occur. This section briefly covers the
essential aspects of this wrapping.
</p>
-<H3><a name="Go_package"></a>23.3.1 Go Package Name</H3>
+<H3><a name="Go_package"></a>23.4.1 Go Package Name</H3>
<p>
@@ -248,7 +264,7 @@ directive. You may override this by using SWIG's <tt>-package</tt>
command line option.
</p>
-<H3><a name="Go_names"></a>23.3.2 Go Names</H3>
+<H3><a name="Go_names"></a>23.4.2 Go Names</H3>
<p>
@@ -280,7 +296,7 @@ followed by that name, and the destructor will be
named <tt>Delete</tt> followed by that name.
</p>
-<H3><a name="Go_constants"></a>23.3.3 Go Constants</H3>
+<H3><a name="Go_constants"></a>23.4.3 Go Constants</H3>
<p>
@@ -288,7 +304,7 @@ C/C++ constants created via <tt>#define</tt> or the <tt>%constant</tt>
directive become Go constants, declared with a <tt>const</tt>
declaration.
-<H3><a name="Go_enumerations"></a>23.3.4 Go Enumerations</H3>
+<H3><a name="Go_enumerations"></a>23.4.4 Go Enumerations</H3>
<p>
@@ -298,7 +314,7 @@ usual). The values of the enumeration will become variables in Go;
code should avoid modifying those variables.
</p>
-<H3><a name="Go_classes"></a>23.3.5 Go Classes</H3>
+<H3><a name="Go_classes"></a>23.4.5 Go Classes</H3>
<p>
@@ -376,21 +392,24 @@ returns a go interface. If the returned pointer can be null, you can check
for this by calling the Swigcptr() method.
</p>
-<H4><a name="Go_class_memory"></a>23.3.5.1 Go Class Memory Management</H4>
+<H4><a name="Go_class_memory"></a>23.4.5.1 Go Class Memory Management</H4>
<p>
Calling <tt>NewClassName</tt> for some C++ class <tt>ClassName</tt>
will allocate memory using the C++ memory allocator. This memory will
-not be automatically freed by Go's garbage collector. When you are
-done with the C++ object you must free it using <tt>DeleteClassName</tt>.
+not be automatically freed by Go's garbage collector as the object ownership is
+not tracked. When you are done with the C++ object you must free it manually
+using <tt>DeleteClassName</tt>.
</p>
<p>
A common technique is to store the C++ object into a Go object, and
-use the Go function <tt>runtime.SetFinalizer</tt> to free the C++
-object when the Go object is freed. For example, if the SWIG package
-is imported as "wrap":
+use the Go function <tt>runtime.SetFinalizer</tt> to free the C++ object when
+the Go object is freed. It is strongly recommended to read the
+<a href="https://golang.org/pkg/runtime/#SetFinalizer">runtime.SetFinalizer</a>
+documentation before using this technique to understand its limitations.
+For example, if the SWIG package is imported as "wrap":
</p>
<div class="code">
<pre>
@@ -409,7 +428,7 @@ func NewGoClassName() *GoClassName {
</pre>
</div>
-<H4><a name="Go_class_inheritance"></a>23.3.5.2 Go Class Inheritance</H4>
+<H4><a name="Go_class_inheritance"></a>23.4.5.2 Go Class Inheritance</H4>
<p>
@@ -421,7 +440,7 @@ Doing the reverse will require an explicit type assertion, which will
be checked dynamically.
</p>
-<H3><a name="Go_templates"></a>23.3.6 Go Templates</H3>
+<H3><a name="Go_templates"></a>23.4.6 Go Templates</H3>
<p>
@@ -429,7 +448,7 @@ In order to use C++ templates in Go, you must tell SWIG to create
wrappers for a particular template instantation. To do this, use
the <tt>%template</tt> directive.
-<H3><a name="Go_director_classes"></a>23.3.7 Go Director Classes</H3>
+<H3><a name="Go_director_classes"></a>23.4.7 Go Director Classes</H3>
<p>
@@ -472,7 +491,7 @@ method defined in Go. The Go code may of course call other methods on
itself, and those methods may be defined either in Go or in C++.
</p>
-<H3><a name="Go_primitive_type_mappings"></a>23.3.8 Default Go primitive type mappings</H3>
+<H3><a name="Go_primitive_type_mappings"></a>23.4.8 Default Go primitive type mappings</H3>
<p>
@@ -579,7 +598,7 @@ that typemap, or add new values, to control how C/C++ types are mapped
into Go types.
</p>
-<H3><a name="Go_output_arguments"></a>23.3.9 Output arguments</H3>
+<H3><a name="Go_output_arguments"></a>23.4.9 Output arguments</H3>
<p>Because of limitations in the way output arguments are processed in swig,
@@ -632,7 +651,7 @@ void f(char *output);
</pre>
</div>
-<H3><a name="Go_adding_additional_code"></a>23.3.10 Adding additional go code</H3>
+<H3><a name="Go_adding_additional_code"></a>23.4.10 Adding additional go code</H3>
<p>Often the APIs generated by swig are not very natural in go, especially if
@@ -727,7 +746,7 @@ func bar() {
</pre>
</div>
-<H3><a name="Go_typemaps"></a>23.3.11 Go typemaps</H3>
+<H3><a name="Go_typemaps"></a>23.4.11 Go typemaps</H3>
<p>
@@ -776,7 +795,8 @@ gotype is best converted to C/C++ using Go code.
<td>
Go code to convert from gotype to imtype when calling a C/C++
function. SWIG will then internally convert imtype to a C/C++ type
-and pass it down. If this is not defined no conversion is done.
+and pass it down. If this is not defined, or is the empty string, no
+conversion is done.
</td>
</tr>
@@ -803,7 +823,8 @@ to the desired type.
<td>goout</td>
<td>
Go code to convert a value returned from a C/C++ function from imtype
-to gotype. If this is not defined no conversion is done.
+to gotype. If this is not defined, or is the empty string, no
+conversion is done.
</td>
</tr>
@@ -824,7 +845,7 @@ be done.
Go code to adjust an argument value when returning from a function.
This is called after the real C/C++ function has run. The value will
be in imtype. This is only useful for a pointer type of some sort.
-If this is not defined nothing will be done.
+If this is not defined, or is the empty string, nothing will be done.
</td>
</tr>
@@ -842,7 +863,8 @@ to the desired type.
<td>godirectorin</td>
<td>
Go code to convert a value used to call a director method from imtype
-to gotype. If this is not defined no conversion is done.
+to gotype. If this is not defined, or is the empty string, no
+conversion is done.
</td>
</tr>
@@ -850,7 +872,8 @@ to gotype. If this is not defined no conversion is done.
<td>godirectorout</td>
<td>
Go code to convert a value returned from a director method from gotype
-to imtype. If this is not defined no conversion is done.
+to imtype. If this is not defined, or is the empty string, no
+conversion is done.
</td>
</tr>
diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html
index 19d59a4df..9cc4277c9 100644
--- a/Doc/Manual/Introduction.html
+++ b/Doc/Manual/Introduction.html
@@ -334,8 +334,7 @@ major features include:
</ul>
<p>
-Currently, the only major C++ feature not supported is nested classes--a limitation
-that should be removed in a future release, but has some workarounds for the moment.
+Most of C++11 is also supported. Details are in the <a href="CPlusPlus11.html">C++11</a> section.
</p>
<p>
diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html
index 6f11b4aa1..623adb68a 100644
--- a/Doc/Manual/Php.html
+++ b/Doc/Manual/Php.html
@@ -142,6 +142,7 @@ least work for Linux though):
<H3><a name="Php_nn1_3"></a>34.1.2 Using PHP Extensions</H3>
+
<p>
To test the extension from a PHP script, you first need to tell PHP to
load it. To do this, add a line like this to the <tt>[PHP]</tt> section of
@@ -773,6 +774,7 @@ Ko::threats();
<H4><a name="Php_nn2_6_5"></a>34.2.6.5 Specifying Implemented Interfaces</H4>
+
<p>
PHP supports the concept of abstract interfaces which a class can implement.
Since SWIG 3.0.3, you can tell SWIG that a wrapped class (for example
diff --git a/Doc/Manual/Preprocessor.html b/Doc/Manual/Preprocessor.html
index 745570ca4..e188fc0be 100644
--- a/Doc/Manual/Preprocessor.html
+++ b/Doc/Manual/Preprocessor.html
@@ -120,7 +120,7 @@ SWIG_JAVASCRIPT_JSC Defined when using Javascript for JavascriptCore
SWIG_JAVASCRIPT_V8 Defined when using Javascript for v8 or node.js
SWIGLUA Defined when using Lua
SWIGMODULA3 Defined when using Modula-3
-SWIGMZSCHEME Defined when using Mzscheme
+SWIGMZSCHEME Defined when using Mzscheme
SWIGOCAML Defined when using Ocaml
SWIGOCTAVE Defined when using Octave
SWIGPERL Defined when using Perl
@@ -129,6 +129,7 @@ SWIGPIKE Defined when using Pike
SWIGPYTHON Defined when using Python
SWIGR Defined when using R
SWIGRUBY Defined when using Ruby
+SWIGSCILAB Defined when using Scilab
SWIGSEXP Defined when using S-expressions
SWIGTCL Defined when using Tcl
SWIGXML Defined when using XML
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index 234117464..8dae4bbf0 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -2169,15 +2169,15 @@ for Python 2.2):
import _example
class Foo(object):
- def __init__(self):
- self.this = _example.new_Foo()
- self.thisown = 1
- def __del__(self):
- if self.thisown:
- _example.delete_Foo(self.this)
- def spam(self,arg1):
- return _example.Foo_spam(self.this,arg1)
- x = property(_example.Foo_x_get, _example.Foo_x_set)
+ def __init__(self):
+ self.this = _example.new_Foo()
+ self.thisown = 1
+ def __del__(self):
+ if self.thisown:
+ _example.delete_Foo(self.this)
+ def spam(self,arg1):
+ return _example.Foo_spam(self.this,arg1)
+ x = property(_example.Foo_x_get, _example.Foo_x_set)
</pre>
</div>
@@ -2219,9 +2219,9 @@ like in a proxy class:
<div class="targetlang">
<pre>
class Foo(object):
- def __init__(self):
- self.this = _example.new_Foo()
- self.thisown = 1
+ def __init__(self):
+ self.this = _example.new_Foo()
+ self.thisown = 1
</pre>
</div>
@@ -2313,11 +2313,11 @@ private:
<div class="targetlang">
<pre>
-class MyPyException (Exception) :
- def __init__(self, msg, *args) :
+class MyPyException(Exception):
+ def __init__(self, msg, *args):
Exception.__init__(self, *args)
self.myexc = MyException(msg)
- def what (self) :
+ def what(self):
return self.myexc.what()
</pre>
</div>
@@ -2841,6 +2841,7 @@ the methods one() and two() (but not three()):
class Foo {
public:
Foo(int foo);
+ virtual ~Foo();
virtual void one();
virtual void two();
};
@@ -2861,11 +2862,12 @@ then at the python side you can define
import mymodule
class MyFoo(mymodule.Foo):
- def __init__(self, foo):
- mymodule.Foo(self, foo)
+ def __init__(self, foo):
+ mymodule.Foo.__init__(self, foo)
+# super().__init__(foo) # Alternative construction for Python3
- def one(self):
- print "one from python"
+ def one(self):
+ print "one from python"
</pre>
</div>
@@ -3368,6 +3370,18 @@ print("Loading", "Whizz", "Bang", sep=' ... ')
</pre>
</div>
+<p>When using <tt>%pythoncode</tt> and <tt>%pythonbegin</tt> you generally
+want to make sure that the block is delimited by <tt>%{</tt> and <tt>%}</tt>.
+If you delimit it with <tt>{</tt> and <tt>}</tt> then any lines with a
+leading <tt>#</tt> will be handled by SWIG as preprocessor directives, when
+you probably meant them as Python comments. Prior to SWIG 3.0.3, invalid
+preprocessor directives were silently ignored, so generally using the wrong
+delimiters resulted in such comments not appearing in the generated output
+(though a comment starting with a valid preprocessor directive could cause
+problems, for example: <tt># error handling</tt>). SWIG 3.0.3 and later report
+an error for invalid preprocessor directives, so you may have to update
+existing interface files to delimit blocks of Python code correctly.</p>
+
<p>Sometimes you may want to replace or modify the wrapper function
that SWIG creates in the proxy <tt>.py</tt> file. The Python module
in SWIG provides some features that enable you to do this. First, to
diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html
index c4e0074f3..e78447b92 100644
--- a/Doc/Manual/Ruby.html
+++ b/Doc/Manual/Ruby.html
@@ -147,7 +147,7 @@
<H2><a name="Ruby_nn2"></a>38.1 Preliminaries</H2>
-<p> SWIG 1.3 is known to work with Ruby versions 1.6 and later.
+<p> SWIG 3.0 is known to work with Ruby versions 1.8 and later.
Given the choice, you should use the latest stable version of Ruby. You
should also determine if your system supports shared libraries and
dynamic loading. SWIG will work with or without dynamic loading, but
@@ -191,7 +191,7 @@ header file. This file is usually contained in a directory such as </p>
<div class="code shell diagram">
<pre>/usr/lib/ruby/1.8/x86_64-linux-gnu/ruby.h
-/usr/local/lib/ruby/1.6/i686-linux/ruby.h
+/usr/include/ruby-2.1.0/ruby.h
</pre>
</div>
@@ -201,8 +201,14 @@ installed, you can run Ruby to find out. For example: </p>
<div class="code shell">
<pre>$ ruby -e 'puts $:.join("\n")'
-/usr/local/lib/ruby/site_ruby/1.6 /usr/local/lib/ruby/site_ruby/1.6/i686-linux
-/usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/1.6 /usr/local/lib/ruby/1.6/i686-linux .
+/usr/local/lib/site_ruby/2.1.0
+/usr/local/lib/x86_64-linux-gnu/site_ruby
+/usr/local/lib/site_ruby
+/usr/lib/ruby/vendor_ruby/2.1.0
+/usr/lib/x86_64-linux-gnu/ruby/vendor_ruby/2.1.0
+/usr/lib/ruby/vendor_ruby
+/usr/lib/ruby/2.1.0
+/usr/lib/x86_64-linux-gnu/ruby/2.1.0
</pre>
</div>
@@ -260,7 +266,7 @@ operating system would look something like this: </p>
<div class="code shell">
<pre>$ swig -ruby example.i
$ gcc -O2 -fPIC -c example.c
-$ gcc -O2 -fPIC -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux
+$ gcc -O2 -fPIC -c example_wrap.c -I/usr/include/ruby-2.1.0
$ gcc -shared example.o example_wrap.o -o example.so
</pre>
</div>
@@ -334,7 +340,7 @@ using the C++ compiler. For example: </p>
<pre>
$ swig -c++ -ruby example.i
$ g++ -fPIC -c example.cxx
-$ g++ -fPIC -c example_wrap.cxx -I/usr/local/lib/ruby/1.6/i686-linux
+$ g++ -fPIC -c example_wrap.cxx -I/usr/include/ruby-2.1.0
$ g++ -shared example.o example_wrap.o -o example.so
</pre>
</div>
@@ -2823,7 +2829,7 @@ not support optional arguments, such as Java and C#, effectively ignore
the value specified by this typemap as all arguments must be given.</p>
<p> Once a default typemap has been applied to an argument, all
-arguments that follow must have default values. See the <a href="http://www.swig.org/Doc1.3/SWIGDocumentation.html#SWIG_default_args">
+arguments that follow must have default values. See the <a href="SWIG.html#SWIG_default_args">
Default/optional arguments</a> section for further information on
default argument wrapping.</p>
@@ -3017,7 +3023,7 @@ catch(char const *_e) {
<p> Note that if your methods do not have an exception
specification yet they do throw exceptions, SWIG cannot know how to
-deal with them. For a neat way to handle these, see the <a href="http://www.swig.org/Doc1.3/SWIGDocumentation.html#exception">Exception
+deal with them. For a neat way to handle these, see the <a href="Customization.html#Customization_exception">Exception
handling with %exception</a> section.</p>
<H4><a name="Ruby_directorin_typemap"></a>38.7.6.14 directorin typemap</H4>
@@ -4466,7 +4472,7 @@ and then type <tt>make</tt> to build the shared library: </p>
<pre>$ <b>ruby extconf.rb</b>
creating Makefile
$ <b>make</b>
-g++ -fPIC -g -O2 -I. -I/usr/local/lib/ruby/1.7/i686-linux \
+g++ -fPIC -g -O2 -I. -I/usr/include/ruby-2.1.0 \
-I. -c shape_wrap.cxx
gcc -shared -L/usr/local/lib -o shape.so shape_wrap.o -L. \
-lruby -lruby -lc</pre>
@@ -5351,7 +5357,7 @@ used for callbacks, for example. </p>
<p>To solve the problem, SWIG can now generate code with director
functions containing the optional macros SWIG_INIT_STACK and
SWIG_RELEASE_STACK. These macros will try to force Ruby to
-reinitiliaze the beginning of the stack the first time a
+reinitialize the beginning of the stack the first time a
director
function is called. This will lead Ruby to measure and not
collect any VALUE objects defined from that point on. </p>
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index e70280a08..4c33aeab8 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -138,6 +138,7 @@ can be obtained by typing <tt>swig -help</tt> or <tt>swig
-xml Generate XML wrappers
-c++ Enable C++ parsing
+-cppext <em>ext</em> Change file extension of C++ generated files to <em>ext</em> (default is cxx, except for PHP which uses cpp)
-D<em>symbol</em> Define a preprocessor symbol
-Fstandard Display error/warning messages in commonly used format
-Fmicrosoft Display error/warning messages in Microsoft format
@@ -146,7 +147,7 @@ can be obtained by typing <tt>swig -help</tt> or <tt>swig
-l<em>file</em> Include a SWIG library file.
-module <em>name</em> Set the name of the SWIG module
-o <em>outfile</em> Name of output file
--outcurrentdir Set default output dir to current dir instead of input file's path
+-outcurrentdir Set default output dir to current dir instead of input file's path
-outdir <em>dir</em> Set language specific files output directory
-pcreversion Display PCRE version information
-swiglib Show location of SWIG library
diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html
index 62c0e8d1e..eeca0291c 100644
--- a/Doc/Manual/SWIGPlus.html
+++ b/Doc/Manual/SWIGPlus.html
@@ -3614,18 +3614,52 @@ and the second will take two integer arguments.
</p>
<p>
-Needless to say, SWIG's template support provides plenty of
-opportunities to break the universe. That said, an important final
-point is that <b>SWIG does not perform extensive error checking of
-templates!</b> Specifically, SWIG does not perform type checking nor
-does it check to see if the actual contents of the template
-declaration make any sense. Since the C++ compiler will hopefully
-check this when it compiles the resulting wrapper file, there is no
-practical reason for SWIG to duplicate this functionality (besides,
-none of the SWIG developers are masochistic enough to want to
-implement this right now).
+Needless to say, SWIG's template support provides plenty of opportunities to
+break the universe. That said, an important final point is that <b>SWIG does
+not perform extensive error checking of templates!</b> Specifically, SWIG does
+not perform type checking nor does it check to see if the actual contents of the
+template declaration make any sense. Since the C++ compiler checks this when it
+compiles the resulting wrapper file, there is no practical reason for SWIG to
+duplicate this functionality.
</p>
+<a name="SWIGPlus_template_nested_class_example"></a>
+<p>
+As SWIG's template support does not perform type checking <tt>%template</tt>
+can be used as early as after a template declaration. You can, and rarely have
+to, use <tt>%template</tt> before the template parameters have been declared.
+For example:
+</p>
+
+<div class="code">
+<pre>
+template &lt;class T&gt; class OuterTemplateClass {};
+
+// The nested class OuterClass::InnerClass inherits from the template class
+// OuterTemplateClass&lt;OuterClass::InnerStruct&gt; and thus the template needs
+// to be expanded with %template before the OuterClass declaration.
+%template(OuterTemplateClass_OuterClass__InnerStruct)
+ OuterTemplateClass&lt;OuterClass::InnerStruct&gt;
+
+
+// Don't forget to use %feature("flatnested") for OuterClass::InnerStruct and
+// OuterClass::InnerClass if the target language doesn't support nested classes.
+class OuterClass {
+ public:
+ // Forward declarations:
+ struct InnerStruct;
+ class InnerClass;
+};
+
+struct OuterClass::InnerStruct {};
+
+// Expanding the template at this point with %template is too late as the
+// OuterClass::InnerClass declaration is processed inside OuterClass.
+
+class OuterClass::InnerClass : public OuterTemplateClass&lt;InnerStruct&gt; {};
+</pre>
+</div>
+
<p>
<b>Compatibility Note</b>: The first implementation of template support relied heavily on
macro expansion in the preprocessor. Templates have been more tightly integrated into
@@ -5000,6 +5034,12 @@ class Bar {
</pre>
</div>
+<p>
+If a nested class, within an outer class, has to be used as a template parameter within the outer class, then the template will
+have to be instantiated with <tt>%template</tt> before the beginning of the outer class.
+An example can be found in the
+<a href="#SWIGPlus_template_nested_class_example">Templates</a> section.
+</p>
<p>
<b>Compatibility Note:</b>
diff --git a/Doc/Manual/Scilab.html b/Doc/Manual/Scilab.html
new file mode 100644
index 000000000..d0a1d5381
--- /dev/null
+++ b/Doc/Manual/Scilab.html
@@ -0,0 +1,2051 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>SWIG and Scilab</title>
+<link rel="stylesheet" type="text/css" href="style.css">
+</head>
+
+
+<body bgcolor="#ffffff">
+
+<H1><a name="Scilab"></a>39 SWIG and Scilab</H1>
+<!-- INDEX -->
+<div class="sectiontoc">
+<ul>
+<li><a href="#Scilab_preliminaries">Preliminaries</a>
+<li><a href="#Scilab_running_swig">Running SWIG</a>
+<ul>
+<li><a href="#Scilab_running_swig_generating_module">Generating the module</a>
+<li><a href="#Scilab_running_swig_building_module">Building the module</a>
+<li><a href="#Scilab_running_swig_loading_module">Loading the module</a>
+<li><a href="#Scilab_running_swig_using_module">Using the module</a>
+<li><a href="#Scilab_running_swig_options">Scilab command line options</a>
+</ul>
+<li><a href="#Scilab_wrapping">A basic tour of C/C++ wrapping</a>
+<ul>
+<li><a href="#Scilab_wrapping_overview">Overview</a>
+<li><a href="#Scilab_wrapping_identifiers">Identifiers</a>
+<li><a href="#Scilab_wrapping_functions">Functions</a>
+<ul>
+<li><a href="#Scilab_nn13">Argument passing</a>
+<li><a href="#Scilab_nn14">Multiple output arguments</a>
+</ul>
+<li><a href="#Scilab_wrapping_global_variables">Global variables</a>
+<li><a href="#Scilab_wrapping_constants_and_enums">Constants and enumerations</a>
+<ul>
+<li><a href="#Scilab_wrapping_constants">Constants</a>
+<li><a href="#Scilab_wrapping_enums">Enumerations</a>
+</ul>
+<li><a href="#Scilab_wrapping_pointers">Pointers</a>
+<ul>
+<li><a href="#Scilab_wrapping_pointers_pointer_adresses">Utility functions</a>
+<li><a href="#Scilab_wrapping_pointers_null_pointers">Null pointers</a>
+</ul>
+<li><a href="#Scilab_wrapping_structs">Structures</a>
+<li><a href="#Scilab_wrapping_cpp_classes">C++ Classes</a>
+<li><a href="#Scilab_wrapping_cpp_inheritance">C++ inheritance</a>
+<li><a href="#Scilab_wrapping_pointers_references_values_arrays">Pointers, references, values, and arrays</a>
+<li><a href="#Scilab_wrapping_cpp_templates">C++ templates</a>
+<li><a href="#Scilab_wrapping_cpp_operators">C++ operators</a>
+<li><a href="#Scilab_wrapping_cpp_namespaces">C++ namespaces</a>
+<li><a href="#Scilab_wrapping_cpp_exceptions">C++ exceptions</a>
+<li><a href="#Scilab_wrapping_cpp_stl">C++ STL</a>
+</ul>
+<li><a href="#Scilab_typemaps">Type mappings and libraries</a>
+<ul>
+<li><a href="#Scilab_typemaps_primitive_types">Default primitive type mappings</a>
+<li><a href="#Scilab_typemaps_non-primitive_types">Default type mappings for non-primitive types</a>
+<li><a href="#Scilab_typemaps_arrays">Arrays</a>
+<li><a href="#Scilab_typemaps_pointer-to-pointers">Pointer-to-pointers</a>
+<li><a href="#Scilab_typemaps_matrices">Matrices</a>
+<li><a href="#Scilab_typemaps_stl">STL</a>
+</ul>
+<li><a href="#Scilab_module_initialization">Module initialization</a>
+<li><a href="#Scilab_building_modes">Building modes</a>
+<ul>
+<li><a href="#Scilab_building_modes_nobuilder_mode">No-builder mode</a>
+<li><a href="#Scilab_building_modes_builder_mode">Builder mode</a>
+</ul>
+<li><a href="#Scilab_generated_scripts">Generated scripts</a>
+<ul>
+<li><a href="#Scilab_generated_scripts_builder_script">Builder script</a>
+<li><a href="#Scilab_generated_scripts_loader_script">Loader script</a>
+</ul>
+<li><a href="#Scilab_other_resources">Other resources</a>
+</ul>
+</div>
+<!-- INDEX -->
+
+
+
+<p>
+Scilab is a scientific software package for numerical computations providing a powerful open computing environment for engineering and scientific applications that is mostly compatible with MATLAB. More information can be found at <a href="http://www.scilab.org">www.scilab.org</a>.
+</p>
+
+<p>
+This chapter explains how to use SWIG for Scilab. After this introduction, you should be able to generate with SWIG a Scilab external module from a C/C++ library.
+</p>
+
+
+<H2><a name="Scilab_preliminaries"></a>39.1 Preliminaries</H2>
+
+
+<p>
+SWIG for Scilab supports Linux. Other operating sytems haven't been tested.
+</p>
+
+<p>
+Scilab is supported from version 5.3.3 onwards.
+The forthcoming version 6, as of January 2015, is also supported.
+</p>
+
+<p>
+SWIG for Scilab supports C language. C++ is partially supported. See <a href="#Scilab_wrapping">A basic tour of C/C++ wrapping</a> for further details.
+</p>
+
+
+<H2><a name="Scilab_running_swig"></a>39.2 Running SWIG</H2>
+
+
+<p>
+Let's see how to use SWIG for Scilab on a small example.
+<br>
+In this example we bind from C a function and a global variable into Scilab. The SWIG interface (stored in a file named <tt>example.i</tt>), is the following:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%inline %{
+double Foo = 3.0;
+
+int fact(int n) {
+ if (n &lt; 0) {
+ return 0;
+ }
+ else if (n == 0) {
+ return 1;
+ }
+ else {
+ return n * fact(n-1);
+ }
+}
+%}
+</pre></div>
+
+<p>
+Note: a code in an <tt>%inline</tt> section is both parsed and wrapped by SWIG, and inserted as is in the wrapper source file.
+</p>
+
+
+<H3><a name="Scilab_running_swig_generating_module"></a>39.2.1 Generating the module</H3>
+
+
+<p>
+The module is generated using the <tt>swig</tt> executable and its <tt>-scilab</tt> option.
+</p>
+
+<div class="shell"><pre>
+$ swig -scilab example.i
+</pre></div>
+
+<p>
+This command generates two files:
+</p>
+<ul>
+<li><tt>example_wrap.c</tt>: a C source file containing the wrapping code and also here the wrapped code (the <tt>fact()</tt> and <tt>Foo</tt> definitions)</li>
+<li><tt>loader.sce</tt>: a Scilab script used to load the module into Scilab
+</ul>
+
+<p>
+Note: if the following error is returned:
+</p>
+
+<div class="shell"><pre>
+:1: Error: Unable to find 'swig.swg'
+:3: Error: Unable to find 'scilab.swg'
+</pre></div>
+
+<p>
+it may be because the SWIG library is not found. Check the <tt>SWIG_LIB</tt> environment variable or your SWIG installation.
+</p>
+
+<p>
+Note: SWIG for Scilab can work in two modes related to the way the module is built, see the <a href="#Scilab_building_modes">Building modes</a> section for details.
+This example uses the <tt>builder</tt> mode.
+</p>
+
+
+<p>
+The <tt>swig</tt> executable has several other command line options you can use. See <a href="#Scilab_running_swig_options">Scilab command line options</a> for further details.
+</p>
+
+
+<H3><a name="Scilab_running_swig_building_module"></a>39.2.2 Building the module</H3>
+
+
+<p>
+To be loaded in Scilab, the wrapper has to be built into a dynamic module (or shared library).
+</p>
+
+<p>
+The commands to compile and link the wrapper (with <tt>gcc</tt>) into the shared library <tt>libexample.so</tt> are:
+</p>
+
+<div class="shell"><pre>
+$ gcc -fPIC -c -I/usr/local/include/scilab example_wrap.c
+$ gcc -shared example_wrap.o -o libexample.so
+</pre></div>
+
+<p>
+Note: we supposed in this example that the path to the Scilab include directory is <tt>/usr/local/include/scilab</tt> (which is the case in a Debian environment), this should be changed for another environment.
+</p>
+
+<H3><a name="Scilab_running_swig_loading_module"></a>39.2.3 Loading the module</H3>
+
+
+<p>
+Loading a module is done by running the loader script in Scilab:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; exec loader.sce
+</pre></div>
+
+<p>
+Scilab should output the following messages:
+</p>
+
+<div class="targetlang"><pre>
+Shared archive loaded.
+Link done.
+</pre></div>
+
+<p>
+which means that Scilab has successfully loaded the shared library. The module functions and other symbols are now available in Scilab.
+</p>
+
+<H3><a name="Scilab_running_swig_using_module"></a>39.2.4 Using the module</H3>
+
+
+<p>
+In Scilab, the function <tt>fact()</tt> is simply called as following:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; fact(5)
+ans =
+
+ 120.
+</pre></div>
+
+<p>For the <tt>Foo</tt> global variable, the accessors need to be used:
+
+<div class="targetlang"><pre>
+--&gt; Foo_get
+ans =
+
+ 3.
+
+--&gt; Foo_set(4);
+
+--&gt; Foo_get
+ans =
+
+ 4.
+</pre></div>
+
+<p>
+Note: for conciseness, we assume in the subsequent Scilab code examples that the modules have been beforehand built and loaded in Scilab.
+</p>
+
+<H3><a name="Scilab_running_swig_options"></a>39.2.5 Scilab command line options</H3>
+
+
+<p>
+The following table lists the Scilab specific command line options in addition to the generic SWIG options:
+</p>
+
+<table summary="Scilab specific options">
+
+<tr>
+<td><tt>-builder</tt></td>
+<td>Generate the Scilab builder script</td>
+</tr>
+
+<tr>
+<td><tt>-buildercflags &lt;cflags&gt;</tt></td>
+<td>Add &lt;cflags&gt; to the builder compiler flags</td>
+</tr>
+
+<tr>
+<td><tt>-builderldflags &lt;ldflags&gt;</tt></td>
+<td>Add &lt;ldlags&gt; to the builder linker flags</td>
+</tr>
+
+<tr>
+<td><tt>-buildersources &lt;files&gt;</tt></td>
+<td>Add the (comma separated) files &lt;files&gt; to the builder sources</td>
+</tr>
+
+<tr>
+<td><tt>-builderverbositylevel &lt;level&gt;</tt></td>
+<td>Set the build verbosity level to &lt;level&gt; (default 0: off, 2: high)</td>
+</tr>
+
+<tr>
+<td><tt>-builderflagscript &lt;file&gt;</tt></td>
+<td>Use the Scilab script &lt;file&gt; to configure the compiler and linker flags</td>
+</tr>
+
+<tr>
+<td><tt>-gatewayxml &lt;gateway_id&gt;</tt></td>
+<td>Generate the gateway XML with the given &lt;gateway_id&gt;</td>
+</tr>
+
+</table>
+
+<p>
+These options can be displayed with:
+</p>
+
+<div class="shell"><pre>
+$ swig -scilab -help
+</pre></div>
+
+
+<H2><a name="Scilab_wrapping"></a>39.3 A basic tour of C/C++ wrapping</H2>
+
+
+<H3><a name="Scilab_wrapping_overview"></a>39.3.1 Overview</H3>
+
+
+<p>
+SWIG for Scilab provides only a low-level C interface for Scilab (see <a href="Scripting.html">Scripting Languages</a> for the general approach to wrapping).
+This means that functions, structs, classes, variables, etc... are interfaced through C functions. These C functions are mapped as Scilab functions.
+There are a few exceptions, such as constants and enumerations, which can be wrapped directly as Scilab variables.
+</p>
+
+<H3><a name="Scilab_wrapping_identifiers"></a>39.3.2 Identifiers</H3>
+
+
+<p>
+In Scilab 5.x, identifier names are composed of 24 characters maximum (this limitation should disappear from Scilab 6.0 onwards).
+<br>Thus long function or variable names may be truncated and this can cause ambiguities.
+</p>
+<p>This happens especially when wrapping structs/classes, for which the wrapped function name is composed of the struct/class name and field names.
+In these cases, the <a href="SWIG.html#SWIG_rename_ignore">%rename directive</a> can be used to choose a different Scilab name.
+</p>
+
+<H3><a name="Scilab_wrapping_functions"></a>39.3.3 Functions</H3>
+
+
+<p>
+Functions are wrapped as new Scilab built-in functions. For example:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%inline %{
+int fact(int n) {
+ if (n &gt; 1)
+ return n * fact(n - 1);
+ else
+ return 1;
+}
+%}
+</pre></div>
+
+<p>
+creates a built-in function <tt>fact(n)</tt> in Scilab:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; fact(4)
+ans =
+
+ 24.
+</pre></div>
+
+<H4><a name="Scilab_nn13"></a>39.3.3.1 Argument passing</H4>
+
+
+<p>
+In the above example, the function parameter is a primitive type and is marshalled by value.
+So this function is wrapped without any additional customization.
+Argument values are converted between C types and Scilab types through type mappings.
+There are several default type mappings for primitive and complex types, described later in the <a href="#Scilab_typemaps">Scilab typemaps</a> section.
+</p>
+
+<p>
+When a parameter is not passed by value, such as a pointer or reference, SWIG does not know if it is an input, output (or both) parameter.
+The INPUT, OUTPUT, INOUT typemaps defined in the <tt>typemaps.i</tt> library can be used to specify this.
+</p>
+
+<p>
+Let's see this on two simple functions: <tt>sub()</tt> which has an output parameter, and <tt>inc()</tt>, which as input/output parameter:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%include &lt;typemaps.i&gt;
+
+extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
+extern void inc(int *INOUT, int *INPUT);
+
+%{
+void sub(int *x, int *y, int *result) {
+ *result = *x - *y;
+}
+void inc(int *x, int *delta) {
+ *x = *x + *delta;
+}
+%}
+</pre></div>
+
+<p>
+In Scilab, parameters are passed by value. The output (and inout) parameters are returned as the result of the functions:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; sub(5, 3)
+ ans =
+
+ 2.
+
+--&gt; inc(4, 3)
+ ans =
+
+ 7.
+</pre></div>
+
+<H4><a name="Scilab_nn14"></a>39.3.3.2 Multiple output arguments</H4>
+
+
+<p>
+A C function can have several output parameters. They can all be returned as results of the wrapped function as Scilab supports multiple return values from a function
+when using the <tt>typemaps.i</tt> library.
+If the C function itself returns a result, this is returned first before the parameter outputs.
+</p>
+
+<p>
+The example below shows this for a C function returning 2 values and a result:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%include &lt;typemaps.i&gt;
+
+int divide(int n, int d, int *OUTPUT, int *OUTPUT);
+
+%{
+int divide(int n, int d, int q*, int *r) {
+ if (d != 0) {
+ *q = n / d;
+ *r = n % d;
+ return 1;
+ }
+ else return 0;
+}
+%}
+</pre></div>
+
+<br/>
+
+<div class="targetlang"><pre>
+--&gt; [ret, q, r] = divide(20, 6)
+ r =
+
+ 2.
+ q =
+
+ 3.
+ ret =
+
+ 1.
+</pre></div>
+
+
+<H3><a name="Scilab_wrapping_global_variables"></a>39.3.4 Global variables</H3>
+
+
+<p>
+Global variables are manipulated through generated accessor functions.
+For example, for a given <tt>Foo</tt> global variable, SWIG actually generates two functions: <tt>Foo_get()</tt> to get the value of <tt>Foo</tt>, and <tt>Foo_set()</tt> to set the value.
+These functions are used as following:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; exec loader.sce;
+--&gt; c = Foo_get();
+
+--&gt; Foo_set(4);
+
+--&gt; c
+c =
+
+ 3.
+
+--&gt; Foo_get()
+ans =
+
+ 4.
+</pre></div>
+
+<p>
+It works for variables of primitive type, but also for non-primitive types: arrays, and structs/classes which are described later.
+For now, an example with two global primitive arrays x and y is shown:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%inline %{
+int x[10];
+double y[7];
+
+void initArrays()
+{
+ int i;
+ for (i = 0; i &lt; 10; i++)
+ x[i] = 1;
+ for (i = 0; i &lt; 7; i++)
+ y[i] = 1.0f;
+}
+%}
+</pre></div>
+
+<p>
+It works the same:</p>
+
+<div class="targetlang"><pre>
+--&gt; exec loader.sce
+
+--&gt; initArrays();
+--&gt; x_get()
+ ans =
+
+ 1. 1. 1. 1. 1. 1. 1. 1. 1. 1.
+
+--&gt; y_set([0:6] / 10);
+--&gt; y_get()
+ ans =
+
+ 0. 0.1 0.2 0.3 0.4 0.5 0.6
+</pre></div>
+
+
+<H3><a name="Scilab_wrapping_constants_and_enums"></a>39.3.5 Constants and enumerations</H3>
+
+
+<H4><a name="Scilab_wrapping_constants"></a>39.3.5.1 Constants</H4>
+
+
+<p>
+There is not any constant in Scilab. By default, C/C++ constants are wrapped as getter functions. For example, for the following constants:
+</p>
+
+<div class="code"><pre>
+%module example
+#define ICONST 42
+#define FCONST 2.1828
+#define CCONST 'x'
+#define CCONST2 '\n'
+#define SCONST "Hello World"
+#define SCONST2 "\"Hello World\""
+</pre></div>
+
+<p>
+the following getter functions are generated:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; exec loader.sce;
+--&gt; ICONST_get();
+ ans =
+
+ 42.
+
+--&gt; FCONST_get();
+ ans =
+
+ 2.1828
+
+--&gt; CCONST_get();
+ ans =
+
+ x
+
+--&gt; CCONST2_get();
+ ans =
+
+--&gt; SCONST_get();
+ ans =
+
+ Hello World
+
+--&gt; SCONST2_get();
+ ans =
+
+ "Hello World"
+
+--&gt; EXPR_get();
+ ans =
+
+ 48.5484
+
+--&gt; iconst_get();
+ ans =
+
+ 37.
+
+--&gt; fconst_get();
+ ans =
+
+ 3.14
+</pre></div>
+
+<p>
+There is another mode in which constants are wrapped as Scilab variables.
+The variables are easier to use than functions, but the drawback is that variables are not constant and so can be modified.
+</p>
+
+<p>
+This mode can be enabled/disabled at any time in the interface file with <tt>%scilabconst()</tt>, which
+works like all the other <a href="Customization.html#Customization_features">%feature directives</a>.
+Use the argument value "1" to enable and "0" to disable this mode.
+For example in this mode the previous constants:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%scilabconst(1);
+#define ICONST 42
+#define FCONST 2.1828
+#define CCONST 'x'
+#define CCONST2 '\n'
+#define SCONST "Hello World"
+#define SCONST2 "\"Hello World\""
+</pre></div>
+
+<p>
+are mapped to Scilab variables, with the same name:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; exec loader.sce;
+--&gt; ICONST
+ ans =
+
+ 42
+
+--&gt; FCONST
+ ans =
+
+ 2.1828
+
+--&gt; CCONST
+ ans =
+
+ x
+
+--&gt; CCONST2
+ ans =
+
+--&gt; SCONST
+ ans =
+
+ Hello World
+
+--&gt; SCONST2
+ ans =
+
+ "Hello World"
+
+--&gt; EXPR
+ ans =
+
+ 48.5484
+
+--&gt; iconst
+ ans =
+
+ 37
+
+--&gt; fconst
+ ans =
+
+ 3.14
+</pre></div>
+
+<H4><a name="Scilab_wrapping_enums"></a>39.3.5.2 Enumerations</H4>
+
+
+<p>
+The wrapping of enums is the same as for constants.
+By default, enums are wrapped as getter functions.
+For example, with the following enumeration:
+</p>
+
+<div class="code"><pre>%module example
+typedef enum { RED, BLUE, GREEN } color;
+</pre></div>
+
+<p>
+a getter function will be generated for each value of the enumeration:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; exec loader.sce;
+--&gt; RED_get()
+ ans =
+
+ 0.
+
+--&gt; BLUE_get()
+ ans =
+
+ 1.
+
+--&gt; GREEN_get()
+ ans =
+
+ 2.
+</pre></div>
+
+<p>
+The <tt>%scilabconst()</tt> feature is also available for enumerations:
+</p>
+
+<div class="code"><pre>%module example
+%scilabconst(1) color;
+typedef enum { RED, BLUE, GREEN } color;
+</pre></div>
+
+<br/>
+
+<div class="targetlang"><pre>
+--&gt; exec loader.sce;
+--&gt; RED
+ ans =
+
+ 0.
+
+--&gt; BLUE
+ ans =
+
+ 1.
+
+--&gt; GREEN
+ ans =
+
+ 2.
+
+</pre></div>
+
+<H3><a name="Scilab_wrapping_pointers"></a>39.3.6 Pointers</H3>
+
+
+<p>
+C/C++ pointers are fully supported by SWIG. They are mapped to the Scilab pointer type ("pointer", type ID: 128).
+</p>
+
+<p>
+Given a wrapping of some of the C file functions:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%{
+#include &lt;stdio.h&gt;
+%}
+
+FILE *fopen(const char *filename, const char *mode);
+int fputs(const char *, FILE *);
+int fclose(FILE *);
+</pre></div>
+
+<p>
+These functions can be used in a natural way from Scilab:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; f = fopen("junk", "w");
+--&gt; typeof(f)
+ ans =
+
+ pointer
+
+--&gt; fputs("Hello World", f);
+--&gt; fclose(f);
+</pre></div>
+
+<p>
+The user of a pointer is responsible for freeing it or, like in the example, closing any resources associated with it (just as is required in a C program).
+</p>
+
+<H4><a name="Scilab_wrapping_pointers_pointer_adresses"></a>39.3.6.1 Utility functions</H4>
+
+
+<p>
+Most of time pointer manipulation is not needed in a scripting language such as Scilab.
+However, in some cases it can be useful, such as for testing or debugging.
+</p>
+
+<p>
+SWIG comes with two pointer utility functions:
+</p>
+<ul>
+<li><tt>SWIG_this()</tt>: returns the address value of a pointer</li>
+<li><tt>SWIG_ptr()</tt>: creates a pointer from an address value</li>
+</ul>
+
+<p>Following illustrates their use on the last example:</p>
+
+<div class="targetlang"><pre>
+--&gt; f = fopen("junk", "w");
+--&gt; fputs("Hello", f);
+--&gt; addr = SWIG_this(f)
+ ans =
+
+ 8219088.
+
+--&gt; p = SWIG_ptr(addr);
+--&gt; fputs(" World", p);
+--&gt; fclose(f);
+</pre></div>
+
+<H4><a name="Scilab_wrapping_pointers_null_pointers"></a>39.3.6.2 Null pointers</H4>
+
+
+<p>By default, Scilab does not provide a way to test or create null pointers.
+But it is possible to have a null pointer by using the previous functions <tt>SWIG_this()</tt> and <tt>SWIG_ptr()</tt>, like this:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; p = SWIG_ptr(0);
+--&gt; SWIG_this(p) == 0
+ ans =
+
+ T
+</pre></div>
+
+
+<H3><a name="Scilab_wrapping_structs"></a>39.3.7 Structures</H3>
+
+
+<p>
+Structs exist in Scilab, but C structs are not (at least in this version of SWIG) mapped to Scilab structs.
+A C structure is wrapped through low-level accessor functions, i.e. functions that give access to the member variables of this structure.
+In Scilab, a structure is manipulated through a pointer which is passed as an argument to the accessor functions.
+</p>
+
+<p>
+Let's see it on an example of a struct with two members:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%inline %{
+
+typedef struct {
+ int x;
+ int arr[4];
+} Foo;
+
+%}
+</pre></div>
+
+<p>
+Several functions are generated:
+</p>
+<ul>
+<li>a constructor function <tt>new_Foo()</tt> which returns a pointer to a newly created struct <tt>Foo</tt>.</li>
+<li>two member getter functions <tt>Foo_x_get()</tt>, <tt>Foo_arr_get()</tt>, to get the values of <tt>x</tt> and <tt>y</tt> for the struct pointer (provided as the first parameter to these functions)</li>
+<li>two member setter functions <tt>Foo_x_set()</tt>, <tt>Foo_arr_set()</tt>, to set the values of <tt>x</tt> and <tt>y</tt> for the struct pointer (provided as the first parameter to these functions).</li>
+<li>a destructor function <tt>delete_Foo()</tt> to release the struct pointer.</li>
+</ul>
+
+<p>
+Usage example:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; f = new_Foo();
+--&gt; Foo_x_set(f, 100);
+--&gt; Foo_x_get(f)
+ans =
+
+ 100.
+
+--&gt; Foo_arr_set(f, [0:3]);
+--&gt; Foo_arr_get(f)
+ans =
+
+ 0. 1. 2. 3.
+
+--&gt; delete_Foo(f);
+</pre></div>
+
+
+<p>
+Members of a structure that are also structures are also accepted and wrapped as a pointer:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%inline %{
+
+typedef struct {
+ int x;
+} Bar;
+
+typedef struct {
+ Bar b;
+} Foo;
+
+%}
+</pre></div>
+
+<br/>
+
+<div class="targetlang"><pre>
+--&gt; b = new_Bar();
+--&gt; Bar_x_set(b, 20.);
+
+--&gt; f = new_Foo();
+--&gt; Foo_b_set(f, b);
+
+--&gt; b2 = Foo_b_get(f);
+--&gt; Bar_x_get(b2);
+ans =
+
+ 20.
+</pre></div>
+
+
+<H3><a name="Scilab_wrapping_cpp_classes"></a>39.3.8 C++ Classes</H3>
+
+
+<p>
+Classes do not exist in Scilab. The classes are wrapped the same way as structs.
+Low-level accessor functions are generated for class members.
+Also, constructor and destructor functions are generated to create and destroy an instance of the class.
+</p>
+
+<p>
+For example, the following class:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%inline %{
+
+class Point {
+public:
+ int x, y;
+ Point(int _x, int _y) : x(_x), y(_y) {}
+ double distance(const Point&amp; rhs) {
+ return sqrt(pow(x-rhs.x, 2) + pow(y-rhs.y, 2));
+ }
+ void set(int _x, int _y) {
+ x=_x;
+ y=_y;
+ }
+};
+
+%}
+</pre></div>
+
+<p>
+can be used in Scilab like this:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; p1 = Point_new(3, 5);
+--&gt; p2 = Point_new(1, 2);
+--&gt; p1.distance(p2)
+ans =
+
+ 3.6056
+
+--&gt; delete_Point(p1);
+--&gt; delete_Point(p2);
+</pre></div>
+
+<H3><a name="Scilab_wrapping_cpp_inheritance"></a>39.3.9 C++ inheritance</H3>
+
+
+<p>
+Inheritance is supported. SWIG knows the inheritance relationship between classes.
+</p>
+
+<p>
+A function is only generated for the class in which it is actually declared.
+But if one of its parameters is a class, any instance of a derived class is accepted as the argument.
+</p>
+
+<p>
+This mechanism also applies for accessor functions: they are generated only in the class in which they are defined.
+But any instance of a derived class can be used as the argument to these accessor functions.
+</p>
+
+<p>
+For example, let's take a base class <tt>Shape</tt> and two derived classes <tt>Circle</tt> and <tt>Square</tt>:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%inline %{
+
+class Shape {
+public:
+ double x, y;
+ void set_location(double _x, double _y) { x = _x; y = _y; }
+ virtual double get_perimeter() { return 0; };
+};
+
+class Circle : public Shape {
+public:
+ int radius;
+ Circle(int _radius): radius(_radius) {};
+ virtual double get_perimeter() { return 6.28 * radius; }
+};
+
+class Square : public Shape {
+public:
+ int size;
+ Square(int _size): size(_size) {};
+ virtual double get_perimeter() { return 4 * size; }
+};
+
+%}
+</pre></div>
+
+<p>
+To set the location of the <tt>Circle</tt>, we have to use the function <tt>set_location()</tt> of the parent <tt>Shape</tt>.
+But we can use either use the <tt>get_perimeter()</tt> function of the parent class or the derived class:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; c = new_Circle(3);
+
+--&gt; Shape_set_location(c, 2, 3);
+--&gt; Shape_x_get(c)
+ ans =
+
+ 2.
+
+--&gt; Circle_get_perimeter(c)
+ ans =
+
+ 18.84
+
+--&gt; Shape_get_perimeter(c)
+ ans =
+
+ 18.84
+</pre></div>
+
+<H3><a name="Scilab_wrapping_pointers_references_values_arrays"></a>39.3.10 Pointers, references, values, and arrays</H3>
+
+
+<p>
+In C++ objects can be passed by value, pointer, reference, or by an array:
+</p>
+<div class="code"><pre>
+%module example
+
+%{
+#include &lt;sciprint.h&gt;
+%}
+
+%inline %{
+
+class Foo {
+public:
+ Foo(int _x) : x(_x) {}
+ int x;
+};
+
+void spam1(Foo *f) { sciprint("%d\n", f-&gt;x); } // Pass by pointer
+void spam2(Foo &amp;f) { sciprint("%d\n", f.x); } // Pass by reference
+void spam3(Foo f) { sciprint("%d\n", f.x); } // Pass by value
+void spam4(Foo f[]) { sciprint("%d\n", f[0].x); } // Array of objects
+
+%}
+</pre></div>
+<p>
+
+In SWIG, there is no real distinction between these.
+So in Scilab, it is perfectly legal to do this:
+</p>
+<div class="targetlang"><pre>
+--&gt; f = new_Foo()
+--&gt; spam1(f)
+3
+--&gt; spam2(f)
+3
+--&gt; spam3(f)
+3
+--&gt; spam4(f)
+3
+</pre></div>
+
+<p>
+Similar behaviour occurs for return values. For example, if you had functions like this:
+</p>
+<div class="code"><pre>
+Foo *spam5();
+Foo &amp;spam6();
+Foo spam7();
+</pre></div>
+<p>
+All these functions will return a pointer to an instance of <tt>Foo</tt>.
+As the function <tt>spam7</tt> returns a value, new instance of <tt>Foo</tt> has to be allocated, and a pointer on this instance is returned.
+</p>
+
+<H3><a name="Scilab_wrapping_cpp_templates"></a>39.3.11 C++ templates</H3>
+
+
+<p>
+As in other languages, function and class templates are supported in SWIG Scilab.
+</p>
+
+<p>
+You have to tell SWIG to create wrappers for a particular
+template instantiation. The <tt>%template</tt> directive is used for this purpose.
+For example:
+</p>
+
+<div class="code"><pre>
+%module example
+
+template&lt;class T1, class T2, class T3&gt;
+struct triplet {
+ T1 first;
+ T2 second;
+ T3 third;
+ triplet(const T1&amp; a, const T2&amp; b, const T3&amp; c) {
+ third = a; second = b; third = c;
+ }
+};
+
+%template(IntTriplet) triplet&lt;int,int,int&gt;;
+</pre></div>
+
+<p>
+Then in Scilab:
+</p>
+
+<div class="targetlang">
+<pre>
+--&gt; t = new_IntTriplet(3, 4, 1);
+
+--&gt; IntTriplet_first_get(t)
+ ans =
+
+ 3.
+
+--&gt; IntTriplet_second_get(t)
+ ans =
+
+ 4.
+
+--&gt; IntTriplet_third_get(t)
+ ans =
+
+ 1.
+
+--&gt; delete_IntTriplet(t);
+</pre>
+</div>
+
+<p>
+More details on template support can be found in the <a href="SWIGPlus.html#SWIGPlus_nn30">templates</a> documentation.
+</p>
+
+<H3><a name="Scilab_wrapping_cpp_operators"></a>39.3.12 C++ operators</H3>
+
+
+<p>
+C++ operators are partially supported.
+Operator overloading exists in Scilab, but a C++ operator is not (in this version) wrapped by SWIG as a Scilab operator, but as a function.
+It is not automatic, you have to rename each operator (with the instruction <tt>%rename</tt>) with the suitable wrapper name.
+</p>
+
+<p>
+Let's see it with an example of class with two operators <tt>+</tt> and <tt>double()</tt>:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%rename(plus) operator +;
+%rename(toDouble) operator double();
+
+%inline %{
+
+class Complex {
+public:
+ Complex(double re, double im) : real(re), imag(im) {};
+
+ Complex operator+(const Complex&amp; other) {
+ double result_real = real + other.real;
+ double result_imaginary = imag + other.imag;
+ return Complex(result_real, result_imaginary);
+ }
+ operator double() { return real; }
+private:
+ double real;
+ double imag;
+};
+
+%}
+</pre></div>
+
+<br/>
+
+<div class="targetlang"><pre>
+--&gt; c1 = new_Complex(3, 7);
+
+--&gt; c2 = Complex_plus(c, new_Complex(1,1));
+
+--&gt; Complex_toDouble(c2)
+ ans =
+
+ 4.
+</pre></div>
+
+
+<H3><a name="Scilab_wrapping_cpp_namespaces"></a>39.3.13 C++ namespaces</H3>
+
+
+<p>
+SWIG is aware of C++ namespaces, but does not use it for wrappers.
+The module is not broken into submodules, nor do namespace appear in functions names.
+All the namespaces are all flattened in the module.
+For example with one namespace <tt>Foo</tt>:
+</p>
+
+<div class="code">
+<pre>
+%module example
+
+%inline %{
+
+namespace foo {
+ int fact(int n) {
+ if (n &gt; 1)
+ return n * fact(n-1);
+ else
+ return 1;
+ }
+
+ struct Vector {
+ double x,y,z;
+ };
+};
+
+%}
+
+</pre>
+</div>
+
+<p>
+In Scilab, there is no need to the specify the <tt>Foo</tt> namespace:
+</p>
+
+<div class="targetlang">
+<pre>
+--&gt; fact(3)
+ ans =
+
+ 6.
+
+--&gt; v = new_Vector();
+--&gt; Vector_x_set(v, 3.4);
+--&gt; Vector_y_get(v)
+ ans =
+
+ 0.
+</pre>
+</div>
+
+<p>
+If your program has more than one namespace, name conflicts can be resolved using <tt>%rename</tt>.
+For example:
+</p>
+
+<div class="code">
+<pre>
+%rename(Bar_spam) Bar::spam;
+
+namespace Foo {
+ int spam();
+}
+
+namespace Bar {
+ int spam();
+}
+</pre>
+</div>
+
+<p>
+Note: the <a href="SWIGPlus.html#SWIGPlus_nspace"><tt>nspace</tt></a> feature is not supported.
+</p>
+
+
+<H3><a name="Scilab_wrapping_cpp_exceptions"></a>39.3.14 C++ exceptions</H3>
+
+
+<p>
+Scilab does not natively support exceptions, but has errors.
+When an exception is thrown, SWIG catches it, and sets a Scilab error. An error message is displayed in Scilab.
+For example:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%inline %{
+void throw_exception() throw(char const *) {
+ throw "Bye world !";
+}
+%}
+</pre></div>
+
+<br/>
+
+<div class="targetlang"><pre>
+--&gt;throw_exception()
+ !--error 999
+SWIG/Scilab: Exception (char const *) occured: Bye world !
+</pre></div>
+
+<p>
+Scilab has a <tt>try-catch</tt> mechanism (and a similar instruction <tt>execstr()</tt>) to handle exceptions.
+It can be used with the <tt>lasterror()</tt> function as following:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; execstr('throw_exception()', 'errcatch');
+ ans =
+
+ 999.
+
+--&gt; lasterror()
+ ans =
+
+ SWIG/Scilab: Exception (char const *) occured: Bye world !
+</pre></div>
+
+<p>
+If the function has a <tt>throw</tt> exception specification, SWIG can automatically map the exception type and set an appropriate Scilab error message.
+It works for a few primitive types, and also for STL exceptions (the library <tt>std_except.i</tt> has to be included to get the STL exception support):
+</p>
+
+<div class="code"><pre>
+%module example
+
+%include &lt;std_except.i&gt;
+
+%inline %{
+void throw_int() throw(int) {
+ throw 12;
+}
+
+void throw_stl_invalid_arg(int i) throw(std::invalid_argument) {
+ if (i &amp;lt 0)
+ throw std::invalid_argument("argument is negative.");
+}
+%}
+</pre></div>
+
+<br/>
+
+<div class="targetlang"><pre>
+--&gt; throw_int();
+ !--error 999
+SWIG/Scilab: Exception (int) occured: 12
+
+--&gt;throw_stl_invalid_arg(-1);
+ !--error 999
+SWIG/Scilab: ValueError: argument is negative.
+</pre></div>
+
+<p>
+More complex or custom exception types require specific exception typemaps to be implemented in order to specifically handle a thrown type.
+See the <a href="SWIGPlus.html#SWIGPlus">SWIG C++ documentation</a> for more details.
+</p>
+
+<H3><a name="Scilab_wrapping_cpp_stl"></a>39.3.15 C++ STL</H3>
+
+
+<p>
+The Standard Template Library (STL) is partially supported. See <a href="#Scilab_typemaps_stl">STL</a> for more details.
+</p>
+
+<H2><a name="Scilab_typemaps"></a>39.4 Type mappings and libraries</H2>
+
+
+<H3><a name="Scilab_typemaps_primitive_types"></a>39.4.1 Default primitive type mappings</H3>
+
+
+<p>
+The following table provides the equivalent Scilab type for C/C++ primitive types.
+</p>
+
+<div class="table">
+<table border="1" summary="Scilab default primitive type mappings">
+<tr>
+ <td><b>C/C++ type</b></td>
+ <td><b>Scilab type</b></td>
+</tr>
+<tr><td>bool</td><td>boolean</td></tr>
+<tr><td>char</td><td>string</td></tr>
+<tr><td>signed char</td><td>double or int8</td></tr>
+<tr><td>unsigned char</td><td>double or uint8</td></tr>
+<tr><td>short</td><td>double or int16</td></tr>
+<tr><td>unsigned short</td><td>double or uint16</td></tr>
+<tr><td>int</td><td>double or int32</td></tr>
+<tr><td>unsigned int</td><td>double or uint32</td></tr>
+<tr><td>long</td><td>double or int32</td></tr>
+<tr><td>unsigned long</td><td>double or uint32</td></tr>
+<tr><td>signed long long</td><td>not supported in Scilab 5.x</td></tr>
+<tr><td>unsigned long long</td><td>not supported in Scilab 5.x</td></tr>
+<tr><td>float</td><td>double</td></tr>
+<tr><td>double</td><td>double</td></tr>
+<tr><td>char * or char[]</td><td>string</td></tr>
+</table>
+</div>
+
+<p>
+Notes:
+</p>
+<ul>
+<li>In Scilab the <tt>double</tt> type is far more used than any integer type.
+This is why integer values (<tt>int32</tt>, <tt>uint32</tt>, ...) are automatically converted to Scilab <tt>double</tt> values when marshalled from C into Scilab.
+Additionally on input to a C function, Scilab <tt>double</tt> values are converted into the related integer type.
+</li>
+<li>
+When an integer is expected, if the input is a double, the value must be an integer, i.e. it must not have any decimal part, otherwise a SWIG value error occurs.
+</li>
+<li>
+In SWIG for Scilab 5.x, the <tt>long long</tt> type is not supported, since Scilab 5.x does not have a 64-bit integer type.
+The default behaviour is for SWIG to generate code that will give a runtime error if <tt>long long</tt> type arguments are used from Scilab.
+</li>
+</ul>
+
+
+<H3><a name="Scilab_typemaps_non-primitive_types"></a>39.4.2 Default type mappings for non-primitive types</H3>
+
+
+<p>
+The default mapped type for C/C++ non-primitive types is the Scilab pointer, for example for C structs, C++ classes, etc...
+</p>
+
+
+<H3><a name="Scilab_typemaps_arrays"></a>39.4.3 Arrays</H3>
+
+
+<p>
+Typemaps are available by default for arrays. Primitive type arrays are automatically converted to/from Scilab matrices.
+Typemaps are also provided to handle members of a struct or class that are arrays.
+</p>
+
+<p>
+In input, the matrix is usually one-dimensional (it can be either a row or column vector). But it can also be a two-dimensional matrix.
+Warning: in Scilab, the values are column-major ordered, unlike in C, which is row-major ordered.
+</p>
+
+<p>
+The type mappings used for arrays is the same for primitive types, described <a href="#Scilab_typemaps_primitive_types">earlier</a>.
+This means that, if needed, a Scilab <tt>double</tt> vector is converted in input into the related C integer array
+and this C integer array is automatically converted on output into a Scilab <tt>double</tt> vector.
+Note that unlike scalars, no control is done for arrays when a <tt>double</tt> is converted into an integer.
+</p>
+
+<p>
+The following example illustrates all this:</p>
+
+<div class="code"><pre>
+%module example
+
+%#include &lt;stdio.h&gt;
+
+%inline %{
+
+void printArray(int values[], int len) {
+ int i = 0;
+ for (i = 0; i &lt; len; i++) {
+ printf("%s %d %s", i==0?"[":"", values[i], i==len-1?"]\n":"");
+ }
+}
+%}
+</pre></div>
+
+<br/>
+
+<div class="targetlang"><pre>
+--&gt; printArray([0 1 2 3], 4)
+[ 0 1 2 3 ]
+
+--&gt; printArray([0.2; -1.8; 2; 3.7], 4)
+[ 0 -1 2 3 ]
+
+--&gt; printArray([0 1; 2 3], 4)
+[ 0 2 1 3 ]
+
+--&gt; printArray([0; 1; 2; 3], 4)
+[ 0 1 2 3 ]
+</pre></div>
+
+<H3><a name="Scilab_typemaps_pointer-to-pointers"></a>39.4.4 Pointer-to-pointers</H3>
+
+
+<p>
+There are no specific typemaps for pointer-to-pointers, they are are mapped as pointers in Scilab.
+</p>
+
+<p>
+Pointer-to-pointers are sometimes used to implement matrices in C. The following is a an example of this:
+</p>
+
+
+<div class="code"><pre>
+%module example
+%inline %{
+
+// Returns the matrix [1 2; 3 4];
+double **create_matrix() {
+ double **M;
+ int i;
+ M = (double **) malloc(2 * sizeof(double *));
+ for (i = 0; i &lt; 2; i++) {
+ M[i] = (double *) malloc(2 * sizeof(double));
+ M[i][0] = 2 * i + 1;
+ M[i][1] = 2 * i + 2;
+ }
+ return M;
+}
+
+// Gets the item M(i,j) value
+double get_matrix(double **M, int i, int j) {
+ return M[i][j];
+}
+
+// Sets the item M(i,j) value to be val
+void set_matrix(double **M, int i, int j, double val) {
+ M[i][j] = val;
+}
+
+// Prints a matrix (2,2) to console
+void print_matrix(double **M, int nbRows, int nbCols) {
+ int i, j;
+ for (i = 0; i &lt; 2; i++) {
+ for (j = 0; j &lt; 2; j++) {
+ printf("%3g ", M[i][j]);
+ }
+ printf("\n");
+ }
+}
+
+%}
+</pre></div>
+
+<p>
+ These functions are used like this in Scilab:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; m = create_matrix();
+
+--&gt; print_matrix(m);
+ 1. 2.
+ 3. 4.
+
+--&gt; set_matrix(m, 1, 1, 5.);
+
+--&gt; get_matrix(m, 1, 1)
+ ans =
+
+ 5.
+</pre></div>
+
+
+<H3><a name="Scilab_typemaps_matrices"></a>39.4.5 Matrices</H3>
+
+
+<p>
+The <tt>matrix.i</tt> library provides a set of typemaps which can be useful when working with one-dimensional and two-dimensional matrices.
+</p>
+
+<p>
+In order to use this library, just include it in the interface file:
+</p>
+
+<div class="code"><pre>
+ %include &lt;matrix.i&gt;
+</pre></div>
+
+
+<p>
+Several typemaps are available for the common Scilab matrix types:
+</p>
+<ul>
+<li><tt>double</tt></li>
+<li><tt>int</tt></li>
+<li><tt>char *</tt></li>
+<li><tt>bool</tt></li>
+</ul>
+
+<p>
+For example: for a matrix of <tt>int</tt>, we have the typemaps, for input:
+</p>
+<ul>
+<li><tt>(int *IN, int IN_ROWCOUNT, int IN_COLCOUNT)</tt></li>
+<li><tt>(int IN_ROWCOUNT, int IN_COLCOUNT, int *IN)</tt></li>
+<li><tt>(int *IN, int IN_SIZE)</tt></li>
+<li><tt>(int IN_SIZE, int *IN)</tt></li>
+</ul>
+
+<p>
+and output:
+</p>
+<ul>
+<li><tt>(int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)</tt></li>
+<li><tt>(int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)</tt></li>
+<li><tt>(int **OUT, int *OUT_SIZE)</tt></li>
+<li><tt>(int *OUT_SIZE, int **OUT)</tt></li>
+</ul>
+
+<p>
+They marshall a Scilab matrix type into the appropriate 2 or 3 C parameters.
+The following is an example using the typemaps in this library:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%include &lt;matrix.i&gt;
+
+%apply (int *IN, int IN_ROWCOUNT, int IN_COLCOUNT) { (int *matrix, int matrixNbRow, int matrixNbCol) };
+%apply (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { (int **outMatrix, int *outMatrixNbRow, int *outMatrixNbCol) };
+
+%inline %{
+
+void absolute(int *matrix, int matrixNbRow, int matrixNbCol,
+ int **outMatrix, int *outMatrixNbRow, int *outMatrixNbCol) {
+ int i, j;
+ *outMatrixNbRow = matrixNbRow;
+ *outMatrixNbCol = matrixNbCol;
+ *outMatrix = malloc(matrixNbRow * matrixNbCol * sizeof(int));
+ for (i=0; i &lt; matrixNbRow * matrixNbCol; i++) {
+ (*outMatrix)[i] = matrix[i] &gt; 0 ? matrix[i]:-matrix[i];
+ }
+}
+
+%}
+</pre></div>
+
+<br/>
+
+<div class="targetlang"><pre>
+--&gt; absolute([-0 1 -2; 3 4 -5])
+ ans =
+
+ 0. 1. 2.
+ 3. 4. 5.
+</pre></div>
+
+<p>
+The remarks made earlier for arrays also apply here:
+</p>
+<ul>
+<li>The values of matrices in Scilab are column-major orderered,</li>
+<li>There is no control while converting <tt>double</tt> values to integers, <tt>double</tt> values are truncated without any checking or warning.</li>
+</ul>
+
+<H3><a name="Scilab_typemaps_stl"></a>39.4.6 STL</H3>
+
+
+<p>
+The STL library wraps some containers defined in the STL (Standard Template Library), so that they can be manipulated in Scilab.
+This library also provides the appropriate typemaps to use the containers in functions and variables.
+</p>
+
+<p>
+The list of wrapped sequence containers are:
+</p>
+<ul>
+<li><tt>std::vector</tt></li>
+<li><tt>std::list</tt></li>
+<li><tt>std::deque</tt></li>
+</ul>
+
+<p>
+And associative containers are:
+</p>
+<ul>
+<li><tt>std::set</tt></li>
+<li><tt>std::multiset</tt></li>
+</ul>
+
+<p>
+Typemaps are available for the following container types:
+</p>
+
+<ul>
+<li><tt>double</tt></li>
+<li><tt>float</tt></li>
+<li><tt>int</tt></li>
+<li><tt>string</tt></li>
+<li><tt>bool</tt></li>
+<li><tt>pointer</tt></li>
+</ul>
+
+<p>
+Containers of other item types are not supported. Using them does not break compilation, but provokes a runtime error.
+Containers of enum are not supported yet.
+</p>
+
+<p>
+In order to use the STL, the library must first be included in the SWIG interface file:
+</p>
+
+<div class="code"><pre>
+%include &lt;stl.i&gt;
+</pre/></div>
+
+<p>Then for each container used, the appropriate template must be instantiated, in the <tt>std</tt> namespace:
+<div class="code"><pre>
+namespace std {
+ %template(IntVector) vector&lt;int&gt;;
+ %template(DoubleVector) vector&lt;double&gt;;
+}
+</pre></div>
+
+<p>
+Additionally, the module initialization function has to be executed first in Scilab, so that all the types are known to Scilab.
+See the <a href="#Scilab_module_initialization">Module initialization</a> section for more details.
+</p>
+
+
+<p>
+Because in Scilab matrices exist for basic types only, a sequence container of pointers is mapped to a Scilab list.
+For other item types (double, int, string...) the sequence container is mapped to a Scilab matrix.
+</p>
+
+<p>
+The first example below shows how to create a vector (of <tt>int</tt>) in Scilab, add some values to the vector and pass it as an argument of a function.
+It also shows, thanks to the typemaps, that we can also pass a Scilab matrix of values directly into the function:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%include &lt;stl.i&gt;
+
+namespace std {
+ %template(IntVector) vector&lt;int&gt;;
+}
+
+%{
+#include &lt;numeric&gt;
+%}
+
+%inline %{
+
+double average(std::vector&lt;int&gt; v) {
+ return std::accumulate(v.begin(), v.end(), 0.0) / v.size();
+}
+
+%}
+</pre></div>
+
+<br/>
+
+<div class="targetlang"><pre>
+--&gt; example_Init();
+
+--&gt; v = new_IntVector();
+
+--&gt; for i = 1:4
+--&gt; IntVector_push_back(v, i);
+--&gt; end;
+
+--&gt; average(v)
+ ans =
+
+ 2.5
+
+--&gt; average([0 1 2 3])
+ ans =
+
+ 2.5
+
+--&gt; delete_IntVector();
+</pre></div>
+
+
+<p>
+In the second example, a set of struct (<tt>Person</tt>) is wrapped.
+A function performs a search in this set, and returns a subset. As one can see, the result in Scilab is a list of pointers:
+</p>
+
+<div class="code"><pre>
+%module example
+
+%include &lt;stl.i&gt;
+
+%{
+#include &lt;string&gt;
+%}
+
+%inline %{
+
+struct Person {
+ Person(std::string _name, int _age) : name(_name), age(_age) {};
+ std::string name;
+ int age;
+};
+typedef Person * PersonPtr;
+
+%}
+
+namespace std {
+ %template(PersonPtrSet) set&lt;PersonPtr&gt;;
+}
+
+%inline %{
+
+std::set&lt;PersonPtr&gt; findPersonsByAge(std::set&lt;PersonPtr&gt; persons, int minAge, int maxAge) {
+ std::set&lt;PersonPtr&gt; foundPersons;
+ for (std::set&lt;PersonPtr&gt;::iterator it = persons.begin(); it != persons.end(); it++) {
+ if (((*it)-&gt;age &gt;= minAge) &amp;&amp; ((*it)-&gt;age &lt;= maxAge)) {
+ foundPersons.insert(*it);
+ }
+ }
+ return foundPersons;
+}
+
+%}
+</pre></div>
+
+<br/>
+
+<div class="targetlang"><pre>
+--&gt; example_Init();
+
+--&gt; joe = new_Person("Joe", 25);
+--&gt; susan = new_Person("Susan", 32);
+--&gt; bill = new_Person("Bill", 50);
+
+--&gt; p = new_PersonPtrSet();
+--&gt; PersonPtrSet_insert(p, susan);
+--&gt; PersonPtrSet_insert(p, joe);
+--&gt; PersonPtrSet_insert(p, bill);
+
+--&gt; l = findPersonsByAge(p, 20, 40);
+
+--&gt; size(l)
+ ans =
+
+ 2.
+
+--&gt; Person_name_get(l(1))
+ans =
+
+ Susan
+
+--&gt; Person_name_get(l(2))
+ ans =
+
+ Joe
+
+--&gt; delete_PersonPtrSet(p);
+</pre></div>
+
+<H2><a name="Scilab_module_initialization"></a>39.5 Module initialization</H2>
+
+
+<p>
+The wrapped module contains an initialization function to:
+</p>
+<ul>
+<li>initialize the SWIG runtime, which is necessary when working with the STL</li>
+<li>initialize in Scilab the module constants and enumerations declared with <tt>%scilabconst()</tt></li>
+</ul>
+
+<p>
+This initialization function should be executed at the start of a script, before the wrapped library has to be used.
+</p>
+
+<p>
+The function has the name of the module suffixed by <tt>_Init</tt>.
+For example, to initialize the module <tt>example</tt>:
+</p>
+
+<div class="targetlang"><pre>
+--&gt; example_Init();
+</pre></div>
+
+<H2><a name="Scilab_building_modes"></a>39.6 Building modes</H2>
+
+
+<p>
+The mechanism to load an external module in Scilab is called <i>Dynamic Link</i> and works with dynamic modules (or shared libraries, <tt>.so</tt> files).
+</p>
+
+<p>
+To produce a dynamic module, when generating the wrapper, there are two possibilities, or build modes:
+</p>
+<ul>
+<li>the <tt>nobuilder</tt> mode, this is the default mode in SWIG. The user is responsible of the build.
+<li>the <tt>builder</tt> mode. In this mode, Scilab is responsible of building.
+</ul>
+
+<H3><a name="Scilab_building_modes_nobuilder_mode"></a>39.6.1 No-builder mode</H3>
+
+
+<p>
+In this mode, used by default, SWIG generates the wrapper sources, which have to be manually compiled and linked.
+A loader script <tt>loader.sce</tt> is also produced, this one is executed further in Scilab to load the module.
+</p>
+
+<p>
+This mode is the best option to use when you have to integrate the module build into a larger build process.
+</p>
+
+
+<H3><a name="Scilab_building_modes_builder_mode"></a>39.6.2 Builder mode</H3>
+
+
+<p>
+In this mode, in addition to the wrapper sources, SWIG produces a builder Scilab script (<tt>builder.sce</tt>), which is executed in Scilab to build the module.
+In a few words, the Scilab <tt>ilib_build()</tt> command is used, which produces the shared library file, and the loader script <tt>loader.sce</tt> (and also a cleaner script <tt>cleaner.sce</tt>).
+</p>
+
+<p>
+An advantage of this mode is that it hides all the complexity of the build and other platform issues.
+Also it allows the module to conform to a Scilab external module convention which is that an external module should be simply built by calling a builder script.
+</p>
+
+<p>
+The builder mode is activated with the <tt>-builder</tt> SWIG option.
+In this mode, the following SWIG options may be used to setup the build:
+</p>
+
+<ul>
+<li><tt><b>-buildersources</b></tt>: to add sources to the build (several files must be separated by a comma)</li>
+<li><tt><b>-buildercflags</b></tt>: to add flags to the builder compiler flags, for example to set library dependencies include paths</li>
+<li><tt><b>-builderldflags</b></tt>: to add flags to the linker flags, for example to set library dependency names and paths</li>
+</ul>
+
+<p>
+Let's give an example how to build a module <tt>example</tt>, composed of two sources, and using a library dependency:
+</p>
+<ul>
+<li>the sources are <tt>baa1.c</tt> and <tt>baa2.c</tt> (and are stored in in the current directory)</li>
+<li>the library is <tt>libfoo</tt> in <tt>/opt/foo</tt> (headers stored in <tt>/opt/foo/include</tt>, and shared library in <tt>/opt/foo/lib</tt>)</li>
+</ul>
+
+<p>
+The command is:
+</p>
+
+<div class="shell"><pre>
+$ swig -scilab -builder -buildercflags -I/opt/foo/include -builderldflags "-L/opt/foo/lib -lfoo" -buildersources baa1.cxx,baa2.cxx example.i
+</pre></div>
+
+<H2><a name="Scilab_generated_scripts"></a>39.7 Generated scripts</H2>
+
+
+<p>
+In this part we give some details about the generated Scilab scripts.
+</p>
+
+<H3><a name="Scilab_generated_scripts_builder_script"></a>39.7.1 Builder script</H3>
+
+
+<p>
+<tt>builder.sce</tt> is the name of the builder script generated by SWIG in <tt>builder</tt> mode. It contains code like this:
+</p>
+<div class="code"><pre>
+ilib_name = "examplelib";
+files = ["example_wrap.c"];
+libs = [];
+table = ["fact","_wrap_fact";"Foo_set","_wrap_Foo_set";"Foo_get","_wrap_Foo_get";];
+ilib_build(ilib_name,table,files,libs);
+</pre></div>
+
+<p>
+<tt>ilib_build(lib_name,table,files,libs)</tt> is used to create shared libraries, and to generate a loader file used to dynamically load the shared library into Scilab.
+</p>
+
+<ul>
+<li><tt><b>ilib_name</b></tt>: a character string, the generic name of the library without path and extension.</li>
+<li><tt><b>files</b></tt>: string matrix containing objects files needed for shared library creation.</li>
+<li><tt><b>libs</b></tt>: string matrix containing extra libraries needed for shared library creation.</li>
+<li><tt><b>table</b></tt>: two column string matrix containing a table of pairs of 'scilab function name', 'C function name'.</li>
+</ul>
+
+<H3><a name="Scilab_generated_scripts_loader_script"></a>39.7.2 Loader script</H3>
+
+
+<p>
+The loader script is used to load in Scilab all the module functions. When loaded, these functions can be used as other Scilab functions.
+</p>
+
+<p>
+The loader script <tt>loader.sce</tt> contains code similar to:
+</p>
+
+<div class="code"><pre>
+// ------------------------------------------------------
+// generated by builder.sce: Please do not edit this file
+// ------------------------------------------------------
+
+libexamplelib_path = get_file_path('loader.sce');
+list_functions = [ 'fact';
+ 'Foo_set';
+ 'Foo_get';
+];
+addinter(libexamplelib_path+'/libexamplelib.so','libexamplelib',list_functions);
+// remove temp. variables on stack
+clear libexamplelib_path;
+clear list_functions;
+clear get_file_path;
+// ------------------------------------------------------
+</pre></div>
+
+<p>
+<tt>addinter(files,spname,fcts)</tt> performs dynamic linking of a compiled C interface function.
+</p>
+<ul>
+<li><tt><b>files</b></tt>: a character string or a vector of character strings defining the object files (containing the C interface functions) to link with.</li>
+<li><tt><b>spname</b></tt>: a character string. Name of interface routine entry point.</li>
+<li><tt><b>fcts</b></tt>: vector of character strings. The name of new Scilab function.</li>
+</ul>
+
+
+<H2><a name="Scilab_other_resources"></a>39.8 Other resources</H2>
+
+
+<ul>
+<li>Example use cases can be found in the <tt>Examples/scilab</tt> directory.</li>
+<li>The test suite in the <tt>Examples/test-suite/scilab</tt> can be another source of useful use cases.</li>
+<li>The <a href="http://help.scilab.org/docs/5.5.0/en_US/api_scilab.html">Scilab API</a> is used in the generated code and is a useful reference when examining the output.</li>
+<li>This <a href="http://wiki.scilab.org/howto/Create%20a%20toolbox">guide</a> describes the Scilab external modules structure and files, in particular the files that are generated by SWIG for Scilab.</li>
+</ul>
+
diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
index 0bda3e106..057d355ec 100644
--- a/Doc/Manual/Sections.html
+++ b/Doc/Manual/Sections.html
@@ -6,7 +6,7 @@
<body bgcolor="#ffffff">
<H1><a name="Sections"></a>SWIG-3.0 Documentation</H1>
-Last update : SWIG-3.0.3 (in progress)
+Last update : SWIG-3.0.6 (in progress)
<H2>Sections</H2>
@@ -55,6 +55,7 @@ Last update : SWIG-3.0.3 (in progress)
<li><a href="Python.html#Python">Python support</a></li>
<li><a href="R.html#R">R support</a></li>
<li><a href="Ruby.html#Ruby">Ruby support</a></li>
+<li><a href="Scilab.html#Scilab">Scilab support</a></li>
<li><a href="Tcl.html#Tcl">Tcl support</a></li>
</ul>
diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html
index 45218f303..874a5325a 100644
--- a/Doc/Manual/Tcl.html
+++ b/Doc/Manual/Tcl.html
@@ -6,7 +6,7 @@
</head>
<body bgcolor="#ffffff">
-<H1><a name="Tcl"></a>39 SWIG and Tcl</H1>
+<H1><a name="Tcl"></a>40 SWIG and Tcl</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -83,7 +83,7 @@ Tcl 8.0 or a later release. Earlier releases of SWIG supported Tcl 7.x, but
this is no longer supported.
</p>
-<H2><a name="Tcl_nn2"></a>39.1 Preliminaries</H2>
+<H2><a name="Tcl_nn2"></a>40.1 Preliminaries</H2>
<p>
@@ -109,7 +109,7 @@ build a Tcl extension module. To finish building the module, you
need to compile this file and link it with the rest of your program.
</p>
-<H3><a name="Tcl_nn3"></a>39.1.1 Getting the right header files</H3>
+<H3><a name="Tcl_nn3"></a>40.1.1 Getting the right header files</H3>
<p>
@@ -127,7 +127,7 @@ this is the case, you should probably make a symbolic link so that <tt>tcl.h</tt
header file.
</p>
-<H3><a name="Tcl_nn4"></a>39.1.2 Compiling a dynamic module</H3>
+<H3><a name="Tcl_nn4"></a>40.1.2 Compiling a dynamic module</H3>
<p>
@@ -163,7 +163,7 @@ The name of the module is specified using the <tt>%module</tt> directive or the
<tt>-module</tt> command line option.
</p>
-<H3><a name="Tcl_nn5"></a>39.1.3 Static linking</H3>
+<H3><a name="Tcl_nn5"></a>40.1.3 Static linking</H3>
<p>
@@ -229,7 +229,7 @@ minimal in most situations (and quite frankly not worth the extra
hassle in the opinion of this author).
</p>
-<H3><a name="Tcl_nn6"></a>39.1.4 Using your module</H3>
+<H3><a name="Tcl_nn6"></a>40.1.4 Using your module</H3>
<p>
@@ -357,7 +357,7 @@ to the default system configuration (this requires root access and you will need
the man pages).
</p>
-<H3><a name="Tcl_nn7"></a>39.1.5 Compilation of C++ extensions</H3>
+<H3><a name="Tcl_nn7"></a>40.1.5 Compilation of C++ extensions</H3>
<p>
@@ -440,7 +440,7 @@ erratic program behavior. If working with lots of software components, you
might want to investigate using a more formal standard such as COM.
</p>
-<H3><a name="Tcl_nn8"></a>39.1.6 Compiling for 64-bit platforms</H3>
+<H3><a name="Tcl_nn8"></a>40.1.6 Compiling for 64-bit platforms</H3>
<p>
@@ -467,7 +467,7 @@ also introduce problems on platforms that support more than one
linking standard (e.g., -o32 and -n32 on Irix).
</p>
-<H3><a name="Tcl_nn9"></a>39.1.7 Setting a package prefix</H3>
+<H3><a name="Tcl_nn9"></a>40.1.7 Setting a package prefix</H3>
<p>
@@ -486,7 +486,7 @@ option will append the prefix to the name when creating a command and
call it "<tt>Foo_bar</tt>".
</p>
-<H3><a name="Tcl_nn10"></a>39.1.8 Using namespaces</H3>
+<H3><a name="Tcl_nn10"></a>40.1.8 Using namespaces</H3>
<p>
@@ -508,7 +508,7 @@ When the <tt>-namespace</tt> option is used, objects in the module
are always accessed with the namespace name such as <tt>Foo::bar</tt>.
</p>
-<H2><a name="Tcl_nn11"></a>39.2 Building Tcl/Tk Extensions under Windows 95/NT</H2>
+<H2><a name="Tcl_nn11"></a>40.2 Building Tcl/Tk Extensions under Windows 95/NT</H2>
<p>
@@ -519,7 +519,7 @@ covers the process of using SWIG with Microsoft Visual C++.
although the procedure may be similar with other compilers.
</p>
-<H3><a name="Tcl_nn12"></a>39.2.1 Running SWIG from Developer Studio</H3>
+<H3><a name="Tcl_nn12"></a>40.2.1 Running SWIG from Developer Studio</H3>
<p>
@@ -577,7 +577,7 @@ MSDOS &gt; tclsh80
%
</pre></div>
-<H3><a name="Tcl_nn13"></a>39.2.2 Using NMAKE</H3>
+<H3><a name="Tcl_nn13"></a>40.2.2 Using NMAKE</H3>
<p>
@@ -640,7 +640,7 @@ to get you started. With a little practice, you'll be making lots of
Tcl extensions.
</p>
-<H2><a name="Tcl_nn14"></a>39.3 A tour of basic C/C++ wrapping</H2>
+<H2><a name="Tcl_nn14"></a>40.3 A tour of basic C/C++ wrapping</H2>
<p>
@@ -651,7 +651,7 @@ classes. This section briefly covers the essential aspects of this
wrapping.
</p>
-<H3><a name="Tcl_nn15"></a>39.3.1 Modules</H3>
+<H3><a name="Tcl_nn15"></a>40.3.1 Modules</H3>
<p>
@@ -685,7 +685,7 @@ To fix this, supply an extra argument to <tt>load</tt> like this:
</pre>
</div>
-<H3><a name="Tcl_nn16"></a>39.3.2 Functions</H3>
+<H3><a name="Tcl_nn16"></a>40.3.2 Functions</H3>
<p>
@@ -710,7 +710,7 @@ like you think it does:
%
</pre></div>
-<H3><a name="Tcl_nn17"></a>39.3.3 Global variables</H3>
+<H3><a name="Tcl_nn17"></a>40.3.3 Global variables</H3>
<p>
@@ -790,7 +790,7 @@ extern char *path; // Read-only (due to %immutable)
</pre>
</div>
-<H3><a name="Tcl_nn18"></a>39.3.4 Constants and enums</H3>
+<H3><a name="Tcl_nn18"></a>40.3.4 Constants and enums</H3>
<p>
@@ -874,7 +874,7 @@ When an identifier name is given, it is used to perform an implicit hash-table l
conversion. This allows the <tt>global</tt> statement to be omitted.
</p>
-<H3><a name="Tcl_nn19"></a>39.3.5 Pointers</H3>
+<H3><a name="Tcl_nn19"></a>40.3.5 Pointers</H3>
<p>
@@ -970,7 +970,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
<tt>None</tt> if the conversion can't be performed.
</p>
-<H3><a name="Tcl_nn20"></a>39.3.6 Structures</H3>
+<H3><a name="Tcl_nn20"></a>40.3.6 Structures</H3>
<p>
@@ -1252,7 +1252,7 @@ Note: Tcl only destroys the underlying object if it has ownership. See the
memory management section that appears shortly.
</p>
-<H3><a name="Tcl_nn21"></a>39.3.7 C++ classes</H3>
+<H3><a name="Tcl_nn21"></a>40.3.7 C++ classes</H3>
<p>
@@ -1319,7 +1319,7 @@ In Tcl, the static member is accessed as follows:
</pre>
</div>
-<H3><a name="Tcl_nn22"></a>39.3.8 C++ inheritance</H3>
+<H3><a name="Tcl_nn22"></a>40.3.8 C++ inheritance</H3>
<p>
@@ -1368,7 +1368,7 @@ For instance:
It is safe to use multiple inheritance with SWIG.
</p>
-<H3><a name="Tcl_nn23"></a>39.3.9 Pointers, references, values, and arrays</H3>
+<H3><a name="Tcl_nn23"></a>40.3.9 Pointers, references, values, and arrays</H3>
<p>
@@ -1422,7 +1422,7 @@ to hold the result and a pointer is returned (Tcl will release this memory
when the return value is garbage collected).
</p>
-<H3><a name="Tcl_nn24"></a>39.3.10 C++ overloaded functions</H3>
+<H3><a name="Tcl_nn24"></a>40.3.10 C++ overloaded functions</H3>
<p>
@@ -1545,7 +1545,7 @@ first declaration takes precedence.
Please refer to the "SWIG and C++" chapter for more information about overloading.
</p>
-<H3><a name="Tcl_nn25"></a>39.3.11 C++ operators</H3>
+<H3><a name="Tcl_nn25"></a>40.3.11 C++ operators</H3>
<p>
@@ -1647,7 +1647,7 @@ There are ways to make this operator appear as part of the class using the <tt>%
Keep reading.
</p>
-<H3><a name="Tcl_nn26"></a>39.3.12 C++ namespaces</H3>
+<H3><a name="Tcl_nn26"></a>40.3.12 C++ namespaces</H3>
<p>
@@ -1711,7 +1711,7 @@ utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
</p>
-<H3><a name="Tcl_nn27"></a>39.3.13 C++ templates</H3>
+<H3><a name="Tcl_nn27"></a>40.3.13 C++ templates</H3>
<p>
@@ -1763,7 +1763,7 @@ More details can be found in the <a href="SWIGPlus.html#SWIGPlus">SWIG and C++</
examples will appear later.
</p>
-<H3><a name="Tcl_nn28"></a>39.3.14 C++ Smart Pointers</H3>
+<H3><a name="Tcl_nn28"></a>40.3.14 C++ Smart Pointers</H3>
<p>
@@ -1847,7 +1847,7 @@ simply use the <tt>__deref__()</tt> method. For example:
</pre>
</div>
-<H2><a name="Tcl_nn29"></a>39.4 Further details on the Tcl class interface</H2>
+<H2><a name="Tcl_nn29"></a>40.4 Further details on the Tcl class interface</H2>
<p>
@@ -1860,7 +1860,7 @@ of low-level details were omitted. This section provides a brief overview
of how the proxy classes work.
</p>
-<H3><a name="Tcl_nn30"></a>39.4.1 Proxy classes</H3>
+<H3><a name="Tcl_nn30"></a>40.4.1 Proxy classes</H3>
<p>
@@ -1925,7 +1925,7 @@ function. This allows objects to be encapsulated objects that look a lot like
as shown in the last section.
</p>
-<H3><a name="Tcl_nn31"></a>39.4.2 Memory management</H3>
+<H3><a name="Tcl_nn31"></a>40.4.2 Memory management</H3>
<p>
@@ -2113,7 +2113,7 @@ typemaps--an advanced topic discussed later.
</p>
-<H2><a name="Tcl_nn32"></a>39.5 Input and output parameters</H2>
+<H2><a name="Tcl_nn32"></a>40.5 Input and output parameters</H2>
<p>
@@ -2301,7 +2301,7 @@ set c [lindex $dim 1]
</pre>
</div>
-<H2><a name="Tcl_nn33"></a>39.6 Exception handling </H2>
+<H2><a name="Tcl_nn33"></a>40.6 Exception handling </H2>
<p>
@@ -2435,7 +2435,7 @@ Since SWIG's exception handling is user-definable, you are not limited to C++ ex
See the chapter on "<a href="Customization.html#Customization">Customization Features</a>" for more examples.
</p>
-<H2><a name="Tcl_nn34"></a>39.7 Typemaps</H2>
+<H2><a name="Tcl_nn34"></a>40.7 Typemaps</H2>
<p>
@@ -2452,7 +2452,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Tcl interface.
</p>
-<H3><a name="Tcl_nn35"></a>39.7.1 What is a typemap?</H3>
+<H3><a name="Tcl_nn35"></a>40.7.1 What is a typemap?</H3>
<p>
@@ -2569,7 +2569,7 @@ parameter is omitted):
</pre>
</div>
-<H3><a name="Tcl_nn36"></a>39.7.2 Tcl typemaps</H3>
+<H3><a name="Tcl_nn36"></a>40.7.2 Tcl typemaps</H3>
<p>
@@ -2707,7 +2707,7 @@ Initialize an argument to a value before any conversions occur.
Examples of these methods will appear shortly.
</p>
-<H3><a name="Tcl_nn37"></a>39.7.3 Typemap variables</H3>
+<H3><a name="Tcl_nn37"></a>40.7.3 Typemap variables</H3>
<p>
@@ -2778,7 +2778,7 @@ properly assigned.
The Tcl name of the wrapper function being created.
</div>
-<H3><a name="Tcl_nn38"></a>39.7.4 Converting a Tcl list to a char ** </H3>
+<H3><a name="Tcl_nn38"></a>40.7.4 Converting a Tcl list to a char ** </H3>
<p>
@@ -2840,7 +2840,7 @@ argv[2] = Larry
3
</pre></div>
-<H3><a name="Tcl_nn39"></a>39.7.5 Returning values in arguments</H3>
+<H3><a name="Tcl_nn39"></a>40.7.5 Returning values in arguments</H3>
<p>
@@ -2882,7 +2882,7 @@ result, a Tcl function using these typemaps will work like this :
%
</pre></div>
-<H3><a name="Tcl_nn40"></a>39.7.6 Useful functions</H3>
+<H3><a name="Tcl_nn40"></a>40.7.6 Useful functions</H3>
<p>
@@ -2958,7 +2958,7 @@ int Tcl_IsShared(Tcl_Obj *obj);
</pre>
</div>
-<H3><a name="Tcl_nn41"></a>39.7.7 Standard typemaps</H3>
+<H3><a name="Tcl_nn41"></a>40.7.7 Standard typemaps</H3>
<p>
@@ -3043,7 +3043,7 @@ work)
</pre>
</div>
-<H3><a name="Tcl_nn42"></a>39.7.8 Pointer handling</H3>
+<H3><a name="Tcl_nn42"></a>40.7.8 Pointer handling</H3>
<p>
@@ -3119,7 +3119,7 @@ For example:
</pre>
</div>
-<H2><a name="Tcl_nn43"></a>39.8 Turning a SWIG module into a Tcl Package.</H2>
+<H2><a name="Tcl_nn43"></a>40.8 Turning a SWIG module into a Tcl Package.</H2>
<p>
@@ -3191,7 +3191,7 @@ As a final note, most SWIG examples do not yet use the
to use the <tt>load</tt> command instead.
</p>
-<H2><a name="Tcl_nn44"></a>39.9 Building new kinds of Tcl interfaces (in Tcl)</H2>
+<H2><a name="Tcl_nn44"></a>40.9 Building new kinds of Tcl interfaces (in Tcl)</H2>
<p>
@@ -3290,7 +3290,7 @@ danger of blowing something up (although it is easily accomplished
with an out of bounds array access).
</p>
-<H3><a name="Tcl_nn45"></a>39.9.1 Proxy classes</H3>
+<H3><a name="Tcl_nn45"></a>40.9.1 Proxy classes</H3>
<p>
@@ -3411,7 +3411,7 @@ short, but clever Tcl script can be combined with SWIG to do many
interesting things.
</p>
-<H2><a name="Tcl_nn46"></a>39.10 Tcl/Tk Stubs</H2>
+<H2><a name="Tcl_nn46"></a>40.10 Tcl/Tk Stubs</H2>
<p>
diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
index 99b89c425..fda162615 100644
--- a/Doc/Manual/Warnings.html
+++ b/Doc/Manual/Warnings.html
@@ -349,9 +349,9 @@ These can be overridden using command line options, for example:
<div class="shell"><pre>
$ swig -python -Fstandard example.i
-example.i:4: Syntax error in input.
+example.i:4: Syntax error in input(1).
$ swig -python -Fmicrosoft example.i
-example.i(4) : Syntax error in input.
+example.i(4) : Syntax error in input(1).
</pre></div>
<H2><a name="Warnings_nn9"></a>15.9 Warning number reference</H2>
diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters
index 32cf0b2dd..4e513beac 100644
--- a/Doc/Manual/chapters
+++ b/Doc/Manual/chapters
@@ -36,6 +36,7 @@ Pike.html
Python.html
R.html
Ruby.html
+Scilab.html
Tcl.html
Extending.html
Doxygen.html
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index ea4c65654..6fccda22e 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -485,11 +485,10 @@ guile: $(SRCDIR_SRCS)
$(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ISRCS) $(SRCDIR_SRCS)
$(LDSHARED) $(CFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
-guile_cpp: $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
-$(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO): $(SRCDIR_SRCS)
+guile_cpp: $(SRCDIR_SRCS)
$(SWIG) -c++ -guile -Linkage passive $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
$(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) $(GUILE_CFLAGS) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
- $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) $(CPP_DLLIBS) -o $@
+ $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(OBJS) $(IOBJS) $(GUILE_LIBS) $(LIBS) $(CPP_DLLIBS) -o $(GUILE_LIBPREFIX)$(TARGET)$(GUILE_SO)
guile_externalhdr:
$(SWIG) -guile -external-runtime $(TARGET)
@@ -596,7 +595,7 @@ java_cpp: $(SRCDIR_SRCS)
# ----------------------------------------------------------------
java_compile: $(SRCDIR_SRCS)
- $(COMPILETOOL) $(JAVAC) $(JAVACFLAGS) $(addprefix $(SRCDIR),$(JAVASRCS))
+ $(COMPILETOOL) $(JAVAC) $(addprefix $(SRCDIR),$(JAVASRCS))
# -----------------------------------------------------------------
# Run java example
@@ -633,9 +632,6 @@ java_clean:
ROOT_DIR = @ROOT_DIR@
JSINCLUDES = @JSCOREINC@ @JSV8INC@
JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@ @JSV8DYNAMICLINKING@
-JSSO =@JSSO@
-JSLDSHARED = @JSLDSHARED@
-JSCXXSHARED = @JSCXXSHARED@
NODEJS = @NODEJS@
NODEGYP = @NODEGYP@
@@ -731,7 +727,7 @@ javascript_clean:
rm -rf build
rm -f *_wrap* $(RUNME)
rm -f core @EXTRA_CLEAN@
- rm -f *.@OBJEXT@ *@JSSO@ *.$(SO)
+ rm -f *.@OBJEXT@ *@SO@
rm -f binding.gyp example-gypcopy.cxx
cd $(ROOT_DIR)/Tools/javascript && $(MAKE) -s clean
@@ -1096,7 +1092,7 @@ ruby_version:
# -----------------------------------------------------------------
ruby_clean:
- rm -f *_wrap* *~ .~* myruby@EXEEXT@ *.pm
+ rm -f *_wrap* *~ .~* myruby@EXEEXT@
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *$(RUBY_SO)
@@ -1668,7 +1664,6 @@ endif
# ----------------------------------------------------------------
# Build a R dynamically loadable module (C++)
# ----------------------------------------------------------------
-
r_cpp: $(SRCDIR_CXXSRCS)
$(SWIG) -c++ -r $(SWIGOPT) -o $(RCXXSRCS) $(INTERFACEPATH)
ifneq ($(SRCDIR_CXXSRCS),)
@@ -1701,6 +1696,57 @@ r_clean:
rm -f $(RRSRC) $(RUNME).Rout .RData
##################################################################
+##### SCILAB ######
+##################################################################
+
+SCILAB = @SCILAB@
+SCILAB_INC= @SCILABINCLUDE@
+SCILAB_OPT = @SCILABOPT@
+SCILAB_LIBPREFIX = lib
+
+# ----------------------------------------------------------------
+# Build a C dynamically loadable module
+# ----------------------------------------------------------------
+
+scilab:
+ $(SWIG) -scilab $(SWIGOPT) -o $(ISRCS) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CPPFLAGS) $(CFLAGS) $(SCILAB_INC) $(INCLUDES) $(ISRCS) $(SRCDIR_SRCS) $(SRCDIR_CSRCS)
+ $(LDSHARED) $(CFLAGS) $(LDFLAGS) $(IOBJS) $(OBJS) $(LIBS) -o $(SCILAB_LIBPREFIX)$(TARGET)$(SO)
+
+# ----------------------------------------------------------------
+# Build a C++ dynamically loadable module
+# ----------------------------------------------------------------
+
+scilab_cpp:
+ $(SWIG) -c++ -scilab $(SWIGOPT) -o $(ICXXSRCS) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CPPFLAGS) $(CXXFLAGS) $(SCILAB_INC) $(INCLUDES) $(ICXXSRCS) $(SRCDIR_SRCS) $(SRCDIR_CXXSRCS)
+ $(CXXSHARED) $(CXXFLAGS) $(LDFLAGS) $(IOBJS) $(OBJS) $(LIBS) $(CPP_DLLIBS) -o $(SCILAB_LIBPREFIX)$(TARGET)$(SO)
+
+# -----------------------------------------------------------------
+# Running a Scilab example
+# -----------------------------------------------------------------
+
+scilab_run:
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(SCILAB) $(SCILAB_OPT) -f $(SRCDIR)$(RUNME).sci $(RUNPIPE)
+
+# -----------------------------------------------------------------
+# Scilab version
+# -----------------------------------------------------------------
+
+scilab_version:
+ echo `$(SCILAB) -version | head -1`
+
+# -----------------------------------------------------------------
+# Cleaning the scilab examples
+# -----------------------------------------------------------------
+
+scilab_clean:
+ rm -f *_wrap* *~ .~*
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
+ rm -f *.sce
+
+##################################################################
##### Go ######
##################################################################
diff --git a/Examples/d/example.mk.in b/Examples/d/example.mk.in
index 33e1a801e..a1d9a85fc 100644
--- a/Examples/d/example.mk.in
+++ b/Examples/d/example.mk.in
@@ -29,9 +29,15 @@ EXTRA_CXXFLAGS =
EXTRA_LDFLAGS =
TARGET = example_wrap
SWIGOPT = -outcurrentdir
-DSRCS = *.d
DFLAGS = -ofrunme
+ifeq (,$(SRCDIR))
+DSRCS = *.d
+else
+DSRCS = *.d $(addprefix ../$(SRCDIR)$(VERSION_DIR),runme.d)
+endif
+
+
check: build
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_run
@@ -44,7 +50,10 @@ build:
else \
$(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT)' TARGET='$(TARGET)' INTERFACE='example.i' SRCS='' d; \
fi
- $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' DSRCS='../$(SRCDIR)$(VERSION_DIR)runme.d $(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+ $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
clean:
- $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_clean
+ if [ -d $(VERSION_DIR) ]; then \
+ $(MAKE) -C $(VERSION_DIR) -f $(EXAMPLES_TOP)/Makefile SRCDIR='../$(SRCDIR)' d_clean; \
+ fi
+ test -f $(VERSION_DIR)runme.d || rm -rf $(VERSION_DIR) # Only delete dir if out of source
diff --git a/Examples/scilab/check.list b/Examples/scilab/check.list
new file mode 100644
index 000000000..0bcf457c2
--- /dev/null
+++ b/Examples/scilab/check.list
@@ -0,0 +1,16 @@
+# see top-level Makefile.in
+class
+constants
+contract
+enum
+funcptr
+matrix
+matrix2
+pointer
+simple
+std_list
+std_vector
+struct
+template
+variables
+
diff --git a/Examples/scilab/class/Makefile b/Examples/scilab/class/Makefile
new file mode 100644
index 000000000..b0545d804
--- /dev/null
+++ b/Examples/scilab/class/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/class/example.cxx b/Examples/scilab/class/example.cxx
new file mode 100644
index 000000000..046304519
--- /dev/null
+++ b/Examples/scilab/class/example.cxx
@@ -0,0 +1,28 @@
+/* File : example.cxx */
+
+#include "example.h"
+#define M_PI 3.14159265358979323846
+
+/* Move the shape to a new location */
+void Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+int Shape::nshapes = 0;
+
+double Circle::area() {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter() {
+ return 2*M_PI*radius;
+}
+
+double Square::area() {
+ return width*width;
+}
+
+double Square::perimeter() {
+ return 4*width;
+}
diff --git a/Examples/scilab/class/example.h b/Examples/scilab/class/example.h
new file mode 100644
index 000000000..0dff185b2
--- /dev/null
+++ b/Examples/scilab/class/example.h
@@ -0,0 +1,34 @@
+/* File : example.h */
+
+class Shape {
+public:
+ Shape() {
+ nshapes++;
+ }
+ virtual ~Shape() {
+ nshapes--;
+ }
+ double x, y;
+ void move(double dx, double dy);
+ virtual double area() = 0;
+ virtual double perimeter() = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { }
+ virtual double area();
+ virtual double perimeter();
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { }
+ virtual double area();
+ virtual double perimeter();
+};
diff --git a/Examples/scilab/class/example.i b/Examples/scilab/class/example.i
new file mode 100644
index 000000000..fbdf7249f
--- /dev/null
+++ b/Examples/scilab/class/example.i
@@ -0,0 +1,9 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
diff --git a/Examples/scilab/class/runme.sci b/Examples/scilab/class/runme.sci
new file mode 100644
index 000000000..236e54110
--- /dev/null
+++ b/Examples/scilab/class/runme.sci
@@ -0,0 +1,52 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+// ----- Object creation -----
+
+printf("Creating some objects:\n");
+c = new_Circle(10)
+s = new_Square(10)
+
+// ----- Access a static member -----
+
+printf("\nA total of %i shapes were created\n", Shape_nshapes_get());
+
+// ----- Member data access -----
+
+// Set the location of the object
+
+Shape_x_set(c, 20);
+Shape_y_set(c, 30);
+
+Shape_x_set(s, -10);
+Shape_y_set(s, 5);
+
+printf("\nHere is their current position:\n");
+printf(" Circle = (%f, %f)\n", Shape_x_get(c), Shape_y_get(c));
+printf(" Square = (%f, %f)\n", Shape_x_get(s), Shape_y_get(s));
+
+// ----- Call some methods -----
+
+printf("\nHere are some properties of the shapes:\n");
+function print_shape(o)
+ printf(" area = %f\n", Shape_area(o));
+ printf(" perimeter = %f\n", Shape_perimeter(o));
+endfunction
+print_shape(c);
+print_shape(s);
+
+printf("\nGuess I will clean up now\n");
+
+// Note: this invokes the virtual destructor
+delete_Circle(c);
+delete_Square(s);
+
+printf("%i shapes remain\n", Shape_nshapes_get());
+printf("Goodbye\n");
+
+exit
diff --git a/Examples/scilab/constants/Makefile b/Examples/scilab/constants/Makefile
new file mode 100644
index 000000000..56e51e6f5
--- /dev/null
+++ b/Examples/scilab/constants/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/constants/example.i b/Examples/scilab/constants/example.i
new file mode 100644
index 000000000..1172a4edc
--- /dev/null
+++ b/Examples/scilab/constants/example.i
@@ -0,0 +1,30 @@
+/* File : example.i */
+%module example
+
+/* Wraps enums and constants as Scilab variables (instead of functions) */
+%scilabconst(1);
+
+/* A few preprocessor macros */
+
+#define ICONST 42
+#define FCONST 2.1828
+#define CCONST 'x'
+#define CCONST2 '\n'
+#define SCONST "Hello World"
+#define SCONST2 "\"Hello World\""
+
+/* This should work just fine */
+#define EXPR ICONST + 3*(FCONST)
+
+/* This shouldn't do anything */
+#define EXTERN extern
+
+/* Neither should this (BAR isn't defined) */
+#define FOO (ICONST + BAR)
+
+/* The following directives also produce constants */
+
+%constant int iconst = 37;
+%constant double fconst = 3.14;
+
+
diff --git a/Examples/scilab/constants/runme.sci b/Examples/scilab/constants/runme.sci
new file mode 100644
index 000000000..cfb28b6b4
--- /dev/null
+++ b/Examples/scilab/constants/runme.sci
@@ -0,0 +1,18 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+example_Init();
+
+printf("\nTest constants\n");
+printf("ICONST = %i (should be 42)\n", ICONST);
+printf("FCONST = %5.4f (should be 2.1828)\n", FCONST);
+printf("SCONST = ''%s'' (should be ''Hello World'')\n", SCONST);
+printf("EXPR = %5.4f (should be 48.5484)\n", EXPR);
+printf("iconst = %i (should be 37)\n", iconst);
+printf("fconst = %3.2f (should be 3.14)\n", fconst);
+
+exit
diff --git a/Examples/scilab/contract/Makefile b/Examples/scilab/contract/Makefile
new file mode 100644
index 000000000..208a88bfe
--- /dev/null
+++ b/Examples/scilab/contract/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/contract/example.c b/Examples/scilab/contract/example.c
new file mode 100644
index 000000000..1a644543f
--- /dev/null
+++ b/Examples/scilab/contract/example.c
@@ -0,0 +1,23 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+int fact(int n) {
+ if (n <= 0) return 1;
+ return n*fact(n-1);
+}
+
+
diff --git a/Examples/scilab/contract/example.i b/Examples/scilab/contract/example.i
new file mode 100644
index 000000000..8fd1a80af
--- /dev/null
+++ b/Examples/scilab/contract/example.i
@@ -0,0 +1,21 @@
+/* File : example.i */
+%module example
+
+%contract gcd(int x, int y) {
+require:
+ x >= 0;
+ y >= 0;
+}
+
+%contract fact(int n) {
+require:
+ n >= 0;
+ensure:
+ fact >= 1;
+}
+
+%inline %{
+extern int gcd(int x, int y);
+extern int fact(int n);
+extern double Foo;
+%}
diff --git a/Examples/scilab/contract/runme.sci b/Examples/scilab/contract/runme.sci
new file mode 100644
index 000000000..718424b29
--- /dev/null
+++ b/Examples/scilab/contract/runme.sci
@@ -0,0 +1,46 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+
+// Call our gcd() function
+x = 42;
+y = 105;
+g = gcd(x, y);
+printf("The gcd of %d and %d is %d\n", x, y, g);
+
+// Call our fact() function
+x = 5;
+g = fact(x);
+printf("The fact of %d is %d\n", x, g);
+
+// Manipulate the Foo global variable
+
+// Output its current value
+printf("Foo = %f\n", Foo_get());
+
+// Change its value
+Foo_set(3.1415926);
+
+// See if the change took effect
+printf("Foo = %f\n", Foo_get());
+
+// Check error messages when violating contract
+ierr = execstr('gcd(-42, 105)', 'errcatch');
+if ierr <> 20003 then
+ error("gcd(-42, 105) must provoke a RunTimeError")
+end
+
+ierr = execstr('fact(-4)', 'errcatch');
+if ierr <> 20003 then
+ error("fact(-4) must provoke a RunTimeError")
+end
+
+exit
+
+
+
diff --git a/Examples/scilab/enum/Makefile b/Examples/scilab/enum/Makefile
new file mode 100644
index 000000000..b0545d804
--- /dev/null
+++ b/Examples/scilab/enum/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/enum/example.cxx b/Examples/scilab/enum/example.cxx
new file mode 100644
index 000000000..6785e57ac
--- /dev/null
+++ b/Examples/scilab/enum/example.cxx
@@ -0,0 +1,37 @@
+/* File : example.c */
+
+#include "example.h"
+#include <stdio.h>
+
+void Foo::enum_test(speed s) {
+ if (s == IMPULSE) {
+ printf("IMPULSE speed\n");
+ } else if (s == WARP) {
+ printf("WARP speed\n");
+ } else if (s == LUDICROUS) {
+ printf("LUDICROUS speed\n");
+ } else {
+ printf("Unknown speed\n");
+ }
+}
+
+void enum_test(color c, Foo::speed s) {
+ if (c == RED) {
+ printf("color = RED, ");
+ } else if (c == BLUE) {
+ printf("color = BLUE, ");
+ } else if (c == GREEN) {
+ printf("color = GREEN, ");
+ } else {
+ printf("color = Unknown color!, ");
+ }
+ if (s == Foo::IMPULSE) {
+ printf("speed = IMPULSE speed\n");
+ } else if (s == Foo::WARP) {
+ printf("speed = WARP speed\n");
+ } else if (s == Foo::LUDICROUS) {
+ printf("speed = LUDICROUS speed\n");
+ } else {
+ printf("speed = Unknown speed!\n");
+ }
+}
diff --git a/Examples/scilab/enum/example.h b/Examples/scilab/enum/example.h
new file mode 100644
index 000000000..525d62afc
--- /dev/null
+++ b/Examples/scilab/enum/example.h
@@ -0,0 +1,13 @@
+/* File : example.h */
+
+enum color { RED, BLUE, GREEN };
+
+class Foo {
+ public:
+ Foo() { }
+ enum speed { IMPULSE, WARP, LUDICROUS };
+ void enum_test(speed s);
+};
+
+void enum_test(color c, Foo::speed s);
+
diff --git a/Examples/scilab/enum/example.i b/Examples/scilab/enum/example.i
new file mode 100644
index 000000000..a9c71c5ab
--- /dev/null
+++ b/Examples/scilab/enum/example.i
@@ -0,0 +1,10 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include "example.h"
+
+
diff --git a/Examples/scilab/enum/runme.sci b/Examples/scilab/enum/runme.sci
new file mode 100644
index 000000000..0895fc340
--- /dev/null
+++ b/Examples/scilab/enum/runme.sci
@@ -0,0 +1,36 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+example_Init();
+
+printf("\nTest enums\n");
+printf("*** color ***\n");
+printf(" RED_get() = %i\n", RED_get());
+printf(" BLUE_get() = %i\n", BLUE_get());
+printf(" GREEN_get() = %i\n", GREEN_get());
+
+printf("\n*** Foo::speed ***\n")
+printf(" Foo_IMPULSE = %i\n", Foo_IMPULSE_get());
+printf(" Foo_WARP = %i\n", Foo_WARP_get());
+printf(" Foo_LUDICROUS = %i\n", Foo_LUDICROUS_get());
+
+printf("\nTest enums as argument of functions\n");
+
+enum_test(RED_get(), Foo_IMPULSE_get());
+enum_test(BLUE_get(), Foo_WARP_get());
+enum_test(GREEN_get(), Foo_LUDICROUS_get());
+enum_test(1234, 5678);
+
+printf("\nTest enums as argument of class methods\n");
+
+f = new_Foo();
+Foo_enum_test(f, Foo_IMPULSE_get());
+Foo_enum_test(f, Foo_WARP_get());
+Foo_enum_test(f, Foo_LUDICROUS_get());
+delete_Foo(f);
+
+exit
diff --git a/Examples/scilab/funcptr/Makefile b/Examples/scilab/funcptr/Makefile
new file mode 100644
index 000000000..208a88bfe
--- /dev/null
+++ b/Examples/scilab/funcptr/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/funcptr/example.c b/Examples/scilab/funcptr/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/Examples/scilab/funcptr/example.c
@@ -0,0 +1,19 @@
+/* File : example.c */
+
+int do_op(int a, int b, int (*op)(int,int)) {
+ return (*op)(a,b);
+}
+
+int add(int a, int b) {
+ return a+b;
+}
+
+int sub(int a, int b) {
+ return a-b;
+}
+
+int mul(int a, int b) {
+ return a*b;
+}
+
+int (*funcvar)(int,int) = add;
diff --git a/Examples/scilab/funcptr/example.h b/Examples/scilab/funcptr/example.h
new file mode 100644
index 000000000..9936e24fc
--- /dev/null
+++ b/Examples/scilab/funcptr/example.h
@@ -0,0 +1,9 @@
+/* file: example.h */
+
+extern int do_op(int,int, int (*op)(int,int));
+extern int add(int,int);
+extern int sub(int,int);
+extern int mul(int,int);
+
+extern int (*funcvar)(int,int);
+
diff --git a/Examples/scilab/funcptr/example.i b/Examples/scilab/funcptr/example.i
new file mode 100644
index 000000000..e8af50e6f
--- /dev/null
+++ b/Examples/scilab/funcptr/example.i
@@ -0,0 +1,11 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+/* Wrap a function taking a pointer to a function */
+extern int do_op(int a, int b, int (*op)(int, int));
+
+extern int (*funcvar)(int,int);
+
diff --git a/Examples/scilab/funcptr/runme.sci b/Examples/scilab/funcptr/runme.sci
new file mode 100644
index 000000000..d3cbed394
--- /dev/null
+++ b/Examples/scilab/funcptr/runme.sci
@@ -0,0 +1,22 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+a = 37
+b = 42
+
+// Now call our C function with a bunch of callbacks
+
+printf("Trying some C callback functions\n");
+printf(" a = %i\n", a);
+printf(" b = %i\n", b);
+printf(" ADD(a,b) = %i\n", do_op(a,b,funcvar_get()));
+
+exit
+
+
+
diff --git a/Examples/scilab/matrix/Makefile b/Examples/scilab/matrix/Makefile
new file mode 100644
index 000000000..208a88bfe
--- /dev/null
+++ b/Examples/scilab/matrix/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/matrix/example.c b/Examples/scilab/matrix/example.c
new file mode 100644
index 000000000..6ce10098b
--- /dev/null
+++ b/Examples/scilab/matrix/example.c
@@ -0,0 +1,61 @@
+/* FILE : matrix.c : some simple 4x4 matrix operations */
+#include <stdlib.h>
+#include <stdio.h>
+
+double **new_matrix() {
+
+ int i;
+ double **M;
+
+ M = (double **) malloc(4*sizeof(double *));
+ M[0] = (double *) malloc(16*sizeof(double));
+
+ for (i = 0; i < 4; i++) {
+ M[i] = M[0] + 4*i;
+ }
+ return M;
+}
+
+void destroy_matrix(double **M) {
+
+ free(M[0]);
+ free(M);
+
+}
+
+void print_matrix(double **M) {
+
+ int i,j;
+
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ printf("%10g ", M[i][j]);
+ }
+ printf("\n");
+ }
+
+}
+
+void mat_mult(double **m1, double **m2, double **m3) {
+
+ int i,j,k;
+ double temp[4][4];
+
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < 4; j++) {
+ temp[i][j] = 0;
+ for (k = 0; k < 4; k++)
+ temp[i][j] += m1[i][k]*m2[k][j];
+ }
+
+ for (i = 0; i < 4; i++)
+ for (j = 0; j < 4; j++)
+ m3[i][j] = temp[i][j];
+}
+
+
+
+
+
+
+
diff --git a/Examples/scilab/matrix/example.i b/Examples/scilab/matrix/example.i
new file mode 100644
index 000000000..c930e92f5
--- /dev/null
+++ b/Examples/scilab/matrix/example.i
@@ -0,0 +1,36 @@
+%module example
+// FILE : matrix.i
+
+%{
+
+void set_m(double **M, int i, int j, double val) {
+ M[i][j] = val;
+}
+
+double get_m(double **M, int i, int j) {
+ return M[i][j];
+}
+%}
+
+%inline {
+/*** Matrix Operations ***/
+
+extern double **new_matrix();
+/* Creates a new matrix and returns a pointer to it */
+
+extern void destroy_matrix(double **M);
+/* Destroys the matrix M */
+
+extern void print_matrix(double **M);
+/* Prints out the matrix M */
+
+extern void set_m(double **M, int i, int j, double val);
+/* Sets M[i][j] = val*/
+
+extern double get_m(double **M, int i, int j);
+/* Returns M[i][j] */
+
+extern void mat_mult(double **a, double **b, double **c);
+/* Multiplies matrix a by b and places the result in c*/
+
+}
diff --git a/Examples/scilab/matrix/runme.sci b/Examples/scilab/matrix/runme.sci
new file mode 100644
index 000000000..26943b184
--- /dev/null
+++ b/Examples/scilab/matrix/runme.sci
@@ -0,0 +1,43 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+// create a new matrix
+x = new_matrix();
+for i = 0 : 3;
+ for j = 0 : 3;
+ set_m(x, i, j, i+j);
+ end;
+end;
+
+// print the matrix
+print_matrix(x);
+
+// another matrix
+y = new_matrix();
+ for i = 0 : 3;
+ for j = 0 : 3;
+ set_m(y, i, j, i-j);
+ end;
+ end;
+
+// print the matrix
+print_matrix(y);
+
+// mat_mult the two matrix, and the result is stored in a new matrix
+z = new_matrix();
+
+mat_mult(x, y, z);
+
+print_matrix(z);
+
+//destroy the matrix
+destroy_matrix(x);
+destroy_matrix(y);
+destroy_matrix(z);
+
+exit
diff --git a/Examples/scilab/matrix2/Makefile b/Examples/scilab/matrix2/Makefile
new file mode 100644
index 000000000..208a88bfe
--- /dev/null
+++ b/Examples/scilab/matrix2/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/matrix2/example.c b/Examples/scilab/matrix2/example.c
new file mode 100644
index 000000000..476067df9
--- /dev/null
+++ b/Examples/scilab/matrix2/example.c
@@ -0,0 +1,118 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+
+// Double matrix functions
+
+double sumDoubleMatrix(double *inputMatrix, int nbRow, int nbCol)
+{
+ int i;
+ double total = 0.0;
+ for (i=0; i<nbRow*nbCol; i++)
+ {
+ total += inputMatrix[i];
+ }
+ return total;
+}
+
+void squareDoubleMatrix(double *inputMatrix, int nbRow, int nbCol, double** resultMatrix, int* nbRowRes, int* nbColRes)
+{
+ int i;
+ int size = nbRow * nbCol;
+ *nbRowRes = nbRow;
+ *nbColRes = nbCol;
+ *resultMatrix = (double*) malloc(size * sizeof(double));
+ for (i=0; i<size; i++)
+ {
+ (*resultMatrix)[i] = inputMatrix[i] * inputMatrix[i];
+ }
+}
+
+void getDoubleMatrix(double **resultMatrix, int *nbRowRes, int *nbColRes)
+{
+ int i;
+ int size;
+ *nbRowRes = 5;
+ *nbColRes = 3;
+ size = (*nbRowRes) * (*nbColRes);
+ *resultMatrix = (double*) malloc(size * sizeof(double));
+ for (i=0; i<size; i++)
+ {
+ (*resultMatrix)[i] = i*2;
+ }
+}
+
+// Integer matrix functions
+
+int sumIntegerMatrix(int *inputMatrix, int nbRow, int nbCol)
+{
+ int i;
+ int total = 0;
+ for (i=0; i<nbRow*nbCol; i++)
+ {
+ total += inputMatrix[i];
+ }
+ return total;
+}
+
+void squareIntegerMatrix(int *inputMatrix, int nbRow, int nbCol, int** resultMatrix, int* nbRowRes, int* nbColRes)
+{
+ int i;
+ int size = nbRow * nbCol;
+ *nbRowRes = nbRow;
+ *nbColRes = nbCol;
+ *resultMatrix = (int*) malloc(size * sizeof(int));
+ for (i=0; i<size; i++)
+ {
+ (*resultMatrix)[i] = inputMatrix[i] * inputMatrix[i];
+ }
+}
+
+void getIntegerMatrix(int **resultMatrix, int *nbRowRes, int *nbColRes)
+{
+ int i;
+ int size;
+ *nbRowRes = 5;
+ *nbColRes = 3;
+ size = (*nbRowRes) * (*nbColRes);
+ *resultMatrix = (int*) malloc(size * sizeof(int));
+ for (i=0; i<size; i++)
+ {
+ (*resultMatrix)[i] = i*2;
+ }
+}
+
+// String matrix functions
+
+char* concatStringVector(char **inputVector, int size)
+{
+ int i;
+ int resultSize;
+ char *result;
+ resultSize = 3 * size + 1;
+ result = calloc(resultSize, sizeof(char));
+ strcpy(result, inputVector[0]);
+ for (i=1; i<size; i++)
+ {
+ strcat(result, " ");
+ strcat(result, (const char*) inputVector[i]);
+ }
+ return result;
+}
+
+void getStringVector(char ***resultVector, int *sizeRes)
+{
+ int i;
+ *sizeRes = 12;
+ *resultVector = (char**) malloc((*sizeRes) * sizeof(char*));
+ for (i=0; i<*sizeRes; i++)
+ {
+ char* pc = (char*) calloc(3, sizeof(char));
+ sprintf(pc, "%d", i);
+ (*resultVector)[i] = pc;
+ }
+}
+
+
+
diff --git a/Examples/scilab/matrix2/example.i b/Examples/scilab/matrix2/example.i
new file mode 100755
index 000000000..e37cd116c
--- /dev/null
+++ b/Examples/scilab/matrix2/example.i
@@ -0,0 +1,26 @@
+%module example
+
+%include matrix.i
+
+%apply (double *IN, int IN_ROWCOUNT, int IN_COLCOUNT) { (double *inputMatrix, int nbRow, int nbCol) }
+%apply (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { (double **resultMatrix, int *nbRowRes, int *nbColRes) }
+
+%apply (int *IN, int IN_ROWCOUNT, int IN_COLCOUNT) { (int *inputMatrix, int nbRow, int nbCol) }
+%apply (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { (int **resultMatrix, int *nbRowRes, int *nbColRes) }
+
+%apply (char **IN, int IN_SIZE) { (char **inputVector, int size) }
+%apply (char ***OUT, int *OUT_SIZE) { (char ***resultVector, int *sizeRes) }
+
+%inline %{
+ extern double sumDoubleMatrix(double *inputMatrix, int nbRow, int nbCol);
+ extern void squareDoubleMatrix(double *inputMatrix, int nbRow, int nbCol, double **resultMatrix, int *nbRowRes, int *nbColRes);
+ extern void getDoubleMatrix(double **resultMatrix, int *nbRowRes, int *nbColRes);
+
+ extern int sumIntegerMatrix(int *inputMatrix, int nbRow, int nbCol);
+ extern void squareIntegerMatrix(int *inputMatrix, int nbRow, int nbCol, int **resultMatrix, int *nbRowRes, int *nbColRes);
+ extern void getIntegerMatrix(int **resultMatrix, int *nbRowRes, int *nbColRes);
+
+ extern char* concatStringVector(char **inputVector, int size);
+ extern void getStringVector(char ***resultVector, int *sizeRes);
+%}
+
diff --git a/Examples/scilab/matrix2/main.c b/Examples/scilab/matrix2/main.c
new file mode 100644
index 000000000..49c7d46a4
--- /dev/null
+++ b/Examples/scilab/matrix2/main.c
@@ -0,0 +1,24 @@
+double sumitems(double *first, int nbRow, int nbCol);
+void main(){
+/**
+ * --> myMatrix=[ 103 3 1 12;0 0 2043 1];
+ * --> sumitems(myMatrix);
+ * 32
+ */
+ double B[] = {1,3,4,9,2,8,3,2}; /* Declare the matrix */
+ int rowB = 2, colB = 4;
+ printf("sumitems: %6.2f\n",sumitems(B, rowB, colB));
+
+
+/**
+ * --> myOtherMatrix=generateValues();
+ * --> size(myOtherMatrix);
+ */
+ int numberRow, numberCol, i;
+ double * matrix=getValues(&numberRow, &numberCol);
+ printf("Matrix of size [%d,%d]",numberRow, numberCol);
+ for(i=0; i < numberRow*numberCol; i++)
+ {
+ printf("A[%d] = %5.2f\n",i,matrix[i]);
+ }
+}
diff --git a/Examples/scilab/matrix2/runme.sci b/Examples/scilab/matrix2/runme.sci
new file mode 100644
index 000000000..0af7df4e7
--- /dev/null
+++ b/Examples/scilab/matrix2/runme.sci
@@ -0,0 +1,51 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+// Test lib double matrix functions
+disp("Call lib function getDoubleMatrix()");
+doubleMatrix = getDoubleMatrix();
+disp(doubleMatrix);
+
+disp("Call lib function sumDoubleMatrix()");
+s = sumDoubleMatrix(doubleMatrix);
+disp(s);
+
+disp("Call lib function squareDoubleMatrix()");
+sqrd = squareDoubleMatrix(doubleMatrix);
+disp(sqrd);
+
+
+// Test lib integer matrix functions
+
+disp("Call lib function getIntegerMatrix()");
+integerMatrix = getIntegerMatrix();
+disp(integerMatrix);
+
+disp("Call lib function sumIntegerMatrix()");
+s = sumIntegerMatrix(integerMatrix);
+disp(s);
+
+disp("Call lib function squareIntegerMatrix()");
+sqri = squareIntegerMatrix(integerMatrix);
+disp(sqri);
+
+
+// Test lib string matrix functions
+
+disp("Call lib function getStringVector()");
+stringVector = getStringVector();
+disp(stringVector);
+
+disp("Call lib function concatStringVector()");
+stringVector2 = concatStringVector(stringVector);
+disp(stringVector2);
+
+exit
+
+
+
diff --git a/Examples/scilab/pointer/Makefile b/Examples/scilab/pointer/Makefile
new file mode 100644
index 000000000..92308c312
--- /dev/null
+++ b/Examples/scilab/pointer/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/pointer/example.c b/Examples/scilab/pointer/example.c
new file mode 100644
index 000000000..b877d9a5b
--- /dev/null
+++ b/Examples/scilab/pointer/example.c
@@ -0,0 +1,16 @@
+/* File : example.c */
+
+void add(int *x, int *y, int *result) {
+ *result = *x + *y;
+}
+
+void sub(int *x, int *y, int *result) {
+ *result = *x - *y;
+}
+
+int divide(int n, int d, int *r) {
+ int q;
+ q = n/d;
+ *r = n - q*d;
+ return q;
+}
diff --git a/Examples/scilab/pointer/example.i b/Examples/scilab/pointer/example.i
new file mode 100644
index 000000000..a8ac79499
--- /dev/null
+++ b/Examples/scilab/pointer/example.i
@@ -0,0 +1,30 @@
+/* File : example.i */
+%module example
+
+%{
+extern void add(int *, int *, int *);
+extern void sub(int *, int *, int *);
+extern int divide(int, int, int *);
+%}
+
+/* This example illustrates a couple of different techniques
+ for manipulating C pointers */
+
+/* First we'll use the pointer library */
+extern void add(int *x, int *y, int *result);
+%include cpointer.i
+%pointer_functions(int, intp);
+
+/* Next we'll use some typemaps */
+
+%include typemaps.i
+extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
+
+/* Next we'll use typemaps and the %apply directive */
+
+%apply int *OUTPUT { int *r };
+extern int divide(int n, int d, int *r);
+
+
+
+
diff --git a/Examples/scilab/pointer/runme.sci b/Examples/scilab/pointer/runme.sci
new file mode 100644
index 000000000..3400ab3e5
--- /dev/null
+++ b/Examples/scilab/pointer/runme.sci
@@ -0,0 +1,47 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+// First create some objects using the pointer library.
+printf("Testing the pointer library\n")
+a = new_intp();
+b = new_intp();
+c = new_intp(); // Memory for result
+
+intp_assign(a, 37);
+intp_assign(b, 42);
+
+printf(" a = %d\n", intp_value(a));
+printf(" b = %d\n", intp_value(b));
+printf(" c = %d\n", intp_value(c));
+
+// Call the add() function with some pointers
+add(a, b, c);
+
+// Now get the result
+r = intp_value(c);
+printf(" 37 + 42 = %d\n", r);
+
+// Clean up the pointers
+delete_intp(a);
+delete_intp(b);
+delete_intp(c);
+
+// Now try the typemap library
+// This should be much easier. Now how it is no longer
+// necessary to manufacture pointers.
+printf("Trying the typemap library\n");
+r = sub(37, 42);
+printf(" 37 - 42 = %d\n", r);
+
+// Now try the version with multiple return values
+printf("Testing multiple return values\n");
+[q, r] = divide(42, 37);
+printf(" 42/37 = %d remainder %d\n", q, r);
+
+exit
+
diff --git a/Examples/scilab/simple/Makefile b/Examples/scilab/simple/Makefile
new file mode 100644
index 000000000..208a88bfe
--- /dev/null
+++ b/Examples/scilab/simple/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/simple/example.c b/Examples/scilab/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/Examples/scilab/simple/example.c
@@ -0,0 +1,18 @@
+/* File : example.c */
+
+/* A global variable */
+double Foo = 3.0;
+
+/* Compute the greatest common divisor of positive integers */
+int gcd(int x, int y) {
+ int g;
+ g = y;
+ while (x > 0) {
+ g = x;
+ x = y % x;
+ y = g;
+ }
+ return g;
+}
+
+
diff --git a/Examples/scilab/simple/example.i b/Examples/scilab/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/Examples/scilab/simple/example.i
@@ -0,0 +1,7 @@
+/* File : example.i */
+%module example
+
+%inline %{
+extern int gcd(int x, int y);
+extern double Foo;
+%}
diff --git a/Examples/scilab/simple/runme.sci b/Examples/scilab/simple/runme.sci
new file mode 100644
index 000000000..ed8b0f6c3
--- /dev/null
+++ b/Examples/scilab/simple/runme.sci
@@ -0,0 +1,29 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+// Call our gcd() function
+
+x = 42;
+y = 105;
+g = gcd(x,y);
+printf("The gcd of %d and %d is %d\n",x,y,g);
+
+// Manipulate the Foo global variable
+
+// Get its default value (see in example.c)
+defaultValue = Foo_get()
+if defaultValue <> 3 then pause; end
+
+// Change its value
+Foo_set(3.1415926)
+
+// See if the change took effect
+if Foo_get() <> 3.1415926 then pause,end
+
+exit
+
diff --git a/Examples/scilab/std_list/Makefile b/Examples/scilab/std_list/Makefile
new file mode 100644
index 000000000..b0545d804
--- /dev/null
+++ b/Examples/scilab/std_list/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS = example.cxx
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/std_list/example.cxx b/Examples/scilab/std_list/example.cxx
new file mode 100644
index 000000000..e58d6a38b
--- /dev/null
+++ b/Examples/scilab/std_list/example.cxx
@@ -0,0 +1,61 @@
+/* File : example.cpp */
+
+#include "example.h"
+
+#include <iostream>
+#include <iterator>
+#include <algorithm>
+#include <numeric>
+#include <sstream>
+
+
+template <typename T>
+std::list<T> concat_list(const std::list<T> list, const std::list<T> other_list)
+{
+ std::list<T> out_list(list);
+ out_list.insert(out_list.end(), other_list.begin(), other_list.end());
+ return out_list;
+}
+
+// int lists
+
+std::list<int> create_integer_list(const int rangemin, const int rangemax)
+{
+ std::list<int> out_list;
+ for (int i = rangemin; i <= rangemax; i++)
+ {
+ out_list.push_back(i);
+ }
+ return out_list;
+}
+
+int sum_integer_list(const std::list<int>& list)
+{
+ return std::accumulate(list.begin(), list.end(), 0);
+}
+
+std::list<int> concat_integer_list(const std::list<int> list, const std::list<int> other_list)
+{
+ return concat_list<int>(list, other_list);
+}
+
+// string lists
+
+std::list<std::string> create_string_list(const char* svalue)
+{
+ std::list<std::string> out_list;
+ std::string str(svalue);
+
+ std::istringstream iss(str);
+ std::copy(std::istream_iterator<std::string>(iss),
+ std::istream_iterator<std::string>(),
+ std::inserter<std::list<std::string> >(out_list, out_list.begin()));
+
+ return out_list;
+}
+
+std::list<std::string> concat_string_list(const std::list<std::string> list, const std::list<std::string> other_list)
+{
+ return concat_list<std::string>(list, other_list);
+}
+
diff --git a/Examples/scilab/std_list/example.h b/Examples/scilab/std_list/example.h
new file mode 100644
index 000000000..769627e08
--- /dev/null
+++ b/Examples/scilab/std_list/example.h
@@ -0,0 +1,14 @@
+/* File : example.h */
+
+#include <list>
+#include <string>
+
+
+// integer lists
+std::list<int> create_integer_list(const int size, const int value);
+int sum_integer_list(const std::list<int>& list);
+std::list<int> concat_integer_list(const std::list<int> list, const std::list<int> other_list);
+
+// string lists
+std::list<std::string> create_string_list(const char* value);
+std::list<std::string> concat_string_list(const std::list<std::string> list, const std::list<std::string> other_list);
diff --git a/Examples/scilab/std_list/example.i b/Examples/scilab/std_list/example.i
new file mode 100644
index 000000000..dbe2a73e4
--- /dev/null
+++ b/Examples/scilab/std_list/example.i
@@ -0,0 +1,19 @@
+/* File : example.i */
+
+%module example
+
+%{
+#include "example.h"
+%}
+
+%include stl.i
+%include std_list.i
+
+/* instantiate the required template specializations */
+namespace std
+{
+ %template(IntList) list<int>;
+ %template(StringList) list<std::string>;
+}
+
+%include "example.h"
diff --git a/Examples/scilab/std_list/runme.sci b/Examples/scilab/std_list/runme.sci
new file mode 100644
index 000000000..e4c04b029
--- /dev/null
+++ b/Examples/scilab/std_list/runme.sci
@@ -0,0 +1,39 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+example_Init();
+
+// This example shows how to use C++ fonctions with STL lists arguments
+// Here, STL lists are converted from/to Scilab matrices (SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS is not defined)
+
+// integer lists
+
+disp("Example of passing matrices of int as list arguments of C++ functions.");
+disp("get a list of int {1...4} from create_integer_list():");
+is = create_integer_list(1, 4);
+disp(is);
+disp("get the sum of this list elements with sum_integer_list():")
+sum = sum_integer_list(is);
+disp(is);
+is2 = create_integer_list(3, 6);
+disp("concat this list with the list of int {3...6} with concat_integer_list():");
+is3 = concat_integer_list(is, is2);
+disp(is3);
+
+// string lists
+
+disp("Example of passing matrices of string as list arguments of C++ functions.");
+disp("get a list of string {''aa'', ''bb'', ''cc'', ''dd''} with create_string_list():");
+ss = create_string_list("aa bb cc dd");
+disp(ss);
+ss2 = create_string_list("cc dd ee ff");
+disp("concat this list with the list of string {''cc'', ''dd'', ''ee'', ''ff''} with concat_string_list():");
+ss3 = concat_string_list(ss, ss2);
+disp(ss3);
+
+exit
+
diff --git a/Examples/scilab/std_vector/Makefile b/Examples/scilab/std_vector/Makefile
new file mode 100644
index 000000000..f73144d78
--- /dev/null
+++ b/Examples/scilab/std_vector/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/std_vector/example.h b/Examples/scilab/std_vector/example.h
new file mode 100644
index 000000000..4f0dac70d
--- /dev/null
+++ b/Examples/scilab/std_vector/example.h
@@ -0,0 +1,25 @@
+/* File : example.h */
+
+#include <vector>
+#include <algorithm>
+#include <functional>
+#include <numeric>
+
+double average(std::vector<int> v) {
+ return std::accumulate(v.begin(),v.end(),0.0)/v.size();
+}
+
+std::vector<double> half(const std::vector<double>& v) {
+ std::vector<double> w(v);
+ for (unsigned int i=0; i<w.size(); i++)
+ w[i] /= 2.0;
+ return w;
+}
+
+void halve_in_place(std::vector<double>& v) {
+ // would you believe this is the same as the above?
+ std::transform(v.begin(),v.end(),v.begin(),
+ std::bind2nd(std::divides<double>(),2.0));
+}
+
+
diff --git a/Examples/scilab/std_vector/example.i b/Examples/scilab/std_vector/example.i
new file mode 100644
index 000000000..1ba9e927e
--- /dev/null
+++ b/Examples/scilab/std_vector/example.i
@@ -0,0 +1,19 @@
+/* File : example.i */
+%module example
+
+%warnfilter(SWIGWARN_SCILAB_TRUNCATED_NAME) std::vector::get_allocator;
+
+%{
+#include "example.h"
+%}
+
+%include stl.i
+/* instantiate the required template specializations */
+namespace std {
+ %template(IntVector) vector<int>;
+ %template(DoubleVector) vector<double>;
+}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/Examples/scilab/std_vector/runme.sci b/Examples/scilab/std_vector/runme.sci
new file mode 100644
index 000000000..3e569454c
--- /dev/null
+++ b/Examples/scilab/std_vector/runme.sci
@@ -0,0 +1,37 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+example_Init();
+
+
+disp(mean([1,2,3,4]));
+
+// ... or a wrapped std::vector<int>
+
+v = new_IntVector();
+for i = 1:4
+ IntVector_push_back(v, i);
+end;
+disp(average(v));
+
+
+// half will return a Scilab matrix.
+// Call it with a Scilab matrix...
+
+disp(half([1.0, 1.5, 2.0, 2.5, 3.0]));
+
+
+// ... or a wrapped std::vector<double>
+
+v = new_DoubleVector();
+for i = 1:4
+ DoubleVector_push_back(v, i);
+end;
+disp(half(v));
+
+exit
+
diff --git a/Examples/scilab/struct/Makefile b/Examples/scilab/struct/Makefile
new file mode 100644
index 000000000..7a030a33c
--- /dev/null
+++ b/Examples/scilab/struct/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS =
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SRCDIR='$(SRCDIR)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/struct/example.i b/Examples/scilab/struct/example.i
new file mode 100644
index 000000000..af2cd3f4a
--- /dev/null
+++ b/Examples/scilab/struct/example.i
@@ -0,0 +1,11 @@
+%module example
+
+%rename(Bar) Foo;
+
+%inline %{
+typedef struct {
+ int x;
+} Foo;
+
+%}
+
diff --git a/Examples/scilab/struct/runme.sci b/Examples/scilab/struct/runme.sci
new file mode 100644
index 000000000..4d47ef0dc
--- /dev/null
+++ b/Examples/scilab/struct/runme.sci
@@ -0,0 +1,18 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+// Test use of a struct (Bar)
+
+a = new_Bar();
+
+Bar_x_set(a, 100);
+printf("a.x = %d (Should be 100)\n", Bar_x_get(a));
+
+delete_Bar(a);
+
+exit
diff --git a/Examples/scilab/template/Makefile b/Examples/scilab/template/Makefile
new file mode 100644
index 000000000..f73144d78
--- /dev/null
+++ b/Examples/scilab/template/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+CXXSRCS =
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' CXXSRCS='$(CXXSRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab_cpp
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/template/example.h b/Examples/scilab/template/example.h
new file mode 100644
index 000000000..7401df650
--- /dev/null
+++ b/Examples/scilab/template/example.h
@@ -0,0 +1,32 @@
+/* File : example.h */
+
+// Some template definitions
+
+template<class T> T max(T a, T b) { return a>b ? a : b; }
+
+template<class T> class vector {
+ T *v;
+ int sz;
+ public:
+ vector(int _sz) {
+ v = new T[_sz];
+ sz = _sz;
+ }
+ T &get(int index) {
+ return v[index];
+ }
+ void set(int index, T &val) {
+ v[index] = val;
+ }
+#ifdef SWIG
+ %extend {
+ T getitem(int index) {
+ return $self->get(index);
+ }
+ void setitem(int index, T val) {
+ $self->set(index,val);
+ }
+ }
+#endif
+};
+
diff --git a/Examples/scilab/template/example.i b/Examples/scilab/template/example.i
new file mode 100644
index 000000000..8f94c4da1
--- /dev/null
+++ b/Examples/scilab/template/example.i
@@ -0,0 +1,17 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
+/* Now instantiate some specific template declarations */
+
+%template(maxint) max<int>;
+%template(maxdouble) max<double>;
+%template(vecint) vector<int>;
+%template(vecdouble) vector<double>;
+
diff --git a/Examples/scilab/template/runme.sci b/Examples/scilab/template/runme.sci
new file mode 100644
index 000000000..35ca9d1c2
--- /dev/null
+++ b/Examples/scilab/template/runme.sci
@@ -0,0 +1,45 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+example_Init();
+
+// Call some templated functions
+printf("maxint(3, 7) = %i\n", maxint(3, 7));
+printf("maxdouble(3.14, 2.18) = %3.2f\n", maxdouble(3.14, 2.18));
+
+// Create some class
+
+iv = new_vecint(100);
+dv = new_vecdouble(1000);
+
+for i = 0:100
+ vecint_setitem(iv, i, 2*i);
+end
+
+for i = 0:100
+ vecdouble_setitem(dv, i, 1.0/(i+1));
+end
+
+isum = 0
+for i = 0:100
+ isum = isum + vecint_getitem(iv, i);
+end
+
+printf("isum = %i\n", isum);
+
+dsum = 0
+for i = 0:100
+ dsum = dsum + vecdouble_getitem(dv, i);
+end
+
+printf("dsum = %3.2f\n", dsum);
+
+delete_vecint(iv);
+delete_vecdouble(dv);
+
+exit
+
diff --git a/Examples/scilab/variables/Makefile b/Examples/scilab/variables/Makefile
new file mode 100644
index 000000000..208a88bfe
--- /dev/null
+++ b/Examples/scilab/variables/Makefile
@@ -0,0 +1,15 @@
+TOP = ../..
+SWIG = $(TOP)/../preinst-swig
+SRCS = example.c
+TARGET = example
+INTERFACE = example.i
+
+check: build
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_run
+
+build:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' SWIG='$(SWIG)' \
+ TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' scilab
+
+clean:
+ $(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' scilab_clean
diff --git a/Examples/scilab/variables/example.c b/Examples/scilab/variables/example.c
new file mode 100644
index 000000000..9f88d90a4
--- /dev/null
+++ b/Examples/scilab/variables/example.c
@@ -0,0 +1,95 @@
+/* File : example.c */
+
+/* I'm a file containing some C global variables */
+
+/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER)
+# define _CRT_SECURE_NO_DEPRECATE
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "example.h"
+
+int ivar = 0;
+short svar = 0;
+long lvar = 0;
+unsigned int uivar = 0;
+unsigned short usvar = 0;
+unsigned long ulvar = 0;
+signed char scvar = 0;
+unsigned char ucvar = 0;
+char cvar = 0;
+float fvar = 0;
+double dvar = 0;
+char *strvar = 0;
+const char cstrvar[] = "Goodbye";
+int *iptrvar = 0;
+char name[256] = "Dave";
+char path[256] = "/home/beazley";
+
+
+/* Global variables involving a structure */
+Point *ptptr = 0;
+Point pt = { 10, 20 };
+
+/* A variable that we will make read-only in the interface */
+int status = 1;
+
+/* A debugging function to print out their values */
+
+void print_vars() {
+ printf("ivar = %d\n", ivar);
+ printf("svar = %d\n", svar);
+ printf("lvar = %ld\n", lvar);
+ printf("uivar = %u\n", uivar);
+ printf("usvar = %u\n", usvar);
+ printf("ulvar = %lu\n", ulvar);
+ printf("scvar = %d\n", scvar);
+ printf("ucvar = %u\n", ucvar);
+ printf("fvar = %g\n", fvar);
+ printf("dvar = %g\n", dvar);
+ printf("cvar = %c\n", cvar);
+ printf("strvar = %s\n", strvar ? strvar : "(null)");
+ printf("cstrvar = %s\n", cstrvar);
+ printf("iptrvar = %p\n", (void *)iptrvar);
+ printf("name = %s\n", name);
+ printf("ptptr = %p (%d, %d)\n", (void *)ptptr, ptptr ? ptptr->x : 0, ptptr ? ptptr->y : 0);
+ printf("pt = (%d, %d)\n", pt.x, pt.y);
+ printf("status = %d\n", status);
+}
+
+/* A function to create an integer (to test iptrvar) */
+
+int *new_int(int value) {
+ int *ip = (int *) malloc(sizeof(int));
+ *ip = value;
+ return ip;
+}
+
+int value_int(int *value) {
+ return *value;
+}
+
+/* A function to create a point */
+
+Point *new_Point(int x, int y) {
+ Point *p = (Point *) malloc(sizeof(Point));
+ p->x = x;
+ p->y = y;
+ return p;
+}
+
+char * Point_print(Point *p) {
+ static char buffer[256];
+ if (p) {
+ sprintf(buffer,"(%d,%d)", p->x,p->y);
+ } else {
+ sprintf(buffer,"null");
+ }
+ return buffer;
+}
+
+void pt_print() {
+ printf("(%d, %d)\n", pt.x, pt.y);
+}
diff --git a/Examples/scilab/variables/example.h b/Examples/scilab/variables/example.h
new file mode 100644
index 000000000..0f7e89594
--- /dev/null
+++ b/Examples/scilab/variables/example.h
@@ -0,0 +1,6 @@
+/* File: example.h */
+
+typedef struct {
+ int x,y;
+} Point;
+
diff --git a/Examples/scilab/variables/example.i b/Examples/scilab/variables/example.i
new file mode 100644
index 000000000..97ba1f0e6
--- /dev/null
+++ b/Examples/scilab/variables/example.i
@@ -0,0 +1,52 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+#pragma SWIG nowarn=SWIGWARN_TYPEMAP_SWIGTYPELEAK
+
+/* Some global variable declarations */
+%inline %{
+extern int ivar;
+extern short svar;
+extern long lvar;
+extern unsigned int uivar;
+extern unsigned short usvar;
+extern unsigned long ulvar;
+extern signed char scvar;
+extern unsigned char ucvar;
+extern char cvar;
+extern float fvar;
+extern double dvar;
+extern char *strvar;
+extern const char cstrvar[];
+extern int *iptrvar;
+extern char name[256];
+
+extern Point *ptptr;
+extern Point pt;
+%}
+
+
+/* Some read-only variables */
+
+%immutable;
+
+%inline %{
+extern int status;
+extern char path[256];
+%}
+
+%mutable;
+
+/* Some helper functions to make it easier to test */
+%inline %{
+extern void print_vars();
+extern int *new_int(int value);
+extern int value_int(int *value);
+extern Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
+%}
+
diff --git a/Examples/scilab/variables/runme.sci b/Examples/scilab/variables/runme.sci
new file mode 100644
index 000000000..98d76cfa0
--- /dev/null
+++ b/Examples/scilab/variables/runme.sci
@@ -0,0 +1,73 @@
+lines(0);
+ilib_verbose(0);
+ierr = exec('loader.sce', 'errcatch');
+if ierr <> 0 then
+ disp(lasterror());
+ exit(ierr);
+end
+
+// Try to set the values of some global variables
+ivar_set(42);
+svar_set(-31000);
+lvar_set(65537);
+uivar_set(uint32(123456));
+usvar_set(uint16(61000));
+ulvar_set(654321);
+scvar_set(int8(-13));
+ucvar_set(uint8(251));
+cvar_set("S");
+fvar_set(3.14159);
+dvar_set(2.1828);
+strvar_set("Hello World");
+iptrvar_set(new_int(37));
+ptptr_set(new_Point(37,42));
+name_set("Bill");
+
+// Now print out the values of the variables
+printf("Variables (values printed from Scilab)\n");
+printf("ivar = %i\n", ivar_get());
+printf("svar = %i\n", svar_get());
+printf("lvar = %i\n", lvar_get());
+printf("uivar = %i\n", uivar_get());
+printf("usvar = %i\n", usvar_get());
+printf("ulvar = %i\n", ulvar_get());
+printf("scvar = %i\n", scvar_get());
+printf("ucvar = %i\n", ucvar_get());
+printf("fvar = %f\n", fvar_get());
+printf("dvar = %f\n", dvar_get());
+printf("cvar = %s\n", cvar_get());
+printf("strvar = %s\n", strvar_get());
+printf("cstrvar = %s\n", cstrvar_get());
+printf("iptrvar = %i\n", value_int(iptrvar_get()));
+printf("name = %s\n", name_get());
+printf("ptptr = %s\n", Point_print(ptptr_get()));
+printf("pt = %s\n", Point_print(pt_get()));
+printf("status = %d\n", status_get());
+
+printf("\nVariables (values printed from C)\n");
+print_vars()
+
+// Immutable variables
+printf("\nNow I''m going to try and modify some read only variables\n");
+printf(" Tring to set ''path''\n");
+try
+ path_set("Whoa!");
+ printf("Hey, what''s going on?!?! This shouldn''t work\n");
+catch
+ printf("Good.\n");
+end
+printf(" Trying to set ''status''\n");
+try
+ status_set(0);
+ printf("Hey, what''s going on?!?! This shouldn''t work\n");
+catch
+ printf("Good.\n");
+end
+
+// Structure
+printf("\nI''m going to try and update a structure variable.\n");
+pt_set(ptptr_get());
+printf("The new value is %s\n", Point_print(pt_get()));
+
+exit
+
diff --git a/Examples/test-suite/allprotected.i b/Examples/test-suite/allprotected.i
index bd4dfe5c7..086cfb245 100644
--- a/Examples/test-suite/allprotected.i
+++ b/Examples/test-suite/allprotected.i
@@ -8,6 +8,11 @@
%include "std_string.i"
+#ifdef SWIGSCILAB
+%rename(ProcBase) ProtectedBase;
+%rename(PubBase) PublicBase;
+#endif
+
%feature("director") PublicBase;
%feature("director") ProtectedBase;
diff --git a/Examples/test-suite/apply_signed_char.i b/Examples/test-suite/apply_signed_char.i
index c0fa00cfe..d3116f024 100644
--- a/Examples/test-suite/apply_signed_char.i
+++ b/Examples/test-suite/apply_signed_char.i
@@ -4,6 +4,10 @@
%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) DirectorTest;
+#if defined(SWIGSCILAB)
+%rename(DirTest) DirectorTest;
+#endif
+
%apply signed char {char, const char};
%apply const signed char & {const char &};
diff --git a/Examples/test-suite/apply_strings.i b/Examples/test-suite/apply_strings.i
index 54a91f83a..62b578bf2 100644
--- a/Examples/test-suite/apply_strings.i
+++ b/Examples/test-suite/apply_strings.i
@@ -1,5 +1,5 @@
-/* Test %apply for char *, signed char *, unsigned char *
- This won't work in all situations, so does not necessarily have to be implemented. See
+/* Test %apply for char *, signed char *, unsigned char *
+ This won't work in all situations, so does not necessarily have to be implemented. See
http://groups.google.com.ai/group/comp.lang.c++.moderated/browse_thread/thread/ad5873ce25d49324/0ae94552452366be?lnk=raot */
%module(directors="1") apply_strings
@@ -7,6 +7,11 @@
%warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) DigitsGlobalB;
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK) DigitsGlobalC;
+#if defined(SWIGSCILAB)
+%rename(TNum) TNumber;
+%rename(DirTest) DirectorTest;
+#endif
+
%apply char * {UCharPtr};
%apply char * {SCharPtr};
%apply const char * {CUCharPtr};
@@ -53,12 +58,12 @@ typedef struct {
TAscii DigitsMemberA[20];
TAscii *DigitsMemberB;
} TNumber;
-
+
TAscii DigitsGlobalA[20];
TAscii DigitsGlobalB[] = {(unsigned char)'A', (unsigned char)'B', 0};
TAscii *DigitsGlobalC;
-%}
+%}
// Director test
%feature("director");
diff --git a/Examples/test-suite/array_member.i b/Examples/test-suite/array_member.i
index d8e2f873c..845eeb72c 100644
--- a/Examples/test-suite/array_member.i
+++ b/Examples/test-suite/array_member.i
@@ -1,5 +1,9 @@
%module array_member
+#if defined(SWIGSCILAB)
+%rename(RayPkt) RayPacketData;
+#endif
+
%inline %{
typedef struct Foo {
diff --git a/Examples/test-suite/array_typedef_memberin.i b/Examples/test-suite/array_typedef_memberin.i
index ed49543a3..d9f768ed8 100644
--- a/Examples/test-suite/array_typedef_memberin.i
+++ b/Examples/test-suite/array_typedef_memberin.i
@@ -1,4 +1,9 @@
%module array_typedef_memberin
+
+#if defined(SWIGSCILAB)
+%rename(ExDetail) ExampleDetail;
+#endif
+
%inline %{
typedef short Eight[8];
typedef const short ConstEight[8];
diff --git a/Examples/test-suite/arrays.i b/Examples/test-suite/arrays.i
index decce7415..07162aa90 100644
--- a/Examples/test-suite/arrays.i
+++ b/Examples/test-suite/arrays.i
@@ -7,6 +7,10 @@ This test case tests that various types of arrays are working.
#include <stdlib.h>
%}
+#if defined(SWIGSCILAB)
+%rename(ArrSt) ArrayStruct;
+#endif
+
%inline %{
#define ARRAY_LEN 2
diff --git a/Examples/test-suite/bloody_hell.i b/Examples/test-suite/bloody_hell.i
index e580f0dd4..ff296a24c 100644
--- a/Examples/test-suite/bloody_hell.i
+++ b/Examples/test-suite/bloody_hell.i
@@ -2,16 +2,20 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) kMaxIOCTLSpaceParmsSize;
-#define kMaxIOCTLSpaceParmsSize 128
+#ifdef SWIGSCILAB
+%rename(Parms) sm_channel_ix_dump_parms;
+#endif
+
+#define kMaxIOCTLSpaceParmsSize 128
%{
-#define kMaxIOCTLSpaceParmsSize 128
+#define kMaxIOCTLSpaceParmsSize 128
%}
%inline %{
-typedef struct sm_channel_ix_dump_parms {
- unsigned data[(kMaxIOCTLSpaceParmsSize - ((4*sizeof(int)) + (2*sizeof(unsigned))))/sizeof(unsigned)];
-} SM_CHANNEL_IX_DUMP_PARMS;
+typedef struct sm_channel_ix_dump_parms {
+ unsigned data[(kMaxIOCTLSpaceParmsSize - ((4*sizeof(int)) + (2*sizeof(unsigned))))/sizeof(unsigned)];
+} SM_CHANNEL_IX_DUMP_PARMS;
%}
diff --git a/Examples/test-suite/bools.i b/Examples/test-suite/bools.i
index 7b94fcf88..2ef3d93a6 100644
--- a/Examples/test-suite/bools.i
+++ b/Examples/test-suite/bools.i
@@ -1,5 +1,10 @@
// bool typemaps check
%module bools
+
+#if defined(SWIGSCILAB)
+%rename(BoolSt) BoolStructure;
+#endif
+
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) constbool; /* Ruby, wrong class name */
diff --git a/Examples/test-suite/callback.i b/Examples/test-suite/callback.i
index c4d50d3fe..8e28dad06 100644
--- a/Examples/test-suite/callback.i
+++ b/Examples/test-suite/callback.i
@@ -57,6 +57,22 @@
return pf(a);
}
+#if defined(__SUNPRO_CC)
+// workaround for: Error: Could not find a match for foobar_T<T>(int, extern "C" int(*)(int)).
+ extern "C" {
+ typedef int (*foobar_int_int)(int a);
+ typedef double (*foobar_double_double)(double a);
+ };
+ template <class T>
+ int foobar_T(int a, foobar_int_int pf) {
+ return pf(a);
+ }
+ template <class T>
+ double foobar_T(double a, foobar_double_double pf) {
+ return pf(a);
+ }
+#endif
+
template <class T>
const T& ident(const T& x) {
return x;
diff --git a/Examples/test-suite/char_strings.i b/Examples/test-suite/char_strings.i
index cc59815b2..9a87df4e3 100644
--- a/Examples/test-suite/char_strings.i
+++ b/Examples/test-suite/char_strings.i
@@ -9,13 +9,9 @@ below.
%warnfilter(SWIGWARN_TYPEMAP_VARIN_UNDEF) global_char_array1; // Unable to set variable of type char[]
%warnfilter(SWIGWARN_TYPEMAP_CHARLEAK_MSG) global_const_char; // Setting a const char * variable may leak memory.
-#ifdef SWIG_ALLEGRO_CL
%{
#include <stdio.h>
-%}
-#endif
-%{
#define OTHERLAND_MSG "Little message from the safe world."
#define CPLUSPLUS_MSG "A message from the deep dark world of C++, where anything is possible."
static char *global_str = NULL;
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index e37580f7c..87b66f47a 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -143,6 +143,7 @@ CPP_TEST_CASES += \
class_scope_weird \
compactdefaultargs \
const_const_2 \
+ constant_directive \
constant_pointers \
constover \
constructor_copy \
@@ -298,6 +299,7 @@ CPP_TEST_CASES += \
nested_directors \
nested_comment \
nested_scope \
+ nested_template_base \
nested_workaround \
newobject1 \
null_pointer \
@@ -306,6 +308,7 @@ CPP_TEST_CASES += \
operator_pointer_ref \
operbool \
ordering \
+ overload_arrays \
overload_bool \
overload_copy \
overload_extend \
@@ -514,6 +517,7 @@ CPP11_TEST_CASES = \
cpp11_decltype \
cpp11_default_delete \
cpp11_delegating_constructors \
+ cpp11_director_enums \
cpp11_explicit_conversion_operators \
cpp11_final_override \
cpp11_function_objects \
diff --git a/Examples/test-suite/constant_directive.i b/Examples/test-suite/constant_directive.i
new file mode 100644
index 000000000..8204720d6
--- /dev/null
+++ b/Examples/test-suite/constant_directive.i
@@ -0,0 +1,28 @@
+%module constant_directive
+
+// %constant and struct
+%{
+ struct Type1 {
+ Type1(int val = 0) : val(val) {}
+ int val;
+ };
+ static Type1 TYPE1_CONSTANT1(1);
+ static Type1 TYPE1_CONST2(2);
+ static Type1 TYPE1_CONST3(3);
+%}
+
+struct Type1 {
+ Type1(int val = 0) : val(val) {}
+ int val;
+};
+
+%inline %{
+Type1 getType1Instance() { return Type1(111); }
+%}
+
+%constant Type1 TYPE1_CONSTANT1;
+%constant Type1 TYPE1_CONSTANT2 = TYPE1_CONST2;
+%constant Type1 *TYPE1_CONSTANT3 = &TYPE1_CONST3;
+
+%constant int TYPE_INT = 0;
+
diff --git a/Examples/test-suite/constant_pointers.i b/Examples/test-suite/constant_pointers.i
index 388970c4d..9094e9dea 100644
--- a/Examples/test-suite/constant_pointers.i
+++ b/Examples/test-suite/constant_pointers.i
@@ -4,6 +4,11 @@ This testcase primarily test constant pointers, eg int* const. Only a getter is
%module constant_pointers
+#if defined(SWIGSCILAB)
+%rename(MbrVar) MemberVariablesTest;
+%rename(RetVal) ReturnValuesTest;
+#endif
+
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG); /* Setting a pointer/reference variable may leak memory. */
diff --git a/Examples/test-suite/constructor_copy.i b/Examples/test-suite/constructor_copy.i
index 8e92e7840..7dcd05e8b 100644
--- a/Examples/test-suite/constructor_copy.i
+++ b/Examples/test-suite/constructor_copy.i
@@ -5,13 +5,13 @@
%nocopyctor Bar<double>;
%inline %{
-
+
struct Foo1 {
int x;
Foo1(int _x = 2) : x(_x)
{
- }
+ }
};
struct Foo2 {
@@ -25,7 +25,7 @@ struct Foo3 {
struct Foo4 {
Foo4() { }
-
+
protected:
Foo4(const Foo4& ) { }
};
@@ -33,7 +33,7 @@ protected:
struct Foo4a {
Foo4a() { }
-
+
private:
Foo4a(const Foo4a& ) { }
};
@@ -53,7 +53,7 @@ struct Foo8 {
};
template <class T>
-class Bar
+class Bar
{
public:
int x;
@@ -73,7 +73,7 @@ public:
%include "std_vector.i"
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGJAVASCRIPT)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGR) || defined(SWIGOCTAVE) || defined(SWIGRUBY) || defined(SWIGJAVASCRIPT) || defined(SWIGSCILAB)
#define SWIG_GOOD_VECTOR
%ignore std::vector<Space::Flow>::vector(size_type);
%ignore std::vector<Space::Flow>::resize(size_type);
@@ -126,7 +126,7 @@ public:
template <class T>
struct ModelUtils_T {};
- }
+ }
}
%}
@@ -144,13 +144,13 @@ namespace Space1 {
class TotalReturnSwap {
public:
TotalReturnSwap() {}
- };
+ };
template <class T>
class TotalReturnSwap_T {
public:
TotalReturnSwap_T() {}
- };
+ };
}
}
diff --git a/Examples/test-suite/constructor_exception.i b/Examples/test-suite/constructor_exception.i
index 4c867c144..e3cdc47af 100644
--- a/Examples/test-suite/constructor_exception.i
+++ b/Examples/test-suite/constructor_exception.i
@@ -1,14 +1,14 @@
%module constructor_exception
%inline %{
-class Error {
+class MyError {
};
class SomeClass {
public:
SomeClass(int x) {
if (x < 0) {
- throw Error();
+ throw MyError();
}
}
};
@@ -17,7 +17,7 @@ class Test {
SomeClass o;
public:
Test(int x) try : o(x) { }
- catch (Error &) {
+ catch (MyError &) {
}
catch (int) {
}
diff --git a/Examples/test-suite/conversion_ns_template.i b/Examples/test-suite/conversion_ns_template.i
index 0814f2a18..bddda5e7b 100644
--- a/Examples/test-suite/conversion_ns_template.i
+++ b/Examples/test-suite/conversion_ns_template.i
@@ -20,9 +20,13 @@
Bar(){ }
Bar(int){ }
+#if !defined(__SUNPRO_CC)
operator int() { return 0; }
+#endif
operator int&() { static int num = 0; return num; }
+#if !defined(__SUNPRO_CC)
operator Foo<T>() { return Foo<T>(); }
+#endif
operator Foo<T>&() { return *(new Foo<T>()); }
};
}
diff --git a/Examples/test-suite/cpp11_constexpr.i b/Examples/test-suite/cpp11_constexpr.i
index 412b8132a..d91107cc6 100644
--- a/Examples/test-suite/cpp11_constexpr.i
+++ b/Examples/test-suite/cpp11_constexpr.i
@@ -18,6 +18,12 @@ struct ConstExpressions {
static const int LLL = 300;
constexpr int MMM() { return 400; }
constexpr const int NNN() { return 500; }
+ // Regression tests for support added in SWIG 3.0.4:
+ static constexpr const int JJJ1 = 101;
+ constexpr static int KKK1 = 201;
+ // Regression tests for https://github.com/swig/swig/issues/284 :
+ explicit constexpr ConstExpressions(int) { }
+ constexpr explicit ConstExpressions(double) { }
};
%}
diff --git a/Examples/test-suite/cpp11_director_enums.i b/Examples/test-suite/cpp11_director_enums.i
new file mode 100644
index 000000000..420b3c8c9
--- /dev/null
+++ b/Examples/test-suite/cpp11_director_enums.i
@@ -0,0 +1,14 @@
+%module(directors="1") cpp11_director_enums
+
+%warnfilter(SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR) Cpp11DirectorEnumsCallback::g;
+
+%director Cpp11DirectorEnumsCallback;
+
+%inline %{
+enum class Color { Red, Green, Blue=10 };
+struct Cpp11DirectorEnumsCallback {
+ virtual Color f(Color c) = 0;
+ virtual const Color & g(const Color &c) = 0;
+ virtual ~Cpp11DirectorEnumsCallback() {}
+};
+%}
diff --git a/Examples/test-suite/csharp_exceptions.i b/Examples/test-suite/csharp_exceptions.i
index 0f11e7d69..e5b4d495b 100644
--- a/Examples/test-suite/csharp_exceptions.i
+++ b/Examples/test-suite/csharp_exceptions.i
@@ -198,7 +198,7 @@ enum UnmanagedExceptions {
UnmanagedSystemException,
UnmanagedArgumentException,
UnmanagedArgumentNullException,
- UnmanagedArgumentOutOfRangeException,
+ UnmanagedArgumentOutOfRangeException
};
void check_exception(UnmanagedExceptions e) {
diff --git a/Examples/test-suite/csharp_typemaps.i b/Examples/test-suite/csharp_typemaps.i
index 32e735ca7..dc5b40c02 100644
--- a/Examples/test-suite/csharp_typemaps.i
+++ b/Examples/test-suite/csharp_typemaps.i
@@ -77,17 +77,17 @@ public:
Number quadruple(Number n) {
n.Value *= 4;
return n;
-};
+}
Number times8(const Number& num) {
Number n(num);
n.Value *= 8;
return n;
-};
+}
Number times12(const Number* num) {
Number n(*num);
n.Value *= 12;
return n;
-};
+}
%}
// Test $csinput expansion
diff --git a/Examples/test-suite/default_args.i b/Examples/test-suite/default_args.i
index 839d28e3e..bcb8766a8 100644
--- a/Examples/test-suite/default_args.i
+++ b/Examples/test-suite/default_args.i
@@ -13,6 +13,27 @@
%inline %{
#include <string>
+ // All kinds of numbers: hex, octal (which pose special problems to Python), negative...
+ void trickyvalue1(int first, int pos = -1) {}
+ void trickyvalue2(int first, unsigned rgb = 0xabcdef) {}
+ void trickyvalue3(int first, int mode = 0644) {}
+
+ void doublevalue1(int first, double num = 0.0e-1) {}
+ void doublevalue2(int first, double num = -0.0E2) {}
+
+ // Long long arguments are not handled at Python level currently but still work.
+ void seek(long long offset = 0LL) {}
+ void seek2(unsigned long long offset = 0ULL) {}
+ void seek3(long offset = 0L) {}
+ void seek4(unsigned long offset = 0UL) {}
+ void seek5(unsigned long offset = 0U) {}
+ void seek6(unsigned long offset = 02U) {}
+ void seek7(unsigned long offset = 00U) {}
+ void seek8(unsigned long offset = 1U) {}
+ void seek9(long offset = 1L) {}
+ void seekA(long long offset = 1LL) {}
+ void seekB(unsigned long long offset = 1ULL) {}
+
// Anonymous arguments
int anonymous(int = 7771);
int anonymous(int x) { return x; }
@@ -29,6 +50,12 @@
bool blah(speed s = FAST, flavor f = SWEET) { return (s == FAST && f == SWEET); };
};
+ // using base class enum in a derived class
+ class DerivedEnumClass : public EnumClass {
+ public:
+ void accelerate(speed s = SLOW) { }
+ };
+
// casts
const char * casts1(const char *m = (const char *) NULL) {
char *ret = NULL;
@@ -199,6 +226,7 @@ namespace Space {
struct Klass {
int val;
Klass(int val = -1) : val(val) {}
+ static Klass inc(int n = 1, const Klass& k = Klass()) { return Klass(k.val + n); }
};
Klass constructorcall(const Klass& k = Klass()) { return k; }
diff --git a/Examples/test-suite/director_frob.i b/Examples/test-suite/director_frob.i
index cf555eb66..f1d502dc2 100644
--- a/Examples/test-suite/director_frob.i
+++ b/Examples/test-suite/director_frob.i
@@ -1,6 +1,12 @@
%module(directors="1") director_frob;
#pragma SWIG nowarn=SWIGWARN_TYPEMAP_THREAD_UNSAFE,SWIGWARN_TYPEMAP_DIRECTOROUT_PTR
+#ifdef SWIGSCILAB
+%rename(cb) coreCallbacks;
+%rename(On3dEngRedrawn) coreCallbacksOn3dEngineRedrawnData;
+%rename (_On3dEngRedrawn) coreCallbacks_On3dEngineRedrawnData;
+#endif
+
%header %{
#include <iostream>
%}
@@ -17,7 +23,7 @@
virtual ~Alpha() { };
virtual const char* abs_method() = 0;
};
-
+
struct Bravo : Alpha
{
const char* abs_method()
@@ -26,14 +32,14 @@
}
};
- struct Charlie : Bravo
+ struct Charlie : Bravo
{
const char* abs_method()
{
return "Charlie::abs_method()";
}
};
-
+
struct Delta : Charlie
{
};
@@ -50,7 +56,9 @@
public:
Ops() : num(0) {}
virtual ~Ops() {}
+#if !defined(__SUNPRO_CC)
virtual operator int() { return 0; }
+#endif
virtual operator int **() const {
return (int **) 0;
}
diff --git a/Examples/test-suite/director_overload2.i b/Examples/test-suite/director_overload2.i
index 0f3238149..e467c18ce 100644
--- a/Examples/test-suite/director_overload2.i
+++ b/Examples/test-suite/director_overload2.i
@@ -12,10 +12,14 @@ struct OverloadBase {
};
struct OverloadDerived1 : OverloadBase {
virtual void nnn(int vvv) {}
-// virtual void nnn() {}
+#if defined(__SUNPRO_CC)
+ virtual void nnn() {}
+#endif
};
struct OverloadDerived2 : OverloadBase {
-// virtual void nnn(int vvv) {}
+#if defined(__SUNPRO_CC)
+ virtual void nnn(int vvv) {}
+#endif
virtual void nnn() {}
};
%}
diff --git a/Examples/test-suite/director_property.i b/Examples/test-suite/director_property.i
index 3363c3c4f..da37ca4ae 100644
--- a/Examples/test-suite/director_property.i
+++ b/Examples/test-suite/director_property.i
@@ -7,13 +7,13 @@
class Foo {
private:
- std::string a;
+ std::string a_;
public:
virtual ~Foo() {}
virtual std::string ping() { return "Foo::ping()"; }
virtual std::string pong() { return "Foo::pong();" + ping(); }
- virtual std::string getA() { return this->a; }
- virtual void setA(std::string a) { this->a = a; }
+ virtual std::string getA() { return this->a_; }
+ virtual void setA(std::string a) { this->a_ = a; }
static Foo* get_self(Foo *slf) {return slf;}
diff --git a/Examples/test-suite/enum_forward.i b/Examples/test-suite/enum_forward.i
index c82e17be7..784f4fb02 100644
--- a/Examples/test-suite/enum_forward.i
+++ b/Examples/test-suite/enum_forward.i
@@ -8,7 +8,20 @@ enum ForwardEnum2 { CCC, DDD };
%}
%inline %{
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+/* ISO C forbids forward references to ‘enum’ types [-Werror=pedantic] */
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+
+#if !defined(__SUNPRO_C)
enum ForwardEnum1;
+enum ForwardEnum2;
+enum ForwardEnum2;
+enum ForwardEnum3;
+#endif
+%}
+
+%inline %{
enum ForwardEnum1 get_enum1() { return AAA; }
enum ForwardEnum1 test_function1(enum ForwardEnum1 e) {
return e;
@@ -16,22 +29,25 @@ enum ForwardEnum1 test_function1(enum ForwardEnum1 e) {
%}
%inline %{
-enum ForwardEnum2;
-enum ForwardEnum2;
enum ForwardEnum2 get_enum2() { return CCC; }
enum ForwardEnum2 test_function2(enum ForwardEnum2 e) {
return e;
}
-enum ForwardEnum2;
%}
%inline %{
-enum ForwardEnum3;
enum ForwardEnum3 { EEE, FFF };
enum ForwardEnum3 get_enum3() { return EEE; }
enum ForwardEnum3 test_function3(enum ForwardEnum3 e) {
return e;
}
+%}
+
+%inline %{
+#if !defined(__SUNPRO_C)
+enum ForwardEnum2;
enum ForwardEnum3;
+#endif
%}
+
#endif
diff --git a/Examples/test-suite/enum_macro.i b/Examples/test-suite/enum_macro.i
index b18e02a84..c058cdf72 100644
--- a/Examples/test-suite/enum_macro.i
+++ b/Examples/test-suite/enum_macro.i
@@ -1,6 +1,13 @@
%module enum_macro
%inline %{
+
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+/* comma at end of enumerator list [-Werror=pedantic] */
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+
+
enum Greeks1
{
#define GREEK1 -1
diff --git a/Examples/test-suite/enum_missing.i b/Examples/test-suite/enum_missing.i
index de71952e7..8a436ba36 100644
--- a/Examples/test-suite/enum_missing.i
+++ b/Examples/test-suite/enum_missing.i
@@ -14,10 +14,10 @@ enum AVPixelFormat2 {
%}
%inline %{
-typedef struct AVCodecContext {
+typedef struct AVCodecCtx {
enum AVPixelFormat pix_fmt;
enum AVPixelFormat2 pix_fmt2;
-} AVCodecContext;
+} AVCodecCtx;
enum AVPixelFormat global_fmt;
enum AVPixelFormat2 global_fmt2;
@@ -29,7 +29,7 @@ enum AVPixelFormat * use_pixel_format_ptr(enum AVPixelFormat *px) {
return px;
}
-const enum AVPixelFormat2 use_pixel_format2(const enum AVPixelFormat2 px) {
+enum AVPixelFormat2 use_pixel_format2(const enum AVPixelFormat2 px) {
return px;
}
const enum AVPixelFormat2 * use_pixel_format_ptr2(const enum AVPixelFormat2 *px) {
diff --git a/Examples/test-suite/errors/.gitignore b/Examples/test-suite/errors/.gitignore
new file mode 100644
index 000000000..22ca11947
--- /dev/null
+++ b/Examples/test-suite/errors/.gitignore
@@ -0,0 +1,4 @@
+*.newerr
+cpp_recursive_typedef.py
+cpp_shared_ptr.py
+xxx.py
diff --git a/Examples/test-suite/errors/c_extra_rblock.stderr b/Examples/test-suite/errors/c_extra_rblock.stderr
index 82877023a..be14eee4c 100644
--- a/Examples/test-suite/errors/c_extra_rblock.stderr
+++ b/Examples/test-suite/errors/c_extra_rblock.stderr
@@ -1 +1 @@
-c_extra_rblock.i:5: Error: Syntax error in input(1).
+c_extra_rblock.i:5: Error: Syntax error. Extraneous '%}'
diff --git a/Examples/test-suite/errors/c_missing_semi.stderr b/Examples/test-suite/errors/c_missing_semi.stderr
index 791b959ca..18befaa1b 100644
--- a/Examples/test-suite/errors/c_missing_semi.stderr
+++ b/Examples/test-suite/errors/c_missing_semi.stderr
@@ -1 +1 @@
-c_missing_semi.i:3: Error: Syntax error in input(1).
+c_missing_semi.i:3: Error: Syntax error - possibly a missing semicolon.
diff --git a/Examples/test-suite/errors/cpp_extra_brackets.stderr b/Examples/test-suite/errors/cpp_extra_brackets.stderr
index 12bb1f327..f1fabc78d 100644
--- a/Examples/test-suite/errors/cpp_extra_brackets.stderr
+++ b/Examples/test-suite/errors/cpp_extra_brackets.stderr
@@ -1 +1 @@
-cpp_extra_brackets.i:5: Error: Syntax error in input(3).
+cpp_extra_brackets.i:5: Error: Unexpected ')'.
diff --git a/Examples/test-suite/errors/doxygen_unknown_command.stderr b/Examples/test-suite/errors/doxygen_unknown_command.stderr
index 263d9cca2..40055ee8b 100644
--- a/Examples/test-suite/errors/doxygen_unknown_command.stderr
+++ b/Examples/test-suite/errors/doxygen_unknown_command.stderr
@@ -1 +1 @@
-doxygen_unknown_command.i:4: Warning 720: Doxygen parser warning: unknown command "unknown".
+doxygen_unknown_command.i:4: Warning 740: Doxygen parser warning: unknown command "unknown".
diff --git a/Examples/test-suite/errors/pp_missing_enddef.stderr b/Examples/test-suite/errors/pp_missing_enddef.stderr
index bb4ea3c75..c461699e6 100644
--- a/Examples/test-suite/errors/pp_missing_enddef.stderr
+++ b/Examples/test-suite/errors/pp_missing_enddef.stderr
@@ -1 +1 @@
-pp_missing_enddef.i:EOF: Error: Missing %enddef for macro starting on line 3
+pp_missing_enddef.i:3: Error: Missing %enddef for macro starting here
diff --git a/Examples/test-suite/errors/pp_missing_endif.stderr b/Examples/test-suite/errors/pp_missing_endif.stderr
index 0bbfad7f2..4db4021aa 100644
--- a/Examples/test-suite/errors/pp_missing_endif.stderr
+++ b/Examples/test-suite/errors/pp_missing_endif.stderr
@@ -1 +1 @@
-pp_missing_endif.i:EOF: Error: Missing #endif for conditional starting on line 3
+pp_missing_endif.i:3: Error: Missing #endif for conditional starting here
diff --git a/Examples/test-suite/errors/pp_missing_endoffile.i b/Examples/test-suite/errors/pp_missing_endoffile.i
new file mode 100644
index 000000000..2074495a8
--- /dev/null
+++ b/Examples/test-suite/errors/pp_missing_endoffile.i
@@ -0,0 +1,7 @@
+%module xxx
+/* %beginfile and %endoffile are internal directives inserted when %include is
+ * used. Users should never use them directly, but test coverage for this
+ * error message still seems useful to have.
+ */
+%includefile "dummy.i" %beginfile
+
diff --git a/Examples/test-suite/errors/pp_missing_endoffile.stderr b/Examples/test-suite/errors/pp_missing_endoffile.stderr
new file mode 100644
index 000000000..7269f2e92
--- /dev/null
+++ b/Examples/test-suite/errors/pp_missing_endoffile.stderr
@@ -0,0 +1 @@
+pp_missing_endoffile.i:6: Error: Missing %endoffile for file inclusion block starting here
diff --git a/Examples/test-suite/errors/pp_missing_rblock.stderr b/Examples/test-suite/errors/pp_missing_rblock.stderr
index 8f4a54c0a..f00457d73 100644
--- a/Examples/test-suite/errors/pp_missing_rblock.stderr
+++ b/Examples/test-suite/errors/pp_missing_rblock.stderr
@@ -1 +1 @@
-pp_missing_rblock.i:EOF: Error: Unterminated %{ ... %} block starting on line 3
+pp_missing_rblock.i:3: Error: Unterminated %{ ... %} block
diff --git a/Examples/test-suite/errors/pp_unknowndirective.i b/Examples/test-suite/errors/pp_unknowndirective.i
new file mode 100644
index 000000000..659a997d3
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective.i
@@ -0,0 +1,7 @@
+%module xxx
+
+/* This used to give the rather cryptic "Syntax error in input(1)." prior to
+ * SWIG 3.0.4. This testcase checks that the improved message is actually
+ * issued.
+ */
+%remane("typo") tyop;
diff --git a/Examples/test-suite/errors/pp_unknowndirective.stderr b/Examples/test-suite/errors/pp_unknowndirective.stderr
new file mode 100644
index 000000000..d0d5e249f
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective.stderr
@@ -0,0 +1 @@
+pp_unknowndirective.i:7: Error: Unknown directive '%remane'.
diff --git a/Examples/test-suite/errors/pp_unknowndirective2.i b/Examples/test-suite/errors/pp_unknowndirective2.i
new file mode 100644
index 000000000..889e6c5b2
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective2.i
@@ -0,0 +1,11 @@
+%module xxx
+
+#ifdef FOO
+long long i;
+/* Check we get an error for an unknown directive (this should be #elif).
+ * Unknown directives were silently ignored by SWIG < 3.0.3. */
+#elsif defined(BAR)
+long i;
+#else
+int i;
+#endif
diff --git a/Examples/test-suite/errors/pp_unknowndirective2.stderr b/Examples/test-suite/errors/pp_unknowndirective2.stderr
new file mode 100644
index 000000000..70afa670c
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unknowndirective2.stderr
@@ -0,0 +1 @@
+pp_unknowndirective2.i:7: Error: Unknown SWIG preprocessor directive: elsif (if this is a block of target language code, delimit it with %{ and %})
diff --git a/Examples/test-suite/errors/pp_unterm_char.stderr b/Examples/test-suite/errors/pp_unterm_char.stderr
index 4386e933d..147e3859d 100644
--- a/Examples/test-suite/errors/pp_unterm_char.stderr
+++ b/Examples/test-suite/errors/pp_unterm_char.stderr
@@ -1 +1 @@
-pp_unterm_char.i:EOF: Error: Unterminated character constant starting at line 4
+pp_unterm_char.i:4: Error: Unterminated character constant
diff --git a/Examples/test-suite/errors/pp_unterm_comment.stderr b/Examples/test-suite/errors/pp_unterm_comment.stderr
index 4ff34230c..ab1edac14 100644
--- a/Examples/test-suite/errors/pp_unterm_comment.stderr
+++ b/Examples/test-suite/errors/pp_unterm_comment.stderr
@@ -1 +1 @@
-pp_unterm_comment.i:EOF: Error: Unterminated comment starting on line 3
+pp_unterm_comment.i:3: Error: Unterminated comment
diff --git a/Examples/test-suite/errors/pp_unterm_string.stderr b/Examples/test-suite/errors/pp_unterm_string.stderr
index 16b4034f3..14e110ebb 100644
--- a/Examples/test-suite/errors/pp_unterm_string.stderr
+++ b/Examples/test-suite/errors/pp_unterm_string.stderr
@@ -1 +1 @@
-pp_unterm_string.i:EOF: Error: Unterminated string constant starting at line 4
+pp_unterm_string.i:4: Error: Unterminated string constant
diff --git a/Examples/test-suite/errors/pp_unterminated_block.i b/Examples/test-suite/errors/pp_unterminated_block.i
new file mode 100644
index 000000000..99f5f0bc2
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unterminated_block.i
@@ -0,0 +1,5 @@
+%module xxx
+
+%{
+int foo(int x);
+
diff --git a/Examples/test-suite/errors/pp_unterminated_block.stderr b/Examples/test-suite/errors/pp_unterminated_block.stderr
new file mode 100644
index 000000000..03c16a45f
--- /dev/null
+++ b/Examples/test-suite/errors/pp_unterminated_block.stderr
@@ -0,0 +1 @@
+pp_unterminated_block.i:3: Error: Unterminated %{ ... %} block
diff --git a/Examples/test-suite/extend_special_variables.i b/Examples/test-suite/extend_special_variables.i
index 9a453597a..1f218a8b9 100644
--- a/Examples/test-suite/extend_special_variables.i
+++ b/Examples/test-suite/extend_special_variables.i
@@ -28,7 +28,10 @@ namespace Space {
%extend Space::ExtendTemplate
{
- void extending() { $parentclassname tmp; }
+ void extending() {
+ $parentclassname tmp;
+ (void)tmp;
+ }
}
%template(ExtendTemplateInt) Space::ExtendTemplate<int>;
diff --git a/Examples/test-suite/go/contract_runme.go b/Examples/test-suite/go/contract_runme.go
index d86110be2..b20a1a64f 100644
--- a/Examples/test-suite/go/contract_runme.go
+++ b/Examples/test-suite/go/contract_runme.go
@@ -196,13 +196,13 @@ func main() {
}()
//Namespace
- my := contract.NewMyClass(1)
+ contract.NewMyClass(1)
func() {
defer func() {
if recover() == nil {
panic("Failed! constructor preassertion")
}
}()
- my = contract.NewMyClass(0)
+ contract.NewMyClass(0)
}()
}
diff --git a/Examples/test-suite/java/constant_directive_runme.java b/Examples/test-suite/java/constant_directive_runme.java
new file mode 100644
index 000000000..b5135a499
--- /dev/null
+++ b/Examples/test-suite/java/constant_directive_runme.java
@@ -0,0 +1,22 @@
+import constant_directive.*;
+
+public class constant_directive_runme {
+
+ static {
+ try {
+ System.loadLibrary("constant_directive");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ if (constant_directive.TYPE1_CONSTANT1.getVal() != 1)
+ throw new RuntimeException("fail");
+ if (constant_directive.TYPE1_CONSTANT2.getVal() != 2)
+ throw new RuntimeException("fail");
+ if (constant_directive.TYPE1_CONSTANT3.getVal() != 3)
+ throw new RuntimeException("fail");
+ }
+}
diff --git a/Examples/test-suite/java/nested_template_base_runme.java b/Examples/test-suite/java/nested_template_base_runme.java
new file mode 100644
index 000000000..8404afe04
--- /dev/null
+++ b/Examples/test-suite/java/nested_template_base_runme.java
@@ -0,0 +1,27 @@
+import nested_template_base.*;
+
+public class nested_template_base_runme {
+
+ static {
+ try {
+ System.loadLibrary("nested_template_base");
+ } catch (UnsatisfiedLinkError e) {
+ System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
+ System.exit(1);
+ }
+ }
+
+ public static void main(String argv[]) {
+ OuterC.InnerS ois = new OuterC.InnerS(123);
+ OuterC.InnerC oic = new OuterC.InnerC();
+
+ // Check base method is available
+ if (oic.outer(ois).getVal() != 123)
+ throw new RuntimeException("Wrong value calling outer");
+
+ // Check non-derived class using base class
+ if (oic.innerc().outer(ois).getVal() != 123)
+ throw new RuntimeException("Wrong value calling innerc");
+
+ }
+}
diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java
index 7726b613b..e38ce0efd 100644
--- a/Examples/test-suite/java/preproc_line_file_runme.java
+++ b/Examples/test-suite/java/preproc_line_file_runme.java
@@ -63,7 +63,7 @@ public class preproc_line_file_runme {
if (SillyMacroClass.LINE_NUM != 56)
throw new RuntimeException("preproc failure");
- if (SillyMultipleMacroStruct.LINE_NUM != 81)
+ if (SillyMulMacroStruc.LINE_NUM != 81)
throw new RuntimeException("preproc failure");
if (preproc_line_file.INLINE_LINE != 87)
diff --git a/Examples/test-suite/java/smart_pointer_const_overload_runme.java b/Examples/test-suite/java/smart_pointer_const_overload_runme.java
index bb4ae2c8f..9c10dedb2 100644
--- a/Examples/test-suite/java/smart_pointer_const_overload_runme.java
+++ b/Examples/test-suite/java/smart_pointer_const_overload_runme.java
@@ -41,7 +41,7 @@ public class smart_pointer_const_overload_runme {
Assert(f.getAccess() == MUTABLE_ACCESS);
// Test static method
- b.stat();
+ b.statMethod();
Assert(f.getAccess() == CONST_ACCESS);
diff --git a/Examples/test-suite/java/template_default_class_parms_runme.java b/Examples/test-suite/java/template_default_class_parms_runme.java
index 406915b82..0a6571fa8 100644
--- a/Examples/test-suite/java/template_default_class_parms_runme.java
+++ b/Examples/test-suite/java/template_default_class_parms_runme.java
@@ -45,6 +45,11 @@ public class template_default_class_parms_runme {
foo.setTType(a);
a = foo.method(a);
}
+
+ {
+ MapDefaults md = new MapDefaults();
+ md.test_func(10, 20, new DefaultNodeType());
+ }
}
}
diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in
index b0fd82c25..83b15f822 100644
--- a/Examples/test-suite/javascript/Makefile.in
+++ b/Examples/test-suite/javascript/Makefile.in
@@ -6,6 +6,8 @@ LANGUAGE = javascript
NODEGYP = @NODEGYP@
NODEJS = @NODEJS@
SCRIPTSUFFIX = _runme.js
+OBJEXT = @OBJEXT@
+SO = @SO@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@@ -116,10 +118,10 @@ endif
%.clean:
@rm -rf $*
- @rm -f $*_wrap.* $*.so $*.o
+ @rm -f $*_wrap.* $*$(SO) $*.$(OBJEXT)
clean:
- for ext in _wrap.cxx _wrap.o .so; do \
+ for ext in _wrap.cxx _wrap.$(OBJEXT) $(SO); do \
rm -f clientdata_prop_a$${ext} clientdata_prop_b$${ext}; \
rm -f imports_a$${ext} imports_b$${ext}; \
rm -f import_stl_a$${ext} import_stl_b$${ext}; \
diff --git a/Examples/test-suite/kwargs_feature.i b/Examples/test-suite/kwargs_feature.i
index a935b25f3..a8d1c38d8 100644
--- a/Examples/test-suite/kwargs_feature.i
+++ b/Examples/test-suite/kwargs_feature.i
@@ -79,9 +79,9 @@
static const size_type hello = 3;
};
- int rfoo( const size_type& x = Hello::hello, const Hello& y = Hello() )
+ int rfoo( int n = 0, const size_type& x = Hello::hello, const Hello& y = Hello() )
{
- return x;
+ return n - x;
}
%}
%{
diff --git a/Examples/test-suite/li_attribute_template.i b/Examples/test-suite/li_attribute_template.i
index 3d4c108ef..28551c2cf 100644
--- a/Examples/test-suite/li_attribute_template.i
+++ b/Examples/test-suite/li_attribute_template.i
@@ -27,38 +27,38 @@
struct C
{
C(int a, int b, int c) :
- _a(a), _b(b), _c(c), _d(a), _e(b),
+ a(a), b(b), c(c), d(a), _e(b),
_f(a,b), _g(b,c)
{
/*
- _f.first = _a;
- _f.second = _b;
+ _f.first = a;
+ _f.second = b;
- _g.first = _b;
- _g.second = _c;
+ _g.first = b;
+ _g.second = c;
*/
}
int get_value() const
{
- return _a;
+ return a;
}
void set_value(int aa)
{
- _a = aa;
+ a = aa;
}
/* only one ref method */
int& get_ref()
{
- return _b;
+ return b;
}
- Foo get_class_value() const { return _d; }
- void set_class_value( Foo foo) { _d = foo; }
+ Foo get_class_value() const { return d; }
+ void set_class_value( Foo foo) { d = foo; }
const Foo& get_class_ref() const { return _e; }
void set_class_ref( const Foo& foo ) { _e = foo; }
@@ -73,10 +73,10 @@
void set_string(std::string other) { str = other; }
private:
- int _a;
- int _b;
- int _c;
- Foo _d;
+ int a;
+ int b;
+ int c;
+ Foo d;
Foo _e;
pair<T1,T2> _f;
pair<T1,T2> _g;
diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i
index 3d474ec00..25ca6039b 100644
--- a/Examples/test-suite/li_boost_shared_ptr.i
+++ b/Examples/test-suite/li_boost_shared_ptr.i
@@ -1,7 +1,7 @@
// This tests shared_ptr is working okay. It also checks that there are no memory leaks in the
// class that shared_ptr is pointing via a counting mechanism in the constructors and destructor of Klass.
// In order to test that there are no leaks of the shared_ptr class itself (as it is created on the heap)
-// the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools
+// the runtime tests can be run for a long time to monitor memory leaks using memory monitor tools
// like 'top'. There is a wrapper for shared_ptr in shared_ptr_wrapper.h which enables one to
// count the instances of shared_ptr. Uncomment the SHARED_PTR_WRAPPER macro to turn this on.
//
@@ -11,6 +11,16 @@
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK);
+#if defined(SWIGSCILAB)
+%rename(MbrVar) MemberVariables;
+%rename(MbrVal) MemberVariables::MemberValue;
+%rename(MbrPtr) MemberVariables::MemberPointer;
+%rename(MbrRef) MemberVariables::MemberReference;
+%rename(SmartMbrVal) MemberVariables::SmartMemberValue;
+%rename(SmartMbrPtr) MemberVariables::SmartMemberPointer;
+%rename(SmartMbrRef) MemberVariables::SmartMemberReference;
+#endif
+
%inline %{
#include "boost/shared_ptr.hpp"
#include "swig_examples_lock.h"
@@ -34,7 +44,7 @@
# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
#endif
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD) || defined(SWIGOCTAVE)
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif
@@ -93,7 +103,7 @@ struct Klass {
static int getTotal_count() { return total_count; }
private:
- // lock increment and decrement as a destructor could be called at the same time as a
+ // lock increment and decrement as a destructor could be called at the same time as a
// new object is being created - C# / Java, at least, have finalizers run in a separate thread
static SwigExamples::CriticalSection critical_section;
static void increment() { SwigExamples::Lock lock(critical_section); total_count++; if (debug_shared) cout << " ++xxxxx Klass::increment tot: " << total_count << endl;}
@@ -104,15 +114,15 @@ private:
};
SwigExamples::CriticalSection Space::Klass::critical_section;
-struct IgnoredMultipleInheritBase {
+struct IgnoredMultipleInheritBase {
IgnoredMultipleInheritBase() : d(0.0), e(0.0) {}
- virtual ~IgnoredMultipleInheritBase() {}
- double d;
+ virtual ~IgnoredMultipleInheritBase() {}
+ double d;
double e;
- virtual void AVirtualMethod() {}
+ virtual void AVirtualMethod() {}
};
-// For most compilers, this use of multiple inheritance results in different derived and base class
+// For most compilers, this use of multiple inheritance results in different derived and base class
// pointer values ... for some more challenging tests :)
struct KlassDerived : IgnoredMultipleInheritBase, Klass {
KlassDerived() : Klass() {}
@@ -254,7 +264,7 @@ long use_count(const SwigBoost::shared_ptr<KlassDerived>& sptr) {
long use_count(const SwigBoost::shared_ptr<Klass>& sptr) {
return sptr.use_count();
}
-const SwigBoost::shared_ptr<Klass>& ref_1() {
+const SwigBoost::shared_ptr<Klass>& ref_1() {
static SwigBoost::shared_ptr<Klass> sptr;
return sptr;
}
@@ -334,7 +344,11 @@ template <class T1, class T2> struct Base {
};
%}
+#if !defined(SWIGSCILAB)
%template(BaseIntDouble) Base<int, double>;
+#else
+%template(BaseIDbl) Base<int, double>;
+#endif
%inline %{
template <class T1, class T2> struct Pair : Base<T1, T2> {
@@ -356,9 +370,9 @@ SwigBoost::shared_ptr< Pair<int, double> > pair_id1(SwigBoost::shared_ptr< Pair<
%inline %{
namespace SwigBoost {
const int NOT_COUNTING = -123456;
- int shared_ptr_wrapper_count() {
+ int shared_ptr_wrapper_count() {
#ifdef SHARED_PTR_WRAPPER
- return SwigBoost::SharedPtrWrapper::getTotalCount();
+ return SwigBoost::SharedPtrWrapper::getTotalCount();
#else
return NOT_COUNTING;
#endif
diff --git a/Examples/test-suite/li_std_auto_ptr.i b/Examples/test-suite/li_std_auto_ptr.i
index 627572d5c..5fdc5fa35 100644
--- a/Examples/test-suite/li_std_auto_ptr.i
+++ b/Examples/test-suite/li_std_auto_ptr.i
@@ -1,7 +1,7 @@
%module li_std_auto_ptr
%{
-#if (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations" // auto_ptr deprecation
#endif
%}
diff --git a/Examples/test-suite/li_std_combinations.i b/Examples/test-suite/li_std_combinations.i
index 57f945bcd..e28950835 100644
--- a/Examples/test-suite/li_std_combinations.i
+++ b/Examples/test-suite/li_std_combinations.i
@@ -9,15 +9,23 @@
%template(PairIntString) std::pair<int, std::string>;
%template(VectorPairIntString) std::vector< std::pair<int, std::string> >;
-%template(PairIntVectorString) std::pair< int, std::vector<std::string> >;
-
%template(VectorVectorString) std::vector< std::vector<std::string> >;
+
+#if !defined(SWIGSCILAB)
+%template(PairIntVectorString) std::pair< int, std::vector<std::string> >;
%template(PairIntPairIntString) std::pair< int, std::pair<int, std::string> >;
+#else
+%template(PairIntVecStr) std::pair< int, std::vector<std::string> >;
+%template(PairIntPairIntStr) std::pair< int, std::pair<int, std::string> >;
+#endif
+
#if defined(SWIGCSHARP) || defined(SWIGD)
// Checks macro containing a type with a comma
SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >)
#endif
+
%template(PairDoubleString) std::pair< double, std::string >;
%template(VectorPairDoubleString) std::vector< std::pair<double, std::string> >;
+
diff --git a/Examples/test-suite/li_std_container_typemaps.i b/Examples/test-suite/li_std_container_typemaps.i
new file mode 100644
index 000000000..9da32ef8d
--- /dev/null
+++ b/Examples/test-suite/li_std_container_typemaps.i
@@ -0,0 +1,132 @@
+%module li_std_container_typemaps
+
+%include stl.i
+%include std_list.i
+%include std_deque.i
+%include std_set.i
+%include std_multiset.i
+
+%{
+#include <vector>
+#include <list>
+#include <deque>
+#include <set>
+
+#include <iostream>
+#include <iterator>
+#include <algorithm>
+#include <numeric>
+
+using namespace std;
+%}
+
+%inline %{
+class ClassA
+{
+public:
+ ClassA() : a(0) {}
+ ClassA(int _a) : a(_a) {}
+ ClassA(const ClassA& c) : a(c.a) {}
+ int a;
+};
+
+typedef ClassA* ClassAPtr;
+
+enum _Color { RED=1, GREEN=10, YELLOW=11, BLUE=100, MAGENTA=101, CYAN=111 };
+typedef enum _Color Color;
+
+namespace std {
+ template<typename T> T binaryOperation(T x, T y) {
+ return static_cast<T>(x + y);
+ }
+
+ template<> bool binaryOperation(bool x, bool y) {
+ return x | y;
+ }
+
+ template<> ClassAPtr binaryOperation(ClassAPtr x, ClassAPtr y) {
+ if (x)
+ y->a += x->a;
+ return y;
+ }
+
+ template<typename SeqCont>
+ struct sequence_container {
+ typedef typename SeqCont::value_type value_type;
+
+ static SeqCont ret_container(const value_type value1, const value_type value2) {
+ SeqCont s;
+ s.insert(s.end(), value1);
+ s.insert(s.end(), value2);
+ return s;
+ }
+
+ static value_type val_container(const SeqCont container) {
+ return std::accumulate(container.begin(), container.end(), value_type(),
+ binaryOperation<value_type>);
+ }
+
+ static value_type ref_container(const SeqCont& container) {
+ return std::accumulate(container.begin(), container.end(), value_type(),
+ binaryOperation<value_type>);
+ }
+ };
+
+ template<typename T, class Container>
+ Container ret_container(const T value1, const T value2) {
+ return sequence_container<Container>::ret_container(value1, value2);
+ }
+ template<typename T, class Container>
+ T val_container(const Container container) {
+ return sequence_container<Container >::val_container(container);
+ }
+ template<typename T, class Container>
+ T ref_container(const Container& container) {
+ return sequence_container<Container >::ref_container(container);
+ }
+}
+%}
+
+%define %instantiate_containers_templates(TYPE...)
+namespace std
+{
+ %template(TYPE ## _vector) std::vector<TYPE>;
+ %template(TYPE ## _list) std::list<TYPE>;
+ %template(TYPE ## _deque) std::deque<TYPE>;
+ %template(TYPE ## _set) std::set<TYPE>;
+ %template(TYPE ## _multiset) std::multiset<TYPE>;
+}
+%enddef
+
+%define %instantiate_containers_functions(TYPE...)
+namespace std
+{
+ %template(ret_ ## TYPE ## _vector) ret_container<TYPE, std::vector<TYPE> >;
+ %template(val_ ## TYPE ## _vector) val_container<TYPE, std::vector<TYPE> >;
+ %template(ref_ ## TYPE ## _vector) ref_container<TYPE, std::vector<TYPE> >;
+ %template(ret_ ## TYPE ## _list) ret_container<TYPE, std::list<TYPE> >;
+ %template(val_ ## TYPE ## _list) val_container<TYPE, std::list<TYPE> >;
+ %template(ref_ ## TYPE ## _list) ref_container<TYPE, std::list<TYPE> >;
+ %template(ret_ ## TYPE ## _deque) ret_container<TYPE, std::deque<TYPE> >;
+ %template(val_ ## TYPE ## _deque) val_container<TYPE, std::deque<TYPE> >;
+ %template(ref_ ## TYPE ## _deque) ref_container<TYPE, std::deque<TYPE> >;
+ %template(ret_ ## TYPE ## _set) ret_container<TYPE, std::set<TYPE> >;
+ %template(val_ ## TYPE ## _set) val_container<TYPE, std::set<TYPE> >;
+ %template(ref_ ## TYPE ## _set) ref_container<TYPE, std::set<TYPE> >;
+ %template(ret_ ## TYPE ## _multiset) ret_container<TYPE, std::multiset<TYPE> >;
+ %template(val_ ## TYPE ## _multiset) val_container<TYPE, std::multiset<TYPE> >;
+ %template(ref_ ## TYPE ## _multiset) ref_container<TYPE, std::multiset<TYPE> >;
+}
+%enddef
+
+%define %instantiate_containers_templates_and_functions(TYPE...)
+ %instantiate_containers_templates(TYPE);
+ %instantiate_containers_functions(TYPE);
+%enddef
+
+%instantiate_containers_templates_and_functions(int);
+%instantiate_containers_templates_and_functions(double);
+%instantiate_containers_templates_and_functions(float);
+%instantiate_containers_templates_and_functions(bool);
+%instantiate_containers_templates_and_functions(string);
+%instantiate_containers_templates_and_functions(ClassAPtr);
diff --git a/Examples/test-suite/li_std_string.i b/Examples/test-suite/li_std_string.i
index 2d0b7503d..a1a55ed85 100644
--- a/Examples/test-suite/li_std_string.i
+++ b/Examples/test-suite/li_std_string.i
@@ -83,6 +83,16 @@ void test_const_pointer_throw() throw(const std::string *) {
std::string *Structure::StaticMemberString2 };
*/
+#ifdef SWIGSCILAB
+%rename(St) MemberString;
+%rename(Str) MemberString;
+%rename(Str2) MemberString2;
+%rename(StaticStr) StaticMemberString;
+%rename(StaticStr2) StaticMemberString2;
+%rename(ConstStr) ConstMemberString;
+%rename(ConstStaticStr) ConstStaticMemberString;
+#endif
+
%inline %{
std::string GlobalString;
std::string GlobalString2 = "global string 2";
diff --git a/Examples/test-suite/li_std_vector_extra.i b/Examples/test-suite/li_std_vector_extra.i
index 114de3f11..531898a0e 100644
--- a/Examples/test-suite/li_std_vector_extra.i
+++ b/Examples/test-suite/li_std_vector_extra.i
@@ -12,6 +12,17 @@
#include <algorithm>
#include <functional>
#include <numeric>
+
+
+#if defined(__clang__)
+// Suppress:
+// warning: destination for this 'memset' call is a pointer to dynamic class
+// 'Test::B'; vtable pointer will be overwritten [-Wdynamic-class-memaccess]
+// memset(v_def,0,sizeof(Type));
+// Better generated code is probably needed though
+#pragma clang diagnostic ignored "-Wdynamic-class-memaccess"
+#endif
+
%}
namespace std {
diff --git a/Examples/test-suite/li_stdint.i b/Examples/test-suite/li_stdint.i
index 518679934..91017aa29 100644
--- a/Examples/test-suite/li_stdint.i
+++ b/Examples/test-suite/li_stdint.i
@@ -3,7 +3,7 @@
%include <stdint.i>
%inline %{
- struct StdInts {
+ struct StdI {
int8_t int8_member;
int16_t int16_member;
int32_t int32_member;
@@ -23,7 +23,7 @@
uint32_t uint32_td(int32_t i) { return i; }
uint64_t uint64_td(int64_t i) { return i; }
- struct StdIntFasts {
+ struct StdIf {
int_fast8_t int_fast8_member;
int_fast16_t int_fast16_member;
int_fast32_t int_fast32_member;
@@ -43,7 +43,7 @@
uint_fast32_t uint_fast32_td(int_fast32_t i) { return i; }
uint_fast64_t uint_fast64_td(int_fast64_t i) { return i; }
- struct StdIntLeasts {
+ struct StdIl {
int_least8_t int_least8_member;
int_least16_t int_least16_member;
int_least32_t int_least32_member;
diff --git a/Examples/test-suite/li_swigtype_inout.i b/Examples/test-suite/li_swigtype_inout.i
index 9d7e9a4c6..136c9fa9e 100644
--- a/Examples/test-suite/li_swigtype_inout.i
+++ b/Examples/test-suite/li_swigtype_inout.i
@@ -13,28 +13,28 @@
#include <iostream>
struct XXX {
XXX(int v) : value(v) {
- if (debug) std::cout << "Default Constructor " << value << " " << this << std::endl;
+ if (debugging) std::cout << "Default Constructor " << value << " " << this << std::endl;
count++;
}
XXX(const XXX &other) {
value = other.value;
- if (debug) std::cout << "Copy Constructor " << value << " " << this << std::endl;
+ if (debugging) std::cout << "Copy Constructor " << value << " " << this << std::endl;
count++;
}
XXX& operator=(const XXX &other) {
value = other.value;
- if (debug) std::cout << "Assignment operator " << value << " " << this << std::endl;
+ if (debugging) std::cout << "Assignment operator " << value << " " << this << std::endl;
return *this;
}
~XXX() {
- if (debug) std::cout << "Destructor " << value << " " << this << std::endl;
+ if (debugging) std::cout << "Destructor " << value << " " << this << std::endl;
count--;
}
void showInfo() {
- if (debug) std::cout << "Info " << value << " " << this << std::endl;
+ if (debugging) std::cout << "Info " << value << " " << this << std::endl;
}
int value;
- static const bool debug = false;
+ static const bool debugging = false;
static int count;
};
int XXX::count = 0;
diff --git a/Examples/test-suite/nested.i b/Examples/test-suite/nested.i
index 004cb4814..1d4710128 100644
--- a/Examples/test-suite/nested.i
+++ b/Examples/test-suite/nested.i
@@ -1,4 +1,4 @@
-/*
+/*
This testcase tests that nested structs/unions work. Named structs/unions declared within
a struct produced redefinition errors in SWIG 1.3.6 as reported by SF bug #447488.
Also tests reported error when a #define placed in a deeply embedded struct/union.
@@ -6,6 +6,13 @@ Also tests reported error when a #define placed in a deeply embedded struct/unio
%module nested
+
+#if defined(SWIGSCILAB)
+%rename(OutStNamed) OuterStructNamed;
+%rename(InStNamed) OuterStructNamed::InnerStructNamed;
+%rename(InUnNamed) OuterStructNamed::Inner_union_named;
+#endif
+
%inline %{
struct TestStruct {
@@ -22,6 +29,13 @@ struct OuterStructNamed {
} inner_union_named;
};
+%}
+
+
+#if !defined(SWIGSCILAB)
+
+%inline %{
+
struct OuterStructUnnamed {
struct {
double xx;
@@ -32,7 +46,6 @@ struct OuterStructUnnamed {
} inner_union_unnamed;
};
-
typedef struct OuterStruct {
union {
@@ -52,3 +65,41 @@ typedef struct OuterStruct {
} OuterStruct;
%}
+
+#else
+
+%inline %{
+
+struct OutStUnnamed {
+ struct {
+ double xx;
+ } inSt;
+ union {
+ double yy;
+ int zz;
+ } inUn;
+};
+
+typedef struct OutSt {
+ union {
+
+ struct nst_st {
+ union in_un {
+#define BAD_STYLE 1
+ int red;
+ struct TestStruct green;
+ } InUn;
+
+ struct in_st {
+ int blue;
+ } InSt;
+ } NstdSt;
+
+ } EmbedUn;
+} OutSt;
+
+%}
+
+#endif
+
+
diff --git a/Examples/test-suite/nested_class.i b/Examples/test-suite/nested_class.i
index ccb7ecac1..ebfc65f3d 100644
--- a/Examples/test-suite/nested_class.i
+++ b/Examples/test-suite/nested_class.i
@@ -1,5 +1,33 @@
%module nested_class
+
+#if defined(SWIGSCILAB)
+%rename(Out) Outer;
+%rename(InSt1) InnerStruct1;
+%rename(InCls1) InnerClass1;
+%rename(InCls2) InnerClass2;
+%rename(InClas3Inst) InnerClass3Instance;
+%rename(InSt3Inst) InnerStruct3Instance;
+%rename(InCls4Type) InnerClass4Typedef;
+%rename(InSt4Type) InnerStruct4Typedef;
+%rename(InCls5Type) InnerClass5Typedef;
+%rename(InSt5Type) InnerStruct5Typedef;
+%rename(InMul) InnerMultiple;
+%rename(InMulDrv) InnerMultipleDerived;
+%rename(MulInst1) MultipleInstance1;
+%rename(MulInst2) MultipleInstance2;
+%rename(MulInst3) MultipleInstance3;
+%rename(MulInst4) MultipleInstance4;
+%rename(MulDrvInst1) MultipleDerivedInstance1;
+%rename(MulDrvInst2) MultipleDerivedInstance2;
+%rename(MulDrvInst3) MultipleDerivedInstance3;
+%rename(MulDrvInst4) MultipleDerivedInstance4;
+%rename(MulInstAnnDrv1) MultipleInstanceAnonDerived1;
+%rename(MulInstAnnDrv2) MultipleInstanceAnonDerived2;
+%rename(MulInstAnnDrv3) MultipleInstanceAnonDerived3;
+%rename(MulInstAnnDrv4) MultipleInstanceAnonDerived4;
+#endif
+
#pragma SWIG nowarn=SWIGWARN_PARSE_UNNAMED_NESTED_CLASS
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerStruct1;
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer::InnerClass1;
@@ -21,6 +49,12 @@
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Outer2::IgnoreMe;
%inline %{
+
+#if __GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
+/* ISO C++ prohibits anonymous structs [-Werror=pedantic] */
+#pragma GCC diagnostic ignored "-Wpedantic"
+#endif
+
struct Outer {
typedef int Integer;
///////////////////////////////////////////
@@ -49,6 +83,9 @@ struct Outer {
struct {
Integer b;
};
+#else
+ Integer a;
+ Integer b;
#endif
union {
@@ -164,6 +201,9 @@ struct Outer {
public:
Integer yy;
};
+#else
+ Integer xx;
+ Integer yy;
#endif
///////////////////////////////////////////
diff --git a/Examples/test-suite/nested_extend_c.i b/Examples/test-suite/nested_extend_c.i
index 64727b9ea..8fde075a4 100644
--- a/Examples/test-suite/nested_extend_c.i
+++ b/Examples/test-suite/nested_extend_c.i
@@ -95,7 +95,7 @@ typedef struct {
} bar;
} FOO;
-struct {
+static struct {
int i;
} THING;
%}
diff --git a/Examples/test-suite/nested_scope.i b/Examples/test-suite/nested_scope.i
index b1515f77f..bd66eec73 100644
--- a/Examples/test-suite/nested_scope.i
+++ b/Examples/test-suite/nested_scope.i
@@ -26,39 +26,42 @@ namespace ns {
#endif
};
}
-#ifndef __clang__
class Outer1 {
struct Nested1;
public:
struct Nested2;
- template <class T> class Abstract;
+#ifdef __clang__
+ struct Nested2 {
+ int data;
+ };
+#endif
+ template <class T> class AbstractClass;
class Real;
};
+#ifndef __clang__
struct Outer1::Nested2 {
int data;
};
+#endif
- class Class {
+ class Klass {
public:
- template <class T> class Abstract;
+ template <class T> class AbstractClass;
class Real;
};
- template <class T> class Class::Abstract {
+ template <class T> class Klass::AbstractClass {
public:
virtual void Method() = 0;
+ virtual ~AbstractClass() {}
};
-#endif
%}
-#ifndef __clang__
- %template(abstract_int) Class::Abstract <int>;
-#endif
+
+%template(abstract_int) Klass::AbstractClass <int>;
+
%inline %{
-#ifndef __clang__
- class Class::Real : public Abstract <int> {
+ class Klass::Real : public AbstractClass <int> {
public:
virtual void Method() {}
};
-#endif
-
%}
diff --git a/Examples/test-suite/nested_template_base.i b/Examples/test-suite/nested_template_base.i
new file mode 100644
index 000000000..0b0272224
--- /dev/null
+++ b/Examples/test-suite/nested_template_base.i
@@ -0,0 +1,38 @@
+%module nested_template_base
+
+%inline %{
+ template <class T> class OuterT {
+ public:
+ T outer(T t) { return t; }
+ };
+%}
+
+// The %template goes after OuterT and before OuterC as OuterC::InnerC's base is handled inside OuterC
+%template(OuterTInnerS) OuterT<OuterC::InnerS>;
+
+#if !defined(SWIGCSHARP) && !defined(SWIGJAVA)
+%feature("flatnested") OuterC::InnerS;
+%feature("flatnested") OuterC::InnerC;
+#endif
+
+
+%inline %{
+ class OuterC {
+ public:
+ struct InnerS;
+ class InnerC;
+ };
+
+ struct OuterC::InnerS {
+ int val;
+ InnerS(int val = 0) : val(val) {}
+ };
+
+
+ class OuterC::InnerC : public OuterT<InnerS> {
+ public:
+ OuterT<InnerS>& innerc() {
+ return *this;
+ }
+ };
+%}
diff --git a/Examples/test-suite/octave/li_boost_shared_ptr_runme.m b/Examples/test-suite/octave/li_boost_shared_ptr_runme.m
new file mode 100644
index 000000000..a9f4a82c0
--- /dev/null
+++ b/Examples/test-suite/octave/li_boost_shared_ptr_runme.m
@@ -0,0 +1,566 @@
+1;
+li_boost_shared_ptr;
+
+function verifyValue(expected, got)
+ if (expected ~= got)
+ error("verify value failed.");% Expected: ", expected, " Got: ", got)
+ end
+endfunction
+
+function verifyCount(expected, k)
+ got = use_count(k);
+ if (expected ~= got)
+ error("verify use_count failed. Expected: %d Got: %d ", expected, got);
+ end
+endfunction
+
+function runtest()
+ li_boost_shared_ptr; # KTTODO this needs to be here at present. Global module failure?
+ # simple shared_ptr usage - created in C++
+ k = Klass("me oh my");
+ val = k.getValue();
+ verifyValue("me oh my", val)
+ verifyCount(1, k)
+
+ # simple shared_ptr usage - not created in C++
+ k = factorycreate();
+ val = k.getValue();
+ verifyValue("factorycreate", val)
+ verifyCount(1, k)
+
+ # pass by shared_ptr
+ k = Klass("me oh my");
+ kret = smartpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointertest", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by shared_ptr pointer
+ k = Klass("me oh my");
+ kret = smartpointerpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by shared_ptr reference
+ k = Klass("me oh my");
+ kret = smartpointerreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by shared_ptr pointer reference
+ k = Klass("me oh my");
+ kret = smartpointerpointerreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # const pass by shared_ptr
+ k = Klass("me oh my");
+ kret = constsmartpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # const pass by shared_ptr pointer
+ k = Klass("me oh my");
+ kret = constsmartpointerpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # const pass by shared_ptr reference
+ k = Klass("me oh my");
+ kret = constsmartpointerreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by value
+ k = Klass("me oh my");
+ kret = valuetest(k);
+ val = kret.getValue();
+ verifyValue("me oh my valuetest", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # pass by pointer
+ k = Klass("me oh my");
+ kret = pointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my pointertest", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # pass by reference
+ k = Klass("me oh my");
+ kret = reftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my reftest", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # pass by pointer reference
+ k = Klass("me oh my");
+ kret = pointerreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my pointerreftest", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # null tests
+ #KTODO None not defined
+ # k = None;
+
+ # if (smartpointertest(k) ~= None)
+ # error("return was not null")
+ # end
+
+ # if (smartpointerpointertest(k) ~= None)
+ # error("return was not null")
+ # end
+
+ # if (smartpointerreftest(k) ~= None)
+ # error("return was not null")
+ # end
+
+ # if (smartpointerpointerreftest(k) ~= None)
+ # error("return was not null")
+ # end
+
+ # if (nullsmartpointerpointertest(None) ~= "null pointer")
+ # error("not null smartpointer pointer")
+ # end
+
+ # # try:
+ # # valuetest(k)
+ # # error("Failed to catch null pointer")
+ # # except ValueError:
+ # # pass
+
+ # if (pointertest(k) ~= None)
+ # error("return was not null")
+ # end
+
+ # # try:
+ # # reftest(k)
+ # # error("Failed to catch null pointer")
+ # # except ValueError:
+ # # pass
+
+ # $owner
+ k = pointerownertest();
+ val = k.getValue();
+ verifyValue("pointerownertest", val)
+ verifyCount(1, k)
+ k = smartpointerpointerownertest();
+ val = k.getValue();
+ verifyValue("smartpointerpointerownertest", val)
+ verifyCount(1, k)
+
+ # //////////////////////////////// Derived class ////////////////////////////////////////
+ # derived pass by shared_ptr
+ k = KlassDerived("me oh my");
+ kret = derivedsmartptrtest(k);
+ val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrtest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # derived pass by shared_ptr pointer
+ k = KlassDerived("me oh my");
+ kret = derivedsmartptrpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointertest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # derived pass by shared_ptr ref
+ k = KlassDerived("me oh my");
+ kret = derivedsmartptrreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrreftest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # derived pass by shared_ptr pointer ref
+ k = KlassDerived("me oh my");
+ kret = derivedsmartptrpointerreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # derived pass by pointer
+ k = KlassDerived("me oh my");
+ kret = derivedpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my derivedpointertest-Derived", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # derived pass by ref
+ k = KlassDerived("me oh my");
+ kret = derivedreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my derivedreftest-Derived", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # //////////////////////////////// Derived and base class mixed ////////////////////////////////////////
+ # pass by shared_ptr (mixed)
+ k = KlassDerived("me oh my");
+ kret = smartpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointertest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by shared_ptr pointer (mixed)
+ k = KlassDerived("me oh my");
+ kret = smartpointerpointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by shared_ptr reference (mixed)
+ k = KlassDerived("me oh my");
+ kret = smartpointerreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by shared_ptr pointer reference (mixed)
+ k = KlassDerived("me oh my");
+ kret = smartpointerpointerreftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest-Derived", val)
+ verifyCount(2, k)
+ verifyCount(2, kret)
+
+ # pass by value (mixed)
+ k = KlassDerived("me oh my");
+ kret = valuetest(k);
+ val = kret.getValue();
+ verifyValue("me oh my valuetest", val) # note slicing
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # pass by pointer (mixed)
+ k = KlassDerived("me oh my");
+ kret = pointertest(k);
+ val = kret.getValue();
+ verifyValue("me oh my pointertest-Derived", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+ # pass by ref (mixed)
+ k = KlassDerived("me oh my");
+ kret = reftest(k);
+ val = kret.getValue();
+ verifyValue("me oh my reftest-Derived", val)
+ verifyCount(1, k)
+ verifyCount(1, kret)
+
+ # //////////////////////////////// Overloading tests ////////////////////////////////////////
+ # Base class
+ k = Klass("me oh my");
+ verifyValue(overload_rawbyval(k), "rawbyval")
+ verifyValue(overload_rawbyref(k), "rawbyref")
+ verifyValue(overload_rawbyptr(k), "rawbyptr")
+ verifyValue(overload_rawbyptrref(k), "rawbyptrref")
+
+ verifyValue(overload_smartbyval(k), "smartbyval")
+ verifyValue(overload_smartbyref(k), "smartbyref")
+ verifyValue(overload_smartbyptr(k), "smartbyptr")
+ verifyValue(overload_smartbyptrref(k), "smartbyptrref")
+
+ # Derived class
+ k = KlassDerived("me oh my");
+ verifyValue(overload_rawbyval(k), "rawbyval")
+ verifyValue(overload_rawbyref(k), "rawbyref")
+ verifyValue(overload_rawbyptr(k), "rawbyptr")
+ verifyValue(overload_rawbyptrref(k), "rawbyptrref")
+
+ verifyValue(overload_smartbyval(k), "smartbyval")
+ verifyValue(overload_smartbyref(k), "smartbyref")
+ verifyValue(overload_smartbyptr(k), "smartbyptr")
+ verifyValue(overload_smartbyptrref(k), "smartbyptrref")
+
+ # 3rd derived class
+ k = Klass3rdDerived("me oh my");
+ val = k.getValue();
+ verifyValue("me oh my-3rdDerived", val)
+ verifyCount(1, k)
+
+ val = test3rdupcast(k);
+ verifyValue("me oh my-3rdDerived", val)
+ verifyCount(1, k)
+
+ # //////////////////////////////// Member variables ////////////////////////////////////////
+ # smart pointer by value
+ m = MemberVariables();
+ k = Klass("smart member value");
+ m.SmartMemberValue = k;
+ val = k.getValue();
+ verifyValue("smart member value", val)
+ verifyCount(2, k)
+
+ kmember = m.SmartMemberValue;
+ val = kmember.getValue();
+ verifyValue("smart member value", val)
+ verifyCount(3, kmember)
+ verifyCount(3, k)
+
+ clear m
+ verifyCount(2, kmember)
+ verifyCount(2, k)
+
+ # smart pointer by pointer
+ m = MemberVariables();
+ k = Klass("smart member pointer");
+ m.SmartMemberPointer = k;
+ val = k.getValue();
+ verifyValue("smart member pointer", val)
+ verifyCount(1, k)
+
+ kmember = m.SmartMemberPointer;
+ val = kmember.getValue();
+ verifyValue("smart member pointer", val)
+ verifyCount(2, kmember)
+ verifyCount(2, k)
+
+ clear m
+ verifyCount(2, kmember)
+ verifyCount(2, k)
+
+ # smart pointer by reference
+ m = MemberVariables();
+ k = Klass("smart member reference");
+ m.SmartMemberReference = k;
+ val = k.getValue();
+ verifyValue("smart member reference", val)
+ verifyCount(2, k)
+
+ kmember = m.SmartMemberReference;
+ val = kmember.getValue();
+ verifyValue("smart member reference", val)
+ verifyCount(3, kmember)
+ verifyCount(3, k)
+
+ # The C++ reference refers to SmartMemberValue...
+ kmemberVal = m.SmartMemberValue;
+ val = kmember.getValue();
+ verifyValue("smart member reference", val)
+ verifyCount(4, kmemberVal)
+ verifyCount(4, kmember)
+ verifyCount(4, k)
+
+ clear m
+ verifyCount(3, kmemberVal)
+ verifyCount(3, kmember)
+ verifyCount(3, k)
+
+ # plain by value
+ m = MemberVariables();
+ k = Klass("plain member value");
+ m.MemberValue = k;
+ val = k.getValue();
+ verifyValue("plain member value", val)
+ verifyCount(1, k)
+
+ kmember = m.MemberValue;
+ val = kmember.getValue();
+ verifyValue("plain member value", val)
+ verifyCount(1, kmember)
+ verifyCount(1, k)
+
+ clear m
+ verifyCount(1, kmember)
+ verifyCount(1, k)
+
+ # plain by pointer
+ m = MemberVariables();
+ k = Klass("plain member pointer");
+ m.MemberPointer = k;
+ val = k.getValue();
+ verifyValue("plain member pointer", val)
+ verifyCount(1, k)
+
+ kmember = m.MemberPointer;
+ val = kmember.getValue();
+ verifyValue("plain member pointer", val)
+ verifyCount(1, kmember)
+ verifyCount(1, k)
+
+ clear m
+ verifyCount(1, kmember)
+ verifyCount(1, k)
+
+ # plain by reference
+ m = MemberVariables();
+ k = Klass("plain member reference");
+ m.MemberReference = k;
+ val = k.getValue();
+ verifyValue("plain member reference", val)
+ verifyCount(1, k)
+
+ kmember = m.MemberReference;
+ val = kmember.getValue();
+ verifyValue("plain member reference", val)
+ verifyCount(1, kmember)
+ verifyCount(1, k)
+
+ clear m
+ verifyCount(1, kmember)
+ verifyCount(1, k)
+
+ # null member variables
+ m = MemberVariables();
+
+ # shared_ptr by value
+ k = m.SmartMemberValue;
+ #KTODO None not defined
+ # if (k ~= None)
+ # error("expected null")
+ # end
+
+ # m.SmartMemberValue = None
+ # k = m.SmartMemberValue
+ # if (k ~= None)
+ # error("expected null")
+ # end
+ # verifyCount(0, k)
+
+ # # plain by value
+ # # try:
+ # # m.MemberValue = None
+ # # error("Failed to catch null pointer")
+ # # except ValueError:
+ # # pass
+
+ # # ////////////////////////////////// Global variables ////////////////////////////////////////
+ # # smart pointer
+ # kglobal = cvar.GlobalSmartValue
+ # if (kglobal ~= None)
+ # error("expected null")
+ # end
+
+ k = Klass("smart global value");
+ cvar.GlobalSmartValue = k;
+ verifyCount(2, k)
+
+ kglobal = cvar.GlobalSmartValue;
+ val = kglobal.getValue();
+ verifyValue("smart global value", val)
+ verifyCount(3, kglobal)
+ verifyCount(3, k)
+ verifyValue("smart global value", cvar.GlobalSmartValue.getValue())
+ #KTTODO cvar.GlobalSmartValue = None
+
+ # plain value
+ k = Klass("global value");
+ cvar.GlobalValue = k;
+ verifyCount(1, k)
+
+ kglobal = cvar.GlobalValue;
+ val = kglobal.getValue();
+ verifyValue("global value", val)
+ verifyCount(1, kglobal)
+ verifyCount(1, k)
+ verifyValue("global value", cvar.GlobalValue.getValue())
+
+ # try:
+ # cvar.GlobalValue = None
+ # error("Failed to catch null pointer")
+ # except ValueError:
+ # pass
+
+ # plain pointer
+ kglobal = cvar.GlobalPointer;
+ #KTODO if (kglobal ~= None)
+ #KTODO error("expected null")
+ #KTODO end
+
+ k = Klass("global pointer");
+ cvar.GlobalPointer = k;
+ verifyCount(1, k)
+
+ kglobal = cvar.GlobalPointer;
+ val = kglobal.getValue();
+ verifyValue("global pointer", val)
+ verifyCount(1, kglobal)
+ verifyCount(1, k)
+ #KTODO cvar.GlobalPointer = None
+
+ # plain reference
+ kglobal;
+ k = Klass("global reference");
+ cvar.GlobalReference = k;
+ verifyCount(1, k)
+
+ kglobal = cvar.GlobalReference;
+ val = kglobal.getValue();
+ verifyValue("global reference", val)
+ verifyCount(1, kglobal)
+ verifyCount(1, k)
+
+ # try:
+ # cvar.GlobalReference = None
+ # error("Failed to catch null pointer")
+ # except ValueError:
+ # pass
+
+ # ////////////////////////////////// Templates ////////////////////////////////////////
+ pid = PairIntDouble(10, 20.2);
+ if (pid.baseVal1 ~= 20 || pid.baseVal2 ~= 40.4)
+ error("Base values wrong")
+ end
+ if (pid.val1 ~= 10 || pid.val2 ~= 20.2)
+ error("Derived Values wrong")
+ end
+
+endfunction
+
+debug = false;%true;
+
+ if (debug)
+ fprintf( "Started\n" )
+ end
+
+ cvar.debug_shared = debug;
+
+ # Change loop count to run for a long time to monitor memory
+ loopCount = 1; #5000
+ for i=0:loopCount
+ runtest()
+ end
+
+ # Expect 1 instance - the one global variable (GlobalValue)
+ #KTTODO next fails, possibly because we commented GlobalSmartValue=None
+ #if (Klass.getTotal_count() ~= 1)
+ # error("Klass.total_count=%d", Klass.getTotal_count())
+ #end
+
+ wrapper_count = shared_ptr_wrapper_count() ;
+ #KTTODO next fails as NOT_COUNTING not in octave name space, so we hard-wire it here
+ #if (wrapper_count ~= NOT_COUNTING)
+ if (wrapper_count ~= -123456)
+ # Expect 1 instance - the one global variable (GlobalSmartValue)
+ if (wrapper_count ~= 1)
+ error("shared_ptr wrapper count=%s", wrapper_count)
+ end
+ end
+
+ if (debug)
+ fprintf( "Finished\n" )
+ end
diff --git a/Examples/test-suite/operator_overload.i b/Examples/test-suite/operator_overload.i
index 061e7024c..90f767a84 100644
--- a/Examples/test-suite/operator_overload.i
+++ b/Examples/test-suite/operator_overload.i
@@ -73,12 +73,6 @@ see bottom for a set of possible tests
%rename(OrOperator) operator ||;
#endif
-#ifdef SWIG_ALLEGRO_CL
-%{
-#include <stdio.h>
-%}
-#endif
-
#ifdef SWIGD
// Due to the way operator overloading is implemented in D1 and D2, the prefix
// increment/decrement operators (D1) resp. the postfix ones (D2) are ignored.
@@ -89,6 +83,7 @@ see bottom for a set of possible tests
%rename(DoubleCast) operator double();
%inline %{
+#include <stdio.h>
#if defined(_MSC_VER)
#include <iso646.h> /* for named logical operator, eg 'operator or' */
diff --git a/Examples/test-suite/overload_arrays.i b/Examples/test-suite/overload_arrays.i
new file mode 100644
index 000000000..42c08390a
--- /dev/null
+++ b/Examples/test-suite/overload_arrays.i
@@ -0,0 +1,148 @@
+// Tests of overloaded functions of arrays
+// Based on overload_simple testcase
+%module overload_arrays
+
+#ifdef SWIGCHICKEN
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) fbool;
+#endif
+
+#ifdef SWIGLUA
+// lua only has one numeric type, so most of the overloads shadow each other creating warnings
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) foo;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) bar;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) Spam;
+#endif
+
+#ifdef SWIGGO
+%warnfilter(SWIGWARN_PARSE_KEYWORD) type; // 'type' is a Go keyword, renamed as 'Xtype'
+%rename(Foos) Foo;
+#endif
+
+
+
+#ifndef SWIG_NO_OVERLOAD
+%immutable Spam::type;
+
+%inline %{
+
+#define SIZE 3
+
+struct Foo {
+};
+
+class Bar {
+public:
+ Bar(int i = 0) { num = i; }
+
+ static int foo(int a=0, int b=0) {return 0;}
+
+ int num;
+};
+
+char *foo() {
+ return (char *) "foo:";
+}
+char *foo(int[SIZE]) {
+ return (char*) "foo:int[SIZE]";
+}
+
+char *foo(double[SIZE]) {
+ return (char*) "foo:double[SIZE]";
+}
+
+char *foo(char *[SIZE]) {
+ return (char*) "foo:char *[SIZE]";
+}
+
+char *foo(Foo *[SIZE]) {
+ return (char*) "foo:Foo *[SIZE]";
+}
+char *foo(Bar *[SIZE]) {
+ return (char *) "foo:Bar *[SIZE]";
+}
+char *foo(void *[SIZE]) {
+ return (char *) "foo:void *[SIZE]";
+}
+char *foo(Foo *[SIZE], int[SIZE]) {
+ return (char *) "foo:Foo *[SIZE],int[SIZE]";
+}
+char *foo(double[SIZE], Bar *[SIZE]) {
+ return (char *) "foo:double[SIZE],Bar *[SIZE]";
+}
+
+char *blah(double[SIZE]) {
+ return (char *) "blah:double[SIZE]";
+}
+
+char *blah(char *[SIZE]) {
+ return (char *) "blah:char *[SIZE]";
+}
+
+class Spam {
+public:
+ Spam() { type = "none"; }
+ Spam(int[SIZE]) { type = "int[SIZE]"; }
+ Spam(double[SIZE]) { type = "double[SIZE]"; }
+ Spam(char *[SIZE]) { type = "char *[SIZE]"; }
+ Spam(Foo *[SIZE]) { type = "Foo *[SIZE]"; }
+ Spam(Bar *[SIZE]) { type = "Bar *[SIZE]"; }
+ Spam(void *[SIZE]) { type = "void *[SIZE]"; }
+ const char *type;
+
+char *foo(int[SIZE]) {
+ return (char*) "foo:int[SIZE]";
+}
+char *foo(double[SIZE]) {
+ return (char*) "foo:double[SIZE]";
+}
+char *foo(char *[SIZE]) {
+ return (char*) "foo:char *[SIZE]";
+}
+char *foo(Foo *[SIZE]) {
+ return (char*) "foo:Foo *[SIZE]";
+}
+char *foo(Bar *[SIZE]) {
+ return (char *) "foo:Bar *[SIZE]";
+}
+char *foo(void *[SIZE]) {
+ return (char *) "foo:void *[SIZE]";
+}
+
+static char *bar(int[SIZE]) {
+ return (char*) "bar:int[SIZE]";
+}
+static char *bar(double[SIZE]) {
+ return (char*) "bar:double[SIZE]";
+}
+static char *bar(char *[SIZE]) {
+ return (char*) "bar:char *[SIZE]";
+}
+static char *bar(Foo *[SIZE]) {
+ return (char*) "bar:Foo *[SIZE]";
+}
+static char *bar(Bar *[SIZE]) {
+ return (char *) "bar:Bar *[SIZE]";
+}
+static char *bar(void *[SIZE]) {
+ return (char *) "bar:void *[SIZE]";
+}
+};
+
+%}
+
+#endif
+
+
+%inline {
+ class ClassA
+ {
+ public:
+ ClassA() {}
+ int method1( ) {return 0;}
+ int method1( int arg1[SIZE] ) {return arg1[0];}
+ protected:
+ int method1( int arg1[SIZE], int arg2[SIZE] ) {return arg1[0] + arg2[0];}
+
+ };
+}
+
diff --git a/Examples/test-suite/php/director_exception_runme.php b/Examples/test-suite/php/director_exception_runme.php
index cb823214b..8b852c2ce 100644
--- a/Examples/test-suite/php/director_exception_runme.php
+++ b/Examples/test-suite/php/director_exception_runme.php
@@ -4,7 +4,7 @@ require "tests.php";
require "director_exception.php";
// No new functions
-check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,bar_pang,returnalltypes_return_int,returnalltypes_return_double,returnalltypes_return_const_char_star,returnalltypes_return_std_string,returnalltypes_return_bar));
+check::functions(array(foo_ping,foo_pong,launder,bar_ping,bar_pong,bar_pang,returnalltypes_return_int,returnalltypes_return_double,returnalltypes_return_const_char_star,returnalltypes_return_std_string,returnalltypes_return_bar,returnalltypes_call_int,returnalltypes_call_double,returnalltypes_call_const_char_star,returnalltypes_call_std_string,returnalltypes_call_bar,is_python_builtin));
// No new classes
check::classes(array(director_exception,Foo,Exception1,Exception2,Base,Bar,ReturnAllTypes));
// now new vars
diff --git a/Examples/test-suite/php/director_thread_runme.php b/Examples/test-suite/php/director_thread_runme.php
index 8df25d969..809dec3e2 100644
--- a/Examples/test-suite/php/director_thread_runme.php
+++ b/Examples/test-suite/php/director_thread_runme.php
@@ -3,6 +3,9 @@
require "tests.php";
require "director_thread.php";
+# Fails in a ZTS-build of PHP - see: https://github.com/swig/swig/pull/155
+exit(0);
+
// No new functions
check::functions(array(millisecondsleep,foo_stop,foo_run,foo_do_foo));
// No new classes
diff --git a/Examples/test-suite/php/exception_order_runme.php b/Examples/test-suite/php/exception_order_runme.php
index a83598170..acb83561a 100644
--- a/Examples/test-suite/php/exception_order_runme.php
+++ b/Examples/test-suite/php/exception_order_runme.php
@@ -2,7 +2,7 @@
require "tests.php";
require "exception_order.php";
-check::functions(array(a_foo,a_bar,a_foobar,a_barfoo));
+check::functions(array(a_foo,a_bar,a_foobar,a_barfoo,is_python_builtin));
check::classes(array(A,E1,E2,E3,exception_order,ET_i,ET_d));
check::globals(array(efoovar,foovar,cfoovar,a_sfoovar,a_foovar,a_efoovar));
diff --git a/Examples/test-suite/php/import_nomodule_runme.php b/Examples/test-suite/php/import_nomodule_runme.php
index 84191fba9..41836ba0f 100644
--- a/Examples/test-suite/php/import_nomodule_runme.php
+++ b/Examples/test-suite/php/import_nomodule_runme.php
@@ -3,7 +3,7 @@ require "tests.php";
require "import_nomodule.php";
// No new functions
-check::functions(array(create_foo,delete_foo,test1));
+check::functions(array(create_foo,delete_foo,test1,is_python_builtin));
// No new classes
check::classes(array(import_nomodule,Bar));
// now new vars
diff --git a/Examples/test-suite/php/threads_exception_runme.php b/Examples/test-suite/php/threads_exception_runme.php
index 31148a1e1..9e4d04e10 100644
--- a/Examples/test-suite/php/threads_exception_runme.php
+++ b/Examples/test-suite/php/threads_exception_runme.php
@@ -4,9 +4,9 @@ require "tests.php";
require "threads_exception.php";
// Check functions
-check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi));
+check::functions(array(test_simple,test_message,test_hosed,test_unknown,test_multi,is_python_builtin));
// Check classes.
-check::classes(array(Exc,Test));
+check::classes(array(Exc,Test,threads_exception));
// Chek globals.
check::globals(array(exc_code,exc_msg));
diff --git a/Examples/test-suite/preproc.i b/Examples/test-suite/preproc.i
index e052bff28..f236bfdff 100644
--- a/Examples/test-suite/preproc.i
+++ b/Examples/test-suite/preproc.i
@@ -11,6 +11,13 @@
#pragma SWIG nowarn=890 /* lots of Go name conflicts */
#pragma SWIG nowarn=206 /* Unexpected tokens after #endif directive. */
+%{
+#if defined(__clang__)
+//Suppress: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
+#pragma clang diagnostic ignored "-Wconstant-logical-operand"
+#endif
+%}
+
/* check __cplusplus case */
%header
%{
@@ -225,8 +232,8 @@ This testcase tests operators for defines
#define A7 13 & 14
#define A8 15 | 16
#define A9 17 ^ 18
-#define A10 19 && 20
-#define A11 21 || 21
+#define A10 1 && 0
+#define A11 1 || 0
#define A12 ~22
#define A13 !23
@@ -346,3 +353,20 @@ int method(struct TypeNameTraits tnt) {
return tnt.val;
}
%}
+
+/* Null directive */
+# /* comment 1 */
+# // comment 2
+# /** comment 3 */
+# /* comment 4 */ /*comment 5*/
+# /** comment 6
+#
+# more comment 6 */
+#
+#
+#
+int methodX(int x);
+%{
+int methodX(int x) { return x+100; }
+%}
+
diff --git a/Examples/test-suite/preproc_constants.i b/Examples/test-suite/preproc_constants.i
index ef5c35e12..db71bd2d7 100644
--- a/Examples/test-suite/preproc_constants.i
+++ b/Examples/test-suite/preproc_constants.i
@@ -1,5 +1,12 @@
%module preproc_constants
+%{
+#if defined(__clang__)
+//Suppress: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand]
+#pragma clang diagnostic ignored "-Wconstant-logical-operand"
+#endif
+%}
+
// Note: C types are slightly different to C++ types as (a && b) is int in C and bool in C++
// Simple constants
@@ -102,3 +109,4 @@ enum MyEnum {
enum MyEnum {
kValue = BIT(2)
};
+
diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i
index b221b7728..cd30b1dc1 100644
--- a/Examples/test-suite/preproc_line_file.i
+++ b/Examples/test-suite/preproc_line_file.i
@@ -2,7 +2,7 @@
// Test __LINE__ and __FILE__ (don't change line numbering in here else runtime tests will need modifying)
#define MYLINE __LINE__
-#define MYLINE_ADJUSTED __LINE__ + 100
+#define MYLINE_ADJUSTED __LINE__ + 100
#define MYFILE __FILE__
#define MYFILE_ADJUSTED __FILE__ ".bak"
@@ -78,7 +78,7 @@ struct NAME { \
int num; \
};
#endif
-KLASS(SillyMultipleMacroStruct)
+KLASS(SillyMulMacroStruc)
%}
%inline %{
diff --git a/Examples/test-suite/primitive_types.i b/Examples/test-suite/primitive_types.i
index 5e3ce3eed..82a673536 100644
--- a/Examples/test-suite/primitive_types.i
+++ b/Examples/test-suite/primitive_types.i
@@ -1,6 +1,11 @@
// Massive primitive datatype test.
%module(directors="1") primitive_types
+#if defined(SWIGSCILAB)
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) ovr_val;
+%rename(TestDir) TestDirector;
+#endif
+
%{
#if defined(_MSC_VER)
#pragma warning(disable: 4290) // C++ exception specification ignored except to indicate a function is not __declspec(nothrow)
@@ -322,10 +327,19 @@ macro(size_t, pfx, sizet)
if (a.str() != b.str()) {
std::cout << "failing in pfx""_""name : "
<< a.str() << " : " << b.str() << std::endl;
- // return 0;
}
}
%enddef
+/* check variables (arrays can't be compared so compare as strings) */
+%define var_array_check(type, pfx, name)
+ std::ostringstream a; std::ostringstream b;
+ a << pfx##_##name;
+ b << def_##name;
+ if (a.str() != b.str()) {
+ std::cout << "failing in pfx""_""name : "
+ << a.str() << " : " << b.str() << std::endl;
+ }
+%enddef
/* check a function call */
%define call_check(type, pfx, name)
@@ -337,7 +351,6 @@ macro(size_t, pfx, sizet)
if (a.str() != b.str()) {
std::cout << "failing in pfx""_""name : "
<< a.str() << " : " << b.str() << std::endl;
- // return 0;
}
}
%enddef
@@ -456,7 +469,7 @@ macro(size_t, pfx, sizet)
{
%test_prim_types_stc(var_check, stc)
%test_prim_types(var_check, var)
- var_check(namet, var, namet);
+ var_array_check(namet, var, namet);
return 1;
}
@@ -540,7 +553,7 @@ macro(size_t, pfx, sizet)
{
%test_prim_types(var_check, cct)
%test_prim_types(var_check, var)
- var_check(namet, var, namet);
+ var_array_check(namet, var, namet);
return 1;
}
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index c79a786da..82a0e9db1 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -11,6 +11,7 @@ endif
LANGUAGE = python
PYTHON = $(PYBIN)
PEP8 = @PEP8@
+PEP8_FLAGS = --ignore=E402,E501,E30,W291,W391
#*_runme.py for Python 2.x, *_runme3.py for Python 3.x
PY2SCRIPTSUFFIX = _runme.py
@@ -126,13 +127,13 @@ py3_runme = $(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
check_pep8 = \
if [ -n "$(PEP8)" ]; then \
- $(PEP8) --ignore=E501,E30,W291,W391 $(SCRIPTPREFIX)$*.py;\
+ $(PEP8) $(PEP8_FLAGS) $(SCRIPTPREFIX)$*.py;\
fi
check_pep8_multi_cpp = \
if [ -n "$(PEP8)" ]; then \
for f in `cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list` ; do \
- $(PEP8) --ignore=E501,E30,W291,W391 $$f.py; \
+ $(PEP8) $(PEP8_FLAGS) $$f.py; \
done \
fi
diff --git a/Examples/test-suite/python/autodoc_runme.py b/Examples/test-suite/python/autodoc_runme.py
index 8c3ca56fa..6ad4bae0c 100644
--- a/Examples/test-suite/python/autodoc_runme.py
+++ b/Examples/test-suite/python/autodoc_runme.py
@@ -2,6 +2,13 @@ from autodoc import *
from commentVerifier import check
import sys
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
+if not is_new_style_class(A):
+ # Missing static methods make this hard to test... skip if -classic is used!
+ sys.exit(0)
+
check(A.__doc__, "Proxy of C++ A class")
check(A.funk.__doc__, "just a string")
check(A.func0.__doc__, "func0(self, arg2, hello) -> int")
diff --git a/Examples/test-suite/python/constant_directive_runme.py b/Examples/test-suite/python/constant_directive_runme.py
new file mode 100644
index 000000000..48f85ce8a
--- /dev/null
+++ b/Examples/test-suite/python/constant_directive_runme.py
@@ -0,0 +1,15 @@
+import constant_directive
+
+if not isinstance(constant_directive.TYPE1_CONSTANT1,constant_directive.Type1):
+ raise RuntimeError("Failure: TYPE1_CONSTANT1 type: {}".format(type(constant_directive.TYPE1_CONSTANT1)))
+if not isinstance(constant_directive.getType1Instance(),constant_directive.Type1):
+ raise RuntimeError("Failure: getType1Instance() type: {}".format(type(constant_directive.getType1Instance())))
+
+if constant_directive.TYPE1_CONSTANT1.val != 1:
+ raise RuntimeError("constant_directive.TYPE1_CONSTANT1.val is %r (should be 1)" % constant_directive.TYPE1_CONSTANT1.val)
+
+if constant_directive.TYPE1_CONSTANT2.val != 2:
+ raise RuntimeError("constant_directive.TYPE1_CONSTANT2.val is %r (should be 2)" % constant_directive.TYPE1_CONSTANT2.val)
+
+if constant_directive.TYPE1_CONSTANT3.val != 3:
+ raise RuntimeError("constant_directive.TYPE1_CONSTANT3.val is %r (should be 3)" % constant_directive.TYPE1_CONSTANT3.val)
diff --git a/Examples/test-suite/python/cpp_static_runme.py b/Examples/test-suite/python/cpp_static_runme.py
index ef8623359..eef921780 100644
--- a/Examples/test-suite/python/cpp_static_runme.py
+++ b/Examples/test-suite/python/cpp_static_runme.py
@@ -1,7 +1,16 @@
#!/usr/bin/evn python
from cpp_static import *
-StaticFunctionTest.static_func()
-StaticFunctionTest.static_func_2(1)
-StaticFunctionTest.static_func_3(1,2)
+
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
+if is_new_style_class(StaticFunctionTest):
+ StaticFunctionTest.static_func()
+ StaticFunctionTest.static_func_2(1)
+ StaticFunctionTest.static_func_3(1,2)
+else:
+ StaticFunctionTest().static_func()
+ StaticFunctionTest().static_func_2(1)
+ StaticFunctionTest().static_func_3(1,2)
StaticMemberTest.static_int = 10
assert StaticMemberTest.static_int == 10
diff --git a/Examples/test-suite/python/default_args_runme.py b/Examples/test-suite/python/default_args_runme.py
index ad5e03d11..25bef14ca 100644
--- a/Examples/test-suite/python/default_args_runme.py
+++ b/Examples/test-suite/python/default_args_runme.py
@@ -1,67 +1,98 @@
-import default_args
-
-ec = default_args.EnumClass()
-if not ec.blah():
- raise RuntimeError,"EnumClass::blah() default arguments don't work"
-
-if default_args.Statics_staticMethod() != 60:
- raise RuntimeError
-
-if default_args.cfunc1(1) != 2:
- raise RuntimeError
-
-if default_args.cfunc2(1) != 3:
- raise RuntimeError
-
-if default_args.cfunc3(1) != 4:
- raise RuntimeError
-
-
-f = default_args.Foo()
-
-f.newname()
-f.newname(1)
-
-
-try:
- f = default_args.Foo(1)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::Foo ignore is not working"
-
-try:
- f = default_args.Foo(1,2)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::Foo ignore is not working"
-
-try:
- f = default_args.Foo(1,2,3)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::Foo ignore is not working"
-
-try:
- m = f.meth(1)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::meth ignore is not working"
-
-try:
- m = f.meth(1,2)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::meth ignore is not working"
-
-try:
- m = f.meth(1,2,3)
- error = 1
-except:
- error = 0
-if error: raise RuntimeError,"Foo::meth ignore is not working"
+# Note that this test is also used by python_default_args_runme.py hence the use of __main__ and the run function
+
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
+def run(module_name):
+ default_args = __import__(module_name)
+ ec = default_args.EnumClass()
+ if not ec.blah():
+ raise RuntimeError("EnumClass::blah() default arguments don't work")
+
+ de = default_args.DerivedEnumClass()
+ de.accelerate()
+ de.accelerate(default_args.EnumClass.SLOW)
+
+ if default_args.Statics_staticMethod() != 60:
+ raise RuntimeError
+
+ if default_args.cfunc1(1) != 2:
+ raise RuntimeError
+
+ if default_args.cfunc2(1) != 3:
+ raise RuntimeError
+
+ if default_args.cfunc3(1) != 4:
+ raise RuntimeError
+
+
+ f = default_args.Foo()
+
+ f.newname()
+ f.newname(1)
+
+
+ try:
+ f = default_args.Foo(1)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::Foo ignore is not working")
+
+ try:
+ f = default_args.Foo(1,2)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::Foo ignore is not working")
+
+ try:
+ f = default_args.Foo(1,2,3)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::Foo ignore is not working")
+
+ try:
+ m = f.meth(1)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::meth ignore is not working")
+
+ try:
+ m = f.meth(1,2)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::meth ignore is not working")
+
+ try:
+ m = f.meth(1,2,3)
+ error = 1
+ except:
+ error = 0
+ if error: raise RuntimeError("Foo::meth ignore is not working")
+
+ if is_new_style_class(default_args.Klass):
+ Klass_inc = default_args.Klass.inc
+ else:
+ Klass_inc = default_args.Klass_inc
+
+ if Klass_inc(100, default_args.Klass(22)).val != 122:
+ raise RuntimeError("Klass::inc failed")
+
+ if Klass_inc(100).val != 99:
+ raise RuntimeError("Klass::inc failed")
+
+ if Klass_inc().val != 0:
+ raise RuntimeError("Klass::inc failed")
+
+ default_args.trickyvalue1(10); default_args.trickyvalue1(10, 10)
+ default_args.trickyvalue2(10); default_args.trickyvalue2(10, 10)
+ default_args.trickyvalue3(10); default_args.trickyvalue3(10, 10)
+ default_args.seek(); default_args.seek(10)
+
+if __name__=="__main__":
+ run('default_args')
diff --git a/Examples/test-suite/python/director_abstract_runme.py b/Examples/test-suite/python/director_abstract_runme.py
index 7d92d10ff..886cda0ae 100644
--- a/Examples/test-suite/python/director_abstract_runme.py
+++ b/Examples/test-suite/python/director_abstract_runme.py
@@ -1,5 +1,8 @@
import director_abstract
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
class MyFoo(director_abstract.Foo):
def __init__(self):
director_abstract.Foo.__init__(self)
@@ -32,12 +35,20 @@ me1 = MyExample1()
if director_abstract.Example1_get_color(me1, 1,2,3) != 1:
raise RuntimeError
+if is_new_style_class(MyExample2):
+ MyExample2_static = MyExample2
+else:
+ MyExample2_static = MyExample2(0, 0)
me2 = MyExample2(1,2)
-if MyExample2.get_color(me2, 1,2,3) != 2:
+if MyExample2_static.get_color(me2, 1,2,3) != 2:
raise RuntimeError
+if is_new_style_class(MyExample3):
+ MyExample3_static = MyExample3
+else:
+ MyExample3_static = MyExample3()
me3 = MyExample3()
-if MyExample3.get_color(me3, 1,2,3) != 3:
+if MyExample3_static.get_color(me3, 1,2,3) != 3:
raise RuntimeError
error = 1
diff --git a/Examples/test-suite/python/global_namespace_runme.py b/Examples/test-suite/python/global_namespace_runme.py
index b64e75ca1..8e42e0653 100644
--- a/Examples/test-suite/python/global_namespace_runme.py
+++ b/Examples/test-suite/python/global_namespace_runme.py
@@ -1,5 +1,8 @@
from global_namespace import *
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
k1 = Klass1()
k2 = Klass2()
k3 = Klass3()
@@ -8,8 +11,12 @@ k5 = Klass5()
k6 = Klass6()
k7 = Klass7()
-KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
-KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
+if is_new_style_class(KlassMethods):
+ KlassMethods_static = KlassMethods
+else:
+ KlassMethods_static = KlassMethods()
+KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
k1 = getKlass1A()
k2 = getKlass2A()
@@ -19,8 +26,8 @@ k5 = getKlass5A()
k6 = getKlass6A()
k7 = getKlass7A()
-KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
-KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
k1 = getKlass1B()
k2 = getKlass2B()
@@ -30,11 +37,19 @@ k5 = getKlass5B()
k6 = getKlass6B()
k7 = getKlass7B()
-KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
-KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
-
-XYZMethods.methodA(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
-XYZMethods.methodB(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
-
-TheEnumMethods.methodA(theenum1, theenum2, theenum3)
-TheEnumMethods.methodA(theenum1, theenum2, theenum3)
+KlassMethods_static.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods_static.methodB(k1, k2, k3, k4, k5, k6, k7)
+
+if is_new_style_class(XYZMethods):
+ XYZMethods_static = XYZMethods
+else:
+ XYZMethods_static = XYZMethods()
+XYZMethods_static.methodA(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
+XYZMethods_static.methodB(XYZ1(), XYZ2(), XYZ3(), XYZ4(), XYZ5(), XYZ6(), XYZ7())
+
+if is_new_style_class(TheEnumMethods):
+ TheEnumMethods_static = TheEnumMethods
+else:
+ TheEnumMethods_static = TheEnumMethods()
+TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)
+TheEnumMethods_static.methodA(theenum1, theenum2, theenum3)
diff --git a/Examples/test-suite/python/implicittest_runme.py b/Examples/test-suite/python/implicittest_runme.py
index a9957bc7e..4cad1bb5d 100644
--- a/Examples/test-suite/python/implicittest_runme.py
+++ b/Examples/test-suite/python/implicittest_runme.py
@@ -4,6 +4,9 @@ def check(a, b):
if a != b:
raise RuntimeError(str(a) + " does not equal " + str(b))
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
#### Class ####
# No implicit conversion
@@ -39,13 +42,17 @@ check(2, A_int(1.0).get())
check(3, A_int(B()).get())
check(4, A_int("hello").get())
-check(1, A_int.sget(1))
-check(2, A_int.sget(1.0))
-check(3, A_int.sget(B()))
+if is_new_style_class(A_int):
+ A_int_static = A_int
+else:
+ A_int_static = A_int(0)
+check(1, A_int_static.sget(1))
+check(2, A_int_static.sget(1.0))
+check(3, A_int_static.sget(B()))
# explicit constructor:
try:
- check(4, A_int.sget("hello"))
+ check(4, A_int_static.sget("hello"))
raise RuntimeError
except TypeError:
pass
diff --git a/Examples/test-suite/python/kwargs_feature_runme.py b/Examples/test-suite/python/kwargs_feature_runme.py
index 7792e2e06..37457c976 100644
--- a/Examples/test-suite/python/kwargs_feature_runme.py
+++ b/Examples/test-suite/python/kwargs_feature_runme.py
@@ -51,7 +51,7 @@ if foo_fn(b=2) != 3:
raise RuntimeError
-#Funtions with keywords
+#Functions with keywords
if foo_kw(_from=2) != 4:
raise RuntimeError
@@ -65,3 +65,17 @@ if foo_mm(min=2) != 4:
if foo_mm(max=3) != 4:
raise RuntimeError
+#Default args with references
+
+if rfoo(n=123) != 120:
+ raise RuntimeError
+
+if rfoo(x=10) != -10:
+ raise RuntimeError
+
+if rfoo(n=11, x=22) != -11:
+ raise RuntimeError
+
+if rfoo(x=11, n=22) != 11:
+ raise RuntimeError
+
diff --git a/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py
index 931317615..a05432925 100644
--- a/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py
+++ b/Examples/test-suite/python/li_boost_shared_ptr_bits_runme.py
@@ -1,5 +1,8 @@
from li_boost_shared_ptr_bits import *
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
def check(nd):
nd.i = 200
i = nd.i
@@ -30,5 +33,8 @@ if sum != 66:
raise "sum is wrong"
################################
-p = HiddenDestructor.create()
+if is_new_style_class(HiddenDestructor):
+ p = HiddenDestructor.create()
+else:
+ p = HiddenDestructor_create()
diff --git a/Examples/test-suite/python/li_boost_shared_ptr_runme.py b/Examples/test-suite/python/li_boost_shared_ptr_runme.py
index f967def14..0e025d546 100644
--- a/Examples/test-suite/python/li_boost_shared_ptr_runme.py
+++ b/Examples/test-suite/python/li_boost_shared_ptr_runme.py
@@ -17,7 +17,7 @@ class li_boost_shared_ptr_runme:
self.runtest()
# Expect 1 instance - the one global variable (GlobalValue)
- if (li_boost_shared_ptr.Klass.getTotal_count() != 1):
+ if (li_boost_shared_ptr.Klass_getTotal_count() != 1):
raise RuntimeError("Klass.total_count=%s" % li_boost_shared_ptr.Klass.getTotal_count())
wrapper_count = li_boost_shared_ptr.shared_ptr_wrapper_count()
diff --git a/Examples/test-suite/python/li_std_auto_ptr_runme.py b/Examples/test-suite/python/li_std_auto_ptr_runme.py
index a29771479..d82a89f42 100644
--- a/Examples/test-suite/python/li_std_auto_ptr_runme.py
+++ b/Examples/test-suite/python/li_std_auto_ptr_runme.py
@@ -2,16 +2,16 @@ from li_std_auto_ptr import *
k1 = makeKlassAutoPtr("first")
k2 = makeKlassAutoPtr("second")
-if Klass.getTotal_count() != 2:
+if Klass_getTotal_count() != 2:
raise "number of objects should be 2"
del k1
-if Klass.getTotal_count() != 1:
+if Klass_getTotal_count() != 1:
raise "number of objects should be 1"
if k2.getLabel() != "second":
raise "wrong object label"
del k2
-if Klass.getTotal_count() != 0:
+if Klass_getTotal_count() != 0:
raise "no objects should be left"
diff --git a/Examples/test-suite/python/namespace_class_runme.py b/Examples/test-suite/python/namespace_class_runme.py
index d139527b7..e009f9515 100644
--- a/Examples/test-suite/python/namespace_class_runme.py
+++ b/Examples/test-suite/python/namespace_class_runme.py
@@ -1,5 +1,8 @@
from namespace_class import *
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
try:
p = Private1()
error = 1
@@ -18,7 +21,10 @@ except:
if (error):
raise RuntimeError, "Private2 is private"
-EulerT3D.toFrame(1,1,1)
+if is_new_style_class(EulerT3D):
+ EulerT3D.toFrame(1,1,1)
+else:
+ EulerT3D().toFrame(1,1,1)
b = BooT_i()
b = BooT_H()
@@ -33,6 +39,7 @@ f.moo(1)
f = FooT_H()
f.foo(Hi)
-f_type = str(type(f))
-if f_type.find("'namespace_class.FooT_H'") == -1:
- raise RuntimeError("Incorrect type: " + f_type)
+if is_new_style_class(FooT_H):
+ f_type = str(type(f))
+ if f_type.find("'namespace_class.FooT_H'") == -1:
+ raise RuntimeError("Incorrect type: " + f_type)
diff --git a/Examples/test-suite/python/nested_template_base_runme.py b/Examples/test-suite/python/nested_template_base_runme.py
new file mode 100644
index 000000000..3d54b8391
--- /dev/null
+++ b/Examples/test-suite/python/nested_template_base_runme.py
@@ -0,0 +1,13 @@
+from nested_template_base import *
+
+
+ois = InnerS(123);
+oic = InnerC();
+
+# Check base method is available
+if (oic.outer(ois).val != 123):
+ raise RuntimeError("Wrong value calling outer");
+
+# Check non-derived class using base class
+if (oic.innerc().outer(ois).val != 123):
+ raise RuntimeError("Wrong value calling innerc");
diff --git a/Examples/test-suite/python/overload_template_fast_runme.py b/Examples/test-suite/python/overload_template_fast_runme.py
index d47f7d14d..299b91db8 100644
--- a/Examples/test-suite/python/overload_template_fast_runme.py
+++ b/Examples/test-suite/python/overload_template_fast_runme.py
@@ -1,4 +1,8 @@
from overload_template_fast import *
+
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
f = foo()
a = maximum(3,4)
@@ -140,6 +144,9 @@ if (nsoverload() != 1050):
raise RuntimeError, ("nsoverload(const char *)")
-A.foo(1)
+if is_new_style_class(A):
+ A.foo(1)
+else:
+ A_foo(1)
b = B()
b.foo(1)
diff --git a/Examples/test-suite/python/preproc_runme.py b/Examples/test-suite/python/preproc_runme.py
index c989294b6..3049f00ab 100644
--- a/Examples/test-suite/python/preproc_runme.py
+++ b/Examples/test-suite/python/preproc_runme.py
@@ -12,3 +12,5 @@ if preproc.defined != 1:
if 2*preproc.one != preproc.two:
raise RuntimeError
+if preproc.methodX(99) != 199:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/python_append_runme.py b/Examples/test-suite/python/python_append_runme.py
index 54d7a3e00..15b0297e9 100644
--- a/Examples/test-suite/python/python_append_runme.py
+++ b/Examples/test-suite/python/python_append_runme.py
@@ -1,12 +1,18 @@
from python_append import *
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
# test not relevant for -builtin
if is_python_builtin():
exit(0)
t=Test()
t.func()
-t.static_func()
+if is_new_style_class(Test):
+ t.static_func()
+else:
+ Test_static_func()
if grabpath() != os.path.dirname(mypath):
raise RuntimeError("grabpath failed")
diff --git a/Examples/test-suite/python/refcount_runme.py b/Examples/test-suite/python/refcount_runme.py
index ab1803f24..ca15e04ac 100644
--- a/Examples/test-suite/python/refcount_runme.py
+++ b/Examples/test-suite/python/refcount_runme.py
@@ -5,7 +5,7 @@ from refcount import *
a = A3()
b1 = B(a)
-b2 = B.create(a)
+b2 = B_create(a)
@@ -14,7 +14,7 @@ if a.ref_count() != 3:
rca = b2.get_rca()
-b3 = B.create(rca)
+b3 = B_create(rca)
if a.ref_count() != 5:
raise RuntimeError("Count = %d" % a.ref_count())
@@ -39,7 +39,7 @@ b5 = global_create(a)
if b5.ref_count() != 1:
raise RuntimeError
-b6 = Factory.create(a)
+b6 = Factory_create(a)
if b6.ref_count() != 1:
raise RuntimeError
diff --git a/Examples/test-suite/python/return_const_value_runme.py b/Examples/test-suite/python/return_const_value_runme.py
index 516e9f5d9..932c4822c 100644
--- a/Examples/test-suite/python/return_const_value_runme.py
+++ b/Examples/test-suite/python/return_const_value_runme.py
@@ -1,12 +1,12 @@
import return_const_value
import sys
-p = return_const_value.Foo_ptr.getPtr()
+p = return_const_value.Foo_ptr_getPtr()
if (p.getVal() != 17):
print "Runtime test1 faild. p.getVal()=", p.getVal()
sys.exit(1)
-p = return_const_value.Foo_ptr.getConstPtr()
+p = return_const_value.Foo_ptr_getConstPtr()
if (p.getVal() != 17):
print "Runtime test2 faild. p.getVal()=", p.getVal()
sys.exit(1)
diff --git a/Examples/test-suite/python/smart_pointer_const_overload_runme.py b/Examples/test-suite/python/smart_pointer_const_overload_runme.py
index f1be315a5..098e5b4c3 100644
--- a/Examples/test-suite/python/smart_pointer_const_overload_runme.py
+++ b/Examples/test-suite/python/smart_pointer_const_overload_runme.py
@@ -56,7 +56,7 @@ def test(b, f):
raise RuntimeError
# Test static method
- b.stat()
+ b.statMethod()
if f.access != CONST_ACCESS:
raise RuntimeError
diff --git a/Examples/test-suite/python/smart_pointer_member_runme.py b/Examples/test-suite/python/smart_pointer_member_runme.py
index 70e655652..2cf3686fc 100644
--- a/Examples/test-suite/python/smart_pointer_member_runme.py
+++ b/Examples/test-suite/python/smart_pointer_member_runme.py
@@ -1,5 +1,8 @@
from smart_pointer_member import *
+def is_new_style_class(cls):
+ return hasattr(cls, "__class__")
+
f = Foo()
f.y = 1
@@ -20,8 +23,9 @@ if b.x != f.x:
if b.z != f.z:
raise RuntimeError
-if Foo.z == Bar.z:
- raise RuntimeError
+if is_new_style_class(Bar): # feature not supported in old style classes
+ if Foo.z == Bar.z:
+ raise RuntimeError
diff --git a/Examples/test-suite/python/typemap_out_optimal_runme.py b/Examples/test-suite/python/typemap_out_optimal_runme.py
index b148f2d06..95556f6bd 100644
--- a/Examples/test-suite/python/typemap_out_optimal_runme.py
+++ b/Examples/test-suite/python/typemap_out_optimal_runme.py
@@ -1,5 +1,5 @@
from typemap_out_optimal import *
cvar.XX_debug = False
-x = XX.create()
+x = XX_create()
diff --git a/Examples/test-suite/rename.h b/Examples/test-suite/rename.h
index 4750337a9..c8199eeeb 100644
--- a/Examples/test-suite/rename.h
+++ b/Examples/test-suite/rename.h
@@ -31,13 +31,27 @@ namespace Space {
};
}
+#if defined(SWIG)
+%exception Space::ABC::operator ABC %{
+#if defined(__clang__)
+ // Workaround for: warning: conversion function converting 'Space::ABC' to itself will never be used
+ result = *arg1;
+#else
+ $action
+#endif
+%}
+#endif
+
namespace Space {
// non-templated class using itself in method and operator
class ABC {
public:
void method(ABC a) const {}
void method(Klass k) const {}
+#if !defined(__clang__)
+ // Workaround for: warning: conversion function converting 'Space::ABC' to itself will never be used
operator ABC() const { ABC a; return a; }
+#endif
operator Klass() const { Klass k; return k; }
};
}
diff --git a/Examples/test-suite/rename4.i b/Examples/test-suite/rename4.i
index 3f61e0c69..9ddff362f 100644
--- a/Examples/test-suite/rename4.i
+++ b/Examples/test-suite/rename4.i
@@ -78,6 +78,15 @@ namespace Space {
};
}
+%exception Space::ABC::operator ABC %{
+#if defined(__clang__)
+ // Workaround for: warning: conversion function converting 'Space::ABC' to itself will never be used
+ result = *arg1;
+#else
+ $action
+#endif
+%}
+
namespace Space {
// non-templated class using itself in method and operator
class ABC {
@@ -90,7 +99,10 @@ class ABC {
void method(ABC a) const {}
void method(Klass k) const {}
+#if !defined(__clang__)
+ // Workaround for: warning: conversion function converting 'Space::ABC' to itself will never be used
operator ABC() const { ABC a; return a; }
+#endif
operator Klass() const { Klass k; return k; }
};
}
diff --git a/Examples/test-suite/scilab/Makefile.in b/Examples/test-suite/scilab/Makefile.in
new file mode 100644
index 000000000..4a9a4f007
--- /dev/null
+++ b/Examples/test-suite/scilab/Makefile.in
@@ -0,0 +1,90 @@
+#######################################################################
+# Makefile for scilab test-suite
+#######################################################################
+
+LANGUAGE = scilab
+SCILAB = @SCILAB@
+SCILAB_OPT = @SCILABOPT@
+SCRIPTSUFFIX = _runme.sci
+
+srcdir = @srcdir@
+top_srcdir = ../@top_srcdir@
+top_builddir = ../@top_builddir@
+
+C_TEST_CASES += \
+ scilab_consts \
+ scilab_enums \
+ scilab_identifier_name \
+
+CPP_TEST_CASES += \
+ inout \
+ primitive_types \
+ scilab_li_matrix \
+ scilab_multivalue \
+ scilab_pointer_conversion_functions \
+
+CPP_STD_TEST_CASES += \
+ li_std_container_typemaps \
+ li_std_string_extra \
+
+include $(srcdir)/../common.mk
+
+# Overriden variables
+SRCDIR = ../$(srcdir)/
+
+# Local variables
+TEST_DIR = $*.dir
+RUNME_SCRIPT = $(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
+SRC_RUNME_SCRIPT = $(srcdir)/$(RUNME_SCRIPT)
+
+# Hide too long identifier warnings
+SWIGOPT += -w720
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +(cd $(TEST_DIR) && $(swig_and_compile_cpp))
+ cd $(TEST_DIR) && $(run_testcase)
+
+%.ctest:
+ $(setup)
+ +(cd $(TEST_DIR) && $(swig_and_compile_c))
+ cd $(TEST_DIR) && $(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +(cd $(TEST_DIR) && $(swig_and_compile_multi_cpp))
+ cd $(TEST_DIR) && $(run_testcase)
+
+# Copies files and creates directories needed for the test case
+setup = \
+ if [ ! -d $(TEST_DIR) ]; then \
+ mkdir $(TEST_DIR); \
+ fi; \
+ if [ -f $(SRC_RUNME_SCRIPT) ]; then \
+ echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \
+ if [ ! -f $(TEST_DIR) ]; then \
+ cp $(SRC_RUNME_SCRIPT) $(TEST_DIR); \
+ fi; \
+ if [ ! -f $(TEST_DIR)/swigtest.start ]; then \
+ cp $(srcdir)/swigtest.start $(TEST_DIR); \
+ fi; \
+ if [ ! -f $(TEST_DIR)/swigtest.quit ]; then \
+ cp $(srcdir)/swigtest.quit $(TEST_DIR); \
+ fi; \
+ else \
+ echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
+ fi; \
+
+# 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 $(RUNME_SCRIPT) ]; then ( \
+ env LD_LIBRARY_PATH=$(srcdir):$$LD_LIBRARY_PATH $(RUNTOOL) $(SCILAB) $(SCILAB_OPT) -f $(RUNME_SCRIPT); ) \
+ fi
+
+# Clean: remove the generated files
+%.clean:
+ @rm -rf $(TEST_DIR)
+
+clean:
diff --git a/Examples/test-suite/scilab/abstract_access_runme.sci b/Examples/test-suite/scilab/abstract_access_runme.sci
new file mode 100644
index 000000000..900a2618b
--- /dev/null
+++ b/Examples/test-suite/scilab/abstract_access_runme.sci
@@ -0,0 +1,16 @@
+exec("swigtest.start", -1);
+
+try
+ D = new_D();
+catch
+ swigtesterror();
+end
+if A_do_x(D) <> 1 then swigtesterror(); end
+
+try
+ delete_D(D);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/abstract_inherit_ok_runme.sci b/Examples/test-suite/scilab/abstract_inherit_ok_runme.sci
new file mode 100644
index 000000000..0ee1e291b
--- /dev/null
+++ b/Examples/test-suite/scilab/abstract_inherit_ok_runme.sci
@@ -0,0 +1,11 @@
+exec("swigtest.start", -1);
+
+try
+ Spam = new_Spam()
+catch
+ swigtesterror();
+end
+
+if Foo_blah(Spam)<>0 then swigtesterror; end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/abstract_inherit_runme.sci b/Examples/test-suite/scilab/abstract_inherit_runme.sci
new file mode 100644
index 000000000..b9058e614
--- /dev/null
+++ b/Examples/test-suite/scilab/abstract_inherit_runme.sci
@@ -0,0 +1,10 @@
+exec("swigtest.start", -1);
+
+try
+ // This call must fail because the constructor does not exist
+ Spam = new_Spam()
+ swigtesterror();
+catch
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/abstract_signature_runme.sci b/Examples/test-suite/scilab/abstract_signature_runme.sci
new file mode 100644
index 000000000..d60acfd76
--- /dev/null
+++ b/Examples/test-suite/scilab/abstract_signature_runme.sci
@@ -0,0 +1,10 @@
+exec("swigtest.start", -1);
+
+// These calls must fail
+ierr = execstr('abstract_foo_meth(1)', 'errcatch');
+if ierr == 0 then swigtesterror(); end
+
+ierr = execstr('abstract_bar_meth(1)', 'errcatch');
+if ierr == 0 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/abstract_typedef2_runme.sci b/Examples/test-suite/scilab/abstract_typedef2_runme.sci
new file mode 100644
index 000000000..8da9c2fab
--- /dev/null
+++ b/Examples/test-suite/scilab/abstract_typedef2_runme.sci
@@ -0,0 +1,15 @@
+exec("swigtest.start", -1);
+
+try
+ a = new_A_UF();
+catch
+ swigtesterror();
+end
+
+try
+ delete_A_UF(a);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/abstract_typedef_runme.sci b/Examples/test-suite/scilab/abstract_typedef_runme.sci
new file mode 100644
index 000000000..bfb03a2f1
--- /dev/null
+++ b/Examples/test-suite/scilab/abstract_typedef_runme.sci
@@ -0,0 +1,17 @@
+exec("swigtest.start", -1);
+
+try
+ e = new_Engine();
+catch
+ swigtesterror();
+end
+
+try
+ a = new_A();
+catch
+ swigtesterror();
+end
+
+// TODO: test write method
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/abstract_virtual_runme.sci b/Examples/test-suite/scilab/abstract_virtual_runme.sci
new file mode 100644
index 000000000..55379eee2
--- /dev/null
+++ b/Examples/test-suite/scilab/abstract_virtual_runme.sci
@@ -0,0 +1,27 @@
+exec("swigtest.start", -1);
+
+try
+ d = new_D();
+catch
+ swigtesterror();
+end
+
+try
+ delete_D(d);
+catch
+ swigtesterror();
+end
+
+try
+ e = new_E();
+catch
+ swigtesterror();
+end
+
+try
+ delete_E(e);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/access_change_runme.sci b/Examples/test-suite/scilab/access_change_runme.sci
new file mode 100644
index 000000000..e3705a2b3
--- /dev/null
+++ b/Examples/test-suite/scilab/access_change_runme.sci
@@ -0,0 +1,39 @@
+exec("swigtest.start", -1);
+
+try
+ baseInt = new_BaseInt();
+catch
+ swigtesterror();
+end
+
+try
+ delete_BaseInt(baseInt);
+catch
+ swigtesterror();
+end
+
+try
+ derivedInt = new_DerivedInt();
+catch
+ swigtesterror();
+end
+
+try
+ delete_DerivedInt(derivedInt);
+catch
+ swigtesterror();
+end
+
+try
+ bottomInt = new_BottomInt();
+catch
+ swigtesterror();
+end
+
+try
+ delete_BottomInt(bottomInt);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/add_link_runme.sci b/Examples/test-suite/scilab/add_link_runme.sci
new file mode 100644
index 000000000..f15d84e1d
--- /dev/null
+++ b/Examples/test-suite/scilab/add_link_runme.sci
@@ -0,0 +1,27 @@
+exec("swigtest.start", -1);
+
+try
+ foo = new_Foo();
+catch
+ swigtesterror();
+end
+
+try
+ foo2 = Foo_blah(foo);
+catch
+ swigtesterror();
+end
+
+try
+ delete_Foo(foo);
+catch
+ swigtesterror();
+end
+
+try
+ delete_Foo(foo2);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/aggregate_runme.sci b/Examples/test-suite/scilab/aggregate_runme.sci
new file mode 100644
index 000000000..ba5768013
--- /dev/null
+++ b/Examples/test-suite/scilab/aggregate_runme.sci
@@ -0,0 +1,21 @@
+exec("swigtest.start", -1);
+
+if UP_get()<>1 then swigtesterror(); end
+if typeof(UP_get())<>"constant" then pause; end
+
+if DOWN_get()<>2 then swigtesterror(); end
+if typeof(DOWN_get())<>"constant" then pause; end
+
+if LEFT_get()<>3 then swigtesterror(); end
+if typeof(LEFT_get())<>"constant" then pause; end
+
+if RIGHT_get()<>4 then swigtesterror(); end
+if typeof(RIGHT_get())<>"constant" then pause; end
+
+// TODO: move is a Scilab function...
+//result = move(UP_get());
+//result = move(DOWN_get());
+//result = move(LEFT_get());
+//result = move(RIGHT_get());
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/allowexcept_runme.sci b/Examples/test-suite/scilab/allowexcept_runme.sci
new file mode 100644
index 000000000..014c77830
--- /dev/null
+++ b/Examples/test-suite/scilab/allowexcept_runme.sci
@@ -0,0 +1,5 @@
+exec("swigtest.start", -1);
+
+// TODO: add tests here
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/allprotected_runme.sci b/Examples/test-suite/scilab/allprotected_runme.sci
new file mode 100644
index 000000000..7bc74fac0
--- /dev/null
+++ b/Examples/test-suite/scilab/allprotected_runme.sci
@@ -0,0 +1,80 @@
+exec("swigtest.start", -1);
+
+// Class Klass
+try
+ klass = new_Klass("allprotected_klass")
+catch
+ swigtesterror(lasterror());
+end
+
+checkequal(Klass_getName(klass), "allprotected_klass", "Klass_getName(new_Klass(""allprotected_klass""))");
+
+// Class PubBase
+try
+ pubBase = new_PubBase("allprotected_PubBase");
+catch
+ swigtesterror(lasterror());
+end
+
+checkequal(PubBase_virtualMethod(pubBase), "PublicBase", "PubBase_virtualMethod(pubBase)");
+
+class = PubBase_instanceMethod(pubBase, klass);
+checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_instanceMethod(pubBase, klass))");
+
+class = PubBase_instanceOverload(pubBase, klass);
+checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_instanceOverloaded(pubBase, klass))");
+
+class = PubBase_instanceOverload(pubBase, klass, "allprotected_klass2");
+checkequal(Klass_getName(class), "allprotected_klass2", "Klass_getName(PubBase_instanceOverloaded(pubBase, klass, ""allprotected_klass2""))");
+
+class = PubBase_staticMethod(klass);
+checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_staticMethod(klass))");
+
+class = PubBase_staticOverloaded(klass);
+checkequal(Klass_getName(class), "allprotected_klass", "Klass_getName(PubBase_staticOverloaded(klass))");
+
+
+class = PubBase_staticOverloaded(klass, "allprotected_klass3");
+checkequal(Klass_getName(class), "allprotected_klass3", "Klass_getName(PubBase_staticOverloaded(klass, ""allprotected_klass3""))");
+
+checkequal(PubBase_EnumVal1_get(), 0, "PubBase_EnumVal1_get()");
+checkequal(PubBase_EnumVal2_get(), 1, "(PubBase_EnumVal2_get()");
+
+
+PubBase_instanceMemb_set(pubBase, 12);
+checkequal(PubBase_instanceMemb_get(pubBase), 12, "PubBase_instanceMemb_get(pubBase)");
+
+checkequal(PubBase_staticConstM_get(), 20, "PubBase_staticConstM_get()");
+checkequal(PubBase_staticMember_get(), 10, "PubBase_staticMember_get()")
+
+PubBase_stringMember_set(pubBase, "dummy");
+checkequal(PubBase_stringMember_get(pubBase), "dummy", "PubBase_stringMember_get()");
+
+// TODO does not work (wrong ENUM mapping?)
+//PubBase_anEnum_get(PubBase)
+//PubBase_anEnum_set(PubBase, ???)
+
+
+// Class ProcBase
+try
+// Constructor is propected and must not be defined here
+ ProcBase = new_ProctectedBase("allprotected_ProcBase");
+ swigtesterror();
+catch
+end
+
+checkequal(ProcBase_EnumVal1_get(), 0, "ProcBase_EnumVal1_get()");
+checkequal(ProcBase_EnumVal2_get(), 1, "ProcBase_EnumVal2_get()");
+
+try
+ delete_Klass(klass);
+catch
+ swigtesterror();
+end
+try
+ delete_PubBase(pubBase);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/anonymous_bitfield_runme.sci b/Examples/test-suite/scilab/anonymous_bitfield_runme.sci
new file mode 100644
index 000000000..9bc462a89
--- /dev/null
+++ b/Examples/test-suite/scilab/anonymous_bitfield_runme.sci
@@ -0,0 +1,60 @@
+exec("swigtest.start", -1);
+
+try
+ foo = new_Foo();
+catch
+ swigtesterror();
+end
+
+checkequal(Foo_x_get(foo), 0, "Foo_x_get()");
+
+checkequal(Foo_y_get(foo), 0, "Foo_y_get()");
+
+checkequal(Foo_z_get(foo), 0, "Foo_y_get()");
+
+checkequal(Foo_f_get(foo), 0, "Foo_f_get()");
+
+checkequal(Foo_seq_get(foo), 0, "Foo_seq_get()");
+
+try
+ Foo_x_set(foo, 5);
+catch
+ swigtesterror();
+end
+checkequal(Foo_x_get(foo), 5, "Foo_x_get()");
+
+try
+ Foo_y_set(foo, 5);
+catch
+ swigtesterror();
+end
+checkequal(Foo_y_get(foo), 5, "Foo_y_get()");
+
+try
+ Foo_f_set(foo, 1);
+catch
+ swigtesterror();
+end
+checkequal(Foo_f_get(foo), 1, "Foo_f_get()");
+
+try
+ Foo_z_set(foo, 13);
+catch
+ swigtesterror();
+end
+checkequal(Foo_z_get(foo), 13, "Foo_z_get()");
+
+try
+ Foo_seq_set(foo, 3);
+catch
+ swigtesterror();
+end
+checkequal(Foo_seq_get(foo), 3, "Foo_seq_get()");
+
+try
+ delete_Foo(foo);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/apply_signed_char_runme.sci b/Examples/test-suite/scilab/apply_signed_char_runme.sci
new file mode 100644
index 000000000..f4aa782eb
--- /dev/null
+++ b/Examples/test-suite/scilab/apply_signed_char_runme.sci
@@ -0,0 +1,43 @@
+exec("swigtest.start", -1);
+
+smallnum = -127;
+checkequal(CharValFunction(smallnum), smallnum, "CharValFunction(smallnum)");
+checkequal(CCharValFunction(smallnum), smallnum, "CCharValFunction(smallnum)");
+checkequal(CCharRefFunction(smallnum), smallnum, "CCharRefFunction(smallnum)");
+
+try
+ globalchar_set(smallnum);
+catch
+ swigtesterror();
+end
+checkequal(globalchar_get(), smallnum, "globalchar_get()");
+checkequal(globalconstchar_get(), -110, "globalconstchar_get()");
+
+try
+ dirTest = new_DirTest();
+catch
+ swigtesterror();
+end
+
+checkequal(DirTest_CharValFunction(dirTest, smallnum), smallnum, "DirTest_CharValFunction(dirTest, smallnum)");
+checkequal(DirTest_CCharValFunction(dirTest, smallnum), smallnum, "DirTest_CCharValFunction(dirTest, smallnum)");
+checkequal(DirTest_CCharRefFunction(dirTest, smallnum), smallnum, "DirTest_CCharRefFunction(dirTest, smallnum)");
+
+// TODO Too long identifiers
+//if dirTest_memberchar_get(dirTest) <> -111 then swigtesterror(); end
+//try
+// dirTest_memberchar_set(dirTest, smallnum)
+//catch
+// swigtesterror();
+//end
+//if dirTest_memberchar_get(dirTest) <> smallnum then swigtesterror(); end
+
+//if dirTest_memberconstchar_get(dirTest) <> -112 then swigtesterror(); end
+
+try
+ delete_DirTest(dirTest);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/apply_strings_runme.sci b/Examples/test-suite/scilab/apply_strings_runme.sci
new file mode 100644
index 000000000..6fb039a7e
--- /dev/null
+++ b/Examples/test-suite/scilab/apply_strings_runme.sci
@@ -0,0 +1,45 @@
+exec("swigtest.start", -1);
+
+testString = "Scilab test string";
+
+checkequal(UCharFunction(testString), testString, "UCharFunction(testString)");
+checkequal(SCharFunction(testString), testString, "SCharFunction(testString)");
+checkequal(CUCharFunction(testString), testString, "CUCharFunction(testString)");
+checkequal(CSCharFunction(testString), testString, "CSCharFunction(testString)");
+//checkequal(CharFunction(testString), testString, "CharFunction(testString)");
+//checkequal(CCharFunction(testString), testString, "CCharFunction(testString)");
+
+try
+ tNum = new_TNum();
+catch
+ swigtesterror();
+end
+//TNumber_DigitsMemberA_get()
+//TNumber_DigitsMemberA_set
+//TNumber_DigitsMemberB_get()
+//TNumber_DigitsMemberB_set
+try
+ delete_TNum(tNum);
+catch
+ swigtesterror();
+end
+
+try
+ dirTest = new_DirTest();
+catch
+ swigtesterror();
+end
+
+checkequal(DirTest_UCharFunction(dirTest, testString), testString, "DirTest_UCharFunction");
+checkequal(DirTest_SCharFunction(dirTest, testString), testString, "DirTest_SCharFunction(dirTest, testString)");
+checkequal(DirTest_CUCharFunction(dirTest, testString), testString, "DirTest_CUCharFunction(dirTest, testString)");
+checkequal(DirTest_CSCharFunction(dirTest, testString), testString, "DirTest_CSharFunction(dirTest, testString)");
+//checkequal(DirTest_CharFunction(dirTest, testString), testString, "DirTest_CharFunction(dirTest, testString)");
+//checkequal(DirTest_CCharFunction(dirTest, testString), testString, "DirTest_CCharFunction(dirTest, testString)");
+try
+ delete_DirTest(dirTest);
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/array_member_runme.sci b/Examples/test-suite/scilab/array_member_runme.sci
new file mode 100644
index 000000000..d839f48ee
--- /dev/null
+++ b/Examples/test-suite/scilab/array_member_runme.sci
@@ -0,0 +1,16 @@
+exec("swigtest.start", -1);
+
+f = new_Foo();
+Foo_data_set(f, [0:7]);
+checkequal(Foo_data_get(f), [0:7], "Foo_data_get()");
+
+Foo_text_set(f, "abcdefgh");
+checkequal(Foo_text_get(f), "abcdefgh", "Foo_text_get()");
+delete_Foo(f);
+
+m = new_MyBuff();
+MyBuff_x_set(m, [0:11]);
+checkequal(MyBuff_x_get(m), [0:11], "MyBuff_x_get()");
+delete_MyBuff(m);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/arrays_dimensionless_runme.sci b/Examples/test-suite/scilab/arrays_dimensionless_runme.sci
new file mode 100644
index 000000000..ac737545f
--- /dev/null
+++ b/Examples/test-suite/scilab/arrays_dimensionless_runme.sci
@@ -0,0 +1,55 @@
+exec("swigtest.start", -1);
+
+// bool
+checkequal(arr_bool([%T %F %F %T %F %T %T %T], 8), 5, "arr_bool");
+
+// char
+checkequal(arr_char(["charptr"], 7), 756, "arr_char");
+
+// signed char
+checkequal(arr_schar([1, 2, 3, 4], 4), 10, "arr_schar");
+checkequal(arr_schar(int8([1, 2, 3, 4]), 4), 10, "arr_schar");
+
+// unsigned char
+checkequal(arr_uchar([1, 2, 3, 4], 4), 10, "arr_uchar");
+checkequal(arr_uchar(uint8([1, 2, 3, 4]), 4), 10, "arr_uchar");
+
+// short
+checkequal(arr_short([1, 2, 3, 4], 4), 10, "arr_short");
+checkequal(arr_short(int16([1, 2, 3, 4]), 4), 10, "arr_short");
+
+// unsigned short
+checkequal(arr_ushort([1, 2, 3, 4], 4), 10, "arr_ushort");
+checkequal(arr_ushort(uint16([1, 2, 3, 4]), 4), 10, "arr_ushort");
+
+// int
+checkequal(arr_int([1, 2, 3, 4], 4), 10, "arr_int");
+checkequal(arr_int(int32([1, 2, 3, 4]), 4), 10, "arr_int");
+
+// unsigned int
+checkequal(arr_uint([1, 2, 3, 4], 4), 10, "");
+checkequal(arr_uint(uint32([1, 2, 3, 4]), 4), 10, "");
+
+// long
+checkequal(arr_long([1, 2, 3, 4], 4), 10, "arr_long");
+checkequal(arr_long(int32([1, 2, 3, 4]), 4), 10, "arr_long");
+
+// unsigned long
+checkequal(arr_ulong([1, 2, 3, 4], 4), 10, "arr_ulong");
+checkequal(arr_ulong(uint32([1, 2, 3, 4]), 4), 10, "arr_ulong");
+
+// long long
+// No equivalent in Scilab 5
+
+// unsigned long long
+// No equivalent in Scilab 5
+
+// float
+a = [1, 2, 3, 4];
+checkequal(arr_float(a, 4), 10, "arr_float");
+
+// double
+a = [1, 2, 3, 4];
+checkequal(arr_double(a, 4), 10, "arr_double");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/arrays_global_runme.sci b/Examples/test-suite/scilab/arrays_global_runme.sci
new file mode 100644
index 000000000..2426276c5
--- /dev/null
+++ b/Examples/test-suite/scilab/arrays_global_runme.sci
@@ -0,0 +1,54 @@
+exec("swigtest.start", -1);
+
+function testArray(arrayName, arraySetFunc, arrayGetFunc, in_values, ..
+ expected_out_values)
+ try
+ arraySetFunc(in_values);
+ catch
+ swigtesterror("error in " + arrayName + "_set()");
+ end
+ try
+ checkequal(arrayGetFunc(), expected_out_values, arrayName + "_get()");
+ catch
+ swigtesterror("error in " + arrayName + "_get()");
+ end
+endfunction
+
+m = [-10, 20];
+um = [10, 20];
+testArray("array_c", array_c_set, array_c_get, ['ab'], ['ab']);
+testArray("array_sc", array_sc_set, array_sc_get, m, m);
+testArray("array_sc", array_sc_set, array_sc_get, int8(m), m);
+testArray("array_uc", array_uc_set, array_uc_get, uint8(um), um);
+testArray("array_s", array_s_set, array_s_get, m, m);
+testArray("array_s", array_s_set, array_s_get, int16(m), m);
+testArray("array_us", array_us_set, array_us_get, uint16(um), um);
+testArray("array_i", array_i_set, array_i_get, m, m);
+testArray("array_i", array_i_set, array_i_get, int32(m), m);
+testArray("array_ui", array_ui_set, array_ui_get, uint32(um), um);
+testArray("array_l", array_l_set, array_l_get, m, m);
+testArray("array_l", array_l_set, array_l_get, int32(m), m);
+testArray("array_ul", array_ul_set, array_ul_get, uint32(um), um);
+testArray("array_f", array_f_set, array_f_get, [-2.5, 2.5], [-2.5, 2.5]);
+testArray("array_d", array_d_set, array_d_get, [-10.5, 20.4], [-10.5, 20.4]);
+
+checkequal(array_const_i_get(), [10, 20], "array_const_i_get()");
+
+ierr = execstr('array_i_set([0:10]', 'errcatch');
+if ierr == 0 then swigtesterror("Overflow error expected"); end
+
+checkequal(BeginString_FIX44a_get(), "FIX.a.a", "BeginString_FIX44a_get()");
+checkequal(BeginString_FIX44b_get(), "FIX.b.b", "BeginString_FIX44b_get()");
+checkequal(BeginString_FIX44c_get(), "FIX.c.c", "BeginString_FIX44c_get()");
+checkequal(BeginString_FIX44d_get(), "FIX.d.d", "BeginString_FIX44d_get()");
+BeginString_FIX44b_set(strcat(["12","\0","45"]));
+checkequal(BeginString_FIX44b_get(), "12\045", "BeginString_FIX44b_get()");
+checkequal(BeginString_FIX44d_get(), "FIX.d.d", "BeginString_FIX44d_get()");
+checkequal(BeginString_FIX44e_get(), "FIX.e.e", "BeginString_FIX44e_get()");
+checkequal(BeginString_FIX44f_get(), "FIX.f.f", "BeginString_FIX44f_get()");
+
+checkequal(test_a("hello","hi","chello","chi"), "hi", "test_a()");
+
+checkequal(test_b("1234567","hi"), "1234567", "test_b()");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/arrays_global_twodim_runme.sci b/Examples/test-suite/scilab/arrays_global_twodim_runme.sci
new file mode 100644
index 000000000..6af5ff217
--- /dev/null
+++ b/Examples/test-suite/scilab/arrays_global_twodim_runme.sci
@@ -0,0 +1,12 @@
+exec("swigtest.start", -1);
+
+a = [1, 2, 3, 4; 5, 6, 7, 8;]
+
+//try
+// array_d_set(a);
+//catch
+// swigtesterror();
+//end
+//if array_d_get() <> a then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/bools_runme.sci b/Examples/test-suite/scilab/bools_runme.sci
new file mode 100644
index 000000000..9516a5df5
--- /dev/null
+++ b/Examples/test-suite/scilab/bools_runme.sci
@@ -0,0 +1,20 @@
+exec("swigtest.start", -1);
+
+function checkBool(bool_val, expected_bool_val)
+ if typeof(bool_val) <> "boolean" then swigtesterror(); end
+ if bool_val <> expected_bool_val then swigtesterror(); end
+endfunction
+
+checkBool(constbool_get(), %f);
+
+checkBool(bool1_get(), %t);
+checkBool(bool2_get(), %f);
+
+checkBool(bo(%t), %t);
+checkBool(bo(%f), %f);
+
+bs = new_BoolSt();
+checkBool(BoolSt_m_bool1_get(bs), %t);
+checkBool(BoolSt_m_bool2_get(bs), %f);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/char_constant_runme.sci b/Examples/test-suite/scilab/char_constant_runme.sci
new file mode 100644
index 000000000..e48e3068d
--- /dev/null
+++ b/Examples/test-suite/scilab/char_constant_runme.sci
@@ -0,0 +1,9 @@
+exec("swigtest.start", -1);
+
+if CHAR_CONSTANT_get() <> "x" then swigtesterror(); end
+if STRING_CONSTANT_get() <> "xyzzy" then swigtesterror(); end
+if ESC_CONST_get() <> ascii(1) then swigtesterror(); end
+if ia_get() <> ascii('a') then swigtesterror(); end
+if ib_get() <> ascii('b') then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/constover_runme.sci b/Examples/test-suite/scilab/constover_runme.sci
new file mode 100644
index 000000000..5b8935f68
--- /dev/null
+++ b/Examples/test-suite/scilab/constover_runme.sci
@@ -0,0 +1,22 @@
+exec("swigtest.start", -1);
+
+p = test("test");
+if strcmp(p, "test") <> 0 then swigtesterror(); end
+
+p = test_pconst("test");
+if strcmp(p, "test_pconst") <> 0 then swigtesterror(); end
+
+f = new_Foo();
+p = Foo_test(f, "test");
+if strcmp(p,"test") <> 0 then swigtesterror(); end
+
+p = Foo_test_pconst(f, "test");
+if strcmp(p,"test_pconst") <> 0 then swigtesterror(); end
+
+p = Foo_test_constm(f, "test");
+if strcmp(p,"test_constmethod") <> 0 then swigtesterror(); end
+
+p = Foo_test_pconstm(f, "test");
+if strcmp(p,"test_pconstmethod") <> 0 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/constructor_copy_runme.sci b/Examples/test-suite/scilab/constructor_copy_runme.sci
new file mode 100644
index 000000000..bfd2b1c20
--- /dev/null
+++ b/Examples/test-suite/scilab/constructor_copy_runme.sci
@@ -0,0 +1,36 @@
+exec("swigtest.start", -1);
+
+
+f1 = new_Foo1(3);
+f11 = new_Foo1(f1);
+
+checkequal(Foo1_x_get(f1), Foo1_x_get(f11), "Foo1_x_get(f1) <> Foo1_x_get(f11)");
+
+delete_Foo1(f1);
+delete_Foo1(f11);
+
+f8 = new_Foo8();
+try
+ f81 = new_Foo8(f8);
+ swigtesterror("Foo(f8) called.");
+catch
+end
+
+bi = new_Bari(5);
+bc = new_Bari(bi);
+
+checkequal(Bari_x_get(bi), Bari_x_get(bc), "Bar_x_get(bi) <> Bar_x_get(bc)");
+
+delete_Bari(bi);
+delete_Bari(bc);
+
+bd = new_Bard(5);
+try
+ bc = Bard(bd);
+ swigtesterror("Bard(bd) called.");
+catch
+end
+
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/cpp_basic_runme.sci b/Examples/test-suite/scilab/cpp_basic_runme.sci
new file mode 100644
index 000000000..6b64de4db
--- /dev/null
+++ b/Examples/test-suite/scilab/cpp_basic_runme.sci
@@ -0,0 +1,64 @@
+exec("swigtest.start", -1);
+
+f = new_Foo(4);
+checkequal(Foo_num_get(f), 4, "Foo_num_get(f)");
+Foo_num_set(f, -17);
+checkequal(Foo_num_get(f), -17, "Foo_num_get(f)");
+
+b = new_Bar();
+Bar_fptr_set(b, f);
+
+fptr = Bar_fptr_get(b);
+checkequal(Foo_num_get(fptr), -17, "Foo_num_get(ftr)");
+
+checkequal(Bar_test(b, -3, fptr), -5, "Bar_test(b, -3, fptr)");
+
+fref = Bar_fref_get(b);
+checkequal(Foo_num_get(fref), -4, "Foo_num_get(fref)");
+
+checkequal(Bar_test(b, 12, fref), 23, "Bar_test(b, 12, fref)");
+
+f2 = new_Foo(23);
+Bar_fref_set(b, f2);
+
+fref = Bar_fref_get(b);
+checkequal(Foo_num_get(fref), 23, "Foo_num_get(fref)");
+
+fval = Bar_fval_get(b);
+checkequal(Bar_test(b, 3, fval), 33, "Bar_test(b, 3, fval)");
+
+Bar_fval_set(b, new_Foo(-15));
+
+fval = Bar_fval_get(b);
+checkequal(Foo_num_get(fval), -15, "Foo_num_get(fval)");
+checkequal(Bar_test(b, 3, fval), -27, "Bar_test(b, 3, fval)");
+
+f3 = Bar_testFoo(b, 12, fref);
+checkequal(Foo_num_get(f3), 32, "Foo_num_get(f3)");
+
+
+// Test globals
+f4 = new_Foo(6);
+Bar_global_fptr_set(f4);
+checkequal(Foo_num_get(Bar_global_fptr_get()), 6, "Foo_num_get(Bar_global_fptr_get())");
+
+checkequal(Foo_num_get(Bar_global_fref_get()), 23, "Foo_num_get(Bar_global_fref_get())");
+
+checkequal(Foo_num_get(Bar_global_fval_get()), 3, "Foo_num_get(Bar_global_fval_get())");
+
+
+// Test member function pointers
+func1_ptr = get_func1_ptr();
+func2_ptr = get_func2_ptr();
+
+Foo_num_set(f, 4);
+checkequal(Foo_func1(f, 2), 16, "Foo_func1(f, 2)");
+checkequal(Foo_func2(f, 2), -8, "Foo_func2(f, 2)");
+
+Foo_func_ptr_set(f, func1_ptr);
+checkequal(test_func_ptr(f, 2), 16, "Foo_test_func_ptr(f, 2)");
+
+Foo_func_ptr_set(f, func2_ptr);
+checkequal(test_func_ptr(f, 2), -8, "Foo_test_func_ptr(f, 2)");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/cpp_enum_runme.sci b/Examples/test-suite/scilab/cpp_enum_runme.sci
new file mode 100644
index 000000000..d684affe9
--- /dev/null
+++ b/Examples/test-suite/scilab/cpp_enum_runme.sci
@@ -0,0 +1,10 @@
+exec("swigtest.start", -1);
+
+f = new_Foo();
+
+if Foo_hola_get(f) <> Hello_get() then swigtesterror("Foo_hola_get() <> ""Hello"""); end
+
+Foo_hola_set(f, Hi_get());
+if Foo_hola_get(f) <> Hi_get() then swigtesterror("Foo_hola_get() <> ""Hi"""); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/default_args_runme.sci b/Examples/test-suite/scilab/default_args_runme.sci
new file mode 100644
index 000000000..15754fdfd
--- /dev/null
+++ b/Examples/test-suite/scilab/default_args_runme.sci
@@ -0,0 +1,67 @@
+exec("swigtest.start", -1);
+
+checkequal(anonymous(), 7771, "anonymous()");
+checkequal(anonymous(1234), 1234, "anonymous(1234)");
+
+checkequal(booltest(), %T, "booltest()");
+checkequal(booltest(%T), %T, "booltest(%T)");
+checkequal(booltest(%F), %F, "booltest(%T)");
+
+ec = new_EnumClass();
+checkequal(EnumClass_blah(ec), %T, "EnumClass_blah(ec)");
+
+checkequal(casts1(), [], "casts1()");
+checkequal(casts1("Ciao"), "Ciao", "casts1(""Ciao"")");
+checkequal(casts2(), "Hello", "casts2()");
+checkequal(chartest1(), 'x', "chartest1()");
+checkequal(chartest2(), '', "chartest2()");
+checkequal(chartest1('y'), 'y', "chartest1(''y'')");
+checkequal(reftest1(), 42, "reftest1()");
+checkequal(reftest1(400), 400, "reftest1(400)");
+checkequal(reftest2(), "hello", "reftest2()");
+
+// Rename
+f = new_Foo();
+Foo_newname(f);
+Foo_newname(f, 10);
+Foo_renamed3arg(f, 10, 10.0);
+Foo_renamed2arg(f, 10);
+Foo_renamed1arg(f);
+delete_Foo(f);
+
+// Static functions
+checkequal(Statics_staticmethod(), 10+20+30, "Statics_staticmethod()");
+checkequal(Statics_staticmethod(100), 100+20+30, "Statics_staticmethod(100)");
+checkequal(Statics_staticmethod(100, 200, 300), 100+200+300, "Statics_staticmethod(100, 200, 300)");
+
+tricky = new_Tricky();
+checkequal(Tricky_privatedefault(tricky), 200, "Tricky_privatedefault(tricky)");
+checkequal(Tricky_protectedint(tricky), 2000, "Tricky_protectedint(tricky)");
+checkequal(Tricky_protecteddouble(tricky), 987.654, "Tricky_protecteddouble(tricky)");
+checkequal(Tricky_functiondefault(tricky), 500, "Tricky_functiondefault(tricky)");
+checkequal(Tricky_contrived(tricky), 'X', "Tricky_contrived(tricky)");
+delete_Tricky(tricky);
+
+// Default argument is a constructor
+k = constructorcall();
+checkequal(Klass_val_get(k), -1, "Klass_constructorcall()");
+delete_Klass(k);
+k = constructorcall(new_Klass(2222));
+checkequal(Klass_val_get(k), 2222, "Klass_constructorcall(new Klass(2222)");
+delete_Klass(k);
+k = constructorcall(new_Klass());
+checkequal(Klass_val_get(k), -1, "Klass_constructorcall(new_Klass()");
+delete_Klass(k);
+
+// Const methods
+cm = new_ConstMethods();
+checkequal(ConstMethods_coo(cm), 20, "ConstMethods_coo()");
+checkequal(ConstMethods_coo(cm, 1.0), 20, "ConstMethods_coo(1.0)");
+
+// C linkage (extern "C")
+checkequal(cfunc1(1), 2, "cfunc1(1)");
+checkequal(cfunc2(1), 3, "cfunc2(1)");
+checkequal(cfunc3(1), 4, "cfunc3(1)");
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/default_constructor_runme.sci b/Examples/test-suite/scilab/default_constructor_runme.sci
new file mode 100644
index 000000000..6c5250bec
--- /dev/null
+++ b/Examples/test-suite/scilab/default_constructor_runme.sci
@@ -0,0 +1,113 @@
+exec("swigtest.start", -1);
+
+a = new_A();
+delete_A(a);
+
+aa = new_AA();
+delete_AA(aa);
+
+try
+ b = new_B();
+ swigtestswigtesterror("new_BB created.")
+catch
+end
+
+del_b = delete_B;
+
+try
+ bb = new_BB();
+ swigtesterror("new_BB created.")
+catch
+
+end
+
+del_bb = delete_BB;
+
+try
+ c = new_C();
+ swigtesterror("new_C created.")
+catch
+end
+
+del_c = delete_C;
+
+cc = new_CC();
+delete_CC(cc);
+
+try
+ d = new_D();
+ swigtesterror("new_D created")
+catch
+end
+
+del_d = delete_D;
+
+try
+ dd = new_DD();
+ swigtesterror("new_DD created")
+catch
+end
+
+dd = delete_DD;
+
+try
+ ad = new_AD();
+ swigtesterror("new_AD created")
+catch
+end
+
+del_ad = delete_AD;
+
+exec("swigtest.start", -1);
+
+e = new_E();
+delete_E(e);
+
+ee = new_EE();
+delete_EE(ee);
+
+try
+ eb = new_EB();
+ swigtesterror("new_EB created")
+catch
+end
+
+del_eb = delete_EB;
+
+f = new_F();
+
+try
+ del_f = delete_F;
+ swigtesterror("delete_F created")
+catch
+end
+
+F_destroy(f);
+
+ff = new_FFF();
+try
+ del_ff = delete_FFF;
+ swigtesterror("delete_FFF created")
+catch
+end
+
+F_destroy(ff);
+
+g = new_G();
+
+try
+ del_g = delete_G;
+ swigtesterror("delete_G created")
+catch
+end
+
+G_destroy(g);
+
+gg = new_GG();
+delete_GG(gg);
+
+hh = new_HH(1,1);
+
+exec("swigtest.quit", -1);
+
+
diff --git a/Examples/test-suite/scilab/empty_runme.sci b/Examples/test-suite/scilab/empty_runme.sci
new file mode 100644
index 000000000..48db2d52b
--- /dev/null
+++ b/Examples/test-suite/scilab/empty_runme.sci
@@ -0,0 +1,3 @@
+exec("swigtest.start", -1);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/enums_runme.sci b/Examples/test-suite/scilab/enums_runme.sci
new file mode 100644
index 000000000..7320d7867
--- /dev/null
+++ b/Examples/test-suite/scilab/enums_runme.sci
@@ -0,0 +1,39 @@
+exec("swigtest.start", -1);
+
+if typeof(CSP_ITERATION_FWD_get()) <> "constant" then swigtesterror(); end
+if typeof(CSP_ITERATION_BWD_get()) <> "constant" then swigtesterror(); end
+if typeof(ABCDE_get()) <> "constant" then swigtesterror(); end
+if typeof(FGHJI_get()) <> "constant" then swigtesterror(); end
+
+try
+ bar1(CSP_ITERATION_FWD_get())
+ bar1(CSP_ITERATION_BWD_get())
+ bar1(1)
+ bar1(int32(1))
+
+ bar2(ABCDE_get())
+ bar2(FGHJI_get())
+ bar2(1)
+ bar2(int32(1))
+
+ bar3(ABCDE_get())
+ bar3(FGHJI_get())
+ bar3(1)
+ bar3(int32(1))
+catch
+ swigtesterror()
+end
+
+if typeof(enumInstance_get()) <> "constant" then swigtesterror(); end
+if enumInstance_get() <> 2 then swigtesterror(); end
+
+if typeof(Slap_get()) <> "constant" then swigtesterror(); end
+if Slap_get() <> 10 then swigtesterror(); end
+
+if typeof(Mine_get()) <> "constant" then swigtesterror(); end
+if Mine_get() <> 11 then swigtesterror(); end
+
+if typeof(Thigh_get()) <> "constant" then swigtesterror(); end
+if Thigh_get() <> 12 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/funcptr_cpp_runme.sci b/Examples/test-suite/scilab/funcptr_cpp_runme.sci
new file mode 100644
index 000000000..cb4c3cd0d
--- /dev/null
+++ b/Examples/test-suite/scilab/funcptr_cpp_runme.sci
@@ -0,0 +1,7 @@
+exec("swigtest.start", -1);
+
+checkequal(call1(ADD_BY_VALUE_get(), 10, 11), 21, "ADD_BY_VALUE");
+checkequal(call2(ADD_BY_POINTER_get(), 12, 13), 25, "ADD_BY_POINTER");
+checkequal(call3(ADD_BY_REFERENCE_get(), 14, 15), 29, "ADD_BY_REFERENCE");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/funcptr_runme.sci b/Examples/test-suite/scilab/funcptr_runme.sci
new file mode 100644
index 000000000..430d15349
--- /dev/null
+++ b/Examples/test-suite/scilab/funcptr_runme.sci
@@ -0,0 +1,6 @@
+exec("swigtest.start", -1);
+
+if add(7, 9) <> 16 then swigtesterror(); end
+if do_op(7, 9, funcvar_get()) <> 16 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/global_vars_runme.sci b/Examples/test-suite/scilab/global_vars_runme.sci
new file mode 100644
index 000000000..721eaf614
--- /dev/null
+++ b/Examples/test-suite/scilab/global_vars_runme.sci
@@ -0,0 +1,31 @@
+exec("swigtest.start", -1);
+
+b_set("hello");
+checkequal(b_get(), "hello", "b_get()");
+
+sa = new_A();
+A_x_set(sa, 5);
+checkequal(A_x_get(sa), 5, "A_x_get(sa)");
+
+a_set(sa);
+checkequal(A_x_get(a_get()), 5, "A_x_get(a)");
+
+ap_set(sa);
+A_x_set(sa, 14);
+checkequal(A_x_get(ap_get()), 14, "A_x_get(ap)");
+delete_A(sa);
+
+sa2 = new_A();
+cap_set(sa2);
+A_x_set(sa2, 16);
+checkequal(A_x_get(cap_get()), 16, "A_x_get(cap)");
+
+checkequal(A_x_get(ar_get()), 5, "A_x_get(ar)");
+ar_set(sa2);
+checkequal(A_x_get(ar_get()), 16, "A_x_get(ar)");
+delete_A(sa2);
+
+x_set(11);
+checkequal(x_get(), 11, "x_get()");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/inctest_runme.sci b/Examples/test-suite/scilab/inctest_runme.sci
new file mode 100644
index 000000000..5a8df7b8f
--- /dev/null
+++ b/Examples/test-suite/scilab/inctest_runme.sci
@@ -0,0 +1,20 @@
+exec("swigtest.start", -1);
+
+try
+ a = new_A();
+catch
+ printf("did not find A\ntherefore, I did not include ""testdir/subdir1/hello.i""\n");
+ swigtesterror();
+end
+
+try
+ b = new_B();
+catch
+ printf("did not find B\ntherefore, I did not include ""testdir/subdir2/hello.i""\n");
+ swigtesterror();
+end
+
+if importtest1(5) <> 15 then swigtesterror(); end
+if importtest2("black") <> "white" then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/inherit_missing_runme.sci b/Examples/test-suite/scilab/inherit_missing_runme.sci
new file mode 100644
index 000000000..d68ab7e1f
--- /dev/null
+++ b/Examples/test-suite/scilab/inherit_missing_runme.sci
@@ -0,0 +1,15 @@
+exec("swigtest.start", -1);
+
+a = new_Foo();
+b = new_Bar();
+c = new_Spam();
+
+checkequal(do_blah(a), "Foo::blah", "do_blah(a)");
+checkequal(do_blah(b), "Bar::blah", "do_blah(b)");
+checkequal(do_blah(c), "Spam::blah", "do_blah(c)");
+
+delete_Foo(a);
+delete_Bar(b);
+delete_Spam(c);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/inout_runme.sci b/Examples/test-suite/scilab/inout_runme.sci
new file mode 100644
index 000000000..6c25a6deb
--- /dev/null
+++ b/Examples/test-suite/scilab/inout_runme.sci
@@ -0,0 +1,15 @@
+exec("swigtest.start", -1);
+
+a = AddOne1(10);
+if a <> 11 then swigtesterror(); end
+
+[a, b, c] = AddOne3(1, 2, 3);
+if a <> 2 then swigtesterror(); end
+if b <> 3 then swigtesterror(); end
+if c <> 4 then swigtesterror(); end
+
+a = AddOne1r(20);
+if a <> 21 then swigtesterror(); end
+
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/integers_runme.sci b/Examples/test-suite/scilab/integers_runme.sci
new file mode 100644
index 000000000..1a59578d8
--- /dev/null
+++ b/Examples/test-suite/scilab/integers_runme.sci
@@ -0,0 +1,29 @@
+exec("swigtest.start", -1);
+
+// Negative values
+checkequal(signed_char_identity(-1), -1, "signed_char_identity(-1)");
+checkequal(signed_short_identity(-1), -1, "signed_short_identity(-1)");
+checkequal(signed_int_identity(-1), -1, "signed_int_identity(-1)");
+checkequal(signed_long_identity(-1), -1, "signed_long_identity(-1)");
+
+// Overflow errors
+ierr = execstr('signed_char_identity(2^8)', 'errcatch');
+checkequal(ierr, 20007, 'signed_char_identity(2^8)');
+ierr = execstr('signed_short_identity(2^16)', 'errcatch');
+checkequal(ierr, 20007, 'signed_short_identity(2^16)');
+ierr = execstr('signed_int_identity(2^32)', 'errcatch');
+checkequal(ierr, 20007, 'signed_int_identity(2^32)');
+ierr = execstr('signed_long_identity(2^64)', 'errcatch');
+checkequal(ierr, 20007, 'signed_long_identity(2^64)');
+
+// Value errors
+ierr = execstr('signed_char_identity(100.2)', 'errcatch');
+checkequal(ierr, 20009, 'signed_char_identity(100.2)');
+ierr = execstr('signed_short_identity(100.2)', 'errcatch');
+checkequal(ierr, 20009, 'signed_short_identity(100.2)');
+ierr = execstr('signed_int_identity(100.2)', 'errcatch');
+checkequal(ierr, 20009, 'signed_int_identity(100.2)');
+ierr = execstr('signed_long_identity(100.2)', 'errcatch');
+checkequal(ierr, 20009, 'signed_long_identity(100.2)');
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/li_carrays_runme.sci b/Examples/test-suite/scilab/li_carrays_runme.sci
new file mode 100644
index 000000000..0ac157446
--- /dev/null
+++ b/Examples/test-suite/scilab/li_carrays_runme.sci
@@ -0,0 +1,11 @@
+exec("swigtest.start", -1);
+
+d = new_intArray(10);
+
+intArray_setitem(d, 0, 7);
+
+intArray_setitem(d, 5, intArray_getitem(d, 0) + 3);
+
+checkequal(intArray_getitem(d, 5) + intArray_getitem(d, 0), 17, "d(5) + d(0) <> 17");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/li_cpointer_runme.sci b/Examples/test-suite/scilab/li_cpointer_runme.sci
new file mode 100644
index 000000000..0aa4339c8
--- /dev/null
+++ b/Examples/test-suite/scilab/li_cpointer_runme.sci
@@ -0,0 +1,8 @@
+exec("swigtest.start", -1);
+
+p = new_intp();
+intp_assign(p, 3);
+checkequal(intp_value(p), 3, "intp_value(p)");
+delete_intp(p);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/li_math_runme.sci b/Examples/test-suite/scilab/li_math_runme.sci
new file mode 100644
index 000000000..d05f8eb18
--- /dev/null
+++ b/Examples/test-suite/scilab/li_math_runme.sci
@@ -0,0 +1,9 @@
+exec("swigtest.start", -1);
+
+try
+ x = fmod(M_PI_get(), M_1_PI_get())
+catch
+ swigtesterror();
+end
+
+exec("swigtest.quit", -1); \ No newline at end of file
diff --git a/Examples/test-suite/scilab/li_std_container_typemaps_runme.sci b/Examples/test-suite/scilab/li_std_container_typemaps_runme.sci
new file mode 100644
index 000000000..e4832efe6
--- /dev/null
+++ b/Examples/test-suite/scilab/li_std_container_typemaps_runme.sci
@@ -0,0 +1,108 @@
+// test STL containers typemaps
+
+exec("swigtest.start", -1);
+
+function checkerror(ierr, cmd)
+ if ierr <> 0 then swigtesterror("error " + string(ierr) + " in """ + cmd + """"); end
+endfunction
+
+// test container of pointers returned from fonction (expected a list)
+function [classAPtr_list, classAPtr1, classAPtr2] = testCreateContainerPtr(container, value1, value2)
+ classAPtr1 = new_ClassA(value1);
+ classAPtr2 = new_ClassA(value2);
+ func = msprintf("ret_ClassAPtr_%s", container);
+ cmd = msprintf("classAPtr_list = %s(classAPtr1, classAPtr2);", func);
+ ierr = execstr(cmd, "errcatch");
+ if ierr <> 0 then swigtesterror("error in " + cmd); end
+ if ~exists('classAPtr_list') | (size(classAPtr_list) <> 2) then
+ swigtesterror(func);
+ end
+
+ checkequal(ClassA_a_get(classAPtr_list(1)), value1, "ClassA_a_get(classAPtr_list(1))");
+ checkequal(ClassA_a_get(classAPtr_list(2)), value2, "ClassA_a_get(classAPtr_list(2))");
+endfunction
+
+// test a given container of pointer
+// -container: type of container: "vector", "set"...
+// -value1, value2: values to store in container
+// -expected_accumulate_value: expected value of an accumulation function
+// computed on the container
+function testContainerPtr(container, value1, value2, expected_accumulate_value)
+ // test container of pointers returned from flonction (expected a list)
+ [classAPtr_list, classAPtr1, classAPtr2] = testCreateContainerPtr(container, value1, value2);
+
+ // test container passed as value of function
+ func = msprintf("val_ClassAPtr_%s", container);
+ cmd = msprintf("classAPtr = %s(classAPtr_list);", func);
+ ierr = execstr(cmd, "errcatch");
+ checkerror(ierr, cmd);
+ checkequal(ClassA_a_get(classAPtr), expected_accumulate_value, func);
+
+ // recreate a container
+ [classAPtr_list, classAPtr1, classAPtr2] = testCreateContainerPtr(container, value1, value2);
+
+ // test container passed as reference of function
+ func = msprintf("ref_ClassAPtr_%s", container);
+ cmd = msprintf("classAPtr = %s(classAPtr_list);", func);
+ ierr = execstr(cmd, "errcatch");
+ checkerror(ierr, cmd);
+ checkequal(ClassA_a_get(classAPtr), expected_accumulate_value, func);
+endfunction
+
+// test a given container of a given primitive type
+// -container: type of container: "vector", "set"...
+// -value_type: type of element stored in container: "int", ...
+// -value1, value2: values to store in container
+// -expected_accumulate_value: expected value of an accumulation function
+// computed on the container
+function testContainerType(container, value_type, value1, value2, ..
+ expected_returned_container, expected_accumulate_value)
+ // test container of basic type returned from fonction
+ func = msprintf("ret_%s_%s", value_type, container);
+ if value_type == "string" then
+ cmd = msprintf("c = %s(''%s'', ''%s'');", func, value1, value2);
+ elseif value_type == "bool" then
+ cmd = msprintf("c = %s(%s, %s);", func, "%"+string(value1), "%"+string(value2));
+ else
+ cmd = msprintf("c = %s(%d, %d);", func, value1, value2);
+ end
+ ierr = execstr(cmd, "errcatch");
+ checkerror(ierr, cmd);
+ checkequal(c, expected_returned_container, func);
+
+ // test container passed as value of function
+ func = msprintf("val_%s_%s", value_type, container);
+ cmd = msprintf("s = %s(c);", func);
+ ierr = execstr(cmd, "errcatch");
+ checkerror(ierr, cmd);
+ checkequal(s, expected_accumulate_value, func);
+
+ // test container passed as reference of function
+ func = msprintf("ref_%s_%s", value_type, container);
+ cmd = msprintf("s = %s(c);", func);
+ ierr = execstr(cmd, "errcatch");
+ checkerror(ierr, cmd);
+ checkequal(s, expected_accumulate_value, func);
+endfunction
+
+// test a given container of different types
+// -container: type of container: "vector", "set"...
+function testContainer(container)
+ testContainerType(container, "int", 1, 2, [1, 2], 3);
+ testContainerType(container, "double", 2., 3., [2., 3.], 5.);
+ testContainerType(container, "float", 2., 3., [2., 3.], 5.);
+ testContainerType(container, "string", "a", "b", ["a", "b"], "ab");
+ testContainerType(container, "bool", %F, %T, [%F, %T], %T);
+ testContainerPtr("vector", 1, 3, 4);
+endfunction
+
+
+testContainer("vector");
+testContainer("list");
+testContainer("deque");
+testContainer("set");
+testContainer("multiset");
+
+exec("swigtest.quit", -1);
+
+
diff --git a/Examples/test-suite/scilab/li_std_deque_runme.sci b/Examples/test-suite/scilab/li_std_deque_runme.sci
new file mode 100644
index 000000000..c0680846b
--- /dev/null
+++ b/Examples/test-suite/scilab/li_std_deque_runme.sci
@@ -0,0 +1,49 @@
+exec("swigtest.start", -1);
+
+// Test constructors for std::deque<int>
+intDeque = new_IntDeque();
+intDeque2 = new_IntDeque(3);
+intDeque3 = new_IntDeque(4, 42);
+//intDeque4 = new_IntDeque(intDeque3);
+
+// Test constructors for std::deque<double>
+doubleDeque = new_DoubleDeque();
+doubleDeque2 = new_DoubleDeque(3);
+doubleDeque3 = new_DoubleDeque(4, 42.0);
+//doubleDeque4 = new_DoubleDeque(doubleDeque3);
+
+// Test constructors for std::deque<Real>
+realDeque = new_RealDeque();
+realDeque2 = new_RealDeque(3);
+realDeque3 = new_RealDeque(4, 42.0);
+//realDeque4 = new_RealDeque(realDeque3);
+
+// average() should return the average of all values in a std::deque<int>
+IntDeque_push_back(intDeque, 2);
+IntDeque_push_back(intDeque, 4);
+IntDeque_push_back(intDeque, 6);
+avg = average(intDeque);
+checkequal(avg, 4.0, "average(intDeque)");
+
+// half shoud return a deque with elements half of the input elements
+RealDeque_clear(realDeque);
+RealDeque_push_front(realDeque, 2.0);
+RealDeque_push_front(realDeque, 4.0);
+halfDeque = half(realDeque);
+checkequal(halfDeque, [2., 1.], "half(realDeque)");
+
+// same for halve_in_place
+//DoubleDeque_clear(doubleDeque);
+//DoubleDeque_push_front(doubleDeque, 2.0);
+//DoubleDeque_push_front(doubleDeque, 4.0);
+//halfDeque2 = halve_in_place(doubleDeque);
+//checkequal(halfDeque2, [2., 1.], "halve_in_place(doubleDeque)");
+
+delete_IntDeque(intDeque);
+delete_DoubleDeque(doubleDeque);
+delete_RealDeque(realDeque);
+
+exec("swigtest.quit", -1);
+
+
+
diff --git a/Examples/test-suite/scilab/li_std_except_runme.sci b/Examples/test-suite/scilab/li_std_except_runme.sci
new file mode 100644
index 000000000..3b6522f45
--- /dev/null
+++ b/Examples/test-suite/scilab/li_std_except_runme.sci
@@ -0,0 +1,33 @@
+exec('swigtest.start', -1);
+
+function checkException(cmd, expected_ierr, expected_error_msg)
+ ierr = execstr(cmd, 'errcatch');
+ checkequal(ierr, expected_ierr, cmd + ': ierr');
+ checkequal(lasterror(), 'SWIG/Scilab: ' + expected_error_msg, cmd + ': msg');
+endfunction
+
+t = new_Test();
+
+checkException('Test_throw_bad_exception(t)', 20010, 'SystemError: std::bad_exception');
+
+checkException('Test_throw_domain_error(t)', 20009, 'ValueError: oops');
+
+checkException('Test_throw_exception(t)', 20010, 'SystemError: std::exception');
+
+checkException('Test_throw_invalid_argum(t)', 20009, 'ValueError: oops');
+
+checkException('Test_throw_length_error(t)', 20004, 'IndexError: oops');
+
+checkException('Test_throw_logic_error(t)', 20003, 'RuntimeError: oops');
+
+checkException('Test_throw_out_of_range(t)', 20004, 'IndexError: oops');
+
+checkException('Test_throw_overflow_erro(t)', 20007, 'OverflowError: oops');
+
+checkException('Test_throw_range_error(t)', 20007, 'OverflowError: oops');
+
+checkException('Test_throw_runtime_error(t)', 20003, 'RuntimeError: oops');
+
+delete_Test(t);
+
+exec('swigtest.quit', -1);
diff --git a/Examples/test-suite/scilab/li_std_pair_runme.sci b/Examples/test-suite/scilab/li_std_pair_runme.sci
new file mode 100644
index 000000000..e5f5607ee
--- /dev/null
+++ b/Examples/test-suite/scilab/li_std_pair_runme.sci
@@ -0,0 +1,38 @@
+exec("swigtest.start", -1);
+
+function checkPair(pair, expected_first, expected_second, func)
+ checkequal(IntPair_first_get(pair), expected_first, func + ": first");;
+ checkequal(IntPair_second_get(pair), expected_second, func + ": second");;
+endfunction
+
+intPair = makeIntPair(7, 6);
+checkPair(intPair, 7, 6, "makeIntPair()");
+
+intPairPtr = makeIntPairPtr(7, 6);
+checkPair(intPairPtr, 7, 6, "makeIntPairPtr()");
+
+intPairRef = makeIntPairRef(7, 6);
+checkPair(intPairRef, 7, 6, "makeIntPairRef()");
+
+intPairConstRef = makeIntPairConstRef(7, 6);
+checkPair(intPairConstRef, 7, 6, "makeIntPairConstRef()");
+
+// call fns
+checkequal(product1(intPair), 42, "product1(intPair)");
+checkequal(product2(intPair), 42, "product2(intPair)");
+checkequal(product3(intPair), 42, "product3(intPair)")
+
+// also use the pointer version
+checkequal(product1(intPairPtr), 42, "product1(intPairPtr)");
+checkequal(product2(intPairPtr), 42, "product2(intPairPtr)");
+checkequal(product3(intPairPtr), 42, "product3(intPairPtr)");
+
+// or the other types
+checkequal(product1(intPairRef), 42, "product1(intPairRef)");
+checkequal(product2(intPairRef), 42, "product2(intPairRef)");
+checkequal(product3(intPairRef), 42, "product3(intPairRef)");
+checkequal(product1(intPairConstRef), 42, "product3(intPairConstRef)");
+checkequal(product2(intPairConstRef), 42, "product2(intPairConstRef)");
+checkequal(product3(intPairConstRef), 42, "product1(intPairConstRef)");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/li_std_string_extra_runme.sci b/Examples/test-suite/scilab/li_std_string_extra_runme.sci
new file mode 100644
index 000000000..b96b07e84
--- /dev/null
+++ b/Examples/test-suite/scilab/li_std_string_extra_runme.sci
@@ -0,0 +1,58 @@
+exec("swigtest.start", -1);
+
+x = "hello";
+
+// li_std_string tests
+
+// Function tests
+
+checkequal(test_ccvalue(x), x, "test_ccvalue()");
+checkequal(test_cvalue(x), x, "test_cvalue(x)");
+checkequal(test_value(x), x, "test_value()");
+
+checkequal(test_const_reference(x), x, "test_const_reference(x)");
+checkequal(test_reference_input(x), x, "test_reference_input(x)");
+checkequal(test_reference_inout(x), x+x, "test_reference_inout(x)");
+
+//checkequal(test_reference_out(), "test_reference_out message", "test_reference_out()");
+//checkequal(test_const_pointer_out(), "x", "test_const_pointer_out()");
+
+s = "initial string";
+
+// Global variable tests
+
+checkequal(GlobalString2_get(), "global string 2", "GlobalString2_get()");
+GlobalString2_set(s);
+checkequal(GlobalString2_get(), s, "GlobalString2_get()");
+
+checkequal(ConstGlobalString_get(), "const global string", "ConstGlobalString_get()");
+
+// Member variable tests
+
+myStructure = new_Structure();
+checkequal(Structure_Str2_get(myStructure), "member string 2", "Structure_Str2_get(myStructure)");
+
+Structure_Str2_set(myStructure, s);
+checkequal(Structure_Str2_get(myStructure), s, "Structure_Str2_get(myStructure)");
+
+checkequal(Structure_ConstStr_get(myStructure), "const member string", "Structure_ConstStr_get(myStructure)");
+
+checkequal(Structure_StaticStr2_get(), "static member string 2", "Structure_StaticStr2_get()");
+
+Structure_StaticStr2_set(s);
+checkequal(Structure_StaticStr2_get(), s, "Structure_StaticStr2_get()");
+
+checkequal(Structure_ConstStati_get(), "const static member string", "Structure_ConstStaticStr_get()");
+
+
+checkequal(stdstring_empty(), "", "stdstring_empty()");
+checkequal(c_empty(), "", "c_empty()");
+
+
+// li_std_string_extra tests
+
+//checkequal(test_value_basic1(x), x, "");
+//checkequal(test_value_basic2(x), x, "");
+//checkequal(test_value_basic3(x), x, "");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/li_std_vector_runme.sci b/Examples/test-suite/scilab/li_std_vector_runme.sci
new file mode 100644
index 000000000..4f21edd18
--- /dev/null
+++ b/Examples/test-suite/scilab/li_std_vector_runme.sci
@@ -0,0 +1,12 @@
+exec("swigtest.start", -1);
+
+// TODO: support for STL vectors operator =
+iv = new_DoubleVector();
+//for i=1:4
+// iv(i) = i;
+//end
+//x = average(iv);
+
+//if x <> 2.5 then swigtesterror(); end
+exit
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/li_typemaps_runme.sci b/Examples/test-suite/scilab/li_typemaps_runme.sci
new file mode 100644
index 000000000..d9ea0218f
--- /dev/null
+++ b/Examples/test-suite/scilab/li_typemaps_runme.sci
@@ -0,0 +1,116 @@
+exec("swigtest.start", -1);
+
+
+// double
+checkequal(in_double(22.22), 22.22, "in_double");
+checkequal(inr_double(22.22), 22.22, "inr_double");
+checkequal(out_double(22.22), 22.22, "out_double");
+checkequal(outr_double(22.22), 22.22, "outr_double");
+checkequal(inout_double(22.22), 22.22, "inout_double");
+checkequal(inoutr_double(22.22), 22.22, "inoutr_double");
+
+// signed char
+checkequal(in_schar(22), 22, "in_schar");
+checkequal(inr_schar(22), 22, "inr_schar");
+checkequal(out_schar(22), 22, "out_schar");
+checkequal(outr_schar(22), 22, "outr_schar");
+checkequal(inout_schar(22), 22, "inout_schar");
+checkequal(inoutr_schar(22), 22, "inoutr_schar");
+
+// unsigned char
+checkequal(in_uchar(uint8(22)), 22, "in_uchar");
+checkequal(inr_uchar(uint8(22)), 22, "inr_uchar");
+checkequal(out_uchar(uint8(22)), 22, "out_uchar");
+checkequal(outr_uchar(uint8(22)), 22, "outr_uchar");
+checkequal(inout_uchar(uint8(22)), 22, "inout_uchar");
+checkequal(inoutr_uchar(uint8(22)), 22, "inoutr_uchar");
+
+// short
+checkequal(in_short(22), 22, "in_short");
+checkequal(inr_short(22), 22, "inr_short");
+checkequal(out_short(22), 22, "out_short");
+checkequal(outr_short(22), 22, "outr_short");
+checkequal(inout_short(22), 22, "inout_short");
+checkequal(inoutr_short(22), 22, "inoutr_short");
+
+// unsigned short
+checkequal(in_ushort(uint16(22)), 22, "in_ushort");
+checkequal(inr_ushort(uint16(22)), 22, "in_ushort");
+checkequal(out_ushort(uint16(22)), 22, "out_ushort");
+checkequal(outr_ushort(uint16(22)), 22, "outr_ushort");
+checkequal(inout_ushort(uint16(22)), 22, "inout_ushort");
+checkequal(inoutr_ushort(uint16(22)), 22, "inoutr_ushort");
+
+// int
+checkequal(in_int(22), 22, "in_int");
+checkequal(inr_int(22), 22, "inr_int");
+checkequal(out_int(22), 22, "out_int");
+checkequal(outr_int(22), 22, "outr_int");
+checkequal(inout_int(22), 22, "inout_int");
+checkequal(inoutr_int(22), 22, "inoutr_int");
+
+// unsigned int
+checkequal(in_uint(uint32(22)), 22, "in_uint");
+checkequal(inr_uint(uint32(22)), 22, "inr_uint");
+checkequal(out_uint(uint32(22)), 22, "out_uint");
+checkequal(outr_uint(uint32(22)), 22, "outr_uint");
+checkequal(inout_uint(uint32(22)), 22, "inout_uint");
+checkequal(inoutr_uint(uint32(22)), 22, "inoutr_uint");
+
+// long
+checkequal(in_long(22), 22, "in_long");
+checkequal(inr_long(22), 22, "inr_long");
+checkequal(out_long(22), 22, "out_long");
+checkequal(outr_long(22), 22, "outr_long");
+checkequal(inout_long(22), 22, "inout_long");
+checkequal(inoutr_long(22), 22, "inoutr_long");
+
+// unsigned long
+checkequal(in_ulong(uint32(22)), 22, "in_ulong");
+checkequal(inr_ulong(uint32(22)), 22, "inr_ulong");
+checkequal(out_ulong(uint32(22)), 22, "out_ulong");
+checkequal(outr_ulong(uint32(22)), 22, "outr_ulong");
+checkequal(inout_ulong(uint32(22)), 22, "inout_ulong");
+checkequal(inoutr_ulong(uint32(22)), 22, "inoutr_ulong");
+
+// bool
+checkequal(in_bool(%t), %t, "in_bool");
+checkequal(inr_bool(%f), %f, "inr_bool");
+checkequal(out_bool(%t), %t, "out_bool");
+checkequal(outr_bool(%f), %f, "outr_bool");
+checkequal(inout_bool(%t), %t, "inout_bool");
+checkequal(inoutr_bool(%f), %f, "inoutr_bool");
+
+// float
+checkequal(in_float(2.5), 2.5, "in_float");
+checkequal(inr_float(2.5), 2.5, "inr_float");
+checkequal(out_float(2.5), 2.5, "out_float");
+checkequal(outr_float(2.5), 2.5, "outr_float");
+checkequal(inout_float(2.5), 2.5, "inout_float");
+checkequal(inoutr_float(2.5), 2.5, "inoutr_float");
+
+// long long
+// Not supported in Scilab 5.5
+//checkequal(in_longlong(22), 22, "in_longlong");
+//checkequal(inr_longlong(22), 22, "inr_longlong");
+//checkequal(out_longlong(22), 22, "out_longlong");
+//checkequal(outr_longlong(22), 22, "outr_longlong");
+//checkequal(inout_longlong(22), 22, "inout_longlong");
+//checkequal(inoutr_longlong(22), 22, "inoutr_longlong");
+
+// unsigned long long
+// Not supported in Scilab 5.5
+//checkequal(in_ulonglong(uint64(22)), 22, "in_ulonglong");
+//checkequal(inr_ulonglong(uint64(22)), 22, "inr_ulonglong");
+//checkequal(out_ulonglong(uint64(22)), 22, "out_ulonglong");
+//checkequal(outr_ulonglong(uint64(22)), 22, "outr_ulonglong");
+//checkequal(inout_ulonglong(uint64(22)), 22, "inout_ulonglong");
+//checkequal(inoutr_ulonglong(uint64(22)), 22, "inoutr_ulonglong");
+
+// the others
+//a,b = inoutr_int2(1, 2);
+//checkequal(a<>1 || b<>2), "");
+//f,i = out_foo(10)
+//checkequal(f.a, 10 || i, 20), "");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/member_pointer_runme.sci b/Examples/test-suite/scilab/member_pointer_runme.sci
new file mode 100644
index 000000000..5d90f172f
--- /dev/null
+++ b/Examples/test-suite/scilab/member_pointer_runme.sci
@@ -0,0 +1,20 @@
+exec("swigtest.start", -1);
+
+s = new_Square(10);
+
+// Functions
+checkequal(do_op(s, areapt()), 100.0, "Square area");
+checkequal(do_op(s, perimeterpt()), 40.0, "Square perimeter");
+
+// Variables
+checkequal(do_op(s, areavar_get()), 100.0, "Square area");
+areavar_set(perimeterpt());
+checkequal(do_op(s, areavar_get()), 40.0, "Square perimeter");
+
+// Constants
+checkequal(do_op(s, AREAPT_get()), 100.0, "Square area");
+checkequal(do_op(s, PERIMPT_get()), 40.0, "Square perimeter");
+
+delete_Square(s);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/name_runme.sci b/Examples/test-suite/scilab/name_runme.sci
new file mode 100644
index 000000000..dd901df61
--- /dev/null
+++ b/Examples/test-suite/scilab/name_runme.sci
@@ -0,0 +1,11 @@
+exec("swigtest.start", -1);
+
+try
+ foo_2();
+catch
+ swigtesterror();
+end
+if bar_2_get() <> 17 then swigtesterror(); end
+if Baz_2_get() <> 47 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/nested_structs_runme.sci b/Examples/test-suite/scilab/nested_structs_runme.sci
new file mode 100644
index 000000000..1899fe378
--- /dev/null
+++ b/Examples/test-suite/scilab/nested_structs_runme.sci
@@ -0,0 +1,34 @@
+exec("swigtest.start", -1);
+
+try
+ outer = new_Outer();
+ setValues(outer, 10);
+
+ inner1 = Outer_inner1_get(outer);
+ inner2 = Outer_inner2_get(outer);
+ inner3 = Outer_inner3_get(outer);
+ inner4 = Outer_inner4_get(outer);
+catch
+ swigtesterror();
+end
+
+checkequal(Outer_inner1_val_get(inner1), 10, "Outer_inner1_val_get(inner1)");
+checkequal(Outer_inner1_val_get(inner2), 20, "Outer_inner1_val_get(inner2)");
+checkequal(Outer_inner1_val_get(inner3), 20, "Outer_inner1_val_get(inner3)");
+checkequal(Outer_inner1_val_get(inner4), 40, "Outer_inner1_val_get(inner4)");
+
+try
+ inside1 = Outer_inside1_get(outer);
+ inside2 = Outer_inside2_get(outer);
+ inside3 = Outer_inside3_get(outer);
+ inside4 = Outer_inside4_get(outer);
+catch
+ swigtesterror();
+end
+
+checkequal(Named_val_get(inside1), 100, "Named_val_get(inside1)");
+checkequal(Named_val_get(inside2), 200, "Named_val_get(inside2)");
+checkequal(Named_val_get(inside3), 200, "Named_val_get(inside3)");
+checkequal(Named_val_get(inside4), 400, "Named_val_get(inside4)");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/newobject2_runme.sci b/Examples/test-suite/scilab/newobject2_runme.sci
new file mode 100644
index 000000000..da1d50cbd
--- /dev/null
+++ b/Examples/test-suite/scilab/newobject2_runme.sci
@@ -0,0 +1,31 @@
+exec("swigtest.start", -1);
+
+try
+ x = makeFoo();
+catch
+ swigtesterror();
+end
+if fooCount() <> 1 then swigtesterror(); end
+
+try
+ y = makeFoo();
+catch
+ swigtesterror();
+end
+if fooCount() <> 2 then swigtesterror(); end
+
+try
+ delete_Foo(x);
+catch
+ swigtesterror();
+end
+if fooCount() <> 1 then swigtesterror(); end
+
+try
+ delete_Foo(y);
+catch
+ swigtesterror();
+end
+if fooCount() <> 0 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/null_pointer_runme.sci b/Examples/test-suite/scilab/null_pointer_runme.sci
new file mode 100644
index 000000000..2c693d259
--- /dev/null
+++ b/Examples/test-suite/scilab/null_pointer_runme.sci
@@ -0,0 +1,7 @@
+exec("swigtest.start", -1);
+
+p = getnull();
+checkequal(SWIG_this(p), 0, "SWIG_this(p)");
+checkequal(func(p), %T, "func(p)");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/operator_overload_runme.sci b/Examples/test-suite/scilab/operator_overload_runme.sci
new file mode 100644
index 000000000..ca41acd75
--- /dev/null
+++ b/Examples/test-suite/scilab/operator_overload_runme.sci
@@ -0,0 +1,82 @@
+exec("swigtest.start", -1);
+
+function checktrue(value, msg)
+ checkequal(value, %T, msg)
+endfunction
+
+a = new_Op();
+b = new_Op(5);
+c = new_Op(b);
+d = new_Op(2);
+dd = new_Op();
+
+// Assignment operator
+Op_Equal(dd, d);
+
+// Comparison operator
+checktrue(Op_NotEqual(a, b), "Op_NotEqual(a, b)");
+checktrue(Op_EqualEqual(b, c), "Op_EqualEqual(b, c)");
+checktrue(Op_NotEqual(a, d), "Op_NotEqual(a, d)");
+checktrue(Op_EqualEqual(d, dd), "Op_EqualEqual(d, dd)");
+
+checktrue(Op_LessThan(a, b), "Op_LessThan(a, b)");
+checktrue(Op_LessThanEqual(a, b), "Op_LessThanEqual(a, b)");
+checktrue(Op_LessThanEqual(b, c), "Op_LessThanEqual(b, c)");
+checktrue(Op_GreaterThanEqual(b, c), "Op_GreaterThanEqual(b, c)");
+checktrue(Op_GreaterThan(b, d), "Op_GreaterThan(b, d)");
+checktrue(Op_GreaterThanEqual(b, d), "Op_GreaterThanEqual(b, d)");
+
+delete_Op(a);
+delete_Op(b);
+delete_Op(c);
+delete_Op(d);
+delete_Op(dd);
+
+f = new_Op(1);
+g = new_Op(1);
+
+expop = new_Op();
+
+op = Op_Plus(f, g);
+Op_i_set(expop, 2);
+checktrue(Op_EqualEqual(op, expop), "Op_Plus(f, g) <> Op(2)");
+delete_Op(op);
+
+op = Op_Minus(f, g);
+Op_i_set(expop, 0);
+checktrue(Op_EqualEqual(op, expop), "Op_Minus(f, g) <> Op(0)");
+delete_Op(op);
+
+op = Op_Multiply(f, g);
+Op_i_set(expop, 1);
+checktrue(Op_EqualEqual(op, expop), "Op_Multiply(f, g) <> Op(1)");
+delete_Op(op);
+
+op = Op_Divide(f, g);
+Op_i_set(expop, 1);
+checktrue(Op_EqualEqual(op, expop), "Op_Divide(f, g) <> Op(1)");
+delete_Op(op);
+
+// Unary operator
+op = Op_PlusPlusPrefix(new_Op(3));
+Op_i_set(expop, 4);
+checktrue(Op_EqualEqual(op, expop), "Op_PlusPlusPrefix(op) <> Op(4)");
+
+// Square bracket operator
+checkequal(Op_IndexIntoConst(op, uint32(0)), 4, "Op_IndexIntoConst(op, 0) <> 4");
+checkequal(Op_IndexIntoConst(op, uint32(1)), 0, "Op_IndexIntoConst(op, 1) <> 0");
+
+// Functor
+i = new_Op(3);
+checkequal(Op_Functor(i), 3, "Op_Functor(i)");
+checkequal(Op_Functor(i, 1), 4, "Op_Functor(i, 1)");
+
+delete_Op(f);
+delete_Op(g);
+
+delete_Op(i);
+
+delete_Op(expop);
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/overload_arrays_runme.sci b/Examples/test-suite/scilab/overload_arrays_runme.sci
new file mode 100644
index 000000000..4d9a8b035
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_arrays_runme.sci
@@ -0,0 +1,46 @@
+exec("swigtest.start", -1);
+
+// Functions
+
+checkequal(foo(int32([1, 2, 3])), "foo:int[SIZE]", "foo(int[SIZE])");
+checkequal(foo([1, 2, 3]), "foo:double[SIZE]", "foo(double[SIZE])");
+checkequal(foo(["1" "2" "3"]), "foo:char *[SIZE]", "foo(char *[SIZE])");
+
+// Class methods
+
+s = new_Spam();
+checkequal(Spam_foo(s, int32([1, 2, 3])), "foo:int[SIZE]", "Spam::foo(int[SIZE])");
+checkequal(Spam_foo(s, [1, 2, 3]), "foo:double[SIZE]", "Spam::foo(double[SIZE])");
+checkequal(Spam_foo(s, ["1" "2" "3"]), "foo:char *[SIZE]", "Spam::foo(char *[SIZE])");
+delete_Spam(s);
+
+// Static class methods
+
+checkequal(Spam_bar(int32([1, 2, 3])), "bar:int[SIZE]", "Spam::bar(int[SIZE])");
+checkequal(Spam_bar([1, 2, 3]), "bar:double[SIZE]", "Spam::bar(double[SIZE])");
+checkequal(Spam_bar("hello"), "bar:char *[SIZE]", "Spam::bar(char *[SIZE])");
+
+// Constructors
+
+s = new_Spam();
+checkequal(Spam_type_get(s), "none", "Spam::Spam()");
+delete_Spam(s);
+
+s = new_Spam(int32([1, 2, 3]));
+checkequal(Spam_type_get(s), "int[SIZE]", "Spam::Spam(int[SIZE])");
+delete_Spam(s);
+
+s = new_Spam([1, 2, 3]);
+checkequal(Spam_type_get(s), "double[SIZE]", "Spam::Spam(double[SIZE])");
+delete_Spam(s);
+
+s = new_Spam(["1" "2" "3"]);
+checkequal(Spam_type_get(s), "char *[SIZE]", "Spam::Spam(char *[SIZE])");
+delete_Spam(s);
+
+
+a = new_ClassA();
+b = ClassA_method1(a, [1 2 3]);
+
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/overload_complicated_runme.sci b/Examples/test-suite/scilab/overload_complicated_runme.sci
new file mode 100644
index 000000000..f1c24717a
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_complicated_runme.sci
@@ -0,0 +1,25 @@
+exec("swigtest.start", -1);
+
+NULL = SWIG_ptr(0);
+p = new_Pop(NULL);
+p = new_Pop(NULL, %T);
+
+checkequal(Pop_hip(p, %T), 701, "Pop_hip(%T)");
+checkequal(Pop_hip(p, NULL), 702, "Pop_hip(NULL)");
+
+checkequal(Pop_hop(p, %T), 801, "Pop_hop(%T)");
+checkequal(Pop_hop(p, NULL), 805, "Pop_hop(NULL)");
+
+checkequal(Pop_pop(p, %T), 901, "Pop_pop(%T)");
+checkequal(Pop_pop(p, NULL), 904, "Pop_pop(NULL)");
+checkequal(Pop_pop(p), 905, "Pop_pop()");
+
+checkequal(Pop_bop(p, NULL), 1001, "Pop_bop(NULL)");
+
+checkequal(Pop_bip(p, NULL), 2002, "Pop_bip(%T)");
+
+checkequal(muzak(%T), 3001, "muzak(%T)");
+checkequal(muzak(NULL), 3002, "muzak(%T)");
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/overload_copy_runme.sci b/Examples/test-suite/scilab/overload_copy_runme.sci
new file mode 100644
index 000000000..6d163ffa7
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_copy_runme.sci
@@ -0,0 +1,10 @@
+exec("swigtest.start", -1);
+
+f = new_Foo();
+g = new_Foo(f);
+
+delete_Foo(f);
+delete_Foo(g);
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/overload_extend_runme.sci b/Examples/test-suite/scilab/overload_extend_runme.sci
new file mode 100644
index 000000000..416477bcb
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_extend_runme.sci
@@ -0,0 +1,13 @@
+exec("swigtest.start", -1);
+
+//try
+// x = new_Foo();
+//catch
+// swigtesterror();
+//end
+//if Foo_test(x) <> 0 then swigtesterror(); end
+//if Foo_test(x, 1) <> 1 then swigtesterror(); end
+//if Foo_test(x, 2, 3) <> 5 then swigtesterror(); end
+//if Foo_test(x, "Hello, swig!") <> 2 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/overload_extendc_runme.sci b/Examples/test-suite/scilab/overload_extendc_runme.sci
new file mode 100644
index 000000000..bf474ddbf
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_extendc_runme.sci
@@ -0,0 +1,15 @@
+exec("swigtest.start", -1);
+
+try
+ x = new_Foo();
+catch
+ swigtesterror();
+end
+if Foo_test(x, 1) <> 1 then swigtesterror(); end
+if Foo_test(x, "Hello swig!") <> 2 then swigtesterror(); end
+if Foo_test(x, 2, 3) <> 3 then swigtesterror(); end
+if Foo_test(x, x) <> 30 then swigtesterror(); end
+if Foo_test(x, x, 4) <> 24 then swigtesterror(); end
+if Foo_test(x, x, 4, 5) <> 9 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/overload_numeric_runme.sci b/Examples/test-suite/scilab/overload_numeric_runme.sci
new file mode 100644
index 000000000..ea79cff61
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_numeric_runme.sci
@@ -0,0 +1,16 @@
+exec("swigtest.start", -1);
+
+nums = new_Nums();
+
+// In overloading in Scilab, double has priority over all other numeric types
+checkequal(Nums_over(nums, 0), "double", "Nums_over(nums, 0)");
+
+// Just checkequal if the following are accepted without exceptions being thrown
+Nums_doublebounce(nums, %inf);
+Nums_doublebounce(nums, -%inf);
+Nums_doublebounce(nums, %nan);
+
+delete_Nums(nums);
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/overload_simple_runme.sci b/Examples/test-suite/scilab/overload_simple_runme.sci
new file mode 100644
index 000000000..23be43db9
--- /dev/null
+++ b/Examples/test-suite/scilab/overload_simple_runme.sci
@@ -0,0 +1,73 @@
+exec("swigtest.start", -1);
+
+// Functions
+
+checkequal(foo(int32(3)), "foo:int", "foo(int)");
+checkequal(foo(3), "foo:double", "foo(double)");
+checkequal(foo("hello"), "foo:char *", "foo(char* )");
+f = new_Foo();
+checkequal(foo(f), "foo:Foo *", "foo(Foo *)");
+//b = new_Bar();
+//checkequal(foo(b), "foo:Bar *", "foo(Bar *)");
+//v = malloc_void(32);
+//checkequal(foo(v), "foo:void *", "foo(void *)");
+
+// Class methods
+
+s = new_Spam();
+checkequal(Spam_foo(s, int32(3)), "foo:int", "Spam::foo(int)");
+checkequal(Spam_foo(s, 3), "foo:double", "Spam::foo(double)");
+checkequal(Spam_foo(s, "hello"), "foo:char *", "Spam::foo(char *)");
+checkequal(Spam_foo(s, f), "foo:Foo *", "Spam::foo(Foo *)");
+//checkequal(Spam_foo(s, b), "foo:Bar *", "Spam::foo(Bar *)");
+//checkequal(Spam_foo(s, v), "foo:void *", "Spam::foo(void *)");
+delete_Spam(s);
+
+// Static class methods
+
+checkequal(Spam_bar(int32(3)), "bar:int", "Spam::bar(int)");
+checkequal(Spam_bar(3.1), "bar:double", "Spam::bar(double)");
+checkequal(Spam_bar("hello"), "bar:char *", "Spam::bar(char *)");
+checkequal(Spam_bar(f), "bar:Foo *", "Spam::bar(Foo *)");
+//checkequal(Spam_bar(b), "bar:Bar *", "Spam::bar(Bar *)");
+//checkequal(Spam_bar(b), "bar:void *", "Spam::bar(void *)");
+
+// Constructors
+
+s = new_Spam();
+checkequal(Spam_type_get(s), "none", "Spam::Spam()");
+delete_Spam(s);
+
+s = new_Spam(int32(3));
+checkequal(Spam_type_get(s), "int", "Spam::Spam(int)");
+delete_Spam(s);
+
+s = new_Spam(3.1);
+checkequal(Spam_type_get(s), "double", "Spam::Spam(double)");
+delete_Spam(s);
+
+s = new_Spam("hello");
+checkequal(Spam_type_get(s), "char *", "Spam::Spam(char *)");
+delete_Spam(s);
+
+s = new_Spam(f);
+checkequal(Spam_type_get(s), "Foo *", "Spam::Spam(Foo *)");
+delete_Spam(s);
+
+//s = new_Spam(b);
+//checkequal(Spam_type_get(s), "Bar *", "Spam::Spam(Bar *)");
+//delete_Spam(s);
+
+//s = new_Spam(v);
+//checkequal(Spam_type_get(s), "void *", "Spam::Spam(void *)");
+//delete_Spam(s);
+
+delete_Foo(f);
+//delete_Bar(b);
+//free_void(v);
+
+a = new_ClassA();
+b = ClassA_method1(a, 1);
+
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/preproc_constants_runme.sci b/Examples/test-suite/scilab/preproc_constants_runme.sci
new file mode 100644
index 000000000..d3d0a4b56
--- /dev/null
+++ b/Examples/test-suite/scilab/preproc_constants_runme.sci
@@ -0,0 +1,30 @@
+exec("swigtest.start", -1);
+
+checkequal(CONST_INT1_get(), 10, "CONST_INT1");
+checkequal(CONST_DOUBLE3_get(), 12.3, "CONST_DOUBLE3");
+checkequal(CONST_BOOL1_get(), %T, "CONST_BOOL1");
+checkequal(CONST_CHAR_get(), 'x', "CONST_CHAR");
+checkequal(CONST_STRING1_get(), "const string", "CONST_STRING1");
+
+// Test global constants can be seen within functions
+function test_global()
+ global CONST_INT1
+ global CONST_DOUBLE3
+ global CONST_BOOL1
+ global CONST_CHAR
+ global CONST_STRING1
+
+ checkequal(CONST_INT1_get(), 10, "CONST_INT1");
+ checkequal(CONST_DOUBLE3_get(), 12.3, "CONST_DOUBLE3");
+ checkequal(CONST_BOOL1_get(), %T, "CONST_BOOL1");
+ checkequal(CONST_CHAR_get(), 'x', "CONST_CHAR");
+ checkequal(CONST_STRING1_get(), "const string", "CONST_STRING1");
+endfunction
+
+test_global();
+
+
+// Test assignement in enums
+checkequal(kValue_get(), 4, "kValue");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/preproc_runme.sci b/Examples/test-suite/scilab/preproc_runme.sci
new file mode 100644
index 000000000..a54815a34
--- /dev/null
+++ b/Examples/test-suite/scilab/preproc_runme.sci
@@ -0,0 +1,8 @@
+exec("swigtest.start", -1);
+
+if endif_get() <> 1 then swigtesterror(); end
+if define_get() <> 1 then swigtesterror(); end
+if defined_get() <> 1 then swigtesterror(); end
+if 2 * one_get() <> two_get() then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/primitive_ref_runme.sci b/Examples/test-suite/scilab/primitive_ref_runme.sci
new file mode 100644
index 000000000..9ff400ea5
--- /dev/null
+++ b/Examples/test-suite/scilab/primitive_ref_runme.sci
@@ -0,0 +1,24 @@
+exec("swigtest.start", -1);
+
+checkequal(ref_int(3), 3, "ref_int() test fails.");
+checkequal(ref_uint(uint32(3)), 3, "ref_uint() test fails.");
+
+checkequal(ref_short(3), 3, "ref_short() test fails.");
+checkequal(ref_ushort(uint16(3)), 3, "ref_ushort() test fails.");
+
+checkequal(ref_long(3), 3, "ref_long() test fails.");
+checkequal(ref_ulong(uint32(3)), 3, "ref_ulong() test fails.");
+
+checkequal(ref_schar(3), 3, "ref_schar() test fails.");
+checkequal(ref_uchar(uint8(3)), 3, "ref_uchar() test fails.");
+
+checkequal(ref_float(3), 3, "ref_float() test fails.");
+checkequal(ref_double(3), 3, "ref_double() test fails.");
+
+checkequal(ref_bool(%T), %T, "ref_bool() test fails.");
+
+checkequal(ref_char('x'), 'x', "ref_char() test fails.");
+
+checkequal(ref_over(0), 0, "ref_over() test fails.");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/primitive_types_runme.sci b/Examples/test-suite/scilab/primitive_types_runme.sci
new file mode 100644
index 000000000..423ee44ae
--- /dev/null
+++ b/Examples/test-suite/scilab/primitive_types_runme.sci
@@ -0,0 +1,57 @@
+exec("swigtest.start", -1);
+
+// Check passing by value
+
+checkequal(val_double(42), 42, "val_double() test fails.");
+checkequal(val_float(42), 42, "val_float() test fails.");
+
+checkequal(val_char('a'), 'a', "val_char() test fails.");
+checkequal(val_schar(42), 42, "val_schar() test fails.");
+checkequal(val_schar(int8(42)), 42, "val_schar() test fails.");
+checkequal(val_uchar(uint8(42)), 42, "val_uchar() test fails.");
+
+checkequal(val_short(42), 42, "val_short() test fails.");
+checkequal(val_short(int16(42)), 42, "val_short() test fails.");
+checkequal(val_ushort(uint16(42)), 42, "val_ushort() test fails.");
+
+checkequal(val_int(42), 42, "val_int() test fails.");
+checkequal(val_int(int32(42)), 42, "val_int() test fails.");
+checkequal(val_uint(uint32(42)), 42, "val_uint() test fails.");
+
+checkequal(val_long(42), 42, "val_long() test fails.");
+checkequal(val_long(int32(42)), 42, "val_long() test fails.");
+checkequal(val_ulong(uint32(42)), 42, "val_long() test fails.");
+
+checkequal(val_bool(%t), %t, "val_bool() test fails.");
+
+// longlong is not supported in Scilab 5.x
+//checkequal(val_llong(42), 42, "val_llong() test fails.");
+//checkequal(val_llong(int64(42)), 42, "val_llong() test fails.");
+//checkequal(val_ullong(uint64(42)), 42, "val_ullong() test fails.");
+
+// Check passing by reference
+checkequal(ref_char('a'), 'a', "ref_char() test fails.");
+checkequal(ref_schar(42), 42, "ref_schar() test fails.");
+checkequal(ref_schar(int8(42)), 42, "ref_schar() test fails.");
+checkequal(ref_uchar(uint8(42)), 42, "ref_uchar() test fails.");
+
+checkequal(ref_short(42), 42, "ref_short() test fails.")
+checkequal(ref_short(int16(42)), 42, "ref_short() test fails.")
+checkequal(ref_ushort(uint16(42)), 42, "ref_ushort() test fails.")
+
+checkequal(ref_int(42), 42, "ref_int() test fails.");
+checkequal(ref_int(int32(42)), 42, "ref_int() test fails.");
+checkequal(ref_uint(uint32(42)), 42, "ref_uint() test fails.");
+
+checkequal(ref_long(42), 42, "ref_long() test fails.");
+checkequal(ref_long(int32(42)), 42, "ref_long() test fails.");
+checkequal(ref_ulong(uint32(42)), 42, "ref_ulong() test fails.");
+
+checkequal(ref_bool(%t), %t, "ref_bool() test fails.");
+
+// long long is not supported in Scilab 5.x
+//checkequal(ref_llong(42), 42, "ref_llong() test fails.");
+//checkequal(ref_llong(int64(42)), 42, "ref_llong() test fails.");
+//checkequal(ref_ullong(uint64(42)), 42, "ref_ullong() test fails.");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/ret_by_value_runme.sci b/Examples/test-suite/scilab/ret_by_value_runme.sci
new file mode 100644
index 000000000..6475c8678
--- /dev/null
+++ b/Examples/test-suite/scilab/ret_by_value_runme.sci
@@ -0,0 +1,28 @@
+exec("swigtest.start", -1);
+
+try
+ a = get_test();
+catch
+ swigtesterror();
+end
+
+// Test default values
+checkequal(test_myInt_get(a), 100, "test_myInt_get() test fails.");
+checkequal(test_myShort_get(a), 200, "test_myShort_get() test fails.");
+
+// Write new values
+try
+ test_myInt_set(a, 42)
+ test_myShort_set(a, 12)
+catch
+ swigtesterror();
+end
+
+// Read new values
+checkequal(test_myInt_get(a), 42, "test_myInt_get() test fails.");
+checkequal(test_myShort_get(a), 12, "test_myShort_get() test fails.");
+
+// Destroy pointer
+delete_test(a);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/return_const_value_runme.sci b/Examples/test-suite/scilab/return_const_value_runme.sci
new file mode 100644
index 000000000..662bf3625
--- /dev/null
+++ b/Examples/test-suite/scilab/return_const_value_runme.sci
@@ -0,0 +1,11 @@
+exec("swigtest.start", -1);
+
+foo_ptr = Foo_ptr_getPtr();
+foo = Foo_ptr___deref__(foo_ptr);
+checkequal(Foo_getVal(foo), 17, "Foo_getVal(p)");
+
+foo_ptr = Foo_ptr_getConstPtr();
+foo = Foo_ptr___deref__(foo_ptr);
+checkequal(Foo_getVal(foo), 17, "Foo_getVal(p)");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/scilab_consts_runme.sci b/Examples/test-suite/scilab/scilab_consts_runme.sci
new file mode 100644
index 000000000..d33b45743
--- /dev/null
+++ b/Examples/test-suite/scilab/scilab_consts_runme.sci
@@ -0,0 +1,35 @@
+exec("swigtest.start", -1);
+
+checkequal(ICONST0_get(), 42, "ICONST0_get()");
+checkequal(FCONST0_get(), 2.1828, "FCONST0_get()");
+checkequal(CCONST0_get(), "x", "CCONST0_get()");
+//checkequal(CCONST0_2_get(), "\n", "CCONST0_2_get()");
+checkequal(SCONST0_get(), "Hello World", "SCONST0_get()");
+checkequal(SCONST0_2_get(), """Hello World""", "SCONST0_2_get()");
+checkequal(EXPR0_get(), 48.5484, "EXPR0_get()");
+checkequal(iconst0_get(), 37, "iconst0_get()");
+checkequal(fconst0_get(), 42.2, "fconst0_get()");
+
+checkequal(UNSIGNED0_get(), hex2dec("5FFF"), "UNSIGNED0_get()");
+checkequal(LONG0_get(), hex2dec("3FFF0000"), "LONG0_get()");
+checkequal(ULONG0_get(), hex2dec("5FF0000"), "ULONG0_get()");
+
+if isdef('BAR0') then swigtesterror("BAR0"); end
+
+checkequal(ICONST1, int32(42), "ICONST1");
+checkequal(FCONST1, 2.1828, "FCONST1");
+checkequal(CCONST1, "x", "CCONST1");
+//checkequal(CCONST1_2, "\n", "CCONST1_2");
+checkequal(SCONST1, "Hello World", "SCONST1");
+checkequal(SCONST1_2, """Hello World""", "SCONST1_2");
+checkequal(EXPR1, 48.5484, "EXPR1");
+checkequal(iconst1, int32(37), "iconst1");
+checkequal(fconst1, 42.2, "fconst1");
+
+checkequal(UNSIGNED1, uint32(hex2dec("5FFF")), "UNSIGNED1");
+checkequal(LONG1, int32(hex2dec("3FFF0000")), "LONG1");
+checkequal(ULONG1, uint32(hex2dec("5FF0000")), "ULONG1");
+
+if isdef('BAR1') then swigtesterror("BAR1"); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/scilab_enums_runme.sci b/Examples/test-suite/scilab/scilab_enums_runme.sci
new file mode 100644
index 000000000..3e9fb7ae0
--- /dev/null
+++ b/Examples/test-suite/scilab/scilab_enums_runme.sci
@@ -0,0 +1,27 @@
+exec("swigtest.start", -1);
+
+function checkEnum(enum_val, expected_enum_val)
+ if typeof(enum_val) <> "constant" then swigtesterror(); end
+ if enum_val <> expected_enum_val then swigtesterror(); end
+endfunction
+
+checkEnum(ENUM_1, 0);
+checkEnum(ENUM_2, 1);
+
+checkEnum(ENUM_EXPLICIT_1_1, 5);
+checkEnum(ENUM_EXPLICIT_1_2, 6);
+
+checkEnum(ENUM_EXPLICIT_2_1, 0);
+checkEnum(ENUM_EXPLICIT_2_2, 10);
+
+checkEnum(ENUM_EXPLICIT_3_1, 2);
+checkEnum(ENUM_EXPLICIT_3_2, 5);
+checkEnum(ENUM_EXPLICIT_3_3, 8);
+
+checkEnum(TYPEDEF_ENUM_1_1, 21);
+checkEnum(TYPEDEF_ENUM_1_2, 22);
+
+checkEnum(TYPEDEF_ENUM_2_1, 31);
+checkEnum(TYPEDEF_ENUM_2_2, 32);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/scilab_identifier_name_runme.sci b/Examples/test-suite/scilab/scilab_identifier_name_runme.sci
new file mode 100644
index 000000000..9a4f3cc08
--- /dev/null
+++ b/Examples/test-suite/scilab/scilab_identifier_name_runme.sci
@@ -0,0 +1,29 @@
+exec("swigtest.start", -1);
+
+
+// Test truncating variables, constants, functions identifier names
+// not truncated
+gvar_identifier_name_set(-101);
+checkequal(gvar_identifier_name_get(), -101, "gvar_identifier_name_get()");
+checkequal(CONS_IDENTIFIER_NAME_get(), -11, "CONS_IDENTIFIER_NAME_get()");
+checkequal(function_identifier_name(), -21, "function_identifier_name()");
+
+// truncated
+too_long_gvar_identi_set(101);
+checkequal(too_long_gvar_identi_get(), 101, "too_long_variable_id_get()");
+checkequal(TOO_LONG_CONST_IDENT_get(), 11, "TOO_LONG_CONST_IDENT_get()");
+checkequal(too_long_function_identi(), 21, "too_long_function_identi()");
+
+// Test truncating when %scilabconst mode is activated
+checkequal(SC_CONST_IDENTIFIER_NAME, int32(-12), "SC_TOO_LONG_IDENTIF");
+checkequal(SC_TOO_LONG_CONST_IDENTI, int32(14), "SC_TOO_LONG_IDENTIF");
+
+// Test truncating in the case of struct
+st = new_st();
+st_m_identifier_name_set(st, 15);
+checkequal(st_m_identifier_name_get(st), 15, "st_m_identifier_name_get(st)");
+st_too_long_member_i_set(st, 25);
+checkequal(st_too_long_member_i_get(st), 25, "st_too_long_member_i_get(st)");
+delete_st(st);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/scilab_li_matrix_runme.sci b/Examples/test-suite/scilab/scilab_li_matrix_runme.sci
new file mode 100644
index 000000000..41924d6f9
--- /dev/null
+++ b/Examples/test-suite/scilab/scilab_li_matrix_runme.sci
@@ -0,0 +1,67 @@
+// test matrix.i library
+
+exec("swigtest.start", -1);
+
+// test matrix passed as output argument from fonction
+function test_outMatrix(func, valueType, expectedOutMatrix)
+ funcName = msprintf("out%s%s", valueType, func);
+ cmd = msprintf("outMatrix = %s();", funcName);
+ ierr = execstr(cmd, "errcatch");
+ if ierr <> 0 then
+ swigtesterror(msprintf("Error %d in %s", ierr, funcName));
+ end
+ checkequal(outMatrix, expectedOutMatrix, funcName);
+endfunction
+
+// test matrix passed as input argument of fonction
+function test_inMatrix(func, valueType, inMatrix, expectedInValue)
+ funcName = msprintf("in%s%s", valueType, func);
+ cmd = msprintf("inValue = %s(inMatrix);", funcName);
+ ierr = execstr(cmd, "errcatch");
+ if ierr <> 0 then
+ swigtesterror(msprintf("Error %d in %s", ierr, funcName));
+ end
+ checkequal(inValue, expectedInValue, funcName);
+endfunction
+
+// test matrixes passed as input and output arguments of fonction
+function test_inoutMatrix(func, valueType, inoutMatrix, expectedInoutMatrix)
+ funcName = msprintf("inout%s%s", valueType, func);
+ cmd = msprintf("inoutMatrix = %s(inoutMatrix);", funcName);
+ ierr = execstr(cmd, "errcatch");
+ if ierr <> 0 then
+ swigtesterror(msprintf("Error %d in %s", ierr, funcName));
+ end
+ checkequal(inoutMatrix, expectedInoutMatrix, funcName);
+endfunction
+
+function test_matrix_typemaps(valueType, ..
+ expectedOutMatrixDims, expectedOutMatrixSize, ..
+ expectedInValue, ..
+ expectedInoutMatrixDims, expectedInoutMatrixSize)
+
+ test_outMatrix("MatrixDims", valueType, expectedOutMatrixDims);
+ test_outMatrix("MatrixSize", valueType, expectedOutMatrixSize);
+ matrixDims = expectedOutMatrixDims;
+ matrixSize = expectedOutMatrixSize;
+ test_inMatrix("MatrixDims", valueType, matrixDims, expectedInValue);
+ test_inMatrix("MatrixSize", valueType, matrixSize, expectedInValue);
+ test_inoutMatrix("MatrixDims", valueType, matrixDims, expectedInoutMatrixDims);
+ test_inoutMatrix("MatrixSize", valueType, matrixSize, expectedInoutMatrixSize);
+endfunction
+
+
+m = [0 3; 1 4; 2 5];
+v = [0 1 2 3 4 5];
+test_matrix_typemaps("Int", m, v, sum(m), m .* m, v .* v);
+test_matrix_typemaps("Double", m, v, sum(m), m .* m, v .* v);
+
+m = ["A" "D"; "B" "E"; "C" "F"];
+v = ["A" "B" "C" "D" "E" "F"];
+test_matrix_typemaps("CharPtr", m, v, strcat(m), m + m, v + v);
+
+m = [%T %F; %F %T; %T %F];
+v = [%T %F %T %F %T %F];
+test_matrix_typemaps("Bool", m, v, %T, ~m, ~v);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/scilab_multivalue_runme.sci b/Examples/test-suite/scilab/scilab_multivalue_runme.sci
new file mode 100644
index 000000000..581890408
--- /dev/null
+++ b/Examples/test-suite/scilab/scilab_multivalue_runme.sci
@@ -0,0 +1,87 @@
+exec("swigtest.start", -1);
+
+// OUTPUT
+
+[a, b] = output2();
+checkequal(a, 1, "[a, b] = output2(): a");
+checkequal(b, 2, "[a, b] = output2(): b");
+
+[ret, a, b] = output2Ret();
+checkequal(ret, 3, "[a, b] = output2Ret(): b");
+checkequal(a, 1, "[a, b] = output2Ret(): a");
+checkequal(b, 2, "[a, b] = output2Ret(): b");
+
+[c, d] = output2Input2(1, 2);
+checkequal(c, 2, "[c, d] = output2Input2(1, 2): c");
+checkequal(d, 4, "[c, d] = output2Input2(1, 2): d");
+
+[ret, c, d] = output2Input2Ret(1, 2);
+checkequal(ret, 6, "[ret, c, d] = output2Input2Ret(1, 2): ret");
+checkequal(c, 2, "[ret, c, d] = output2Input2Ret(1, 2): c");
+checkequal(d, 4, "[ret, c, d = output2Input2Ret(1, 2): d");
+
+[ret, a, b, c] = output3Input1Ret(10);
+checkequal(ret, 10, "[ret, a, b, c] = output3Input1Ret(10): ret");
+checkequal(a, 11, "[ret, a, b, c] = output3Input1Ret(10): a");
+checkequal(b, 12, "[ret, a, b, c] = output3Input1Ret(10): b");
+checkequal(c, 13, "[ret, a, b, c] = output3Input1Ret(10): c");
+
+[ret, a, b, c] = output3Input3Ret(10, 20, 30);
+checkequal(ret, 66, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): ret");
+checkequal(a, 11, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): a");
+checkequal(b, 22, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): b");
+checkequal(c, 33, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): c");
+
+
+// INOUT
+
+[a, b] = inout2(1, 2);
+checkequal(a, 2, "[a, b] = output2(1, 2): a");
+checkequal(b, 4, "[a, b] = output2(1, 2): b");
+
+[ret, a, b] = inout2Ret(1, 2);
+checkequal(ret, 6, "[a, b] = inout2Ret(1, 2): b");
+checkequal(a, 2, "[a, b] = inout2Ret(1, 2): a");
+checkequal(b, 4, "[a, b] = inout2Ret(1, 2): b");
+
+[c, d] = inout2Input2(1, 2, 1, 1);
+checkequal(c, 2, "[c, d] = inout2Input2(1, 2): c");
+checkequal(d, 3, "[c, d] = inout2Input2(1, 2): d");
+
+[ret, c, d] = inout2Input2Ret(1, 2, 1, 1);
+checkequal(ret, 5, "[c, d] = inout2Input2Ret(1, 2): ret");
+checkequal(c, 2, "[c, d] = inout2Input2Ret(1, 2): c");
+checkequal(d, 3, "[c, d] = inout2Input2Ret(1, 4): d");
+
+[ret, a, b, c] = inout3Input1Ret(10, 1, 2, 3);
+checkequal(ret, 10, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): ret");
+checkequal(a, 11, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): a");
+checkequal(b, 12, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): b");
+checkequal(c, 13, "[ret, a, b, c] = output3Input1Ret(ret, 1, 2, 3): c");
+
+[ret, a, b, c] = inout3Input3Ret(10, 1, 20, 2, 30, 3);
+checkequal(ret, 66, "[ret, a, b, c] = output3Input1Ret(10, 20, 30): ret");
+checkequal(a, 11, "[ret, a, b, c] = inout3Input1Ret(10, 1, 20, 2, 30, 3): a");
+checkequal(b, 22, "[ret, a, b, c] = inout3Input1Ret(10, 1, 20, 2, 30, 3): b");
+checkequal(c, 33, "[ret, a, b, c] = inout3Input1Ret(10, 1, 20, 2, 30, 3): c");
+
+
+// CLASS
+
+a = new_ClassA();
+
+[ret, c, d] = ClassA_output2Input2Ret(a, 1, 2);
+checkequal(ret, 6, "[ret, c, d] = ClassA_output2Input2Ret(a, 1, 2): ret");
+checkequal(c, 2, "[c, d] = ClassA_output2Input2Ret(a, 1, 2): c");
+checkequal(d, 4, "[c, d] = ClassA_output2Input2Ret(a, 1, 2): d");
+
+[ret, c, d] = ClassA_inout2Input2Ret(a, 1, 2, 1, 1);
+checkequal(ret, 5, "[ret, c, d] = ClassA_inout2Input2Ret(a, 1, 2): ret");
+checkequal(c, 2, "[c, d] = ClassA_inout2Input2(a, 1, 2): c");
+checkequal(d, 3, "[c, d] = ClassA_inout2Input2(a, 1, 2): d");
+
+delete_ClassA(a);
+
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/scilab_pointer_conversion_functions_runme.sci b/Examples/test-suite/scilab/scilab_pointer_conversion_functions_runme.sci
new file mode 100644
index 000000000..d24f60eb9
--- /dev/null
+++ b/Examples/test-suite/scilab/scilab_pointer_conversion_functions_runme.sci
@@ -0,0 +1,18 @@
+exec("swigtest.start", -1);
+
+// Test on NULL
+null = getNull();
+checkequal(SWIG_this(null), 0, "SWIG_this(null)");
+
+null = SWIG_ptr(0);
+checkequal(isNull(null), %T, "func(null)");
+
+// Test on variable
+expected_foo_addr = getFooAddress();
+foo_addr = SWIG_this(pfoo_get());
+checkequal(foo_addr, expected_foo_addr, "SWIG_this(pfoo_get())");
+
+pfoo = SWIG_ptr(foo_addr);
+checkequal(equalFooPointer(pfoo), %T, "equalFooPointer(pfoo)");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/simple_array_runme.sci b/Examples/test-suite/scilab/simple_array_runme.sci
new file mode 100644
index 000000000..8ff1a3a57
--- /dev/null
+++ b/Examples/test-suite/scilab/simple_array_runme.sci
@@ -0,0 +1,12 @@
+exec("swigtest.start", -1);
+
+try
+ initArray();
+catch
+ swigtesterror();
+end
+
+if x_get() <> int32([0,1,2,3,4,5,6,7,8,9]) then swigtesterror(); end
+if y_get() <> [0/7,1/7,2/7,3/7,4/7,5/7,6/7] then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/sizet_runme.sci b/Examples/test-suite/scilab/sizet_runme.sci
new file mode 100644
index 000000000..117024973
--- /dev/null
+++ b/Examples/test-suite/scilab/sizet_runme.sci
@@ -0,0 +1,11 @@
+exec("swigtest.start", -1);
+
+s = 2000;
+s = test1(s+1);
+s = test2(s+1);
+s = test3(s+1);
+s = test4(s+1);
+if s <> 2004 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/smart_pointer_simple_runme.sci b/Examples/test-suite/scilab/smart_pointer_simple_runme.sci
new file mode 100644
index 000000000..7ab9085fe
--- /dev/null
+++ b/Examples/test-suite/scilab/smart_pointer_simple_runme.sci
@@ -0,0 +1,13 @@
+exec("swigtest.start", -1);
+
+f = new_Foo();
+b = new_Bar(f);
+
+Bar_x_set(b, 3);
+if Bar_x_get(b) <> 3 then swigtesterror(); end
+
+fp = Bar___deref__(b);
+Bar_x_set(b, 4);
+if Bar_x_get(b) <> 4 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/sneaky1_runme.sci b/Examples/test-suite/scilab/sneaky1_runme.sci
new file mode 100644
index 000000000..5d9e24407
--- /dev/null
+++ b/Examples/test-suite/scilab/sneaky1_runme.sci
@@ -0,0 +1,31 @@
+exec("swigtest.start", -1);
+
+try
+ x = add(3, 4);
+catch
+ swigtesterror();
+end
+if x <> 7 then swigtesterror(); end
+
+try
+ y = subtract(3,4);
+catch
+ swigtesterror();
+end
+if y <> -1 then swigtesterror(); end
+
+try
+ z = mul(3,4);
+catch
+ swigtesterror();
+end
+if z <> 12 then swigtesterror(); end
+
+try
+ w = divide(3,4);
+catch
+ swigtesterror();
+end
+if w <> 0 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/struct_initialization_runme.sci b/Examples/test-suite/scilab/struct_initialization_runme.sci
new file mode 100644
index 000000000..fcdb3fccc
--- /dev/null
+++ b/Examples/test-suite/scilab/struct_initialization_runme.sci
@@ -0,0 +1,15 @@
+exec("swigtest.start", -1);
+
+if StructC_x_get(instanceC1_get()) <> 10 then swigtesterror(); end
+
+if StructD_x_get(instanceD1_get()) <> 10 then swigtesterror(); end
+
+if StructD_x_get(instanceD2_get()) <> 20 then swigtesterror(); end
+
+if StructD_x_get(instanceD3_get()) <> 30 then swigtesterror(); end
+
+if StructE_x_get(instanceE1_get()) <> 1 then swigtesterror(); end
+
+if StructF_x_get(instanceF1_get()) <> 1 then swigtesterror(); end
+
+exec("swigtest.quit", -1); \ No newline at end of file
diff --git a/Examples/test-suite/scilab/struct_rename_runme.sci b/Examples/test-suite/scilab/struct_rename_runme.sci
new file mode 100644
index 000000000..2737d446e
--- /dev/null
+++ b/Examples/test-suite/scilab/struct_rename_runme.sci
@@ -0,0 +1,11 @@
+exec("swigtest.start", -1);
+
+try
+ a = new_Bar();
+ Bar_x_set(a,100);
+catch
+ swigtesterror();
+end
+if Bar_x_get(a) <> 100 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/struct_value_runme.sci b/Examples/test-suite/scilab/struct_value_runme.sci
new file mode 100644
index 000000000..b00970ef9
--- /dev/null
+++ b/Examples/test-suite/scilab/struct_value_runme.sci
@@ -0,0 +1,16 @@
+exec("swigtest.start", -1);
+
+foo = new_Foo();
+Foo_x_set(foo, 1);
+if Foo_x_get(foo) <> 1 then swigtesterror(); end
+
+bar = new_Bar();
+Bar_a_set(bar, foo);
+a = Bar_a_get(bar);
+if Foo_x_get(a) <> 1 then swigtesterror(); end
+
+Bar_b_set(bar, foo);
+b = Bar_b_get(bar);
+if Foo_x_get(b) <> 1 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/swigtest.quit b/Examples/test-suite/scilab/swigtest.quit
new file mode 100644
index 000000000..307077da1
--- /dev/null
+++ b/Examples/test-suite/scilab/swigtest.quit
@@ -0,0 +1,2 @@
+// Exit from Scilab
+exit
diff --git a/Examples/test-suite/scilab/swigtest.start b/Examples/test-suite/scilab/swigtest.start
new file mode 100644
index 000000000..e4347bd90
--- /dev/null
+++ b/Examples/test-suite/scilab/swigtest.start
@@ -0,0 +1,57 @@
+lines(0);
+warning('off');
+ilib_verbose(0);
+
+// Get test name (used in swigtest.quit file)
+[units, typ, names] = file(1);
+swigtestname = strsubst(fileparts(names, "fname"), "_runme", "");
+
+// Does the library exists? If not then exit!
+libname = "lib" + swigtestname + getdynlibext();
+if ~isfile(libname) then
+ mfprintf(0, "*** LIBRARY NOT FOUND: %s ***\n", libname);
+ exit(1)
+end
+
+// Load library
+try
+ exec("loader.sce", -1);
+catch
+ mfprintf(0, "*** LOADER EXECUTION FAILED ***\n");
+ exit(1)
+end
+
+// Module initialization
+try
+ moduleInit = sprintf("%s_Init()", swigtestname);
+ execstr(moduleInit);
+catch
+ mfprintf(0, "*** MODULE INIT FAILED ***\n");
+ exit(1)
+end
+
+// Error management function
+function swigtesterror(msg)
+ [lines, names] = where();
+ if size(lines, '*') > 0
+ mfprintf(0, "*** TEST FAILED (at line %d) ***\n", lines($));
+ if argn(2) >= 1 then disp(msg); end
+ else
+ mfprintf(0, "*** TEST FAILED ***\n");
+ end;
+ exit(1)
+endfunction
+
+// Check equal function
+function checkequal(returned, expected, message)
+ if typeof(returned) <> typeof(expected) then
+ returned_type_msg = ["returned type:"; typeof(returned)];
+ expected_type_msg = ["expected type:"; typeof(expected)];
+ swigtesterror([message; returned_type_msg; expected_type_msg]);
+ end
+ if ~isequal(returned, expected) then
+ returned_value_msg = ["returned value:"; string(returned)];
+ expected_value_msg = ["expected value:"; string(expected)];
+ swigtesterror([message; returned_value_msg; expected_value_msg]);
+ end
+endfunction
diff --git a/Examples/test-suite/scilab/template_classes_runme.sci b/Examples/test-suite/scilab/template_classes_runme.sci
new file mode 100644
index 000000000..b4b3a2c53
--- /dev/null
+++ b/Examples/test-suite/scilab/template_classes_runme.sci
@@ -0,0 +1,8 @@
+exec("swigtest.start", -1);
+
+ri = new_RectangleInt();
+pi = RectangleInt_getPoint(ri);
+x = PointInt_getX(pi);
+delete_RectangleInt(ri);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/template_ns_runme.sci b/Examples/test-suite/scilab/template_ns_runme.sci
new file mode 100644
index 000000000..aea784114
--- /dev/null
+++ b/Examples/test-suite/scilab/template_ns_runme.sci
@@ -0,0 +1,15 @@
+exec("swigtest.start", -1);
+
+p1 = new_pairii(2, 3);
+p2 = new_pairii(p1);
+
+checkequal(pairii_first_get(p2), 2, "pairii_first(p2) test fails.");
+checkequal(pairii_second_get(p2), 3, "pairii_second(p2) test fails.");
+
+p3 = new_pairdd(0.5, 2.5);
+p4 = new_pairdd(p3);
+
+checkequal(pairdd_first_get(p4), 0.5, "pairdd_first(p4) test fails.");
+checkequal(pairdd_second_get(p4), 2.5, "pairdd_second(p4) test fails.");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/template_rename_runme.sci b/Examples/test-suite/scilab/template_rename_runme.sci
new file mode 100644
index 000000000..9c9512930
--- /dev/null
+++ b/Examples/test-suite/scilab/template_rename_runme.sci
@@ -0,0 +1,15 @@
+exec("swigtest.start", -1);
+
+i = new_iFoo();
+checkequal(iFoo_blah_test(i, 4), 4, "iFoo_blah_test(i, 4) test fails");
+checkequal(iFoo_spam_test(i, 5), 5, "iFoo_spam_test(i, 5) test fails");
+checkequal(iFoo_groki_test(i, 6), 6, "iFoo_groki_test(i, 6) test fails");
+delete_iFoo(i);
+
+d = new_iFoo();
+checkequal(dFoo_blah_test(d, 4), 4, "dFoo_blah_test(d, 4) test fails");
+checkequal(dFoo_spam(d, 5), 5, "dFoo_spam_test(d, 5) test fails");
+checkequal(dFoo_grok_test(d, 6), 6, "dFoo_groki_test(d, 6) test fails");
+delete_dFoo(d);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/template_static_runme.sci b/Examples/test-suite/scilab/template_static_runme.sci
new file mode 100644
index 000000000..e17c46143
--- /dev/null
+++ b/Examples/test-suite/scilab/template_static_runme.sci
@@ -0,0 +1,8 @@
+exec("swigtest.start", -1);
+
+checkequal(foo_i_test_get(), 0, "foo_i_test_get() test fails.");
+checkequal(foo_d_test_get(), 0, "foo_i_test_get() test fails.");
+
+checkequal(Foo_bar_double(0), 1, "Foo_bar_double() test fails");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/throw_exception_runme.sci b/Examples/test-suite/scilab/throw_exception_runme.sci
new file mode 100644
index 000000000..2eada4be2
--- /dev/null
+++ b/Examples/test-suite/scilab/throw_exception_runme.sci
@@ -0,0 +1,23 @@
+exec("swigtest.start", -1);
+
+function checkException(cmd, expected_error_msg)
+ ierr = execstr(cmd, 'errcatch');
+ checkequal(ierr, 20000, cmd + ': ierr');
+ checkequal(lasterror(), 'SWIG/Scilab: ' + expected_error_msg, cmd + ': msg');
+endfunction
+
+foo = new_Foo();
+
+checkException('Foo_test_int(foo)', 'Exception (int) occured: 37');
+
+checkException('Foo_test_msg(foo)', 'Exception (char const *) occured: Dead');
+
+checkException('Foo_test_multi(foo, 1)', 'Exception (int) occured: 37');
+
+checkException('Foo_test_multi(foo, 2)', 'Exception (char const *) occured: Dead');
+
+checkException('Foo_test_cls(foo)', 'Exception (CError) occured.');
+
+delete_Foo(foo);
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/typedef_struct_runme.sci b/Examples/test-suite/scilab/typedef_struct_runme.sci
new file mode 100644
index 000000000..e41c21629
--- /dev/null
+++ b/Examples/test-suite/scilab/typedef_struct_runme.sci
@@ -0,0 +1,29 @@
+exec("swigtest.start", -1);
+
+try
+ x = new_LineObj();
+ LineObj_numpoints_set(x, 100);
+catch
+ swigtesterror();
+end
+if LineObj_numpoints_get(x) <> 100 then swigtesterror(); end
+
+if MS_NOOVERRIDE_get() <> -1111 then swigtesterror(); end
+
+try
+ y = make_a();
+ A_t_a_set(y, 200);
+catch
+ swigtesterror();
+end
+if A_t_a_get(y) <> 200 then swigtesterror(); end
+
+try
+ A_t_b_set(y, 300);
+catch
+ swigtesterror();
+end
+if A_t_b_get(y) <> 300 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab/union_parameter_runme.sci b/Examples/test-suite/scilab/union_parameter_runme.sci
new file mode 100644
index 000000000..2918856d9
--- /dev/null
+++ b/Examples/test-suite/scilab/union_parameter_runme.sci
@@ -0,0 +1,35 @@
+// Some lines are commented out because of too long identifiers...
+
+exec("swigtest.start", -1);
+
+event = new_SDL_Event();
+
+for i=1:2
+ evAvailable = SDL_PollEvent(event);
+ evType = SDL_Event_type_get(event);
+
+ if evType==1 then
+ specEvent = SDL_Event_active_get(event);
+ _type = SDL_ActiveEvent_type_get(specEvent);
+
+ if _type <> evType then swigtesterror(); end
+
+ gain = SDL_ActiveEvent_gain_get(specEvent);
+ //state = SDL_ActiveEvent_state_get(specEvent);
+ end
+
+ if evType==2 then
+ specEvent = SDL_Event_key_get(event);
+ //_type = SDL_KeyboardEvent_type_get(specEvent);
+
+ //if _type <> evType then swigtesterror(); end
+
+ //_which = SDL_KeyboardEvent_which_get(specEvent);
+ //state = SDL_KeyboardEvent_state_get(specEvent);
+ end
+
+end
+
+delete_SDL_Event(event);
+
+exec("swigtest.quit", -1); \ No newline at end of file
diff --git a/Examples/test-suite/scilab/unions_runme.sci b/Examples/test-suite/scilab/unions_runme.sci
new file mode 100644
index 000000000..c8c6a9444
--- /dev/null
+++ b/Examples/test-suite/scilab/unions_runme.sci
@@ -0,0 +1,23 @@
+exec("swigtest.start", -1);
+
+try
+ small = new_SmallStruct();
+ SmallStruct_jill_set(small, 200);
+
+ big = new_BigStruct();
+ BigStruct_jack_set(big, 300);
+
+ Jill = SmallStruct_jill_get(small);
+catch
+ swigtesterror();
+end
+if Jill <> 200 then swigtesterror(); end
+
+try
+ Jack = BigStruct_jack_get(big);
+catch
+ swigtesterror();
+end
+if Jack <> 300 then swigtesterror(); end
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/varargs_overload_runme.sci b/Examples/test-suite/scilab/varargs_overload_runme.sci
new file mode 100644
index 000000000..7603b667c
--- /dev/null
+++ b/Examples/test-suite/scilab/varargs_overload_runme.sci
@@ -0,0 +1,21 @@
+exec("swigtest.start", -1);
+
+checkequal(vararg_over1("Hello"), "Hello", "vararg_over1(""Hello"")");
+
+checkequal(vararg_over1(2), "2", "vararg_over1(2)");
+
+checkequal(vararg_over2("Hello"), "Hello", "vararg_over1(""Hello"")");
+
+checkequal(vararg_over2(2, 2.2), "2 2.2", "vararg_over2(2, 2.2)")
+
+checkequal(vararg_over3("Hello"), "Hello", "vararg_over3(""Hello"")");
+
+checkequal(vararg_over3(2, 2.2, "hey"), "2 2.2 hey", "vararg_over3(2, 2.2, ""hey"")");
+
+checkequal(vararg_over4("Hello"), "Hello", "vararg_over4(""Hello"")");
+
+checkequal(vararg_over4(123), "123", "vararg_over4(123)");
+
+checkequal(vararg_over4("Hello", 123), "Hello", "vararg_over4(""Hello"", 123)");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/varargs_runme.sci b/Examples/test-suite/scilab/varargs_runme.sci
new file mode 100644
index 000000000..333838c00
--- /dev/null
+++ b/Examples/test-suite/scilab/varargs_runme.sci
@@ -0,0 +1,17 @@
+exec("swigtest.start", -1);
+
+checkequal(test("Hello"), "Hello", "test(""Hello"")");
+
+f = new_Foo("Greetings");
+checkequal(Foo_str_get(f), "Greetings", "new_Foo(""Greetings"")");
+
+checkequal(Foo_test(f, "Hello"), "Hello", "Foo_test(f)");
+delete_Foo(f);
+
+checkequal(Foo_statictest("Hello", 1), "Hello", "Foo_statictest(""Hello"", 1)");
+
+checkequal(test_def("Hello", 1), "Hello", "test_def(""Hello"", 1)");
+
+checkequal(test_def("Hello"), "Hello", "test_def(""Hello"")");
+
+exec("swigtest.quit", -1);
diff --git a/Examples/test-suite/scilab/voidtest_runme.sci b/Examples/test-suite/scilab/voidtest_runme.sci
new file mode 100644
index 000000000..395e8f630
--- /dev/null
+++ b/Examples/test-suite/scilab/voidtest_runme.sci
@@ -0,0 +1,22 @@
+exec("swigtest.start", -1);
+
+globalfunc();
+
+f = new_Foo();
+Foo_memberfunc(f);
+
+Foo_staticmemberfunc();
+
+v1 = vfunc1(f);
+checkequal(SWIG_this(v1), SWIG_this(f), "vfunc1(f) <> f");
+
+v2 = vfunc2(f);
+checkequal(SWIG_this(v2), SWIG_this(f), "vfunc2(f) <> f");
+
+v3 = vfunc3(v1);
+checkequal(SWIG_this(v3), SWIG_this(f), "vfunc3(f) <> f");
+
+Foo_memberfunc(v3);
+
+exec("swigtest.quit", -1);
+
diff --git a/Examples/test-suite/scilab_consts.i b/Examples/test-suite/scilab_consts.i
new file mode 100644
index 000000000..11f2504b7
--- /dev/null
+++ b/Examples/test-suite/scilab_consts.i
@@ -0,0 +1,52 @@
+%module scilab_consts
+
+/* Default mode: constants are wrapped as getter functions */
+%scilabconst(0);
+
+#define ICONST0 42
+#define FCONST0 2.1828
+#define CCONST0 'x'
+#define CCONST0_2 '\n'
+#define SCONST0 "Hello World"
+#define SCONST0_2 "\"Hello World\""
+
+/* Constants with type */
+#define UNSIGNED0 0x5FFFU
+#define LONG0 0x3FFF0000L
+#define ULONG0 0x5FF0000UL
+
+/* Expressions should work too */
+#define EXPR0 ICONST0 + 3*FCONST0
+
+/* This shouldn't do anything, bar is not defined */
+#define BAR0 bar
+
+/* SWIG directive %constant produces constants too */
+%constant int iconst0 = 37;
+%constant double fconst0 = 42.2;
+
+
+/* Alternative mode: constants are wrapped as variables */
+%scilabconst(1);
+
+#define ICONST1 42
+#define FCONST1 2.1828
+#define CCONST1 'x'
+#define CCONST1_2 '\n'
+#define SCONST1 "Hello World"
+#define SCONST1_2 "\"Hello World\""
+
+/* Constants with type */
+#define UNSIGNED1 0x5FFFU
+#define LONG1 0x3FFF0000L
+#define ULONG1 0x5FF0000UL
+
+/* Expressions should work too */
+#define EXPR1 ICONST1 + 3*FCONST1
+
+/* This shouldn't do anything, bar is not defined */
+#define BAR1 bar
+
+/* SWIG directive %constant produces constants too */
+%constant int iconst1 = 37;
+%constant double fconst1 = 42.2;
diff --git a/Examples/test-suite/scilab_enums.i b/Examples/test-suite/scilab_enums.i
new file mode 100644
index 000000000..32d5a34de
--- /dev/null
+++ b/Examples/test-suite/scilab_enums.i
@@ -0,0 +1,38 @@
+%module scilab_enums
+
+%scilabconst(1);
+
+%inline %{
+
+enum ENUM {
+ ENUM_1,
+ ENUM_2
+};
+
+enum ENUM_EXPLICIT_1 {
+ ENUM_EXPLICIT_1_1 = 5,
+ ENUM_EXPLICIT_1_2
+};
+
+enum ENUM_EXPLICIT_2 {
+ ENUM_EXPLICIT_2_1,
+ ENUM_EXPLICIT_2_2 = 10
+};
+
+enum ENUM_EXPLICIT_3 {
+ ENUM_EXPLICIT_3_1 = 2,
+ ENUM_EXPLICIT_3_2 = 5,
+ ENUM_EXPLICIT_3_3 = 8
+};
+
+typedef enum {
+ TYPEDEF_ENUM_1_1 = 21,
+ TYPEDEF_ENUM_1_2 = 22
+} TYPEDEF_ENUM_1;
+
+typedef enum TYPEDEF_ENUM_2 {
+ TYPEDEF_ENUM_2_1 = 31,
+ TYPEDEF_ENUM_2_2 = 32
+} TYPEDEF_ENUM_2;
+
+%}
diff --git a/Examples/test-suite/scilab_identifier_name.i b/Examples/test-suite/scilab_identifier_name.i
new file mode 100644
index 000000000..94dde47e0
--- /dev/null
+++ b/Examples/test-suite/scilab_identifier_name.i
@@ -0,0 +1,53 @@
+%module scilab_identifier_name
+
+//
+// Test long identifier name (> 24 characters) truncating
+//
+
+// Test truncating variables, constants, functions identifier names
+
+%inline %{
+// these identifier names wont be truncated
+int gvar_identifier_name = -1;
+#define CONS_IDENTIFIER_NAME -11
+int function_identifier_name() { return -21; };
+
+// these identifier names will be truncated
+int too_long_gvar_identifier_name_1 = 1;
+int too_long_gvar_identifier_name_2 = 2;
+
+#define TOO_LONG_CONST_IDENTIFIER_NAME_1 11
+
+int too_long_function_identifier_name_1() { return 21; };
+%}
+
+// Test truncating when %scilabconst mode is activated
+%scilabconst(1);
+
+%inline %{
+#define SC_CONST_IDENTIFIER_NAME -12;
+
+#define SC_TOO_LONG_CONST_IDENTIFIER_NAME_1 13
+#define SC_TOO_LONG_CONST_IDENTIFIER_NAME_2 14
+%}
+%scilabconst(0);
+
+// Test truncating in the case of struct
+%inline %{
+struct st {
+ int m_identifier_name;
+ int too_long_member_identifier_name;
+};
+
+%}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Examples/test-suite/scilab_li_matrix.i b/Examples/test-suite/scilab_li_matrix.i
new file mode 100644
index 000000000..ae5ad76bb
--- /dev/null
+++ b/Examples/test-suite/scilab_li_matrix.i
@@ -0,0 +1,161 @@
+%module scilab_li_matrix
+
+%include "matrix.i"
+
+%define %use_matrix_apply(TYPE...)
+%apply (TYPE *IN, int IN_ROWCOUNT, int IN_COLCOUNT) { (TYPE *matrix, int nbRow, int nbCol) }
+%apply (TYPE **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT) { (TYPE **matrixRes, int *nbRowRes, int *nbColRes) }
+%apply (TYPE *IN, int IN_SIZE) { (TYPE *matrix, int size) }
+%apply (TYPE **OUT, int *OUT_SIZE) { (TYPE **matrixRes, int *sizeRes) }
+%enddef
+
+%use_matrix_apply(int);
+%use_matrix_apply(double);
+%use_matrix_apply(char *);
+%use_matrix_apply(bool);
+
+%inline %{
+
+/*
+ * (T *matrixIn, int matrixInSize) pattern functions
+ */
+
+template<typename T> T inMatrixSize(T *matrix, int size) {
+ T sum = 0;
+ int i;
+ for (i = 0; i < size; i++)
+ sum += matrix[i];
+ return sum;
+}
+
+template<typename T> void outMatrixSize(T **matrixRes, int *sizeRes) {
+ int size;
+ int i;
+ *sizeRes = 6;
+ *matrixRes = (T*) malloc(*sizeRes * sizeof(T));
+ for (i = 0; i < *sizeRes; i++)
+ (*matrixRes)[i] = i;
+}
+
+template<typename T> void inoutMatrixSize(T *matrix, int size, T **matrixRes, int *sizeRes) {
+ int i;
+ *sizeRes = size;
+ *matrixRes = (T*) malloc(size * sizeof(T));
+ for (i = 0; i < size; i++) {
+ (*matrixRes)[i] = matrix[i] * matrix[i];
+ }
+}
+
+/*
+ * (char **matrixIn, int matrixInSize) pattern functions
+ */
+
+template<> char* inMatrixSize(char **matrix, int size) {
+ char *s = (char *) calloc(size + 1, sizeof(char));
+ int i;
+ for (i = 0; i < size; i++)
+ strcat(s, matrix[i]);
+ return s;
+}
+
+template<> void outMatrixSize(char ***matrixRes, int *sizeRes) {
+ char *s;
+ int i;
+ *sizeRes = 6;
+ *matrixRes = (char **) malloc(*sizeRes * sizeof(char *));
+ for (i = 0; i < *sizeRes; i++) {
+ s = (char *) malloc(sizeof(char)+1);
+ sprintf(s, "%c", char(65 + i));
+ (*matrixRes)[i] = s;
+ }
+}
+
+template<> void inoutMatrixSize(char **matrix, int size,
+ char ***matrixRes, int *sizeRes) {
+ int i;
+ char *s;
+ *sizeRes = size;
+ *matrixRes = (char **) malloc(*sizeRes * sizeof(char* ));
+ for (i = 0; i < *sizeRes; i++) {
+ s = (char *) malloc((2 * strlen(matrix[i]) + 1) * sizeof(char));
+ sprintf(s, "%s%s", matrix[i], matrix[i]);
+ (*matrixRes)[i] = s;
+ }
+}
+
+/*
+ * (bool **matrixIn, int matrixInSize) pattern functions
+ */
+
+template<> bool inMatrixSize(bool *matrix, int size) {
+ bool b = true;
+ int i;
+ b = matrix[0];
+ for (i = 1; i < size; i++)
+ b = b ^ matrix[i];
+ return b;
+}
+
+template<> void outMatrixSize(bool **matrixRes, int *sizeRes) {
+ int i;
+ *sizeRes = 6;
+ *matrixRes = (bool*) malloc(*sizeRes * sizeof(bool));
+ for (i = 0; i < *sizeRes; i++) {
+ (*matrixRes)[i] = i % 2 == 0;
+ }
+}
+
+template<> void inoutMatrixSize(bool *matrix, int size,
+ bool **matrixRes, int *sizeRes) {
+ int i;
+ *sizeRes = size;
+ *matrixRes = (bool*) malloc(*sizeRes * sizeof(bool));
+ for (i = 0; i < *sizeRes; i++) {
+ (*matrixRes)[i] = matrix[i] == 1 ? 0 : 1;
+ }
+}
+
+/*
+ * (T *matrixIn, int matrixInRowCount, int matrixInColCount) pattern functions
+ */
+
+template<typename T> T inMatrixDims(T *matrix, int nbRow, int nbCol) {
+ return inMatrixSize(matrix, nbRow * nbCol);
+}
+
+template<typename T> void outMatrixDims(T **matrixRes, int *nbRowRes, int *nbColRes) {
+ int size = 0;
+ outMatrixSize(matrixRes, &size);
+ *nbRowRes = 3;
+ *nbColRes = 2;
+}
+
+template<typename T> void inoutMatrixDims(T *matrix, int nbRow, int nbCol,
+ T **matrixRes, int *nbRowRes, int *nbColRes) {
+ *nbRowRes = nbRow;
+ *nbColRes = nbCol;
+ int sizeRes = 0;
+ inoutMatrixSize(matrix, nbRow * nbCol, matrixRes, &sizeRes);
+}
+
+%}
+
+%define %instantiate_matrix_template_functions(NAME, TYPE...)
+%template(in ## NAME ## MatrixDims) inMatrixDims<TYPE>;
+%template(out ## NAME ## MatrixDims) outMatrixDims<TYPE>;
+%template(inout ## NAME ## MatrixDims) inoutMatrixDims<TYPE>;
+%template(in ## NAME ## MatrixSize) inMatrixSize<TYPE>;
+%template(out ## NAME ## MatrixSize) outMatrixSize<TYPE>;
+%template(inout ## NAME ## MatrixSize) inoutMatrixSize<TYPE>;
+%enddef
+
+%instantiate_matrix_template_functions(Int, int);
+%instantiate_matrix_template_functions(Double, double);
+%instantiate_matrix_template_functions(CharPtr, char *);
+%instantiate_matrix_template_functions(Bool, bool);
+
+
+
+
+
+
diff --git a/Examples/test-suite/scilab_multivalue.i b/Examples/test-suite/scilab_multivalue.i
new file mode 100644
index 000000000..3165d48e1
--- /dev/null
+++ b/Examples/test-suite/scilab_multivalue.i
@@ -0,0 +1,123 @@
+%module scilab_multivalue
+
+
+
+void output2(int *OUTPUT, int *OUTPUT);
+int output2Ret(int *OUTPUT, int *OUTPUT);
+void output2Input2(int a, int b, int *OUTPUT, int *OUTPUT);
+int output2Input2Ret(int a, int b, int *OUTPUT, int *OUTPUT);
+int output3Input1Ret(int a, int *OUTPUT, int *OUTPUT, int *OUTPUT);
+int output3Input3Ret(int x, int *OUTPUT, int y, int *OUTPUT, int z, int *OUTPUT);
+
+void inout2(int *INOUT, int *INOUT);
+int inout2Ret(int *INOUT, int *INOUT);
+void inout2Input2(int a, int b, int *INOUT, int *INOUT);
+int inout2Input2Ret(int a, int b, int *INOUT, int *INOUT);
+int inout3Input1Ret(int a, int *INOUT, int *INOUT, int *INOUT);
+int inout3Input3Ret(int x, int *INOUT, int y, int *INOUT, int z, int *INOUT);
+
+class ClassA {
+public:
+ ClassA() {};
+ int output2Input2Ret(int a, int b, int *OUTPUT, int *OUTPUT);
+ int inout2Input2Ret(int a, int b, int *INOUT, int *INOUT);
+};
+
+%{
+
+// Test return of multiple values with OUTPUT
+
+void output2(int *a, int *b) {
+ *a = 1;
+ *b = 2;
+}
+
+int output2Ret(int *a, int *b) {
+ *a = 1;
+ *b = 2;
+ return *a + *b;
+}
+
+void output2Input2(int a, int b, int *c, int *d) {
+ *c = a + 1;
+ *d = b + 2;
+}
+
+int output2Input2Ret(int a, int b, int *c, int *d) {
+ *c = a + 1;
+ *d = b + 2;
+ return *c + *d;
+}
+
+int output3Input1Ret(int x, int *a, int *b, int *c) {
+ *a = x + 1;
+ *b = x + 2;
+ *c = x + 3;
+ return x;
+}
+
+int output3Input3Ret(int x, int *a, int y, int *b, int z, int *c) {
+ *a = x + 1;
+ *b = y + 2;
+ *c = z + 3;
+ return *a + *b + *c;
+}
+
+
+// Test return of multiple values with INOUT
+
+void inout2(int *a, int *b) {
+ *a = *a + 1;
+ *b = *a + 2;
+}
+
+int inout2Ret(int *a, int *b) {
+ *a = *a + 1;
+ *b = *a + 2;
+ return *a + *b;
+}
+
+void inout2Input2(int a, int b, int *c, int *d) {
+ *c = *c + a;
+ *d = *d + b;
+}
+
+int inout2Input2Ret(int a, int b, int *c, int *d) {
+ *c = *c + a;
+ *d = *d + b;
+ return *c + *d;
+}
+
+int inout3Input1Ret(int x, int *a, int *b, int *c) {
+ *a = *a + x;
+ *b = *b + x;
+ *c = *c + x;
+ return x;
+}
+
+int inout3Input3Ret(int x, int *a, int y, int *b, int z, int *c) {
+ *a = *a + x;
+ *b = *b + y;
+ *c = *c + z;
+ return *a + *b + *c;
+}
+
+// Test return multiples from class methods
+
+class ClassA {
+public:
+ ClassA() {};
+ int output2Input2Ret(int a, int b, int *c, int *d) {
+ *c = a + 1;
+ *d = b + 2;
+ return *c + *d;
+ }
+ int inout2Input2Ret(int a, int b, int *c, int *d) {
+ *c = *c + a;
+ *d = *d + b;
+ return *c + *d;
+ }
+};
+
+
+%}
diff --git a/Examples/test-suite/scilab_pointer_conversion_functions.i b/Examples/test-suite/scilab_pointer_conversion_functions.i
new file mode 100644
index 000000000..5e29926c1
--- /dev/null
+++ b/Examples/test-suite/scilab_pointer_conversion_functions.i
@@ -0,0 +1,18 @@
+%module scilab_pointer_conversion_functions
+
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) pfoo; /* Setting a pointer/reference variable may leak memory. */
+
+%inline %{
+
+void* getNull() { return NULL; }
+bool isNull(void *p) { return p == NULL; }
+
+int foo = 3;
+int *pfoo = &foo;
+
+double getFooAddress() { return (double) (unsigned long) pfoo; }
+bool equalFooPointer(void *p) { return p == pfoo; }
+
+%}
+
+
diff --git a/Examples/test-suite/sizeof_pointer.i b/Examples/test-suite/sizeof_pointer.i
index 993ba4de5..aa6cfcd5c 100644
--- a/Examples/test-suite/sizeof_pointer.i
+++ b/Examples/test-suite/sizeof_pointer.i
@@ -4,16 +4,17 @@ This testcase tests whether the sizeof operator on a pointer is working.
%module sizeof_pointer
+
%inline %{
#define NO_PROBLEM sizeof(char)
#define STAR_PROBLEM sizeof(char*)
#define STAR_STAR_PROBLEM sizeof(char**)
-typedef struct SizeofPointerTest {
+typedef struct SizePtrTst {
unsigned char array1[NO_PROBLEM];
unsigned char array2[STAR_PROBLEM];
unsigned char array3[STAR_STAR_PROBLEM];
-} SizeofPointerTest;
+} SizePtrTst;
%}
diff --git a/Examples/test-suite/smart_pointer_const_overload.i b/Examples/test-suite/smart_pointer_const_overload.i
index e3b000b52..75a137b73 100644
--- a/Examples/test-suite/smart_pointer_const_overload.i
+++ b/Examples/test-suite/smart_pointer_const_overload.i
@@ -34,7 +34,7 @@ struct Foo {
Foo() : x(0), xp(&x), y(0), yp(&y), access(0) { }
int getx() const { return x; }
void setx(int x_) { x = x_; }
- static void stat() {}
+ static void statMethod() {}
};
%}
diff --git a/Examples/test-suite/template_default_class_parms.i b/Examples/test-suite/template_default_class_parms.i
index cd37269d3..d07a1309f 100644
--- a/Examples/test-suite/template_default_class_parms.i
+++ b/Examples/test-suite/template_default_class_parms.i
@@ -31,3 +31,49 @@ namespace Space {
%template(FooAnotherType) Space::Foo<Space::AnotherType>;
%template() Space::ATemplate<>;
+
+
+// Github issue #280 segfault
+%inline %{
+namespace Teuchos {
+ class Describable {};
+}
+namespace KokkosClassic {
+ namespace DefaultNode {
+ struct DefaultNodeType {};
+ }
+}
+
+namespace Tpetra {
+ template <class LocalOrdinal = int,
+ class GlobalOrdinal = LocalOrdinal,
+ class Node = KokkosClassic::DefaultNode::DefaultNodeType>
+ class Map : public Teuchos::Describable {
+ public:
+ typedef LocalOrdinal local_ordinal_type;
+ typedef GlobalOrdinal global_ordinal_type;
+ typedef Node node_type;
+ void test_func(LocalOrdinal, GlobalOrdinal, Node) {}
+ };
+}
+%}
+
+#ifdef SWIGJAVA
+// Fixes still required for other languages
+%template(MapDefaults) Tpetra::Map<>;
+#endif
+
+%inline %{
+namespace Details {
+ template < class LO = ::Tpetra::Map<>::local_ordinal_type,
+ class GO = typename ::Tpetra::Map<LO>::global_ordinal_type,
+ class NT = typename ::Tpetra::Map<LO, GO>::node_type >
+ class Transfer : public Teuchos::Describable {
+ public:
+ void transfer_func(LO, GO, NT) {}
+ };
+}
+%}
+
+// Below is not resolving correctly yet
+//%template(TransferDefaults) Details::Transfer<>;
diff --git a/Examples/test-suite/template_nested.i b/Examples/test-suite/template_nested.i
index 81a551a41..67668fb1a 100644
--- a/Examples/test-suite/template_nested.i
+++ b/Examples/test-suite/template_nested.i
@@ -114,6 +114,8 @@ namespace ns {
};
}
%}
+
+#if !defined(SWIGSCILAB)
%extend ns::OuterClass {
%template(T_OuterClassInner2Double) Inner2<double>;
}
@@ -125,3 +127,14 @@ namespace ns {
%template(T_OuterClassInner1Int) ns::OuterClass::Inner1<int>;
%template(T_OuterClassInner2NormalClass) ns::OuterClass::Inner2<ns::NormalClass>;
%template(T_OuterClassInner2Int) ns::OuterClass::Inner2<int>;
+
+#else
+%extend ns::OuterClass {
+ %template(T_OutClsIn2Dbl) Inner2<double>;
+}
+
+%template(T_OutClsIn1Int) ns::OuterClass::Inner1<int>;
+%template(T_OutClsIn2NormCls) ns::OuterClass::Inner2<ns::NormalClass>;
+%template(T_OutClsIn2Int) ns::OuterClass::Inner2<int>;
+
+#endif
diff --git a/Examples/test-suite/template_template_parameters.i b/Examples/test-suite/template_template_parameters.i
index 0c3989603..89197229e 100644
--- a/Examples/test-suite/template_template_parameters.i
+++ b/Examples/test-suite/template_template_parameters.i
@@ -13,7 +13,7 @@
template<typename t_item, typename t2> class list_impl_t {};
template<typename t_item, template<typename> class t_alloc = pfc::alloc_fast >
- class list_t : public list_impl_t<t_item,pfc::array_t<t_item,t_alloc> > {
+ class list_tt : public list_impl_t<t_item,pfc::array_t<t_item,t_alloc> > {
public:
t_item item;
// typename t_alloc<t_item>::alloc_type allotype; // SWIG can't handle this yet
@@ -32,8 +32,8 @@ void TestInstantiations() {
%}
%template(ListImplFastBool) list_impl_t<bool, pfc::array_t<bool, pfc::alloc_fast> >;
-%template(ListFastBool) list_t<bool, pfc::alloc_fast>;
+%template(ListFastBool) list_tt<bool, pfc::alloc_fast>;
%template(ListImplFastDouble) list_impl_t<double, pfc::array_t<double, pfc::alloc_fast> >;
-%template(ListDefaultDouble) list_t<double>;
+%template(ListDefaultDouble) list_tt<double>;
diff --git a/Examples/test-suite/throw_exception.i b/Examples/test-suite/throw_exception.i
index c1ad945fb..396c633a6 100644
--- a/Examples/test-suite/throw_exception.i
+++ b/Examples/test-suite/throw_exception.i
@@ -16,15 +16,15 @@
%inline %{
-class Error {
+class CError {
};
-void test_is_Error(Error *r) {}
+void test_is_Error(CError *r) {}
namespace Namespace {
- typedef Error ErrorTypedef;
- typedef const Error& ErrorRef;
- typedef const Error* ErrorPtr;
+ typedef CError ErrorTypedef;
+ typedef const CError& ErrorRef;
+ typedef const CError* ErrorPtr;
typedef int IntArray[10];
enum EnumTest { enum1, enum2 };
}
@@ -36,26 +36,26 @@ public:
void test_msg() throw(const char *) {
throw "Dead";
}
- void test_cls() throw(Error) {
- throw Error();
+ void test_cls() throw(CError) {
+ throw CError();
}
- void test_cls_ptr() throw(Error *) {
- static Error StaticError;
+ void test_cls_ptr() throw(CError *) {
+ static CError StaticError;
throw &StaticError;
}
- void test_cls_ref() throw(Error &) {
- static Error StaticError;
+ void test_cls_ref() throw(CError &) {
+ static CError StaticError;
throw StaticError;
}
void test_cls_td() throw(Namespace::ErrorTypedef) {
- throw Error();
+ throw CError();
}
void test_cls_ptr_td() throw(Namespace::ErrorPtr) {
- static Error StaticError;
+ static CError StaticError;
throw &StaticError;
}
void test_cls_ref_td() throw(Namespace::ErrorRef) {
- static Error StaticError;
+ static CError StaticError;
throw StaticError;
}
void test_array() throw(Namespace::IntArray) {
@@ -68,10 +68,10 @@ public:
void test_enum() throw(Namespace::EnumTest) {
throw Namespace::enum2;
}
- void test_multi(int x) throw(int, const char *, Error) {
+ void test_multi(int x) throw(int, const char *, CError) {
if (x == 1) throw 37;
if (x == 2) throw "Dead";
- if (x == 3) throw Error();
+ if (x == 3) throw CError();
}
};
diff --git a/Examples/test-suite/typemap_array_qualifiers.i b/Examples/test-suite/typemap_array_qualifiers.i
index cbc6c95ff..c3965ced2 100644
--- a/Examples/test-suite/typemap_array_qualifiers.i
+++ b/Examples/test-suite/typemap_array_qualifiers.i
@@ -33,8 +33,10 @@
typedef SomeType myarray[3];
typedef const SomeType myconstarray[4];
typedef volatile SomeType ** mycrazyarray[5];
- typedef volatile SomeType (mycrazyfunc)(SomeType);
- typedef volatile SomeType (*mycrazyfuncptr)(SomeType);
+ extern "C" {
+ typedef volatile SomeType (mycrazyfunc)(SomeType);
+ typedef volatile SomeType (*mycrazyfuncptr)(SomeType);
+ }
%}
CLEAR_SWIGTYPE_TYPEMAPS;
diff --git a/Examples/test-suite/typemap_variables.i b/Examples/test-suite/typemap_variables.i
index 687cae1da..b1ae24fdf 100644
--- a/Examples/test-suite/typemap_variables.i
+++ b/Examples/test-suite/typemap_variables.i
@@ -63,6 +63,19 @@
%typemap(javain) int Space::Struct::smember "/*int smember in */ $javainput"
%typemap(javaout) int Space::Struct::smember "/*int smember out*/ { return $jnicall; }"
+#if defined(SWIGSCILAB)
+%clear int globul;
+%clear int Space::nspace;
+%clear int Space::Struct::smember;
+%ignore Space::Struct::member;
+%typemap(varin) int globul "TYPEMAP_VARIABLES_FAIL";
+%typemap(varout, noblock=1, fragment=SWIG_From_frag(int)) int globul "if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, SWIG_From_int($result)))) return SWIG_ERROR;";
+%typemap(varin) int Space::nspace "TYPEMAP_VARIABLES_FAIL";
+%typemap(varout, noblock=1, fragment=SWIG_From_frag(int)) int Space::nspace "if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, SWIG_From_int($result)))) return SWIG_ERROR;";
+%typemap(varin) int Space::Struct::smember "TYPEMAP_VARIABLES_FAIL";
+%typemap(varout, noblock=1, fragment=SWIG_From_frag(int)) int Space::Struct::smember "if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, SWIG_From_int($result)))) return SWIG_ERROR;";
+#endif
+
%inline %{
int globul;
diff --git a/Examples/test-suite/unions.i b/Examples/test-suite/unions.i
index 49bb85de4..405d28c67 100644
--- a/Examples/test-suite/unions.i
+++ b/Examples/test-suite/unions.i
@@ -8,7 +8,7 @@ This testcase checks that unions can be set and read.
/* Must undefine small to work on Windows. small is defined as a
char in rpcndr.h */
#ifdef small
-#undef small
+#undef small
#endif
%}
@@ -37,6 +37,12 @@ typedef struct {
SmallStruct small;
} uni;
int number;
-} EmbeddedUnionTest;
+}
+#if !defined(SWIGSCILAB)
+EmbeddedUnionTest;
+#else
+EmbedUnionTst;
+#endif
%}
+
diff --git a/Examples/test-suite/varargs_overload.i b/Examples/test-suite/varargs_overload.i
index 1ba00ba65..9a24e15a8 100644
--- a/Examples/test-suite/varargs_overload.i
+++ b/Examples/test-suite/varargs_overload.i
@@ -3,6 +3,8 @@
%module varargs_overload
%inline %{
+#include <stdio.h>
+
const char *vararg_over1(const char *fmt, ...) {
return fmt;
}
diff --git a/Examples/test-suite/voidtest.i b/Examples/test-suite/voidtest.i
index 90779e227..f0e649373 100644
--- a/Examples/test-suite/voidtest.i
+++ b/Examples/test-suite/voidtest.i
@@ -17,7 +17,5 @@ void *vfunc1(void *f) { return f; }
void *vfunc2(Foo *f) { return f; }
Foo *vfunc3(void *f) { return (Foo *) f; }
Foo *vfunc4(Foo *f) { return f; }
-
%}
-
diff --git a/Lib/csharp/enums.swg b/Lib/csharp/enums.swg
index 9b4acefc0..5cc265476 100644
--- a/Lib/csharp/enums.swg
+++ b/Lib/csharp/enums.swg
@@ -18,7 +18,7 @@
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
%{ static $*1_ltype temp = ($*1_ltype)$input;
$result = &temp; %}
-%typemap(directorin) const enum SWIGTYPE & "$input = $1;"
+%typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;"
%typemap(csdirectorin) const enum SWIGTYPE & "($*csclassname)$iminput"
%typemap(csdirectorout) const enum SWIGTYPE & "(int)$cscall"
@@ -51,7 +51,7 @@
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
-%typemap(directorin) enum SWIGTYPE "$input = $1;"
+%typemap(directorin) enum SWIGTYPE "$input = (int)$1;"
%typemap(csdirectorin) enum SWIGTYPE "($csclassname)$iminput"
%typemap(csdirectorout) enum SWIGTYPE "(int)$cscall"
diff --git a/Lib/csharp/enumsimple.swg b/Lib/csharp/enumsimple.swg
index 484443652..24e4bcf18 100644
--- a/Lib/csharp/enumsimple.swg
+++ b/Lib/csharp/enumsimple.swg
@@ -20,7 +20,7 @@
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
%{ static $*1_ltype temp = ($*1_ltype)$input;
$result = &temp; %}
-%typemap(directorin) const enum SWIGTYPE & "$input = $1;"
+%typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;"
%typemap(csdirectorin) const enum SWIGTYPE & "$iminput"
%typemap(csdirectorout) const enum SWIGTYPE & "$cscall"
@@ -53,7 +53,7 @@
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
-%typemap(directorin) enum SWIGTYPE "$input = $1;"
+%typemap(directorin) enum SWIGTYPE "$input = (int)$1;"
%typemap(csdirectorin) enum SWIGTYPE "$iminput"
%typemap(csdirectorout) enum SWIGTYPE "$cscall"
diff --git a/Lib/csharp/enumtypesafe.swg b/Lib/csharp/enumtypesafe.swg
index b7079343c..fd6801730 100644
--- a/Lib/csharp/enumtypesafe.swg
+++ b/Lib/csharp/enumtypesafe.swg
@@ -19,7 +19,7 @@
%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
%{ static $*1_ltype temp = ($*1_ltype)$input;
$result = &temp; %}
-%typemap(directorin) const enum SWIGTYPE & "$input = $1;"
+%typemap(directorin) const enum SWIGTYPE & "$input = (int)$1;"
%typemap(csdirectorin) const enum SWIGTYPE & "$*csclassname.swigToEnum($iminput)"
%typemap(csdirectorout) const enum SWIGTYPE & "$cscall.swigValue"
@@ -52,7 +52,7 @@
%typemap(out) enum SWIGTYPE %{ $result = (int)$1; %}
%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
-%typemap(directorin) enum SWIGTYPE "$input = $1;"
+%typemap(directorin) enum SWIGTYPE "$input = (int)$1;"
%typemap(csdirectorin) enum SWIGTYPE "$csclassname.swigToEnum($iminput)"
%typemap(csdirectorout) enum SWIGTYPE "$cscall.swigValue"
diff --git a/Lib/d/dhead.swg b/Lib/d/dhead.swg
index 786ca6e66..50e9c2e87 100644
--- a/Lib/d/dhead.swg
+++ b/Lib/d/dhead.swg
@@ -28,7 +28,7 @@ typedef enum {
SWIG_DIllegalArgumentException,
SWIG_DIllegalElementException,
SWIG_DIOException,
- SWIG_DNoSuchElementException,
+ SWIG_DNoSuchElementException
} SWIG_DExceptionCodes;
typedef void (* SWIG_DExceptionCallback_t)(const char *);
diff --git a/Lib/go/cdata.i b/Lib/go/cdata.i
index 9e6dc2161..b4411af97 100644
--- a/Lib/go/cdata.i
+++ b/Lib/go/cdata.i
@@ -8,16 +8,47 @@
typedef struct SWIGCDATA {
char *data;
intgo len;
- intgo cap;
} SWIGCDATA;
%}
-%typemap(gotype) SWIGCDATA %{ []byte %}
-%typemap(out) SWIGCDATA %{
- $result.data = (char*)_swig_goallocate($1.len);
- memcpy($result.data, $1.data, $1.len);
- $result.len = (intgo)$1.len;
- $result.cap = $result.len;
+%fragment("cdata", "header") %{
+struct swigcdata {
+ intgo size;
+ void *data;
+};
+%}
+
+%typemap(gotype) SWIGCDATA "[]byte"
+
+%typemap(imtype) SWIGCDATA "uint64"
+
+%typemap(out, fragment="cdata") SWIGCDATA(struct swigcdata *swig_out) %{
+ swig_out = (struct swigcdata *)malloc(sizeof(*swig_out));
+ if (swig_out) {
+ swig_out->size = $1.len;
+ swig_out->data = malloc(swig_out->size);
+ if (swig_out->data) {
+ memcpy(swig_out->data, $1.data, swig_out->size);
+ }
+ }
+ $result = *(long long *)(void **)&swig_out;
+%}
+
+%typemap(goout) SWIGCDATA %{
+ {
+ type swigcdata struct { size int; data uintptr }
+ p := (*swigcdata)(unsafe.Pointer(uintptr($1)))
+ if p == nil || p.data == 0 {
+ $result = nil
+ } else {
+ b := make([]byte, p.size)
+ a := (*[0x7fffffff]byte)(unsafe.Pointer(p.data))[:p.size]
+ copy(b, a)
+ Swig_free(p.data)
+ Swig_free(uintptr(unsafe.Pointer(p)))
+ $result = b
+ }
+ }
%}
/* -----------------------------------------------------------------------------
diff --git a/Lib/go/go.swg b/Lib/go/go.swg
index c680844c4..d38623b4a 100644
--- a/Lib/go/go.swg
+++ b/Lib/go/go.swg
@@ -4,6 +4,8 @@
* Go configuration module.
* ------------------------------------------------------------ */
+%include <gostring.swg>
+
/* Code insertion directives */
#define %go_import(...) %insert(go_imports) %{__VA_ARGS__%}
@@ -75,6 +77,22 @@
double
%{ $result = $1; %}
+%typemap(goout) bool,
+ char,
+ signed char,
+ unsigned char,
+ short,
+ unsigned short,
+ int,
+ unsigned int,
+ long,
+ unsigned long,
+ long long,
+ unsigned long long,
+ float,
+ double
+""
+
%typemap(out) const bool &,
const char &,
const signed char &,
@@ -91,8 +109,26 @@
const double &
%{ $result = ($*1_ltype)*$1; %}
+%typemap(goout) const bool &,
+ const char &,
+ const signed char &,
+ const unsigned char &,
+ const short &,
+ const unsigned short &,
+ const int &,
+ const unsigned int &,
+ const long &,
+ const unsigned long &,
+ const long long &,
+ const unsigned long long &,
+ const float &,
+ const double &
+""
+
%typemap(out) void ""
+%typemap(goout) void ""
+
%typemap(directorin) bool,
char,
signed char,
@@ -109,6 +145,22 @@
double
%{ $input = ($1_ltype)$1; %}
+%typemap(godirectorin) bool,
+ char,
+ signed char,
+ unsigned char,
+ short,
+ unsigned short,
+ int,
+ unsigned int,
+ long,
+ unsigned long,
+ long long,
+ unsigned long long,
+ float,
+ double
+""
+
%typemap(directorin) const bool &,
const char &,
const signed char &,
@@ -125,6 +177,22 @@
const double &
%{ $input = ($*1_ltype)$1; %}
+%typemap(godirectorin) const bool &,
+ const char &,
+ const signed char &,
+ const unsigned char &,
+ const short &,
+ const unsigned short &,
+ const int &,
+ const unsigned int &,
+ const long &,
+ const unsigned long &,
+ const long long &,
+ const unsigned long long &,
+ const float &,
+ const double &
+""
+
%typemap(directorout) bool,
char,
signed char,
@@ -141,7 +209,7 @@
double
%{ $result = ($1_ltype)$input; %}
-%typemap(directorout) const bool &,
+%typemap(directorout,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const bool &,
const char &,
const signed char &,
const unsigned char &,
@@ -156,8 +224,8 @@
const float &,
const double &
%{
- $result = ($1_ltype)_swig_goallocate(sizeof($*1_ltype));
- *$result = *($1_ltype)&$input;
+ $result = new $*1_ltype($input);
+ swig_acquire_pointer(&swig_mem, $result);
%}
/* The size_t type. */
@@ -173,22 +241,30 @@
%typemap(out) size_t
%{ $result = $1; %}
+%typemap(goout) size_t ""
+
%typemap(out) const size_t &
%{ $result = ($*1_ltype)*$1; %}
+%typemap(goout) const size_t & ""
+
%typemap(directorin) size_t
%{ $input = (size_t)$1; %}
+%typemap(godirectorin) size_t ""
+
%typemap(directorin) const size_t &
%{ $input = ($*1_ltype)$1; %}
+%typemap(godirectorin) const size_t & ""
+
%typemap(directorout) size_t
%{ $result = ($1_ltype)$input; %}
-%typemap(directorout) const size_t &
+%typemap(directorout,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) const size_t &
%{
- $result = ($1_ltype)_swig_goallocate(sizeof($*1_ltype));
- *$result = *($1_ltype)$input;
+ $result = new $*1_ltype($input);
+ swig_acquire_pointer(&swig_mem, $result);
%}
/* Member pointers. */
@@ -201,17 +277,45 @@
%typemap(out) SWIGTYPE (CLASS::*)
%{
- $result = _swig_goallocate(sizeof($1_ltype));
- *($&1_ltype)$result = $1;
+ struct swig_out_type { intgo size; void* val; } *swig_out;
+ swig_out = (struct swig_out_type*)malloc(sizeof(*swig_out));
+ if (swig_out) {
+ swig_out->size = sizeof($1_ltype);
+ swig_out->val = malloc(swig_out->size);
+ if (swig_out->val) {
+ *($&1_ltype)(swig_out->val) = $1;
+ }
+ }
+ $result = swig_out;
+%}
+
+%typemap(goout) SWIGTYPE (CLASS::*)
+%{
+ {
+ type swig_out_type struct { size int; val uintptr }
+ p := (*swig_out_type)(unsafe.Pointer($1))
+ if p == nil || p.val == 0 {
+ $result = nil
+ } else {
+ m := make([]byte, p.size)
+ a := (*[1024]byte)(unsafe.Pointer(p.val))[:p.size]
+ copy(m, a)
+ Swig_free(p.val)
+ Swig_free(uintptr(unsafe.Pointer(p)))
+ $result = &m[0]
+ }
+ }
%}
%typemap(directorin) SWIGTYPE (CLASS::*)
%{ $input = *($&1_ltype)$1; %}
+%typemap(godirectorin) SWIGTYPE (CLASS::*) ""
+
%typemap(directorout) SWIGTYPE (CLASS::*)
%{
- $result = _swig_goallocate(sizeof($1_ltype));
- *($&1_ltype)$result = $input;
+ $result = new $1_ltype($input);
+ swig_acquire_pointer(&swig_mem, $result);
%}
/* Pointers. */
@@ -227,9 +331,13 @@
%typemap(out) SWIGTYPE *
%{ *($&1_ltype)&$result = ($1_ltype)$1; %}
+%typemap(goout) SWIGTYPE * ""
+
%typemap(directorin) SWIGTYPE *
%{ *($&1_ltype)&$input = ($1_ltype)$1; %}
+%typemap(godirectorin) SWIGTYPE * ""
+
%typemap(directorout) SWIGTYPE *
%{ $result = *($&1_ltype)&$input; %}
@@ -249,6 +357,8 @@
%typemap(out) SWIGTYPE *const&
%{ *($1_ltype)&$result = *$1; %}
+%typemap(goout) SWIGTYPE *const& ""
+
/* References. */
/* Converting a C++ reference to Go has to be handled in the C++
@@ -262,9 +372,13 @@
%typemap(out) SWIGTYPE &
%{ *($&1_ltype)&$result = $1; %}
+%typemap(goout) SWIGTYPE & ""
+
%typemap(directorin) SWIGTYPE &
%{ $input = ($1_ltype)&$1; %}
+%typemap(godirectorin) SWIGTYPE & ""
+
%typemap(directorout) SWIGTYPE &
%{ *($&1_ltype)&$result = $input; %}
@@ -277,9 +391,13 @@
%typemap(out) SWIGTYPE &&
%{ *($&1_ltype)&$result = $1; %}
+%typemap(goout) SWIGTYPE && ""
+
%typemap(directorin) SWIGTYPE &&
%{ $input = ($1_ltype)&$1_name; %}
+%typemap(godirectorin) SWIGTYPE && ""
+
%typemap(directorout) SWIGTYPE &&
%{ *($&1_ltype)&$result = $input; %}
@@ -295,9 +413,13 @@
%typemap(out) SWIGTYPE []
%{ *($&1_ltype)&$result = $1; %}
+%typemap(goout) SWIGTYPE [] ""
+
%typemap(directorin) SWIGTYPE []
%{ $input = *($1_ltype)&$1; %}
+%typemap(godirectorin) SWIGTYPE [] ""
+
%typemap(directorout) SWIGTYPE []
%{ *($&1_ltype)&$result = $input; %}
@@ -323,18 +445,32 @@
%typemap(in) char *&, signed char *&, unsigned char *&
%{ $1 = ($1_ltype)$input.p; %}
-%typemap(out)
+%typemap(out,fragment="AllocateString")
+ char *, char *&, char[ANY], char[],
+ signed char *, signed char *&, signed char[ANY], signed char[],
+ unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
+%{ $result = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0); %}
+
+%typemap(goout,fragment="CopyString")
char *, char *&, char[ANY], char[],
signed char *, signed char *&, signed char[ANY], signed char[],
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
-%{ $result = _swig_makegostring((char*)$1, $1 ? strlen((char*)$1) : 0); %}
+%{ $result = swigCopyString($1) %}
-%typemap(directorin)
+%typemap(directorin,fragment="AllocateString")
char *, char *&, char[ANY], char[],
signed char *, signed char *&, signed char[ANY], signed char[],
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
%{
- $input = _swig_makegostring((char*)$1, $1 ? strlen((char*)$1) : 0);
+ $input = Swig_AllocateString((char*)$1, $1 ? strlen((char*)$1) : 0);
+%}
+
+%typemap(godirectorin,fragment="CopyString")
+ char *, char *&, char[ANY], char[],
+ signed char *, signed char *&, signed char[ANY], signed char[],
+ unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
+%{
+ $result = swigCopyString($input)
%}
%typemap(directorout)
@@ -353,11 +489,17 @@
$2 = ($2_ltype)$input.n;
%}
-%typemap(out) (char *STRING, size_t LENGTH)
-%{ $result = _swig_makegostring((char*)$1, (size_t)$2); %}
+%typemap(out,fragment="AllocateString") (char *STRING, size_t LENGTH)
+%{ $result = Swig_AllocateString((char*)$1, (size_t)$2); %}
-%typemap(directorin) (char *STRING, size_t LENGTH)
-%{ $input = _swig_makegostring((char*)$1, $2); %}
+%typemap(goout,fragment="CopyString") (char *STRING, size_t LENGTH)
+%{ $result = swigCopyString($1) %}
+
+%typemap(directorin,fragment="AllocateString") (char *STRING, size_t LENGTH)
+%{ $input = Swig_AllocateString((char*)$1, $2); %}
+
+%typemap(godirectorin,fragment="CopyString") (char *STRING, size_t LENGTH)
+%{ $result = swigCopyString($input) %}
%typemap(directorout) (char *STRING, size_t LENGTH)
%{
@@ -378,8 +520,12 @@
%typemap(out) enum SWIGTYPE
%{ $result = (intgo)$1; %}
+%typemap(goout) enum SWIGTYPE ""
+
%typemap(directorin) enum SWIGTYPE
-%{ $input = ($1_ltype)$1; %}
+%{ $input = (intgo)$1; %}
+
+%typemap(godirectorin) enum SWIGTYPE ""
%typemap(directorout) enum SWIGTYPE
%{ $result = ($1_ltype)$input; %}
@@ -390,6 +536,8 @@
$input = &e;
%}
+%typemap(godirectorin) enum SWIGTYPE & ""
+
%typemap(directorout) enum SWIGTYPE &
%{
$*1_ltype f = ($*1_ltype)*$input;
@@ -423,9 +571,13 @@
}
#endif
+%typemap(goout) SWIGTYPE ""
+
%typemap(directorin) SWIGTYPE
%{ $input = ($&1_ltype)&$1; %}
+%typemap(godirectorin) SWIGTYPE ""
+
%typemap(directorout) SWIGTYPE
%{ $result = *($&1_ltype)$input; %}
diff --git a/Lib/go/goruntime.swg b/Lib/go/goruntime.swg
index ef64186b7..19ccf5ae9 100644
--- a/Lib/go/goruntime.swg
+++ b/Lib/go/goruntime.swg
@@ -4,6 +4,12 @@
* Go runtime code for the various generated files.
* ------------------------------------------------------------ */
+%inline %{
+static void Swig_free(void* p) {
+ free(p);
+}
+%}
+
%insert(runtime) %{
#include <stddef.h>
#include <stdio.h>
@@ -242,3 +248,72 @@ var Swig_escape_val interface{}
type _swig_fnptr *byte
type _swig_memberptr *byte
%}
+
+/* Handle memory management for directors. */
+
+%insert(director) %{
+#include <map>
+
+namespace {
+ struct GCItem {
+ virtual ~GCItem() {}
+ };
+
+ struct GCItem_var {
+ GCItem_var(GCItem *item = 0) : _item(item) {
+ }
+
+ GCItem_var& operator=(GCItem *item) {
+ GCItem *tmp = _item;
+ _item = item;
+ delete tmp;
+ return *this;
+ }
+
+ ~GCItem_var() {
+ delete _item;
+ }
+
+ GCItem* operator->() {
+ return _item;
+ }
+
+ private:
+ GCItem *_item;
+ };
+
+ template <typename Type>
+ struct GCItem_T : GCItem {
+ GCItem_T(Type *ptr) : _ptr(ptr) {
+ }
+
+ virtual ~GCItem_T() {
+ delete _ptr;
+ }
+
+ private:
+ Type *_ptr;
+ };
+}
+
+class Swig_memory {
+public:
+ template <typename Type>
+ void swig_acquire_pointer(Type* vptr) {
+ if (vptr) {
+ swig_owner[vptr] = new GCItem_T<Type>(vptr);
+ }
+ }
+private:
+ typedef std::map<void *, GCItem_var> swig_ownership_map;
+ swig_ownership_map swig_owner;
+};
+
+template <typename Type>
+static void swig_acquire_pointer(Swig_memory** pmem, Type* ptr) {
+ if (!pmem) {
+ *pmem = new Swig_memory;
+ }
+ (*pmem)->swig_acquire_pointer(ptr);
+}
+%}
diff --git a/Lib/go/gostring.swg b/Lib/go/gostring.swg
new file mode 100644
index 000000000..44cbbb8ee
--- /dev/null
+++ b/Lib/go/gostring.swg
@@ -0,0 +1,29 @@
+/* ------------------------------------------------------------
+ * gostring.swg
+ *
+ * Support for returning strings from C to Go.
+ * ------------------------------------------------------------ */
+
+// C/C++ code to convert a memory buffer into a Go string allocated in
+// C/C++ memory.
+%fragment("AllocateString", "runtime") %{
+static _gostring_ Swig_AllocateString(const char *p, size_t l) {
+ _gostring_ ret;
+ ret.p = (char*)malloc(l);
+ memcpy(ret.p, p, l);
+ ret.n = l;
+ return ret;
+}
+%}
+
+// Go code to convert a string allocated in C++ memory to one
+// allocated in Go memory.
+%fragment("CopyString", "go_runtime") %{
+type swig_gostring struct { p uintptr; n int }
+func swigCopyString(s string) string {
+ p := *(*swig_gostring)(unsafe.Pointer(&s))
+ r := string((*[0x7fffffff]byte)(unsafe.Pointer(p.p))[:p.n])
+ Swig_free(p.p)
+ return r
+}
+%}
diff --git a/Lib/go/std_string.i b/Lib/go/std_string.i
index 9922fbe13..068c688cb 100644
--- a/Lib/go/std_string.i
+++ b/Lib/go/std_string.i
@@ -27,11 +27,17 @@ class string;
%typemap(directorout) string
%{ $result.assign($input.p, $input.n); %}
-%typemap(out) string
-%{ $result = _swig_makegostring($1.data(), $1.length()); %}
+%typemap(out,fragment="AllocateString") string
+%{ $result = Swig_AllocateString($1.data(), $1.length()); %}
-%typemap(directorin) string
-%{ $input = _swig_makegostring($1.data(), $1.length()); %}
+%typemap(goout,fragment="CopyString") string
+%{ $result = swigCopyString($1) %}
+
+%typemap(directorin,fragment="AllocateString") string
+%{ $input = Swig_AllocateString($1.data(), $1.length()); %}
+
+%typemap(godirectorin,fragment="CopyString") string
+%{ $result = swigCopyString($input) %}
%typemap(in) const string &
%{
@@ -46,10 +52,16 @@ class string;
$result = &$1_str;
%}
-%typemap(out) const string &
-%{ $result = _swig_makegostring((*$1).data(), (*$1).length()); %}
+%typemap(out,fragment="AllocateString") const string &
+%{ $result = Swig_AllocateString((*$1).data(), (*$1).length()); %}
+
+%typemap(goout,fragment="CopyString") const string &
+%{ $result = swigCopyString($1) %}
+
+%typemap(directorin,fragment="AllocateString") const string &
+%{ $input = Swig_AllocateString($1.data(), $1.length()); %}
-%typemap(directorin) const string &
-%{ $input = _swig_makegostring($1.data(), $1.length()); %}
+%typemap(godirectorin,fragment="CopyString") const string &
+%{ $result = swigCopyString($input) %}
}
diff --git a/Lib/go/typemaps.i b/Lib/go/typemaps.i
index c339fb37e..d2e60d37c 100644
--- a/Lib/go/typemaps.i
+++ b/Lib/go/typemaps.i
@@ -67,6 +67,8 @@ char * typemaps instead:
%typemap(out) TYPE *INPUT, TYPE &INPUT ""
+%typemap(goout) TYPE *INPUT, TYPE &INPUT ""
+
%typemap(freearg) TYPE *INPUT, TYPE &INPUT ""
%typemap(argout) TYPE *INPUT, TYPE &INPUT ""
@@ -167,6 +169,8 @@ char * typemaps instead:
%typemap(out) TYPE *OUTPUT, TYPE &OUTPUT ""
+%typemap(goout) TYPE *INPUT, TYPE &INPUT ""
+
%typemap(freearg) TYPE *OUTPUT, TYPE &OUTPUT ""
%typemap(argout) TYPE *OUTPUT, TYPE &OUTPUT
@@ -268,6 +272,8 @@ char * typemaps instead:
%typemap(out) TYPE *INOUT, TYPE &INOUT ""
+%typemap(goout) TYPE *INOUT, TYPE &INOUT ""
+
%typemap(freearg) TYPE *INOUT, TYPE &INOUT ""
%typemap(argout) TYPE *INOUT, TYPE &INOUT ""
diff --git a/Lib/java/java.swg b/Lib/java/java.swg
index 98524e85e..e7e041d13 100644
--- a/Lib/java/java.swg
+++ b/Lib/java/java.swg
@@ -1181,7 +1181,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%typemap(javabody) TYPE *, TYPE &, TYPE &&, TYPE [] %{
private long swigCPtr;
- PTRCTOR_VISIBILITY $javaclassname(long cPtr, boolean futureUse) {
+ PTRCTOR_VISIBILITY $javaclassname(long cPtr, @SuppressWarnings("unused") boolean futureUse) {
swigCPtr = cPtr;
}
@@ -1197,7 +1197,7 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
%typemap(javabody) TYPE (CLASS::*) %{
private String swigCMemberPtr;
- PTRCTOR_VISIBILITY $javaclassname(String cMemberPtr, boolean futureUse) {
+ PTRCTOR_VISIBILITY $javaclassname(String cMemberPtr, @SuppressWarnings("unused") boolean futureUse) {
swigCMemberPtr = cMemberPtr;
}
diff --git a/Lib/javascript/jsc/javascriptcode.swg b/Lib/javascript/jsc/javascriptcode.swg
index 672df8677..d7f5f5212 100644
--- a/Lib/javascript/jsc/javascriptcode.swg
+++ b/Lib/javascript/jsc/javascriptcode.swg
@@ -402,6 +402,7 @@ static JSStaticFunction $jsnspace_functions[] = {
};
static JSClassDefinition $jsnspace_classDefinition;
+static JSObjectRef $jsmangledname_object;
%}
/* -----------------------------------------------------------------------------
@@ -412,7 +413,7 @@ static JSClassDefinition $jsnspace_classDefinition;
%{
$jsmangledname_classDefinition.staticFunctions = $jsmangledname_functions;
$jsmangledname_classDefinition.staticValues = $jsmangledname_values;
- JSObjectRef $jsmangledname_object = JSObjectMake(context, JSClassCreate(&$jsmangledname_classDefinition), NULL);
+ $jsmangledname_object = JSObjectMake(context, JSClassCreate(&$jsmangledname_classDefinition), NULL);
%}
/* -----------------------------------------------------------------------------
diff --git a/Lib/javascript/jsc/javascriptprimtypes.swg b/Lib/javascript/jsc/javascriptprimtypes.swg
index 7e9898a24..814805b95 100644
--- a/Lib/javascript/jsc/javascriptprimtypes.swg
+++ b/Lib/javascript/jsc/javascriptprimtypes.swg
@@ -76,11 +76,12 @@ SWIG_From_dec(unsigned long)(unsigned long value)
SWIGINTERN int
SWIG_AsVal_dec(unsigned long)(JSValueRef obj, unsigned long *val)
{
+ long longVal;
if(!JSValueIsNumber(context, obj)) {
return SWIG_TypeError;
}
- long longVal = (long) JSValueToNumber(context, obj, NULL);
+ longVal = (long) JSValueToNumber(context, obj, NULL);
if(longVal < 0) {
return SWIG_OverflowError;
@@ -142,11 +143,12 @@ SWIG_From_dec(unsigned long long)(unsigned long long value)
SWIGINTERN int
SWIG_AsVal_dec(unsigned long long)(JSValueRef obj, unsigned long long *val)
{
+ long long longVal;
if(!JSValueIsNumber(context, obj)) {
return SWIG_TypeError;
}
- long long longVal = (unsigned long long) JSValueToNumber(context, obj, NULL);
+ longVal = (unsigned long long) JSValueToNumber(context, obj, NULL);
if(longVal < 0) {
return SWIG_OverflowError;
diff --git a/Lib/javascript/jsc/javascriptstrings.swg b/Lib/javascript/jsc/javascriptstrings.swg
index b3f46ae41..55c8e4b98 100644
--- a/Lib/javascript/jsc/javascriptstrings.swg
+++ b/Lib/javascript/jsc/javascriptstrings.swg
@@ -52,6 +52,7 @@ SWIG_JSC_FromCharPtrAndSize(JSContextRef context, const char* carray, size_t siz
return JSValueMakeUndefined(context);
} else {
JSStringRef jsstring;
+ JSValueRef result;
if(size < 2) {
char c[2];
int i;
@@ -63,7 +64,7 @@ SWIG_JSC_FromCharPtrAndSize(JSContextRef context, const char* carray, size_t siz
} else {
jsstring = JSStringCreateWithUTF8CString(carray);
}
- JSValueRef result = JSValueMakeString(context, jsstring);
+ result = JSValueMakeString(context, jsstring);
JSStringRelease(jsstring);
return result;
}
diff --git a/Lib/lua/lua.swg b/Lib/lua/lua.swg
index 60e418596..892d15798 100644
--- a/Lib/lua/lua.swg
+++ b/Lib/lua/lua.swg
@@ -44,6 +44,9 @@
%typemap(consttab) SWIGTYPE *, SWIGTYPE *const, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE []
{ SWIG_LUA_CONSTTAB_POINTER("$symname",$value, $1_descriptor) }
+%typemap(consttab) SWIGTYPE
+ { SWIG_LUA_CONSTTAB_POINTER("$symname",&$value, $&1_descriptor) }
+
// member function pointers
%typemap(consttab) SWIGTYPE (CLASS::*)
{ SWIG_LUA_CONSTTAB_BINARY("$symname", sizeof($type),&$value, $1_descriptor) }
diff --git a/Lib/lua/luarun.swg b/Lib/lua/luarun.swg
index 8803c66f6..d9124887d 100644
--- a/Lib/lua/luarun.swg
+++ b/Lib/lua/luarun.swg
@@ -1161,7 +1161,7 @@ SWIGINTERN void SWIG_Lua_init_base_class(lua_State *L,swig_lua_class *clss)
#if defined(SWIG_LUA_SQUASH_BASES) && (SWIG_LUA_TARGET == SWIG_LUA_FLAVOR_LUA)
/* Merges two tables */
-SWIGINTERN int SWIG_Lua_merge_tables_by_index(lua_State *L, int target, int source)
+SWIGINTERN void SWIG_Lua_merge_tables_by_index(lua_State *L, int target, int source)
{
/* iterating */
lua_pushnil(L);
@@ -1177,7 +1177,7 @@ SWIGINTERN int SWIG_Lua_merge_tables_by_index(lua_State *L, int target, int sour
}
/* Merges two tables with given name. original - index of target metatable, base - index of source metatable */
-SWIGINTERN int SWIG_Lua_merge_tables(lua_State *L, const char* name, int original, int base)
+SWIGINTERN void SWIG_Lua_merge_tables(lua_State *L, const char* name, int original, int base)
{
/* push original[name], then base[name] */
lua_pushstring(L,name);
@@ -1192,7 +1192,7 @@ SWIGINTERN int SWIG_Lua_merge_tables(lua_State *L, const char* name, int origina
}
/* Function takes all symbols from base and adds it to derived class. It's just a helper. */
-SWIGINTERN int SWIG_Lua_class_squash_base(lua_State *L, swig_lua_class *base_cls)
+SWIGINTERN void SWIG_Lua_class_squash_base(lua_State *L, swig_lua_class *base_cls)
{
/* There is one parameter - original, i.e. 'derived' class metatable */
assert(lua_istable(L,-1));
@@ -1206,7 +1206,7 @@ SWIGINTERN int SWIG_Lua_class_squash_base(lua_State *L, swig_lua_class *base_cls
}
/* Function squashes all symbols from 'clss' bases into itself */
-SWIGINTERN int SWIG_Lua_class_squash_bases(lua_State *L, swig_lua_class *clss)
+SWIGINTERN void SWIG_Lua_class_squash_bases(lua_State *L, swig_lua_class *clss)
{
int i;
SWIG_Lua_get_class_metatable(L,clss->fqname);
diff --git a/Lib/octave/boost_shared_ptr.i b/Lib/octave/boost_shared_ptr.i
index 93b1a896f..052d48bb0 100644
--- a/Lib/octave/boost_shared_ptr.i
+++ b/Lib/octave/boost_shared_ptr.i
@@ -29,7 +29,8 @@
}
}
%typemap(out) CONST TYPE {
- %set_output(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
}
%typemap(varin) CONST TYPE {
@@ -47,7 +48,8 @@
}
}
%typemap(varout) CONST TYPE {
- %set_varoutput(SWIG_NewPointerObj(new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
}
// plain pointer
diff --git a/Lib/octave/octrun.swg b/Lib/octave/octrun.swg
index dc9b6b6e6..b5c3e5d86 100644
--- a/Lib/octave/octrun.swg
+++ b/Lib/octave/octrun.swg
@@ -578,26 +578,40 @@ SWIGRUNTIME void swig_acquire_ownership_obj(void *vptr, int own);
swig_member_const_iterator swig_members_begin() { return members.begin(); }
swig_member_const_iterator swig_members_end() { return members.end(); }
- void *cast(swig_type_info *type, int *_own, int flags) {
+ int cast(void **vptr, swig_type_info *type, int *_own, int flags) {
+ int res = SWIG_ERROR;
if (_own)
*_own = own;
if (flags &SWIG_POINTER_DISOWN)
own = 0;
- if (!type && types.size())
- return types[0].second.ptr;
+ if (!type && types.size()) {
+ if(vptr)
+ *vptr = types[0].second.ptr;
+ return SWIG_OK;
+ }
for (unsigned int j = 0; j < types.size(); ++j)
- if (type == types[j].first)
- return types[j].second.ptr;
+ if (type == types[j].first) {
+ if(vptr)
+ *vptr = types[j].second.ptr;
+ return SWIG_OK;
+ }
for (unsigned int j = 0; j < types.size(); ++j) {
swig_cast_info *tc = SWIG_TypeCheck(types[j].first->name, type);
if (!tc)
continue;
- int newmemory = 0;
- void *vptr = SWIG_TypeCast(tc, types[j].second.ptr, &newmemory);
- assert(!newmemory); // newmemory handling not yet implemented
- return vptr;
+ if(vptr) {
+ int newmemory = 0;
+ *vptr = SWIG_TypeCast(tc, types[j].second.ptr, &newmemory);
+ if (newmemory == SWIG_CAST_NEW_MEMORY) {
+ assert(_own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
+ if (_own)
+ *_own = *_own | SWIG_CAST_NEW_MEMORY;
+ }
+ }
+ res = SWIG_OK;
+ break;
}
- return 0;
+ return res;
}
bool is_owned() const {
@@ -1327,12 +1341,7 @@ SWIGRUNTIME int SWIG_Octave_ConvertPtrAndOwn(octave_value ov, void **ptr, swig_t
return SWIG_ERROR;
octave_swig_ref *osr = static_cast < octave_swig_ref *>(ov.internal_rep());
octave_swig_type *ost = osr->get_ptr();
- void *vptr = ost->cast(type, own, flags);
- if (!vptr)
- return SWIG_ERROR;
- if (ptr)
- *ptr = vptr;
- return SWIG_OK;
+ return ost->cast(ptr, type, own, flags);
}
SWIGRUNTIME octave_value SWIG_Octave_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
diff --git a/Lib/octave/std_shared_ptr.i b/Lib/octave/std_shared_ptr.i
new file mode 100644
index 000000000..df873679c
--- /dev/null
+++ b/Lib/octave/std_shared_ptr.i
@@ -0,0 +1,2 @@
+#define SWIG_SHARED_PTR_NAMESPACE std
+%include <boost_shared_ptr.i>
diff --git a/Lib/perl5/perlinit.swg b/Lib/perl5/perlinit.swg
index d9ffa9bf8..cdb73d53a 100644
--- a/Lib/perl5/perlinit.swg
+++ b/Lib/perl5/perlinit.swg
@@ -21,7 +21,7 @@ SWIGEXPORT void SWIG_init (CV *cv, CPerlObj *);
%init %{
-#ifdef __cplusplus
+#if defined(__cplusplus) && ! defined(XSPROTO)
extern "C"
#endif
diff --git a/Lib/php/director.swg b/Lib/php/director.swg
index 1338ff5fc..b28df607c 100644
--- a/Lib/php/director.swg
+++ b/Lib/php/director.swg
@@ -101,8 +101,7 @@ namespace Swig {
TSRMLS_SET_CTX(swig_zts_ctx);
}
- bool swig_is_overridden_method(char *cname, char *lc_fname) {
- TSRMLS_FETCH_FROM_CTX(swig_zts_ctx);
+ static bool swig_is_overridden_method(char *cname, char *lc_fname TSRMLS_DC) {
zend_class_entry **ce;
zend_function *mptr;
diff --git a/Lib/pointer.i b/Lib/pointer.i
index 8015317d7..ea8e535ab 100644
--- a/Lib/pointer.i
+++ b/Lib/pointer.i
@@ -4,7 +4,7 @@
%echo "pointer.i is deprecated. Use cpointer.i instead."
-%echo "See http://www.swig.org/Doc1.3/Library.html"
+%echo "See http://www.swig.org/Doc3.0/Library.html"
diff --git a/Lib/python/pyinit.swg b/Lib/python/pyinit.swg
index b44c2c893..47d3d9700 100644
--- a/Lib/python/pyinit.swg
+++ b/Lib/python/pyinit.swg
@@ -375,6 +375,7 @@ SWIG_init(void) {
PyObject *public_interface, *public_symbol;
PyObject *this_descr;
PyObject *thisown_descr;
+ PyObject *self = 0;
int i;
(void)builtin_pytype;
@@ -382,6 +383,7 @@ SWIG_init(void) {
(void)builtin_basetype;
(void)tuple;
(void)static_getset;
+ (void)self;
/* metatype is used to implement static member variables. */
metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type);
@@ -401,6 +403,7 @@ SWIG_init(void) {
#else
m = Py_InitModule((char *) SWIG_name, SwigMethods);
#endif
+
md = d = PyModule_GetDict(m);
(void)md;
diff --git a/Lib/python/pyuserdir.swg b/Lib/python/pyuserdir.swg
index d3c3eb188..00aec07d5 100644
--- a/Lib/python/pyuserdir.swg
+++ b/Lib/python/pyuserdir.swg
@@ -185,7 +185,6 @@ These methods "may be called" if needed.
#define %clearpythonappend %feature("pythonappend","")
-
/* ------------------------------------------------------------------------- */
/*
%extend_smart_pointer extend the smart pointer support.
diff --git a/Lib/scilab/boost_shared_ptr.i b/Lib/scilab/boost_shared_ptr.i
new file mode 100644
index 000000000..095b7fe43
--- /dev/null
+++ b/Lib/scilab/boost_shared_ptr.i
@@ -0,0 +1,318 @@
+%include <shared_ptr.i>
+
+// Set SHARED_PTR_DISOWN to $disown if required, for example
+// #define SHARED_PTR_DISOWN $disown
+#if !defined(SHARED_PTR_DISOWN)
+#define SHARED_PTR_DISOWN 0
+#endif
+
+// Language specific macro implementing all the customisations for handling the smart pointer
+%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
+
+// %naturalvar is as documented for member variables
+%naturalvar TYPE;
+%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+
+// destructor wrapper customisation
+%feature("unref") TYPE
+//"if (debug_shared) { cout << \"deleting use_count: \" << (*smartarg1).use_count() << \" [\" << (boost::get_deleter<SWIG_null_deleter>(*smartarg1) ? std::string(\"CANNOT BE DETERMINED SAFELY\") : ( (*smartarg1).get() ? (*smartarg1)->getValue() : std::string(\"NULL PTR\") )) << \"]\" << endl << flush; }\n"
+ "(void)arg1; delete smartarg1;"
+
+// Typemap customisations...
+
+// plain value
+%typemap(in) CONST TYPE (void *argp, int res = 0) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) {
+ %argument_nullref("$type", $symname, $argnum);
+ } else {
+ $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get());
+ if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ }
+}
+%typemap(out) CONST TYPE {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) CONST TYPE {
+ void *argp = 0;
+ int newmem = 0;
+ int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ if (!argp) {
+ %argument_nullref("$type", $symname, $argnum);
+ } else {
+ $1 = *(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get());
+ if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ }
+}
+%typemap(varout) CONST TYPE {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1));
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+// plain pointer
+// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance
+%typemap(in) CONST TYPE * (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = %const_cast(tempshared.get(), $1_ltype);
+ } else {
+ smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype);
+ }
+}
+
+%typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE * {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), $owner | SWIG_POINTER_OWN));
+}
+
+%typemap(varin) CONST TYPE * {
+ void *argp = 0;
+ int newmem = 0;
+ int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared;
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0;
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = %const_cast(tempshared.get(), $1_ltype);
+ } else {
+ smartarg = %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = %const_cast((smartarg ? smartarg->get() : 0), $1_ltype);
+ }
+}
+%typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE * {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_0) : 0;
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+// plain reference
+%typemap(in) CONST TYPE & (void *argp = 0, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) { %argument_nullref("$type", $symname, $argnum); }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = %const_cast(tempshared.get(), $1_ltype);
+ } else {
+ $1 = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype);
+ }
+}
+%typemap(out, fragment="SWIG_null_deleter_python") CONST TYPE & {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner);
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) CONST TYPE & {
+ void *argp = 0;
+ int newmem = 0;
+ int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared;
+ if (!argp) { %argument_nullref("$type", $symname, $argnum); }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ $1 = *%const_cast(tempshared.get(), $1_ltype);
+ } else {
+ $1 = *%const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $1_ltype);
+ }
+}
+%typemap(varout, fragment="SWIG_null_deleter_python") CONST TYPE & {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(&$1 SWIG_NO_NULL_DELETER_0);
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+// plain pointer by reference
+// Note: $disown not implemented by default as it will lead to a memory leak of the shared_ptr instance
+%typemap(in) TYPE *CONST& (void *argp = 0, int res = 0, $*1_ltype temp = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SHARED_PTR_DISOWN | %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ tempshared = *%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ delete %reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *);
+ temp = %const_cast(tempshared.get(), $*1_ltype);
+ } else {
+ temp = %const_cast(%reinterpret_cast(argp, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)->get(), $*1_ltype);
+ }
+ $1 = &temp;
+}
+%typemap(out, fragment="SWIG_null_deleter_python") TYPE *CONST& {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner);
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) TYPE *CONST& %{
+#error "varin typemap not implemented"
+%}
+%typemap(varout) TYPE *CONST& %{
+#error "varout typemap not implemented"
+%}
+
+// shared_ptr by value
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > (void *argp, int res = 0) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (argp) $1 = *(%reinterpret_cast(argp, $&ltype));
+ if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $&ltype);
+}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ int newmem = 0;
+ void *argp = 0;
+ int res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ $1 = argp ? *(%reinterpret_cast(argp, $&ltype)) : SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE >();
+ if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $&ltype);
+}
+%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1) : 0;
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+// shared_ptr by reference
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & (void *argp, int res = 0, $*1_ltype tempshared) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
+ delete %reinterpret_cast(argp, $ltype);
+ $1 = &tempshared;
+ } else {
+ $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared;
+ }
+}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0;
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
+#error "varin typemap not implemented"
+%}
+%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & %{
+#error "varout typemap not implemented"
+%}
+
+// shared_ptr by pointer
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * (void *argp, int res = 0, $*1_ltype tempshared) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (newmem & SWIG_CAST_NEW_MEMORY) {
+ if (argp) tempshared = *%reinterpret_cast(argp, $ltype);
+ delete %reinterpret_cast(argp, $ltype);
+ $1 = &tempshared;
+ } else {
+ $1 = (argp) ? %reinterpret_cast(argp, $ltype) : &tempshared;
+ }
+}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = $1 && *$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1) : 0;
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+ if ($owner) delete $1;
+}
+
+%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
+#error "varin typemap not implemented"
+%}
+%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * %{
+#error "varout typemap not implemented"
+%}
+
+// shared_ptr by pointer reference
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (void *argp, int res = 0, SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempshared, $*1_ltype temp = 0) {
+ int newmem = 0;
+ res = SWIG_ConvertPtrAndOwn($input, &argp, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), %convertptr_flags, &newmem);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (argp) tempshared = *%reinterpret_cast(argp, $*ltype);
+ if (newmem & SWIG_CAST_NEW_MEMORY) delete %reinterpret_cast(argp, $*ltype);
+ temp = &tempshared;
+ $1 = &temp;
+}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartresult = *$1 && **$1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0;
+ %set_output(SWIG_NewPointerObj(%as_voidptr(smartresult), $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), SWIG_POINTER_OWN));
+}
+
+%typemap(varin) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
+#error "varin typemap not implemented"
+%}
+%typemap(varout) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& %{
+#error "varout typemap not implemented"
+%}
+
+// Typecheck typemaps
+// Note: SWIG_ConvertPtr with void ** parameter set to 0 instead of using SWIG_ConvertPtrAndOwn, so that the casting
+// function is not called thereby avoiding a possible smart pointer copy constructor call when casting up the inheritance chain.
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1)
+ TYPE CONST,
+ TYPE CONST &,
+ TYPE CONST *,
+ TYPE *CONST&,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *,
+ SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
+ int res = SWIG_ConvertPtr($input, 0, $descriptor(SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< TYPE > *), 0);
+ $1 = SWIG_CheckState(res);
+}
+
+
+// various missing typemaps - If ever used (unlikely) ensure compilation error rather than runtime bug
+%typemap(in) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+%typemap(out) CONST TYPE[], CONST TYPE[ANY], CONST TYPE (CLASS::*) %{
+#error "typemaps for $1_type not available"
+%}
+
+
+%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+
+
+%enddef
+
diff --git a/Lib/scilab/carrays.i b/Lib/scilab/carrays.i
new file mode 100644
index 000000000..014de37ff
--- /dev/null
+++ b/Lib/scilab/carrays.i
@@ -0,0 +1,5 @@
+%define %array_class(TYPE,NAME)
+ %array_class_wrap(TYPE,NAME,__paren__,__paren_asgn__)
+%enddef
+
+%include <typemaps/carrays.swg>
diff --git a/Lib/scilab/cmalloc.i b/Lib/scilab/cmalloc.i
new file mode 100644
index 000000000..248f06b96
--- /dev/null
+++ b/Lib/scilab/cmalloc.i
@@ -0,0 +1 @@
+%include <typemaps/cmalloc.swg>
diff --git a/Lib/scilab/cpointer.i b/Lib/scilab/cpointer.i
new file mode 100644
index 000000000..d824792fa
--- /dev/null
+++ b/Lib/scilab/cpointer.i
@@ -0,0 +1 @@
+%include <typemaps/cpointer.swg>
diff --git a/Lib/scilab/exception.i b/Lib/scilab/exception.i
new file mode 100644
index 000000000..17f4175c4
--- /dev/null
+++ b/Lib/scilab/exception.i
@@ -0,0 +1,6 @@
+%include <typemaps/exception.swg>
+
+
+%insert("runtime") {
+ %define_as(SWIG_exception(code, msg), SWIG_Scilab_Error(code, msg);)
+}
diff --git a/Lib/scilab/matrix.i b/Lib/scilab/matrix.i
new file mode 100644
index 000000000..0936d9365
--- /dev/null
+++ b/Lib/scilab/matrix.i
@@ -0,0 +1,11 @@
+/*
+ * Matrix typemaps
+ *
+ */
+
+%include <scimatrixdouble.swg>
+%include <scimatrixint.swg>
+%include <scimatrixchar.swg>
+%include <scimatrixbool.swg>
+
+
diff --git a/Lib/scilab/sciarray.swg b/Lib/scilab/sciarray.swg
new file mode 100644
index 000000000..c00e3837e
--- /dev/null
+++ b/Lib/scilab/sciarray.swg
@@ -0,0 +1,115 @@
+/* --------------------------------------------------------------------------
+ *
+ * Arrays typemaps
+ *
+ * --------------------------------------------------------------------------*/
+
+%{
+#include <stdio.h>
+%}
+
+%define %scilab_asarray_withallocatecopy(TYPEMAPTYPE, FRAGMENTNAME, CTYPE, TEMPDATATYPE)
+%typemap(TYPEMAPTYPE, fragment="FRAGMENTNAME") CTYPE {
+ size_t i = 0;
+ int iRows = 0;
+ int iCols = 0;
+ TEMPDATATYPE *pTempData = NULL;
+ if (FRAGMENTNAME(pvApiCtx, $input, &iRows, &iCols, &pTempData, fname)) {
+ return SWIG_ERROR;
+ }
+ $1 = ($1_ltype)MALLOC(sizeof($*1_ltype) * iRows * iCols);
+ for (i = 0; i < iRows * iCols; i++) {
+ $1[i] = ($*1_ltype) pTempData[i];
+ }
+}
+%enddef
+
+%define %scilab_asarrayandsize_withcopy(TYPEMAPTYPE, FRAGMENTNAME, CTYPE, TEMPDATATYPE)
+%typemap(TYPEMAPTYPE, fragment="FRAGMENTNAME") CTYPE {
+ int iRows = 0;
+ int iCols = 0;
+ TEMPDATATYPE *pTempData = NULL;
+ if (FRAGMENTNAME(pvApiCtx, $input, &iRows, &iCols, &pTempData, fname)) {
+ return SWIG_ERROR;
+ }
+ if (iRows*iCols <= $1_dim0) {
+ size_t i;
+ for (i = 0; i < $1_dim0; i++) {
+ $1[i] = ($*1_ltype) pTempData[i];
+ }
+ }
+ else {
+ char errmsg[100];
+ sprintf(errmsg, "Size of input data (%d) is too big (maximum is %d)",
+ iRows*iCols, $1_dim0);
+ SWIG_exception_fail(SWIG_OverflowError, errmsg);
+ }
+}
+%enddef
+
+%define %scilab_fromarrayandsize(TYPEMAPTYPE, FRAGMENTNAME, CTYPE)
+%typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE {
+ %set_output(FRAGMENTNAME(pvApiCtx, $result, 1, $1_dim0, $1));
+}
+%enddef
+
+%define %scilab_array_typemaps(CTYPE, ASARRAY_FRAGMENT, FROMARRAY_FRAGMENT, TEMPDATATYPE)
+ %scilab_asarrayandsize_withcopy(varin, ASARRAY_FRAGMENT, CTYPE[ANY], TEMPDATATYPE);
+ %scilab_asarray_withallocatecopy(in, ASARRAY_FRAGMENT, CTYPE[ANY], TEMPDATATYPE);
+ %scilab_fromarrayandsize(varout, FROMARRAY_FRAGMENT, CTYPE[ANY]);
+ %scilab_fromarrayandsize(out, FROMARRAY_FRAGMENT, CTYPE[ANY]);
+
+ %apply SWIGTYPE[] { CTYPE[] };
+ %scilab_asarray_withallocatecopy(in, ASARRAY_FRAGMENT, CTYPE[], TEMPDATATYPE);
+%enddef
+
+
+// Double
+%scilab_array_typemaps(double, SWIG_SciDouble_AsDoubleArrayAndSize,
+ SWIG_SciDouble_FromDoubleArrayAndSize, double);
+
+// Signed char
+
+%scilab_array_typemaps(signed char, SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize,
+ SWIG_SciDouble_FromSignedCharArrayAndSize, signed char);
+
+// Unsigned char
+%scilab_array_typemaps(unsigned char, SWIG_SciDoubleOrUint8_AsUnsignedCharArrayAndSize,
+ SWIG_SciDouble_FromUnsignedCharArrayAndSize, unsigned char);
+
+// Short
+%scilab_array_typemaps(short, SWIG_SciDoubleOrInt16_AsShortArrayAndSize,
+ SWIG_SciDouble_FromShortArrayAndSize, short);
+
+// Unsigned short
+%scilab_array_typemaps(unsigned short, SWIG_SciDoubleOrUint16_AsUnsignedShortArrayAndSize,
+ SWIG_SciDouble_FromUnsignedShortArrayAndSize, unsigned short);
+
+// Int
+%scilab_array_typemaps(int, SWIG_SciDoubleOrInt32_AsIntArrayAndSize,
+ SWIG_SciDouble_FromIntArrayAndSize, int);
+
+// Unsigned int
+%scilab_array_typemaps(unsigned int, SWIG_SciDoubleOrUint32_AsUnsignedIntArrayAndSize,
+ SWIG_SciDouble_FromUnsignedIntArrayAndSize, unsigned int);
+
+// Long
+%scilab_array_typemaps(long, SWIG_SciDoubleOrInt32_AsIntArrayAndSize,
+ SWIG_SciDouble_FromLongArrayAndSize, int);
+
+// Unsigned long
+%scilab_array_typemaps(unsigned long, SWIG_SciDoubleOrUint32_AsUnsignedIntArrayAndSize,
+ SWIG_SciDouble_FromUnsignedLongArrayAndSize, unsigned int);
+
+// Float
+%scilab_array_typemaps(float, SWIG_SciDouble_AsFloatArrayAndSize,
+ SWIG_SciDouble_FromFloatArrayAndSize, float);
+
+// Bool
+%scilab_array_typemaps(bool, SWIG_SciBoolean_AsIntArrayAndSize,
+ SWIG_SciBoolean_FromBoolArrayAndSize, int);
+
+// Char *
+%scilab_array_typemaps(char *, SWIG_SciString_AsCharPtrArrayAndSize,
+ SWIG_SciString_FromCharPtrArrayAndSize, char *);
+
diff --git a/Lib/scilab/scibool.swg b/Lib/scilab/scibool.swg
new file mode 100644
index 000000000..ea7938dc8
--- /dev/null
+++ b/Lib/scilab/scibool.swg
@@ -0,0 +1,157 @@
+/*
+ * C-type: bool
+ * Scilab type: boolean scalar
+ */
+%fragment(SWIG_AsVal_frag(bool), "header") {
+SWIGINTERN int
+SWIG_AsVal_dec(bool)(SwigSciObject iVar, bool *pbValue) {
+ SciErr sciErr;
+ int iRet = 0;
+ int *piAddrVar = NULL;
+ int iTempValue = 0;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (!isBooleanType(pvApiCtx, piAddrVar)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A boolean expected.\n"), SWIG_Scilab_GetFuncName(), iVar);
+ return SWIG_ERROR;
+ }
+
+ if (!isScalar(pvApiCtx, piAddrVar)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A boolean expected.\n"), SWIG_Scilab_GetFuncName(), iVar);
+ return SWIG_ERROR;
+ }
+
+ iRet = getScalarBoolean(pvApiCtx, piAddrVar, &iTempValue);
+ if (iRet) {
+ return SWIG_ERROR;
+ }
+
+ *pbValue = iTempValue;
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(bool), "header") {
+SWIGINTERN int
+SWIG_From_dec(bool)(bool bValue) {
+ if (createScalarBoolean(pvApiCtx, SWIG_NbInputArgument(pvApiCtx)
+ + SWIG_Scilab_GetOutputPosition(), bValue))
+ return SWIG_ERROR;
+ return SWIG_OK;
+}
+}
+
+/*
+ * C-type: bool[]
+ * Scilab type: boolean matrix
+ */
+%fragment("SWIG_SciBoolean_AsBoolArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciBoolean_AsBoolArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, bool **pbValue, char *fname) {
+ SciErr sciErr;
+ int *piAddrVar = NULL;
+ int *piValue = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (isBooleanType(pvApiCtx, piAddrVar)) {
+ int i;
+ sciErr = getMatrixOfBoolean(pvApiCtx, piAddrVar, iRows, iCols, &piValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ *pbValue = (bool*) malloc((*iRows) * (*iCols) * sizeof(bool));
+ for (i = 0; i < (*iRows) * (*iCols); i++)
+ (*pbValue)[i] = piValue[i] != 0;
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A boolean matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciBoolean_FromBoolArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciBoolean_FromBoolArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, bool *pbValue) {
+ SciErr sciErr;
+ int *piValue = NULL;
+ int i;
+
+ piValue = (int*) malloc(iRows * iCols * sizeof(int));
+ for (i = 0; i < iRows * iCols; i++)
+ piValue[i] = pbValue[i];
+
+ sciErr = createMatrixOfBoolean(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, piValue);
+ if(sciErr.iErr) {
+ printError(&sciErr, 0);
+ free(piValue);
+ return SWIG_ERROR;
+ }
+
+ free(piValue);
+ return SWIG_OK;
+}
+}
+
+/*
+ * C-type: int[]
+ * Scilab type: boolean matrix
+ */
+%fragment("SWIG_SciBoolean_AsIntArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciBoolean_AsIntArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, int **piValue, char *fname) {
+ SciErr sciErr;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (isBooleanType(pvApiCtx, piAddrVar)) {
+ int i;
+ sciErr = getMatrixOfBoolean(pvApiCtx, piAddrVar, iRows, iCols, piValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A boolean matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciBoolean_FromIntArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciBoolean_FromIntArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, int *piValue) {
+ SciErr sciErr;
+
+ sciErr = createMatrixOfBoolean(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, piValue);
+ if(sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/scichar.swg b/Lib/scilab/scichar.swg
new file mode 100644
index 000000000..509a40c18
--- /dev/null
+++ b/Lib/scilab/scichar.swg
@@ -0,0 +1,285 @@
+/*
+ * C-type: char or char*
+ * Scilab type: string
+ */
+
+/*
+ * CHAR
+ */
+
+%fragment(SWIG_AsVal_frag(char), "header", fragment="SWIG_SciString_AsChar") {
+#define SWIG_AsVal_char(scilabValue, valuePointer) SWIG_SciString_AsChar(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciString_AsChar", "header") {
+SWIGINTERN int
+SWIG_SciString_AsChar(void *pvApiCtx, int iVar, char *pcValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int iRows = 0;
+ int iCols = 0;
+ int *piAddrVar = NULL;
+ char *pstStrings = NULL;
+ int piLength = 0;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iType != sci_strings) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A string expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ pstStrings = (char *)malloc(sizeof(char));
+ sciErr = getMatrixOfString(pvApiCtx, piAddrVar, &iRows, &iCols, &piLength, (char **)&pstStrings);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A string expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+ *pcValue = pstStrings[0];
+
+ free(pstStrings);
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(char), "header", fragment="SWIG_SciString_FromChar") {
+#define SWIG_From_char(value) SWIG_SciString_FromChar(pvApiCtx, SWIG_Scilab_GetOutputPosition(), value)
+}
+%fragment("SWIG_SciString_FromChar", "header") {
+SWIGINTERN int
+SWIG_SciString_FromChar(void *pvApiCtx, int iVarOut, char chValue) {
+ char *pchValue = (char*)malloc(sizeof(char) * 2);
+ pchValue[0] = chValue;
+ pchValue[1] = '\0';
+
+ if (createSingleString(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, pchValue))
+ return SWIG_ERROR;
+
+ free(pchValue);
+ return SWIG_OK;
+}
+}
+
+/*
+ * CHAR *
+*/
+
+%fragment("SWIG_AsCharArray", "header", fragment = "SWIG_SciString_AsCharPtr") {
+#define SWIG_AsCharArray(scilabValue, charPtrPointer, charPtrLength) SWIG_SciString_AsCharPtr(pvApiCtx, scilabValue, charPtrPointer, charPtrLength, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciString_AsCharPtr", "header") {
+SWIGINTERN int
+SWIG_SciString_AsCharPtr(void *pvApiCtx, int iVar, char *pcValue, int iLength, char *fname) {
+ SciErr sciErr;
+ int *piAddrVar = NULL;
+ char* pcTmpValue = NULL;
+ int iRet;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ iRet = getAllocatedSingleString(pvApiCtx, piAddrVar, &pcTmpValue);
+ if (iRet) {
+ return SWIG_ERROR;
+ }
+
+ if (pcValue != NULL) {
+ strncpy(pcValue, pcTmpValue, iLength);
+ }
+
+ free(pcTmpValue);
+
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_AsCharPtrAndSize", "header", fragment = "SWIG_SciString_AsCharPtrAndSize") {
+#define SWIG_AsCharPtrAndSize(scilabValue, charPtrPointer, charPtrLength, allocMemory) SWIG_SciString_AsCharPtrAndSize(pvApiCtx, scilabValue, charPtrPointer, charPtrLength, allocMemory, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciString_AsCharPtrAndSize", "header") {
+SWIGINTERN int
+SWIG_SciString_AsCharPtrAndSize(void *pvApiCtx, int iVar, char **pcValue, size_t *piLength, int *alloc, char *fname) {
+ SciErr sciErr;
+ int *piAddrVar = NULL;
+ int iRet;
+ char *pstStrings = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ iRet = getAllocatedSingleString(pvApiCtx, piAddrVar, &pstStrings);
+ if (iRet) {
+ return SWIG_ERROR;
+ }
+
+ // TODO: return SWIG_ERROR if pcValue NULL (now returning SWIG_ERROR fails some typechecks)
+ if (pcValue) {
+ *pcValue = pstStrings;
+ }
+
+ if (alloc != NULL) {
+ *alloc = SWIG_NEWOBJ;
+ }
+
+ if (piLength != NULL) {
+ *piLength = strlen(*pcValue);
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_FromCharPtr", "header", fragment = "SWIG_SciString_FromCharPtr") {
+#define SWIG_FromCharPtr(charPtr) SWIG_SciString_FromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), charPtr)
+}
+%fragment("SWIG_SciString_FromCharPtr", "header") {
+SWIGINTERN int
+SWIG_SciString_FromCharPtr(void *pvApiCtx, int iVarOut, const char *pchValue) {
+ if (pchValue) {
+ SciErr sciErr;
+ const char* pstStrings[1];
+ pstStrings[0] = pchValue;
+
+ sciErr = createMatrixOfString(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, 1, 1, pstStrings);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ int iRet = createEmptyMatrix(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut);
+ if (iRet) {
+ return SWIG_ERROR;
+ }
+ }
+
+ return SWIG_OK;
+}
+}
+
+/*
+ * CHAR * ARRAY
+ */
+
+%fragment("SWIG_SciString_AsCharPtrArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciString_AsCharPtrArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, char ***charPtrArray, char *fname) {
+ SciErr sciErr;
+ int i = 0;
+ int *piAddrVar = NULL;
+ int* piLength = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getMatrixOfString(pvApiCtx, piAddrVar, iRows, iCols, NULL, NULL);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ piLength = (int*) malloc((*iRows) * (*iCols) * sizeof(int));
+
+ sciErr = getMatrixOfString(pvApiCtx, piAddrVar, iRows, iCols, piLength, NULL);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ *charPtrArray = (char**) malloc((*iRows) * (*iCols) * sizeof(char*));
+ for(i = 0 ; i < (*iRows) * (*iCols); i++) {
+ (*charPtrArray)[i] = (char*) malloc(sizeof(char) * (piLength[i] + 1));
+ }
+
+ sciErr = getMatrixOfString(pvApiCtx, piAddrVar, iRows, iCols, piLength, *charPtrArray);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ free(piLength);
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciString_FromCharPtrArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciString_FromCharPtrArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, char **charPtrArray) {
+ SciErr sciErr;
+
+ sciErr = createMatrixOfString(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, (const char* const*) charPtrArray);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_FromCharPtrAndSize", "header", fragment = "SWIG_SciString_FromCharPtr") {
+#define SWIG_FromCharPtrAndSize(charPtr, charPtrLength) SWIG_SciString_FromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), charPtr)
+}
+
+
+/*
+ * Char* Scilab variable
+ */
+
+%fragment(SWIG_CreateScilabVariable_frag(char), "wrapper") {
+SWIGINTERN int
+SWIG_CreateScilabVariable_dec(char)(void *pvApiCtx, const char* psVariableName, const char cVariableValue) {
+ SciErr sciErr;
+ char sValue[2];
+ const char* psStrings[1];
+
+ sValue[0] = cVariableValue;
+ sValue[1] = '\0';
+ psStrings[0] = sValue;
+
+ sciErr = createNamedMatrixOfString(pvApiCtx, psVariableName, 1, 1, psStrings);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_CreateScilabVariable_frag(charptr), "wrapper") {
+SWIGINTERN int
+SWIG_CreateScilabVariable_dec(charptr)(void *pvApiCtx, const char* psVariableName, const char* psVariableValue) {
+ SciErr sciErr;
+ const char* psStrings[1];
+ psStrings[0] = psVariableValue;
+
+ sciErr = createNamedMatrixOfString(pvApiCtx, psVariableName, 1, 1, psStrings);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/scicontainer.swg b/Lib/scilab/scicontainer.swg
new file mode 100644
index 000000000..529d27888
--- /dev/null
+++ b/Lib/scilab/scicontainer.swg
@@ -0,0 +1,445 @@
+/* -----------------------------------------------------------------------------
+ * scicontainer.swg
+ *
+ * Scilab list <-> C++ container wrapper
+ *
+ * This wrapper, and its iterator, allows a general use (and reuse) of
+ * the mapping between C++ and Scilab, thanks to the C++ templates.
+ *
+ * Of course, it needs the C++ compiler to support templates, but
+ * since we will use this wrapper with the STL containers, that should
+ * be the case.
+ * ----------------------------------------------------------------------------- */
+
+%{
+#include <iostream>
+%}
+
+#if !defined(SWIG_NO_EXPORT_ITERATOR_METHODS)
+# if !defined(SWIG_EXPORT_ITERATOR_METHODS)
+# define SWIG_EXPORT_ITERATOR_METHODS SWIG_EXPORT_ITERATOR_METHODS
+# endif
+#endif
+
+
+// #define (SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS)
+// if defined: sequences in return are converted from/to Scilab lists or matrices
+// if not defined: sequences are passed from/to Scilab as pointers
+
+%{
+#define SWIG_STD_NOASSIGN_STL
+%}
+
+%include <sciiterators.swg>
+%include <scisequence.swg>
+
+%{
+#include <stdexcept>
+%}
+
+%include <exception.i>
+%include <std_except.i>
+
+%fragment("SciSequence_Cont", "header",
+ fragment="StdTraits",
+ fragment="SwigSciIterator_T")
+{
+namespace swig
+{
+ template <class T>
+ struct SciSequence_Ref
+ {
+ SciSequence_Ref(const SwigSciObject& seq, int index)
+ : _seq(seq), _index(index)
+ {
+ if (traits_as_sequence<T>::get(_seq, &piSeqAddr) != SWIG_OK)
+ {
+ throw std::invalid_argument("Cannot get sequence data.");
+ }
+ }
+
+ operator T () const
+ {
+ try
+ {
+ return traits_asval_sequenceitem<T>::asval(_seq, piSeqAddr, _index);
+ }
+ catch (std::exception& e)
+ {
+ SWIG_exception(SWIG_RuntimeError, e.what());
+ }
+ }
+
+ SciSequence_Ref& operator=(const T& v)
+ {
+ // TODO
+ return *this;
+ }
+
+ private:
+ SwigSciObject _seq;
+ int _index;
+ void *piSeqAddr;
+ };
+
+
+ template <class T>
+ struct SciSequence_ArrowProxy
+ {
+ SciSequence_ArrowProxy(const T& x): m_value(x) {}
+ const T* operator->() const { return &m_value; }
+ operator const T*() const { return &m_value; }
+ T m_value;
+ };
+
+ template <class T, class Reference >
+ struct SwigSciSequence_InputIterator
+ {
+ typedef SwigSciSequence_InputIterator<T, Reference > self;
+
+ typedef std::random_access_iterator_tag iterator_category;
+ typedef Reference reference;
+ typedef T value_type;
+ typedef T* pointer;
+ typedef int difference_type;
+
+ SwigSciSequence_InputIterator()
+ {
+ }
+
+ SwigSciSequence_InputIterator(const SwigSciObject& seq, int index)
+ : _seq(seq), _index(index)
+ {
+ }
+
+ reference operator*() const
+ {
+ return reference(_seq, _index);
+ }
+
+ SciSequence_ArrowProxy<T>
+ operator->() const {
+ return SciSequence_ArrowProxy<T>(operator*());
+ }
+
+ bool operator==(const self& ri) const
+ {
+ return (_index == ri._index);
+ }
+
+ bool operator!=(const self& ri) const
+ {
+ return !(operator==(ri));
+ }
+
+ self& operator ++ ()
+ {
+ ++_index;
+ return *this;
+ }
+
+ self& operator -- ()
+ {
+ --_index;
+ return *this;
+ }
+
+ self& operator += (difference_type n)
+ {
+ _index += n;
+ return *this;
+ }
+
+ self operator +(difference_type n) const
+ {
+ return self(_seq, _index + n);
+ }
+
+ self& operator -= (difference_type n)
+ {
+ _index -= n;
+ return *this;
+ }
+
+ self operator -(difference_type n) const
+ {
+ return self(_seq, _index - n);
+ }
+
+ difference_type operator - (const self& ri) const
+ {
+ return _index - ri._index;
+ }
+
+ bool operator < (const self& ri) const
+ {
+ return _index < ri._index;
+ }
+
+ reference
+ operator[](difference_type n) const
+ {
+ return reference(_seq, _index + n);
+ }
+
+ private:
+ SwigSciObject _seq;
+ difference_type _index;
+ };
+
+ template <class T>
+ struct SciSequence_Cont
+ {
+ typedef SciSequence_Ref<T> reference;
+ typedef const SciSequence_Ref<T> const_reference;
+ typedef T value_type;
+ typedef T* pointer;
+ typedef int difference_type;
+ typedef int size_type;
+ typedef const pointer const_pointer;
+ typedef SwigSciSequence_InputIterator<T, reference> iterator;
+ typedef SwigSciSequence_InputIterator<T, const_reference> const_iterator;
+
+ SciSequence_Cont(const SwigSciObject& seq) : _seq(seq)
+ {
+ }
+
+ ~SciSequence_Cont()
+ {
+ }
+
+ size_type size() const
+ {
+ int iSeqSize;
+ if (traits_as_sequence<value_type>::size(_seq, &iSeqSize) == SWIG_OK)
+ {
+ return iSeqSize;
+ }
+ else
+ {
+ return SWIG_ERROR;
+ }
+ }
+
+ bool empty() const
+ {
+ return size() == 0;
+ }
+
+ iterator begin()
+ {
+ return iterator(_seq, 0);
+ }
+
+ const_iterator begin() const
+ {
+ return const_iterator(_seq, 0);
+ }
+
+ iterator end()
+ {
+ return iterator(_seq, size());
+ }
+
+ const_iterator end() const
+ {
+ return const_iterator(_seq, size());
+ }
+
+ reference operator[](difference_type n)
+ {
+ return reference(_seq, n);
+ }
+
+ const_reference operator[](difference_type n) const
+ {
+ return const_reference(_seq, n);
+ }
+
+ private:
+ SwigSciObject _seq;
+ };
+}
+}
+
+%define %swig_sequence_iterator(Sequence...)
+#if defined(SWIG_EXPORT_ITERATOR_METHODS)
+ class iterator;
+ class reverse_iterator;
+ class const_iterator;
+ class const_reverse_iterator;
+
+ %typemap(out,noblock=1,fragment="SciSequence_Cont")
+ iterator, reverse_iterator, const_iterator, const_reverse_iterator {
+ %set_output(SWIG_NewPointerObj(swig::make_output_iterator(%static_cast($1,const $type &)),
+ swig::SciSwigIterator::descriptor(),SWIG_POINTER_OWN));
+ }
+ %typemap(out,fragment="SciSequence_Cont")
+ std::pair<iterator, iterator>, std::pair<const_iterator, const_iterator> {
+ // TODO: return a Scilab list from the pair (see code for Octave)
+ }
+
+ %fragment("SciSwigPairBoolOutputIterator", "header",
+ fragment=SWIG_From_frag(bool), fragment="SciSequence_Cont") {}
+
+ %typemap(out,fragment="SciSwigPairBoolOutputIterator")
+ std::pair<iterator, bool>, std::pair<const_iterator, bool> {
+ // TODO: return a Scilab list from the pair (see code for Octave)
+ }
+
+ %typemap(in,noblock=1,fragment="SciSequence_Cont")
+ iterator(swig::SciSwigIterator *iter = 0, int res),
+ reverse_iterator(swig::SciSwigIterator *iter = 0, int res),
+ const_iterator(swig::SciSwigIterator *iter = 0, int res),
+ const_reverse_iterator(swig::SciSwigIterator *iter = 0, int res) {
+ res = SWIG_ConvertPtr((SwigSciObject)$input, %as_voidptrptr(&iter), swig::SciSwigIterator::descriptor(), 0);
+ if (!SWIG_IsOK(res) || !iter) {
+ %argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
+ } else {
+ swig::SwigSciIterator_T<$type > *iter_t = dynamic_cast<swig::SwigSciIterator_T<$type > *>(iter);
+ if (iter_t) {
+ $1 = iter_t->get_current();
+ } else {
+ %argument_fail(SWIG_TypeError, "$type", $symname, $argnum);
+ }
+ }
+ }
+
+ %typecheck(%checkcode(ITERATOR),noblock=1,fragment="SciSequence_Cont")
+ iterator, reverse_iterator, const_iterator, const_reverse_iterator {
+ swig::SciSwigIterator *iter = 0;
+ int res = SWIG_ConvertPtr((SwigSciObject)$input, %as_voidptrptr(&iter), swig::SciSwigIterator::descriptor(), 0);
+ $1 = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigSciIterator_T<$type > *>(iter) != 0));
+ }
+
+ %fragment("SciSequence_Cont");
+#endif //SWIG_EXPORT_ITERATOR_METHODS
+%enddef
+
+// The Scilab container methods
+
+%define %swig_container_methods(Container...)
+%enddef
+
+%define %swig_sequence_methods_common(Sequence...)
+ %swig_sequence_iterator(%arg(Sequence))
+ %swig_container_methods(%arg(Sequence))
+
+%enddef
+
+%define %swig_sequence_methods(Sequence...)
+ %swig_sequence_methods_common(%arg(Sequence))
+%enddef
+
+%define %swig_sequence_methods_val(Sequence...)
+ %swig_sequence_methods_common(%arg(Sequence))
+%enddef
+
+//
+// Common fragments
+//
+
+%fragment("StdSequenceTraits","header",
+ fragment="StdTraits",
+ fragment="SciSequence_Cont",
+ fragment=SWIG_Traits_SequenceItem_frag(ptr))
+{
+namespace swig {
+ template <class SciSeq, class Seq>
+ inline void
+ assign(const SciSeq& sciSeq, Seq* seq) {
+%#ifdef SWIG_STD_NOASSIGN_STL
+ typedef typename SciSeq::value_type value_type;
+ typename SciSeq::const_iterator it = sciSeq.begin();
+ for (;it != sciSeq.end(); ++it) {
+ seq->insert(seq->end(),(value_type)(*it));
+ }
+%#else
+ seq->assign(sciSeq.begin(), sciSeq.end());
+%#endif
+ }
+
+ template <class Seq, class T = typename Seq::value_type >
+ struct traits_asptr_stdseq {
+ typedef Seq sequence;
+ typedef T value_type;
+
+ static int asptr(const SwigSciObject& obj, sequence **seq)
+ {
+ swig_type_info *typeInfo = swig::type_info<sequence>();
+ if (typeInfo)
+ {
+ sequence *p;
+ if (SWIG_ConvertPtr(obj, (void**)&p, typeInfo, 0) == SWIG_OK)
+ {
+ if (seq)
+ *seq = p;
+ return SWIG_OLDOBJ;
+ }
+ }
+
+ if (traits_as_sequence<value_type>::check(obj) == SWIG_OK)
+ {
+ try
+ {
+ SciSequence_Cont<value_type> sciSeq(obj);
+ if (seq)
+ {
+ *seq = new sequence();
+ assign(sciSeq, *seq);
+ return SWIG_NEWOBJ;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ catch (std::exception& e)
+ {
+ SWIG_exception(SWIG_RuntimeError, e.what());
+ }
+ }
+ }
+ };
+
+ template <class Seq, class T = typename Seq::value_type >
+ struct traits_from_stdseq {
+ typedef Seq sequence;
+ typedef T value_type;
+ typedef typename Seq::size_type size_type;
+ typedef typename sequence::const_iterator const_iterator;
+
+ static SwigSciObject from(const sequence& seq)
+ {
+ %#ifdef SWIG_SCILAB_EXTRA_NATIVE_CONTAINERS
+ swig_type_info *typeInfo = swig::type_info<sequence>();
+ if (typeInfo)
+ {
+ return SWIG_NewPointerObj(new sequence(seq), typeInfo, SWIG_POINTER_OWN);
+ }
+ %#endif
+
+ try
+ {
+ void *data;
+ size_type size = seq.size();
+ if (traits_from_sequence<value_type>::create(size, &data) == SWIG_OK) {
+ const_iterator it;
+ int index = 0;
+ for (it = seq.begin(); it != seq.end(); ++it)
+ {
+ traits_from_sequenceitem<value_type>::from(data, index, *it);
+ index++;
+ }
+ return traits_from_sequence<value_type>::set(size, data);
+ }
+ return SWIG_OK;
+ }
+ catch (std::exception& e)
+ {
+ SWIG_exception(SWIG_RuntimeError, e.what());
+ }
+ }
+ };
+}
+}
diff --git a/Lib/scilab/scidouble.swg b/Lib/scilab/scidouble.swg
new file mode 100644
index 000000000..1b8263306
--- /dev/null
+++ b/Lib/scilab/scidouble.swg
@@ -0,0 +1,108 @@
+/*
+ * DOUBLE SCALAR
+ */
+%fragment(SWIG_AsVal_frag(double), "header", fragment="SWIG_SciDouble_AsDouble") {
+%#define SWIG_AsVal_double(scilabValue, valuePointer) SWIG_SciDouble_AsDouble(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDouble_AsDouble", "header") {
+SWIGINTERN int
+SWIG_SciDouble_AsDouble(void *pvApiCtx, SwigSciObject iVar, double *pdblValue, char *fname) {
+ SciErr sciErr;
+ int iRet = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (!isDoubleType(pvApiCtx, piAddrVar) || isVarComplex(pvApiCtx, piAddrVar)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A real expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ if (!isScalar(pvApiCtx, piAddrVar)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A real expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ iRet = getScalarDouble(pvApiCtx, piAddrVar, pdblValue);
+ if (iRet) {
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(double), "header", fragment="SWIG_SciDouble_FromDouble") {
+%#define SWIG_From_double(scilabValue) SWIG_SciDouble_FromDouble(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDouble_FromDouble", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromDouble(void *pvApiCtx, int iVarOut, double dblValue, char *fname) {
+ if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, dblValue))
+ return SWIG_ERROR;
+ return SWIG_OK;
+}
+}
+
+/*
+ * DOUBLE ARRAY
+ */
+
+%fragment("SWIG_SciDouble_AsDoubleArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_AsDoubleArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, double **pdValue, char *fname) {
+ SciErr sciErr;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (isDoubleType(pvApiCtx, piAddrVar) && !isVarComplex(pvApiCtx, piAddrVar)) {
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, pdValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A real matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciDouble_FromDoubleArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromDoubleArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, double *pdblValue) {
+ SciErr sciErr;
+ sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdblValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_CreateScilabVariable_frag(double), "wrapper") {
+SWIGINTERN int
+SWIG_CreateScilabVariable_dec(double)(void *pvApiCtx, const char* psVariableName, const double dVariableValue) {
+ SciErr sciErr;
+ sciErr = createNamedMatrixOfDouble(pvApiCtx, psVariableName, 1, 1, &dVariableValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/scienum.swg b/Lib/scilab/scienum.swg
new file mode 100644
index 000000000..54ec1f85c
--- /dev/null
+++ b/Lib/scilab/scienum.swg
@@ -0,0 +1,31 @@
+/*
+ * C-type: enum
+ * Scilab type: double or int32
+ */
+
+%fragment(SWIG_AsVal_frag(Enum), "header", fragment="SWIG_Int_AsEnum") {
+%#define SWIG_AsVal_Enum(scilabValue, valuePointer) SWIG_Int_AsEnum(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_Int_AsEnum", "header", fragment="SWIG_SciDoubleOrInt32_AsInt") {
+SWIGINTERN int
+SWIG_Int_AsEnum(void *pvApiCtx, int iVar, int *enumValue, char *fname) {
+ int iValue = 0;
+ if (SWIG_SciDoubleOrInt32_AsInt(pvApiCtx, iVar, &iValue, fname) != SWIG_OK)
+ return SWIG_ERROR;
+ *enumValue = iValue;
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(Enum), "header", fragment="SWIG_Int_FromEnum") {
+%#define SWIG_From_Enum(scilabValue) SWIG_Int_FromEnum(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_Int_FromEnum", "header", fragment="SWIG_SciDouble_FromInt") {
+SWIGINTERN int
+SWIG_Int_FromEnum(void *pvApiCtx, int iVarOut, int enumValue, char *fname) {
+ if (SWIG_SciDouble_FromInt(pvApiCtx, iVarOut, enumValue, fname) != SWIG_OK)
+ return SWIG_ERROR;
+ SWIG_Scilab_SetOutput(pvApiCtx, iVarOut);
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/sciexception.swg b/Lib/scilab/sciexception.swg
new file mode 100644
index 000000000..a5eb4c00f
--- /dev/null
+++ b/Lib/scilab/sciexception.swg
@@ -0,0 +1,60 @@
+/*
+ * Exception typemaps (throws)
+ */
+
+%include <exception.i>
+
+%typemap(throws, noblock=1) int, unsigned int, signed int,
+ int&,unsigned int&, signed int&,
+ long, unsigned long, signed long,
+ short, unsigned short,signed short,
+ long long, unsigned long long,
+ unsigned char, signed char,
+ long&, unsigned long&, signed long&,
+ short&, unsigned short&, signed short&,
+ long long&, unsigned long long&,
+ unsigned char&, signed char&,
+ size_t, size_t&,
+ ptrdiff_t, ptrdiff_t& {
+ char obj[20];
+ sprintf(obj, "%d", (int)$1);
+ SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor);
+}
+
+%typemap(throws, noblock=1) enum SWIGTYPE {
+ char obj[20];
+ sprintf(obj, "%d", (int)$1);
+ SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor);
+}
+
+%typemap(throws, noblock=1) float, double,
+ float&, double& {
+ char obj[20];
+ sprintf(obj, "%5.3f", (double)$1);
+ SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor);
+}
+
+%typemap(throws, noblock=1) bool, bool& {
+ SWIG_Scilab_Raise_Ex($1 ? "true" : "false", "$type", $descriptor);
+}
+
+%typemap(throws, noblock=1) char*, char[ANY] {
+ SWIG_Scilab_Raise_Ex($1, "$type", $descriptor);
+}
+
+%typemap(throws, noblock=1) char, char& {
+ char obj[1];
+ sprintf(obj, "%c", (char)$1);
+ SWIG_Scilab_Raise_Ex(obj, "$type", $descriptor);
+}
+
+%typemap(throws, noblock=1) SWIGTYPE,
+ SWIGTYPE*,
+ SWIGTYPE [ANY],
+ SWIGTYPE & {
+ SWIG_Scilab_Raise_Ex((char*)NULL, "$type", $descriptor);
+}
+
+%typemap(throws, noblock=1) (...) {
+ SWIG_exception(SWIG_RuntimeError, "unknown exception");
+}
diff --git a/Lib/scilab/scifloat.swg b/Lib/scilab/scifloat.swg
new file mode 100644
index 000000000..f0af17c0e
--- /dev/null
+++ b/Lib/scilab/scifloat.swg
@@ -0,0 +1,83 @@
+/*
+ * FLOAT SCALAR
+ */
+
+%fragment(SWIG_AsVal_frag(float), "header", fragment=SWIG_AsVal_frag(double)) {
+SWIGINTERN int
+SWIG_AsVal_dec(float)(SwigSciObject iVar, float *pfValue) {
+ double dblValue = 0.0;
+ if(SWIG_AsVal_dec(double)(iVar, &dblValue) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+ if (pfValue)
+ *pfValue = (float) dblValue;
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(float), "header") {
+SWIGINTERN int
+SWIG_From_dec(float)(float flValue) {
+ if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx)
+ + SWIG_Scilab_GetOutputPosition(), (double)flValue))
+ return SWIG_ERROR;
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciDouble_AsFloatArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_AsFloatArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, float **pfValue, char *fname) {
+ SciErr sciErr;
+ int *piAddrVar = NULL;
+ double *pdValue = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (isDoubleType(pvApiCtx, piAddrVar) && !isVarComplex(pvApiCtx, piAddrVar)) {
+ int i;
+
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ *pfValue = (float *) malloc((*iRows) * (*iCols) * sizeof(float));
+ for (i=0; i < (*iRows) * (*iCols); i++)
+ (*pfValue)[i] = (float) pdValue[i];
+
+ return SWIG_OK;
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A real matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+}
+}
+
+%fragment("SWIG_SciDouble_FromFloatArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromFloatArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, float *pfValue) {
+ SciErr sciErr;
+ double *pdValue;
+ int i;
+
+ pdValue = (double *) malloc(iRows * iCols * sizeof(double));
+ for (i = 0; i < iRows * iCols; i++)
+ pdValue[i] = pfValue[i];
+
+ sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ free(pdValue);
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/sciint.swg b/Lib/scilab/sciint.swg
new file mode 100644
index 000000000..2d6993569
--- /dev/null
+++ b/Lib/scilab/sciint.swg
@@ -0,0 +1,202 @@
+/*
+ * C-type: int
+ * Scilab type: double or int32
+ */
+
+%fragment(SWIG_AsVal_frag(int), "header", fragment="SWIG_SciDoubleOrInt32_AsInt", fragment="<limits.h>") {
+%#define SWIG_AsVal_int(scilabValue, valuePointer) SWIG_SciDoubleOrInt32_AsInt(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDoubleOrInt32_AsInt", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrInt32_AsInt(void *pvApiCtx, SwigSciObject iVar, int *piValue, char *fname)
+{
+ SciErr sciErr;
+ int iType = 0;
+ int iRows = 0;
+ int iCols = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_ints) {
+ if (piValue) {
+ int iPrec = 0;
+ int *piData = NULL;
+
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iPrec != SCI_INT32) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ sciErr = getMatrixOfInteger32(pvApiCtx, piAddrVar, &iRows, &iCols, &piData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ *piValue = *piData;
+ }
+ }
+ else if (iType == sci_matrix) {
+ if (piValue) {
+ double *pdData = NULL;
+ double dValue = 0.0f;
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ dValue = *pdData;
+ if (dValue != floor(dValue)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar);
+ return SWIG_ValueError;
+ }
+ if ((dValue < INT_MIN) || (dValue > INT_MAX)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar);
+ return SWIG_OverflowError;
+ }
+ *piValue = (int) dValue;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(int), "header", fragment="SWIG_SciDouble_FromInt") {
+%#define SWIG_From_int(scilabValue) SWIG_SciDouble_FromInt(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDouble_FromInt", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromInt(void *pvApiCtx, int iVarOut, int iValue, char *fname){
+ if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx)
+ + iVarOut, (double) iValue))
+ return SWIG_ERROR;
+ return SWIG_OK;
+}
+}
+
+/*
+ * C-type: int[]
+ * Scilab type: double or int32 matrix
+ */
+%fragment("SWIG_SciDoubleOrInt32_AsIntArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrInt32_AsIntArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, int **piValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_matrix) {
+ double *pdData = NULL;
+ int size = 0;
+ int i;
+
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ size = (*iRows) * (*iCols);
+ *piValue = (int*) malloc(size * sizeof(int*));
+ for (i = 0; i < size; i++)
+ (*piValue)[i] = (int) pdData[i];
+ }
+ else if (iType == sci_ints) {
+ int iPrec = 0;
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iPrec != SCI_INT32) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+ sciErr = getMatrixOfInteger32(pvApiCtx, piAddrVar, iRows, iCols, piValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciDouble_FromIntArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromIntArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const int *piData) {
+ SciErr sciErr;
+ double *pdValues = NULL;
+ int i;
+
+ pdValues = (double*) malloc(iRows * iCols * sizeof(double));
+ for (i=0; i<iRows * iCols; i++)
+ pdValues[i] = piData[i];
+
+ sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ free(pdValues);
+ return SWIG_ERROR;
+ }
+
+ free(pdValues);
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_CreateScilabVariable_frag(int), "wrapper") {
+SWIGINTERN int
+SWIG_CreateScilabVariable_dec(int)(void *pvApiCtx, const char* psVariableName, const int iVariableValue) {
+ SciErr sciErr;
+ sciErr = createNamedMatrixOfInteger32(pvApiCtx, psVariableName, 1, 1, &iVariableValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/sciiterators.swg b/Lib/scilab/sciiterators.swg
new file mode 100644
index 000000000..1c7ce4394
--- /dev/null
+++ b/Lib/scilab/sciiterators.swg
@@ -0,0 +1,363 @@
+/* -----------------------------------------------------------------------------
+ * sciiterators.swg
+ *
+ * Users can derive form the SciSwigIterator to implemet their
+ * own iterators. As an example (real one since we use it for STL/STD
+ * containers), the template SwigSciIterator_T does the
+ * implementation for generic C++ iterators.
+ * ----------------------------------------------------------------------------- */
+
+%include <std_common.i>
+
+%fragment("SciSwigIterator","header",fragment="<stddef.h>") {
+namespace swig {
+ struct stop_iteration {
+ };
+
+ struct SciSwigIterator {
+ private:
+ SwigSciObject _seq;
+
+ protected:
+ SciSwigIterator(SwigSciObject seq) : _seq(seq)
+ {
+ }
+
+ public:
+ virtual ~SciSwigIterator() {}
+
+ virtual SwigSciObject value() const = 0;
+
+ virtual SciSwigIterator *incr(size_t n = 1) = 0;
+
+ virtual SciSwigIterator *decr(size_t n = 1)
+ {
+ throw stop_iteration();
+ }
+
+ virtual ptrdiff_t distance(const SciSwigIterator &x) const
+ {
+ throw std::invalid_argument("operation not supported");
+ }
+
+ virtual bool equal (const SciSwigIterator &x) const
+ {
+ throw std::invalid_argument("operation not supported");
+ }
+
+ virtual SciSwigIterator *copy() const = 0;
+
+ SwigSciObject next()
+ {
+ SwigSciObject obj = value();
+ incr();
+ return obj;
+ }
+
+ SwigSciObject previous()
+ {
+ decr();
+ return value();
+ }
+
+ SciSwigIterator *advance(ptrdiff_t n)
+ {
+ return (n > 0) ? incr(n) : decr(-n);
+ }
+
+ bool operator == (const SciSwigIterator& x) const
+ {
+ return equal(x);
+ }
+
+ bool operator != (const SciSwigIterator& x) const
+ {
+ return ! operator==(x);
+ }
+
+ SciSwigIterator* operator ++ () {
+ incr();
+ return this;
+ }
+
+ SciSwigIterator* operator -- () {
+ decr();
+ return this;
+ }
+
+ SciSwigIterator* operator + (ptrdiff_t n) const
+ {
+ return copy()->advance(n);
+ }
+
+ SciSwigIterator* operator - (ptrdiff_t n) const
+ {
+ return copy()->advance(-n);
+ }
+
+ ptrdiff_t operator - (const SciSwigIterator& x) const
+ {
+ return x.distance(*this);
+ }
+
+ static swig_type_info* descriptor() {
+ static int init = 0;
+ static swig_type_info* desc = 0;
+ if (!init) {
+ desc = SWIG_TypeQuery("swig::SciSwigIterator *");
+ init = 1;
+ }
+ return desc;
+ }
+ };
+}
+}
+
+%fragment("SwigSciIterator_T","header",fragment="<stddef.h>",fragment="SciSwigIterator",fragment="StdTraits",fragment="StdIteratorTraits") {
+namespace swig {
+ template<typename OutIterator>
+ class SwigSciIterator_T : public SciSwigIterator
+ {
+ public:
+ typedef OutIterator out_iterator;
+ typedef typename std::iterator_traits<out_iterator>::value_type value_type;
+ typedef SwigSciIterator_T<out_iterator> self_type;
+
+ SwigSciIterator_T(out_iterator curr, SwigSciObject seq)
+ : SciSwigIterator(seq), current(curr)
+ {
+ }
+
+ const out_iterator& get_current() const
+ {
+ return current;
+ }
+
+
+ bool equal (const SciSwigIterator &iter) const
+ {
+ const self_type *iters = dynamic_cast<const self_type *>(&iter);
+ if (iters) {
+ return (current == iters->get_current());
+ } else {
+ throw std::invalid_argument("bad iterator type");
+ }
+ }
+
+ ptrdiff_t distance(const SciSwigIterator &iter) const
+ {
+ const self_type *iters = dynamic_cast<const self_type *>(&iter);
+ if (iters) {
+ return std::distance(current, iters->get_current());
+ } else {
+ throw std::invalid_argument("bad iterator type");
+ }
+ }
+
+ protected:
+ out_iterator current;
+ };
+
+ template <class ValueType>
+ struct from_oper
+ {
+ typedef const ValueType& argument_type;
+ typedef SwigSciObject result_type;
+ result_type operator()(argument_type v) const
+ {
+ return swig::from(v);
+ }
+ };
+
+ template<typename OutIterator,
+ typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
+ typename FromOper = from_oper<ValueType> >
+ class SciSwigIteratorOpen_T : public SwigSciIterator_T<OutIterator>
+ {
+ public:
+ FromOper from;
+ typedef OutIterator out_iterator;
+ typedef ValueType value_type;
+ typedef SwigSciIterator_T<out_iterator> base;
+ typedef SciSwigIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
+
+ SciSwigIteratorOpen_T(out_iterator curr, SwigSciObject seq)
+ : SwigSciIterator_T<OutIterator>(curr, seq)
+ {
+ }
+
+ SwigSciObject value() const {
+ return from(static_cast<const value_type&>(*(base::current)));
+ }
+
+ SciSwigIterator *copy() const
+ {
+ return new self_type(*this);
+ }
+
+ SciSwigIterator *incr(size_t n = 1)
+ {
+ while (n--) {
+ ++base::current;
+ }
+ return this;
+ }
+
+ SciSwigIterator *decr(size_t n = 1)
+ {
+ while (n--) {
+ --base::current;
+ }
+ return this;
+ }
+ };
+
+ template<typename OutIterator,
+ typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
+ typename FromOper = from_oper<ValueType> >
+ class SciSwigIteratorClosed_T : public SwigSciIterator_T<OutIterator>
+ {
+ public:
+ FromOper from;
+ typedef OutIterator out_iterator;
+ typedef ValueType value_type;
+ typedef SwigSciIterator_T<out_iterator> base;
+ typedef SciSwigIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
+
+ SciSwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, SwigSciObject seq)
+ : SwigSciIterator_T<OutIterator>(curr, seq), begin(first), end(last)
+ {
+ }
+
+ SwigSciObject value() const {
+ if (base::current == end) {
+ throw stop_iteration();
+ } else {
+ return from(static_cast<const value_type&>(*(base::current)));
+ }
+ }
+
+ SciSwigIterator *copy() const
+ {
+ return new self_type(*this);
+ }
+
+ SciSwigIterator *incr(size_t n = 1)
+ {
+ while (n--) {
+ if (base::current == end) {
+ throw stop_iteration();
+ } else {
+ ++base::current;
+ }
+ }
+ return this;
+ }
+
+ SciSwigIterator *decr(size_t n = 1)
+ {
+ while (n--) {
+ if (base::current == begin) {
+ throw stop_iteration();
+ } else {
+ --base::current;
+ }
+ }
+ return this;
+ }
+
+ private:
+ out_iterator begin;
+ out_iterator end;
+ };
+
+ template<typename OutIter>
+ inline SciSwigIterator*
+ make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, SwigSciObject seq = SwigSciObject())
+ {
+ return new SciSwigIteratorClosed_T<OutIter>(current, begin, end, seq);
+ }
+
+ template<typename OutIter>
+ inline SciSwigIterator*
+ make_output_iterator(const OutIter& current, SwigSciObject seq = SwigSciObject())
+ {
+ return new SciSwigIteratorOpen_T<OutIter>(current, seq);
+ }
+}
+}
+
+
+%fragment("SciSwigIterator");
+namespace swig
+{
+// Throw a StopIteration exception
+ %ignore stop_iteration;
+ struct stop_iteration {};
+
+ %typemap(throws, noblock=1) stop_iteration
+ {
+ SWIG_Scilab_Raise(0, "stop_iteration", NULL);
+ return SWIG_ERROR;
+ }
+
+// Mark methods that return new objects
+ %newobject SciSwigIterator::copy;
+ %newobject SciSwigIterator::operator + (ptrdiff_t n) const;
+ %newobject SciSwigIterator::operator - (ptrdiff_t n) const;
+
+ %nodirector SciSwigIterator;
+
+ %catches(swig::stop_iteration) SciSwigIterator::value() const;
+ %catches(swig::stop_iteration) SciSwigIterator::incr(size_t n = 1);
+ %catches(swig::stop_iteration) SciSwigIterator::decr(size_t n = 1);
+ %catches(std::invalid_argument) SciSwigIterator::distance(const SciSwigIterator &x) const;
+ %catches(std::invalid_argument) SciSwigIterator::equal (const SciSwigIterator &x) const;
+ %catches(swig::stop_iteration) SciSwigIterator::next();
+ %catches(swig::stop_iteration) SciSwigIterator::previous();
+ %catches(swig::stop_iteration) SciSwigIterator::advance(ptrdiff_t n);
+ %catches(swig::stop_iteration) SciSwigIterator::operator += (ptrdiff_t n);
+ %catches(swig::stop_iteration) SciSwigIterator::operator -= (ptrdiff_t n);
+ %catches(swig::stop_iteration) SciSwigIterator::operator + (ptrdiff_t n) const;
+ %catches(swig::stop_iteration) SciSwigIterator::operator - (ptrdiff_t n) const;
+
+ %ignore SciSwigIterator::operator==;
+ %ignore SciSwigIterator::operator!=;
+ %ignore SciSwigIterator::operator++;
+ %ignore SciSwigIterator::operator--;
+ %ignore SciSwigIterator::operator+;
+ %ignore SciSwigIterator::operator-;
+
+ struct SciSwigIterator
+ {
+ protected:
+ SciSwigIterator(SwigSciObject seq);
+
+ public:
+ virtual ~SciSwigIterator();
+
+ virtual SwigSciObject value() const = 0;
+
+ virtual SciSwigIterator *incr(size_t n = 1) = 0;
+
+ virtual SciSwigIterator *decr(size_t n = 1);
+
+ virtual ptrdiff_t distance(const SciSwigIterator &x) const;
+
+ virtual bool equal (const SciSwigIterator &x) const;
+
+ virtual SciSwigIterator *copy() const = 0;
+
+ SwigSciObject next();
+ SwigSciObject previous();
+ SciSwigIterator *advance(ptrdiff_t n);
+
+ bool operator == (const SciSwigIterator& x) const;
+ bool operator != (const SciSwigIterator& x) const;
+ SciSwigIterator* operator ++ ();
+ SciSwigIterator* operator -- ();
+ SciSwigIterator* operator + (ptrdiff_t n) const;
+ SciSwigIterator* operator - (ptrdiff_t n) const;
+ ptrdiff_t operator - (const SciSwigIterator& x) const;
+ };
+}
diff --git a/Lib/scilab/scilab.swg b/Lib/scilab/scilab.swg
new file mode 100644
index 000000000..3b5f6e817
--- /dev/null
+++ b/Lib/scilab/scilab.swg
@@ -0,0 +1,6 @@
+%include <typemaps/swigmacros.swg>
+%include <typemaps/fragments.swg>
+%include <scimacros.swg>
+%include <sciruntime.swg>
+%include <scitypemaps.swg>
+
diff --git a/Lib/scilab/scilist.swg b/Lib/scilab/scilist.swg
new file mode 100644
index 000000000..513f40b64
--- /dev/null
+++ b/Lib/scilab/scilist.swg
@@ -0,0 +1,91 @@
+/*
+ * Scilab list related functions
+ *
+ */
+
+%fragment("SWIG_ScilabList", "header")
+{
+SWIGINTERN int
+SWIG_GetScilabList(SwigSciObject obj, int **piListAddr)
+{
+ SciErr sciErr;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, obj, piListAddr);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+
+SWIGINTERN int
+SWIG_GetScilabListSize(SwigSciObject obj, int *piListSize)
+{
+ SciErr sciErr;
+ int *piListAddr;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piListAddr);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getListItemNumber(pvApiCtx, piListAddr, piListSize);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+
+SWIGINTERN int
+SWIG_GetScilabListAndSize(SwigSciObject obj, int **piListAddr, int *piListSize)
+{
+ SciErr sciErr;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, obj, piListAddr);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getListItemNumber(pvApiCtx, *piListAddr, piListSize);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+
+SWIGINTERN int
+SWIG_CheckScilabList(SwigSciObject obj)
+{
+ SciErr sciErr;
+ int *piListAddr;
+ int iType;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piListAddr);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piListAddr, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if ((iType != sci_list) && (iType != sci_tlist) && (iType != sci_mlist)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A list is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+
+}
+
diff --git a/Lib/scilab/scilong.swg b/Lib/scilab/scilong.swg
new file mode 100644
index 000000000..4e55be539
--- /dev/null
+++ b/Lib/scilab/scilong.swg
@@ -0,0 +1,123 @@
+/*
+ * C-type: long
+ * Scilab type: double or int32
+ */
+
+%fragment(SWIG_AsVal_frag(long), "header", fragment="SWIG_SciDoubleOrInt32_AsLong", fragment="<limits.h>") {
+%#define SWIG_AsVal_long(scilabValue, valuePointer) SWIG_SciDoubleOrInt32_AsLong(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName());
+}
+%fragment("SWIG_SciDoubleOrInt32_AsLong", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrInt32_AsLong(void *pvApiCtx, SwigSciObject iVar, long *plValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int iRows = 0;
+ int iCols = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_ints) {
+ int iPrec = 0;
+ int *piData = NULL;
+
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iPrec != SCI_INT32) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ sciErr = getMatrixOfInteger32(pvApiCtx, piAddrVar, &iRows, &iCols, &piData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ *plValue = (long) *piData;
+ }
+ else if (iType == sci_matrix) {
+ double *pdData = NULL;
+ double dValue = 0.0f;
+
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ dValue = *pdData;
+ if (dValue != floor(dValue)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar);
+ return SWIG_ValueError;
+ }
+ if ((dValue < LONG_MIN) || (dValue > LONG_MAX)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 32-bit signed integer.\n"), fname, iVar);
+ return SWIG_OverflowError;
+ }
+ *plValue = (long) dValue;
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(long), "header", fragment="SWIG_SciDouble_FromLong") {
+%#define SWIG_From_long(scilabValue) SWIG_SciDouble_FromLong(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDouble_FromLong", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromLong(void *pvApiCtx, int iVarOut, long lValue, char *fname) {
+ if (createScalarDouble(pvApiCtx,
+ SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) lValue))
+ return SWIG_ERROR;
+ return SWIG_OK;
+}
+}
+
+
+%fragment("SWIG_SciDouble_FromLongArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromLongArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const long *plData) {
+ SciErr sciErr;
+ int i;
+ double *pdValues = NULL;
+
+ pdValues = (double*) malloc(iRows * iCols * sizeof(double));
+ for (i=0; i<iRows * iCols; i++) {
+ pdValues[i] = plData[i];
+ }
+
+ sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ free(pdValues);
+ return SWIG_ERROR;
+ }
+ free(pdValues);
+ return SWIG_OK;
+}
+}
+
diff --git a/Lib/scilab/scilonglong.swg b/Lib/scilab/scilonglong.swg
new file mode 100644
index 000000000..02d9b2fab
--- /dev/null
+++ b/Lib/scilab/scilonglong.swg
@@ -0,0 +1,54 @@
+/*
+ * C-type: long long
+ * Scilab 5 type: NONE
+ * Scilab 6 type: int64
+ */
+%fragment(SWIG_AsVal_frag(long long), "header", fragment="SWIG_SciInt64_ToLongLong") {
+%#define SWIG_AsVal_long_SS_long(scilabValue, valuePointer) SWIG_SciInt64_ToLongLong(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciInt64_ToLongLong", "header") {
+SWIGINTERN int
+SWIG_SciInt64_ToLongLong(void *pvApiCtx, int iVar, long long *pllValue, char *fname) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciInt64_ToLongLong", "int64");
+ return SWIG_ERROR;
+}
+}
+
+%fragment(SWIG_From_frag(long long), "header", fragment="SWIG_SciInt64_FromLongLong") {
+#define SWIG_From_long_SS_long(value) SWIG_SciInt64_FromLongLong(pvApiCtx, $result, value)
+}
+%fragment("SWIG_SciInt64_FromLongLong", "header") {
+SWIGINTERN int
+SWIG_SciInt64_FromLongLong(void *pvApiCtx, int iVarOut, long long llValue) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciInt64_ToLongLong", "int64");
+ return SWIG_ERROR;
+}
+}
+
+/*
+ * C-type: unsigned long long
+ * Scilab 5 type: NONE
+ * Scilab 6 type: uint64
+ */
+%fragment(SWIG_AsVal_frag(unsigned long long), "header", fragment="SWIG_SciUint64_ToUnsignedLongLong") {
+#define SWIG_AsVal_unsigned_SS_long_SS_long(scilabValue, valuePointer) SWIG_SciUint64_ToUnsignedLongLong(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciUint64_ToUnsignedLongLong", "header") {
+SWIGINTERN int
+SWIG_SciUint64_ToUnsignedLongLong(void *pvApiCtx, int iVar, unsigned long long *pullValue, char *fname) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciUint64_ToLongLong", "uint64");
+ return SWIG_ERROR;
+}
+}
+
+%fragment(SWIG_From_frag(unsigned long long), "header", fragment="SWIG_SciUint64_FromUnsignedLongLong") {
+#define SWIG_From_unsigned_SS_long_SS_long(value) SWIG_SciUint64_FromUnsignedLongLong(pvApiCtx, $result, value)
+}
+%fragment("SWIG_SciUint64_FromUnsignedLongLong", "header") {
+SWIGINTERN int
+SWIG_SciUint64_FromUnsignedLongLong(void *pvApiCtx, int iVarOut, unsigned long long llValue) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Scilab 5.X does not manage '%s' data type.\n"), "SWIG_SciUint64_ToLongLong", "uint64");
+ return SWIG_ERROR;
+}
+}
+
diff --git a/Lib/scilab/scimacros.swg b/Lib/scilab/scimacros.swg
new file mode 100644
index 000000000..669ca893f
--- /dev/null
+++ b/Lib/scilab/scimacros.swg
@@ -0,0 +1,5 @@
+ #define %scilabconst(flag) %feature("scilab:const","flag")
+
+// Create Scilab variable
+#define SWIG_CreateScilabVariable_frag(Type...) %fragment_name(CreateScilabVariable, Type)
+#define SWIG_CreateScilabVariable_dec(Type...) %symbol_name(CreateScilabVariable, Type)
diff --git a/Lib/scilab/scimatrixbool.swg b/Lib/scilab/scimatrixbool.swg
new file mode 100644
index 000000000..3b1f8cb77
--- /dev/null
+++ b/Lib/scilab/scimatrixbool.swg
@@ -0,0 +1,170 @@
+/*
+ * C-type: bool array
+ * Scilab type: bool matrix
+ */
+
+%include <scibool.swg>
+
+// in (bool *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+
+%typemap(in, noblock=1, fragment="SWIG_SciBoolean_AsBoolArrayAndSize") (bool *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+{
+ if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+// in (int IN_ROWCOUNT, int IN_COLCOUNT, bool *IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciBoolean_AsBoolArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, bool *IN)
+{
+ if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+// in (bool *IN, int IN_SIZE)
+
+%typemap(in, noblock=1, fragment="SWIG_SciBoolean_AsBoolArrayAndSize") (bool *IN, int IN_SIZE) (int rowCount, int colCount)
+{
+ if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
+ $2 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// in (int IN_SIZE, bool *IN)
+
+%typemap(in, noblock=1) (int IN_SIZE, bool *IN) (int rowCount, int colCount)
+{
+ if (SWIG_SciBoolean_AsBoolArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
+ $1 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// out (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+
+%typemap(in, noblock=1, numinputs=0) (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+}
+
+%typemap(arginit, noblock=1) (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ $1 = (bool**) malloc(sizeof(bool*));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (int*) malloc(sizeof(int));
+}
+
+%typemap(freearg, noblock=1) (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ free(*$1);
+ free($1);
+ free($2);
+ free($3);
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (bool **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT)
+{
+ $1 = (int*) malloc(sizeof(int));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (bool**) malloc(sizeof(bool*));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT)
+{
+ if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, bool **OUT)
+{
+ free($1);
+ free($2);
+ free(*$3);
+ free($3);
+}
+
+
+// out (bool **OUT, int *OUT_SIZE)
+
+%typemap(in, noblock=1, numinputs=0) (bool **OUT, int *OUT_SIZE)
+{
+}
+
+%typemap(arginit, noblock=1) (bool **OUT, int *OUT_SIZE)
+{
+ $1 = (bool**) malloc(sizeof(bool*));
+ $2 = (int*) malloc(sizeof(int));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (bool **OUT, int *OUT_SIZE)
+{
+ if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (bool **OUT, int *OUT_SIZE)
+{
+ free(*$1);
+ free($1);
+ free($2);
+}
+
+
+// out (int *OUT_SIZE, bool **OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, bool **OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_SIZE, bool **OUT)
+{
+ $1 = (int*) malloc(sizeof(int));
+ $2 = (bool**) malloc(sizeof(bool*));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciBoolean_FromBoolArrayAndSize") (int *OUT_SIZE, bool **OUT)
+{
+ if (SWIG_SciBoolean_FromBoolArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *OUT_SIZE, bool **OUT)
+{
+ free($1);
+ free(*$2);
+ free($2);
+}
diff --git a/Lib/scilab/scimatrixchar.swg b/Lib/scilab/scimatrixchar.swg
new file mode 100644
index 000000000..37f683396
--- /dev/null
+++ b/Lib/scilab/scimatrixchar.swg
@@ -0,0 +1,199 @@
+/*
+ * C-type: char*
+ * Scilab type: string matrix
+ */
+
+%include <scichar.swg>
+
+// in (char **IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+
+%typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (char **IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+{
+ if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+// in (int IN_ROWCOUNT, int IN_COLCOUNT, char **IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, char **IN)
+{
+ if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+// in (char **IN, int IN_SIZE)
+
+%typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (char **IN, int IN_SIZE) (int rowCount, int colCount)
+{
+ if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
+ $2 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// in (int IN_SIZE, char **IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (int IN_SIZE, char **IN) (int rowCount, int colCount)
+{
+ if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
+ $1 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// out (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+
+%typemap(in, noblock=1, numinputs=0) (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+}
+
+%typemap(arginit, noblock=1) (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ $1 = (char***) malloc(sizeof(char**));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (int*) malloc(sizeof(int));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (char ***OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ {
+ int i;
+ for (i = 0; i < (*$2) * (*$3); i++)
+ free((*$1)[i]);
+ }
+ free(*$1);
+ free($1);
+ free($2);
+ free($3);
+}
+
+// out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT)
+{
+ $1 = (char***) malloc(sizeof(char**));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (int**) malloc(sizeof(int*));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT)
+{
+ if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, char ***OUT)
+{
+ free($1);
+ free($2);
+ {
+ int i;
+ for (i = 0; i < (*$1) * (*$2); i++)
+ free((*$3)[i]);
+ }
+ free(*$3);
+ free($3);
+}
+
+
+// out (char ***OUT, int *OUT_SIZE)
+
+%typemap(in, noblock=1, numinputs=0) (char ***OUT, int *OUT_SIZE)
+{
+}
+
+%typemap(arginit, noblock=1) (char ***OUT, int *OUT_SIZE)
+{
+ $1 = (char***) malloc(sizeof(char**));
+ $2 = (int*) malloc(sizeof(int));
+}
+
+%typemap(freearg, noblock=1) (char ***OUT, int *OUT_SIZE)
+{
+ {
+ int i;
+ for (i = 0; i < *$2; i++)
+ free((*$1)[i]);
+ }
+ free(*$1);
+ free($1);
+ free($2);
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (char ***OUT, int *OUT_SIZE)
+{
+ if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// in (int IN_SIZE, char **IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciString_AsCharPtrArrayAndSize") (int IN_SIZE, char **IN)
+{
+ if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, $input, 1, &$1, &$2, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+// out (int *OUT_SIZE, char ***OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, char ***OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_SIZE, char ***OUT)
+{
+ $1 = (int*) malloc(sizeof(int));
+ $2 = (char***) malloc(sizeof(char**));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciString_FromCharPtrArrayAndSize") (int *OUT_SIZE, char ***OUT)
+{
+ if (SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *OUT_SIZE, char ***OUT)
+{
+ free($1);
+ {
+ int i;
+ for (i = 0; i < *$1; i++)
+ free((*$2)[i]);
+ }
+ free(*$2);
+ free($2);
+}
+
diff --git a/Lib/scilab/scimatrixdouble.swg b/Lib/scilab/scimatrixdouble.swg
new file mode 100644
index 000000000..b8272e9a6
--- /dev/null
+++ b/Lib/scilab/scimatrixdouble.swg
@@ -0,0 +1,170 @@
+/*
+ * C-type: double array
+ * Scilab type: double matrix
+ */
+
+%include <scidouble.swg>
+
+// in (double *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (double *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+{
+ if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+// in (int IN_ROWCOUNT, int IN_COLCOUNT, double *IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, double *IN)
+{
+ if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+// in (double *IN, int IN_SIZE)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (double *IN, int IN_SIZE) (int rowCount, int colCount)
+{
+ if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
+ $2 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// in (int IN_SIZE, double *IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDouble_AsDoubleArrayAndSize") (int IN_SIZE, double *IN) (int rowCount, int colCount)
+{
+ if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
+ $1 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// out (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+
+%typemap(in, noblock=1, numinputs=0) (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+}
+
+%typemap(arginit, noblock=1) (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ $1 = (double**) malloc(sizeof(double*));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (int*) malloc(sizeof(int));
+}
+
+%typemap(freearg, noblock=1) (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ free(*$1);
+ free($1);
+ free($2);
+ free($3);
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (double **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT)
+{
+ $1 = (int*) malloc(sizeof(int));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (double**) malloc(sizeof(double*));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (int *IN_ROWCOUNT, int *IN_COLCOUNT, double **OUT)
+{
+ if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, double **OUT)
+{
+ free($1);
+ free($2);
+ free(*$3);
+ free($3);
+}
+
+
+// out (double **OUT, int *OUT_SIZE)
+
+%typemap(in, noblock=1, numinputs=0) (double **OUT, int *OUT_SIZE)
+{
+}
+
+%typemap(arginit, noblock=1) (double **OUT, int *OUT_SIZE)
+{
+ $1 = (double**) malloc(sizeof(double*));
+ $2 = (int*) malloc(sizeof(int));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (double **OUT, int *OUT_SIZE)
+{
+ if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (double **OUT, int *OUT_SIZE)
+{
+ free(*$1);
+ free($1);
+ free($2);
+}
+
+
+// out (int *OUT_SIZE, double **OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, double **OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_SIZE, double **OUT)
+{
+ $1 = (int*) malloc(sizeof(int));
+ $2 = (double**) malloc(sizeof(double*));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromDoubleArrayAndSize") (int *OUT_SIZE, double **OUT)
+{
+ if (SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *OUT_SIZE, double **OUT)
+{
+ free($1);
+ free(*$2);
+ free($2);
+}
diff --git a/Lib/scilab/scimatrixint.swg b/Lib/scilab/scimatrixint.swg
new file mode 100644
index 000000000..b7270d5d5
--- /dev/null
+++ b/Lib/scilab/scimatrixint.swg
@@ -0,0 +1,175 @@
+/*
+ * C-type: int array
+ * Scilab type: 32-bit integer matrix
+ */
+
+%include <sciint.swg>
+
+// in (int *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int *IN, int IN_ROWCOUNT, int IN_COLCOUNT)
+{
+ if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &$2, &$3, &$1, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+
+// in (int IN_ROWCOUNT, int IN_COLCOUNT, int *IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int IN_ROWCOUNT, int IN_COLCOUNT, int *IN)
+{
+ if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &$1, &$2, &$3, fname) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+
+// in (int *IN, int IN_SIZE)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int *IN, int IN_SIZE) (int rowCount, int colCount)
+{
+ if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$1, fname) == SWIG_OK) {
+ $2 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+
+// in (int IN_SIZE, int *IN)
+
+%typemap(in, noblock=1, fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") (int IN_SIZE, int *IN) (int rowCount, int colCount)
+{
+ if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, $input, &rowCount, &colCount, &$2, fname) == SWIG_OK) {
+ $1 = rowCount * colCount;
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+// out (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+
+%typemap(in, noblock=1, numinputs=0) (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+}
+
+%typemap(arginit, noblock=1) (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ $1 = (int**) malloc(sizeof(int*));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (int*) malloc(sizeof(int));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$2, *$3, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int **OUT, int *OUT_ROWCOUNT, int *OUT_COLCOUNT)
+{
+ free(*$1);
+ free($1);
+ free($2);
+ free($3);
+}
+
+
+// out (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
+{
+ $1 = (int*) malloc(sizeof(int));
+ $2 = (int*) malloc(sizeof(int));
+ $3 = (int**) malloc(sizeof(int*));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
+{
+ if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), *$1, *$2, *$3) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *OUT_ROWCOUNT, int *OUT_COLCOUNT, int **OUT)
+{
+ free($1);
+ free($2);
+ free(*$3);
+ free($3);
+}
+
+
+// out (int **OUT, int *OUT_SIZE)
+
+%typemap(in, noblock=1, numinputs=0) (int **OUT, int *OUT_SIZE)
+{
+}
+
+%typemap(arginit) (int **OUT, int *OUT_SIZE)
+{
+ $1 = (int**) malloc(sizeof(int*));
+ $2 = (int*) malloc(sizeof(int));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int **OUT, int *OUT_SIZE)
+{
+ if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$2, *$1) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int **OUT, int *OUT_SIZE)
+{
+ free(*$1);
+ free($1);
+ free($2);
+}
+
+
+// out (int *OUT_SIZE, int **OUT)
+
+%typemap(in, noblock=1, numinputs=0) (int *OUT_SIZE, int **OUT)
+{
+}
+
+%typemap(arginit, noblock=1) (int *OUT_SIZE, int **OUT)
+{
+ $1 = (int*) malloc(sizeof(int));
+ $2 = (int**) malloc(sizeof(int*));
+}
+
+%typemap(argout, noblock=1, fragment="SWIG_SciDouble_FromIntArrayAndSize") (int *OUT_SIZE, int **OUT)
+{
+ if (SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, *$1, *$2) == SWIG_OK) {
+ SWIG_Scilab_SetOutput(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition());
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
+%typemap(freearg, noblock=1) (int *IN_SIZE, int **OUT)
+{
+ free($1);
+ free(*$2);
+ free($2);
+}
+
diff --git a/Lib/scilab/scimisctypes.swg b/Lib/scilab/scimisctypes.swg
new file mode 100644
index 000000000..fe75e1568
--- /dev/null
+++ b/Lib/scilab/scimisctypes.swg
@@ -0,0 +1,69 @@
+// Other primitive such as size_t and ptrdiff_t
+
+/*
+ * C-type: size_t
+ * Scilab type: double or int32
+ */
+
+%fragment(SWIG_AsVal_frag(size_t), "header", fragment="SWIG_Int_AsSize") {
+%#define SWIG_AsVal_size_t(scilabValue, valuePointer) SWIG_Int_AsSize(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_Int_AsSize", "header", fragment=SWIG_AsVal_frag(int))
+{
+SWIGINTERN int
+SWIG_Int_AsSize(void *pvApiCtx, SwigSciObject iVar, size_t *piValue, char *fname) {
+ int iValue = 0;
+ if (SWIG_AsVal_dec(int)(iVar, &iValue) != SWIG_OK)
+ return SWIG_ERROR;
+
+ if (piValue)
+ *piValue = (size_t) iValue;
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(size_t), "header", fragment="SWIG_Int_FromSize") {
+%#define SWIG_From_size_t(scilabValue) SWIG_Int_FromSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_Int_FromSize", "header", fragment=SWIG_From_frag(int))
+{
+SWIGINTERN int
+SWIG_Int_FromSize(void *pvApiCtx, int iVarOut, size_t iValue, char *fname) {
+ return SWIG_From_dec(int)((int)iValue);
+}
+}
+
+/*
+ * C-type: ptrdiff_t
+ * Scilab type: double or int32
+ */
+
+%fragment(SWIG_AsVal_frag(ptrdiff_t), "header", fragment="SWIG_Int_AsPtrDiff") {
+%#define SWIG_AsVal_ptrdiff_t(scilabValue, valuePointer) SWIG_Int_AsPtrDiff(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_Int_AsPtrDiff", "header", fragment=SWIG_AsVal_frag(int))
+{
+SWIGINTERN int
+SWIG_Int_AsPtrDiff(void *pvApiCtx, SwigSciObject iVar, ptrdiff_t *piValue, char *fname) {
+ int iValue = 0;
+ if (SWIG_AsVal_dec(int)(iVar, &iValue) != SWIG_OK)
+ return SWIG_ERROR;
+
+ if (piValue)
+ *piValue = (ptrdiff_t) iValue;
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(ptrdiff_t), "header", fragment="SWIG_Int_FromPtrDiff") {
+%#define SWIG_From_ptrdiff_t(scilabValue) SWIG_Int_FromPtrDiff(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_Int_FromPtrDiff", "header", fragment=SWIG_From_frag(int)) {
+SWIGINTERN int
+SWIG_Int_FromPtrDiff(void *pvApiCtx, int iVarOut, ptrdiff_t iValue, char *fname) {
+ return SWIG_From_dec(int)((int)iValue);
+}
+}
+
diff --git a/Lib/scilab/scipointer.swg b/Lib/scilab/scipointer.swg
new file mode 100644
index 000000000..8d0526d4d
--- /dev/null
+++ b/Lib/scilab/scipointer.swg
@@ -0,0 +1,32 @@
+/*
+ * POINTER
+ */
+%fragment("SWIG_ConvertPtr", "header") {
+#define SWIG_ConvertPtr(scilabValue, voidPointer, pointerDescriptor, flags) SwigScilabPtrToObject(pvApiCtx, scilabValue, voidPointer, pointerDescriptor, flags, SWIG_Scilab_GetFuncName())
+}
+
+%fragment("SWIG_NewPointerObj", "header") {
+#define SWIG_NewPointerObj(pointer, pointerDescriptor, flags) SwigScilabPtrFromObject(pvApiCtx, SWIG_Scilab_GetOutputPosition(), pointer, pointerDescriptor, flags)
+}
+
+/*
+ * FUNCTION POINTER
+ */
+%fragment("SWIG_ConvertFunctionPtr", "header") {
+#define SWIG_ConvertFunctionPtr(scilabValue, voidPointer, pointerDescriptor) SwigScilabPtrToObject(pvApiCtx, scilabValue, voidPointer, pointerDescriptor, 0, SWIG_Scilab_GetFuncName())
+}
+
+%fragment("SWIG_NewFunctionPtrObj", "header") {
+#define SWIG_NewFunctionPtrObj(pointer, pointerDescriptor) SwigScilabPtrFromObject(pvApiCtx, SWIG_Scilab_GetOutputPosition(), pointer, pointerDescriptor, 0)
+}
+// No fragment used here, the functions "SwigScilabPtrToObject" and "SwigScilabPtrFromObject" are defined in sciruntime.swg
+
+/*
+ * C++ member pointers, ie, member methods
+ */
+%fragment("SWIG_NewMemberObj", "header") {
+#define SWIG_NewMemberObj(ptr, sz, tp) SWIG_Scilab_NewMemberObj(pvApiCtx, $result, ptr, sz, tp)
+}
+%fragment("SWIG_ConvertMember", "header") {
+#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Scilab_ConvertPacked(pvApiCtx, obj, ptr, sz, ty, SWIG_Scilab_GetFuncName())
+}
diff --git a/Lib/scilab/sciprimtypes.swg b/Lib/scilab/sciprimtypes.swg
new file mode 100644
index 000000000..b5e30d932
--- /dev/null
+++ b/Lib/scilab/sciprimtypes.swg
@@ -0,0 +1,23 @@
+%include <scidouble.swg>
+%include <scifloat.swg>
+
+%include <scilonglong.swg>
+
+%include <sciint.swg>
+%include <sciunsignedint.swg>
+
+%include <scilong.swg>
+%include <sciunsignedlong.swg>
+
+%include <scishort.swg>
+%include <sciunsignedshort.swg>
+
+%include <scichar.swg>
+%include <scisignedchar.swg>
+%include <sciunsignedchar.swg>
+
+%include <scimisctypes.swg>
+
+%include <scipointer.swg>
+%include <scibool.swg>
+
diff --git a/Lib/scilab/scirun.swg b/Lib/scilab/scirun.swg
new file mode 100644
index 000000000..081012fe9
--- /dev/null
+++ b/Lib/scilab/scirun.swg
@@ -0,0 +1,318 @@
+/* -----------------------------------------------------------------------------
+ * Scilab support runtime
+ * -----------------------------------------------------------------------------*/
+
+/* Scilab version macro */
+
+#include "version.h"
+#define SWIG_SCILAB_VERSION (SCI_VERSION_MAJOR * 100) + (SCI_VERSION_MINOR * 10) + SCI_VERSION_MAINTENANCE
+
+/* Scilab standard headers */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+#include "api_scilab.h"
+#if SWIG_SCILAB_VERSION < 540
+#define __USE_DEPRECATED_STACK_FUNCTIONS__
+#include "stack-c.h"
+#endif
+#include "MALLOC.h"
+#include "Scierror.h"
+#include "localization.h"
+#include "freeArrayOfString.h"
+#include <sci_gateway.h>
+#include <mex.h>
+#ifdef __cplusplus
+}
+#endif
+
+/* Gateway signature */
+
+#if SWIG_SCILAB_VERSION >= 600
+#define SWIG_GatewayParameters char* fname, void *pvApiCtx
+#define SWIG_GatewayArguments fname, pvApiCtx
+#else
+#define SWIG_GatewayParameters char* fname, unsigned long fname_len
+#define SWIG_GatewayArguments fname, fname_len
+#endif
+
+/* Function name management functions */
+
+#include <stdlib.h>
+static char *SwigFuncName = NULL;
+static char *SWIG_Scilab_GetFuncName(void) {
+ return SwigFuncName;
+}
+static void SWIG_Scilab_SetFuncName(char *funcName) {
+ if (SwigFuncName != NULL) {
+ free(SwigFuncName);
+ }
+ SwigFuncName = strdup(funcName);
+}
+
+/* Api context management functions */
+
+#if SWIG_SCILAB_VERSION >= 600
+static void *pvApiCtx = NULL;
+static void SWIG_Scilab_SetApiContext(void *apiCtx) {
+ pvApiCtx = apiCtx;
+}
+#else
+#define SWIG_Scilab_SetApiContext(apiCtx)
+#endif
+
+/* Argument management functions */
+
+#if SWIG_SCILAB_VERSION >= 540
+#define SWIG_CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument) CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument)
+#define SWIG_CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument) CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument)
+#define SWIG_NbInputArgument(pvApiCtx) nbInputArgument(pvApiCtx)
+#define SWIG_AssignOutputArgument(pvApiCtx, outputArgumentPos, argumentPos) AssignOutputVariable(pvApiCtx, outputArgumentPos) = argumentPos
+#else
+#define SWIG_CheckInputArgument(pvApiCtx, minInputArgument, maxInputArgument) CheckRhs(minInputArgument, maxInputArgument)
+#define SWIG_CheckOutputArgument(pvApiCtx, minOutputArgument, maxOutputArgument) CheckLhs(minOutputArgument, maxOutputArgument)
+#define SWIG_NbInputArgument(pvApiCtx) Rhs
+#define SWIG_AssignOutputArgument(pvApiCtx, outputArgumentPos, argumentPos) LhsVar(outputArgumentPos) = argumentPos
+#endif
+
+typedef int SwigSciObject;
+
+static int SwigOutputPosition = -1;
+static int SWIG_Scilab_GetOutputPosition(void) {
+ return SwigOutputPosition;
+}
+static void SWIG_Scilab_SetOutputPosition(int outputPosition) {
+ SwigOutputPosition = outputPosition;
+}
+
+SWIGRUNTIME int
+SWIG_Scilab_SetOutput(void *pvApiCtx, SwigSciObject output) {
+ int outputPosition = SWIG_Scilab_GetOutputPosition();
+ if (outputPosition < 0)
+ return SWIG_ERROR;
+ SWIG_AssignOutputArgument(pvApiCtx, outputPosition,
+ SWIG_NbInputArgument(pvApiCtx) + outputPosition);
+ return SWIG_OK;
+}
+
+
+/* Pointer conversion functions */
+
+SWIGINTERN int
+SwigScilabPtrToObject(void *pvApiCtx, int iVar, void **pObjValue, swig_type_info *descriptor, int flags, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_pointer) {
+ sciErr = getPointer(pvApiCtx, piAddrVar, pObjValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+
+SWIGRUNTIMEINLINE int
+SwigScilabPtrFromObject(void *pvApiCtx, int iVarOut, void *obj, swig_type_info *descriptor, int flags) {
+ SciErr sciErr;
+
+ sciErr = createPointer(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, (void *)obj);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+
+SWIGRUNTIME int
+SWIG_Scilab_ConvertPacked(void *pvApiCtx, int iVar, void *ptr, int sz, swig_type_info *ty, char *fname) {
+ swig_cast_info *tc;
+ int *piAddrVar = NULL;
+ char *pstStrings = NULL;
+ SciErr sciErr;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (getAllocatedSingleString(pvApiCtx, piAddrVar, &pstStrings)) {
+ return SWIG_ERROR;
+ }
+
+ /* Pointer values must start with leading underscore */
+ if (*pstStrings != '_') {
+ return SWIG_ERROR;
+ }
+
+ pstStrings++;
+ pstStrings = (char*)SWIG_UnpackData(pstStrings, ptr, sz);
+
+ if (ty) {
+ if (!pstStrings) {
+ return SWIG_ERROR;
+ }
+ tc = SWIG_TypeCheck(pstStrings, ty);
+ if (!tc) {
+ return SWIG_ERROR;
+ }
+ }
+ return SWIG_OK;
+}
+
+SWIGRUNTIME int
+SWIG_Scilab_NewMemberObj(void *pvApiCtx, int iVarOut, void *ptr, int sz, swig_type_info *type) {
+ char result[1024];
+ char *r = result;
+
+ if ((2*sz + 1 + strlen(type->name)) > 1000) {
+ return SWIG_ERROR;
+ }
+ *(r++) = '_';
+ r = SWIG_PackData(r, ptr, sz);
+ strcpy(r, type->name);
+
+ if (createSingleString(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, &result[0]))
+ return SWIG_ERROR;
+
+ return SWIG_OK;
+}
+
+
+/* Error functions */
+
+#define SCILAB_API_ARGUMENT_ERROR 999
+
+SWIGINTERN const char*
+SWIG_Scilab_ErrorType(int code) {
+ switch(code) {
+ case SWIG_MemoryError:
+ return "MemoryError";
+ case SWIG_IOError:
+ return "IOError";
+ case SWIG_RuntimeError:
+ return "RuntimeError";
+ case SWIG_IndexError:
+ return "IndexError";
+ case SWIG_TypeError:
+ return "TypeError";
+ case SWIG_DivisionByZero:
+ return "ZeroDivisionError";
+ case SWIG_OverflowError:
+ return "OverflowError";
+ case SWIG_SyntaxError:
+ return "SyntaxError";
+ case SWIG_ValueError:
+ return "ValueError";
+ case SWIG_SystemError:
+ return "SystemError";
+ case SWIG_AttributeError:
+ return "AttributeError";
+ default:
+ return "RuntimeError";
+ }
+}
+#define SWIG_ErrorType(code) SWIG_Scilab_ErrorType(code)
+
+#ifndef SWIG_SCILAB_ERROR
+#define SWIG_SCILAB_ERROR 20000
+#endif
+
+SWIGINTERN void
+SWIG_Scilab_Error(int code, const char *msg)
+{
+ Scierror(SWIG_SCILAB_ERROR - code, _("SWIG/Scilab: %s: %s\n"), SWIG_Scilab_ErrorType(code), msg);
+}
+
+#define SWIG_Error(code, msg) SWIG_Scilab_Error(code, msg)
+
+#define SWIG_fail return SWIG_ERROR;
+
+SWIGRUNTIME void
+SWIG_Scilab_Raise_Ex(const char *obj, const char *type, swig_type_info *descriptor) {
+ if (type) {
+ if (obj)
+ Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured: %s\n", type, obj);
+ else
+ Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured.\n", type);
+ }
+}
+
+SWIGRUNTIME void
+SWIG_Scilab_Raise(const int obj, const char *type, swig_type_info *descriptor) {
+ Scierror(SWIG_SCILAB_ERROR, "SWIG/Scilab: Exception (%s) occured.\n", type);
+}
+
+/*
+ * Pointer utility functions
+ */
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C"
+#endif
+int SWIG_this(SWIG_GatewayParameters) {
+ void *ptrValue = NULL;
+ if (SwigScilabPtrToObject(pvApiCtx, 1, &ptrValue, NULL, 0, fname) == SWIG_OK) {
+ SWIG_Scilab_SetOutputPosition(1);
+ return SWIG_Scilab_SetOutput(pvApiCtx,
+ createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + 1,
+ (double)(uintptr_t)ptrValue));
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The value is not a pointer.\n"), fname, 1);
+ return SWIG_ERROR;
+ }
+}
+
+#ifdef __cplusplus
+extern "C"
+#endif
+int SWIG_ptr(SWIG_GatewayParameters) {
+ double dValue = 0;
+ int *piAddr;
+ SciErr sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr);
+ if(sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (getScalarDouble(pvApiCtx, piAddr, &dValue) == 0) {
+ if (dValue != (uintptr_t)dValue) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a pointer.\n"), fname, 1);
+ return SWIG_ValueError;
+ }
+ if ((dValue < 0) || (dValue > ULONG_MAX)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a pointer.\n"), fname, 1);
+ return SWIG_OverflowError;
+ }
+ SWIG_Scilab_SetOutputPosition(1);
+ return SWIG_Scilab_SetOutput(pvApiCtx,
+ SwigScilabPtrFromObject(pvApiCtx, 1, (void *) (uintptr_t)dValue, NULL, 0));
+ }
+ else {
+ return SWIG_ERROR;
+ }
+}
+
diff --git a/Lib/scilab/sciruntime.swg b/Lib/scilab/sciruntime.swg
new file mode 100644
index 000000000..9832ed411
--- /dev/null
+++ b/Lib/scilab/sciruntime.swg
@@ -0,0 +1,33 @@
+%insert(runtime) "swigrun.swg";
+%insert(runtime) "swigerrors.swg";
+
+#define %scilabcode %insert("scilab")
+
+%insert(runtime) "scirun.swg";
+
+%init %{
+#define SWIG_GetModule(clientdata) SWIG_Scilab_GetModule()
+#define SWIG_SetModule(clientdata, pointer) SWIG_Scilab_SetModule(pointer)
+
+SWIGRUNTIME swig_module_info*
+SWIG_Scilab_GetModule(void)
+{
+ return NULL;
+}
+
+SWIGRUNTIME void
+SWIG_Scilab_SetModule(swig_module_info *swig_module)
+{
+}
+%}
+
+%insert(init) "swiginit.swg"
+
+%init %{
+#ifdef __cplusplus
+extern "C"
+#endif
+int <module>_Init(SWIG_GatewayParameters) {
+ SWIG_InitializeModule(NULL);
+ SWIG_CreateScilabVariables(pvApiCtx);
+%}
diff --git a/Lib/scilab/scisequence.swg b/Lib/scilab/scisequence.swg
new file mode 100644
index 000000000..cc9da1fab
--- /dev/null
+++ b/Lib/scilab/scisequence.swg
@@ -0,0 +1,195 @@
+/*
+ *
+ * Scilab sequence conversions
+ *
+ */
+
+#define SWIG_Traits_Sequence_frag(Type) %fragment_name(AsVal_Traits_Sequence, Type)
+
+#define SWIG_AsCheck_Sequence_frag(Type...) %fragment_name(AsCheck_Sequence, Type)
+#define SWIG_AsCheck_Sequence_dec(Type...) %symbol_name(AsCheck_Sequence, Type)
+#define SWIG_AsGet_Sequence_frag(Type...) %fragment_name(AsGet_Sequence, Type)
+#define SWIG_AsGet_Sequence_dec(Type...) %symbol_name(AsGet_Sequence, Type)
+#define SWIG_AsSize_Sequence_frag(Type...) %fragment_name(AsSize_Sequence, Type)
+#define SWIG_AsSize_Sequence_dec(Type...) %symbol_name(AsSize_Sequence, Type)
+#define SWIG_FromCreate_Sequence_frag(Type...) %fragment_name(FromCreate_Sequence, Type)
+#define SWIG_FromCreate_Sequence_dec(Type...) %symbol_name(FromCreate_Sequence, Type)
+#define SWIG_FromSet_Sequence_frag(Type...) %fragment_name(FromSet_Sequence, Type)
+#define SWIG_FromSet_Sequence_dec(Type...) %symbol_name(FromSet_Sequence, Type)
+
+#define SWIG_Traits_SequenceItem_frag(Type) %fragment_name(AsVal_Traits_SequenceItem, Type)
+#define SWIG_AsVal_SequenceItem_frag(Type...) %fragment_name(AsVal_SequenceItem, Type)
+#define SWIG_AsVal_SequenceItem_dec(Type...) %symbol_name(AsVal_SequenceItem, Type)
+#define SWIG_From_SequenceItem_frag(Type...) %fragment_name(From_SequenceItem, Type)
+#define SWIG_From_SequenceItem_dec(Type...) %symbol_name(From_SequenceItem, Type)
+
+%include <scisequencepointer.swg>
+%include <scisequenceint.swg>
+%include <scisequencedouble.swg>
+%include <scisequencefloat.swg>
+%include <scisequencestring.swg>
+%include <scisequencebool.swg>
+
+//
+// Sequence conversion
+//
+
+%fragment(SWIG_Traits_Sequence_frag(ptr), "header",
+ fragment=SWIG_AsCheck_Sequence_frag(ptr),
+ 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="StdTraits",
+ fragment="<stdint.h>") {
+
+namespace swig {
+ // Error returned for sequence containers of default item type
+ template <typename T> struct traits_as_sequence {
+ static int check(SwigSciObject obj) {
+ SWIG_Error(SWIG_TypeError, type_name<T>());
+ }
+ static int get(SwigSciObject obj, void **sequence) {
+ SWIG_Error(SWIG_TypeError, type_name<T>());
+ }
+ static int size(SwigSciObject obj, int *size) {
+ SWIG_Error(SWIG_TypeError, type_name<T>());
+ }
+ };
+ template <typename T> struct traits_from_sequence {
+ static int create(int size, void **sequence) {
+ SWIG_Error(SWIG_TypeError, type_name<T>());
+ }
+ static SwigSciObject set(int size, void *sequence) {
+ SWIG_Error(SWIG_TypeError, type_name<T>());
+ }
+ };
+
+ // Support sequence containers of pointers
+ template <typename T> struct traits_as_sequence<T*> {
+ static int check(SwigSciObject obj) {
+ return SWIG_AsCheck_Sequence_dec(ptr)(obj);
+ }
+ static int get(SwigSciObject obj, void **sequence) {
+ return SWIG_AsGet_Sequence_dec(ptr)(obj, (int **)sequence);
+ }
+ static int size(SwigSciObject obj, int *size) {
+ return SWIG_AsSize_Sequence_dec(ptr)(obj, size);
+ }
+ };
+ template <typename T> struct traits_from_sequence<T*> {
+ static int create(int size, void **sequence) {
+ return SWIG_FromCreate_Sequence_dec(ptr)(size, (uintptr_t **)sequence);
+ }
+ static SwigSciObject set(int size, void *sequence) {
+ return SWIG_FromSet_Sequence_dec(ptr)(size, (uintptr_t *)sequence);
+ }
+ };
+}
+}
+
+%define %traits_sequence(CppType, ScilabType)
+ %fragment(SWIG_Traits_Sequence_frag(CppType), "header",
+ fragment=SWIG_Traits_Sequence_frag(ptr),
+ fragment=SWIG_AsCheck_Sequence_frag(CppType),
+ fragment=SWIG_AsGet_Sequence_frag(CppType),
+ fragment=SWIG_AsSize_Sequence_frag(CppType),
+ fragment=SWIG_FromCreate_Sequence_frag(CppType),
+ fragment=SWIG_FromSet_Sequence_frag(CppType)) {
+
+namespace swig {
+ template <> struct traits_as_sequence<CppType > {
+ static int check(SwigSciObject obj) {
+ return SWIG_AsCheck_Sequence_dec(CppType)(obj);
+ }
+ static int get(SwigSciObject obj, void **sequence) {
+ return SWIG_AsGet_Sequence_dec(CppType)(obj, (ScilabType **)sequence);
+ }
+ static int size(SwigSciObject obj, int *size) {
+ return SWIG_AsSize_Sequence_dec(CppType)(obj, size);
+ }
+ };
+ template <> struct traits_from_sequence<CppType > {
+ static int create(int size, void **sequence) {
+ return SWIG_FromCreate_Sequence_dec(CppType)(size, (ScilabType **)sequence);
+ }
+ static SwigSciObject set(int size, void *sequence) {
+ return SWIG_FromSet_Sequence_dec(CppType)(size, (ScilabType *)sequence);
+ }
+ };
+}
+}
+%enddef
+
+
+//
+// Sequence item conversion
+//
+
+%fragment(SWIG_Traits_SequenceItem_frag(ptr), "header",
+ fragment=SWIG_AsVal_SequenceItem_frag(ptr),
+ fragment=SWIG_From_SequenceItem_frag(ptr),
+ fragment="StdTraits",
+ fragment="<stdint.h>") {
+
+namespace swig {
+ // Error returned for sequence containers of default item type
+ template <typename T> struct traits_asval_sequenceitem {
+ static T asval(SwigSciObject obj, void *pSequence, int iItemIndex) {
+ SWIG_Error(SWIG_TypeError, type_name<T>());
+ }
+ };
+ template <typename T> struct traits_from_sequenceitem {
+ static int from(void *pSequence, int iItemIndex, T itemValue) {
+ SWIG_Error(SWIG_TypeError, type_name<T>());
+ }
+ };
+
+ // Support sequence containers of pointers
+ template <typename T> struct traits_asval_sequenceitem<T*> {
+ static T* asval(SwigSciObject obj, void *pSequence, int iItemIndex) {
+ return static_cast<T*>(SWIG_AsVal_SequenceItem_dec(ptr)(obj, (int *)pSequence, iItemIndex));
+ }
+ };
+ template <typename T> struct traits_from_sequenceitem<T*> {
+ static int from(void *pSequence, int iItemIndex, T *itemValue) {
+ return SWIG_From_SequenceItem_dec(ptr)((uintptr_t *)pSequence, iItemIndex, (uintptr_t) itemValue);
+ }
+ };
+}
+}
+
+%define %traits_sequenceitem(CppType, ScilabType)
+ %fragment(SWIG_Traits_SequenceItem_frag(CppType), "header",
+ fragment=SWIG_Traits_SequenceItem_frag(ptr),
+ fragment=SWIG_AsVal_SequenceItem_frag(CppType),
+ fragment=SWIG_From_SequenceItem_frag(CppType)) {
+
+namespace swig {
+ template <> struct traits_asval_sequenceitem<CppType > {
+ static CppType asval(SwigSciObject obj, void *pSequence, int iItemIndex) {
+ return SWIG_AsVal_SequenceItem_dec(CppType)(obj, (ScilabType *)pSequence, iItemIndex);
+ }
+ };
+ template <> struct traits_from_sequenceitem<CppType > {
+ static int from(void *pSequence, int iItemIndex, CppType itemValue) {
+ return SWIG_From_SequenceItem_dec(CppType)((ScilabType *)pSequence, iItemIndex, itemValue);
+ }
+ };
+}
+}
+%enddef
+
+%define %add_traits_sequence(CppType, ScilabType)
+ %traits_sequence(CppType, ScilabType);
+ %fragment(SWIG_Traits_Sequence_frag(CppType));
+ %traits_sequenceitem(CppType, ScilabType);
+ %fragment(SWIG_Traits_SequenceItem_frag(CppType));
+%enddef
+
+%add_traits_sequence(int, int);
+%add_traits_sequence(double, double);
+%add_traits_sequence(float, float);
+%add_traits_sequence(std::string, char*);
+%add_traits_sequence(bool, int);
+
diff --git a/Lib/scilab/scisequencebool.swg b/Lib/scilab/scisequencebool.swg
new file mode 100644
index 000000000..0430c3e39
--- /dev/null
+++ b/Lib/scilab/scisequencebool.swg
@@ -0,0 +1,98 @@
+/*
+ *
+ * Scilab matrix of bool <-> C++ bool container
+ *
+ */
+
+%include <scibool.swg>
+
+%fragment(SWIG_AsCheck_Sequence_frag(bool), "header") {
+
+SWIGINTERN int
+SWIG_AsCheck_Sequence_dec(bool)(SwigSciObject obj) {
+ SciErr sciErr;
+ int *piAddrVar;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (isBooleanType(pvApiCtx, piAddrVar)) {
+ return SWIG_OK;
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A boolean is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
+ return SWIG_ERROR;
+ }
+}
+}
+
+%fragment(SWIG_AsGet_Sequence_frag(bool), "header",
+ fragment="SWIG_SciBoolean_AsIntArrayAndSize") {
+
+SWIGINTERN int
+SWIG_AsGet_Sequence_dec(bool)(SwigSciObject obj, int **pSequence) {
+ int iMatrixRowCount;
+ int iMatrixColCount;
+ return (SWIG_SciBoolean_AsIntArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, pSequence, SWIG_Scilab_GetFuncName()));
+}
+}
+
+%fragment(SWIG_AsSize_Sequence_frag(bool), "header",
+ fragment="SWIG_SciBoolean_AsIntArrayAndSize") {
+
+SWIGINTERN int
+SWIG_AsSize_Sequence_dec(bool)(SwigSciObject obj, int *piSize) {
+ int *piMatrix;
+ int iMatrixRowCount;
+ int iMatrixColCount;
+ if (SWIG_SciBoolean_AsIntArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, &piMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) {
+ if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: An integer vector is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
+ return SWIG_ERROR;
+ }
+ *piSize = iMatrixRowCount * iMatrixColCount;
+ return SWIG_OK;
+ }
+ return SWIG_ERROR;
+}
+}
+
+%fragment(SWIG_FromCreate_Sequence_frag(bool), "header") {
+
+SWIGINTERN int
+SWIG_FromCreate_Sequence_dec(bool)(int size, int **pSequence) {
+ *pSequence = new int[size];
+ return *pSequence != NULL ? SWIG_OK : SWIG_ERROR;
+}
+}
+
+%fragment(SWIG_FromSet_Sequence_frag(bool), "header",
+ fragment="SWIG_SciBoolean_FromIntArrayAndSize") {
+
+SWIGINTERN SwigSciObject
+SWIG_FromSet_Sequence_dec(bool)(int size, int *pSequence) {
+ SwigSciObject obj = SWIG_SciBoolean_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence);
+ delete (int *)pSequence;
+ return obj;
+}
+}
+
+%fragment(SWIG_AsVal_SequenceItem_frag(bool), "header") {
+
+SWIGINTERN bool
+SWIG_AsVal_SequenceItem_dec(bool)(SwigSciObject obj, int *pSequence, int iItemIndex) {
+ return pSequence[iItemIndex];
+}
+}
+
+%fragment(SWIG_From_SequenceItem_frag(bool), "header") {
+
+SWIGINTERN int
+SWIG_From_SequenceItem_dec(bool)(int *pSequence, int iItemIndex, bool itemValue) {
+ pSequence[iItemIndex] = itemValue;
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/scisequencedouble.swg b/Lib/scilab/scisequencedouble.swg
new file mode 100644
index 000000000..29cc52d6a
--- /dev/null
+++ b/Lib/scilab/scisequencedouble.swg
@@ -0,0 +1,99 @@
+/*
+ *
+ * Scilab matrix of double <-> C++ double container
+ *
+ */
+
+%include <scidouble.swg>
+
+%fragment(SWIG_AsCheck_Sequence_frag(double), "header") {
+
+SWIGINTERN int
+SWIG_AsCheck_Sequence_dec(double)(SwigSciObject obj) {
+ SciErr sciErr;
+ int *piAddrVar;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (isDoubleType(pvApiCtx, piAddrVar)) {
+ return SWIG_OK;
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A double is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
+ return SWIG_ERROR;
+ }
+}
+}
+
+%fragment(SWIG_AsGet_Sequence_frag(double), "header",
+ fragment="SWIG_SciDouble_AsDoubleArrayAndSize") {
+
+SWIGINTERN int
+SWIG_AsGet_Sequence_dec(double)(SwigSciObject obj, double **pSequence) {
+ int iMatrixRowCount;
+ int iMatrixColCount;
+ return (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, pSequence, SWIG_Scilab_GetFuncName()));
+}
+}
+
+%fragment(SWIG_AsSize_Sequence_frag(double), "header",
+ fragment="SWIG_SciDouble_AsDoubleArrayAndSize") {
+
+SWIGINTERN int
+SWIG_AsSize_Sequence_dec(double)(SwigSciObject obj, int *piSize) {
+ double *pdblMatrix;
+ int iMatrixRowCount;
+ int iMatrixColCount;
+ if (SWIG_SciDouble_AsDoubleArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, &pdblMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) {
+ if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A double vector is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
+ return SWIG_ERROR;
+ }
+ *piSize = iMatrixRowCount * iMatrixColCount;
+ return SWIG_OK;
+ }
+ return SWIG_ERROR;
+}
+}
+
+%fragment(SWIG_FromCreate_Sequence_frag(double), "header") {
+
+SWIGINTERN int
+SWIG_FromCreate_Sequence_dec(double)(int size, double **pSequence) {
+ *pSequence = new double[size];
+ return *pSequence != NULL ? SWIG_OK : SWIG_ERROR;
+}
+}
+
+%fragment(SWIG_FromSet_Sequence_frag(double), "header",
+ fragment="SWIG_SciDouble_FromDoubleArrayAndSize") {
+
+SWIGINTERN SwigSciObject
+SWIG_FromSet_Sequence_dec(double)(int size, double *pSequence) {
+ SwigSciObject obj = SWIG_SciDouble_FromDoubleArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence);
+ delete (double *)pSequence;
+ return obj;
+}
+}
+
+%fragment(SWIG_AsVal_SequenceItem_frag(double), "header") {
+
+SWIGINTERN double
+SWIG_AsVal_SequenceItem_dec(double)(SwigSciObject obj, double *pSequence, int iItemIndex) {
+ return pSequence[iItemIndex];
+}
+}
+
+%fragment(SWIG_From_SequenceItem_frag(double), "header") {
+
+SWIGINTERN int
+SWIG_From_SequenceItem_dec(double)(double *pSequence, int iItemIndex, double itemValue) {
+ pSequence[iItemIndex] = itemValue;
+ return SWIG_OK;
+}
+}
+
diff --git a/Lib/scilab/scisequencefloat.swg b/Lib/scilab/scisequencefloat.swg
new file mode 100644
index 000000000..41d37e558
--- /dev/null
+++ b/Lib/scilab/scisequencefloat.swg
@@ -0,0 +1,98 @@
+/*
+ *
+ * Scilab matrix of float <-> C++ float container
+ *
+ */
+
+%include <scifloat.swg>
+
+%fragment(SWIG_AsCheck_Sequence_frag(float), "header") {
+
+SWIGINTERN int
+SWIG_AsCheck_Sequence_dec(float)(SwigSciObject obj) {
+ SciErr sciErr;
+ int *piAddrVar;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (isDoubleType(pvApiCtx, piAddrVar)) {
+ return SWIG_OK;
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A double is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
+ return SWIG_ERROR;
+ }
+}
+}
+
+%fragment(SWIG_AsGet_Sequence_frag(float), "header",
+ fragment="SWIG_SciDouble_AsFloatArrayAndSize") {
+
+SWIGINTERN int
+SWIG_AsGet_Sequence_dec(float)(SwigSciObject obj, float **pSequence) {
+ int iMatrixRowCount;
+ int iMatrixColCount;
+ return (SWIG_SciDouble_AsFloatArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, pSequence, SWIG_Scilab_GetFuncName()));
+}
+}
+
+%fragment(SWIG_AsSize_Sequence_frag(float), "header",
+ fragment="SWIG_SciDouble_AsFloatArrayAndSize") {
+
+SWIGINTERN int
+SWIG_AsSize_Sequence_dec(float)(SwigSciObject obj, int *piSize) {
+ float *pdblMatrix;
+ int iMatrixRowCount;
+ int iMatrixColCount;
+ if (SWIG_SciDouble_AsFloatArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, &pdblMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) {
+ if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A float vector is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
+ return SWIG_ERROR;
+ }
+ *piSize = iMatrixRowCount * iMatrixColCount;
+ return SWIG_OK;
+ }
+ return SWIG_ERROR;
+}
+}
+
+%fragment(SWIG_FromCreate_Sequence_frag(float), "header") {
+
+SWIGINTERN int
+SWIG_FromCreate_Sequence_dec(float)(int size, float **pSequence) {
+ *pSequence = new float[size];
+ return *pSequence != NULL ? SWIG_OK : SWIG_ERROR;
+}
+}
+
+%fragment(SWIG_FromSet_Sequence_frag(float), "header",
+ fragment="SWIG_SciDouble_FromFloatArrayAndSize") {
+
+SWIGINTERN SwigSciObject
+SWIG_FromSet_Sequence_dec(float)(int size, float *pSequence) {
+ SwigSciObject obj = SWIG_SciDouble_FromFloatArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence);
+ delete (float *)pSequence;
+ return obj;
+}
+}
+
+%fragment(SWIG_AsVal_SequenceItem_frag(float), "header") {
+
+SWIGINTERN float
+SWIG_AsVal_SequenceItem_dec(float)(SwigSciObject obj, float *pSequence, int iItemIndex) {
+ return pSequence[iItemIndex];
+}
+}
+
+%fragment(SWIG_From_SequenceItem_frag(float), "header") {
+SWIGINTERN int
+SWIG_From_SequenceItem_dec(float)(float *pSequence, int iItemIndex, float itemValue) {
+ pSequence[iItemIndex] = itemValue;
+ return SWIG_OK;
+}
+}
+
diff --git a/Lib/scilab/scisequenceint.swg b/Lib/scilab/scisequenceint.swg
new file mode 100644
index 000000000..3a9f7bf63
--- /dev/null
+++ b/Lib/scilab/scisequenceint.swg
@@ -0,0 +1,104 @@
+/*
+ *
+ * Scilab matrix of int <-> C++ int container
+ *
+ */
+
+%include <sciint.swg>
+
+%fragment(SWIG_AsCheck_Sequence_frag(int), "header") {
+
+SWIGINTERN int
+SWIG_AsCheck_Sequence_dec(int)(SwigSciObject obj) {
+ SciErr sciErr;
+ int *piAddrVar;
+ int iType = 0;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if ((iType == sci_matrix) || (iType == sci_ints)) {
+ return SWIG_OK;
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: An integer is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
+ return SWIG_ERROR;
+ }
+}
+}
+
+%fragment(SWIG_AsGet_Sequence_frag(int), "header",
+ fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") {
+SWIGINTERN int
+SWIG_AsGet_Sequence_dec(int)(SwigSciObject obj, int **pSequence) {
+ int iMatrixRowCount;
+ int iMatrixColCount;
+ return (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, pSequence, SWIG_Scilab_GetFuncName()));
+}
+}
+
+%fragment(SWIG_AsSize_Sequence_frag(int), "header",
+ fragment="SWIG_SciDoubleOrInt32_AsIntArrayAndSize") {
+
+SWIGINTERN int
+SWIG_AsSize_Sequence_dec(int)(SwigSciObject obj, int *piSize) {
+ int *piMatrix;
+ int iMatrixRowCount;
+ int iMatrixColCount;
+ if (SWIG_SciDoubleOrInt32_AsIntArrayAndSize(pvApiCtx, obj, &iMatrixRowCount, &iMatrixColCount, &piMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) {
+ if ((iMatrixRowCount > 1) && (iMatrixColCount > 1)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: An integer vector is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
+ return SWIG_ERROR;
+ }
+ *piSize = iMatrixRowCount * iMatrixColCount;
+ return SWIG_OK;
+ }
+ return SWIG_ERROR;
+}
+}
+
+%fragment(SWIG_FromCreate_Sequence_frag(int), "header") {
+
+SWIGINTERN int
+SWIG_FromCreate_Sequence_dec(int)(int size, int **pSequence) {
+ *pSequence = new int[size];
+ return *pSequence != NULL ? SWIG_OK : SWIG_ERROR;
+}
+}
+
+%fragment(SWIG_FromSet_Sequence_frag(int), "header",
+ fragment="SWIG_SciDouble_FromIntArrayAndSize") {
+
+SWIGINTERN SwigSciObject
+SWIG_FromSet_Sequence_dec(int)(int size, int *pSequence) {
+ SwigSciObject obj = SWIG_SciDouble_FromIntArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence);
+ delete (int *)pSequence;
+ return obj;
+}
+}
+
+%fragment(SWIG_AsVal_SequenceItem_frag(int), "header") {
+
+SWIGINTERN int
+SWIG_AsVal_SequenceItem_dec(int)(SwigSciObject obj, int *pSequence, int iItemIndex) {
+ return pSequence[iItemIndex];
+}
+}
+
+%fragment(SWIG_From_SequenceItem_frag(int), "header") {
+
+SWIGINTERN int
+SWIG_From_SequenceItem_dec(int)(int *pSequence, int iItemIndex, int itemValue) {
+ pSequence[iItemIndex] = itemValue;
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/scisequencepointer.swg b/Lib/scilab/scisequencepointer.swg
new file mode 100644
index 000000000..b3618e941
--- /dev/null
+++ b/Lib/scilab/scisequencepointer.swg
@@ -0,0 +1,123 @@
+/*
+ *
+ * Scilab list of pointer <-> C++ pointer container
+ *
+ */
+
+%include <scilist.swg>
+
+%fragment("<stdint.h>", "header") {
+%#include <stdint.h>
+}
+
+%fragment(SWIG_AsCheck_Sequence_frag(ptr), "header",
+ fragment="SWIG_ScilabList") {
+
+SWIGINTERN int
+SWIG_AsCheck_Sequence_dec(ptr)(SwigSciObject obj) {
+ return SWIG_CheckScilabList(obj);
+}
+}
+
+%fragment(SWIG_AsGet_Sequence_frag(ptr), "header",
+ fragment="SWIG_ScilabList") {
+
+SWIGINTERN int
+SWIG_AsGet_Sequence_dec(ptr)(SwigSciObject obj, int **piSequence) {
+ return SWIG_GetScilabList(obj, piSequence);
+}
+}
+
+%fragment(SWIG_AsSize_Sequence_frag(ptr), "header",
+ fragment="SWIG_ScilabList") {
+
+SWIGINTERN int
+SWIG_AsSize_Sequence_dec(ptr)(SwigSciObject obj, int *piSize) {
+ return SWIG_GetScilabListSize(obj, piSize);
+}
+}
+
+%fragment(SWIG_FromCreate_Sequence_frag(ptr), "header",
+ fragment="<stdint.h>") {
+
+SWIGINTERN int
+SWIG_FromCreate_Sequence_dec(ptr)(int size, uintptr_t **pSequence) {
+ *pSequence = new uintptr_t[size];
+ return *pSequence != NULL ? SWIG_OK : SWIG_ERROR;
+}
+}
+
+%fragment(SWIG_FromSet_Sequence_frag(ptr), "header",
+ fragment="<stdint.h>") {
+
+SWIGINTERN SwigSciObject
+SWIG_FromSet_Sequence_dec(ptr)(int size, uintptr_t *pSequence) {
+ SciErr sciErr;
+ int *piListAddr;
+
+ int iVarOut = SWIG_NbInputArgument(pvApiCtx) + SWIG_Scilab_GetOutputPosition();
+
+ sciErr = createList(pvApiCtx, iVarOut, size, &piListAddr);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ for (int i=0; i<size; i++) {
+ sciErr = createPointerInList(pvApiCtx, iVarOut, piListAddr, i + 1, (void *)pSequence[i]);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ delete (int*)pSequence;
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_AsVal_SequenceItem_frag(ptr), "header") {
+
+SWIGINTERN void*
+SWIG_AsVal_SequenceItem_dec(ptr)(SwigSciObject obj, int *piSequence, int itemIndex)
+{
+ SciErr sciErr;
+ int *piItemAddr;
+ int iType;
+ void* pItemValue = NULL;
+
+ sciErr = getListItemAddress(pvApiCtx, piSequence, itemIndex + 1, &piItemAddr);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return NULL;
+ }
+
+ sciErr = getVarType(pvApiCtx, piItemAddr, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return NULL;
+ }
+
+ if (iType != sci_pointer) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A pointer is expected at list item #%d.\n"), SWIG_Scilab_GetFuncName(), obj, itemIndex + 1);
+ return NULL;
+ }
+
+ sciErr = getPointerInList(pvApiCtx, piSequence, itemIndex + 1, &pItemValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return NULL;
+ }
+
+ return pItemValue;
+}
+}
+
+%fragment(SWIG_From_SequenceItem_frag(ptr), "header",
+ fragment="<stdint.h>") {
+
+SWIGINTERN int
+SWIG_From_SequenceItem_dec(ptr)(uintptr_t *pSequence, int iItemIndex, uintptr_t itemValue) {
+ pSequence[iItemIndex] = itemValue;
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/scisequencestring.swg b/Lib/scilab/scisequencestring.swg
new file mode 100644
index 000000000..36f0927a8
--- /dev/null
+++ b/Lib/scilab/scisequencestring.swg
@@ -0,0 +1,97 @@
+/*
+ *char
+ * Scilab matrix of string <-> C++ std::string container
+ *
+ */
+
+%include <scichar.swg>
+
+%fragment(SWIG_AsCheck_Sequence_frag(std::string), "header") {
+
+SWIGINTERN int
+SWIG_AsCheck_Sequence_dec(std::string)(SwigSciObject obj) {
+ SciErr sciErr;
+ int *piAddrVar;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, obj, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (isStringType(pvApiCtx, piAddrVar)) {
+ return SWIG_OK;
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A string is expected.\n"), SWIG_Scilab_GetFuncName(), obj);
+ return SWIG_ERROR;
+ }
+}
+}
+
+%fragment(SWIG_AsGet_Sequence_frag(std::string), "header",
+ fragment="SWIG_SciString_AsCharPtrArrayAndSize") {
+
+SWIGINTERN int
+SWIG_AsGet_Sequence_dec(std::string)(SwigSciObject obj, char ***pSequence) {
+ int iRows = 0;
+ int iCols = 0;
+ return (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, obj, &iRows, &iCols, pSequence, SWIG_Scilab_GetFuncName()));
+}
+}
+
+%fragment(SWIG_AsSize_Sequence_frag(std::string), "header",
+ fragment="SWIG_SciString_AsCharPtrArrayAndSize") {
+
+SWIGINTERN int
+SWIG_AsSize_Sequence_dec(std::string)(SwigSciObject obj, int *piSize) {
+ char **pstMatrix;
+ int iCols = 0;
+ int iRows = 0;
+ if (SWIG_SciString_AsCharPtrArrayAndSize(pvApiCtx, obj, &iRows, &iCols, &pstMatrix, SWIG_Scilab_GetFuncName()) == SWIG_OK) {
+ *piSize = iRows * iCols;
+ return SWIG_OK;
+ }
+ return SWIG_ERROR;
+}
+}
+
+%fragment(SWIG_FromCreate_Sequence_frag(std::string), "header") {
+
+SWIGINTERN int
+SWIG_FromCreate_Sequence_dec(std::string)(int size, char ***pSequence) {
+ *pSequence = new char*[size];
+ return *pSequence != NULL ? SWIG_OK : SWIG_ERROR;
+}
+}
+
+%fragment(SWIG_FromSet_Sequence_frag(std::string), "header",
+ fragment="SWIG_SciString_FromCharPtrArrayAndSize") {
+
+SWIGINTERN SwigSciObject
+SWIG_FromSet_Sequence_dec(std::string)(int size, char **pSequence) {
+ SwigSciObject obj = SWIG_SciString_FromCharPtrArrayAndSize(pvApiCtx, SWIG_Scilab_GetOutputPosition(), 1, size, pSequence);
+ delete (char **)pSequence;
+ return obj;
+}
+}
+
+%fragment(SWIG_AsVal_SequenceItem_frag(std::string), "header") {
+
+SWIGINTERN std::string
+SWIG_AsVal_SequenceItem_dec(std::string)(SwigSciObject obj, char **pSequence, int iItemIndex) {
+ return std::string(pSequence[iItemIndex]);
+}
+}
+
+%fragment(SWIG_From_SequenceItem_frag(std::string), "header") {
+
+SWIGINTERN int
+SWIG_From_SequenceItem_dec(std::string)(char **pSequence, int iItemIndex, std::string itemValue) {
+ char *pChar = new char(itemValue.size() + 1);
+ strcpy(pChar, itemValue.c_str());
+ pSequence[iItemIndex] = pChar;
+ return SWIG_OK;
+}
+}
+
diff --git a/Lib/scilab/scishort.swg b/Lib/scilab/scishort.swg
new file mode 100644
index 000000000..3d2f0f97a
--- /dev/null
+++ b/Lib/scilab/scishort.swg
@@ -0,0 +1,188 @@
+/*
+ * C-type: short
+ * Scilab type: double or int16
+ */
+
+%fragment(SWIG_AsVal_frag(short), "header", fragment="SWIG_SciDoubleOrInt16_AsShort", fragment="<limits.h>") {
+#define SWIG_AsVal_short(scilabValue, valuePointer) SWIG_SciDoubleOrInt16_AsShort(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDoubleOrInt16_AsShort", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrInt16_AsShort(void *pvApiCtx, int iVar, short *psValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int iRows = 0;
+ int iCols = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_ints) {
+ int iPrec = 0;
+ short *psData = NULL;
+
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iPrec != SCI_INT16) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ sciErr = getMatrixOfInteger16(pvApiCtx, piAddrVar, &iRows, &iCols, &psData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 16-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ *psValue = *psData;
+ }
+ else if (iType == sci_matrix) {
+ double *pdData = NULL;
+ double dValue = 0.0f;
+
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 16-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ dValue = *pdData;
+ if (dValue != floor(dValue)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 16-bit signed integer.\n"), fname, iVar);
+ return SWIG_ValueError;
+ }
+ if ((dValue < SHRT_MIN) || (dValue > SHRT_MAX)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 16-bit signed integer.\n"), fname, iVar);
+ return SWIG_OverflowError;
+ }
+ *psValue = (short) dValue;
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(short), "header", fragment="SWIG_SciDouble_FromShort") {
+#define SWIG_From_short(scilabValue) SWIG_SciDouble_FromShort(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDouble_FromShort", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromShort(void *pvApiCtx, int iVarOut, short sValue, char *fname) {
+ if (createScalarDouble(pvApiCtx,
+ SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) sValue))
+ return SWIG_ERROR;
+ return SWIG_OK;
+}
+}
+
+/*
+ * C-type: short[]
+ * Scilab type: double or int16 matrix
+ */
+%fragment("SWIG_SciDoubleOrInt16_AsShortArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrInt16_AsShortArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, short **psValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int iPrec = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_matrix) {
+ double *pdData = NULL;
+ int size = 0;
+ int i;
+
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ size = (*iRows) * (*iCols);
+ *psValue = (short*) malloc(size * sizeof(int*));
+ for (i = 0; i < size; i++)
+ (*psValue)[i] = (short) pdData[i];
+ }
+ else if (iType == sci_ints) {
+ int iPrec = 0;
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iPrec != SCI_INT16) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit signed integer or a double matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getMatrixOfInteger16(pvApiCtx, piAddrVar, iRows, iCols, psValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit signed integer or a double matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+%fragment("SWIG_SciDouble_FromShortArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromShortArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, short *psValue) {
+ SciErr sciErr;
+ int i;
+ double *pdValues = NULL;
+
+ pdValues = (double*) malloc(iRows * iCols * sizeof(double));
+ for (i=0; i<iRows * iCols; i++)
+ pdValues[i] = psValue[i];
+
+ sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ free(pdValues);
+ return SWIG_ERROR;
+ }
+
+ free(pdValues);
+ return SWIG_OK;
+}
+}
+
diff --git a/Lib/scilab/scisignedchar.swg b/Lib/scilab/scisignedchar.swg
new file mode 100644
index 000000000..c2350b0c1
--- /dev/null
+++ b/Lib/scilab/scisignedchar.swg
@@ -0,0 +1,185 @@
+/*
+ * C-type: signed char
+ * Scilab type: double or int8
+ */
+%fragment(SWIG_AsVal_frag(signed char), "header", fragment="SWIG_SciDoubleOrInt8_AsSignedChar", fragment="<limits.h>") {
+#define SWIG_AsVal_signed_SS_char(scilabValue, valuePointer) SWIG_SciDoubleOrInt8_AsSignedChar(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDoubleOrInt8_AsSignedChar", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrInt8_AsSignedChar(void *pvApiCtx, int iVar, signed char *pscValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int iRows = 0;
+ int iCols = 0;
+ int iPrec = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_ints) {
+ char *pcData = NULL;
+
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iPrec != SCI_INT8) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ sciErr = getMatrixOfInteger8(pvApiCtx, piAddrVar, &iRows, &iCols, &pcData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 8-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ *pscValue = *pcData;
+ }
+ else if (iType == sci_matrix) {
+ double *pdData = NULL;
+ double dValue = 0.0f;
+
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 8-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ dValue = *pdData;
+ if (dValue != floor(dValue)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 8-bit signed integer.\n"), fname, iVar);
+ return SWIG_ValueError;
+ }
+ if ((dValue < SCHAR_MIN) || (dValue > SCHAR_MAX)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 8-bit signed integer.\n"), fname, iVar);
+ return SWIG_OverflowError;
+ }
+ *pscValue = (signed char) dValue;
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit signed integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(signed char), "header", fragment="SWIG_SciDouble_FromSignedChar") {
+#define SWIG_From_signed_SS_char(scilabValue) SWIG_SciDouble_FromSignedChar(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue)
+}
+%fragment("SWIG_SciDouble_FromSignedChar", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromSignedChar(void *pvApiCtx, int iVarOut, signed char scValue) {
+ if (createScalarDouble(pvApiCtx,
+ SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) scValue))
+ return SWIG_ERROR;
+ return SWIG_OK;
+}
+}
+
+/*
+ * C-type: signed char[]
+ * Scilab type: double or int8 matrix
+ */
+%fragment("SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrInt8_AsSignedCharArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, signed char **pscValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_matrix) {
+ double *pdData = NULL;
+ int size = 0;
+ int i;
+
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ size = (*iRows) * (*iCols);
+ *pscValue = (signed char*) malloc(size * sizeof(int*));
+ for (i = 0; i < size; i++)
+ (*pscValue)[i] = (signed char) pdData[i];
+ }
+ else if (iType == sci_ints) {
+ int iPrec = 0;
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iPrec != SCI_INT8) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit signed integer or a double matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getMatrixOfInteger8(pvApiCtx, piAddrVar, iRows, iCols, (char **)pscValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit signed integer or a double matrix expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciDouble_FromSignedCharArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromSignedCharArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const signed char *pscValue) {
+ SciErr sciErr;
+ int i;
+ double *pdValues = NULL;
+
+ pdValues = (double*) malloc(iRows * iCols * sizeof(double));
+ for (i=0; i<iRows * iCols; i++)
+ pdValues[i] = pscValue[i];
+
+ sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ free(pdValues);
+ return SWIG_ERROR;
+ }
+
+ free(pdValues);
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/scistdcommon.swg b/Lib/scilab/scistdcommon.swg
new file mode 100644
index 000000000..7fdc72212
--- /dev/null
+++ b/Lib/scilab/scistdcommon.swg
@@ -0,0 +1,226 @@
+%fragment("StdTraits","header",fragment="StdTraitsCommon")
+{
+namespace swig {
+// Traits that provides the from method
+ template <class Type> struct traits_from_ptr {
+ static SwigSciObject from(Type *val, int owner = 0) {
+ return SWIG_OK; //SWIG_NewPointerObj(val, type_info<Type>(), owner);
+ }
+ };
+
+ template <class Type> struct traits_from {
+ static SwigSciObject from(const Type& val) {
+ return traits_from_ptr<Type>::from(new Type(val), 1);
+ }
+ };
+
+ template <class Type> struct traits_from<Type *> {
+ static SwigSciObject from(Type* val) {
+ return traits_from_ptr<Type>::from(val, 0);
+ }
+ };
+
+ template <class Type> struct traits_from<const Type *> {
+ static SwigSciObject from(const Type* val) {
+ return traits_from_ptr<Type>::from(const_cast<Type*>(val), 0);
+ }
+ };
+
+
+ template <class Type>
+ inline SwigSciObject from(const Type& val) {
+ return traits_from<Type>::from(val);
+ }
+
+ template <class Type>
+ inline SwigSciObject from_ptr(Type* val, int owner) {
+ return traits_from_ptr<Type>::from(val, owner);
+ }
+
+ // Traits that provides the asval/as/check method
+ template <class Type>
+ struct traits_asptr {
+ static int asptr(const SwigSciObject& obj, Type **val) {
+ Type *p;
+ int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
+ if (SWIG_IsOK(res)) {
+ if (val) *val = p;
+ }
+ return res;
+ }
+ };
+
+ template <class Type>
+ inline int asptr(const SwigSciObject& obj, Type **vptr) {
+ return traits_asptr<Type>::asptr(obj, vptr);
+ }
+
+ template <class Type>
+ struct traits_asval {
+ static int asval(const SwigSciObject& obj, Type *val) {
+ if (val) {
+ Type *p = 0;
+ int res = traits_asptr<Type>::asptr(obj, &p);
+ if (!SWIG_IsOK(res))
+ return res;
+ if (p) {
+ typedef typename noconst_traits<Type>::noconst_type noconst_type;
+ *(const_cast<noconst_type*>(val)) = *p;
+ if (SWIG_IsNewObj(res)){
+ %delete(p);
+ res = SWIG_DelNewMask(res);
+ }
+ return res;
+ } else {
+ return SWIG_ERROR;
+ }
+ } else {
+ return traits_asptr<Type>::asptr(obj, (Type **)(0));
+ }
+ }
+ };
+
+ template <class Type> struct traits_asval<Type*> {
+ static int asval(const SwigSciObject& obj, Type **val) {
+ if (val) {
+ typedef typename noconst_traits<Type>::noconst_type noconst_type;
+ noconst_type *p = 0;
+ int res = traits_asptr<noconst_type>::asptr(obj, &p);
+ if (SWIG_IsOK(res)) {
+ *(const_cast<noconst_type**>(val)) = p;
+ }
+ return res;
+ } else {
+ return traits_asptr<Type>::asptr(obj, (Type **)(0));
+ }
+ }
+ };
+
+ template <class Type>
+ inline int asval(const SwigSciObject& obj, Type *val) {
+ return traits_asval<Type>::asval(obj, val);
+ }
+
+ template <class Type>
+ struct traits_as<Type, value_category> {
+ static Type as(const SwigSciObject& obj, bool throw_error) {
+ Type v;
+ int res = asval(obj, &v);
+ if (SWIG_IsOK(res)) {
+ return v;
+ } else {
+ %type_error(swig::type_name<Type>());
+ if (throw_error)
+ throw std::invalid_argument("bad type");
+ return res;
+ }
+ }
+ };
+
+ template <class Type>
+ struct traits_as<Type, pointer_category> {
+ static Type as(const SwigSciObject& obj, bool throw_error) {
+ Type *v = 0;
+ int res = traits_asptr<Type>::asptr(obj, &v);
+ if (SWIG_IsOK(res) && v) {
+ if (SWIG_IsNewObj(res)) {
+ Type r(*v);
+ %delete(v);
+ return r;
+ } else {
+ return *v;
+ }
+ } else {
+ // Uninitialized return value, no Type() constructor required.
+ static Type *v_def = (Type*) malloc(sizeof(Type));
+ %type_error(swig::type_name<Type>());
+ if (throw_error)
+ throw std::invalid_argument("bad type");
+ memset(v_def,0,sizeof(Type));
+ return *v_def;
+ }
+ }
+ };
+
+ template <class Type>
+ struct traits_as<Type*, pointer_category> {
+ static Type* as(const SwigSciObject& obj, bool throw_error) {
+ Type *v = 0;
+ int res = traits_asptr<Type>::asptr(obj, &v);
+ if (SWIG_IsOK(res)) {
+ return v;
+ } else {
+ %type_error(swig::type_name<Type>());
+ if (throw_error)
+ throw std::invalid_argument("bad type");
+ return SWIG_OK;
+ }
+ }
+ };
+
+ template <class Type>
+ inline Type as(const SwigSciObject& obj, bool te = false) {
+ return traits_as<Type, typename traits<Type>::category>::as(obj, te);
+ }
+
+ template <class Type>
+ struct traits_check<Type, value_category> {
+ static bool check(const SwigSciObject& obj) {
+ int res = asval(obj, (Type *)(0));
+ return SWIG_IsOK(res) ? true : false;
+ }
+ };
+
+ template <class Type>
+ struct traits_check<Type, pointer_category> {
+ static bool check(const SwigSciObject& obj) {
+ int res = asptr(obj, (Type **)(0));
+ return SWIG_IsOK(res) ? true : false;
+ }
+ };
+
+ template <class Type>
+ inline bool check(const SwigSciObject& obj) {
+ return traits_check<Type, typename traits<Type>::category>::check(obj);
+ }
+}
+}
+
+%define %specialize_std_container(Type,Check,As,From)
+%{
+namespace swig {
+ template <> struct traits_asval<Type > {
+ typedef Type value_type;
+ static int asval(const SwigSciObject& obj, value_type *val) {
+ if (Check(obj)) {
+ if (val) *val = As(obj);
+ return SWIG_OK;
+ }
+ return SWIG_ERROR;
+ }
+ };
+ template <> struct traits_from<Type > {
+ typedef Type value_type;
+ static SwigSciObject from(const value_type& val) {
+ return From(val);
+ }
+ };
+
+ template <>
+ struct traits_check<Type, value_category> {
+ static int check(const SwigSciObject& obj) {
+ int res = Check(obj);
+ return obj && res ? res : 0;
+ }
+ };
+}
+%}
+%enddef
+
+
+#define specialize_std_vector(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
+#define specialize_std_list(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
+#define specialize_std_deque(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
+#define specialize_std_set(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
+#define specialize_std_multiset(Type,Check,As,From) %specialize_std_container(%arg(Type),Check,As,From)
+
diff --git a/Lib/scilab/scitypemaps.swg b/Lib/scilab/scitypemaps.swg
new file mode 100644
index 000000000..62a819f35
--- /dev/null
+++ b/Lib/scilab/scitypemaps.swg
@@ -0,0 +1,243 @@
+// Scilab fragments for primitive types
+%include <sciprimtypes.swg>
+
+%include <scienum.swg>
+
+// Scilab object type
+#define SWIG_Object int
+
+#define %append_output(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR
+#define %set_constant(name, obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR // Name is managed by the the function name
+#define %raise(obj, type, desc) SWIG_Scilab_Raise(obj, type, desc)
+#define %set_output(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR
+#define %set_varoutput(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR
+#define %set_argoutput(obj) if (!SWIG_IsOK(SWIG_Scilab_SetOutput(pvApiCtx, obj))) return SWIG_ERROR
+
+// Include the unified typemap library
+%include <typemaps/swigtypemaps.swg>
+
+/* ---------------------------------------------------------------------------*/
+/* Generic typmemaps */
+/* */
+/* This typemap is used when Scilab does not store this type directly */
+/* For example, a 'float' is stored in Scilab as a 'double' */
+/* So we read a 'double' in Scilab and cast it to a 'float' */
+/* ---------------------------------------------------------------------------*/
+
+%define %scilab_in_typemap_withcast(TYPEMAPTYPE, FRAGMENTNAME, CTYPE, TEMPTYPE, TEMPINIT)
+%typemap(TYPEMAPTYPE, fragment="FRAGMENTNAME") CTYPE {
+ TEMPTYPE tempValue = TEMPINIT;
+ if(FRAGMENTNAME(pvApiCtx, $input, &tempValue, SWIG_Scilab_GetFuncName()) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+ $1 = (CTYPE) tempValue;
+}
+%enddef
+%define %scilab_inptr_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE)
+%typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE {
+ if (FRAGMENTNAME(pvApiCtx, $input, %as_voidptrptr(&$1), SWIG_Scilab_GetFuncName()) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+%enddef
+
+%define %scilab_out_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE)
+%typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE {
+ if (FRAGMENTNAME(pvApiCtx, $result, $1) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+%enddef
+
+%define %scilab_outptr_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE)
+%typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE {
+ if (FRAGMENTNAME(pvApiCtx, $result, %as_voidptr($1)) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+%enddef
+
+%define %scilab_varout_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE)
+%typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE {
+ if (FRAGMENTNAME(pvApiCtx, $result, $value) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+%enddef
+
+%define %scilab_varoutptr_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE)
+%typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE {
+ if (FRAGMENTNAME(pvApiCtx, $result, %as_voidptr($value)) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+%enddef
+
+%define %scilab_in_typemap(TYPEMAPTYPE, FRAGMENTNAME, CTYPE)
+%typemap(TYPEMAPTYPE, noblock=1, fragment="FRAGMENTNAME") CTYPE {
+ if (FRAGMENTNAME(pvApiCtx, $input, &$1, SWIG_Scilab_GetFuncName()) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+%enddef
+
+
+/* ---------------------------------------------------------------------------*/
+/* Array typmemaps */
+/* ---------------------------------------------------------------------------*/
+
+%include <sciarray.swg>
+
+
+/* ---------------------------------------------------------------------------*/
+/* Enum typemaps */
+/* ---------------------------------------------------------------------------*/
+
+%typemap(in, noblock=1, fragment=SWIG_AsVal_frag(Enum)) enum SWIGTYPE (int val) {
+ if (SWIG_AsVal_dec(Enum)($input, &val) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+ $1 = %reinterpret_cast(val, $ltype);
+}
+
+%typemap(out, fragment=SWIG_From_frag(Enum)) enum SWIGTYPE {
+ if (SWIG_From_dec(Enum)($1) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+}
+
+/* ---------------------------------------------------------------------------*/
+/* Typecheck typemaps */
+/* ---------------------------------------------------------------------------*/
+
+%define %scilab_typecheck_generic(PRECEDENCE, TYPE_CHECK_FUNCTION, TYPE)
+%typecheck(PRECEDENCE) TYPE {
+ int *piAddrVar = NULL;
+ SciErr sciErr = getVarAddressFromPosition(pvApiCtx, $input, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ $1 = TYPE_CHECK_FUNCTION(pvApiCtx, piAddrVar);
+}
+%enddef
+
+/* Scilab equivalent for C integers can be sci_ints or sci_matrix */
+%define %scilab_typecheck_integer(PRECEDENCE, INTTYPE, TYPE)
+%typecheck(PRECEDENCE) TYPE {
+ int *piAddrVar = NULL;
+ SciErr sciErr = getVarAddressFromPosition(pvApiCtx, $input, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ $1 = isIntegerType(pvApiCtx, piAddrVar);
+ if ($1 == 1) {
+ int iPrec = 0;
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ $1 = (iPrec == INTTYPE) ? 1 : 0;
+ }
+ else {
+ $1 = isDoubleType(pvApiCtx, piAddrVar);
+ }
+}
+%enddef
+
+// Double (and Float) have priority over before Integer type.
+
+// Primitive types
+%scilab_typecheck_generic(SWIG_TYPECHECK_VOIDPTR, isPointerType, SWIGTYPE *)
+%scilab_typecheck_generic(SWIG_TYPECHECK_POINTER, isPointerType, SWIGTYPE *)
+%scilab_typecheck_generic(SWIG_TYPECHECK_BOOL, isBooleanType, bool)
+%scilab_typecheck_generic(16, isDoubleType, double)
+%scilab_typecheck_generic(17, isDoubleType, float)
+%scilab_typecheck_integer(SWIG_TYPECHECK_INT8, SCI_INT8, signed char)
+%scilab_typecheck_integer(SWIG_TYPECHECK_UINT8, SCI_UINT8, unsigned char)
+%scilab_typecheck_integer(SWIG_TYPECHECK_INT16, SCI_INT16, short)
+%scilab_typecheck_integer(SWIG_TYPECHECK_UINT16, SCI_UINT16, unsigned short)
+%scilab_typecheck_integer(SWIG_TYPECHECK_INT32, SCI_INT32, int)
+%scilab_typecheck_integer(SWIG_TYPECHECK_INT32, SCI_INT32, long)
+%scilab_typecheck_integer(SWIG_TYPECHECK_UINT32, SCI_UINT32, unsigned int)
+%scilab_typecheck_integer(SWIG_TYPECHECK_UINT32, SCI_UINT32, unsigned long)
+%scilab_typecheck_integer(SWIG_TYPECHECK_INT32, SCI_INT32, enum SWIGTYPE)
+%scilab_typecheck_generic(SWIG_TYPECHECK_CHAR, isStringType, char)
+
+// Arrays
+%scilab_typecheck_generic(SWIG_TYPECHECK_BOOL_ARRAY, isBooleanType, bool)
+%scilab_typecheck_generic(1016, isDoubleType, double [ANY])
+%scilab_typecheck_generic(1017, isDoubleType, float [ANY])
+%scilab_typecheck_integer(SWIG_TYPECHECK_INT8_ARRAY, SCI_INT8, signed char [ANY])
+%scilab_typecheck_integer(1026, SCI_UINT8, unsigned char [ANY])
+%scilab_typecheck_integer(SWIG_TYPECHECK_INT16_ARRAY, SCI_INT16, short [ANY])
+%scilab_typecheck_integer(1036, SCI_UINT16, unsigned short [ANY])
+%scilab_typecheck_integer(SWIG_TYPECHECK_INT32_ARRAY, SCI_INT32, int [ANY])
+%scilab_typecheck_integer(SWIG_TYPECHECK_INT32_ARRAY, SCI_INT32, long [ANY])
+%scilab_typecheck_integer(1046, SCI_UINT32, unsigned int [ANY])
+%scilab_typecheck_integer(1046, SCI_UINT32, unsigned long [ANY])
+%scilab_typecheck_generic(SWIG_TYPECHECK_CHAR_ARRAY, isStringType, char [ANY])
+%scilab_typecheck_generic(SWIG_TYPECHECK_STRING_ARRAY, isStringType, char *[ANY])
+%scilab_typecheck_generic(SWIG_TYPECHECK_STRING_ARRAY, isStringType, char **)
+
+
+/* ---------------------------------------------------------------------------*/
+/* %scilabconstcode() feature typemaps */
+/* ---------------------------------------------------------------------------*/
+
+%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(double)) double
+%{
+ if (SWIG_CreateScilabVariable_double(pvApiCtx, "$result", $value) != SWIG_OK)
+ return SWIG_ERROR;
+%}
+
+%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(int)) int
+%{
+ if (SWIG_CreateScilabVariable_int(pvApiCtx, "$result", $value) != SWIG_OK)
+ return SWIG_ERROR;
+%}
+
+%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(uint)) unsigned int
+%{
+ if (SWIG_CreateScilabVariable_uint(pvApiCtx, "$result", $value) != SWIG_OK)
+ return SWIG_ERROR;
+%}
+
+%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(int)) long
+%{
+ if (SWIG_CreateScilabVariable_int(pvApiCtx, "$result", $value) != SWIG_OK)
+ return SWIG_ERROR;
+%}
+
+%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(uint)) unsigned long
+%{
+ if (SWIG_CreateScilabVariable_uint(pvApiCtx, "$result", $value) != SWIG_OK)
+ return SWIG_ERROR;
+%}
+
+%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(char)) char
+%{
+ if (SWIG_CreateScilabVariable_char(pvApiCtx, "$result", $value) != SWIG_OK)
+ return SWIG_ERROR;
+%}
+
+%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(charptr)) char *
+%{
+ if (SWIG_CreateScilabVariable_charptr(pvApiCtx, "$result", $value) != SWIG_OK)
+ return SWIG_ERROR;
+%}
+
+%typemap(scilabconstcode, fragment=SWIG_CreateScilabVariable_frag(double)) enum SWIGTYPE
+%{
+ if (SWIG_CreateScilabVariable_double(pvApiCtx, "$result", $value) != SWIG_OK)
+ return SWIG_ERROR;
+%}
+
+
+/* ---------------------------------------------------------------------------*/
+/* Exception typmemaps */
+/* ---------------------------------------------------------------------------*/
+
+%include <sciexception.swg>
diff --git a/Lib/scilab/sciunsignedchar.swg b/Lib/scilab/sciunsignedchar.swg
new file mode 100644
index 000000000..f73389580
--- /dev/null
+++ b/Lib/scilab/sciunsignedchar.swg
@@ -0,0 +1,190 @@
+/*
+ * C-type: unsigned char
+ * Scilab type: double or uint8
+ */
+%fragment(SWIG_AsVal_frag(unsigned char), "header", fragment="SWIG_SciDoubleOrUint8_AsUnsignedChar", fragment="<limits.h>") {
+#define SWIG_AsVal_unsigned_SS_char(scilabValue, valuePointer) SWIG_SciDoubleOrUint8_AsUnsignedChar(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDoubleOrUint8_AsUnsignedChar", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrUint8_AsUnsignedChar(void *pvApiCtx, int iVar, unsigned char *pucValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int iRows = 0;
+ int iCols = 0;
+ int iPrec = 0;
+ int *piAddrVar = NULL;
+ unsigned char *pucData = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_ints) {
+ if (pucValue) {
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iPrec != SCI_UINT8) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer or a double expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getMatrixOfUnsignedInteger8(pvApiCtx, piAddrVar, &iRows, &iCols, &pucData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 8-bit unsigned integer or a double expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+ *pucValue = *pucData;
+ }
+ }
+ else if (iType == sci_matrix) {
+ if (pucValue) {
+ double *pdData = NULL;
+ double dValue = 0.0f;
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 8-bit unsigned integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ dValue = *pdData;
+ if (dValue != floor(dValue)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 8-bit unsigned integer.\n"), fname, iVar);
+ return SWIG_ValueError;
+ }
+ if ((dValue < 0) || (dValue > UCHAR_MAX)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 8-bit unsigned integer.\n"), fname, iVar);
+ return SWIG_OverflowError;
+ }
+ *pucValue = (unsigned char) dValue;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer or a double expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(unsigned char), "header", fragment="SWIG_SciDouble_FromUnsignedChar") {
+#define SWIG_From_unsigned_SS_char(value) SWIG_SciDouble_FromUnsignedChar(pvApiCtx, SWIG_Scilab_GetOutputPosition(), value)
+}
+%fragment("SWIG_SciDouble_FromUnsignedChar", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromUnsignedChar(void *pvApiCtx, int iVarOut, unsigned char ucValue) {
+ if (createScalarDouble(pvApiCtx,
+ SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) ucValue))
+ return SWIG_ERROR;
+ return SWIG_OK;
+}
+}
+
+/*
+ * C-type: unsigned char[]
+ * Scilab type: double or uint8 matrix
+ */
+%fragment("SWIG_SciDoubleOrUint8_AsUnsignedCharArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrUint8_AsUnsignedCharArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, unsigned char **pucValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int iPrec = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_matrix) {
+ double *pdData = NULL;
+ int size = 0;
+ int i;
+
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ size = (*iRows) * (*iCols);
+ *pucValue = (unsigned char*) malloc(size * sizeof(int*));
+ for (i = 0; i < size; i++)
+ (*pucValue)[i] = (unsigned char) pdData[i];
+ }
+ else if (iType == sci_ints) {
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iPrec != SCI_UINT8) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer or a double vector expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getMatrixOfUnsignedInteger8(pvApiCtx, piAddrVar, iRows, iCols, pucValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 8-bit unsigned integer or a double vector expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciDouble_FromUnsignedCharArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromUnsignedCharArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const unsigned char *pucValues) {
+ SciErr sciErr;
+ double *pdValues = NULL;
+ int i;
+
+ pdValues = (double*) malloc(iRows * iCols * sizeof(double));
+ for (i=0; i<iRows * iCols; i++)
+ pdValues[i] = pucValues[i];
+
+ sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ free(pdValues);
+ return SWIG_ERROR;
+ }
+
+ free(pdValues);
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/sciunsignedint.swg b/Lib/scilab/sciunsignedint.swg
new file mode 100644
index 000000000..021b0ea90
--- /dev/null
+++ b/Lib/scilab/sciunsignedint.swg
@@ -0,0 +1,204 @@
+/*
+ * C-type: unsigned int
+ * Scilab type: double or uint32
+ */
+%fragment(SWIG_AsVal_frag(unsigned int), "header", fragment="SWIG_SciDoubleOrUint32_AsUnsignedInt", fragment="<limits.h>") {
+%#define SWIG_AsVal_unsigned_SS_int(scilabValue, valuePointer) SWIG_SciDoubleOrUint32_AsUnsignedInt(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDoubleOrUint32_AsUnsignedInt", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrUint32_AsUnsignedInt(void *pvApiCtx, int iVar, unsigned int *puiValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int iRows = 0;
+ int iCols = 0;
+ int iPrec = 0;
+ int *piAddrVar = NULL;
+ unsigned int *puiData = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_ints) {
+ if (puiValue) {
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iPrec != SCI_UINT32) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer or a double expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getMatrixOfUnsignedInteger32(pvApiCtx, piAddrVar, &iRows, &iCols, &puiData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit unsigned integer or a double expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+ *puiValue = *puiData;
+ }
+ }
+ else if (iType == sci_matrix) {
+ if (puiValue) {
+ double *pdData = NULL;
+ double dValue = 0.0f;
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 32-bit unsigned integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ dValue = *pdData;
+ if (dValue != floor(dValue)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 32-bit unsigned integer.\n"), fname, iVar);
+ return SWIG_ValueError;
+ }
+ if ((dValue < 0) || (dValue > UINT_MAX)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 32-bit unsigned integer.\n"), fname, iVar);
+ return SWIG_OverflowError;
+ }
+ *puiValue = (unsigned int) dValue;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer or a double expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(unsigned int), "header", fragment="SWIG_SciDouble_FromUnsignedInt") {
+%#define SWIG_From_unsigned_SS_int(scilabValue) SWIG_SciDouble_FromUnsignedInt(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDouble_FromUnsignedInt", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromUnsignedInt(void *pvApiCtx, int iVarOut, unsigned int uiValue, char *fname) {
+ if (createScalarDouble(pvApiCtx,
+ SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) uiValue))
+ return SWIG_ERROR;
+ return SWIG_OK;
+}
+}
+
+/*
+ * C-type: unsigned int[]
+ * Scilab type: uint32 vector
+ */
+%fragment("SWIG_SciDoubleOrUint32_AsUnsignedIntArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrUint32_AsUnsignedIntArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, unsigned int **puiValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int iPrec = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_matrix) {
+ double *pdData = NULL;
+ int size = 0;
+ int i;
+
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ size = (*iRows) * (*iCols);
+ *puiValue = (unsigned int*) malloc(size * sizeof(int*));
+ for (i = 0; i < size; i++)
+ (*puiValue)[i] = (unsigned int) pdData[i];
+ }
+ else if (iType == sci_ints) {
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iPrec != SCI_UINT32) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer or a double vector expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getMatrixOfUnsignedInteger32(pvApiCtx, piAddrVar, iRows, iCols, puiValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 32-bit unsigned integer or a double vector expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciDouble_FromUnsignedIntArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromUnsignedIntArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, unsigned int *puiValues) {
+ SciErr sciErr;
+ double *pdValues = NULL;
+ int i;
+
+ pdValues = (double*) malloc(iRows * iCols * sizeof(double));
+ for (i=0; i<iRows * iCols; i++)
+ pdValues[i] = puiValues[i];
+
+ sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ free(pdValues);
+ return SWIG_ERROR;
+ }
+
+ free(pdValues);
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_CreateScilabVariable_frag(uint), "wrapper") {
+SWIGINTERN int
+SWIG_CreateScilabVariable_dec(uint)(void *pvApiCtx, const char* psVariableName, const unsigned int uiVariableValue) {
+ SciErr sciErr;
+ sciErr = createNamedMatrixOfUnsignedInteger32(pvApiCtx, psVariableName, 1, 1, &uiVariableValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ return SWIG_OK;
+}
+}
+
diff --git a/Lib/scilab/sciunsignedlong.swg b/Lib/scilab/sciunsignedlong.swg
new file mode 100644
index 000000000..0e9b906c8
--- /dev/null
+++ b/Lib/scilab/sciunsignedlong.swg
@@ -0,0 +1,53 @@
+/*
+ * C-type: unsigned long
+ * Scilab type: see unsigned int
+ */
+
+%fragment(SWIG_AsVal_frag(unsigned long), "header", fragment="SWIG_UnsignedInt_AsUnsignedLong") {
+#define SWIG_AsVal_unsigned_SS_long(scilabValue, valuePointer) SWIG_UnsignedInt_AsUnsignedLong(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_UnsignedInt_AsUnsignedLong", "header", fragment=SWIG_AsVal_frag(unsigned int)) {
+SWIGINTERN int
+SWIG_UnsignedInt_AsUnsignedLong(void *pvApiCtx, SwigSciObject iVar, unsigned long *pulValue, char *fname) {
+ unsigned int uiValue = 0;
+ if(SWIG_AsVal_unsigned_SS_int(iVar, &uiValue) != SWIG_OK) {
+ return SWIG_ERROR;
+ }
+ *pulValue = (unsigned long) uiValue;
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(unsigned long), "header", fragment="SWIG_UnsignedInt_FromUnsignedLong") {
+#define SWIG_From_unsigned_SS_long(scilabValue) SWIG_UnsignedInt_FromUnsignedLong(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_UnsignedInt_FromUnsignedLong", "header", fragment=SWIG_From_frag(unsigned int)) {
+SWIGINTERN int
+SWIG_UnsignedInt_FromUnsignedLong(void *pvApiCtx, int iVarOut, unsigned long ulValue, char *fname) {
+ return SWIG_From_unsigned_SS_int((unsigned int)ulValue);
+}
+}
+
+%fragment("SWIG_SciDouble_FromUnsignedLongArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromUnsignedLongArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, const unsigned long *pulValues) {
+ SciErr sciErr;
+ double *pdValues = NULL;
+ int i;
+
+ pdValues = (double*) malloc(iRows * iCols * sizeof(double));
+ for (i=0; i<iRows * iCols; i++) {
+ pdValues[i] = pulValues[i];
+ }
+
+ sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ free(pdValues);
+ return SWIG_ERROR;
+ }
+
+ free(pdValues);
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/sciunsignedshort.swg b/Lib/scilab/sciunsignedshort.swg
new file mode 100644
index 000000000..110fba436
--- /dev/null
+++ b/Lib/scilab/sciunsignedshort.swg
@@ -0,0 +1,189 @@
+/*
+ * C-type: unsigned short
+ * Scilab type: double or uint16
+ */
+%fragment(SWIG_AsVal_frag(unsigned short), "header", fragment="SWIG_SciDoubleOrUint16_AsUnsignedShort", fragment="<limits.h>") {
+%#define SWIG_AsVal_unsigned_SS_short(scilabValue, valuePointer) SWIG_SciDoubleOrUint16_AsUnsignedShort(pvApiCtx, scilabValue, valuePointer, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDoubleOrUint16_AsUnsignedShort", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrUint16_AsUnsignedShort(void *pvApiCtx, int iVar, unsigned short *pusValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int iRows = 0;
+ int iCols = 0;
+ int iPrec = 0;
+ int *piAddrVar = NULL;
+ unsigned short *pusData = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_ints) {
+ if (pusValue) {
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iPrec != SCI_UINT16) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer or a double expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getMatrixOfUnsignedInteger16(pvApiCtx, piAddrVar, &iRows, &iCols, &pusData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 16-bit unsigned integer or a double expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+ *pusValue = *pusData;
+ }
+ }
+ else if (iType == sci_matrix) {
+ if (pusValue) {
+ double *pdData = NULL;
+ double dValue = 0.0f;
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, &iRows, &iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ if (iRows * iCols != 1) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong size for input argument #%d: A 16-bit unsigned integer or a double expected.\n"), fname, iVar);
+ return SWIG_TypeError;
+ }
+ dValue = *pdData;
+ if (dValue != floor(dValue)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Incorrect value for input argument #%d: The double value cannot be converted to a 16-bit unsigned integer.\n"), fname, iVar);
+ return SWIG_ValueError;
+ }
+ if ((dValue < 0) || (dValue > USHRT_MAX)) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Overflow error for input argument #%d: The double value cannot be converted to a 16-bit unsigned integer.\n"), fname, iVar);
+ return SWIG_OverflowError;
+ }
+ *pusValue = (unsigned short) dValue;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer or a double expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment(SWIG_From_frag(unsigned short), "header", fragment="SWIG_SciDouble_FromUnsignedShort") {
+%#define SWIG_From_unsigned_SS_short(scilabValue) SWIG_SciDouble_FromUnsignedShort(pvApiCtx, SWIG_Scilab_GetOutputPosition(), scilabValue, SWIG_Scilab_GetFuncName())
+}
+%fragment("SWIG_SciDouble_FromUnsignedShort", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromUnsignedShort(void *pvApiCtx, int iVarOut, unsigned short usValue, char *fname) {
+ if (createScalarDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, (double) usValue))
+ return SWIG_ERROR;
+ return SWIG_OK;
+}
+}
+
+/*
+ * C-type: unsigned short[]
+ * Scilab type: uint16 vector
+ */
+%fragment("SWIG_SciDoubleOrUint16_AsUnsignedShortArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDoubleOrUint16_AsUnsignedShortArrayAndSize(void *pvApiCtx, int iVar, int *iRows, int *iCols, unsigned short **pusValue, char *fname) {
+ SciErr sciErr;
+ int iType = 0;
+ int iPrec = 0;
+ int *piAddrVar = NULL;
+
+ sciErr = getVarAddressFromPosition(pvApiCtx, iVar, &piAddrVar);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getVarType(pvApiCtx, piAddrVar, &iType);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iType == sci_matrix) {
+ double *pdData = NULL;
+ int size = 0;
+ int i;
+
+ sciErr = getMatrixOfDouble(pvApiCtx, piAddrVar, iRows, iCols, &pdData);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ size = (*iRows) * (*iCols);
+ *pusValue = (unsigned short*) malloc(size * sizeof(int*));
+ for (i = 0; i < size; i++)
+ (*pusValue)[i] = (unsigned short) pdData[i];
+ }
+ else if (iType == sci_ints) {
+ sciErr = getMatrixOfIntegerPrecision(pvApiCtx, piAddrVar, &iPrec);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+
+ if (iPrec != SCI_UINT16) {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer or a double vector expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ sciErr = getMatrixOfUnsignedInteger16(pvApiCtx, piAddrVar, iRows, iCols, pusValue);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ return SWIG_ERROR;
+ }
+ }
+ else {
+ Scierror(SCILAB_API_ARGUMENT_ERROR, _("%s: Wrong type for input argument #%d: A 16-bit unsigned integer or a double vector expected.\n"), fname, iVar);
+ return SWIG_ERROR;
+ }
+
+ return SWIG_OK;
+}
+}
+
+%fragment("SWIG_SciDouble_FromUnsignedShortArrayAndSize", "header") {
+SWIGINTERN int
+SWIG_SciDouble_FromUnsignedShortArrayAndSize(void *pvApiCtx, int iVarOut, int iRows, int iCols, unsigned short *pusValues) {
+ SciErr sciErr;
+ double *pdValues = NULL;
+ int i;
+
+ pdValues = (double*) malloc(iRows * iCols * sizeof(double));
+ for (i=0; i<iRows * iCols; i++)
+ pdValues[i] = pusValues[i];
+
+ sciErr = createMatrixOfDouble(pvApiCtx, SWIG_NbInputArgument(pvApiCtx) + iVarOut, iRows, iCols, pdValues);
+ if (sciErr.iErr) {
+ printError(&sciErr, 0);
+ free(pdValues);
+ return SWIG_ERROR;
+ }
+
+ free(pdValues);
+ return SWIG_OK;
+}
+}
diff --git a/Lib/scilab/std_alloc.i b/Lib/scilab/std_alloc.i
new file mode 100644
index 000000000..6ea03aad3
--- /dev/null
+++ b/Lib/scilab/std_alloc.i
@@ -0,0 +1,2 @@
+%include <std/std_alloc.i>
+
diff --git a/Lib/scilab/std_basic_string.i b/Lib/scilab/std_basic_string.i
new file mode 100644
index 000000000..4922abd35
--- /dev/null
+++ b/Lib/scilab/std_basic_string.i
@@ -0,0 +1,47 @@
+/*
+ * C++: basic_string<char>
+ * Scilab: string
+ */
+
+#define %swig_basic_string(Type...) %swig_sequence_methods_val(Type)
+
+%fragment(SWIG_AsPtr_frag(std::basic_string<char>), "header", fragment="SWIG_SciString_AsCharPtrAndLength") {
+SWIGINTERN int
+SWIG_AsPtr_dec(std::basic_string<char>)(int _iVar, std::basic_string<char> **_pstValue) {
+ char* buf = 0;
+ size_t len = 0;
+ int alloc = SWIG_OLDOBJ;
+
+ if (SWIG_IsOK((SWIG_SciString_AsCharPtrAndSize(pvApiCtx, _iVar, &buf, &len, &alloc, SWIG_Scilab_GetFuncName())))) {
+ if (buf) {
+ if (_pstValue) {
+ *_pstValue = new std::string(buf, len - 1);
+ sciprint("%s\n", (*_pstValue)->c_str());
+ }
+ if (alloc == SWIG_NEWOBJ) {
+ delete[] buf;
+ }
+ return SWIG_NEWOBJ;
+ }
+ else {
+ if (_pstValue) {
+ *_pstValue = NULL;
+ }
+ return SWIG_OLDOBJ;
+ }
+ } else {
+ return SWIG_ERROR;
+ }
+}
+}
+
+%fragment(SWIG_From_frag(std::basic_string<char>), "header", fragment="SWIG_SciString_FromCharPtr") {
+SWIGINTERN int
+SWIG_From_dec(std::basic_string<char>)(std::basic_string<char> _pstValue) {
+ return SWIG_SciString_FromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), _pstValue.c_str());
+}
+}
+
+%include <std/std_basic_string.i>
+
+
diff --git a/Lib/scilab/std_char_traits.i b/Lib/scilab/std_char_traits.i
new file mode 100644
index 000000000..bf4e6c47d
--- /dev/null
+++ b/Lib/scilab/std_char_traits.i
@@ -0,0 +1 @@
+%include <std/std_char_traits.i>
diff --git a/Lib/scilab/std_common.i b/Lib/scilab/std_common.i
new file mode 100644
index 000000000..4524ffd6b
--- /dev/null
+++ b/Lib/scilab/std_common.i
@@ -0,0 +1,72 @@
+%include <std/std_except.i>
+%include <scistdcommon.swg>
+
+
+// Generate the traits for a 'primitive' type, such as 'double',
+// for which the SWIG_AsVal and SWIG_From methods are already defined.
+
+%define %traits_ptypen(Type...)
+ %fragment(SWIG_Traits_frag(Type),"header",
+ fragment=SWIG_AsVal_frag(Type),
+ fragment=SWIG_From_frag(Type),
+ fragment="StdTraits") {
+namespace swig {
+ template <> struct traits<Type > {
+ typedef value_category category;
+ static const char* type_name() { return #Type; }
+ };
+ template <> struct traits_asval<Type > {
+ typedef Type value_type;
+ static int asval(SwigSciObject obj, value_type *val) {
+ return SWIG_AsVal(Type)(obj, val);
+ }
+ };
+ template <> struct traits_from<Type > {
+ typedef Type value_type;
+ static SwigSciObject from(const value_type& val) {
+ return SWIG_From(Type)(val);
+ }
+ };
+}
+}
+%enddef
+
+/* Traits for enums. This is bit of a sneaky trick needed because a generic template specialization of enums
+ is not possible (unless using template meta-programming which SWIG doesn't support because of the explicit
+ instantiations required using %template). The STL containers define the 'front' method and the typemap
+ below is used whenever the front method is wrapped returning an enum. This typemap simply picks up the
+ standard enum typemap, but additionally drags in a fragment containing the traits_asval and traits_from
+ required in the generated code for enums. */
+
+%define %traits_enum(Type...)
+ %fragment("SWIG_Traits_enum_"{Type},"header",
+ fragment=SWIG_AsVal_frag(int),
+ fragment=SWIG_From_frag(int),
+ fragment="StdTraits") {
+namespace swig {
+ template <> struct traits_asval<Type > {
+ typedef Type value_type;
+ static int asval(SwigSciObject obj, value_type *val) {
+ return SWIG_AsVal(int)(obj, (int *)val);
+ }
+ };
+ template <> struct traits_from<Type > {
+ typedef Type value_type;
+ static SwigSciObject from(const value_type& val) {
+ return SWIG_From(int)((int)val);
+ }
+ };
+}
+}
+%typemap(out, fragment="SWIG_Traits_enum_"{Type}) const enum SWIGTYPE& front %{$typemap(out, const enum SWIGTYPE&)%}
+%enddef
+
+
+%include <std/std_common.i>
+
+//
+// Generates the traits for all the known primitive
+// C++ types (int, double, ...)
+//
+%apply_cpptypes(%traits_ptypen);
+
diff --git a/Lib/scilab/std_container.i b/Lib/scilab/std_container.i
new file mode 100644
index 000000000..a1e037b8c
--- /dev/null
+++ b/Lib/scilab/std_container.i
@@ -0,0 +1,3 @@
+%include <scicontainer.swg>
+%include <std/std_container.i>
+
diff --git a/Lib/scilab/std_deque.i b/Lib/scilab/std_deque.i
new file mode 100644
index 000000000..d2ca597a8
--- /dev/null
+++ b/Lib/scilab/std_deque.i
@@ -0,0 +1,31 @@
+/*
+ *
+ * C++ type : STL deque
+ * Scilab type : matrix (for primitive types) or list (for pointer types)
+ *
+*/
+
+%fragment("StdDequeTraits", "header", fragment="StdSequenceTraits")
+%{
+ namespace swig {
+ template <class T>
+ struct traits_asptr<std::deque<T> > {
+ static int asptr(const SwigSciObject &obj, std::deque<T> **deq) {
+ return traits_asptr_stdseq<std::deque<T> >::asptr(obj, deq);
+ }
+ };
+
+ template <class T>
+ struct traits_from<std::deque<T> > {
+ static SwigSciObject from(const std::deque<T>& deq) {
+ return traits_from_stdseq<std::deque<T> >::from(deq);
+ }
+ };
+ }
+%}
+
+
+#define %swig_deque_methods(Type...) %swig_sequence_methods(Type)
+#define %swig_deque_methods_val(Type...) %swig_sequence_methods_val(Type);
+
+%include <std/std_deque.i>
diff --git a/Lib/scilab/std_except.i b/Lib/scilab/std_except.i
new file mode 100644
index 000000000..af98428f6
--- /dev/null
+++ b/Lib/scilab/std_except.i
@@ -0,0 +1 @@
+%include <typemaps/std_except.swg>
diff --git a/Lib/scilab/std_list.i b/Lib/scilab/std_list.i
new file mode 100644
index 000000000..75d002d49
--- /dev/null
+++ b/Lib/scilab/std_list.i
@@ -0,0 +1,30 @@
+/*
+ *
+ * C++ type : STL list
+ * Scilab type : matrix (for primitive types) or list (for pointer types)
+ *
+*/
+
+%fragment("StdListTraits", "header", fragment="StdSequenceTraits")
+%{
+ namespace swig {
+ template <class T >
+ struct traits_asptr<std::list<T> > {
+ static int asptr(SwigSciObject obj, std::list<T> **lis) {
+ return traits_asptr_stdseq<std::list<T> >::asptr(obj, lis);
+ }
+ };
+
+ template <class T>
+ struct traits_from<std::list<T> > {
+ static SwigSciObject from(const std::list<T> &lis) {
+ return traits_from_stdseq<std::list<T> >::from(lis);
+ }
+ };
+ }
+%}
+
+#define %swig_list_methods(Type...) %swig_sequence_methods(Type)
+#define %swig_list_methods_val(Type...) %swig_sequence_methods_val(Type);
+
+%include <std/std_list.i>
diff --git a/Lib/scilab/std_map.i b/Lib/scilab/std_map.i
new file mode 100644
index 000000000..250d2d84c
--- /dev/null
+++ b/Lib/scilab/std_map.i
@@ -0,0 +1,69 @@
+//
+// SWIG typemaps for std::map
+//
+// Common implementation
+
+%include <std_common.i>
+
+// ------------------------------------------------------------------------
+// std::map
+// ------------------------------------------------------------------------
+
+%{
+#include <map>
+#include <algorithm>
+#include <stdexcept>
+%}
+
+// exported class
+
+namespace std {
+
+ template<class K, class T> class map {
+ // add typemaps here
+ public:
+ map();
+ map(const map<K,T> &);
+
+ unsigned int size() const;
+ bool empty() const;
+ void clear();
+ %extend {
+ const T& get(const K& key) throw (std::out_of_range) {
+ std::map<K,T >::iterator i = self->find(key);
+ if (i != self->end())
+ return i->second;
+ else
+ throw std::out_of_range("key not found");
+ }
+ void set(const K& key, const T& x) {
+ (*self)[key] = x;
+ }
+ void del(const K& key) throw (std::out_of_range) {
+ std::map<K,T >::iterator i = self->find(key);
+ if (i != self->end())
+ self->erase(i);
+ else
+ throw std::out_of_range("key not found");
+ }
+ bool has_key(const K& key) {
+ std::map<K,T >::iterator i = self->find(key);
+ return i != self->end();
+ }
+ }
+ };
+
+// Legacy macros (deprecated)
+%define specialize_std_map_on_key(K,CHECK,CONVERT_FROM,CONVERT_TO)
+#warning "specialize_std_map_on_key ignored - macro is deprecated and no longer necessary"
+%enddef
+
+%define specialize_std_map_on_value(T,CHECK,CONVERT_FROM,CONVERT_TO)
+#warning "specialize_std_map_on_value ignored - macro is deprecated and no longer necessary"
+%enddef
+
+%define specialize_std_map_on_both(K,CHECK_K,CONVERT_K_FROM,CONVERT_K_TO, T,CHECK_T,CONVERT_T_FROM,CONVERT_T_TO)
+#warning "specialize_std_map_on_both ignored - macro is deprecated and no longer necessary"
+%enddef
+
+}
diff --git a/Lib/scilab/std_multiset.i b/Lib/scilab/std_multiset.i
new file mode 100644
index 000000000..67e17926f
--- /dev/null
+++ b/Lib/scilab/std_multiset.i
@@ -0,0 +1,30 @@
+/*
+ *
+ * C++ type : STL multiset
+ * Scilab type : matrix (for primitive types) or list (for pointer types)
+ *
+*/
+
+%fragment("StdMultisetTraits", "header", fragment="StdSequenceTraits")
+%{
+ namespace swig {
+ template <class T>
+ struct traits_asptr<std::multiset<T> > {
+ static int asptr(const SwigSciObject &obj, std::multiset<T> **multiset) {
+ return traits_asptr_stdseq<std::multiset<T> >::asptr(obj, multiset);
+ }
+ };
+
+ template <class T>
+ struct traits_from<std::multiset<T> > {
+ static SwigSciObject from(const std::multiset<T>& multiset) {
+ return traits_from_stdseq<std::multiset<T> >::from(multiset);
+ }
+ };
+ }
+%}
+
+#define %swig_multiset_methods(Set...) %swig_sequence_methods(Type)
+#define %swig_multiset_methods_val(Type...) %swig_sequence_methods_val(Type);
+
+%include <std/std_multiset.i>
diff --git a/Lib/scilab/std_pair.i b/Lib/scilab/std_pair.i
new file mode 100644
index 000000000..1448d6524
--- /dev/null
+++ b/Lib/scilab/std_pair.i
@@ -0,0 +1,34 @@
+/* -----------------------------------------------------------------------------
+ * std_pair.i
+ *
+ * Typemaps for std::pair
+ * ----------------------------------------------------------------------------- */
+
+%include <std_common.i>
+%include <exception.i>
+
+// ------------------------------------------------------------------------
+// std::pair
+// ------------------------------------------------------------------------
+
+%{
+#include <utility>
+%}
+
+namespace std {
+
+ template<class T, class U> struct pair {
+
+ pair();
+ pair(T first, U second);
+ pair(const pair& p);
+
+ template <class U1, class U2> pair(const pair<U1, U2> &p);
+
+ T first;
+ U second;
+ };
+
+ // add specializations here
+
+}
diff --git a/Lib/scilab/std_set.i b/Lib/scilab/std_set.i
new file mode 100644
index 000000000..9070e2d68
--- /dev/null
+++ b/Lib/scilab/std_set.i
@@ -0,0 +1,32 @@
+/*
+ *
+ * C++ type : STL set
+ * Scilab type : matrix (for primitive types) or list (for pointer types)
+ *
+*/
+
+%fragment("StdSetTraits", "header", fragment="StdSequenceTraits")
+%{
+ namespace swig {
+ template <class T>
+ struct traits_asptr<std::set<T> > {
+ static int asptr(const SwigSciObject &obj, std::set<T> **set) {
+ return traits_asptr_stdseq<std::set<T> >::asptr(obj, set);
+ }
+ };
+
+ template <class T>
+ struct traits_from<std::set<T> > {
+ static SwigSciObject from(const std::set<T>& set) {
+ return traits_from_stdseq<std::set<T> >::from(set);
+ }
+ };
+ }
+%}
+
+
+#define %swig_set_methods(Type...) %swig_sequence_methods(Type)
+#define %swig_set_methods_val(Type...) %swig_sequence_methods_val(Type);
+
+%include <std/std_set.i>
+
diff --git a/Lib/scilab/std_string.i b/Lib/scilab/std_string.i
new file mode 100644
index 000000000..71ac6d2f4
--- /dev/null
+++ b/Lib/scilab/std_string.i
@@ -0,0 +1,39 @@
+/*
+ * POINTER
+ */
+%fragment(SWIG_AsPtr_frag(std::string), "header", fragment="SWIG_SciString_AsCharPtrAndSize") {
+SWIGINTERN int
+SWIG_AsPtr_dec(std::string)(int iVar, std::string **pstValue) {
+ char* buf = 0;
+ size_t size = 0;
+ int alloc = SWIG_OLDOBJ;
+
+ if (SWIG_IsOK((SWIG_SciString_AsCharPtrAndSize(pvApiCtx, iVar, &buf, &size, &alloc, SWIG_Scilab_GetFuncName())))) {
+ if (buf) {
+ if (pstValue) {
+ *pstValue = new std::string(buf, size);
+ }
+ if (alloc == SWIG_NEWOBJ) {
+ delete[] buf;
+ }
+ return SWIG_NEWOBJ;
+ } else {
+ if (pstValue) {
+ *pstValue = NULL;
+ }
+ return SWIG_OLDOBJ;
+ }
+ } else {
+ return SWIG_ERROR;
+ }
+}
+}
+
+%fragment(SWIG_From_frag(std::string), "header", fragment="SWIG_SciString_FromCharPtr") {
+SWIGINTERN int
+SWIG_From_dec(std::string)(std::string pstValue) {
+ return SWIG_SciString_FromCharPtr(pvApiCtx, SWIG_Scilab_GetOutputPosition(), pstValue.c_str());
+}
+}
+
+%include <typemaps/std_string.swg>
diff --git a/Lib/scilab/std_vector.i b/Lib/scilab/std_vector.i
new file mode 100644
index 000000000..6eaeeca57
--- /dev/null
+++ b/Lib/scilab/std_vector.i
@@ -0,0 +1,31 @@
+/*
+ *
+ * C++ type : STL vector
+ * Scilab type : matrix (for primitive types) or list (for pointer types)
+ *
+*/
+
+%fragment("StdVectorTraits", "header", fragment="StdSequenceTraits")
+%{
+ namespace swig {
+ template <class T>
+ struct traits_asptr<std::vector<T> > {
+ static int asptr(const SwigSciObject &obj, std::vector<T> **vec) {
+ return traits_asptr_stdseq<std::vector<T> >::asptr(obj, vec);
+ }
+ };
+
+ template <class T>
+ struct traits_from<std::vector<T> > {
+ static SwigSciObject from(const std::vector<T>& vec) {
+ return traits_from_stdseq<std::vector<T> >::from(vec);
+ }
+ };
+ }
+%}
+
+
+#define %swig_vector_methods(Type...) %swig_sequence_methods(Type)
+#define %swig_vector_methods_val(Type...) %swig_sequence_methods_val(Type);
+
+%include <std/std_vector.i>
diff --git a/Lib/scilab/stl.i b/Lib/scilab/stl.i
new file mode 100644
index 000000000..b29f7d84d
--- /dev/null
+++ b/Lib/scilab/stl.i
@@ -0,0 +1,6 @@
+/* initial STL definition. extended as needed in each language */
+%include <std_common.i>
+%include <std_string.i>
+%include <std_vector.i>
+%include <std_map.i>
+%include <std_pair.i>
diff --git a/Lib/scilab/typemaps.i b/Lib/scilab/typemaps.i
new file mode 100644
index 000000000..9d7138743
--- /dev/null
+++ b/Lib/scilab/typemaps.i
@@ -0,0 +1,62 @@
+/* -----------------------------------------------------------------------------
+ * typemaps.i
+ *
+ * ----------------------------------------------------------------------------- */
+
+// INPUT typemaps
+%define %scilab_input_typemap(Type)
+%typemap(in, noblock=1, fragment=SWIG_AsVal_frag(Type)) Type *INPUT(Type temp)(int ecode), Type &INPUT(Type temp)(int ecode) {
+ ecode = SWIG_AsVal_dec(Type)($input, &temp);
+ if (!SWIG_IsOK(ecode)) {
+ %argument_fail(ecode, "$type", $symname, $argnum);
+ }
+ $1 = &temp;
+}
+
+%typemap(freearg, noblock=1) Type *INPUT, Type &INPUT {
+}
+
+%typemap(typecheck) Type *INPUT, Type &INPUT {
+}
+%enddef
+
+// OUTPUT typemaps
+%define %scilab_output_typemap(Type)
+%typemap(argout, noblock=1, fragment=SWIG_From_frag(Type)) Type *OUTPUT, Type &OUTPUT {
+ %set_output(SWIG_From_dec(Type)(*$1));
+}
+%enddef
+
+// INOUT typemaps
+%define %scilab_inout_typemap(Type)
+ %typemap(in) Type *INOUT = Type *INPUT;
+ %typemap(in) Type &INOUT = Type &INPUT;
+ %typemap(argout) Type *INOUT = Type *OUTPUT;
+ %typemap(argout) Type &INOUT = Type &OUTPUT;
+%enddef
+
+
+%define %scilab_inout_typemaps(Type)
+ %scilab_input_typemap(%arg(Type))
+ %scilab_output_typemap(%arg(Type))
+ %scilab_inout_typemap(%arg(Type))
+%enddef
+
+%scilab_inout_typemaps(double);
+%scilab_inout_typemaps(signed char);
+%scilab_inout_typemaps(unsigned char);
+%scilab_inout_typemaps(short);
+%scilab_inout_typemaps(unsigned short);
+%scilab_inout_typemaps(int);
+%scilab_inout_typemaps(unsigned int);
+%scilab_inout_typemaps(long);
+%scilab_inout_typemaps(unsigned long);
+%scilab_inout_typemaps(bool);
+%scilab_inout_typemaps(float);
+
+//%apply_ctypes(%scilab_inout_typemaps);
+
+
+
+
+
diff --git a/Lib/swigarch.i b/Lib/swigarch.i
index f5aea4678..bf4ee8ef8 100644
--- a/Lib/swigarch.i
+++ b/Lib/swigarch.i
@@ -42,7 +42,7 @@
#include <limits.h>
#endif
#if (__WORDSIZE == 64) || (LONG_MAX != INT_MAX)
-# error "SWIG wrapped code invalid in 64 bit architecture, regenarete code using -DSWIGWORDSIZE64"
+# error "SWIG wrapped code invalid in 64 bit architecture, regenerate code using -DSWIGWORDSIZE64"
#endif
%}
#endif
@@ -54,7 +54,7 @@
#include <limits.h>
#endif
#if (__WORDSIZE == 32) || (LONG_MAX == INT_MAX)
-# error "SWIG wrapped code invalid in 32 bit architecture, regenarete code using -DSWIGWORDSIZE32"
+# error "SWIG wrapped code invalid in 32 bit architecture, regenerate code using -DSWIGWORDSIZE32"
#endif
%}
#endif
diff --git a/Lib/swiginit.swg b/Lib/swiginit.swg
index 69e368ac1..cb72c36eb 100644
--- a/Lib/swiginit.swg
+++ b/Lib/swiginit.swg
@@ -55,7 +55,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
- int found, init;
+ int init;
/* check to see if the circular list has been setup, if not, set it up */
if (swig_module.next==0) {
@@ -74,22 +74,18 @@ SWIG_InitializeModule(void *clientdata) {
/* This is the first module loaded for this interpreter */
/* so set the swig module into the interpreter */
SWIG_SetModule(clientdata, &swig_module);
- module_head = &swig_module;
} else {
/* the interpreter has loaded a SWIG module, but has it loaded this one? */
- found=0;
iter=module_head;
do {
if (iter==&swig_module) {
- found=1;
- break;
+ /* Our module is already in the list, so there's nothing more to do. */
+ return;
}
iter=iter->next;
} while (iter!= module_head);
- /* if the is found in the list, then all is done and we may leave */
- if (found) return;
- /* otherwise we must add out module into the list */
+ /* otherwise we must add our module into the list */
swig_module.next = module_head->next;
module_head->next = &swig_module;
}
diff --git a/Lib/swiglabels.swg b/Lib/swiglabels.swg
index d428ac33d..baa21a756 100644
--- a/Lib/swiglabels.swg
+++ b/Lib/swiglabels.swg
@@ -106,3 +106,7 @@
# define _SCL_SECURE_NO_DEPRECATE
#endif
+/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */
+#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES)
+# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
+#endif
diff --git a/Lib/typemaps/strings.swg b/Lib/typemaps/strings.swg
index 6bac0b98a..87e97dd74 100644
--- a/Lib/typemaps/strings.swg
+++ b/Lib/typemaps/strings.swg
@@ -300,7 +300,7 @@
/* varout */
-%typemap(varout,noblock=1,fragment=#SWIG_CharBufLen)
+%typemap(varout,fragment=#SWIG_CharBufLen)
Char [ANY], const Char [ANY] {
%#ifndef SWIG_PRESERVE_CARRAY_SIZE
size_t size = SWIG_CharBufLen($1, $1_dim0);
diff --git a/Makefile.in b/Makefile.in
index bb0845f37..964c48a07 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -82,6 +82,7 @@ skip-clisp = test -n "@SKIP_CLISP@"
skip-cffi = test -n "@SKIP_CFFI@"
skip-uffi = test -n "@SKIP_UFFI@"
skip-r = test -n "@SKIP_R@"
+skip-scilab = test -n "@SKIP_SCILAB@"
skip-go = test -n "@SKIP_GO@"
skip-d = test -n "@SKIP_D@"
skip-javascript = test -n "@SKIP_JAVASCRIPT@"
@@ -128,6 +129,7 @@ check-aliveness:
@$(skip-cffi) || ./$(TARGET) -cffi -help
@$(skip-lua) || ./$(TARGET) -lua -help
@$(skip-r) || ./$(TARGET) -r -help
+ @$(skip-scilab) || ./$(TARGET) -scilab -help
@$(skip-go) || ./$(TARGET) -go -help
@$(skip-d) || ./$(TARGET) -d -help
@$(skip-javascript) || ./$(TARGET) -javascript -help
@@ -159,6 +161,7 @@ check-versions: \
check-uffi-version \
check-cffi-version \
check-r-version \
+ check-scilab-version \
check-go-version \
check-d-version
@@ -198,6 +201,7 @@ check-examples: \
check-uffi-examples \
check-cffi-examples \
check-r-examples \
+ check-scilab-examples \
check-go-examples \
check-d-examples \
check-javascript-examples
@@ -223,6 +227,7 @@ clisp_examples :=
uffi_examples :=
cffi_examples :=
r_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/r/check.list)
+scilab_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/scilab/check.list)
go_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/go/check.list)
d_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/d/check.list)
javascript_examples:=$(shell sed '/^\#/d' $(srcdir)/Examples/javascript/check.list)
@@ -280,6 +285,7 @@ check-test-suite: \
check-cffi-test-suite \
check-chicken-test-suite \
check-r-test-suite \
+ check-scilab-test-suite \
check-go-test-suite \
check-d-test-suite \
check-javascript-test-suite
@@ -333,6 +339,7 @@ all-test-suite: \
all-cffi-test-suite \
all-chicken-test-suite \
all-r-test-suite \
+ all-scilab-test-suite \
all-go-test-suite \
all-d-test-suite \
all-javascript-test-suite
@@ -362,6 +369,7 @@ broken-test-suite: \
broken-cffi-test-suite \
broken-chicken-test-suite \
broken-r-test-suite \
+ broken-scilab-test-suite \
broken-go-test-suite \
broken-d-test-suite \
broken-javascript-test-suite
@@ -497,7 +505,7 @@ install-main:
lib-languages = gcj typemaps tcl perl5 python guile java mzscheme ruby php ocaml octave \
pike chicken csharp modula3 allegrocl clisp lua cffi uffi r go d javascript javascript/jsc \
- javascript/v8
+ javascript/v8 scilab
lib-modules = std
@@ -562,7 +570,7 @@ dd = @PACKAGE_NAME@-@PACKAGE_VERSION@
srpm = @PACKAGE_NAME@-@PACKAGE_VERSION@
dist:
- @echo "not implemented - use Tools/makedist.py instead."
+ @echo "not implemented - use Tools/mkdist.py instead."
false
srcrpm:
diff --git a/README b/README
index 7d0130b83..5c85e6c3a 100644
--- a/README
+++ b/README
@@ -1,13 +1,13 @@
SWIG (Simplified Wrapper and Interface Generator)
-Version: 3.0.3 (in progress)
+Version: 3.0.6 (in progress)
Tagline: SWIG is a compiler that integrates C and C++ with languages
including Perl, Python, Tcl, Ruby, PHP, Java, C#, D, Go, Lua,
- Octave, R, Scheme (Guile, MzScheme/Racket, CHICKEN), Ocaml,
- Modula-3, Common Lisp (CLISP, Allegro CL, CFFI, UFFI) and Pike.
- SWIG can also export its parse tree into Lisp s-expressions and
- XML.
+ Octave, R, Scheme (Guile, MzScheme/Racket, CHICKEN), Scilab,
+ Ocaml, Modula-3, Common Lisp (CLISP, Allegro CL, CFFI, UFFI)
+ and Pike. SWIG can also export its parse tree into XML and
+ Lisp s-expressions.
SWIG reads annotated C/C++ header files and creates wrapper code (glue
code) in order to make the corresponding C/C++ libraries available to
diff --git a/RELEASENOTES b/RELEASENOTES
index 38fbe60e7..ff1c99821 100644
--- a/RELEASENOTES
+++ b/RELEASENOTES
@@ -4,6 +4,20 @@ and CHANGES files.
Release Notes
=============
+SWIG-3.0.5 summary:
+- Added support for Scilab.
+- Important Python regression fix when wrapping C++ default arguments.
+- Minor improvements for C#, Go, Octave, PHP and Python.
+
+SWIG-3.0.4 summary:
+- Python regression fix when wrapping C++ default arguments.
+- Improved error messages.
+
+SWIG-3.0.3 summary:
+- Add support for C++11 strongly typed enumerations.
+- Numerous bug fixes and minor enhancements for C#, D, Go, Java,
+ Javascript, PHP, Perl and Python wrappers.
+
SWIG-3.0.2 summary:
- Bug fix during install and a couple of other minor changes.
diff --git a/Source/CParse/cparse.h b/Source/CParse/cparse.h
index f3f51e434..0681c65dd 100644
--- a/Source/CParse/cparse.h
+++ b/Source/CParse/cparse.h
@@ -27,6 +27,7 @@ extern "C" {
extern int cparse_cplusplus;
extern int cparse_cplusplusout;
extern int cparse_start_line;
+ extern String *cparse_unknown_directive;
extern int scan_doxygen_comments;
extern void Swig_cparse_cplusplus(int);
diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c
index b83af9f6e..7dd63924b 100644
--- a/Source/CParse/cscanner.c
+++ b/Source/CParse/cscanner.c
@@ -40,6 +40,9 @@ int cparse_cplusplus = 0;
/* Generate C++ compatible code when wrapping C code */
int cparse_cplusplusout = 0;
+/* To allow better error reporting */
+String *cparse_unknown_directive = 0;
+
/* Private vars */
static int scan_init = 0;
static int num_brace = 0;
@@ -823,8 +826,11 @@ int yylex(void) {
if (strcmp(yytext, "inline") == 0)
return (yylex());
- /* SWIG directives */
} else {
+ Delete(cparse_unknown_directive);
+ cparse_unknown_directive = NULL;
+
+ /* SWIG directives */
if (strcmp(yytext, "%module") == 0)
return (MODULE);
if (strcmp(yytext, "%insert") == 0)
@@ -900,6 +906,9 @@ int yylex(void) {
}
if (strcmp(yytext, "%warn") == 0)
return (WARN);
+
+ /* Note down the apparently unknown directive for error reporting. */
+ cparse_unknown_directive = Swig_copy_string(yytext);
}
/* Have an unknown identifier, as a last step, we'll do a typedef lookup on it. */
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index fe653f2b5..f24fbcc78 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -1628,7 +1628,11 @@ declaration : swig_directive { $$ = $1; }
| SEMI { $$ = 0; }
| error {
$$ = 0;
- Swig_error(cparse_file, cparse_line,"Syntax error in input(1).\n");
+ if (cparse_unknown_directive) {
+ Swig_error(cparse_file, cparse_line, "Unknown directive '%s'.\n", cparse_unknown_directive);
+ } else {
+ Swig_error(cparse_file, cparse_line, "Syntax error in input(1).\n");
+ }
exit(1);
}
/* Out of class constructor/destructor declarations */
@@ -3138,6 +3142,15 @@ c_decl_tail : SEMI {
skip_balanced('{','}');
$$ = 0;
}
+ | error {
+ $$ = 0;
+ if (yychar == RPAREN) {
+ Swig_error(cparse_file, cparse_line, "Unexpected ')'.\n");
+ } else {
+ Swig_error(cparse_file, cparse_line, "Syntax error - possibly a missing semicolon.\n");
+ }
+ exit(1);
+ }
;
initializer : def_args {
@@ -4849,7 +4862,10 @@ storage_class : EXTERN { $$ = "extern"; }
| FRIEND { $$ = "friend"; }
| EXPLICIT { $$ = "explicit"; }
| CONSTEXPR { $$ = "constexpr"; }
+ | EXPLICIT CONSTEXPR { $$ = "explicit constexpr"; }
+ | CONSTEXPR EXPLICIT { $$ = "explicit constexpr"; }
| STATIC CONSTEXPR { $$ = "static constexpr"; }
+ | CONSTEXPR STATIC { $$ = "static constexpr"; }
| THREAD_LOCAL { $$ = "thread_local"; }
| THREAD_LOCAL STATIC { $$ = "static thread_local"; }
| STATIC THREAD_LOCAL { $$ = "static thread_local"; }
diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h
index d2ecd7d1c..9c9ecb652 100644
--- a/Source/Include/swigwarn.h
+++ b/Source/Include/swigwarn.h
@@ -232,13 +232,17 @@
/* please leave 700-719 free for D */
-#define WARN_DOXYGEN_UNKNOWN_COMMAND 720
-#define WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT 721
-#define WARN_DOXYGEN_COMMAND_EXPECTED 722
-#define WARN_DOXYGEN_UNTERMINATED_STRING 723
-#define WARN_DOXYGEN_COMMAND_ERROR 724
+#define WARN_SCILAB_TRUNCATED_NAME 720
-/* please leave 720-729 free for Doxygen */
+/* please leave 720-739 free for Scilab */
+
+#define WARN_DOXYGEN_UNKNOWN_COMMAND 740
+#define WARN_DOXYGEN_UNEXPECTED_END_OF_COMMENT 741
+#define WARN_DOXYGEN_COMMAND_EXPECTED 742
+#define WARN_DOXYGEN_UNTERMINATED_STRING 743
+#define WARN_DOXYGEN_COMMAND_ERROR 744
+
+/* please leave 740-749 free for Doxygen */
#define WARN_RUBY_WRONG_NAME 801
#define WARN_RUBY_MULTIPLE_INHERITANCE 802
diff --git a/Source/Makefile.am b/Source/Makefile.am
index 8f64db9ec..84dc05458 100644
--- a/Source/Makefile.am
+++ b/Source/Makefile.am
@@ -66,6 +66,7 @@ eswig_SOURCES = CParse/cscanner.c \
Modules/r.cxx \
Modules/ruby.cxx \
Modules/s-exp.cxx \
+ Modules/scilab.cxx \
Modules/swigmain.cxx \
Modules/tcl8.cxx \
Modules/typepass.cxx \
diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
index 39cab8f0a..3b1e03560 100644
--- a/Source/Modules/csharp.cxx
+++ b/Source/Modules/csharp.cxx
@@ -914,21 +914,10 @@ public:
String *null_attribute = 0;
// Now write code to make the function call
if (!native_function_flag) {
- if (Cmp(nodeType(n), "constant") == 0) {
- // Wrapping a constant hack
- Swig_save("functionWrapper", n, "wrap:action", NIL);
-
- // below based on Swig_VargetToFunction()
- SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
- Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
- }
Swig_director_emit_dynamic_cast(n, f);
String *actioncode = emit_action(n);
- if (Cmp(nodeType(n), "constant") == 0)
- Swig_restore(n);
-
/* Return value if necessary */
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
canThrow(n, "out", n);
diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx
index da31504e6..8546372ea 100644
--- a/Source/Modules/d.cxx
+++ b/Source/Modules/d.cxx
@@ -1701,21 +1701,10 @@ public:
String *null_attribute = 0;
// Now write code to make the function call
if (!native_function_flag) {
- if (Cmp(nodeType(n), "constant") == 0) {
- // Wrapping a constant hack
- Swig_save("functionWrapper", n, "wrap:action", NIL);
-
- // below based on Swig_VargetToFunction()
- SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
- Setattr(n, "wrap:action", NewStringf("%s = (%s) %s;", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
- }
Swig_director_emit_dynamic_cast(n, f);
String *actioncode = emit_action(n);
- if (Cmp(nodeType(n), "constant") == 0)
- Swig_restore(n);
-
/* Return value if necessary */
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
canThrow(n, "out", n);
diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx
index eac83a5a5..9a3960ce0 100644
--- a/Source/Modules/go.cxx
+++ b/Source/Modules/go.cxx
@@ -11,6 +11,103 @@
#include "cparse.h"
#include <ctype.h>
+/* ----------------------------------------------------------------------
+ * siphash()
+ *
+ * 64-bit SipHash-2-4 to generate unique id for each module
+ * ---------------------------------------------------------------------- */
+
+// An unsigned 64-bit integer that works on a 32-bit host.
+typedef struct {
+ // Assume unsigned long is at least 32 bits.
+ unsigned long hi;
+ unsigned long lo;
+} swig_uint64;
+
+// Rotate v left by bits, which must be <= 32.
+static inline void _rotl(swig_uint64 *v, int bits) {
+ assert(bits <= 32);
+ unsigned long tmp = v->hi;
+ if (bits == 32) {
+ v->hi = v->lo;
+ v->lo = tmp;
+ } else {
+ v->hi = (tmp << bits) | ((0xfffffffful & v->lo) >> (32 - bits));
+ v->lo = (v->lo << bits) | ((0xfffffffful & tmp) >> (32 - bits));
+ }
+}
+
+// dst ^= src
+static inline void _xor(swig_uint64 *dst, swig_uint64 *src) {
+ dst->lo ^= src->lo;
+ dst->hi ^= src->hi;
+}
+
+// dst += src
+static inline void _add(swig_uint64 *dst, swig_uint64 *src) {
+ dst->lo += src->lo;
+ dst->hi += src->hi + ((dst->lo & 0xfffffffful) < (src->lo&0xfffffffful) ? 1 : 0);
+}
+#define SIPROUND \
+ do { \
+ _add(&v0, &v1); _rotl(&v1, 13); _xor(&v1, &v0); _rotl(&v0, 32); \
+ _add(&v2, &v3); _rotl(&v3, 16); _xor(&v3, &v2); \
+ _add(&v0, &v3); _rotl(&v3, 21); _xor(&v3, &v0); \
+ _add(&v2, &v1); _rotl(&v1, 17); _xor(&v1, &v2); _rotl(&v2, 32); \
+ } while(0)
+
+// Set out to the hash of inc/inlen.
+static void siphash(swig_uint64 *out, const char *inc, unsigned long inlen) {
+ /* "somepseudorandomlygeneratedbytes" */
+ swig_uint64 v0 = {0x736f6d65UL, 0x70736575UL};
+ swig_uint64 v1 = {0x646f7261UL, 0x6e646f6dUL};
+ swig_uint64 v2 = {0x6c796765UL, 0x6e657261UL};
+ swig_uint64 v3 = {0x74656462UL, 0x79746573UL};
+ swig_uint64 b;
+ /* hard-coded k. */
+ swig_uint64 k0 = {0x07060504UL, 0x03020100UL};
+ swig_uint64 k1 = {0x0F0E0D0CUL, 0x0B0A0908UL};
+ int i;
+ const int cROUNDS = 2, dROUNDS = 4;
+ const unsigned char *in = (const unsigned char *)inc;
+ const unsigned char *end = in + inlen - (inlen % 8);
+ int left = inlen & 7;
+ _xor(&v3, &k1); _xor(&v2, &k0); _xor(&v1, &k1); _xor(&v0, &k0);
+ for (; in != end; in += 8) {
+ b.hi = 0; b.lo = 0;
+ for (i = 0; i < 4; i++) {
+ b.lo |= ((unsigned long)in[i]) << (8*i);
+ }
+ for (i = 0; i < 4; i++) {
+ b.hi |= ((unsigned long)in[i+4]) << (8*i);
+ }
+ _xor(&v3, &b);
+ for (i = 0; i < cROUNDS; i++) {
+ SIPROUND;
+ }
+ _xor(&v0, &b);
+ }
+ b.hi = (inlen & 0xff)<<24; b.lo = 0;
+ for (; left; left--) {
+ if (left > 4) {
+ b.hi |= ((unsigned long)in[left-1]) << (8*left-8-32);
+ } else {
+ b.lo |= ((unsigned long)in[left-1]) << (8*left-8);
+ }
+ }
+ _xor(&v3, &b);
+ for(i=0; i<cROUNDS; i++) {
+ SIPROUND;
+ }
+ _xor(&v0, &b); v2.lo ^= 0xff;
+ for(i=0; i<dROUNDS; i++) {
+ SIPROUND;
+ }
+ out->lo = 0; out->hi = 0;
+ _xor(out, &v0); _xor(out, &v1); _xor(out, &v2); _xor(out, &v3);
+}
+#undef SIPROUND
+
class GO:public Language {
static const char *const usage;
@@ -91,6 +188,8 @@ class GO:public Language {
// A hash table of all the go_imports already imported. The index is a full
// import name e.g. '"runtime"' or '_ "runtime/cgo"' or 'sc "syscall"'.
Hash *go_imports;
+ // A unique ID used to make public symbols unique.
+ String *unique_id;
public:
GO():package(NULL),
@@ -333,6 +432,20 @@ private:
Printf(gc_filename, "%s%s_gc.c", SWIG_output_directory(), module);
}
+ // Generate a unique ID based on a hash of the SWIG input.
+ swig_uint64 hash = {0, 0};
+ FILE *swig_input = Swig_open(swig_filename);
+ if (swig_input == NULL) {
+ FileErrorDisplay(swig_filename);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ String *swig_input_content = Swig_read_file(swig_input);
+ siphash(&hash, Char(swig_input_content), Len(swig_input_content));
+ Delete(swig_input_content);
+ fclose(swig_input);
+ unique_id = NewString("");
+ Printf(unique_id, "_%s_%08x%08x", package, hash.hi, hash.lo);
+
// Open files.
f_c_begin = NewFile(c_filename, "w", SWIG_output_files());
@@ -421,6 +534,7 @@ private:
Printf(f_c_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module);
Printf(f_c_directors_h, "#define SWIG_%s_WRAP_H_\n\n", module);
+ Printf(f_c_directors_h, "class Swig_memory;\n\n");
Printf(f_c_directors, "\n// C++ director class methods.\n");
String *filename = Swig_file_filename(c_filename_h);
@@ -744,6 +858,7 @@ private:
if (overname) {
Append(wname, overname);
}
+ Append(wname, unique_id);
Setattr(n, "wrap:name", wname);
ParmList *parms = Getattr(n, "parms");
@@ -895,7 +1010,7 @@ private:
receiver = NULL;
}
- String *goout = Swig_typemap_lookup("goout", n, "swig_r", NULL);
+ String *goout = goTypemapLookup("goout", n, "swig_r");
bool add_to_interface = (interfaces && !is_constructor && !is_destructor && !is_static && !overname && checkFunctionVisibility(n, NULL));
@@ -913,10 +1028,10 @@ private:
for (int i = 0; i < parm_count; ++i) {
p = getParm(p);
String *ty = Getattr(p, "type");
- if (Getattr(p, "tmap:goargout")) {
+ if (goGetattr(p, "tmap:goargout")) {
has_goout = true;
needs_wrapper = true;
- } else if (goTypeIsInterface(p, ty) || Getattr(p, "tmap:goin")) {
+ } else if (goTypeIsInterface(p, ty) || goGetattr(p, "tmap:goin")) {
needs_wrapper = true;
}
@@ -1188,7 +1303,7 @@ private:
SwigType *pt = Getattr(p, "type");
String *ln = Getattr(p, "lname");
- String *goin = Getattr(p, "tmap:goin");
+ String *goin = goGetattr(p, "tmap:goin");
if (goin == NULL) {
Printv(call, ln, NULL);
if ((i == 0 && is_destructor) || ((i > 0 || !receiver || base || is_constructor) && goTypeIsInterface(p, pt))) {
@@ -1238,7 +1353,7 @@ private:
Printv(f_go_wrappers, "\tvar swig_r_1 ", tm, "\n", NULL);
Replaceall(goout, "$input", "swig_r");
Replaceall(goout, "$result", "swig_r_1");
- Printv(f_go_wrappers, goout, NULL);
+ Printv(f_go_wrappers, goout, "\n", NULL);
Printv(f_go_wrappers, "\treturn swig_r_1\n", NULL);
}
}
@@ -1371,10 +1486,10 @@ private:
// The single function parameter is a pointer to the real argument
// values. Define the structure that it points to.
- Printv(f->code, "\tstruct swigargs {\n", NULL);
+ String *swigargs = NewString("\tstruct swigargs {\n");
if (parm_count > required_count) {
- Printv(f->code, "\t\tintgo _swig_optargc;\n", NULL);
+ Printv(swigargs, "\t\tintgo _swig_optargc;\n", NULL);
}
Parm *p = parms;
@@ -1384,7 +1499,7 @@ private:
String *ln = Getattr(p, "lname");
SwigType *pt = Getattr(p, "type");
String *ct = gcCTypeForGoValue(p, pt, ln);
- Printv(f->code, "\t\t\t", ct, ";\n", NULL);
+ Printv(swigargs, "\t\t\t", ct, ";\n", NULL);
Delete(ct);
String *gn = NewStringf("_swig_go_%d", i);
@@ -1396,11 +1511,11 @@ private:
p = nextParm(p);
}
if (SwigType_type(result) != T_VOID) {
- Printv(f->code, "\t\tlong : 0;\n", NULL);
+ Printv(swigargs, "\t\tlong : 0;\n", NULL);
String *ln = NewString(Swig_cresult_name());
String *ct = gcCTypeForGoValue(n, result, ln);
Delete(ln);
- Printv(f->code, "\t\t", ct, ";\n", NULL);
+ Printv(swigargs, "\t\t", ct, ";\n", NULL);
Delete(ct);
ln = NewString("_swig_go_result");
@@ -1409,9 +1524,7 @@ private:
Delete(ct);
Delete(ln);
}
- Printv(f->code, "\t} *swig_a = (struct swigargs *) swig_v;\n", NULL);
-
- Printv(f->code, "\n", NULL);
+ Printv(swigargs, "\t} *swig_a = (struct swigargs *) swig_v;\n", NULL);
// Copy the input arguments out of the structure into the Go local
// variables.
@@ -1459,12 +1572,15 @@ private:
cleanupFunction(n, f, parms);
+ Printv(f->locals, swigargs, NULL);
+
Printv(f->code, "}\n", NULL);
Wrapper_print(f, f_c_wrappers);
Swig_restore(n);
+ Delete(swigargs);
DelWrapper(f);
Delete(base_parm);
@@ -1745,7 +1861,7 @@ private:
Parm *p = parms;
for (int i = 0; i < parm_count; ++i) {
p = getParm(p);
- String *tm = Getattr(p, "tmap:goargout");
+ String *tm = goGetattr(p, "tmap:goargout");
if (!tm) {
p = nextSibling(p);
} else {
@@ -2044,6 +2160,7 @@ private:
Append(go_name, sname);
String *wname = Swig_name_wrapper(sname);
+ Append(wname, unique_id);
Setattr(n, "wrap:name", wname);
int r = makeWrappers(n, sname, go_name, NULL, wname, NULL, NULL, type, true);
@@ -2332,6 +2449,7 @@ private:
if (overname) {
Append(wname, overname);
}
+ Append(wname, unique_id);
String *result = NewString(Getattr(method, "type"));
SwigType_push(result, Getattr(method, "decl"));
@@ -2419,6 +2537,7 @@ private:
Swig_MembersetToFunction(var, class_name, flags);
String *wname = Swig_name_wrapper(mname_set);
+ Append(wname, unique_id);
ParmList *parms = NewParm(vt, var_name, var);
String *result = NewString("void");
int r = makeWrappers(var, mname_set, go_name, NULL, wname, bases, parms, result, false);
@@ -2448,6 +2567,7 @@ private:
Append(go_name, var_name);
String *wname = Swig_name_wrapper(mname_get);
+ Append(wname, unique_id);
int r = makeWrappers(var, mname_get, go_name, NULL, wname, bases, NULL, vt, false);
if (r != SWIG_OK) {
@@ -2559,6 +2679,7 @@ private:
Delete(c1);
String *wname = Swig_name_wrapper(name);
+ Append(wname, unique_id);
Setattr(n, "wrap:name", wname);
SwigType *result = Copy(Getattr(b.item, "classtypeobj"));
@@ -2772,6 +2893,7 @@ private:
if (overname) {
Append(wname, overname);
}
+ Append(wname, unique_id);
Setattr(n, "wrap:name", wname);
bool is_static = isStatic(n);
@@ -2885,7 +3007,9 @@ private:
Swig_save("classDirectorConstructor", n, "wrap:name", "wrap:action", NULL);
- Setattr(n, "wrap:name", Swig_name_wrapper(name));
+ String *dwname = Swig_name_wrapper(name);
+ Append(dwname, unique_id);
+ Setattr(n, "wrap:name", dwname);
String *action = NewString("");
Printv(action, Swig_cresult_name(), " = new SwigDirector_", class_name, "(", NULL);
@@ -2954,7 +3078,7 @@ private:
p = nextParm(p);
}
Printv(f_c_directors, "),\n", NULL);
- Printv(f_c_directors, " go_val(swig_p)\n", NULL);
+ Printv(f_c_directors, " go_val(swig_p), swig_mem(0)\n", NULL);
Printv(f_c_directors, "{ }\n\n", NULL);
if (Getattr(n, "sym:overloaded") && !Getattr(n, "sym:nextSibling")) {
@@ -2999,6 +3123,7 @@ private:
Delete(c1);
String *wname = Swig_name_wrapper(fnname);
+ Append(wname, unique_id);
Setattr(n, "wrap:name", fnname);
@@ -3022,9 +3147,6 @@ private:
// Go code is keeping a pointer to the C++ object, we need to call
// back to the Go code to let it know that the C++ object is gone.
- String *wname = NewString("_swiggo_wrap_DeleteDirector_");
- Append(wname, class_name);
-
String *go_name = NewString("Swiggo_DeleteDirector_");
Append(go_name, class_name);
@@ -3042,53 +3164,31 @@ private:
Printv(f_c_directors_h, ";\n", NULL);
- if (!is_ignored) {
- if (!gccgo_flag) {
- Printv(f_c_directors, "extern \"C\" void ", wname, "(void*, int);\n", NULL);
- } else {
- Printv(f_c_directors, "extern \"C\" void ", wname, "(void*) __asm__(\"", go_prefix, ".", go_name, "\");\n", NULL);
- }
- }
+ String *director_sig = NewString("");
- Printv(f_c_directors, "SwigDirector_", class_name, "::~SwigDirector_", class_name, "()", NULL);
+ Printv(director_sig, "SwigDirector_", class_name, "::~SwigDirector_", class_name, "()", NULL);
if (throws) {
- Printv(f_c_directors, " ", throws, NULL);
+ Printv(director_sig, " ", throws, NULL);
Delete(throws);
}
- Printv(f_c_directors, "\n", NULL);
- Printv(f_c_directors, "{\n", NULL);
+ Printv(director_sig, "\n", NULL);
+ Printv(director_sig, "{\n", NULL);
if (!is_ignored) {
- if (!gccgo_flag) {
- Printv(f_c_directors, " struct { void *p; } a;\n", NULL);
- Printv(f_c_directors, " a.p = go_val;\n", NULL);
- Printv(f_c_directors, " crosscall2(", wname, ", &a, (int) sizeof a);\n", NULL);
-
- Printv(f_gc_wrappers, "#pragma dynexport ", wname, " ", wname, "\n", NULL);
- Printv(f_gc_wrappers, "#pragma cgo_export_static ", wname, " ", wname, "\n", NULL);
- Printv(f_gc_wrappers, "#pragma textflag 7\n", NULL);
- Printv(f_gc_wrappers, "extern void \xc2\xb7", go_name, "();\n", NULL);
- Printv(f_gc_wrappers, "void\n", NULL);
- Printv(f_gc_wrappers, wname, "(void *a, int32 n)\n", NULL);
- Printv(f_gc_wrappers, "{\n", NULL);
- Printv(f_gc_wrappers, "\truntime\xc2\xb7" "cgocallback(\xc2\xb7", go_name, ", a, n);\n", NULL);
- Printv(f_gc_wrappers, "}\n\n", NULL);
- } else {
- Printv(f_c_directors, " ", wname, "(go_val);\n", NULL);
- }
- }
+ makeDirectorDestructorWrapper(go_name, director_sig);
- Printv(f_c_directors, "}\n\n", NULL);
+ Printv(f_c_directors, " delete swig_mem;\n", NULL);
- if (!is_ignored) {
Printv(f_go_wrappers, "func ", go_name, "(p *", director_struct_name, ") {\n", NULL);
Printv(f_go_wrappers, "\tp.", class_receiver, " = 0\n", NULL);
Printv(f_go_wrappers, "}\n\n", NULL);
}
- Delete(wname);
+ Printv(f_c_directors, "}\n\n", NULL);
+
+ Delete(director_sig);
Delete(go_name);
Delete(cn);
Delete(director_struct_name);
@@ -3097,6 +3197,47 @@ private:
}
/* ------------------------------------------------------------
+ * makeDirectorDestructorWrapper
+ *
+ * Emit the function wrapper for the destructor of a director class.
+ * This writes director_sig to f_c_directors and leaves the function
+ * unfinished.
+ * ------------------------------------------------------------ */
+
+ void makeDirectorDestructorWrapper(String *go_name, String *director_sig) {
+ String *wname = NewString("_swiggo_wrap_DeleteDirector_");
+ Append(wname, class_name);
+
+ if (!gccgo_flag) {
+ Printv(f_c_directors, "extern \"C\" void ", wname, "(void*, int);\n", NULL);
+ } else {
+ Printv(f_c_directors, "extern \"C\" void ", wname, "(void*) __asm__(\"", go_prefix, ".", go_name, "\");\n", NULL);
+ }
+
+ Printv(f_c_directors, director_sig, NULL);
+
+ if (!gccgo_flag) {
+ Printv(f_c_directors, " struct { void *p; } a;\n", NULL);
+ Printv(f_c_directors, " a.p = go_val;\n", NULL);
+ Printv(f_c_directors, " crosscall2(", wname, ", &a, (int) sizeof a);\n", NULL);
+
+ Printv(f_gc_wrappers, "#pragma dynexport ", wname, " ", wname, "\n", NULL);
+ Printv(f_gc_wrappers, "#pragma cgo_export_static ", wname, " ", wname, "\n", NULL);
+ Printv(f_gc_wrappers, "#pragma textflag 7\n", NULL);
+ Printv(f_gc_wrappers, "extern void \xc2\xb7", go_name, "();\n", NULL);
+ Printv(f_gc_wrappers, "void\n", NULL);
+ Printv(f_gc_wrappers, wname, "(void *a, int32 n)\n", NULL);
+ Printv(f_gc_wrappers, "{\n", NULL);
+ Printv(f_gc_wrappers, "\truntime\xc2\xb7" "cgocallback(\xc2\xb7", go_name, ", a, n);\n", NULL);
+ Printv(f_gc_wrappers, "}\n\n", NULL);
+ } else {
+ Printv(f_c_directors, " ", wname, "(go_val);\n", NULL);
+ }
+
+ Delete(wname);
+ }
+
+ /* ------------------------------------------------------------
* classDirectorMethod
*
* Emit a method for a director class, plus its overloads.
@@ -3134,6 +3275,7 @@ private:
// set.
String *wn = Swig_name_wrapper(Getattr(on, "sym:name"));
Append(wn, Getattr(on, "sym:overname"));
+ Append(wn, unique_id);
Setattr(on, "wrap:name", wn);
Delete(wn);
Setattr(on, "wrap:parms", Getattr(on, "parms"));
@@ -3251,8 +3393,6 @@ private:
Append(callback_name, overname);
}
- String *callback_wname = Swig_name_wrapper(callback_name);
-
String *upcall_name = Copy(director_struct_name);
Append(upcall_name, "_upcall_");
Append(upcall_name, go_name);
@@ -3261,6 +3401,7 @@ private:
if (overname) {
Append(upcall_wname, overname);
}
+ Append(upcall_wname, unique_id);
String *upcall_gc_name = buildGoWrapperName(upcall_name, overname);
@@ -3405,7 +3546,7 @@ private:
String *goout = NULL;
if (SwigType_type(result) != T_VOID) {
Printv(f_go_wrappers, "\tvar swig_r ", goImType(n, result), "\n", NULL);
- goout = Swig_typemap_lookup("goout", n, "swig_r", NULL);
+ goout = goTypemapLookup("goout", n, "swig_r");
if (goout) {
has_goout = true;
}
@@ -3414,7 +3555,7 @@ private:
p = parms;
for (int i = 0; i < parm_count; ++i) {
p = getParm(p);
- if (Getattr(p, "tmap:goargout")) {
+ if (goGetattr(p, "tmap:goargout")) {
has_goout = true;
}
p = nextParm(p);
@@ -3446,7 +3587,7 @@ private:
// This is an ordinary call from Go to C++, so adjust using
// the goin typemap.
- String *goin = Getattr(p, "tmap:goin");
+ String *goin = goGetattr(p, "tmap:goin");
if (goin == NULL) {
Printv(call, ln, NULL);
if (goTypeIsInterface(p, pt)) {
@@ -3489,7 +3630,7 @@ private:
Printv(f_go_wrappers, "\tvar swig_r_1 ", tm, "\n", NULL);
Replaceall(goout, "$input", "swig_r");
Replaceall(goout, "$result", "swig_r_1");
- Printv(f_go_wrappers, goout, NULL);
+ Printv(f_go_wrappers, goout, "\n", NULL);
Printv(f_go_wrappers, "\treturn swig_r_1\n", NULL);
}
}
@@ -3628,7 +3769,7 @@ private:
String *goout = NULL;
if (SwigType_type(result) != T_VOID) {
Printv(f_go_wrappers, "\tvar swig_r ", goImType(n, result), "\n", NULL);
- goout = Swig_typemap_lookup("goout", n, "swig_r", NULL);
+ goout = goTypemapLookup("goout", n, "swig_r");
}
String *call = NewString("");
@@ -3658,7 +3799,7 @@ private:
Printv(ln, ".Swigcptr()", NULL);
}
- String *goin = Getattr(p, "tmap:goin");
+ String *goin = goGetattr(p, "tmap:goin");
if (goin == NULL) {
Printv(call, ln, NULL);
Setattr(p, "emit:goinput", ln);
@@ -3700,7 +3841,7 @@ private:
Printv(f_go_wrappers, "\tvar swig_r_1 ", tm, "\n", NULL);
Replaceall(goout, "$input", "swig_r");
Replaceall(goout, "$result", "swig_r_1");
- Printv(f_go_wrappers, goout, NULL);
+ Printv(f_go_wrappers, goout, "\n", NULL);
Printv(f_go_wrappers, "\treturn swig_r_1\n", NULL);
}
}
@@ -3744,19 +3885,10 @@ private:
Printv(f_go_wrappers, result_wrapper, NULL);
}
Printv(f_go_wrappers, "\n", NULL);
- goout = Swig_typemap_lookup("godirectorout", n, "swig_r", NULL);
+ goout = goTypemapLookup("godirectorout", n, "swig_r");
}
String *call = NewString("");
-
- if (gccgo_flag) {
- if (goout != NULL) {
- Printv(call, "\tfunc() {\n", NULL);
- }
- Printv(call, "\tSwigCgocallBack()\n", NULL);
- Printv(call, "\tdefer SwigCgocallBackDone()\n", NULL);
- }
-
Printv(call, "\t", NULL);
if (SwigType_type(result) != T_VOID) {
@@ -3767,6 +3899,8 @@ private:
}
Printv(call, "p.", go_with_over_name, "(", NULL);
+ String *goincode = NewString("");
+
p = parms;
for (int i = 0; i < parm_count; ++i) {
p = getParm(p);
@@ -3795,18 +3929,18 @@ private:
Printv(ln, ")", NULL);
}
- String *goin = Getattr(p, "tmap:godirectorin");
+ String *goin = goGetattr(p, "tmap:godirectorin");
if (goin == NULL) {
Printv(call, ln, NULL);
} else {
String *ivar = NewString("");
Printf(ivar, "_swig_i_%d", i);
String *itm = goType(p, pt);
- Printv(f_go_wrappers, "\tvar ", ivar, " ", itm, NULL);
+ Printv(f_go_wrappers, "\tvar ", ivar, " ", itm, "\n", NULL);
goin = Copy(goin);
Replaceall(goin, "$input", ln);
Replaceall(goin, "$result", ivar);
- Printv(f_go_wrappers, goin, NULL);
+ Printv(goincode, goin, "\n", NULL);
Delete(goin);
Printv(call, ivar, NULL);
Delete(ivar);
@@ -3824,13 +3958,22 @@ private:
}
Printv(call, "\n", NULL);
- if (gccgo_flag && goout != NULL) {
- Printv(call, "\t}()\n", NULL);
+ if (gccgo_flag) {
+ if (goout != NULL) {
+ Printv(f_go_wrappers, "\tfunc() {\n", NULL);
+ }
+ Printv(f_go_wrappers, "\tSwigCgocallBack()\n", NULL);
+ Printv(f_go_wrappers, "\tdefer SwigCgocallBackDone()\n", NULL);
}
+ Printv(f_go_wrappers, goincode, NULL);
Printv(f_go_wrappers, call, NULL);
Delete(call);
+ if (gccgo_flag && goout != NULL) {
+ Printv(f_go_wrappers, "\t}()\n", NULL);
+ }
+
if (SwigType_type(result) != T_VOID) {
if (goout == NULL) {
Printv(f_go_wrappers, "\treturn swig_r\n", NULL);
@@ -3839,7 +3982,7 @@ private:
Printv(f_go_wrappers, "\tvar swig_r_1 ", tm, "\n", NULL);
Replaceall(goout, "$input", "swig_r");
Replaceall(goout, "$result", "swig_r_1");
- Printv(f_go_wrappers, goout, NULL);
+ Printv(f_go_wrappers, goout, "\n", NULL);
Printv(f_go_wrappers, "\treturn swig_r_1\n", NULL);
}
}
@@ -3851,44 +3994,6 @@ private:
Delete(upcall_wname);
Delete(upcall_gc_name);
-
- // Build the C++ functions.
-
- if (!gccgo_flag) {
- Printv(f_c_directors, "extern \"C\" void ", callback_wname, "(void*, int);\n", NULL);
- } else {
- Printv(f_c_directors, "extern \"C\" ", NULL);
-
- String *fnname = NewString("");
- Printv(fnname, callback_wname, "(void*", NULL);
-
- p = parms;
- while (p) {
- while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
- p = Getattr(p, "tmap:directorin:next");
- }
- String *cg = gccgoCTypeForGoValue(p, Getattr(p, "type"),
- Getattr(p, "lname"));
- Printv(fnname, ", ", cg, NULL);
- Delete(cg);
- p = Getattr(p, "tmap:directorin:next");
- }
-
- Printv(fnname, ")", NULL);
-
- if (SwigType_type(result) == T_VOID) {
- Printv(f_c_directors, "void ", fnname, NULL);
- } else {
- String *tm = gccgoCTypeForGoValue(n, result, fnname);
- Printv(f_c_directors, tm, NULL);
- Delete(tm);
- }
-
- Delete(fnname);
-
- Printv(f_c_directors, " __asm__(\"", go_prefix, ".", callback_name, "\");\n", NULL);
- }
-
Delete(go_with_over_name);
}
@@ -3923,184 +4028,7 @@ private:
}
if (!is_ignored) {
- if (!gccgo_flag) {
- Printv(w->code, " struct {\n", NULL);
- Printv(w->code, " void *go_val;\n", NULL);
-
- p = parms;
- while (p) {
- while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
- p = Getattr(p, "tmap:directorin:next");
- }
- String *ln = Getattr(p, "lname");
- String *cg = gcCTypeForGoValue(p, Getattr(p, "type"), ln);
- Printv(w->code, " ", cg, ";\n", NULL);
- Delete(cg);
- p = Getattr(p, "tmap:directorin:next");
- }
- if (SwigType_type(result) != T_VOID) {
- Printv(w->code, " long : 0;\n", NULL);
- String *rname = NewString(Swig_cresult_name());
- String *cg = gcCTypeForGoValue(n, result, rname);
- Printv(w->code, " ", cg, ";\n", NULL);
- Delete(cg);
- Delete(rname);
- }
-
- Printv(w->code, " } swig_a;\n", NULL);
- Printv(w->code, " swig_a.go_val = go_val;\n", NULL);
-
- p = parms;
- while (p) {
- while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
- p = Getattr(p, "tmap:directorin:next");
- }
- String *tm = Getattr(p, "tmap:directorin");
- if (!tm) {
- Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file,
- line_number, "Unable to use type %s as director method argument\n", SwigType_str(Getattr(p, "type"), 0));
- } else {
- tm = Copy(tm);
- String *ln = Getattr(p, "lname");
- String *input = NewString("");
- Printv(input, "swig_a.", ln, NULL);
- Setattr(p, "emit:directorinput", input);
- Replaceall(tm, "$input", input);
- Replaceall(tm, "$owner", "0");
- Delete(input);
- Printv(w->code, "\t", tm, "\n", NULL);
- Delete(tm);
- }
- p = Getattr(p, "tmap:directorin:next");
- }
-
- Printv(w->code, " crosscall2(", callback_wname, ", &swig_a, (int) sizeof swig_a);\n", NULL);
-
- /* Marshal outputs */
- for (p = parms; p;) {
- String *tm;
- if ((tm = Getattr(p, "tmap:directorargout"))) {
- tm = Copy(tm);
- Replaceall(tm, "$result", "jresult");
- Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
- Printv(w->code, tm, "\n", NIL);
- Delete(tm);
- p = Getattr(p, "tmap:directorargout:next");
- } else {
- p = nextSibling(p);
- }
- }
-
- if (SwigType_type(result) != T_VOID) {
- String *result_str = NewString("c_result");
- String *tm = Swig_typemap_lookup("directorout", n, result_str, NULL);
- if (!tm) {
- Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
- "Unable to use type %s as director method result\n", SwigType_str(result, 0));
- } else {
- static const String *swig_a_result = NewStringf("swig_a.%s", Swig_cresult_name());
- Replaceall(tm, "$input", swig_a_result);
- Replaceall(tm, "$result", "c_result");
- Printv(w->code, " ", tm, "\n", NULL);
- String *retstr = SwigType_rcaststr(result, "c_result");
- Printv(w->code, " return ", retstr, ";\n", NULL);
- Delete(retstr);
- Delete(tm);
- }
- Delete(result_str);
- }
-
- // The C wrapper code which calls the Go function.
- Printv(f_gc_wrappers, "#pragma dynexport ", callback_wname, " ", callback_wname, "\n", NULL);
- Printv(f_gc_wrappers, "#pragma cgo_export_static ", callback_wname, " ", callback_wname, "\n", NULL);
- Printv(f_gc_wrappers, "#pragma textflag 7\n", NULL);
- Printv(f_gc_wrappers, "extern void \xc2\xb7", callback_name, "();\n", NULL);
- Printv(f_gc_wrappers, "void\n", NULL);
- Printv(f_gc_wrappers, callback_wname, "(void *a, int32 n)\n", NULL);
- Printv(f_gc_wrappers, "{\n", NULL);
- Printv(f_gc_wrappers, "\truntime\xc2\xb7" "cgocallback(\xc2\xb7", callback_name, ", a, n);\n", NULL);
- Printv(f_gc_wrappers, "}\n\n", NULL);
- } else {
- if (SwigType_type(result) != T_VOID) {
- String *r = NewString(Swig_cresult_name());
- String *tm = gccgoCTypeForGoValue(n, result, r);
- Wrapper_add_local(w, r, tm);
- Delete(tm);
- Delete(r);
- }
-
- String *args = NewString("");
-
- p = parms;
- while (p) {
- while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
- p = Getattr(p, "tmap:directorin:next");
- }
-
- String *pn = NewString("g");
- Append(pn, Getattr(p, "lname"));
- Setattr(p, "emit:directorinput", pn);
-
- String *tm = gccgoCTypeForGoValue(n, Getattr(p, "type"), pn);
- Wrapper_add_local(w, pn, tm);
- Delete(tm);
-
- tm = Getattr(p, "tmap:directorin");
- if (!tm) {
- Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file,
- line_number, "Unable to use type %s as director method argument\n", SwigType_str(Getattr(p, "type"), 0));
- } else {
- tm = Copy(tm);
- Replaceall(tm, "$input", pn);
- Replaceall(tm, "$owner", 0);
- Printv(w->code, " ", tm, "\n", NULL);
- Delete(tm);
-
- Printv(args, ", ", pn, NULL);
- }
-
- p = Getattr(p, "tmap:directorin:next");
- }
-
- Printv(w->code, " ", NULL);
- if (SwigType_type(result) != T_VOID) {
- Printv(w->code, Swig_cresult_name(), " = ", NULL);
- }
- Printv(w->code, callback_wname, "(go_val", args, ");\n", NULL);
-
- /* Marshal outputs */
- for (p = parms; p;) {
- String *tm;
- if ((tm = Getattr(p, "tmap:directorargout"))) {
- tm = Copy(tm);
- Replaceall(tm, "$result", "jresult");
- Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
- Printv(w->code, tm, "\n", NIL);
- Delete(tm);
- p = Getattr(p, "tmap:directorargout:next");
- } else {
- p = nextSibling(p);
- }
- }
-
- if (SwigType_type(result) != T_VOID) {
- String *result_str = NewString("c_result");
- String *tm = Swig_typemap_lookup("directorout", n, result_str, NULL);
- if (!tm) {
- Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
- "Unable to use type %s as director method result\n", SwigType_str(result, 0));
- } else {
- Replaceall(tm, "$input", Swig_cresult_name());
- Replaceall(tm, "$result", "c_result");
- Printv(w->code, " ", tm, "\n", NULL);
- String *retstr = SwigType_rcaststr(result, "c_result");
- Printv(w->code, " return ", retstr, ";\n", NULL);
- Delete(retstr);
- Delete(tm);
- }
- Delete(result_str);
- }
- }
+ makeDirectorMethodWrapper(n, w, callback_name);
} else {
assert(is_pure_virtual);
Printv(w->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n", NULL);
@@ -4122,7 +4050,6 @@ private:
Delete(director_struct_name);
Delete(interface_name);
Delete(upcall_name);
- Delete(callback_wname);
Delete(go_name);
DelWrapper(w);
@@ -4130,6 +4057,235 @@ private:
}
/* ------------------------------------------------------------
+ * makeDirectorMethodWrapper
+ *
+ * Emit the function wrapper for a director method.
+ * ------------------------------------------------------------ */
+ void makeDirectorMethodWrapper(Node *n, Wrapper *w, String *callback_name) {
+ ParmList *parms = Getattr(n, "wrap:parms");
+ SwigType *result = Getattr(n, "type");
+
+ String *callback_wname = Swig_name_wrapper(callback_name);
+ Append(callback_wname, unique_id);
+
+ if (!gccgo_flag) {
+ Printv(f_c_directors, "extern \"C\" void ", callback_wname, "(void*, int);\n", NULL);
+ } else {
+ Printv(f_c_directors, "extern \"C\" ", NULL);
+
+ String *fnname = NewString("");
+ Printv(fnname, callback_wname, "(void*", NULL);
+
+ Parm *p = parms;
+ while (p) {
+ while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
+ p = Getattr(p, "tmap:directorin:next");
+ }
+ String *cg = gccgoCTypeForGoValue(p, Getattr(p, "type"),
+ Getattr(p, "lname"));
+ Printv(fnname, ", ", cg, NULL);
+ Delete(cg);
+ p = Getattr(p, "tmap:directorin:next");
+ }
+
+ Printv(fnname, ")", NULL);
+
+ if (SwigType_type(result) == T_VOID) {
+ Printv(f_c_directors, "void ", fnname, NULL);
+ } else {
+ String *tm = gccgoCTypeForGoValue(n, result, fnname);
+ Printv(f_c_directors, tm, NULL);
+ Delete(tm);
+ }
+
+ Delete(fnname);
+
+ Printv(f_c_directors, " __asm__(\"", go_prefix, ".", callback_name, "\");\n", NULL);
+ }
+
+ if (!gccgo_flag) {
+ Printv(w->code, " struct {\n", NULL);
+ Printv(w->code, " void *go_val;\n", NULL);
+
+ Parm *p = parms;
+ while (p) {
+ while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
+ p = Getattr(p, "tmap:directorin:next");
+ }
+ String *ln = Getattr(p, "lname");
+ String *cg = gcCTypeForGoValue(p, Getattr(p, "type"), ln);
+ Printv(w->code, " ", cg, ";\n", NULL);
+ Delete(cg);
+ p = Getattr(p, "tmap:directorin:next");
+ }
+ if (SwigType_type(result) != T_VOID) {
+ Printv(w->code, " long : 0;\n", NULL);
+ String *rname = NewString(Swig_cresult_name());
+ String *cg = gcCTypeForGoValue(n, result, rname);
+ Printv(w->code, " ", cg, ";\n", NULL);
+ Delete(cg);
+ Delete(rname);
+ }
+
+ Printv(w->code, " } swig_a;\n", NULL);
+ Printv(w->code, " swig_a.go_val = go_val;\n", NULL);
+
+ p = parms;
+ while (p) {
+ while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
+ p = Getattr(p, "tmap:directorin:next");
+ }
+ String *tm = Getattr(p, "tmap:directorin");
+ if (!tm) {
+ Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file,
+ line_number, "Unable to use type %s as director method argument\n", SwigType_str(Getattr(p, "type"), 0));
+ } else {
+ tm = Copy(tm);
+ String *ln = Getattr(p, "lname");
+ String *input = NewString("");
+ Printv(input, "swig_a.", ln, NULL);
+ Setattr(p, "emit:directorinput", input);
+ Replaceall(tm, "$input", input);
+ Replaceall(tm, "$owner", "0");
+ Delete(input);
+ Printv(w->code, "\t", tm, "\n", NULL);
+ Delete(tm);
+ }
+ p = Getattr(p, "tmap:directorin:next");
+ }
+
+ Printv(w->code, " crosscall2(", callback_wname, ", &swig_a, (int) sizeof swig_a);\n", NULL);
+
+ /* Marshal outputs */
+ for (p = parms; p;) {
+ String *tm;
+ if ((tm = Getattr(p, "tmap:directorargout"))) {
+ tm = Copy(tm);
+ Replaceall(tm, "$result", "jresult");
+ Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
+ Printv(w->code, tm, "\n", NIL);
+ Delete(tm);
+ p = Getattr(p, "tmap:directorargout:next");
+ } else {
+ p = nextSibling(p);
+ }
+ }
+
+ if (SwigType_type(result) != T_VOID) {
+ String *result_str = NewString("c_result");
+ String *tm = Swig_typemap_lookup("directorout", n, result_str, NULL);
+ if (!tm) {
+ Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
+ "Unable to use type %s as director method result\n", SwigType_str(result, 0));
+ } else {
+ static const String *swig_a_result = NewStringf("swig_a.%s", Swig_cresult_name());
+ Replaceall(tm, "$input", swig_a_result);
+ Replaceall(tm, "$result", "c_result");
+ Printv(w->code, " ", tm, "\n", NULL);
+ String *retstr = SwigType_rcaststr(result, "c_result");
+ Printv(w->code, " return ", retstr, ";\n", NULL);
+ Delete(retstr);
+ Delete(tm);
+ }
+ Delete(result_str);
+ }
+
+ // The C wrapper code which calls the Go function.
+ Printv(f_gc_wrappers, "#pragma dynexport ", callback_wname, " ", callback_wname, "\n", NULL);
+ Printv(f_gc_wrappers, "#pragma cgo_export_static ", callback_wname, " ", callback_wname, "\n", NULL);
+ Printv(f_gc_wrappers, "#pragma textflag 7\n", NULL);
+ Printv(f_gc_wrappers, "extern void \xc2\xb7", callback_name, "();\n", NULL);
+ Printv(f_gc_wrappers, "void\n", NULL);
+ Printv(f_gc_wrappers, callback_wname, "(void *a, int32 n)\n", NULL);
+ Printv(f_gc_wrappers, "{\n", NULL);
+ Printv(f_gc_wrappers, "\truntime\xc2\xb7" "cgocallback(\xc2\xb7", callback_name, ", a, n);\n", NULL);
+ Printv(f_gc_wrappers, "}\n\n", NULL);
+ } else {
+ if (SwigType_type(result) != T_VOID) {
+ String *r = NewString(Swig_cresult_name());
+ String *tm = gccgoCTypeForGoValue(n, result, r);
+ Wrapper_add_local(w, r, tm);
+ Delete(tm);
+ Delete(r);
+ }
+
+ String *args = NewString("");
+
+ Parm *p = parms;
+ while (p) {
+ while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
+ p = Getattr(p, "tmap:directorin:next");
+ }
+
+ String *pn = NewString("g");
+ Append(pn, Getattr(p, "lname"));
+ Setattr(p, "emit:directorinput", pn);
+
+ String *tm = gccgoCTypeForGoValue(n, Getattr(p, "type"), pn);
+ Wrapper_add_local(w, pn, tm);
+ Delete(tm);
+
+ tm = Getattr(p, "tmap:directorin");
+ if (!tm) {
+ Swig_warning(WARN_TYPEMAP_DIRECTORIN_UNDEF, input_file,
+ line_number, "Unable to use type %s as director method argument\n", SwigType_str(Getattr(p, "type"), 0));
+ } else {
+ tm = Copy(tm);
+ Replaceall(tm, "$input", pn);
+ Replaceall(tm, "$owner", 0);
+ Printv(w->code, " ", tm, "\n", NULL);
+ Delete(tm);
+
+ Printv(args, ", ", pn, NULL);
+ }
+
+ p = Getattr(p, "tmap:directorin:next");
+ }
+
+ Printv(w->code, " ", NULL);
+ if (SwigType_type(result) != T_VOID) {
+ Printv(w->code, Swig_cresult_name(), " = ", NULL);
+ }
+ Printv(w->code, callback_wname, "(go_val", args, ");\n", NULL);
+
+ /* Marshal outputs */
+ for (p = parms; p;) {
+ String *tm;
+ if ((tm = Getattr(p, "tmap:directorargout"))) {
+ tm = Copy(tm);
+ Replaceall(tm, "$result", "jresult");
+ Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
+ Printv(w->code, tm, "\n", NIL);
+ Delete(tm);
+ p = Getattr(p, "tmap:directorargout:next");
+ } else {
+ p = nextSibling(p);
+ }
+ }
+
+ if (SwigType_type(result) != T_VOID) {
+ String *result_str = NewString("c_result");
+ String *tm = Swig_typemap_lookup("directorout", n, result_str, NULL);
+ if (!tm) {
+ Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
+ "Unable to use type %s as director method result\n", SwigType_str(result, 0));
+ } else {
+ Replaceall(tm, "$input", Swig_cresult_name());
+ Replaceall(tm, "$result", "c_result");
+ Printv(w->code, " ", tm, "\n", NULL);
+ String *retstr = SwigType_rcaststr(result, "c_result");
+ Printv(w->code, " return ", retstr, ";\n", NULL);
+ Delete(retstr);
+ Delete(tm);
+ }
+ Delete(result_str);
+ }
+ }
+
+ Delete(callback_wname);
+ }
+
+ /* ------------------------------------------------------------
* classDirectorEnd
*
* Complete support for a director class.
@@ -4140,6 +4296,7 @@ private:
Printv(f_c_directors_h, " private:\n", NULL);
Printv(f_c_directors_h, " void *go_val;\n", NULL);
+ Printv(f_c_directors_h, " Swig_memory *swig_mem;\n", NULL);
Printv(f_c_directors_h, "};\n\n", NULL);
class_name = NULL;
@@ -5420,6 +5577,32 @@ private:
return storage && Strcmp(storage, "friend") == 0;
}
+ /* ----------------------------------------------------------------------
+ * goGetattr
+ *
+ * Fetch an attribute from a node but return NULL if it is the empty string.
+ * ---------------------------------------------------------------------- */
+ Node *goGetattr(Node *n, const char *name) {
+ Node *ret = Getattr(n, name);
+ if (ret != NULL && Len(ret) == 0) {
+ ret = NULL;
+ }
+ return ret;
+ }
+
+ /* ----------------------------------------------------------------------
+ * goTypemapLookup
+ *
+ * Look up a typemap but return NULL if it is the empty string.
+ * ---------------------------------------------------------------------- */
+ String *goTypemapLookup(const char *name, Node *node, const char *lname) {
+ String *ret = Swig_typemap_lookup(name, node, lname, NULL);
+ if (ret != NULL && Len(ret) == 0) {
+ ret = NULL;
+ }
+ return ret;
+ }
+
}; /* class GO */
/* -----------------------------------------------------------------------------
diff --git a/Source/Modules/guile.cxx b/Source/Modules/guile.cxx
index 1c135b53d..61f79c1d0 100644
--- a/Source/Modules/guile.cxx
+++ b/Source/Modules/guile.cxx
@@ -1300,13 +1300,13 @@ public:
char *name = GetChar(n, "name");
char *iname = GetChar(n, "sym:name");
SwigType *type = Getattr(n, "type");
- String *value = Getattr(n, "value");
+ String *rawval = Getattr(n, "rawval");
+ String *value = rawval ? rawval : Getattr(n, "value");
int constasvar = GetFlag(n, "feature:constasvar");
String *proc_name;
String *var_name;
- String *rvalue;
Wrapper *f;
SwigType *nctype;
String *tm;
@@ -1334,23 +1334,14 @@ public:
}
// See if there's a typemap
- bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
- if (SwigType_type(nctype) == T_STRING) {
- rvalue = NewStringf("\"%s\"", value);
- } else if (SwigType_type(nctype) == T_CHAR && !is_enum_item) {
- rvalue = NewStringf("\'%s\'", value);
- } else {
- rvalue = NewString(value);
- }
-
if ((tm = Swig_typemap_lookup("constant", n, name, 0))) {
- Replaceall(tm, "$source", rvalue);
- Replaceall(tm, "$value", rvalue);
+ Replaceall(tm, "$source", value);
+ Replaceall(tm, "$value", value);
Replaceall(tm, "$target", name);
Printv(f_header, tm, "\n", NIL);
} else {
// Create variable and assign it a value
- Printf(f_header, "static %s = (%s)(%s);\n", SwigType_str(type, var_name), SwigType_str(type, 0), rvalue);
+ Printf(f_header, "static %s = (%s)(%s);\n", SwigType_str(type, var_name), SwigType_str(type, 0), value);
}
{
/* Hack alert: will cleanup later -- Dave */
@@ -1370,7 +1361,6 @@ public:
Delete(var_name);
Delete(nctype);
Delete(proc_name);
- Delete(rvalue);
DelWrapper(f);
return SWIG_OK;
}
diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
index 741e5ff4d..dcbc2718c 100644
--- a/Source/Modules/java.cxx
+++ b/Source/Modules/java.cxx
@@ -1078,26 +1078,15 @@ public:
}
}
+ // Now write code to make the function call
if (!native_function_flag) {
- if (Cmp(nodeType(n), "constant") == 0) {
- // Wrapping a constant hack
- Swig_save("functionWrapper", n, "wrap:action", NIL);
- // below based on Swig_VargetToFunction()
- SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
- Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
- }
-
- // Now write code to make the function call
Swig_director_emit_dynamic_cast(n, f);
String *actioncode = emit_action(n);
// Handle exception classes specified in the "except" feature's "throws" attribute
addThrows(n, "feature:except", n);
- if (Cmp(nodeType(n), "constant") == 0)
- Swig_restore(n);
-
/* Return value if necessary */
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
addThrows(n, "tmap:out", n);
diff --git a/Source/Modules/javascript.cxx b/Source/Modules/javascript.cxx
index 0c3f02a75..179ffb28c 100644
--- a/Source/Modules/javascript.cxx
+++ b/Source/Modules/javascript.cxx
@@ -1792,6 +1792,7 @@ int JSCEmitter::emitNamespaces() {
namespace_definition.replace("$jsglobalvariables", variables)
.replace("$jsglobalfunctions", functions)
.replace("$jsnspace", name_mangled)
+ .replace("$jsmangledname", name_mangled)
.pretty_print(f_wrap_cpp);
Template t_createNamespace(getTemplate("jsc_nspace_definition"));
diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
index f41844d34..aa0d7d589 100644
--- a/Source/Modules/main.cxx
+++ b/Source/Modules/main.cxx
@@ -63,6 +63,8 @@ static const char *usage1 = (const char *) "\
-co <file> - Check <file> out of the SWIG library\n\
-copyctor - Automatically generate copy constructors wherever possible\n\
-cpperraswarn - Treat the preprocessor #error statement as #warning (default)\n\
+ -cppext <ext> - Change file extension of generated C++ files to <ext>\n\
+ (default is cxx, except for PHP which uses cpp)\n\
-copyright - Display copyright notices\n\
-debug-classes - Display information about the classes found in the interface\n\
-debug-module <n>- Display module parse tree at stages 1-4, <n> is a csv list of stages\n\
@@ -80,6 +82,9 @@ static const char *usage1 = (const char *) "\
-directors - Turn on director mode for all the classes, mainly for testing\n\
-dirprot - Turn on wrapping of protected members for director classes (default)\n\
-D<symbol> - Define a symbol <symbol> (for conditional compilation)\n\
+";
+
+static const char *usage2 = (const char *) "\
-E - Preprocess only, does not generate wrapper code\n\
-external-runtime [file] - Export the SWIG runtime stack\n\
-fakeversion <v>- Make SWIG fake the program version number to <v>\n\
@@ -87,9 +92,6 @@ static const char *usage1 = (const char *) "\
-features <list>- Set global features, where <list> is a comma separated list of\n\
features, eg -features directors,autodoc=1\n\
If no explicit value is given to the feature, a default of 1 is used\n\
-";
-
-static const char *usage2 = (const char *) "\
-fastdispatch - Enable fast dispatch mode to produce faster overload dispatcher code\n\
-Fmicrosoft - Display error/warning messages in Microsoft format\n\
-Fstandard - Display error/warning messages in commonly used format\n\
@@ -101,6 +103,9 @@ static const char *usage2 = (const char *) "\
-importall - Follow all #include statements as imports\n\
-includeall - Follow all #include statements\n\
-l<ifile> - Include SWIG library file <ifile>\n\
+";
+
+static const char *usage3 = (const char *) "\
-macroerrors - Report errors inside macros\n\
-makedefault - Create default constructors/destructors (the default)\n\
-M - List all dependencies\n\
@@ -120,10 +125,10 @@ static const char *usage2 = (const char *) "\
-noexcept - Do not wrap exception specifiers\n\
-nofastdispatch - Disable fast dispatch mode (default)\n\
-nopreprocess - Skip the preprocessor step\n\
+ -notemplatereduce - Disable reduction of the typedefs in templates\n\
";
-static const char *usage3 = (const char *) "\
- -notemplatereduce - Disable reduction of the typedefs in templates\n\
+static const char *usage4 = (const char *) "\
-O - Enable the optimization options: \n\
-fastdispatch -fvirtual \n\
-o <outfile> - Set name of the output file to <outfile>\n\
@@ -678,6 +683,15 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else if (strcmp(argv[i], "-nocpperraswarn") == 0) {
Preprocessor_error_as_warning(0);
Swig_mark_arg(i);
+ } else if (strcmp(argv[i], "-cppext") == 0) {
+ Swig_mark_arg(i);
+ if (argv[i + 1]) {
+ SWIG_config_cppext(argv[i + 1]);
+ Swig_mark_arg(i + 1);
+ i++;
+ } else {
+ Swig_arg_error();
+ }
} else if ((strcmp(argv[i], "-debug-typemap") == 0) || (strcmp(argv[i], "-debug_typemap") == 0) || (strcmp(argv[i], "-tm_debug") == 0)) {
tm_debug = 1;
Swig_mark_arg(i);
@@ -851,6 +865,7 @@ void SWIG_getoptions(int argc, char *argv[]) {
fputs(usage1, stdout);
fputs(usage2, stdout);
fputs(usage3, stdout);
+ fputs(usage4, stdout);
Swig_mark_arg(i);
help = 1;
}
diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx
index 2d6f26108..d9a0c922b 100644
--- a/Source/Modules/modula3.cxx
+++ b/Source/Modules/modula3.cxx
@@ -1407,25 +1407,12 @@ MODULA3():
}
}
- if (Cmp(nodeType(n), "constant") == 0) {
- // Wrapping a constant hack
- Swig_save("functionWrapper", n, "wrap:action", NIL);
-
- // below based on Swig_VargetToFunction()
- SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
- Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
- }
-
Setattr(n, "wrap:name", wname);
// Now write code to make the function call
if (!native_function_flag) {
String *actioncode = emit_action(n);
- if (Cmp(nodeType(n), "constant") == 0) {
- Swig_restore(n);
- }
-
/* Return value if necessary */
String *tm;
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx
index f3d63a6dc..ac73c1f0c 100644
--- a/Source/Modules/ocaml.cxx
+++ b/Source/Modules/ocaml.cxx
@@ -19,7 +19,7 @@ static const char *usage = "\
Ocaml Options (available with -ocaml)\n\
-oldvarnames - Old intermediary method names for variable wrappers\n\
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
- -suffix <name> - Change .cxx to something else\n\
+ -suffix <name> - Deprecated alias for general option -cppext\n\
-where - Emit library location\n\
\n";
@@ -114,6 +114,7 @@ public:
}
} else if (strcmp(argv[i], "-suffix") == 0) {
if (argv[i + 1]) {
+ Printf(stderr, "swig: warning: -suffix option deprecated. SWIG 3.0.4 and later provide a -cppext option which should be used instead.\n");
SWIG_config_cppext(argv[i + 1]);
Swig_mark_arg(i);
Swig_mark_arg(i + 1);
diff --git a/Source/Modules/octave.cxx b/Source/Modules/octave.cxx
index 12903166c..236598c1f 100644
--- a/Source/Modules/octave.cxx
+++ b/Source/Modules/octave.cxx
@@ -19,8 +19,10 @@ static String *op_prefix = 0;
static const char *usage = "\
Octave Options (available with -octave)\n\
+ -cppcast - Enable C++ casting operators (default)\n\
-globals <name> - Set <name> used to access C global variables [default: 'cvar']\n\
Use '.' to load C global variables into module namespace\n\
+ -nocppcast - Disable C++ casting operators\n\
-opprefix <str> - Prefix <str> for global operator functions [default: 'op_']\n\
\n";
@@ -90,6 +92,8 @@ public:
}
virtual void main(int argc, char *argv[]) {
+ int cppcast = 1;
+
for (int i = 1; i < argc; i++) {
if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) {
@@ -112,6 +116,12 @@ public:
} else {
Swig_arg_error();
}
+ } else if (strcmp(argv[i], "-cppcast") == 0) {
+ cppcast = 1;
+ Swig_mark_arg(i);
+ } else if (strcmp(argv[i], "-nocppcast") == 0) {
+ cppcast = 0;
+ Swig_mark_arg(i);
}
}
}
@@ -120,6 +130,8 @@ public:
global_name = NewString("cvar");
if (!op_prefix)
op_prefix = NewString("op_");
+ if(cppcast)
+ Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0);
SWIG_library_directory("octave");
Preprocessor_define("SWIGOCTAVE 1", 0);
@@ -952,7 +964,26 @@ public:
SwigType *t = Copy(Getattr(n, "name"));
SwigType_add_pointer(t);
+ String *smartptr = Getattr(n, "feature:smartptr"); // Replace storing a pointer to underlying class with a smart pointer (intended for use with non-intrusive smart pointers)
+ SwigType *smart = 0;
+ if (smartptr) {
+ SwigType *cpt = Swig_cparse_type(smartptr);
+ if (cpt) {
+ smart = SwigType_typedef_resolve_all(cpt);
+ Delete(cpt);
+ } else {
+ // TODO: report line number of where the feature comes from
+ Swig_error(Getfile(n), Getline(n), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, class_name);
+ }
+ }
String *wrap_class = NewStringf("&_wrap_class_%s", class_name);
+ if(smart){
+ SwigType_add_pointer(smart);
+ SwigType_remember_clientdata(smart, wrap_class);
+ }
+ Delete(smart);
+ Delete(smartptr);
+ //String *wrap_class = NewStringf("&_wrap_class_%s", class_name);
SwigType_remember_clientdata(t, wrap_class);
int use_director = Swig_directorclass(n);
diff --git a/Source/Modules/perl5.cxx b/Source/Modules/perl5.cxx
index 224c4852e..e1b0e69c6 100644
--- a/Source/Modules/perl5.cxx
+++ b/Source/Modules/perl5.cxx
@@ -1996,8 +1996,8 @@ public:
Printf(f_directors_h, " return (iv != swig_inner.end() ? iv->second : false);\n");
Printf(f_directors_h, " }\n");
- Printf(f_directors_h, " void swig_set_inner(const char *swig_protected_method_name, bool val) const {\n");
- Printf(f_directors_h, " swig_inner[swig_protected_method_name] = val;\n");
+ Printf(f_directors_h, " void swig_set_inner(const char *swig_protected_method_name, bool swig_val) const {\n");
+ Printf(f_directors_h, " swig_inner[swig_protected_method_name] = swig_val;\n");
Printf(f_directors_h, " }\n");
Printf(f_directors_h, "private:\n");
Printf(f_directors_h, " mutable std::map<std::string, bool> swig_inner;\n");
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index b09dd09aa..e6105eb3e 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -44,7 +44,6 @@
static const char *usage = "\
PHP Options (available with -php)\n\
- -cppext <ext> - Change C++ file extension to <ext> (default is cpp)\n\
-noproxy - Don't generate proxy classes.\n\
-prefix <prefix> - Prepend <prefix> to all class names in PHP wrappers\n\
\n";
@@ -221,15 +220,6 @@ public:
} else {
Swig_arg_error();
}
- } else if (strcmp(argv[i], "-cppext") == 0) {
- if (argv[i + 1]) {
- SWIG_config_cppext(argv[i + 1]);
- Swig_mark_arg(i);
- Swig_mark_arg(i + 1);
- i++;
- } else {
- Swig_arg_error();
- }
} else if ((strcmp(argv[i], "-noshadow") == 0) || (strcmp(argv[i], "-noproxy") == 0)) {
shadow = 0;
Swig_mark_arg(i);
@@ -836,13 +826,6 @@ public:
Delete(args);
args = NULL;
}
- if (is_member_director(n)) {
- Wrapper_add_local(f, "director", "Swig::Director *director = 0");
- Printf(f->code, "director = dynamic_cast<Swig::Director*>(arg1);\n");
- Wrapper_add_local(f, "upcall", "bool upcall = false");
- Printf(f->code, "upcall = !director->swig_is_overridden_method((char *)\"%s%s\", (char *)\"%s\");\n",
- prefix, Swig_class_name(Swig_methodclass(n)), name);
- }
// This generated code may be called:
// 1) as an object method, or
@@ -931,6 +914,12 @@ public:
Delete(source);
}
+ if (is_member_director(n)) {
+ Wrapper_add_local(f, "upcall", "bool upcall = false");
+ Printf(f->code, "upcall = !Swig::Director::swig_is_overridden_method((char *)\"%s%s\", (char *)\"%s\" TSRMLS_CC);\n",
+ prefix, Swig_class_name(Swig_methodclass(n)), name);
+ }
+
Swig_director_emit_dynamic_cast(n, f);
/* Insert constraint checking code */
@@ -1278,7 +1267,7 @@ public:
break;
char *p;
errno = 0;
- int n = strtol(Char(value), &p, 0);
+ long n = strtol(Char(value), &p, 0);
Clear(value);
if (errno || *p) {
Append(value, "?");
@@ -1293,10 +1282,11 @@ public:
case T_SCHAR:
case T_SHORT:
case T_INT:
- case T_LONG: {
+ case T_LONG:
+ case T_LONGLONG: {
char *p;
errno = 0;
- unsigned int n = strtol(Char(value), &p, 0);
+ long n = strtol(Char(value), &p, 0);
(void) n;
if (errno || *p) {
Clear(value);
@@ -1307,7 +1297,8 @@ public:
case T_UCHAR:
case T_USHORT:
case T_UINT:
- case T_ULONG: {
+ case T_ULONG:
+ case T_ULONGLONG: {
char *p;
errno = 0;
unsigned int n = strtoul(Char(value), &p, 0);
@@ -1319,7 +1310,8 @@ public:
break;
}
case T_FLOAT:
- case T_DOUBLE:{
+ case T_DOUBLE:
+ case T_LONGDOUBLE: {
char *p;
errno = 0;
/* FIXME: strtod is locale dependent... */
@@ -1338,13 +1330,6 @@ public:
}
break;
}
- case T_REFERENCE:
- case T_RVALUE_REFERENCE:
- case T_USER:
- case T_ARRAY:
- Clear(value);
- Append(value, "?");
- break;
case T_STRING:
if (Len(value) < 2) {
// How can a string (including "" be less than 2 characters?)
@@ -1393,6 +1378,11 @@ public:
}
break;
}
+ default:
+ /* Safe default */
+ Clear(value);
+ Append(value, "?");
+ break;
}
if (!arg_values[argno]) {
@@ -1741,7 +1731,8 @@ public:
}
} else {
Printf(output, "\t\tif (!is_resource($r)) return $r;\n");
- Printf(output, "\t\tswitch (get_resource_type($r)) {\n");
+ String *wrapobj = NULL;
+ String *common = NULL;
Iterator i = First(ret_types);
while (i.item) {
SwigType *ret_type = i.item;
@@ -1761,22 +1752,43 @@ public:
continue;
}
}
- Printf(output, "\t\t");
- if (i.item) {
- Printf(output, "case '%s': ", mangled);
- } else {
- Printf(output, "default: ");
- }
const char *classname = GetChar(class_node, "sym:name");
if (!classname)
classname = GetChar(class_node, "name");
+ String * action = NewStringEmpty();
if (classname)
- Printf(output, "return new %s%s($r);\n", prefix, classname);
+ Printf(action, "return new %s%s($r);\n", prefix, classname);
else
- Printf(output, "return $r;\n");
+ Printf(action, "return $r;\n");
+ if (!wrapobj) {
+ wrapobj = NewString("\t\tswitch (get_resource_type($r)) {\n");
+ common = action;
+ } else {
+ if (common && Cmp(common, action) != 0) {
+ Delete(common);
+ common = NULL;
+ }
+ }
+ Printf(wrapobj, "\t\t");
+ if (i.item) {
+ Printf(wrapobj, "case '%s': ", mangled);
+ } else {
+ Printf(wrapobj, "default: ");
+ }
+ Printv(wrapobj, action, NIL);
+ if (action != common) Delete(action);
Delete(mangled);
}
- Printf(output, "\t\t}\n");
+ Printf(wrapobj, "\t\t}\n");
+ if (common) {
+ // All cases have the same action, so eliminate the switch
+ // wrapper.
+ Printf(output, "\t\t%s", common);
+ Delete(common);
+ } else {
+ Printv(output, wrapobj, NIL);
+ }
+ Delete(wrapobj);
}
} else {
if (non_void_return) {
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index cd0ec2b44..3244d9ea6 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -17,6 +17,8 @@
static int treduce = SWIG_cparse_template_reduce(0);
#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
#include <sstream>
#include "../DoxygenTranslator/src/PyDocConverter.h"
@@ -898,7 +900,17 @@ public:
#else
tab4, "if (not static):\n",
#endif
- tab4, tab4, "object.__setattr__(self, name, value)\n",
+ NIL);
+ if (!classic) {
+ if (!modern)
+ Printv(f_shadow, tab4, tab4, "if _newclass:\n", tab4, NIL);
+ Printv(f_shadow, tab4, tab4, "object.__setattr__(self, name, value)\n", NIL);
+ if (!modern)
+ Printv(f_shadow, tab4, tab4, "else:\n", tab4, NIL);
+ }
+ if (classic || !modern)
+ Printv(f_shadow, tab4, tab4, "self.__dict__[name] = value\n", NIL);
+ Printv(f_shadow,
tab4, "else:\n",
tab4, tab4, "raise AttributeError(\"You cannot add attributes to %s\" % self)\n\n",
"\n", "def _swig_setattr(self, class_type, name, value):\n", tab4, "return _swig_setattr_nondynamic(self, class_type, name, value, 0)\n\n", NIL);
@@ -1879,19 +1891,132 @@ public:
}
/* ------------------------------------------------------------
+ * convertDoubleValue()
+ * Check if the given string looks like a decimal floating point constant
+ * and return it if it does, otherwise return NIL.
+ * ------------------------------------------------------------ */
+ String *convertDoubleValue(String *v) {
+ const char *const s = Char(v);
+ char *end;
+
+ double value = strtod(s, &end);
+ (void) value;
+ if (errno != ERANGE && end != s) {
+ // An added complication: at least some versions of strtod() recognize
+ // hexadecimal floating point numbers which don't exist in Python, so
+ // detect them ourselves and refuse to convert them (this can't be done
+ // without loss of precision in general).
+ //
+ // Also don't accept neither "NAN" nor "INFINITY" (both of which
+ // conveniently contain "n").
+ if (strpbrk(s, "xXnN"))
+ return NIL;
+
+ // Disregard optional "f" suffix, it can be just dropped in Python as it
+ // uses doubles for everything anyhow.
+ for (char* p = end; *p != '\0'; ++p) {
+ switch (*p) {
+ case 'f':
+ case 'F':
+ break;
+
+ default:
+ return NIL;
+ }
+ }
+
+ // Avoid unnecessary string allocation in the common case when we don't
+ // need to remove any suffix.
+ return *end == '\0' ? v : NewStringWithSize(s, end - s);
+ }
+
+ return NIL;
+ }
+
+ /* ------------------------------------------------------------
* convertValue()
* Check if string v can be a Python value literal or a
* constant. Return NIL if it isn't.
* ------------------------------------------------------------ */
String *convertValue(String *v, SwigType *t) {
- char fc = (Char(v))[0];
- if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) {
- /* number or string (or maybe NULL pointer) */
- if (SwigType_ispointer(t) && Strcmp(v, "0") == 0)
- return NewString("None");
- else
- return v;
+ const char *const s = Char(v);
+ char *end;
+
+ // Check if this is a number in any base.
+ long value = strtol(s, &end, 0);
+ (void) value;
+ if (end != s) {
+ if (errno == ERANGE) {
+ // There was an overflow, we could try representing the value as Python
+ // long integer literal, but for now don't bother with it.
+ return NIL;
+ }
+
+ if (*end != '\0') {
+ // If there is a suffix after the number, we can safely ignore any
+ // combination of "l" and "u", but not anything else (again, stuff like
+ // "LL" could be handled, but we don't bother to do it currently).
+ bool seen_long = false;
+ for (char* p = end; *p != '\0'; ++p) {
+ switch (*p) {
+ case 'l':
+ case 'L':
+ // Bail out on "LL".
+ if (seen_long)
+ return NIL;
+ seen_long = true;
+ break;
+
+ case 'u':
+ case 'U':
+ break;
+
+ default:
+ // Except that our suffix could actually be the fractional part of
+ // a floating point number, so we still have to check for this.
+ return convertDoubleValue(v);
+ }
+ }
+ }
+
+ // Deal with the values starting with 0 first as they can be octal or
+ // hexadecimal numbers or even pointers.
+ if (s[0] == '0') {
+ if (Len(v) == 1) {
+ // This is just a lone 0, but it needs to be represented differently
+ // in Python depending on whether it's a zero or a null pointer.
+ if (SwigType_ispointer(t))
+ return NewString("None");
+ else
+ return v;
+ } else if (s[1] == 'x' || s[1] == 'X') {
+ // This must have been a hex number, we can use it directly in Python,
+ // so nothing to do here.
+ } else {
+ // This must have been an octal number, we have to change its prefix
+ // to be "0o" in Python 3 only (and as long as we still support Python
+ // 2.5, this can't be done unconditionally).
+ if (py3) {
+ if (end - s > 1) {
+ String *res = NewString("0o");
+ Append(res, NewStringWithSize(s + 1, end - s - 1));
+ return res;
+ }
+ }
+ }
+ }
+
+ // Avoid unnecessary string allocation in the common case when we don't
+ // need to remove any suffix.
+ return *end == '\0' ? v : NewStringWithSize(s, end - s);
}
+
+ // Check if this is a floating point number (notice that it wasn't
+ // necessarily parsed as a long above, consider e.g. ".123").
+ if (String *res = convertDoubleValue(v)) {
+ return res;
+ }
+
if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
return NewString("True");
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
@@ -1899,12 +2024,15 @@ public:
if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0)
return SwigType_ispointer(t) ? NewString("None") : NewString("0");
- // This could also be an enum type, default value of which is perfectly
- // representable in Python.
- Node *lookup = Swig_symbol_clookup(v, 0);
- if (lookup) {
- if (Cmp(Getattr(lookup, "nodeType"), "enumitem") == 0)
- return Getattr(lookup, "sym:name");
+ // This could also be an enum type, default value of which could be
+ // representable in Python if it doesn't include any scope (which could,
+ // but currently is not, translated).
+ if (!Strchr(s, ':')) {
+ Node *lookup = Swig_symbol_clookup(v, 0);
+ if (lookup) {
+ if (Cmp(Getattr(lookup, "nodeType"), "enumitem") == 0)
+ return Getattr(lookup, "sym:name");
+ }
}
return NIL;
@@ -1920,27 +2048,34 @@ public:
* at C++ code level where they can always be handled.
* ------------------------------------------------------------ */
bool is_representable_as_pyargs(Node *n) {
+ bool is_representable = true;
+
ParmList *plist = CopyParmList(Getattr(n, "parms"));
Parm *p;
Parm *pnext;
for (p = plist; p; p = pnext) {
+ pnext = NIL;
String *tm = Getattr(p, "tmap:in");
if (tm) {
pnext = Getattr(p, "tmap:in:next");
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
continue;
}
- } else {
+ }
+ if (!pnext) {
pnext = nextSibling(p);
}
if (String *value = Getattr(p, "value")) {
String *type = Getattr(p, "type");
- if (!convertValue(value, type))
- return false;
+ if (!convertValue(value, type)) {
+ is_representable = false;
+ break;
+ }
}
}
- return true;
+
+ return is_representable;
}
@@ -3233,7 +3368,33 @@ public:
Replaceall(tm, "$source", value);
Replaceall(tm, "$target", name);
Replaceall(tm, "$value", value);
- Printf(f_init, "%s\n", tm);
+ if (!builtin && (shadow) && (!(shadow & PYSHADOW_MEMBER)) && (!in_class || !Getattr(n, "feature:python:callback"))) {
+ // Generate method which registers the new constant
+ Printf(f_wrappers, "SWIGINTERN PyObject *%s_swigconstant(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {\n", iname);
+ Printf(f_wrappers, tab2 "PyObject *module;\n", tm);
+ Printf(f_wrappers, tab2 "PyObject *d;\n");
+ if (modernargs) {
+ if (fastunpack) {
+ Printf(f_wrappers, tab2 "if (!SWIG_Python_UnpackTuple(args,(char*)\"swigconstant\", 1, 1,&module)) return NULL;\n");
+ } else {
+ Printf(f_wrappers, tab2 "if (!PyArg_UnpackTuple(args,(char*)\"swigconstant\", 1, 1,&module)) return NULL;\n");
+ }
+ } else {
+ Printf(f_wrappers, tab2 "if (!PyArg_ParseTuple(args,(char*)\"O:swigconstant\", &module)) return NULL;\n");
+ }
+ Printf(f_wrappers, tab2 "d = PyModule_GetDict(module);\n");
+ Printf(f_wrappers, tab2 "if (!d) return NULL;\n");
+ Printf(f_wrappers, tab2 "%s\n", tm);
+ Printf(f_wrappers, tab2 "return SWIG_Py_Void();\n");
+ Printf(f_wrappers, "}\n\n\n");
+
+ // Register the method in SwigMethods array
+ String *cname = NewStringf("%s_swigconstant", iname);
+ add_method(cname, cname, 0);
+ Delete(cname);
+ } else {
+ Printf(f_init, "%s\n", tm);
+ }
Delete(tm);
have_tm = 1;
}
@@ -3255,6 +3416,8 @@ public:
}
if (f_s) {
+ Printv(f_s, "\n",NIL);
+ Printv(f_s, module, ".", iname, "_swigconstant(",module,")\n", NIL);
Printv(f_s, iname, " = ", module, ".", iname, "\n", NIL);
if (have_docstring(n))
Printv(f_s, docstring(n, AUTODOC_CONST), "\n", NIL);
@@ -3421,8 +3584,8 @@ public:
Printf(f_directors_h, " return (iv != swig_inner.end() ? iv->second : false);\n");
Printf(f_directors_h, " }\n");
- Printf(f_directors_h, " void swig_set_inner(const char *swig_protected_method_name, bool val) const {\n");
- Printf(f_directors_h, " swig_inner[swig_protected_method_name] = val;\n");
+ Printf(f_directors_h, " void swig_set_inner(const char *swig_protected_method_name, bool swig_val) const {\n");
+ Printf(f_directors_h, " swig_inner[swig_protected_method_name] = swig_val;\n");
Printf(f_directors_h, " }\n");
Printf(f_directors_h, "private:\n");
Printf(f_directors_h, " mutable std::map<std::string, bool> swig_inner;\n");
diff --git a/Source/Modules/scilab.cxx b/Source/Modules/scilab.cxx
new file mode 100644
index 000000000..6d9930431
--- /dev/null
+++ b/Source/Modules/scilab.cxx
@@ -0,0 +1,1122 @@
+/* ----------------------------------------------------------------------------
+ * This file is part of SWIG, which is licensed as a whole under version 3
+ * (or any later version) of the GNU General Public License. Some additional
+ * terms also apply to certain portions of SWIG. The full details of the SWIG
+ * license and copyrights can be found in the LICENSE and COPYRIGHT files
+ * included with the SWIG source code as distributed by the SWIG developers
+ * and at http://www.swig.org/legal.html.
+ *
+ * scilab.cxx
+ *
+ * Scilab language module for SWIG.
+ * --------------------------------------------------------------------------*/
+
+#include "swigmod.h"
+
+static const int SCILAB_IDENTIFIER_NAME_CHAR_MAX = 24;
+static const int SCILAB_VARIABLE_NAME_CHAR_MAX = SCILAB_IDENTIFIER_NAME_CHAR_MAX - 4;
+
+static const char *usage = (char *) " \
+Scilab options (available with -scilab)\n \
+ -builder - Generate a Scilab builder script\n \
+ -buildercflags <cflags> - Add <cflags> to the builder compiler flags\n \
+ -builderflagscript <file> - Set the Scilab script <file> to use by builder to configure the build flags\n \
+ -builderldflags <ldflags> - Add <ldflags> to the builder linker flags\n \
+ -buildersources <files> - Add the (comma separated) files <files> to the builder sources\n \
+ -builderverbositylevel <level> - Set the builder verbosity level to <level> (default 0: off, 2: high)\n \
+ -gatewayxml <gateway_id> - Generate gateway xml with the given <gateway_id>\n \
+\n";
+
+
+class SCILAB:public Language {
+protected:
+ /* General objects used for holding the strings */
+ File *beginSection;
+ File *runtimeSection;
+ File *headerSection;
+ File *wrappersSection;
+ File *initSection;
+
+ String *variablesCode;
+
+ bool generateBuilder;
+ File *builderFile;
+ String *builderCode;
+ int builderFunctionCount;
+
+ List *sourceFileList;
+ List *cflags;
+ List *ldflags;
+
+ String *verboseBuildLevel;
+ String *buildFlagsScript;
+
+ String *gatewayHeader;
+ String *gatewayHeaderV5;
+ String *gatewayHeaderV6;
+
+ bool createGatewayXML;
+ File *gatewayXMLFile;
+ String *gatewayXML;
+ String *gatewayID;
+ int primitiveID;
+
+ bool createLoader;
+ File *loaderFile;
+ String *loaderScript;
+public:
+
+ /* ------------------------------------------------------------------------
+ * main()
+ * ----------------------------------------------------------------------*/
+
+ virtual void main(int argc, char *argv[]) {
+
+ generateBuilder = false;
+ sourceFileList = NewList();
+ cflags = NewList();
+ ldflags = NewList();
+ verboseBuildLevel = NULL;
+ buildFlagsScript = NULL;
+
+ gatewayHeader = NULL;
+ gatewayHeaderV5 = NULL;
+ gatewayHeaderV6 = NULL;
+
+ createGatewayXML = false;
+ gatewayXML = NULL;
+ gatewayXMLFile = NULL;
+ gatewayID = NULL;
+
+ createLoader = true;
+ loaderFile = NULL;
+ loaderScript = NULL;
+
+ /* Manage command line arguments */
+ for (int argIndex = 1; argIndex < argc; argIndex++) {
+ if (argv[argIndex] != NULL) {
+ if (strcmp(argv[argIndex], "-help") == 0) {
+ Printf(stdout, "%s\n", usage);
+ } else if (strcmp(argv[argIndex], "-builder") == 0) {
+ Swig_mark_arg(argIndex);
+ generateBuilder = true;
+ createLoader = false;
+ } else if (strcmp(argv[argIndex], "-buildersources") == 0) {
+ if (argv[argIndex + 1] != NULL) {
+ Swig_mark_arg(argIndex);
+ char *sourceFile = strtok(argv[argIndex + 1], ",");
+ while (sourceFile != NULL) {
+ Insert(sourceFileList, Len(sourceFileList), sourceFile);
+ sourceFile = strtok(NULL, ",");
+ }
+ Swig_mark_arg(argIndex + 1);
+ }
+ } else if (strcmp(argv[argIndex], "-buildercflags") == 0) {
+ Swig_mark_arg(argIndex);
+ if (argv[argIndex + 1] != NULL) {
+ Insert(cflags, Len(cflags), argv[argIndex + 1]);
+ Swig_mark_arg(argIndex + 1);
+ }
+ } else if (strcmp(argv[argIndex], "-builderldflags") == 0) {
+ Swig_mark_arg(argIndex);
+ if (argv[argIndex + 1] != NULL) {
+ Insert(ldflags, Len(ldflags), argv[argIndex + 1]);
+ Swig_mark_arg(argIndex + 1);
+ }
+ } else if (strcmp(argv[argIndex], "-builderverbositylevel") == 0) {
+ Swig_mark_arg(argIndex);
+ verboseBuildLevel = NewString(argv[argIndex + 1]);
+ Swig_mark_arg(argIndex + 1);
+ } else if (strcmp(argv[argIndex], "-builderflagscript") == 0) {
+ Swig_mark_arg(argIndex);
+ buildFlagsScript = NewString(argv[argIndex + 1]);
+ Swig_mark_arg(argIndex + 1);
+ } else if (strcmp(argv[argIndex], "-gatewayxml") == 0) {
+ Swig_mark_arg(argIndex);
+ createGatewayXML = true;
+ gatewayID = 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");
+
+ /* Add a symbol to the parser for conditional compilation */
+ Preprocessor_define("SWIGSCILAB 1", 0);
+
+ /* Set scilab configuration file */
+ SWIG_config_file("scilab.swg");
+
+ /* Set typemap for scilab */
+ SWIG_typemap_lang("scilab");
+
+ allow_overloading();
+ }
+
+ /* ------------------------------------------------------------------------
+ * top()
+ * ----------------------------------------------------------------------*/
+
+ virtual int top(Node *node) {
+
+ /* Get the module name */
+ String *gatewayName = Getattr(node, "name");
+
+ // Set library name
+ String *gatewayLibraryName = NewStringf("lib%s", gatewayName);
+
+ /* Get the output file name */
+ String *outputFilename = Getattr(node, "outfile");
+
+ /* Initialize I/O */
+ beginSection = NewFile(outputFilename, "w", SWIG_output_files());
+ if (!beginSection) {
+ FileErrorDisplay(outputFilename);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ runtimeSection = NewString("");
+ initSection = NewString("");
+ headerSection = NewString("");
+ wrappersSection = NewString("");
+
+ /* Register file targets with the SWIG file handler */
+ Swig_register_filebyname("begin", beginSection);
+ Swig_register_filebyname("header", headerSection);
+ Swig_register_filebyname("wrapper", wrappersSection);
+ Swig_register_filebyname("runtime", runtimeSection);
+ Swig_register_filebyname("init", initSection);
+
+ /* Output module initialization code */
+ Swig_banner(beginSection);
+
+ Printf(runtimeSection, "\n#define SWIGSCILAB\n");
+ Printf(runtimeSection, "\n");
+
+ // Gateway header source merged with wrapper source in nobuilder mode
+ if (!generateBuilder)
+ startGatewayHeader(gatewayLibraryName);
+
+ // Create builder file if required
+ if (generateBuilder) {
+ createBuilderFile(outputFilename);
+ }
+
+ // Create gateway XML if required
+ if (createGatewayXML) {
+ createGatewayXMLFile(gatewayName);
+ }
+
+ // Create loader script if required
+ if (createLoader) {
+ createLoaderFile(gatewayLibraryName);
+ }
+
+ // Module initialization function
+ String *gatewayInitFunctionName = NewStringf("%s_Init", gatewayName);
+
+ /* Add initialization function to builder table */
+ addFunctionToScilab(gatewayInitFunctionName, gatewayInitFunctionName);
+
+ // Add helper functions to builder table
+ addHelperFunctions();
+
+ // Open Scilab wrapper variables creation function
+ variablesCode = NewString("");
+ Printf(variablesCode, "int SWIG_CreateScilabVariables(void *_pvApiCtx) {");
+
+ /* Emit code for children */
+ if (CPlusPlus) {
+ Printf(wrappersSection, "extern \"C\" {\n");
+ }
+
+ Language::top(node);
+
+ if (CPlusPlus) {
+ Printf(wrappersSection, "}\n");
+ }
+ // Close Scilab wrapper variables creation function
+ Printf(variablesCode, " return SWIG_OK;\n}\n");
+
+ // Add Builder footer code and save
+ if (generateBuilder) {
+ saveBuilderFile(gatewayName);
+ }
+
+ /* Close the init function and rename with module name */
+ Printf(initSection, "return 0;\n}\n");
+ Replaceall(initSection, "<module>", gatewayName);
+
+ /* Write all to the wrapper file */
+ SwigType_emit_type_table(runtimeSection, wrappersSection); // Declare pointer types, ... (Ex: SWIGTYPE_p_p_double)
+
+ // Gateway header source merged with wrapper source in nobuilder mode
+ if (!generateBuilder) {
+ terminateGatewayHeader(gatewayLibraryName);
+ Printv(initSection, gatewayHeader, NIL);
+ }
+
+ Dump(runtimeSection, beginSection);
+ Dump(headerSection, beginSection);
+ Dump(wrappersSection, beginSection);
+ Dump(variablesCode, beginSection);
+ Wrapper_pretty_print(initSection, beginSection);
+
+ if (createGatewayXML) {
+ saveGatewayXMLFile();
+ }
+
+ if (createLoader) {
+ saveLoaderFile(gatewayLibraryName);
+ }
+
+ /* Cleanup files */
+ Delete(runtimeSection);
+ Delete(headerSection);
+ Delete(wrappersSection);
+ Delete(initSection);
+ Delete(beginSection);
+
+ Delete(sourceFileList);
+ Delete(cflags);
+ Delete(ldflags);
+
+ return SWIG_OK;
+ }
+
+ /* ------------------------------------------------------------------------
+ * emitBanner()
+ * ----------------------------------------------------------------------*/
+
+ void emitBanner(File *f) {
+ Printf(f, "// ----------------------------------------------------------------------------\n");
+ Swig_banner_target_lang(f, "// ");
+ Printf(f, "// ----------------------------------------------------------------------------- */\n\n");
+ }
+
+ /* ------------------------------------------------------------------------
+ * functionWrapper()
+ * ----------------------------------------------------------------------*/
+
+ virtual int functionWrapper(Node *node) {
+
+ /* Get some useful attributes of this function */
+ String *functionName = Getattr(node, "sym:name");
+ SwigType *functionReturnType = Getattr(node, "type");
+ ParmList *functionParamsList = Getattr(node, "parms");
+
+ int paramIndex = 0; // Used for loops over ParmsList
+ Parm *param = NULL; // Used for loops over ParamsList
+
+ /* Create the wrapper object */
+ Wrapper *wrapper = NewWrapper();
+
+ /* Create the function wrapper name */
+ String *wrapperName = Swig_name_wrapper(functionName);
+
+ /* Deal with overloading */
+ String *overloadedName = Copy(wrapperName);
+ /* Determine whether the function is overloaded or not */
+ bool isOverloaded = ! !Getattr(node, "sym:overloaded");
+ /* Determine whether the function is the last overloaded */
+ bool isLastOverloaded = isOverloaded && !Getattr(node, "sym:nextSibling");
+
+ if (!isOverloaded && !addSymbol(functionName, node)) {
+ return SWIG_ERROR;
+ }
+
+ if (isOverloaded) {
+ Append(overloadedName, Getattr(node, "sym:overname"));
+ }
+
+ /* Write the wrapper function definition (standard Scilab gateway function prototype) */
+ Printv(wrapper->def, "int ", overloadedName, "(SWIG_GatewayParameters) {", NIL);
+
+ /* Emit all of the local variables for holding arguments */
+ // E.g.: double arg1;
+ emit_parameter_variables(functionParamsList, wrapper);
+
+ /* Attach typemaps to the parameter list */
+ // Add local variables used in typemaps (iRows, iCols, ...)
+ emit_attach_parmmaps(functionParamsList, wrapper);
+ Setattr(node, "wrap:parms", functionParamsList);
+
+ /* Check arguments */
+ int maxInputArguments = emit_num_arguments(functionParamsList);
+ int minInputArguments = emit_num_required(functionParamsList);
+ int minOutputArguments = 0;
+ int maxOutputArguments = 0;
+
+ /* Insert calls to CheckInputArgument and CheckOutputArgument */
+ Printf(wrapper->code, "SWIG_CheckInputArgument(pvApiCtx, $mininputarguments, $maxinputarguments);\n");
+ Printf(wrapper->code, "SWIG_CheckOutputArgument(pvApiCtx, $minoutputarguments, $maxoutputarguments);\n");
+
+ /* Set context */
+ Printf(wrapper->code, "SWIG_Scilab_SetFuncName(fname);\n");
+ Printf(wrapper->code, "SWIG_Scilab_SetApiContext(pvApiCtx);\n");
+
+ /* Write typemaps(in) */
+
+ for (paramIndex = 0, param = functionParamsList; paramIndex < maxInputArguments; ++paramIndex) {
+ // Ignore parameter if the typemap specifies numinputs=0
+ while (checkAttribute(param, "tmap:in:numinputs", "0")) {
+ param = Getattr(param, "tmap:in:next");
+ }
+
+ SwigType *paramType = Getattr(param, "type");
+ String *paramTypemap = Getattr(param, "tmap:in");
+
+ if (paramTypemap) {
+ // Replace $input by the position on Scilab stack
+ String *source = NewString("");
+ Printf(source, "%d", paramIndex + 1);
+ Setattr(param, "emit:input", source);
+ Replaceall(paramTypemap, "$input", Getattr(param, "emit:input"));
+
+ if (Getattr(param, "wrap:disown") || (Getattr(param, "tmap:in:disown"))) {
+ Replaceall(paramTypemap, "$disown", "SWIG_POINTER_DISOWN");
+ } else {
+ Replaceall(paramTypemap, "$disown", "0");
+ }
+
+ if (paramIndex >= minInputArguments) { /* Optional input argument management */
+ Printf(wrapper->code, "if (SWIG_NbInputArgument(pvApiCtx) > %d) {\n%s\n}\n", paramIndex, paramTypemap);
+ } else {
+ Printf(wrapper->code, "%s\n", paramTypemap);
+ }
+ param = Getattr(param, "tmap:in:next");
+ } else {
+ Swig_warning(WARN_TYPEMAP_IN_UNDEF, input_file, line_number, "Unable to use type %s as a function argument.\n", SwigType_str(paramType, 0));
+ break;
+ }
+ }
+
+ /* TODO write constraints */
+
+ Setattr(node, "wrap:name", overloadedName);
+
+ /* Emit the function call */
+ Swig_director_emit_dynamic_cast(node, wrapper);
+ String *functionActionCode = emit_action(node);
+
+ /* Insert the return variable */
+ emit_return_variable(node, functionReturnType, wrapper);
+
+ /* Return the function value if necessary */
+ String *functionReturnTypemap = Swig_typemap_lookup_out("out", node, "result", wrapper, functionActionCode);
+ if (functionReturnTypemap) {
+ // Result is actually the position of output value on stack
+ if (Len(functionReturnTypemap) > 0) {
+ Printf(wrapper->code, "SWIG_Scilab_SetOutputPosition(%d);\n", 1);
+ }
+ Replaceall(functionReturnTypemap, "$result", "1");
+
+ if (GetFlag(node, "feature:new")) {
+ Replaceall(functionReturnTypemap, "$owner", "1");
+ } else {
+ Replaceall(functionReturnTypemap, "$owner", "0");
+ }
+
+ Printf(wrapper->code, "%s\n", functionReturnTypemap);
+
+ /* If the typemap is not empty, the function return one more argument than the typemaps gives */
+ if (Len(functionReturnTypemap) > 0) {
+ minOutputArguments++;
+ maxOutputArguments++;
+ }
+ Delete(functionReturnTypemap);
+
+ } else {
+ Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(functionReturnType, 0),
+ functionName);
+ }
+
+ /* Write typemaps(out) */
+ for (param = functionParamsList; param;) {
+ String *paramTypemap = Getattr(param, "tmap:argout");
+ if (paramTypemap) {
+ minOutputArguments++;
+ maxOutputArguments++;
+ Printf(wrapper->code, "SWIG_Scilab_SetOutputPosition(%d);\n", minOutputArguments);
+ String *result = NewString("");
+ Printf(result, "%d", minOutputArguments);
+ Replaceall(paramTypemap, "$result", result);
+ Printf(wrapper->code, "%s\n", paramTypemap);
+ Delete(paramTypemap);
+ param = Getattr(param, "tmap:argout:next");
+ } else {
+ param = nextSibling(param);
+ }
+ }
+ /* Add cleanup code */
+ for (param = functionParamsList; param;) {
+ String *tm;
+ if ((tm = Getattr(param, "tmap:freearg"))) {
+ if (tm && (Len(tm) != 0)) {
+ Replaceall(tm, "$source", Getattr(param, "lname"));
+ Printf(wrapper->code, "%s\n", tm);
+ }
+ param = Getattr(param, "tmap:freearg:next");
+ } else {
+ param = nextSibling(param);
+ }
+ }
+
+
+ /* Close the function(ok) */
+ Printv(wrapper->code, "return SWIG_OK;\n", NIL);
+ Printv(wrapper->code, "}\n", NIL);
+
+ /* Add the failure cleanup code */
+ /* TODO */
+
+ /* Final substititions if applicable */
+ Replaceall(wrapper->code, "$symname", functionName);
+
+ /* Set CheckInputArgument and CheckOutputArgument input arguments */
+ /* In Scilab there is always one output even if not defined */
+ if (minOutputArguments == 0) {
+ maxOutputArguments = 1;
+ }
+ String *argnumber = NewString("");
+ Printf(argnumber, "%d", minInputArguments);
+ Replaceall(wrapper->code, "$mininputarguments", argnumber);
+
+ argnumber = NewString("");
+ Printf(argnumber, "%d", maxInputArguments);
+ Replaceall(wrapper->code, "$maxinputarguments", argnumber);
+
+ argnumber = NewString("");
+ Printf(argnumber, "%d", minOutputArguments);
+ Replaceall(wrapper->code, "$minoutputarguments", argnumber);
+
+ argnumber = NewString("");
+ Printf(argnumber, "%d", maxOutputArguments);
+ Replaceall(wrapper->code, "$maxoutputarguments", argnumber);
+
+ /* Dump the function out */
+ Wrapper_print(wrapper, wrappersSection);
+
+ String *scilabFunctionName = checkIdentifierName(functionName, SCILAB_IDENTIFIER_NAME_CHAR_MAX);
+
+ /* Update builder.sce contents */
+ if (isLastOverloaded) {
+ addFunctionToScilab(scilabFunctionName, wrapperName);
+ dispatchFunction(node);
+ }
+
+ if (!isOverloaded) {
+ addFunctionToScilab(scilabFunctionName, wrapperName);
+ }
+
+ /* tidy up */
+ Delete(overloadedName);
+ Delete(wrapperName);
+ DelWrapper(wrapper);
+
+ return SWIG_OK;
+ }
+
+ /* -----------------------------------------------------------------------
+ * dispatchFunction()
+ * ----------------------------------------------------------------------- */
+
+ void dispatchFunction(Node *node) {
+ Wrapper *wrapper = NewWrapper();
+
+ String *functionName = Getattr(node, "sym:name");
+ String *wrapperName = Swig_name_wrapper(functionName);
+ int maxargs = 0;
+
+ /* Generate the dispatch function */
+ String *dispatch = Swig_overload_dispatch(node, "return %s(SWIG_GatewayArguments);", &maxargs);
+ String *tmp = NewString("");
+
+ Printv(wrapper->def, "int ", wrapperName, "(SWIG_GatewayParameters) {\n", NIL);
+
+ /* Get the number of the parameters */
+ Wrapper_add_local(wrapper, "argc", "int argc = SWIG_NbInputArgument(pvApiCtx)");
+ Printf(tmp, "int argv[%d] = {", maxargs);
+ for (int j = 0; j < maxargs; ++j) {
+ Printf(tmp, "%s%d", j ? "," : " ", j + 1);
+ }
+ Printf(tmp, "}");
+ Wrapper_add_local(wrapper, "argv", tmp);
+
+ Printf(wrapper->code, "SWIG_Scilab_SetApiContext(pvApiCtx);\n");
+
+ /* Dump the dispatch function */
+ Printv(wrapper->code, dispatch, "\n", NIL);
+ Printf(wrapper->code, "Scierror(999, _(\"No matching function for overload\"));\n");
+ Printf(wrapper->code, "return SWIG_ERROR;\n");
+ Printv(wrapper->code, "}\n", NIL);
+ Wrapper_print(wrapper, wrappersSection);
+
+ Delete(tmp);
+ DelWrapper(wrapper);
+ Delete(dispatch);
+ Delete(wrapperName);
+ }
+
+ /* -----------------------------------------------------------------------
+ * variableWrapper()
+ * ----------------------------------------------------------------------- */
+
+ virtual int variableWrapper(Node *node) {
+
+ /* Get information about variable */
+ String *origVariableName = Getattr(node, "name"); // Ex: Shape::nshapes
+ String *variableName = Getattr(node, "sym:name"); // Ex; Shape_nshapes (can be used for function names, ...)
+
+ // Variable names can have SCILAB_VARIABLE_NAME_CHAR_MAX because of suffixes "_get" or "_set" added to function
+ String *scilabVariableName = checkIdentifierName(variableName, SCILAB_VARIABLE_NAME_CHAR_MAX);
+
+ /* Manage GET function */
+ Wrapper *getFunctionWrapper = NewWrapper();
+ String *getFunctionName = Swig_name_get(NSPACE_TODO, variableName);
+ String *scilabGetFunctionName = Swig_name_get(NSPACE_TODO, scilabVariableName);
+
+ Setattr(node, "wrap:name", getFunctionName);
+ Printv(getFunctionWrapper->def, "int ", getFunctionName, "(SWIG_GatewayParameters) {\n", NIL);
+
+ /* Check the number of input and output */
+ Printf(getFunctionWrapper->def, "SWIG_CheckInputArgument(pvApiCtx, 0, 0);\n");
+ Printf(getFunctionWrapper->def, "SWIG_CheckOutputArgument(pvApiCtx, 1, 1);\n");
+ Printf(getFunctionWrapper->def, "SWIG_Scilab_SetApiContext(pvApiCtx);\n");
+
+ String *varoutTypemap = Swig_typemap_lookup("varout", node, origVariableName, 0);
+ if (varoutTypemap != NULL) {
+ Printf(getFunctionWrapper->code, "SWIG_Scilab_SetOutputPosition(%d);\n", 1);
+ Replaceall(varoutTypemap, "$value", origVariableName);
+ Replaceall(varoutTypemap, "$result", "1");
+ emit_action_code(node, getFunctionWrapper->code, varoutTypemap);
+ Delete(varoutTypemap);
+ }
+ Append(getFunctionWrapper->code, "return SWIG_OK;\n");
+ Append(getFunctionWrapper->code, "}\n");
+ Wrapper_print(getFunctionWrapper, wrappersSection);
+
+ /* Add function to builder table */
+ addFunctionToScilab(scilabGetFunctionName, getFunctionName);
+
+ /* Manage SET function */
+ if (is_assignable(node)) {
+ Wrapper *setFunctionWrapper = NewWrapper();
+ String *setFunctionName = Swig_name_set(NSPACE_TODO, variableName);
+ String *scilabSetFunctionName = Swig_name_set(NSPACE_TODO, scilabVariableName);
+
+ Setattr(node, "wrap:name", setFunctionName);
+ Printv(setFunctionWrapper->def, "int ", setFunctionName, "(SWIG_GatewayParameters) {\n", NIL);
+
+ /* Check the number of input and output */
+ Printf(setFunctionWrapper->def, "SWIG_CheckInputArgument(pvApiCtx, 1, 1);\n");
+ Printf(setFunctionWrapper->def, "SWIG_CheckOutputArgument(pvApiCtx, 1, 1);\n");
+ Printf(setFunctionWrapper->def, "SWIG_Scilab_SetApiContext(pvApiCtx);\n");
+
+ String *varinTypemap = Swig_typemap_lookup("varin", node, origVariableName, 0);
+ if (varinTypemap != NULL) {
+ Replaceall(varinTypemap, "$input", "1");
+ emit_action_code(node, setFunctionWrapper->code, varinTypemap);
+ Delete(varinTypemap);
+ }
+ Append(setFunctionWrapper->code, "return SWIG_OK;\n");
+ Append(setFunctionWrapper->code, "}\n");
+ Wrapper_print(setFunctionWrapper, wrappersSection);
+
+ /* Add function to builder table */
+ addFunctionToScilab(scilabSetFunctionName, setFunctionName);
+ }
+
+ return SWIG_OK;
+ }
+
+ /* -----------------------------------------------------------------------
+ * constantWrapper()
+ * ----------------------------------------------------------------------- */
+
+ virtual int constantWrapper(Node *node) {
+
+ /* Get the useful information from the node */
+ String *nodeName = Getattr(node, "name");
+ SwigType *type = Getattr(node, "type");
+ String *constantName = Getattr(node, "sym:name");
+ String *rawValue = Getattr(node, "rawval");
+ String *constantValue = rawValue ? rawValue : Getattr(node, "value");
+ String *constantTypemap = NULL;
+
+ // 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));
+ bool isEnum = (Cmp(nodeType(node), "enumitem") == 0);
+
+ if (isConstant || isEnum) {
+ if (isEnum) {
+ Setattr(node, "type", "double");
+ constantValue = Getattr(node, "enumvalue");
+ }
+
+ constantTypemap = Swig_typemap_lookup("scilabconstcode", node, nodeName, 0);
+ if (constantTypemap != NULL) {
+ String *scilabConstantName = checkIdentifierName(constantName, SCILAB_IDENTIFIER_NAME_CHAR_MAX);
+
+ Setattr(node, "wrap:name", constantName);
+ Replaceall(constantTypemap, "$result", scilabConstantName);
+ Replaceall(constantTypemap, "$value", constantValue);
+
+ emit_action_code(node, variablesCode, constantTypemap);
+ Delete(constantTypemap);
+ return SWIG_OK;
+ }
+ }
+ }
+
+ /* Create variables for member pointer constants, not suppported by typemaps (like Python wrapper does) */
+ if (SwigType_type(type) == T_MPOINTER) {
+ String *wname = Swig_name_wrapper(constantName);
+ String *str = SwigType_str(type, wname);
+ Printf(headerSection, "static %s = %s;\n", str, constantValue);
+ Delete(str);
+ constantValue = wname;
+ }
+ // Constant names can have SCILAB_VARIABLE_NAME_CHAR_MAX because of suffixes "_get" added to function
+ String *scilabConstantName = checkIdentifierName(constantName, SCILAB_VARIABLE_NAME_CHAR_MAX);
+
+ /* Create GET function to get the constant value */
+ Wrapper *getFunctionWrapper = NewWrapper();
+ String *getFunctionName = Swig_name_get(NSPACE_TODO, constantName);
+ String *scilabGetFunctionName = Swig_name_get(NSPACE_TODO, scilabConstantName);
+ Setattr(node, "wrap:name", getFunctionName);
+ Printv(getFunctionWrapper->def, "int ", getFunctionName, "(SWIG_GatewayParameters) {\n", NIL);
+
+ /* Check the number of input and output */
+ Printf(getFunctionWrapper->def, "SWIG_CheckInputArgument(pvApiCtx, 0, 0);\n");
+ Printf(getFunctionWrapper->def, "SWIG_CheckOutputArgument(pvApiCtx, 1, 1);\n");
+ Printf(getFunctionWrapper->def, "SWIG_Scilab_SetApiContext(pvApiCtx);\n");
+
+ constantTypemap = Swig_typemap_lookup("constcode", node, nodeName, 0);
+ if (constantTypemap != NULL) {
+ Printf(getFunctionWrapper->code, "SWIG_Scilab_SetOutputPosition(%d);\n", 1);
+ Replaceall(constantTypemap, "$value", constantValue);
+ Replaceall(constantTypemap, "$result", "1");
+ emit_action_code(node, getFunctionWrapper->code, constantTypemap);
+ Delete(constantTypemap);
+ }
+
+ /* Dump the wrapper function */
+ Append(getFunctionWrapper->code, "return SWIG_OK;\n");
+ Append(getFunctionWrapper->code, "}\n");
+ Wrapper_print(getFunctionWrapper, wrappersSection);
+
+ /* Add the function to Scilab */
+ addFunctionToScilab(scilabGetFunctionName, getFunctionName);
+
+ DelWrapper(getFunctionWrapper);
+
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------
+ * enumvalueDeclaration()
+ * --------------------------------------------------------------------- */
+
+ virtual int enumvalueDeclaration(Node *node) {
+ static int iPreviousEnumValue = 0;
+
+ if (GetFlag(node, "feature:scilab:const")) {
+ // Compute the "absolute" value of enum if needed
+ // (most of time enum values are a linked list of relative values)
+ String *enumValue = Getattr(node, "enumvalue");
+ String *enumValueEx = Getattr(node, "enumvalueex");
+
+ // First enum value ?
+ String *firstenumitem = Getattr(node, "firstenumitem");
+ if (firstenumitem) {
+ if (enumValue) {
+ // Value is in 'enumvalue'
+ iPreviousEnumValue = atoi(Char(enumValue));
+ } else if (enumValueEx) {
+ // Or value is in 'enumValueEx'
+ iPreviousEnumValue = atoi(Char(enumValueEx));
+
+ enumValue = NewString("");
+ Printf(enumValue, "%d", iPreviousEnumValue);
+ Setattr(node, "enumvalue", enumValue);
+ }
+ } else if (!enumValue && enumValueEx) {
+ // Value is not specified, set it by incrementing last value
+ enumValue = NewString("");
+ Printf(enumValue, "%d", ++iPreviousEnumValue);
+ Setattr(node, "enumvalue", enumValue);
+ }
+ // Enums in Scilab are mapped to double
+ Setattr(node, "type", "double");
+ }
+
+ return Language::enumvalueDeclaration(node);
+ }
+
+ /* ---------------------------------------------------------------------
+ * membervariableHandler()
+ * --------------------------------------------------------------------- */
+ virtual int membervariableHandler(Node *node) {
+ checkMemberIdentifierName(node, SCILAB_VARIABLE_NAME_CHAR_MAX);
+ return Language::membervariableHandler(node);
+ }
+
+ /* -----------------------------------------------------------------------
+ * checkIdentifierName()
+ * Truncates (and displays a warning) for too long identifier names
+ * (applies on functions, variables, constants...)
+ * (Scilab identifiers names are limited to 24 chars max)
+ * ----------------------------------------------------------------------- */
+
+ String *checkIdentifierName(String *name, int char_size_max) {
+ String *scilabIdentifierName;
+ if (Len(name) > char_size_max) {
+ scilabIdentifierName = DohNewStringWithSize(name, char_size_max);
+ Swig_warning(WARN_SCILAB_TRUNCATED_NAME, input_file, line_number,
+ "Identifier name '%s' exceeds 24 characters and has been truncated to '%s'.\n", name, scilabIdentifierName);
+ } else
+ scilabIdentifierName = name;
+ return scilabIdentifierName;
+ }
+
+ /* -----------------------------------------------------------------------
+ * checkMemberIdentifierName()
+ * Truncates (and displays a warning) too long member identifier names
+ * (applies on members of structs, classes...)
+ * (Scilab identifiers names are limited to 24 chars max)
+ * ----------------------------------------------------------------------- */
+
+ void checkMemberIdentifierName(Node *node, int char_size_max) {
+
+ String *memberName = Getattr(node, "sym:name");
+
+ Node *containerNode = parentNode(node);
+ String *containerName = Getattr(containerNode, "sym:name");
+
+ int lenContainerName = Len(containerName);
+ int lenMemberName = Len(memberName);
+
+ if (lenContainerName + lenMemberName + 1 > char_size_max) {
+ int lenScilabMemberName = char_size_max - lenContainerName - 1;
+
+ if (lenScilabMemberName > 0) {
+ String *scilabMemberName = DohNewStringWithSize(memberName, lenScilabMemberName);
+ Setattr(node, "sym:name", scilabMemberName);
+ Swig_warning(WARN_SCILAB_TRUNCATED_NAME, input_file, line_number,
+ "Wrapping functions names for member '%s.%s' will exceed 24 characters, "
+ "so member name has been truncated to '%s'.\n", containerName, memberName, scilabMemberName);
+ } else
+ Swig_error(input_file, line_number,
+ "Wrapping functions names for member '%s.%s' will exceed 24 characters, "
+ "please rename the container of member '%s'.\n", containerName, memberName, containerName);
+ }
+ }
+
+
+
+ /* -----------------------------------------------------------------------
+ * addHelperFunctions()
+ * ----------------------------------------------------------------------- */
+
+ void addHelperFunctions() {
+ addFunctionToScilab("SWIG_this", "SWIG_this");
+ addFunctionToScilab("SWIG_ptr", "SWIG_ptr");
+ }
+
+ /* -----------------------------------------------------------------------
+ * addFunctionToScilab()
+ * Declare a wrapped function in Scilab (builder, gateway, XML, ...)
+ * ----------------------------------------------------------------------- */
+
+ void addFunctionToScilab(const_String_or_char_ptr scilabFunctionName, const_String_or_char_ptr wrapperFunctionName) {
+ if (!generateBuilder)
+ addFunctionInGatewayHeader(scilabFunctionName, wrapperFunctionName);
+
+ if (generateBuilder) {
+ addFunctionInScriptTable(scilabFunctionName, wrapperFunctionName, builderCode);
+ }
+
+ if (createLoader) {
+ addFunctionInLoader(scilabFunctionName);
+ }
+
+ if (gatewayXMLFile) {
+ Printf(gatewayXML, "<PRIMITIVE gatewayId=\"%s\" primitiveId=\"%d\" primitiveName=\"%s\"/>\n", gatewayID, primitiveID++, scilabFunctionName);
+ }
+ }
+
+
+ /* -----------------------------------------------------------------------
+ * createBuilderCode()
+ * ----------------------------------------------------------------------- */
+
+ void createBuilderFile(String *outputFilename) {
+ String *builderFilename = NewStringf("builder.sce");
+ builderFile = NewFile(builderFilename, "w", SWIG_output_files());
+ if (!builderFile) {
+ FileErrorDisplay(builderFilename);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ emitBanner(builderFile);
+
+ builderFunctionCount = 0;
+ builderCode = NewString("");
+ Printf(builderCode, "mode(-1);\n");
+ Printf(builderCode, "lines(0);\n"); /* Useful for automatic tests */
+
+ // Scilab needs to be in the build directory
+ Printf(builderCode, "originaldir = pwd();\n");
+ Printf(builderCode, "builddir = get_absolute_file_path('builder.sce');\n");
+ Printf(builderCode, "cd(builddir);\n");
+
+ Printf(builderCode, "ilib_verbose(%s);\n", verboseBuildLevel);
+
+ Printf(builderCode, "libs = [];\n");
+
+ // Flags from command line arguments
+ Printf(builderCode, "cflags = [];\n");
+ for (int i = 0; i < Len(cflags); i++) {
+ String *cflag = Getitem(cflags, i);
+ Printf(builderCode, "cflags = cflags + \" %s\";\n", cflag);
+ }
+
+ if (Len(ldflags) > 0) {
+ for (int i = 0; i < Len(ldflags); i++) {
+ String *ldflag = Getitem(ldflags, i);
+ if (i == 0) {
+ Printf(builderCode, "ldflags = \"%s\";\n", ldflag);
+ } else {
+ Printf(builderCode, "ldflags = ldflags + \" %s\";\n", ldflag);
+ }
+ }
+ } else {
+ Printf(builderCode, "ldflags = [];\n");
+ }
+
+ // External script to set flags
+ if (buildFlagsScript) {
+ Printf(builderCode, "exec(\"%s\");\n", buildFlagsScript);
+ Printf(builderCode, "cflags = cflags + getCompilationFlags();\n");
+ Printf(builderCode, "ldflags = ldflags + getLinkFlags();\n");
+ }
+ // Additional sources
+ Insert(sourceFileList, 0, outputFilename);
+ for (int i = 0; i < Len(sourceFileList); i++) {
+ String *sourceFile = Getitem(sourceFileList, i);
+ if (i == 0) {
+ Printf(builderCode, "files = \"%s\";\n", sourceFile);
+ } else {
+ Printf(builderCode, "files($ + 1) = \"%s\";\n", sourceFile);
+ }
+ }
+
+ Printf(builderCode, "table = [");
+ }
+
+ /* -----------------------------------------------------------------------
+ * addFunctionInBuilderCode()
+ * Add a function wrapper in the function table of generated builder script
+ * ----------------------------------------------------------------------- */
+
+ void addFunctionInScriptTable(const_String_or_char_ptr scilabFunctionName, const_String_or_char_ptr wrapperFunctionName, String *scriptCode) {
+ if (++builderFunctionCount % 10 == 0) {
+ Printf(scriptCode, "];\ntable = [table;");
+ }
+ Printf(scriptCode, "\"%s\",\"%s\";", scilabFunctionName, wrapperFunctionName);
+ }
+
+ /* -----------------------------------------------------------------------
+ * saveBuilderFile()
+ * ----------------------------------------------------------------------- */
+
+ void saveBuilderFile(String *gatewayName) {
+ Printf(builderCode, "];\n");
+ Printf(builderCode, "ierr = 0;\n");
+ Printf(builderCode, "if ~isempty(table) then\n");
+ Printf(builderCode, " ierr = execstr(\"ilib_build(''%s'', table, files, libs, [], ldflags, cflags);\", 'errcatch');\n", gatewayName);
+ Printf(builderCode, " if ierr <> 0 then\n");
+ Printf(builderCode, " err_msg = lasterror();\n");
+ Printf(builderCode, " end\n");
+ Printf(builderCode, "end\n");
+ Printf(builderCode, "cd(originaldir);\n");
+ Printf(builderCode, "if ierr <> 0 then\n");
+ Printf(builderCode, " error(ierr, err_msg);\n");
+ Printf(builderCode, "end\n");
+ Printv(builderFile, builderCode, NIL);
+ Delete(builderFile);
+ }
+
+ /* -----------------------------------------------------------------------
+ * createGatewayXMLFile()
+ * This XML file is used by Scilab in the context of internal modules
+ * ----------------------------------------------------------------------- */
+
+ void createGatewayXMLFile(String *gatewayName) {
+ String *gatewayXMLFilename = NewStringf("%s_gateway.xml", gatewayName);
+ gatewayXMLFile = NewFile(gatewayXMLFilename, "w", SWIG_output_files());
+ if (!gatewayXMLFile) {
+ FileErrorDisplay(gatewayXMLFilename);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ // Add a slightly modified SWIG banner to the gateway XML ("--modify" is illegal in XML)
+ gatewayXML = NewString("");
+ Printf(gatewayXML, "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
+ Printf(gatewayXML, "<!--\n");
+ Printf(gatewayXML, "This file was automatically generated by SWIG (http://www.swig.org).\n");
+ Printf(gatewayXML, "Version %s\n", Swig_package_version());
+ Printf(gatewayXML, "\n");
+ Printf(gatewayXML, "Do not make changes to this file unless you know what you are doing - modify\n");
+ Printf(gatewayXML, "the SWIG interface file instead.\n");
+ Printf(gatewayXML, "-->\n");
+ Printf(gatewayXML, "<GATEWAY name=\"%s\">\n", gatewayName);
+
+ primitiveID = 1;
+ }
+
+ /* -----------------------------------------------------------------------
+ * saveGatewayXMLFile()
+ * ----------------------------------------------------------------------- */
+
+ void saveGatewayXMLFile() {
+ Printf(gatewayXML, "</GATEWAY>\n");
+ Printv(gatewayXMLFile, gatewayXML, NIL);
+ Delete(gatewayXMLFile);
+ }
+
+ /* -----------------------------------------------------------------------
+ * startGatewayHeader()
+ * Start the gateway header
+ * ----------------------------------------------------------------------- */
+ void startGatewayHeader(String *gatewayLibraryName) {
+ gatewayHeader = NewString("");
+ Printf(gatewayHeader, "\n");
+
+ gatewayHeaderV6 = NewString("");
+ Printf(gatewayHeaderV6, "#include \"c_gateway_prototype.h\"\n");
+ Printf(gatewayHeaderV6, "#include \"addfunction.h\"\n");
+ Printf(gatewayHeaderV6, "\n");
+ Printf(gatewayHeaderV6, "#define MODULE_NAME L\"%s\"\n", gatewayLibraryName);
+ Printf(gatewayHeaderV6, "#ifdef __cplusplus\n");
+ Printf(gatewayHeaderV6, "extern \"C\"\n");
+ Printf(gatewayHeaderV6, "#endif\n");
+ Printf(gatewayHeaderV6, "int %s(wchar_t *pwstFuncName) {\n", gatewayLibraryName);
+ Printf(gatewayHeaderV6, "\n");
+ }
+
+ /* -----------------------------------------------------------------------
+ * addFunctionInGatewayHeader()
+ * Add a function in the gateway header
+ * ----------------------------------------------------------------------- */
+
+ void addFunctionInGatewayHeader(const_String_or_char_ptr scilabFunctionName, const_String_or_char_ptr wrapperFunctionName) {
+ if (gatewayHeaderV5 == NULL) {
+ gatewayHeaderV5 = NewString("");
+ Printf(gatewayHeaderV5, "static GenericTable Tab[] = {\n");
+ } else
+ Printf(gatewayHeaderV5, ",\n");
+ Printf(gatewayHeaderV5, " {(Myinterfun)sci_gateway, (GT)%s, (char *)\"%s\"}", wrapperFunctionName, scilabFunctionName);
+
+ Printf(gatewayHeaderV6, "if (wcscmp(pwstFuncName, L\"%s\") == 0) { addCFunction((wchar_t *)L\"%s\", &%s, (wchar_t *)MODULE_NAME); }\n", scilabFunctionName, scilabFunctionName, wrapperFunctionName);
+ }
+
+ /* -----------------------------------------------------------------------
+ * terminateGatewayHeader()
+ * Terminates the gateway header
+ * ----------------------------------------------------------------------- */
+
+ void terminateGatewayHeader(String *gatewayLibraryName) {
+ Printf(gatewayHeaderV5, "};\n");
+ Printf(gatewayHeaderV5, "\n");
+ Printf(gatewayHeaderV5, "#ifdef __cplusplus\n");
+ Printf(gatewayHeaderV5, "extern \"C\" {\n");
+ Printf(gatewayHeaderV5, "#endif\n");
+ Printf(gatewayHeaderV5, "int C2F(%s)() {\n", gatewayLibraryName);
+ Printf(gatewayHeaderV5, " Rhs = Max(0, Rhs);\n");
+ Printf(gatewayHeaderV5, " if (*(Tab[Fin-1].f) != NULL) {\n");
+ Printf(gatewayHeaderV5, " if(pvApiCtx == NULL) {\n");
+ Printf(gatewayHeaderV5, " pvApiCtx = (StrCtx *)MALLOC(sizeof(StrCtx));\n");
+ Printf(gatewayHeaderV5, " }\n");
+ Printf(gatewayHeaderV5, " pvApiCtx->pstName = (char *)Tab[Fin-1].name;\n");
+ Printf(gatewayHeaderV5, " (*(Tab[Fin-1].f))(Tab[Fin-1].name,(GatefuncH)Tab[Fin-1].F);\n");
+ Printf(gatewayHeaderV5, " }\n");
+ Printf(gatewayHeaderV5, " return 0;\n");
+ Printf(gatewayHeaderV5, "}\n");
+ Printf(gatewayHeaderV5, "\n");
+ Printf(gatewayHeaderV5, "#ifdef __cplusplus\n");
+ Printf(gatewayHeaderV5, "}\n");
+ Printf(gatewayHeaderV5, "#endif\n");
+
+ Printf(gatewayHeaderV6, "return 1;\n");
+ Printf(gatewayHeaderV6, "};\n");
+
+ Printf(gatewayHeader, "#if SWIG_SCILAB_VERSION >= 600\n");
+ Printv(gatewayHeader, gatewayHeaderV6, NIL);
+ Printf(gatewayHeader, "#else\n");
+ Printv(gatewayHeader, gatewayHeaderV5, NIL);
+ Printf(gatewayHeader, "#endif\n");
+ }
+
+
+ /* -----------------------------------------------------------------------
+ * createLoaderScriptFile()
+ * Creates the loader script file (loader.sce)
+ * ----------------------------------------------------------------------- */
+
+ void createLoaderFile(String *gatewayLibraryName) {
+ String *loaderFilename = NewString("loader.sce");
+ loaderFile = NewFile(loaderFilename, "w", SWIG_output_files());
+ if (!loaderFile) {
+ FileErrorDisplay(loaderFilename);
+ SWIG_exit(EXIT_FAILURE);
+ }
+
+ emitBanner(loaderFile);
+
+ loaderScript = NewString("");
+ Printf(loaderScript, "%s_path = get_absolute_file_path('loader.sce');\n", gatewayLibraryName);
+ Printf(loaderScript, "[bOK, ilib] = c_link('%s');\n", gatewayLibraryName);
+ Printf(loaderScript, "if bOK then\n");
+ Printf(loaderScript, " ulink(ilib);\n");
+ Printf(loaderScript, "end\n");
+ Printf(loaderScript, "list_functions = [..\n");
+ }
+
+ /* -----------------------------------------------------------------------
+ * addFunctionInLoaderScript()
+ * Add a function in the loader script table
+ * ----------------------------------------------------------------------- */
+
+ void addFunctionInLoader(const_String_or_char_ptr scilabFunctionName) {
+ Printf(loaderScript, " '%s'; ..\n", scilabFunctionName);
+ }
+
+ /* -----------------------------------------------------------------------
+ * saveLoaderScriptFile()
+ * Terminates and saves the loader script
+ * ----------------------------------------------------------------------- */
+
+ void saveLoaderFile(String *gatewayLibraryName) {
+ Printf(loaderScript, "];\n");
+ Printf(loaderScript, "addinter(fullfile(%s_path, '%s' + getdynlibext()), '%s', list_functions);\n",
+ gatewayLibraryName, gatewayLibraryName, gatewayLibraryName);
+ Printf(loaderScript, "clear %s_path;\n", gatewayLibraryName);
+ Printf(loaderScript, "clear bOK;\n");
+ Printf(loaderScript, "clear ilib;\n");
+ Printf(loaderScript, "clear list_functions;\n");
+ Printv(loaderFile, loaderScript, NIL);
+
+ Delete(loaderFile);
+ }
+
+};
+
+extern "C" Language *swig_scilab(void) {
+ return new SCILAB();
+}
diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx
index 8a0861d17..b7b5d66ee 100644
--- a/Source/Modules/swigmain.cxx
+++ b/Source/Modules/swigmain.cxx
@@ -49,6 +49,7 @@ extern "C" {
Language *swig_cffi(void);
Language *swig_uffi(void);
Language *swig_r(void);
+ Language *swig_scilab(void);
Language *swig_go(void);
Language *swig_d(void);
Language *swig_javascript(void);
@@ -89,6 +90,7 @@ static swig_module modules[] = {
{"-python", swig_python, "Python"},
{"-r", swig_r, "R (aka GNU S)"},
{"-ruby", swig_ruby, "Ruby"},
+ {"-scilab", swig_scilab, "Scilab"},
{"-sexp", swig_sexp, "Lisp S-Expressions"},
{"-tcl", swig_tcl, "Tcl"},
{"-tcl8", swig_tcl, 0},
@@ -180,11 +182,6 @@ int main(int margc, char **margv) {
} else if (strcmp(argv[i], "-nolang") == 0) {
dl = new Language;
Swig_mark_arg(i);
- } else if ((strcmp(argv[i], "-dnone") == 0) ||
- (strcmp(argv[i], "-dhtml") == 0) ||
- (strcmp(argv[i], "-dlatex") == 0) || (strcmp(argv[i], "-dascii") == 0) || (strcmp(argv[i], "-stat") == 0)) {
- Printf(stderr, "swig: Warning. %s option deprecated.\n", argv[i]);
- Swig_mark_arg(i);
} else if ((strcmp(argv[i], "-help") == 0) || (strcmp(argv[i], "--help") == 0)) {
if (strcmp(argv[i], "--help") == 0)
strcpy(argv[i], "-help");
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
index 1ca549703..ac912f49e 100644
--- a/Source/Preprocessor/cpp.c
+++ b/Source/Preprocessor/cpp.c
@@ -1376,12 +1376,12 @@ String *Preprocessor_parse(String *s) {
else if (c == '\"') {
start_line = Getline(s);
if (skip_tochar(s, '\"', chunk) < 0) {
- Swig_error(Getfile(s), -1, "Unterminated string constant starting at line %d\n", start_line);
+ Swig_error(Getfile(s), start_line, "Unterminated string constant\n");
}
} else if (c == '\'') {
start_line = Getline(s);
if (skip_tochar(s, '\'', chunk) < 0) {
- Swig_error(Getfile(s), -1, "Unterminated character constant starting at line %d\n", start_line);
+ Swig_error(Getfile(s), start_line, "Unterminated character constant\n");
}
} else if (c == '/')
state = 30; /* Comment */
@@ -1768,8 +1768,10 @@ String *Preprocessor_parse(String *s) {
}
} else if (Equal(id, kpp_level)) {
Swig_error(Getfile(s), Getline(id), "cpp debug: level = %d, startlevel = %d\n", level, start_level);
+ } else if (Equal(id, "")) {
+ /* Null directive */
} else {
- Swig_error(Getfile(s), Getline(id), "Unknown SWIG preprocessor directive: %s\n", id);
+ Swig_error(Getfile(s), Getline(id), "Unknown SWIG preprocessor directive: %s (if this is a block of target language code, delimit it with %%{ and %%})\n", id);
}
for (i = 0; i < cpp_lines; i++)
Putc('\n', ns);
@@ -2006,21 +2008,21 @@ String *Preprocessor_parse(String *s) {
}
}
while (level > 0) {
- Swig_error(Getfile(s), -1, "Missing #endif for conditional starting on line %d\n", cond_lines[level - 1]);
+ Swig_error(Getfile(s), cond_lines[level - 1], "Missing #endif for conditional starting here\n");
level--;
}
if (state == 120) {
- Swig_error(Getfile(s), -1, "Missing %%endoffile for file inclusion block starting on line %d\n", start_line);
+ Swig_error(Getfile(s), start_line, "Missing %%endoffile for file inclusion block starting here\n");
}
if (state == 150) {
Seek(value, 0, SEEK_SET);
- Swig_error(Getfile(s), -1, "Missing %%enddef for macro starting on line %d\n", Getline(value));
+ Swig_error(Getfile(s), Getline(value), "Missing %%enddef for macro starting here\n", Getline(value));
}
if ((state >= 105) && (state < 107)) {
- Swig_error(Getfile(s), -1, "Unterminated %%{ ... %%} block starting on line %d\n", start_line);
+ Swig_error(Getfile(s), start_line, "Unterminated %%{ ... %%} block\n");
}
if ((state >= 30) && (state < 40)) {
- Swig_error(Getfile(s), -1, "Unterminated comment starting on line %d\n", start_line);
+ Swig_error(Getfile(s), start_line, "Unterminated comment\n");
}
copy_location(s, chunk);
diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c
index c97640b08..9da4e0829 100644
--- a/Source/Swig/cwrap.c
+++ b/Source/Swig/cwrap.c
@@ -1614,7 +1614,14 @@ int Swig_VargetToFunction(Node *n, int flags) {
Delete(mangled);
Delete(sname);
} else {
- String *nname = SwigType_namestr(name);
+ String *nname = 0;
+ if (Equal(nodeType(n), "constant")) {
+ String *rawval = Getattr(n, "rawval");
+ String *value = rawval ? rawval : Getattr(n, "value");
+ nname = NewStringf("(%s)", value);
+ } else {
+ nname = SwigType_namestr(name);
+ }
call = Swig_wrapped_var_assign(type, nname, varcref);
cres = Swig_cresult(ty, Swig_cresult_name(), call);
Setattr(n, "wrap:action", cres);
diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c
index d8c3f7f3f..b0d608c9e 100644
--- a/Source/Swig/scanner.c
+++ b/Source/Swig/scanner.c
@@ -824,6 +824,9 @@ static int look(Scanner *s) {
state = 7;
} else if (c == '=') {
return SWIG_TOKEN_MODEQUAL;
+ } else if (c == '}') {
+ Swig_error(cparse_file, cparse_line, "Syntax error. Extraneous '%%}'\n");
+ exit(1);
} else {
retract(s, 1);
return SWIG_TOKEN_PERCENT;
diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c
index e77f818de..2202f61c6 100644
--- a/Source/Swig/symbol.c
+++ b/Source/Swig/symbol.c
@@ -1875,15 +1875,15 @@ ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope,
Delete(ntq);
ntq = ty;
}
- /* Printf(stderr,"value %s %s %s\n",value,ntr,ntq); */
cp = NewParmWithoutFileLineInfo(ntq, 0);
- if (lp)
- set_nextSibling(lp, cp);
- else
- expandedparms = CopyParm(cp);
+ if (lp) {
+ set_nextSibling(lp, cp);
+ Delete(cp);
+ } else {
+ expandedparms = cp;
+ }
lp = cp;
tp = nextSibling(tp);
- Delete(cp);
Delete(nt);
Delete(ntq);
} else {
diff --git a/Tools/javascript/Makefile.in b/Tools/javascript/Makefile.in
index 37ff8830e..1eec5bc1e 100644
--- a/Tools/javascript/Makefile.in
+++ b/Tools/javascript/Makefile.in
@@ -26,10 +26,6 @@ LINKFLAGS = @JSINTERPRETERLINKFLAGS@
ROOT_DIR = @ROOT_DIR@
JSINCLUDES = @JSCOREINC@ @JSV8INC@
JSDYNAMICLINKING = @JSCOREDYNAMICLINKING@ @JSV8DYNAMICLINKING@
-JSLIBRARYPREFIX = @JSLIBRARYPREFIX@
-JSSO =@JSSO@
-JSLDSHARED = @JSLDSHARED@
-JSCXXSHARED = @JSCXXSHARED@
JSV8ENABLED = @JSV8ENABLED@
JSCENABLED = @JSCENABLED@
diff --git a/Tools/obs-buildlogs.py b/Tools/obs-buildlogs.py
new file mode 100755
index 000000000..eaf0f613b
--- /dev/null
+++ b/Tools/obs-buildlogs.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+import os
+import subprocess
+import argparse
+import glob
+
+def remove_old_files():
+ files = glob.glob("*.log")
+ for file in files:
+ os.remove(file)
+
+def download():
+ repos = subprocess.Popen(['osc', 'repositories'], stdout=subprocess.PIPE)
+ for line in repos.stdout:
+ command = ['osc', 'buildlog', '--last'] + line.split()
+ filename = "-".join(line.split()) + ".log"
+ print "Downloading logs using: {}".format(" ".join(command))
+ buildlog = subprocess.Popen(command, stdout=subprocess.PIPE)
+
+ print("Writing log to {}".format(filename))
+ file = open(filename, "w")
+ if buildlog.stderr != None:
+ print("Errors: {}".format(buildlog.stderr))
+ for log_line in buildlog.stdout:
+ file.write(log_line)
+
+ print("Finished")
+
+parser = argparse.ArgumentParser(description="Download OpenBuild logs using osc. All the logs for each architecture from the last completed builds are downloaded and stored as .log files. Must be run from a working copy that is already checked out, eg after running obs-update.")
+args = parser.parse_args()
+
+remove_old_files()
+download()
diff --git a/configure.ac b/configure.ac
index 40eeb5a18..c2a36fc95 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ dnl Process this file with autoconf to produce a configure script.
dnl The macros which aren't shipped with the autotools are stored in the
dnl Tools/config directory in .m4 files.
-AC_INIT([swig],[3.0.3],[http://www.swig.org])
+AC_INIT([swig],[3.0.6],[http://www.swig.org])
dnl NB: When this requirement is increased to 2.60 or later, AC_PROG_SED
dnl definition below can be removed
@@ -274,6 +274,8 @@ then
then CCSHARED="-fpic"
else CCSHARED="+z"
fi;;
+ s390x*-*-*) CCSHARED="-fpic" ;;
+ s390*-*-*) CCSHARED="-fPIC" ;;
*-*-linux*) CCSHARED="-fpic";;
*-*-freebsd* | *-*-openbsd*) CCSHARED="-fpic";;
*-*-netbsd*) CCSHARED="-fPIC";;
@@ -335,7 +337,7 @@ AC_MSG_CHECKING([whether to enable C++11 testing])
AC_MSG_RESULT([$enable_cpp11_testing])
PLATCXXFLAGS="$PLATCFLAGS"
-if test x"$enable_cpp11_testing" = xyes; then
+if test x"$enable_cpp11_testing" = xyes; then
AC_LANG_PUSH([C++])
CXXFLAGS_SAVED=$CXXFLAGS
AX_CXX_COMPILE_STDCXX_11([noext], [nostop])
@@ -353,7 +355,7 @@ if test x"$enable_cpp11_testing" = xyes; then
fi
# On darwin 10.7,10.8,10.9 using clang++, need to ensure using
-# libc++ for tests and examples to run under mono. May affect
+# libc++ for tests and examples to run under mono. May affect
# other language targets as well - problem is an OSX incompatibility
# between libraries depending on libstdc++ and libc++.
CLANGXX=
@@ -821,7 +823,7 @@ fi
# perl -MExtUtils::Embed -e ccopts
AC_MSG_CHECKING(for Perl5 header files)
if test -n "$PERL"; then
- PERL5DIR=`($PERL -e 'use Config; print $Config{archlib}, "\n";') 2>/dev/null`
+ PERL5DIR=`($PERL -MConfig -le 'print $Config{archlibexp}') 2>/dev/null`
if test -n "$PERL5DIR" ; then
dirs="$PERL5DIR $PERL5DIR/CORE"
PERL5EXT=none
@@ -992,6 +994,92 @@ AC_SUBST(OCTAVE_CXXFLAGS)
AC_SUBST(OCTAVE_LDFLAGS)
#----------------------------------------------------------------
+# Look for Scilab
+#----------------------------------------------------------------
+
+AC_ARG_WITH(scilab, AS_HELP_STRING([--without-scilab], [Disable Scilab])
+AS_HELP_STRING([--with-scilab=path], [Set location of Scilab executable]),[SCILABBIN="$withval"], [SCILABBIN=yes])
+AC_ARG_WITH(scilab-inc, [ --with-scilab-inc=path Set location of Scilab include directory], [SCILABINCDIR="$withval"], [SCILABINCDIR=""])
+
+# First, check for "--without-scilab" or "--with-scilab=no".
+if test x"${SCILABBIN}" = xno -o x"${with_alllang}" = xno ; then
+ AC_MSG_NOTICE([Disabling Scilab])
+ SCILAB=
+else
+ # Check for Scilab executable
+ if test "x$SCILABBIN" = xyes; then
+ AC_CHECK_PROGS(SCILAB, scilab)
+ else
+ AC_MSG_CHECKING(for scilab)
+ if test -f "$SCILABBIN"; then
+ AC_MSG_RESULT($SCILABBIN)
+ SCILAB="$SCILABBIN"
+ else
+ AC_MSG_RESULT(not found)
+ fi
+ fi
+
+ if test -n "$SCILAB"; then
+ # Check for Scilab version (needs api_scilab so needs version 5.3.3 or higher)
+ SCILAB_FULL_VERSION=`$SCILAB -version | head -1 | sed -e 's|Scilab version \"\(.*\)\"|\1|g'`
+
+ AC_MSG_CHECKING(Scilab version is 5.3.3 or higher)
+ SCILAB_MAJOR_VERSION=`echo $SCILAB_FULL_VERSION | cut -d. -f1`
+ SCILAB_MINOR_VERSION=`echo $SCILAB_FULL_VERSION | cut -d. -f2`
+ SCILAB_MAINTENANCE_VERSION=`echo $SCILAB_FULL_VERSION | cut -d. -f3`
+ SCILAB_VERSION="$SCILAB_MAJOR_VERSION$SCILAB_MINOR_VERSION$SCILAB_MAINTENANCE_VERSION"
+
+ if test $SCILAB_VERSION -ge 533; then
+ AC_MSG_RESULT(yes)
+ else
+ AC_MSG_RESULT(no)
+ SCILAB=
+ fi
+
+ if test -n "$SCILAB"; then
+ # Set Scilab startup options depending on version
+ AC_MSG_CHECKING(for Scilab startup options)
+ SCILABOPT="-nwni -nb"
+ if test $SCILAB_VERSION -ge 540; then
+ SCILABOPT+=" -noatomsautoload"
+ fi
+ AC_MSG_RESULT($SCILABOPT)
+
+ # Check for Scilab header files
+ AC_MSG_CHECKING(for Scilab header files)
+ if test "$SCILABINCDIR" != ""; then
+ dirs="$SCILABINCDIR"
+ elif test -n "$PKGCONFIG"; then
+ dirs=`$PKGCONFIG scilab --cflags-only-I | sed -e 's/-I//g'`
+ else
+ dirs=""
+ fi
+ for i in $dirs; do
+ if test -r $i/api_scilab.h; then
+ AC_MSG_RESULT($i)
+ SCILABINCLUDE="-I$i"
+ break;
+ fi
+ if test -r $i/scilab/api_scilab.h; then
+ AC_MSG_RESULT($i/scilab)
+ SCILABINCLUDE="-I$i/scilab"
+ break;
+ fi
+ done
+ if test "$SCILABINCLUDE" = "" ; then
+ AC_MSG_RESULT(not found)
+ SCILAB=
+ fi
+ fi
+ fi
+fi
+
+AC_SUBST(SCILAB)
+AC_SUBST(SCILABINCLUDE)
+AC_SUBST(SCILABOPT)
+
+
+#----------------------------------------------------------------
# Look for java
#----------------------------------------------------------------
@@ -1124,27 +1212,14 @@ else
#----------------------------------------------------------------
case $host in
- *-*-cygwin* | *-*-mingw*)
- JSLIBRARYPREFIX=""
- ;;
- *)
- JSLIBRARYPREFIX="lib"
- ;;
- esac
-
- case $host in
*-*-darwin*)
JSSO=".dylib"
- JSLDSHARED='$(CC) -dynamiclib'
- JSCXXSHARED='$(CXX) -dynamiclib'
# HACK: didn't manage to get dynamic module loading working with a g++ compiled interpreter
JSINTERPRETERCXX='c++'
JSINTERPRETERLINKFLAGS='-g -Wl,-search_paths_first -Wl,-headerpad_max_install_names'
;;
*)
JSSO=$SO
- JSLDSHARED='$(LDSHARED)'
- JSCXXSHARED='$(CXXSHARED)'
JSINTERPRETERCXX='$(CXX)'
JSINTERPRETERLINKFLAGS='-ldl'
;;
@@ -1296,11 +1371,6 @@ else
fi
-AC_SUBST(JSLIBRARYPREFIX)
-AC_SUBST(JSSO)
-AC_SUBST(JSLDSHARED)
-AC_SUBST(JSCXXSHARED)
-
AC_SUBST(JSINTERPRETERCXX)
AC_SUBST(JSINTERPRETERLINKFLAGS)
@@ -1507,6 +1577,7 @@ AC_ARG_WITH(ruby, AS_HELP_STRING([--without-ruby], [Disable Ruby])
AS_HELP_STRING([--with-ruby=path], [Set location of Ruby executable]),[ RUBYBIN="$withval"], [RUBYBIN=yes])
# First, check for "--without-ruby" or "--with-ruby=no".
+RUBYSO=$SO
if test x"${RUBYBIN}" = xno -o x"${with_alllang}" = xno ; then
AC_MSG_NOTICE([Disabling Ruby])
RUBY=
@@ -1525,7 +1596,7 @@ if test -n "$RUBY"; then
# Try Ruby1.9+ first
RUBYDIR=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["rubyhdrdir"]] || $rubyhdrdir') 2>/dev/null`
if test x"$RUBYDIR" = x"" || test x"$RUBYDIR" = x"nil"; then
- RUBYDIR=`($RUBY -rmkmf -e 'print Config::CONFIG[["archdir"]] || $archdir') 2>/dev/null`
+ RUBYDIR=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["archdir"]] || $archdir') 2>/dev/null`
else
RUBYARCH=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["arch"]] || $arch') 2>/dev/null`
fi
@@ -1550,13 +1621,13 @@ if test -n "$RUBY"; then
# Find library and path for linking.
AC_MSG_CHECKING(for Ruby library)
RUBYLIB=""
- rb_libdir=`($RUBY -rrbconfig -e 'print Config::CONFIG[["libdir"]]') 2>/dev/null`
- rb_bindir=`($RUBY -rrbconfig -e 'print Config::CONFIG[["bindir"]]') 2>/dev/null`
+ rb_libdir=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["libdir"]]') 2>/dev/null`
+ rb_bindir=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["bindir"]]') 2>/dev/null`
dirs="$dirs $rb_libdir $rb_bindir"
- rb_libruby=`($RUBY -rrbconfig -e 'print Config::CONFIG[["LIBRUBY_A"]]') 2>/dev/null`
+ rb_libruby=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["LIBRUBY_A"]]') 2>/dev/null`
RUBYLINK=`($RUBY -rrbconfig -e '
- c = Config::CONFIG
+ c = RbConfig::CONFIG
if c.has_key? "LIBRUBYARG_STATIC" # 1.8.x
if c[["LIBRUBY"]] == c[["LIBRUBY_A"]]
link = c[["LIBRUBYARG_STATIC"]]
@@ -1602,11 +1673,11 @@ if test -n "$RUBY"; then
case $host in
*-*-mingw*) ;; # do nothing, the default windows libraries are already included
- *) RUBYLINK="$RUBYLINK `($RUBY -rrbconfig -e 'print Config::CONFIG[["LIBS"]]') 2>/dev/null`";;
+ *) RUBYLINK="$RUBYLINK `($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["LIBS"]]') 2>/dev/null`";;
esac
- RUBYCCDLFLAGS=`($RUBY -rrbconfig -e 'print Config::CONFIG[["CCDLFLAGS"]]') 2>/dev/null`
- RUBYSO=.`($RUBY -rrbconfig -e 'print Config::CONFIG[["DLEXT"]]') 2>/dev/null`
+ RUBYCCDLFLAGS=`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["CCDLFLAGS"]]') 2>/dev/null`
+ RUBYSO=.`($RUBY -rrbconfig -e 'print RbConfig::CONFIG[["DLEXT"]]') 2>/dev/null`
else
AC_MSG_RESULT(could not figure out how to run ruby)
fi
@@ -2078,85 +2149,85 @@ fi
# check version: we need Lua 5.x
if test "$LUABIN"; then
- AC_MSG_CHECKING(Lua version)
- # if version 5.x
- LUAV5=`$LUABIN -e 'if string.sub(_VERSION,5,5)=="5" then print "1" end'`
- # if not version 5.0
- LUAV51=`$LUABIN -e 'if string.sub(_VERSION,5,7)~="5.0" then print "1" end'`
-
- if test -z "$LUAV5"; then
- AC_MSG_WARN(Not Lua 5.x, SWIG does not support this version of Lua)
- LUABIN=""
- elif test -z "$LUAV51"; then
- AC_MSG_RESULT(Lua 5.0.x)
- else
- AC_MSG_RESULT(Lua 5.1 or later)
- fi
+ AC_MSG_CHECKING(Lua version)
+ # if version 5.x
+ LUAV5=`$LUABIN -e 'if string.sub(_VERSION,5,5)=="5" then print "1" end'`
+ # if not version 5.0
+ LUAV51=`$LUABIN -e 'if string.sub(_VERSION,5,7)~="5.0" then print "1" end'`
+
+ if test -z "$LUAV5"; then
+ AC_MSG_WARN(Not Lua 5.x, SWIG does not support this version of Lua)
+ LUABIN=""
+ elif test -z "$LUAV51"; then
+ AC_MSG_RESULT(Lua 5.0.x)
+ else
+ AC_MSG_RESULT(Lua 5.1 or later)
+ fi
fi
if test "$LUABIN"; then
- AC_MSG_CHECKING(whether Lua dynamic loading is enabled)
- # using Lua to check Lua
- # lua 5.0 & 5.1 have different fn names
- if test -z "$LUAV51"; then
- LUADYNAMICLOADLIB=`$LUABIN -e '_,_,c=loadlib("no_such_lib","") if c~="absent" then print "1" end'`
- else
- LUADYNAMICLOADLIB=`$LUABIN -e '_,_,c=package.loadlib("no_such_lib","") if c~="absent" then print "1" end'`
- fi
+ AC_MSG_CHECKING(whether Lua dynamic loading is enabled)
+ # using Lua to check Lua
+ # lua 5.0 & 5.1 have different fn names
+ if test -z "$LUAV51"; then
+ LUADYNAMICLOADLIB=`$LUABIN -e '_,_,c=loadlib("no_such_lib","") if c~="absent" then print "1" end'`
+ else
+ LUADYNAMICLOADLIB=`$LUABIN -e '_,_,c=package.loadlib("no_such_lib","") if c~="absent" then print "1" end'`
+ fi
- if test -z "$LUADYNAMICLOADLIB"; then
- AC_MSG_RESULT(no)
- else
- AC_MSG_RESULT(yes)
- fi
-fi
+ if test -z "$LUADYNAMICLOADLIB"; then
+ AC_MSG_RESULT(no)
+ else
+ AC_MSG_RESULT(yes)
+ fi
-# look for the header files & set LUAFLAGS accordingly
-# will clear LUABIN if not present
-if test -n "$LUAINCLUDE"; then
- AC_CHECK_FILE($LUAINCLUDE/lua.h,[LUAFLAGS="$ISYSTEM$LUAINCLUDE"],[LUABIN=])
-else
- LUA_OK="1"
- AC_CHECK_HEADER(lua.h,[LUAFLAGS=""],[LUA_OK=""])
- # if we didn't get it, going to have to look elsewhere (the hard way)
- if test -z "$LUA_OK"; then
- AC_MSG_CHECKING(for lua.h in other locations)
- # note: Debian/Ubuntu seem to like /usr/include/lua5.1/lua.h
- # The ordering of the include directories to search should match
- # the ordering of libraries to search in the library test below.
- inc=/usr/include
- dirs="$inc/lua5.2 $inc/lua5.1 $inc/lua51 $inc/lua5.0 $inc/lua50 /usr/local/include"
- for i in $dirs; do
- #echo "$i"
- if test -r $i/lua.h; then
- AC_MSG_RESULT($i/lua.h)
- LUAFLAGS="$ISYSTEM$i"
- break
+ # look for the header files & set LUAFLAGS accordingly
+ # will clear LUABIN if not present
+ if test -n "$LUAINCLUDE"; then
+ AC_CHECK_FILE($LUAINCLUDE/lua.h,[LUAFLAGS="$ISYSTEM$LUAINCLUDE"],[LUABIN=])
+ else
+ LUA_OK="1"
+ AC_CHECK_HEADER(lua.h,[LUAFLAGS=""],[LUA_OK=""])
+ # if we didn't get it, going to have to look elsewhere (the hard way)
+ if test -z "$LUA_OK"; then
+ AC_MSG_CHECKING(for lua.h in other locations)
+ # note: Debian/Ubuntu seem to like /usr/include/lua5.1/lua.h
+ # The ordering of the include directories to search should match
+ # the ordering of libraries to search in the library test below.
+ inc=/usr/include
+ dirs="$inc/lua5.2 $inc/lua5.1 $inc/lua51 $inc/lua5.0 $inc/lua50 /usr/local/include"
+ for i in $dirs; do
+ #echo "$i"
+ if test -r $i/lua.h; then
+ AC_MSG_RESULT($i/lua.h)
+ LUAFLAGS="$ISYSTEM$i"
+ break
+ fi
+ done
+ if test -z "$LUAFLAGS"; then
+ AC_MSG_RESULT(not found)
+ LUABIN="" # clear the bin
fi
- done
- if test -z "$LUAFLAGS"; then
- AC_MSG_RESULT(not found)
- LUABIN="" # clear the bin
fi
fi
-fi
-# look for the library files & set LUALINK accordingly
-# will clear LUABIN if not present
-lua_save_LIBS=$LIBS # the code seems to disrupt LIBS, so saving
+ # look for the library files & set LUALINK accordingly
+ # will clear LUABIN if not present
+ lua_save_LIBS=$LIBS # the code seems to disrupt LIBS, so saving
-if test -n "$LUALIB"; then
- AC_CHECK_FILE($LUALIB/liblua.a,[LUALINK="-L$LUALIB -llua"],[LUABIN=])
-else
- AC_SEARCH_LIBS(lua_close, [lua lua5.2 lua5.1 lua51 lua5.0 lua50], [LUALINK="-l$ac_lib"],[LUABIN=])
-fi
+ if test -n "$LUALIB"; then
+ AC_CHECK_FILE($LUALIB/liblua.a,[LUALINK="-L$LUALIB -llua"],[LUABIN=])
+ else
+ AC_SEARCH_LIBS(lua_close, [lua lua5.2 lua5.1 lua51 lua5.0 lua50], [LUALINK="-l$ac_lib"],[LUABIN=])
+ fi
-# adding lualib for lua 5.0
-if test -z "$LUAV51"; then # extra for lua 5.0
- LUALINK="$LUALINK -llualib"
-fi
+ # adding lualib for lua 5.0
+ if test -z "$LUAV51"; then # extra for lua 5.0
+ LUALINK="$LUALINK -llualib"
+ fi
-LIBS=$lua_save_LIBS # restore LIBS
+ LIBS=$lua_save_LIBS # restore LIBS
+fi
fi # if not disabled
@@ -2586,6 +2657,12 @@ SKIP_UFFI=
#fi
AC_SUBST(SKIP_UFFI)
+SKIP_SCILAB=
+if test -z "$SCILAB"; then
+ SKIP_SCILAB="1"
+fi
+AC_SUBST(SKIP_SCILAB)
+
SKIP_GO=
if test -z "$GO" ; then
SKIP_GO="1"
@@ -2678,6 +2755,7 @@ AC_CONFIG_FILES([
Examples/test-suite/pike/Makefile
Examples/test-suite/python/Makefile
Examples/test-suite/ruby/Makefile
+ Examples/test-suite/scilab/Makefile
Examples/test-suite/tcl/Makefile
Examples/test-suite/lua/Makefile
Examples/test-suite/allegrocl/Makefile
@@ -2751,6 +2829,7 @@ test -n "$SKIP_PIKE" || langs="${langs}pike "
test -n "$SKIP_PYTHON" || langs="${langs}python "
test -n "$SKIP_R" || langs="${langs}r "
test -n "$SKIP_RUBY" || langs="${langs}ruby "
+test -n "$SKIP_SCILAB" || langs="${langs}scilab "
test -n "$SKIP_TCL" || langs="${langs}tcl "
test -n "$SKIP_UFFI" || langs="${langs}uffi "
diff --git a/preinst-swig.in b/preinst-swig.in
index 0f49e2e5e..384593ce1 100755
--- a/preinst-swig.in
+++ b/preinst-swig.in
@@ -4,4 +4,4 @@ srcdir=`cd "$builddir" && cd '@srcdir@' && pwd`
SWIG_LIB=$srcdir/Lib
#SWIG_LIB=`cygpath -w $srcdir/Lib` # For native Windows version of SWIG
export SWIG_LIB
-exec "$builddir/swig" $*
+exec "$builddir/swig" "$@"
diff --git a/testflags.py b/testflags.py
new file mode 100755
index 000000000..23bec9c8d
--- /dev/null
+++ b/testflags.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+c_common = "-fdiagnostics-show-option -std=gnu89 -Wno-long-long -Wreturn-type -Wdeclaration-after-statement"
+cflags = {
+ "csharp":"-Werror " + c_common,
+ "d":"-Werror " + c_common,
+ "go":"-Werror " + c_common,
+ "guile":"-Werror " + c_common,
+ "java":"-Werror " + c_common,
+ "javascript":"-Werror " + c_common,
+ "lua":"-Werror " + c_common,
+ "octave":"-Werror " + c_common,
+ "perl5":"-Werror " + c_common,
+ "php":"-Werror " + c_common,
+ "python":"-Werror " + c_common,
+ "ruby":"-Werror " + c_common,
+ "scilab":"-Werror " + c_common,
+ "tcl":"-Werror " + c_common,
+}
+
+cxx_common = "-fdiagnostics-show-option -std=c++98 -Wno-long-long -Wreturn-type"
+cxxflags = {
+ "csharp":"-Werror " + cxx_common,
+ "d":"-Werror " + cxx_common,
+ "go":"-Werror " + cxx_common,
+ "guile":"-Werror " + cxx_common,
+ "java":"-Werror " + cxx_common,
+ "javascript":"-Werror " + cxx_common + " -Wno-error=unused-function", # Until overload_rename is fixed for node
+ "lua":"-Werror " + cxx_common,
+ "octave":"-Werror " + cxx_common,
+ "perl5":"-Werror " + cxx_common,
+ "php":"-Werror " + cxx_common,
+ "python":"-Werror " + cxx_common,
+ "ruby":"-Werror " + cxx_common,
+ "scilab": cxx_common,
+ "tcl":"-Werror " + cxx_common,
+}
+
+import argparse
+parser = argparse.ArgumentParser(description="Display CFLAGS or CXXFLAGS to use for testing the SWIG examples and test-suite.")
+parser.add_argument('-l', '--language', required=True, help='set language to show flags for')
+flags = parser.add_mutually_exclusive_group(required=True)
+flags.add_argument('-c', '--cflags', action='store_true', default=False, help='show CFLAGS')
+flags.add_argument('-x', '--cxxflags', action='store_true', default=False, help='show CXXFLAGS')
+args = parser.parse_args()
+
+if args.cflags:
+ print("{}".format(cflags[args.language]))
+elif args.cxxflags:
+ print("{}".format(cxxflags[args.language]))
+else:
+ parser.print_help()
+ exit(1)