summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerrick <a11426@users.sourceforge.net>2011-02-14 20:11:58 +0000
committerDerrick <a11426@users.sourceforge.net>2011-02-14 20:11:58 +0000
commit5815f7ec289e067e765fb8e893a2f337d8b48303 (patch)
treeebe9e0534a089fe431cedc6fdbc1a53ac523d70c
parent3e1af1f698d5d02d7905431bcb3549c0f7bc9aa7 (diff)
parent1fab53b2046b97702e1de4cfab06cb8fa8fc129d (diff)
downloadswig-a11426-fortran.tar.gz
update fortran branch. merge of 12160:12460a11426-fortran
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/a11426-fortran@12461 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--ANNOUNCE2
-rw-r--r--CHANGES189
-rw-r--r--CHANGES.current136
-rw-r--r--COPYRIGHT4
-rw-r--r--Doc/Devel/index.html1
-rw-r--r--Doc/Devel/internals.html164
-rw-r--r--Doc/Devel/tree.html35
-rw-r--r--Doc/Manual/CSharp.html31
-rw-r--r--Doc/Manual/Contents.html106
-rw-r--r--Doc/Manual/D.html444
-rw-r--r--Doc/Manual/Extending.html120
-rw-r--r--Doc/Manual/Go.html30
-rw-r--r--Doc/Manual/Guile.html44
-rw-r--r--Doc/Manual/Introduction.html12
-rw-r--r--Doc/Manual/Java.html263
-rw-r--r--Doc/Manual/Library.html69
-rw-r--r--Doc/Manual/Lisp.html22
-rw-r--r--Doc/Manual/Lua.html74
-rw-r--r--Doc/Manual/Makefile13
-rw-r--r--Doc/Manual/Modula3.html53
-rw-r--r--Doc/Manual/Modules.html3
-rw-r--r--Doc/Manual/Mzscheme.html122
-rw-r--r--Doc/Manual/Ocaml.html64
-rw-r--r--Doc/Manual/Octave.html51
-rw-r--r--Doc/Manual/Perl5.html94
-rw-r--r--Doc/Manual/Php.html48
-rw-r--r--Doc/Manual/Pike.html24
-rw-r--r--Doc/Manual/Python.html150
-rw-r--r--Doc/Manual/R.html16
-rw-r--r--Doc/Manual/Ruby.html445
-rw-r--r--Doc/Manual/SWIG.html308
-rw-r--r--Doc/Manual/SWIGPlus.html17
-rw-r--r--Doc/Manual/Sections.html11
-rw-r--r--Doc/Manual/Tcl.html92
-rw-r--r--Doc/Manual/Typemaps.html16
-rw-r--r--Doc/Manual/Warnings.html5
-rw-r--r--Doc/Manual/chapters4
-rw-r--r--Doc/Manual/linkchecker.config5
-rw-r--r--Doc/Manual/makechap.py2
-rw-r--r--Doc/Manual/maketoc.py4
-rw-r--r--Examples/Makefile.in112
-rw-r--r--Examples/d/callback/Makefile30
-rw-r--r--Examples/d/callback/d1/runme.d36
-rw-r--r--Examples/d/callback/d2/runme.d36
-rw-r--r--Examples/d/callback/example.cxx4
-rw-r--r--Examples/d/callback/example.h24
-rw-r--r--Examples/d/callback/example.i13
-rw-r--r--Examples/d/check.list9
-rw-r--r--Examples/d/class/Makefile30
-rw-r--r--Examples/d/class/d1/runme.d58
-rw-r--r--Examples/d/class/d2/runme.d58
-rw-r--r--Examples/d/class/example.cxx28
-rw-r--r--Examples/d/class/example.h34
-rw-r--r--Examples/d/class/example.i10
-rw-r--r--Examples/d/constants/Makefile30
-rw-r--r--Examples/d/constants/d1/runme.d28
-rw-r--r--Examples/d/constants/d2/runme.d28
-rw-r--r--Examples/d/constants/example.d23
-rw-r--r--Examples/d/constants/example.i32
-rw-r--r--Examples/d/enum/Makefile30
-rw-r--r--Examples/d/enum/d1/runme.d28
-rw-r--r--Examples/d/enum/d2/runme.d28
-rw-r--r--Examples/d/enum/example.cxx37
-rw-r--r--Examples/d/enum/example.h13
-rw-r--r--Examples/d/enum/example.i11
-rw-r--r--Examples/d/extend/Makefile30
-rw-r--r--Examples/d/extend/d1/runme.d75
-rw-r--r--Examples/d/extend/d2/runme.d75
-rw-r--r--Examples/d/extend/example.cxx4
-rw-r--r--Examples/d/extend/example.h56
-rw-r--r--Examples/d/extend/example.i14
-rw-r--r--Examples/d/funcptr/Makefile30
-rw-r--r--Examples/d/funcptr/d1/runme.d42
-rw-r--r--Examples/d/funcptr/d2/runme.d34
-rw-r--r--Examples/d/funcptr/example.c19
-rw-r--r--Examples/d/funcptr/example.h9
-rw-r--r--Examples/d/funcptr/example.i16
-rw-r--r--Examples/d/simple/Makefile30
-rw-r--r--Examples/d/simple/d1/runme.d27
-rw-r--r--Examples/d/simple/d2/runme.d27
-rw-r--r--Examples/d/simple/example.c18
-rw-r--r--Examples/d/simple/example.i7
-rw-r--r--Examples/d/variables/Makefile30
-rw-r--r--Examples/d/variables/d1/runme.d71
-rw-r--r--Examples/d/variables/d2/runme.d71
-rw-r--r--Examples/d/variables/example.c91
-rw-r--r--Examples/d/variables/example.h6
-rw-r--r--Examples/d/variables/example.i49
-rw-r--r--Examples/go/callback/example.go188
-rw-r--r--Examples/go/class/example.go284
-rw-r--r--Examples/go/constants/example.go44
-rw-r--r--Examples/go/enum/example.go93
-rw-r--r--Examples/go/extend/example.go397
-rw-r--r--Examples/go/funcptr/example.go54
-rw-r--r--Examples/go/multimap/example.go55
-rw-r--r--Examples/go/pointer/example.go68
-rw-r--r--Examples/go/reference/example.go126
-rw-r--r--Examples/go/simple/example.go48
-rw-r--r--Examples/go/template/example.go150
-rw-r--r--Examples/go/variables/example.go198
-rw-r--r--Examples/ocaml/argout_ref/example.i4
-rw-r--r--Examples/ocaml/shapes/example.c2
-rw-r--r--Examples/ocaml/shapes/example.h3
-rw-r--r--Examples/ocaml/std_string/README6
-rw-r--r--Examples/ocaml/strings_test/example.h18
-rw-r--r--Examples/php/cpointer/runme.php26
-rw-r--r--Examples/php/overloading/runme.php7
-rw-r--r--Examples/test-suite/abstract_virtual.i6
-rw-r--r--Examples/test-suite/char_binary.i29
-rw-r--r--Examples/test-suite/common.mk17
-rw-r--r--Examples/test-suite/constant_pointers.i5
-rw-r--r--Examples/test-suite/contract.i7
-rw-r--r--Examples/test-suite/csharp/Makefile.in7
-rw-r--r--Examples/test-suite/csharp/csharp_prepost_runme.cs37
-rw-r--r--Examples/test-suite/csharp/director_alternating_runme.cs11
-rw-r--r--Examples/test-suite/csharp/director_protected_runme.cs28
-rw-r--r--Examples/test-suite/csharp/pointer_reference_runme.cs3
-rw-r--r--Examples/test-suite/csharp/rename_pcre_encoder_runme.cs12
-rw-r--r--Examples/test-suite/csharp/rename_pcre_enum_runme.cs24
-rw-r--r--Examples/test-suite/csharp/rename_simple_runme.cs30
-rw-r--r--Examples/test-suite/csharp_attributes.i2
-rw-r--r--Examples/test-suite/csharp_prepost.i5
-rw-r--r--Examples/test-suite/d/Makefile.in81
-rw-r--r--Examples/test-suite/d/README7
-rw-r--r--Examples/test-suite/d/aggregate_runme.1.d25
-rw-r--r--Examples/test-suite/d/aggregate_runme.2.d25
-rw-r--r--Examples/test-suite/d/allprotected_runme.1.d65
-rw-r--r--Examples/test-suite/d/allprotected_runme.2.d65
-rw-r--r--Examples/test-suite/d/apply_strings_runme.1.d12
-rw-r--r--Examples/test-suite/d/apply_strings_runme.2.d12
-rw-r--r--Examples/test-suite/d/bools_runme.1.d20
-rw-r--r--Examples/test-suite/d/bools_runme.2.d20
-rw-r--r--Examples/test-suite/d/catches_runme.1.d33
-rw-r--r--Examples/test-suite/d/catches_runme.2.d33
-rw-r--r--Examples/test-suite/d/char_strings_runme.1.d151
-rw-r--r--Examples/test-suite/d/char_strings_runme.2.d123
-rw-r--r--Examples/test-suite/d/constover_runme.1.d31
-rw-r--r--Examples/test-suite/d/constover_runme.2.d16
-rw-r--r--Examples/test-suite/d/d_nativepointers_runme.1.d36
-rw-r--r--Examples/test-suite/d/d_nativepointers_runme.2.d36
-rw-r--r--Examples/test-suite/d/default_args_runme.1.d127
-rw-r--r--Examples/test-suite/d/default_args_runme.2.d84
-rw-r--r--Examples/test-suite/d/default_constructor_runme.1.d30
-rw-r--r--Examples/test-suite/d/default_constructor_runme.2.d25
-rw-r--r--Examples/test-suite/d/director_alternating_runme.1.d7
-rw-r--r--Examples/test-suite/d/director_alternating_runme.2.d7
-rw-r--r--Examples/test-suite/d/director_basic_runme.1.d59
-rw-r--r--Examples/test-suite/d/director_basic_runme.2.d46
-rw-r--r--Examples/test-suite/d/director_classes_runme.1.d168
-rw-r--r--Examples/test-suite/d/director_classes_runme.2.d169
-rw-r--r--Examples/test-suite/d/director_classic_runme.1.d207
-rw-r--r--Examples/test-suite/d/director_classic_runme.2.d202
-rw-r--r--Examples/test-suite/d/director_ignore_runme.1.d39
-rw-r--r--Examples/test-suite/d/director_ignore_runme.2.d38
-rw-r--r--Examples/test-suite/d/director_primitives_runme.1.d122
-rw-r--r--Examples/test-suite/d/director_primitives_runme.2.d123
-rw-r--r--Examples/test-suite/d/director_protected_runme.1.d50
-rw-r--r--Examples/test-suite/d/director_protected_runme.2.d36
-rw-r--r--Examples/test-suite/d/director_string_runme.1.d46
-rw-r--r--Examples/test-suite/d/director_string_runme.2.d42
-rw-r--r--Examples/test-suite/d/enum_thorough_runme.1.d424
-rw-r--r--Examples/test-suite/d/enum_thorough_runme.2.d425
-rw-r--r--Examples/test-suite/d/inherit_target_language_runme.1.d29
-rw-r--r--Examples/test-suite/d/inherit_target_language_runme.2.d29
-rw-r--r--Examples/test-suite/d/li_attribute_runme.1.d75
-rw-r--r--Examples/test-suite/d/li_attribute_runme.2.d58
-rw-r--r--Examples/test-suite/d/li_boost_shared_ptr_bits_runme.1.d21
-rw-r--r--Examples/test-suite/d/li_boost_shared_ptr_bits_runme.2.d19
-rw-r--r--Examples/test-suite/d/li_boost_shared_ptr_runme.1.d604
-rw-r--r--Examples/test-suite/d/li_boost_shared_ptr_runme.2.d602
-rw-r--r--Examples/test-suite/d/li_std_except_runme.1.d40
-rw-r--r--Examples/test-suite/d/li_std_except_runme.2.d34
-rw-r--r--Examples/test-suite/d/li_std_string_runme.1.d97
-rw-r--r--Examples/test-suite/d/li_std_string_runme.2.d86
-rw-r--r--Examples/test-suite/d/li_std_vector_runme.1.d219
-rw-r--r--Examples/test-suite/d/li_std_vector_runme.2.d207
-rw-r--r--Examples/test-suite/d/li_typemaps_runme.1.d94
-rw-r--r--Examples/test-suite/d/li_typemaps_runme.2.d91
-rw-r--r--Examples/test-suite/d/long_long_runme.1.d35
-rw-r--r--Examples/test-suite/d/long_long_runme.2.d32
-rw-r--r--Examples/test-suite/d/member_pointer_runme.1.d43
-rw-r--r--Examples/test-suite/d/member_pointer_runme.2.d42
-rw-r--r--Examples/test-suite/d/operator_overload_runme.1.d89
-rw-r--r--Examples/test-suite/d/operator_overload_runme.2.d91
-rw-r--r--Examples/test-suite/d/overload_complicated_runme.1.d50
-rw-r--r--Examples/test-suite/d/overload_complicated_runme.2.d34
-rw-r--r--Examples/test-suite/d/overload_template_runme.1.d146
-rw-r--r--Examples/test-suite/d/overload_template_runme.2.d80
-rw-r--r--Examples/test-suite/d/pointer_reference_runme.1.d13
-rw-r--r--Examples/test-suite/d/pointer_reference_runme.2.d14
-rw-r--r--Examples/test-suite/d/preproc_constants_c_runme.1.d63
-rw-r--r--Examples/test-suite/d/preproc_constants_c_runme.2.d63
-rw-r--r--Examples/test-suite/d/preproc_constants_runme.1.d62
-rw-r--r--Examples/test-suite/d/preproc_constants_runme.2.d62
-rw-r--r--Examples/test-suite/d/sizet_runme.1.d15
-rw-r--r--Examples/test-suite/d/sizet_runme.2.d14
-rw-r--r--Examples/test-suite/d/sneaky1_runme.1.d21
-rw-r--r--Examples/test-suite/d/sneaky1_runme.2.d11
-rw-r--r--Examples/test-suite/d/special_variable_macros_runme.1.d39
-rw-r--r--Examples/test-suite/d/special_variable_macros_runme.2.d21
-rw-r--r--Examples/test-suite/d/threads_runme.1.d70
-rw-r--r--Examples/test-suite/d/threads_runme.2.d55
-rw-r--r--Examples/test-suite/d/throw_exception_runme.1.d30
-rw-r--r--Examples/test-suite/d/throw_exception_runme.2.d30
-rw-r--r--Examples/test-suite/d/typemap_namespace_runme.1.d13
-rw-r--r--Examples/test-suite/d/typemap_namespace_runme.2.d9
-rw-r--r--Examples/test-suite/d/typemap_out_optimal_runme.1.d9
-rw-r--r--Examples/test-suite/d/typemap_out_optimal_runme.2.d9
-rw-r--r--Examples/test-suite/d/varargs_runme.1.d20
-rw-r--r--Examples/test-suite/d/varargs_runme.2.d13
-rw-r--r--Examples/test-suite/d/virtual_poly_runme.1.d27
-rw-r--r--Examples/test-suite/d/virtual_poly_runme.2.d22
-rw-r--r--Examples/test-suite/d_exception_name.i15
-rw-r--r--Examples/test-suite/d_nativepointers.i21
-rw-r--r--Examples/test-suite/default_constructor.i6
-rw-r--r--Examples/test-suite/director_alternating.i36
-rw-r--r--Examples/test-suite/director_keywords.i13
-rw-r--r--Examples/test-suite/director_protected.i13
-rw-r--r--Examples/test-suite/director_using.i15
-rw-r--r--Examples/test-suite/dynamic_cast.i13
-rw-r--r--Examples/test-suite/enum_rename.i2
-rw-r--r--Examples/test-suite/enums.i5
-rw-r--r--Examples/test-suite/errors/cpp_inherit.i47
-rw-r--r--Examples/test-suite/errors/cpp_macro_locator.i103
-rw-r--r--Examples/test-suite/errors/cpp_recursive_typedef.i4
-rw-r--r--Examples/test-suite/errors/cpp_shared_ptr.i29
-rw-r--r--Examples/test-suite/errors/expected.log314
-rwxr-xr-xExamples/test-suite/errors/make.sh19
-rw-r--r--Examples/test-suite/errors/pp_constant.i50
-rw-r--r--Examples/test-suite/errors/pp_deprecated.i9
-rw-r--r--Examples/test-suite/errors/pp_illegal_argument.i20
-rw-r--r--Examples/test-suite/errors/pp_macro_defined_unterminated.i6
-rw-r--r--Examples/test-suite/errors/pp_macro_expansion.i10
-rw-r--r--Examples/test-suite/errors/pp_macro_expansion_multiline.i32
-rw-r--r--Examples/test-suite/errors/pp_macro_inline_unterminated.i11
-rw-r--r--Examples/test-suite/errors/pp_pragma.i6
-rw-r--r--Examples/test-suite/errors/pp_variable_args.i10
-rw-r--r--Examples/test-suite/evil_diamond.i3
-rw-r--r--Examples/test-suite/evil_diamond_ns.i3
-rw-r--r--Examples/test-suite/evil_diamond_prop.i1
-rw-r--r--Examples/test-suite/exception_order.i20
-rw-r--r--Examples/test-suite/global_namespace.i22
-rw-r--r--Examples/test-suite/go/char_binary_runme.go25
-rw-r--r--Examples/test-suite/guilescm/ext_test_external.cxx2
-rw-r--r--Examples/test-suite/immutable_values.i (renamed from Examples/test-suite/immutable.i)2
-rw-r--r--Examples/test-suite/import_nomodule.i8
-rw-r--r--Examples/test-suite/inherit_target_language.i8
-rw-r--r--Examples/test-suite/java/Makefile.in4
-rw-r--r--Examples/test-suite/java/char_binary_runme.java24
-rw-r--r--Examples/test-suite/java/director_protected_runme.java32
-rw-r--r--Examples/test-suite/java/global_namespace_runme.java34
-rw-r--r--Examples/test-suite/java/pointer_reference_runme.java3
-rw-r--r--Examples/test-suite/java/preproc_line_file_runme.java68
-rw-r--r--Examples/test-suite/java/rename_pcre_encoder_runme.java14
-rw-r--r--Examples/test-suite/java/rename_pcre_enum_runme.java26
-rw-r--r--Examples/test-suite/java/rname_runme.java2
-rw-r--r--Examples/test-suite/java/smart_pointer_const_overload_runme.java99
-rw-r--r--Examples/test-suite/java/typemap_arrays_runme.java19
-rw-r--r--Examples/test-suite/java/wallkw_runme.java4
-rw-r--r--Examples/test-suite/li_boost_shared_ptr.i3
-rw-r--r--Examples/test-suite/li_boost_shared_ptr_bits.i2
-rw-r--r--Examples/test-suite/li_std_combinations.i2
-rw-r--r--Examples/test-suite/li_typemaps_apply.i46
-rw-r--r--Examples/test-suite/lua/pointer_reference_runme.lua2
-rw-r--r--Examples/test-suite/member_funcptr_galore.i83
-rw-r--r--Examples/test-suite/minherit2.i29
-rw-r--r--Examples/test-suite/multiple_inheritance.i6
-rw-r--r--Examples/test-suite/namespace_class.i4
-rw-r--r--Examples/test-suite/octave/primitive_types_runme.m402
-rw-r--r--Examples/test-suite/octave/samename_runme.m (renamed from Examples/test-suite/samename_runme.m)0
-rw-r--r--Examples/test-suite/operator_overload.i6
-rw-r--r--Examples/test-suite/operator_overload_break.i2
-rw-r--r--Examples/test-suite/operbool.i2
-rwxr-xr-xExamples/test-suite/perl5/char_binary_runme.pl32
-rwxr-xr-xExamples/test-suite/perl5/primitive_types_runme.pl9
-rw-r--r--Examples/test-suite/php/director_protected_runme.php21
-rw-r--r--Examples/test-suite/php/pointer_reference_runme.php3
-rw-r--r--Examples/test-suite/pointer_reference.i6
-rw-r--r--Examples/test-suite/preproc_defined.i108
-rw-r--r--Examples/test-suite/preproc_include.i18
-rw-r--r--Examples/test-suite/preproc_include_a.h3
-rw-r--r--Examples/test-suite/preproc_include_b.h7
-rw-r--r--Examples/test-suite/preproc_include_c.h3
-rw-r--r--Examples/test-suite/preproc_line_file.i95
-rw-r--r--Examples/test-suite/primitive_types.i9
-rw-r--r--Examples/test-suite/pure_virtual.i5
-rw-r--r--Examples/test-suite/python/Makefile.in2
-rw-r--r--Examples/test-suite/python/char_binary_runme.py36
-rw-r--r--Examples/test-suite/python/director_alternating_runme.py5
-rw-r--r--Examples/test-suite/python/director_protected_runme.py43
-rw-r--r--Examples/test-suite/python/global_namespace_runme.py40
-rw-r--r--Examples/test-suite/python/pointer_reference_runme.py16
-rw-r--r--Examples/test-suite/python/preproc_defined_runme.py11
-rw-r--r--Examples/test-suite/python/preproc_include_runme.py11
-rw-r--r--Examples/test-suite/python/primitive_types_runme.py11
-rw-r--r--Examples/test-suite/python/rename_pcre_encoder_runme.py13
-rw-r--r--Examples/test-suite/python/smart_pointer_const_overload_runme.py123
-rw-r--r--Examples/test-suite/python/typemap_arrays_runme.py5
-rw-r--r--Examples/test-suite/r/rename_simple_runme.R20
-rw-r--r--Examples/test-suite/r/unittest.R18
-rw-r--r--Examples/test-suite/rename_camel.i4
-rw-r--r--Examples/test-suite/rename_pcre_encoder.i31
-rw-r--r--Examples/test-suite/rename_pcre_enum.i49
-rw-r--r--Examples/test-suite/rename_simple.i24
-rw-r--r--Examples/test-suite/restrict_cplusplus.i10
-rw-r--r--Examples/test-suite/return_const_value.i1
-rw-r--r--Examples/test-suite/rname.i19
-rw-r--r--Examples/test-suite/samename.i2
-rw-r--r--Examples/test-suite/smart_pointer_const_overload.i74
-rw-r--r--Examples/test-suite/smart_pointer_templatemethods.i13
-rw-r--r--Examples/test-suite/special_variable_macros.i14
-rw-r--r--Examples/test-suite/static_const_member.i3
-rw-r--r--Examples/test-suite/template_basic.i (renamed from Examples/test-suite/template.i)6
-rw-r--r--Examples/test-suite/template_enum.i4
-rw-r--r--Examples/test-suite/template_inherit_abstract.i5
-rw-r--r--[-rwxr-xr-x]Examples/test-suite/threads_exception.i0
-rw-r--r--Examples/test-suite/typemap_arrays.i30
-rw-r--r--Examples/test-suite/typemap_namespace.i9
-rw-r--r--Examples/test-suite/typemap_out_optimal.i6
-rw-r--r--Examples/test-suite/typemap_subst.i4
-rw-r--r--Examples/test-suite/using_composition.i9
-rw-r--r--Examples/test-suite/using_extend.i3
-rw-r--r--Examples/test-suite/using_namespace.i3
-rw-r--r--Examples/test-suite/using_protected.i17
-rw-r--r--Examples/test-suite/varargs.i3
-rw-r--r--Examples/test-suite/wallkw.i4
-rw-r--r--Examples/test-suite/wrapmacro.i2
-rw-r--r--Lib/allkw.swg1
-rw-r--r--Lib/chicken/chicken.swg2
-rw-r--r--Lib/csharp/std_map.i24
-rw-r--r--Lib/csharp/typemaps.i21
-rw-r--r--Lib/csharp/wchar.i204
-rw-r--r--Lib/d/boost_shared_ptr.i201
-rw-r--r--Lib/d/carrays.i111
-rw-r--r--Lib/d/cpointer.i171
-rw-r--r--Lib/d/d.swg46
-rw-r--r--Lib/d/dclassgen.swg142
-rw-r--r--Lib/d/ddirectives.swg10
-rw-r--r--Lib/d/denums.swg60
-rw-r--r--Lib/d/dexception.swg30
-rw-r--r--Lib/d/dhead.swg310
-rw-r--r--Lib/d/director.swg46
-rw-r--r--Lib/d/dkw.swg126
-rw-r--r--Lib/d/dmemberfunctionpointers.swg92
-rw-r--r--Lib/d/doperators.swg259
-rw-r--r--Lib/d/dprimitives.swg158
-rw-r--r--Lib/d/dstrings.swg80
-rw-r--r--Lib/d/dswigtype.swg184
-rw-r--r--Lib/d/dvoid.swg18
-rw-r--r--Lib/d/std_common.i5
-rw-r--r--Lib/d/std_deque.i1
-rw-r--r--Lib/d/std_except.i30
-rw-r--r--Lib/d/std_map.i59
-rw-r--r--Lib/d/std_pair.i34
-rw-r--r--Lib/d/std_shared_ptr.i2
-rw-r--r--Lib/d/std_string.i98
-rw-r--r--Lib/d/std_vector.i591
-rw-r--r--Lib/d/stl.i12
-rw-r--r--Lib/d/typemaps.i298
-rw-r--r--Lib/d/wrapperloader.swg308
-rw-r--r--Lib/exception.i36
-rw-r--r--Lib/go/cdata.i79
-rw-r--r--Lib/go/go.swg41
-rw-r--r--Lib/go/goruntime.swg150
-rw-r--r--Lib/guile/typemaps.i2
-rw-r--r--Lib/java/java.swg15
-rw-r--r--Lib/ocaml/std_string.i180
-rw-r--r--Lib/ocaml/swigp4.ml.in249
-rw-r--r--Lib/ocaml/typemaps.i11
-rw-r--r--Lib/octave/octcontainer.swg3
-rw-r--r--Lib/perl5/perlprimtypes.swg4
-rw-r--r--Lib/php/php.swg19
-rw-r--r--Lib/pike/pike.swg2
-rw-r--r--Lib/python/pycontainer.swg3
-rw-r--r--Lib/python/pyrun.swg6
-rw-r--r--Lib/ruby/rubycontainer.swg3
-rw-r--r--Lib/ruby/rubyerrors.swg2
-rw-r--r--Lib/ruby/timeval.i5
-rw-r--r--Lib/std_except.i2
-rw-r--r--Lib/swig.swg5
-rw-r--r--Lib/typemaps/strings.swg2
-rw-r--r--Lib/typemaps/swigtype.swg2
-rw-r--r--Makefile.in21
-rw-r--r--README15
-rw-r--r--RELEASENOTES9
-rw-r--r--Source/CParse/cscanner.c105
-rw-r--r--Source/CParse/parser.y45
-rw-r--r--Source/DOH/base.c2
-rw-r--r--Source/DOH/doh.h12
-rw-r--r--Source/DOH/dohint.h4
-rw-r--r--Source/DOH/file.c2
-rw-r--r--Source/DOH/hash.c55
-rw-r--r--Source/DOH/list.c2
-rw-r--r--Source/DOH/string.c70
-rw-r--r--Source/Include/swigwarn.h32
-rw-r--r--Source/Makefile.am1
-rw-r--r--Source/Modules/allocate.cxx8
-rw-r--r--Source/Modules/clisp.cxx16
-rw-r--r--Source/Modules/csharp.cxx82
-rw-r--r--Source/Modules/d.cxx4351
-rw-r--r--Source/Modules/go.cxx59
-rw-r--r--Source/Modules/java.cxx32
-rw-r--r--Source/Modules/lang.cxx36
-rw-r--r--Source/Modules/lua.cxx2
-rw-r--r--Source/Modules/main.cxx16
-rw-r--r--Source/Modules/modula3.cxx11
-rw-r--r--Source/Modules/mzscheme.cxx2
-rw-r--r--Source/Modules/ocaml.cxx45
-rw-r--r--Source/Modules/php.cxx21
-rw-r--r--Source/Modules/python.cxx6
-rw-r--r--Source/Modules/r.cxx17
-rw-r--r--Source/Modules/ruby.cxx13
-rw-r--r--Source/Modules/swigmain.cxx2
-rw-r--r--Source/Modules/swigmod.h11
-rw-r--r--Source/Modules/tcl8.cxx5
-rw-r--r--Source/Modules/typepass.cxx23
-rw-r--r--Source/Modules/utils.cxx113
-rw-r--r--Source/Preprocessor/cpp.c321
-rw-r--r--Source/Swig/cwrap.c42
-rw-r--r--Source/Swig/error.c35
-rw-r--r--Source/Swig/include.c2
-rw-r--r--Source/Swig/misc.c219
-rw-r--r--Source/Swig/naming.c111
-rw-r--r--Source/Swig/scanner.c159
-rw-r--r--Source/Swig/stype.c209
-rw-r--r--Source/Swig/swig.h93
-rw-r--r--Source/Swig/swigscan.h2
-rw-r--r--Source/Swig/symbol.c2
-rw-r--r--Source/Swig/tree.c8
-rw-r--r--Source/Swig/typemap.c20
-rw-r--r--Source/Swig/typeobj.c30
-rw-r--r--Source/Swig/typesys.c37
-rw-r--r--Tools/config/ax_boost_base.m4258
-rw-r--r--Tools/config/ax_compare_version.m4177
-rw-r--r--Tools/config/ax_path_generic.m4142
-rwxr-xr-xTools/mkwindows.sh14
-rwxr-xr-xTools/pcre-build.sh53
-rw-r--r--Tools/swig.gdb41
-rw-r--r--configure.in203
439 files changed, 24100 insertions, 4529 deletions
diff --git a/ANNOUNCE b/ANNOUNCE
index ad3e8f8d6..cdf246e07 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,4 +1,4 @@
-*** ANNOUNCE: SWIG 2.0.1 (in progress) ***
+*** ANNOUNCE: SWIG 2.0.2 (in progress) ***
http://www.swig.org
diff --git a/CHANGES b/CHANGES
index f243ff7c6..bf5e20da1 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,195 @@ 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 2.0.1 (4 October 2010)
+==============================
+
+2010-10-03: wsfulton
+ Apply patch #3066958 from Mikael Johansson to fix default smart pointer
+ handling when the smart pointer contains both a const and non-const operator->.
+
+2010-10-01: wsfulton
+ Add -pcreversion option to display PCRE version information.
+
+2010-10-01: olly
+ [Ruby] Avoid segfault when a method node has no parentNode
+ (SF#3034054).
+
+2010-10-01: olly
+ [Python] Allow reinitialisation to work with an embedded Python
+ interpreter (patch from Jim Carroll in SF#3075178).
+
+2010-09-28: wsfulton
+ [C#] Apply patch from Tomas Dirvanauskas for std::map wrappers to avoid
+ throwing exceptions with normal usage of iterators.
+
+2010-09-27: olly
+ [Python] Improve error message given when a parameter of the wrong
+ type is passed to an overloaded method (SF#3027355).
+
+2010-09-25: wsfulton
+ Apply SF patch #3075150 - Java directors using static variables in
+ named namespace.
+
+2010-09-24: wsfulton
+ More file and line error/warning reporting fixes where SWIG macros
+ are used within {} braces (where the preprocessor expands macros),
+ for example macros within %inline {...} and %fragment(...) {...}
+ and nested structs.
+
+2010-09-18: wsfulton
+ More file and line error/warning reporting fixes for various inherited
+ class problems.
+
+2010-09-15: wsfulton
+ A much improved debugging of SWIG source experience is now available and
+ documented in the "Debugging SWIG" section in the Doc/Devel/internals.html
+ file, including a swig.dbg support file for the gdb debugger.
+
+2010-09-11: wsfulton
+ Fix incorrect line number reporting in errors/warnings when a macro
+ definition ends with '/' and it is not the end of a C comment.
+
+2010-09-11: wsfulton
+ Fix incorrect line number reporting in errors/warnings after parsing
+ macro invocations with parameters given over more than one line.
+
+2010-09-10: wsfulton
+ Remove extraneous extra line in preprocessed output after including files
+ which would sometimes lead to error/warning messages two lines after the
+ end of the file.
+
+2010-09-10: wsfulton
+ Fix #2149523 - Incorrect line number reporting in errors after parsing macros
+ containing C++ comments.
+
+2010-09-08: olly
+ [PHP] Fix handling of OUTPUT typemaps (Patch from Ryan in SF#3058394).
+
+2010-09-03: wsfulton
+ Fix erroneous line numbers in error messages for macro expansions, for example,
+ the error message now points to instantiation of the macro, ie the last line here:
+
+ #define MACRO2(a, b)
+
+ #define MACRO1(NAME) MACRO2(NAME,2,3)
+
+ MACRO1(abc)
+
+2010-09-02: wsfulton
+ Fix line numbers in error and warning messages for preprocessor messages within
+ %inline, for example:
+
+ %inline %{
+ #define FOOBAR 1
+ #define FOOBAR "hi"
+ %}
+
+2010-09-02: wsfulton
+ Fix line numbers in error and warning messages which were cumulatively one
+ less than they should have been after parsing each %include/%import - bug
+ introduced in swig-1.3.32. Also fix line numbers in error and warning messages
+ when new line characters appear between the %include / %import statement and
+ the filename.
+
+2010-08-30: wsfulton
+ Fix line number and file name reporting for some macro preprocessor warnings.
+ The line number of the macro argument has been corrected and the line number
+ of the start of the macro instead of one past the end of the macro is used.
+ Some examples:
+ file.h:11: Error: Illegal macro argument name '..'
+ file.h:19: Error: Macro 'DUPLICATE' redefined,
+ file.h:15: Error: previous definition of 'DUPLICATE'.
+ file.h:25: Error: Variable-length macro argument must be last parameter
+ file.h:32: Error: Illegal character in macro argument name
+ file.i:37: Error: Macro 'SIT' expects 2 arguments
+
+2010-08-26: wsfulton
+ Fix __LINE__ and __FILE__ expansion reported by Camille Gillot. Mostly this
+ did not work at all. Also fixes SF #2822822.
+
+2010-08-17: wsfulton
+ [Perl] Fix corner case marshalling of doubles - errno was not being correctly
+ set before calling strtod - patch from Justin Vallon - SF Bug #3038936.
+
+2010-08-17: wsfulton
+ Fix make distclean when some of the more obscure languages are detected by
+ configure - fixes from Torsten Landschoff.
+
+2010-07-28: wsfulton
+ Restore configuring out of source for the test-suite since it broke in 1.3.37.
+ As previously, if running 'make check-test-suite' out of source, it needs to be
+ done by invoking configure with a relative path. Invoking configure with an
+ absolute path will not work. Running the full 'make check' still needs to be
+ done in the source tree.
+
+2010-07-16: wsfulton
+ Fix wrapping of function pointers and member function pointers when the function
+ returns by reference.
+
+2010-07-13: vadz
+ Removed support for the old experimental "rxspencer" encoder and
+ "[not]rxsmatch" in %rename (see the 01/16/2006 entry). The new and
+ officially supported "regex" encoder and "[not]regexmatch" checks
+ should be used instead (see the two previous entries). Please
+ replace "%(rxspencer:[pat][subst])s" with "%(regex:/pat/subst/)s"
+ when upgrading. Notice that you will also need to replace the back-
+ references of form "@1" with the more standard "\\1" and may need to
+ adjust your regular expressions syntax as the new regex encoder uses
+ Perl-compatible syntax and not (extended) POSIX syntax as the old one.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2010-07-13: vadz
+ Add "regexmatch", "regextarget" and "notregexmatch" which can be
+ used to apply %rename directives to the declarations matching the
+ specified regular expression only. The first two can be used
+ interchangeably, both of the %renames below do the same thing:
+
+ %rename("$ignore", regexmatch$name="Old$") "";
+ %rename("$ignore", regextarget=1) "Old$";
+
+ (namely ignore the declarations having "Old" suffix).
+
+ "notregexmatch" restricts the match to only the declarations which
+ do not match the regular expression, e.g. here is how to rename to
+ lower case versions all declarations except those consisting from
+ capital letters only:
+
+ %rename("$(lowercase)s", notregexmatch$name="^[A-Z]+$") "";
+
+2010-07-13: vadz
+ Add the new "regex" encoder that can be used in %rename, e.g.
+
+ %rename("regex:/(\\w+)_(.*)/\\2/") "";
+
+ to remove any alphabetical prefix from all identifiers. The syntax
+ of the regular expressions is Perl-like and PCRE library
+ (http://www.pcre.org/) is used to implement this feature but notice
+ that backslashes need to be escaped as usual inside C strings.
+
+ Original patch from Torsten Landschoff.
+
+2010-07-08: wsfulton
+ Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes
+ the "unref" feature when used on classes with non-public destructors.
+
+2010-06-17: ianlancetaylor
+ [Go] Add the Go language module.
+
+2010-06-10: wsfulton
+ [Lua] Fix SWIG_lua_isnilstring multiply defined when using multiple
+ modules and wrapping strings. Patch from 'Number Cruncher'.
+
+2010-06-10: olly
+ [PHP] Fix directors to correctly call a method with has a
+ different name in PHP to C++ (we were always using the C++ name
+ in this case).
+
+2010-06-03: wsfulton
+ Fix uncompileable code when %rename results in two enum items
+ with the same name. Reported by Vadim Zeitlin.
+
Version 2.0.0 (2 June 2010)
===========================
diff --git a/CHANGES.current b/CHANGES.current
index 63af7206d..8ae8b784f 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -2,26 +2,128 @@ This file contains 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 2.0.1 (in progress)
+Version 2.0.2 (in progress)
===========================
-2010-07-16: wsfulton
- Fix wrapping of function pointers and member function pointers when the function
- returns by reference.
+2011-02-13: wsfulton
+ [Ruby] Apply patch #3176274 from James Masters - typecheck typemap for time_t.
-2010-07-08: wsfulton
- Fix #3024875 - shared_ptr of classes with non-public destructors. This also fixes
- the "unref" feature when used on classes with non-public destructors.
+2011-02-13: wsfulton
+ Apply patch #3171793 from szager - protected director methods failing when -fvirtual is used.
-2010-06-10: wsfulton
- [Lua] Fix SWIG_lua_isnilstring multiply defined when using multiple
- modules and wrapping strings. Patch from 'Number Cruncher'.
+2011-02-13: wsfulton
+ Fix #1927852 - #include directives don't preprocess the file passed to it. The fix is for
+ #include with -importall or -includeall, %include and %import, for example:
+ #define FILENAME "abc.h"
+ %include FILENAME
-2010-06-10: olly
- [PHP] Fix directors to correctly call a method with has a
- different name in PHP to C++ (we were always using the C++ name
- in this case).
+2011-02-12: wsfulton
+ Fix #1940536, overactive preprocessor which was expanding defined(...) outside of #if and #elif
+ preprocessor directives.
-2010-06-03: wsfulton
- Fix uncompileable code when %rename results in two enum items
- with the same name. Reported by Vadim Zeitlin.
+2011-02-05: wsfulton
+ [MzScheme] SF #2942899 Add user supplied documentation to help getting started with MzScheme.
+ Update chapter name to MzScheme/Racket accounting for the rename of MzScheme to Racket.
+
+2011-02-05: wsfulton
+ [C#] SF #3085906 - Possible fix running test-suite on Mac OSX.
+
+2011-02-05: wsfulton
+ SF #3173367 Better information during configure about Boost prerequisite for running
+ the test-suite.
+
+2011-02-05: wsfulton
+ SF #3127633 Fix infinite loop in recursive typedef resolution.
+
+2011-02-04: wsfulton
+ [R] SF #3168676 Fix %rename not working for member variables and methods.
+
+2011-02-04: wsfulton
+ [PHP] SF #3166423 Recent PHP versions no longer define zend_error_noreturn - calls to this
+ have been replaced with zend_error.
+
+2011-02-04: wsfulton
+ [clisp] SF #3148200 Fix segfault parsing nested unions.
+
+2011-02-01: wsfulton
+ [C#] Directors - a call to a method being defined in the base class, not
+ overridden in a subclass, but again overridden in a class derived from
+ the first subclass was not being dispatched correctly to the most derived class.
+ See director_alternating.i for an example.
+
+2011-02-01: wsfulton
+ [C#, Java] Any 'using' statements in the protected section of a class were previously
+ ignored with director protected (dirprot) mode.
+
+2011-01-30: wsfulton
+ Fix overloading with const pointer reference (SWIGTYPE *const&) parameters for a
+ number of scripting languages.
+
+2011-01-17: wsfulton
+ New warning for smart pointers if only some of the classes in the inheritance
+ chain are marked as smart pointer, eg, %shared_ptr should be used for all classes
+ in an inheritance hierarchy, so this new warning highlights code where this is
+ not the case.
+
+ example.i:12: Warning 520: Base class 'A' of 'B' is not similarly marked as a smart pointer.
+ example.i:16: Warning 520: Derived class 'C' of 'B' is not similarly marked as a smart pointer.
+
+2011-01-14: wsfulton
+ Added some missing multi-argument typemaps: (char *STRING, size_t LENGTH) and
+ (char *STRING, int LENGTH). Documentation for this updated. Java patch from
+ Volker Grabsch.
+
+2011-01-11: iant
+ Require Go version 7077 or later.
+
+2010-12-30: klickverbot
+ [C#, D, Java] Check for collision of parameter names with target
+ language keywords when generating the director glue code.
+
+ The situation in which the generated could would previously be
+ invalid is illustrated in the new 'director_keywords' test case.
+
+2010-12-23: wsfulton
+ [C#] Fix $csinput special variable not being expanded for csvarin typemaps
+ when used for global variables. Reported by Vadim Zeitlin.
+
+2010-12-14: wsfulton
+ Fix $basemangle expansion in array typemaps. For example if type is int *[3],
+ $basemangle expands to _p_int.
+
+2010-12-07: iant
+ Check that we are using a sufficiently new version of the
+ 6g or 8g Go compiler during configure time. If not, disable Go.
+ Minimum version is now 6707.
+
+ *** POTENTIAL INCOMPATIBILITY ***
+
+2010-12-06: wsfulton
+ Fix #3127394 - use of network paths on Windows/MSys.
+
+2010-11-18: klickverbot
+ [D] Added the D language module.
+
+2010-11-12: vadz
+ Fix handling of multiple regex-using %renames attached to the same
+ declaration. For example, now
+
+ %rename("%(regex/^Set(.*)/put\\1/)s") "";
+ %rename("%(regex/^Get(.*)/get\\1/)s") "";
+
+ works as expected whereas before only the last anonymous rename was
+ taken into account.
+
+2010-10-17: drjoe
+ [R] Fix failure in overloaded functions which was breaking
+ QuantLib-SWIG
+
+2010-10-14: olly
+ [PHP] Allow compilation on non-conforming Microsoft C++ compilers
+ which don't accept: return function_returning_void();
+ Reported by Frank Vanden Berghen on the SWIG mailing list.
+
+2010-10-12: wsfulton
+ Fix unary scope operator (::) (global scope) regression introduced in 2.0.0, reported by
+ Ben Walker. The mangled symbol names were incorrect, sometimes resulting in types being
+ incorrectly treated as opaque types.
diff --git a/COPYRIGHT b/COPYRIGHT
index 40d09a1d6..1e5d080d4 100644
--- a/COPYRIGHT
+++ b/COPYRIGHT
@@ -42,7 +42,7 @@ Past SWIG developers and major contributors include:
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)
+ Ahmon Dancy (dancy@franz.com) (Allegro CL)
Dirk Gerrits (Allegro CL)
Neil Cawse (C#)
Harco de Hilster (Java)
@@ -55,6 +55,8 @@ Past SWIG developers and major contributors include:
Mark Gossage (mark@gossage.cjb.net) (Lua)
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)
Past contributors include:
James Michael DuPont, Clark McGrew, Dustin Mitchell, Ian Cooke, Catalin Dumitrescu, Baran
diff --git a/Doc/Devel/index.html b/Doc/Devel/index.html
index 55c612ec3..4ddc63a76 100644
--- a/Doc/Devel/index.html
+++ b/Doc/Devel/index.html
@@ -21,6 +21,7 @@ The following documentation describe the internal APIs used by SWIG. These may
<li><a href="parm.html">Parameter and Parameter list handling functions</a>
<li><a href="scanner.html">Generic C/C++ Scanner interface</a>
<li><a href="wrapobj.html">Wrapper objects</a>.
+<li><a href="runtime.txt">SWIG Runtime</a>.
</ul>
<hr>
diff --git a/Doc/Devel/internals.html b/Doc/Devel/internals.html
index 6ac3947f7..d24869d10 100644
--- a/Doc/Devel/internals.html
+++ b/Doc/Devel/internals.html
@@ -7,11 +7,6 @@
<center>
<h1>SWIG Internals Manual</h1>
-<b>Thien-Thi Nguyen <br>
-
-<p>
-David M. Beazley <br>
-
</b>
</center>
@@ -45,6 +40,9 @@ David M. Beazley <br>
<li><a name="i5" href="#5">5. C/C++ Wrapper Support Functions</a>
<li><a name="i6" href="#6">6. Symbol Naming Guidelines for Generated C/C++ Code</a>
<li><a name="i7" href="#7">7. Debugging SWIG</a>
+<ul>
+<li><a name="i7.1" href="#7.1">7.1 Debugging DOH Types The Hard Way</a>
+</ul>
</ul>
<a name="1" href="#i1">
@@ -1015,15 +1013,139 @@ In the past SWIG has generated many symbols which flout the standard especially
<a name="7" href="#i7">
<h2>7. Debugging SWIG</h2>
</a>
-Warning. Debugging SWIG is for the very patient.
+
+<p>
+The DOH types used in the SWIG source code are all typedefined to void.
+Consequently, it is impossible for debuggers to automatically extract any information about DOH objects.
+The easiest approach to debugging and viewing the contents of DOH objects is to make a call into one of the family of SWIG print functions from the debugger.
+The "Debugging Functions" section in <a href="tree.html">SWIG Parse Tree Handling</a> lists them.
+It is sometimes easier to debug by placing a few calls to these functions in code of interest and recompile, especially if your debugger cannot easily make calls into functions within a debugged binary.
+</p>
+
+<p>
+The SWIG distribution comes with some additional support for the gdb debugger in the <tt>Tools/swig.gdb</tt> file.
+Follow the instructions in this file for 'installing'.
+This support file provides an easy way to call into some of the family of SWIG print functions via additional user-defined gdb commands.
+Some usage of the <tt>swigprint</tt> and <tt>locswigprint</tt> user-defined commands are demonstrated below.
+</p>
+
+<p>
+More often than not, a parse tree node needs to be examined.
+The session below displays the node <tt>n</tt> in one of the Java language module wrapper functions.
+The <tt>swigprint</tt> method is used to show the symbol name (<tt>symname</tt> - a DOH String type) and the node (<tt>n</tt> - a DOH Hash type).
+</p>
+<blockquote>
+<pre>
+Breakpoint 1, JAVA::functionWrapper (this=0x97ea5f0, n=0xb7d2afc8) at Modules/java.cxx:799
+799 String *symname = Getattr(n, "sym:name");
+(gdb) next
+800 SwigType *t = Getattr(n, "type");
+(gdb) swigprint symname
+Shape_x_set
+(gdb) swigprint n
+Hash(0xb7d2afc8) {
+ 'membervariableHandler:view' : variableHandler,
+ 'feature:except' : 0,
+ 'name' : x,
+ 'ismember' : 1,
+ 'sym:symtab' : Hash(0xb7d2aca8) {......},
+ 'nodeType' : cdecl,
+ 'nextSibling' : Hash(0xb7d2af98) {.............},
+ 'kind' : variable,
+ 'variableHandler:feature:immutable' : &lt;Object 'VoidObj' at 0xb7cfa008&gt;,
+ 'sym:name' : Shape_x_set,
+ 'view' : membervariableHandler,
+ 'membervariableHandler:sym:name' : x,
+ 'membervariableHandler:type' : double,
+ 'membervariableHandler:parms' : &lt;Object 'VoidObj' at 0xb7cfa008&gt;,
+ 'parentNode' : Hash(0xb7d2abc8) {..............................},
+ 'feature:java:enum' : typesafe,
+ 'access' : public,
+ 'parms' : Hash(0xb7cb9408) {......},
+ 'wrap:action' : if (arg1) (arg1)-&gt;x = arg2;,
+ 'type' : void,
+ 'memberset' : 1,
+ 'sym:overname' : __SWIG_0,
+ 'membervariableHandler:name' : x,
+}
+</pre>
+</blockquote>
+
<p>
+Note that all the attributes in the Hash are shown, including the 'sym:name' attribute which was assigned to the <tt>symname</tt> variable.
+</p>
-The DOH types are all typedefined to void.
-Consequently, it is impossible for debuggers to extract any information about DOH objects.
-Most debuggers will be able to display useful variable information when an object is cast to the appropriate type.
-Below are some tips for displaying some of the DOH objects.
-Be sure to compile with compiler optimisations turned off before attempting the casts shown in a debugger window else they are unlikely to work.
-Even displaying the underlying string in a String* doesn't work straight off in all debuggers due to the multiple definition of String as a struct and a void.
+<p>
+Hash types can be shown either expanded or collapsed.
+When a Hash is shown expanded, all the attributes are displayed along with their values, otherwise a '.' replaces each attribute when collapsed.
+Therefore a count of the dots provides the number of attributes within an unexpanded Hash.
+Below shows the 'parms' Hash being displayed with the default Hash expansion of 1, then with 2 provided as the second argument to <tt>swigprint</tt> to expand to two Hash levels in order to view the contents of the collapsed 'nextSibling' Hash.
+</p>
+
+<blockquote>
+<pre>
+(gdb) swigprint 0xb7cb9408
+Hash(0xb7cb9408) {
+ 'name' : self,
+ 'type' : p.Shape,
+ 'self' : 1,
+ 'nextSibling' : Hash(0xb7cb9498) {...},
+ 'hidden' : 1,
+ 'nodeType' : parm,
+}
+(gdb) swigprint 0xb7cb9408 2
+Hash(0xb7cb9408) {
+ 'name' : self,
+ 'type' : p.Shape,
+ 'self' : 1,
+ 'nextSibling' : Hash(0xb7cb9498) {
+ 'name' : x,
+ 'type' : double,
+ 'nodeType' : parm,
+ },
+ 'hidden' : 1,
+ 'nodeType' : parm,
+}
+</pre>
+</blockquote>
+
+<p>
+The same Hash can also be displayed with file and line location information via the <tt>locswigprint</tt> command.
+</p>
+
+<blockquote>
+<pre>
+(gdb) locswigprint 0xb7cb9408
+example.h:11: [Hash(0xb7cb9408) {
+Hash(0xb7cb9408) {
+ 'name' : self,
+ 'type' : p.Shape,
+ 'self' : 1,
+ 'nextSibling' : Hash(0xb7cb9498) {...},
+ 'hidden' : 1,
+ 'nodeType' : parm,
+}]
+</pre>
+</blockquote>
+
+<p>
+<b>Tip</b>: Commands in gdb can be shortened with whatever makes them unique and can be command completed with the tab key.
+Thus <tt>swigprint</tt> can usually be shortened to <tt>sw</tt> and <tt>locswigprint</tt> to <tt>loc</tt>.
+The help for each command can also be obtained within the debugging session, for example, 'help swigprint'.
+</p>
+
+<p>
+The sub-section below gives pointers for debugging DOH objects using casts and provides an insight into why it can be hard to debug SWIG without the family of print functions.
+<p>
+
+<a name="7.1" href="#i7.1">
+<h3>7.1 Debugging DOH Types The Hard Way</h3>
+</a>
+The DOH types used in SWIG are all typedefined to void and hence the lack of type information for inspecting types within a debugger.
+Most debuggers will however be able to display useful variable information when an object is cast to the appropriate type.
+Getting at the underlying C string within DOH types is cumbersome, but possible with appropriate casts.
+The casts below can be used in a debugger windows, but be sure to compile with compiler optimisations turned off before attempting the casts else they are unlikely to work.
+Even displaying the underlying string in a String * doesn't work straight off in all debuggers due to the multiple definitions of String as a struct and a void.
<p>
Below are a list of common SWIG types.
@@ -1033,36 +1155,30 @@ With each is the cast that can be used in the debugger to extract the underlying
<p>
<li>String *s;</li>
-<br>
-(struct String *)((DohBase *)s)-&gt;data
+<tt>(struct String *)((DohBase *)s)-&gt;data</tt>
<br>
The underlying char * string can be displayed with
<br>
-(*(struct String *)(((DohBase *)s)-&gt;data)).str
+<tt>(*(struct String *)(((DohBase *)s)-&gt;data)).str</tt>
<p>
<li>SwigType *t;</li>
-<br>
-(struct String *)((DohBase *)t)-&gt;data
+<tt>(struct String *)((DohBase *)t)-&gt;data</tt>
<br>
The underlying char * string can be displayed with
<br>
-(*(struct String *)(((DohBase *)t)-&gt;data)).str
+<tt>(*(struct String *)(((DohBase *)t)-&gt;data)).str</tt>
<p>
<li>const_String_or_char_ptr sc;</li>
Either <br>
-(*(struct String *)(((DohBase *)sc)-&gt;data)).str
+<tt>(*(struct String *)(((DohBase *)sc)-&gt;data)).str</tt>
<br> or <br>
-(char *)sc
+<tt>(char *)sc</tt>
<br> will work depending on whether the underlying type is really a String * or char *.
</ul>
-<p>
-Please also read the Debugging Functions section in <a href="tree.html">SWIG Parse Tree Handling</a> for the <tt>Swig_print_node()</tt>, <tt>Swig_print_tree()</tt> and <tt>Swig_print_tags()</tt> functions for displaying node contents. It is often easier to place a few calls to these functions in code of interest and recompile than use the debugger.
-</p>
-
<hr>
Copyright (C) 1999-2010 SWIG Development Team.
diff --git a/Doc/Devel/tree.html b/Doc/Devel/tree.html
index 43ad191f6..db3c6fee4 100644
--- a/Doc/Devel/tree.html
+++ b/Doc/Devel/tree.html
@@ -6,13 +6,6 @@
<body>
<center>
<h1>SWIG Parse Tree Handling</h1>
-
-<p>
-David M. Beazley <br>
-dave-swig@dabeaz.com<br>
-December, 2006<br>
-
-</b>
</center>
<h2>Introduction</h2>
@@ -210,7 +203,33 @@ This function restores a node to the state it was in prior to the last <tt>Swig_
<h2>Debugging Functions</h2>
-The following functions are used to help debug SWIG parse trees.
+<p>
+The following functions can be used to help debug any SWIG DOH object.
+</p>
+
+<b><tt>void Swig_print(DOH *object, int count = -1)</tt></b>
+
+<blockquote>
+Prints to stdout a string representation of any DOH type.
+The number of nested Hash types to expand is set by count (default is 1 if count&lt;0). See Swig_set_max_hash_expand() to change default.
+<pre>
+</pre>
+</blockquote>
+
+<b><tt>void Swig_print_with_location(DOH *object, int count = -1)</tt></b>
+
+<blockquote>
+Prints to stdout a string representation of any DOH type, within [] brackets
+for Hash and List types, prefixed by line and file information.
+The number of nested Hash types to expand is set by count (default is 1 if count&lt;0). See Swig_set_max_hash_expand() to change default.
+<pre>
+</pre>
+</blockquote>
+
+
+<p>
+The following functions can be used to help debug SWIG parse trees.
+</p>
<p>
<b><tt>void Swig_print_tags(Node *node, String_or_char *prefix)</tt></b>
diff --git a/Doc/Manual/CSharp.html b/Doc/Manual/CSharp.html
index 909357f37..6691400b7 100644
--- a/Doc/Manual/CSharp.html
+++ b/Doc/Manual/CSharp.html
@@ -57,7 +57,7 @@ PInvoke is part of the ECMA/ISO C# specification.
It is also better suited for robust production environments due to the Managed C++ flaw called the
<a href="http://msdn.microsoft.com/en-us/library/aa290048(VS.71).aspx">Mixed DLL Loading Problem</a>.
SWIG C# works equally well on non-Microsoft operating systems such as Linux, Solaris and Apple Mac using
-<a href="http://www.mono-project.com/">Mono</a> and <a href="http://www.dotgnu.org/pnet.html">Portable.NET</a>.
+<a href="http://www.mono-project.com/Main_Page">Mono</a> and <a href="http://www.dotgnu.org/pnet.html">Portable.NET</a>.
</p>
<p>
@@ -575,7 +575,8 @@ marshalling for the arrays:
<pre>
[DllImport("example", EntryPoint="CSharp_myArrayCopy")]
public static extern void myArrayCopy([In, MarshalAs(UnmanagedType.LPArray)]int[] jarg1,
- [Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2, int jarg3);
+ [Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2,
+ int jarg3);
</pre>
</div>
@@ -624,7 +625,8 @@ and intermediate class method
<pre>
[DllImport("example", EntryPoint="CSharp_myArraySwap")]
public static extern void myArraySwap([In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg1,
- [In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2, int jarg3);
+ [In, Out, MarshalAs(UnmanagedType.LPArray)]int[] jarg2,
+ int jarg3);
</pre>
</div>
@@ -696,7 +698,8 @@ As a result, we get the following method in the module class:
fixed ( int *swig_ptrTo_sourceArray = sourceArray ) {
fixed ( int *swig_ptrTo_targetArray = targetArray ) {
{
- examplePINVOKE.myArrayCopy((IntPtr)swig_ptrTo_sourceArray, (IntPtr)swig_ptrTo_targetArray, nitems);
+ examplePINVOKE.myArrayCopy((IntPtr)swig_ptrTo_sourceArray, (IntPtr)swig_ptrTo_targetArray,
+ nitems);
}
}
}
@@ -2109,7 +2112,8 @@ public class example {
try {
examplePINVOKE.addYears(CDate.getCPtr(temppDate), years);
} finally {
- pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(), 0, 0, 0);
+ pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(),
+ 0, 0, 0);
}
}
...
@@ -2126,13 +2130,13 @@ The <tt>subtractYears</tt> method is nearly identical to the above <tt>addYears<
<div class="code">
<pre>
%typemap(csin,
- pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
- post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
- " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
- terminator=" } // terminate temp$csinput using block",
- cshin="ref $csinput"
- ) CDate *
- "$csclassname.getCPtr(temp$csinput)"
+ pre=" using (CDate temp$csinput = new CDate($csinput.Year, $csinput.Month, $csinput.Day)) {",
+ post=" $csinput = new System.DateTime(temp$csinput.getYear(),"
+ " temp$csinput.getMonth(), temp$csinput.getDay(), 0, 0, 0);",
+ terminator=" } // terminate temp$csinput using block",
+ cshin="ref $csinput"
+ ) CDate *
+ "$csclassname.getCPtr(temp$csinput)"
void subtractYears(CDate *pDate, int years) {
*pDate = CDate(pDate-&gt;getYear() - years, pDate-&gt;getMonth(), pDate-&gt;getDay());
@@ -2152,7 +2156,8 @@ public class example {
try {
examplePINVOKE.subtractYears(CDate.getCPtr(temppDate), years);
} finally {
- pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(), 0, 0, 0);
+ pDate = new System.DateTime(temppDate.getYear(), temppDate.getMonth(), temppDate.getDay(),
+ 0, 0, 0);
}
} // terminate temppDate using block
}
diff --git a/Doc/Manual/Contents.html b/Doc/Manual/Contents.html
index 66bf41264..a828fdd94 100644
--- a/Doc/Manual/Contents.html
+++ b/Doc/Manual/Contents.html
@@ -5,7 +5,7 @@
<TITLE>SWIG Users Manual</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
-<H1>SWIG Users Manual</H1>
+<H1><a name="Contents"></a>SWIG Users Manual</H1>
<p>
@@ -152,6 +152,11 @@
<li><a href="SWIG.html#SWIG_nn26">Arrays</a>
<li><a href="SWIG.html#SWIG_readonly_variables">Creating read-only variables</a>
<li><a href="SWIG.html#SWIG_rename_ignore">Renaming and ignoring declarations</a>
+<ul>
+<li><a href="SWIG.html#SWIG_nn29">Simple renaming of specific identifiers</a>
+<li><a href="SWIG.html#SWIG_advanced_renaming">Advanced renaming support</a>
+<li><a href="SWIG.html#SWIG_limiting_renaming">Limiting global renaming rules</a>
+</ul>
<li><a href="SWIG.html#SWIG_default_args">Default/optional arguments</a>
<li><a href="SWIG.html#SWIG_nn30">Pointers to functions and callbacks</a>
</ul>
@@ -489,7 +494,7 @@
<li><a href="Warnings.html#Warnings_nn12">C/C++ Parser (300-399)</a>
<li><a href="Warnings.html#Warnings_nn13">Types and typemaps (400-499) </a>
<li><a href="Warnings.html#Warnings_nn14">Code generation (500-599)</a>
-<li><a href="Warnings.html#Warnings_nn15">Language module specific (800-899) </a>
+<li><a href="Warnings.html#Warnings_nn15">Language module specific (700-899) </a>
<li><a href="Warnings.html#Warnings_nn16">User defined (900-999)</a>
</ul>
<li><a href="Warnings.html#Warnings_nn17">History</a>
@@ -701,7 +706,40 @@
</div>
<!-- INDEX -->
-<h3><a href="Go.html#Go">20 SWIG and Go</a></h3>
+<h3><a href="D.html#D">20 SWIG and D</a></h3>
+
+<!-- INDEX -->
+<div class="sectiontoc">
+<ul>
+<li><a href="D.html#D_introduction">Introduction</a>
+<li><a href="D.html#D_command_line_invocation">Command line invocation</a>
+<li><a href="D.html#D_typemaps">Typemaps</a>
+<ul>
+<li><a href="D.html#D_typemap_name_comparison">C# &lt;-&gt; D name comparison</a>
+<li><a href="D.html#D_ctype_imtype_dtype">ctype, imtype, dtype</a>
+<li><a href="D.html#D_in_out_directorin_direcetorout">in, out, directorin, directorout</a>
+<li><a href="D.html#D_din_dout_ddirectorin_ddirectorout">din, dout, ddirectorin, ddirectorout</a>
+<li><a href="D.html#D_typecheck_typemaps">typecheck typemaps</a>
+<li><a href="D.html#D_code_injection_typemaps">Code injection typemaps</a>
+<li><a href="D.html#D_special_variables">Special variable macros</a>
+</ul>
+<li><a href="D.html#D_features"><tt>%feature</tt>s</a>
+<li><a href="D.html#D_pragmas">Pragmas</a>
+<li><a href="D.html#D_exceptions">D Exceptions</a>
+<li><a href="D.html#D_directors">D Directors</a>
+<li><a href="D.html#D_other_features">Other features</a>
+<ul>
+<li><a href="D.html#D_native_pointer_support">Native pointer support</a>
+<li><a href="D.html#D_operator_overloading">Operator overloading</a>
+<li><a href="D.html#D_test_suite">Running the test-suite</a>
+</ul>
+<li><a href="D.html#D_typemap_examples">D Typemap examples</a>
+<li><a href="D.html#D_planned_features">Work in progress and planned features</a>
+</ul>
+</div>
+<!-- INDEX -->
+
+<h3><a href="Go.html#Go">21 SWIG and Go</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -730,7 +768,7 @@
</div>
<!-- INDEX -->
-<h3><a href="Guile.html#Guile">21 SWIG and Guile</a></h3>
+<h3><a href="Guile.html#Guile">22 SWIG and Guile</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -765,7 +803,7 @@
</div>
<!-- INDEX -->
-<h3><a href="Java.html#Java">22 SWIG and Java</a></h3>
+<h3><a href="Java.html#Java">23 SWIG and Java</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -907,7 +945,7 @@
</div>
<!-- INDEX -->
-<h3><a href="Lisp.html#Lisp">23 SWIG and Common Lisp</a></h3>
+<h3><a href="Lisp.html#Lisp">24 SWIG and Common Lisp</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -930,7 +968,7 @@
</div>
<!-- INDEX -->
-<h3><a href="Lua.html#Lua">24 SWIG and Lua</a></h3>
+<h3><a href="Lua.html#Lua">25 SWIG and Lua</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -987,7 +1025,7 @@
</div>
<!-- INDEX -->
-<h3><a href="Modula3.html#Modula3">25 SWIG and Modula-3</a></h3>
+<h3><a href="Modula3.html#Modula3">26 SWIG and Modula-3</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -1025,7 +1063,7 @@
</div>
<!-- INDEX -->
-<h3><a href="Mzscheme.html#Mzscheme">26 SWIG and MzScheme</a></h3>
+<h3><a href="Mzscheme.html#Mzscheme">27 SWIG and MzScheme</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -1035,7 +1073,7 @@
</div>
<!-- INDEX -->
-<h3><a href="Ocaml.html#Ocaml">27 SWIG and Ocaml</a></h3>
+<h3><a href="Ocaml.html#Ocaml">28 SWIG and Ocaml</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -1086,7 +1124,7 @@
</div>
<!-- INDEX -->
-<h3><a href="Octave.html#Octave">28 SWIG and Octave</a></h3>
+<h3><a href="Octave.html#Octave">29 SWIG and Octave</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -1121,7 +1159,7 @@
</div>
<!-- INDEX -->
-<h3><a href="Perl5.html#Perl5">29 SWIG and Perl5</a></h3>
+<h3><a href="Perl5.html#Perl5">30 SWIG and Perl5</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -1188,7 +1226,7 @@
</div>
<!-- INDEX -->
-<h3><a href="Php.html#Php">30 SWIG and PHP</a></h3>
+<h3><a href="Php.html#Php">31 SWIG and PHP</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -1228,7 +1266,7 @@
</div>
<!-- INDEX -->
-<h3><a href="Pike.html#Pike">31 SWIG and Pike</a></h3>
+<h3><a href="Pike.html#Pike">32 SWIG and Pike</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -1252,7 +1290,7 @@
</div>
<!-- INDEX -->
-<h3><a href="Python.html#Python">32 SWIG and Python</a></h3>
+<h3><a href="Python.html#Python">33 SWIG and Python</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -1355,7 +1393,23 @@
</div>
<!-- INDEX -->
-<h3><a href="Ruby.html#Ruby">33 SWIG and Ruby</a></h3>
+<h3><a href="R.html#R">34 SWIG and R</a></h3>
+
+<!-- INDEX -->
+<div class="sectiontoc">
+<ul>
+<li><a href="R.html#R_nn2">Bugs</a>
+<li><a href="R.html#R_nn3">Using R and SWIG</a>
+<li><a href="R.html#R_nn4">Precompiling large R files</a>
+<li><a href="R.html#R_nn5">General policy</a>
+<li><a href="R.html#R_language_conventions">Language conventions</a>
+<li><a href="R.html#R_nn6">C++ classes</a>
+<li><a href="R.html#R_nn7">Enumerations</a>
+</ul>
+</div>
+<!-- INDEX -->
+
+<h3><a href="Ruby.html#Ruby">35 SWIG and Ruby</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -1489,7 +1543,7 @@
</div>
<!-- INDEX -->
-<h3><a href="Tcl.html#Tcl">34 SWIG and Tcl</a></h3>
+<h3><a href="Tcl.html#Tcl">36 SWIG and Tcl</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
@@ -1555,23 +1609,7 @@
</div>
<!-- INDEX -->
-<h3><a href="R.html#R">35 SWIG and R</a></h3>
-
-<!-- INDEX -->
-<div class="sectiontoc">
-<ul>
-<li><a href="R.html#R_nn2">Bugs</a>
-<li><a href="R.html#R_nn3">Using R and SWIG</a>
-<li><a href="R.html#R_nn4">Precompiling large R files</a>
-<li><a href="R.html#R_nn5">General policy</a>
-<li><a href="R.html#R_language_conventions">Language conventions</a>
-<li><a href="R.html#R_nn6">C++ classes</a>
-<li><a href="R.html#R_nn7">Enumerations</a>
-</ul>
-</div>
-<!-- INDEX -->
-
-<h3><a href="Extending.html#Extending">36 Extending SWIG to support new languages</a></h3>
+<h3><a href="Extending.html#Extending">37 Extending SWIG to support new languages</a></h3>
<!-- INDEX -->
<div class="sectiontoc">
diff --git a/Doc/Manual/D.html b/Doc/Manual/D.html
new file mode 100644
index 000000000..6f65db1e4
--- /dev/null
+++ b/Doc/Manual/D.html
@@ -0,0 +1,444 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>SWIG and D</title>
+<link rel="stylesheet" type="text/css" href="style.css">
+<meta http-equiv="content-type" content="text/html; charset=UTF-8">
+</head>
+<body bgcolor="#FFFFFF">
+<H1><a name="D"></a>20 SWIG and D</H1>
+<!-- INDEX -->
+<div class="sectiontoc">
+<ul>
+<li><a href="#D_introduction">Introduction</a>
+<li><a href="#D_command_line_invocation">Command line invocation</a>
+<li><a href="#D_typemaps">Typemaps</a>
+<ul>
+<li><a href="#D_typemap_name_comparison">C# &lt;-&gt; D name comparison</a>
+<li><a href="#D_ctype_imtype_dtype">ctype, imtype, dtype</a>
+<li><a href="#D_in_out_directorin_direcetorout">in, out, directorin, directorout</a>
+<li><a href="#D_din_dout_ddirectorin_ddirectorout">din, dout, ddirectorin, ddirectorout</a>
+<li><a href="#D_typecheck_typemaps">typecheck typemaps</a>
+<li><a href="#D_code_injection_typemaps">Code injection typemaps</a>
+<li><a href="#D_special_variables">Special variable macros</a>
+</ul>
+<li><a href="#D_features"><tt>%feature</tt>s</a>
+<li><a href="#D_pragmas">Pragmas</a>
+<li><a href="#D_exceptions">D Exceptions</a>
+<li><a href="#D_directors">D Directors</a>
+<li><a href="#D_other_features">Other features</a>
+<ul>
+<li><a href="#D_native_pointer_support">Native pointer support</a>
+<li><a href="#D_operator_overloading">Operator overloading</a>
+<li><a href="#D_test_suite">Running the test-suite</a>
+</ul>
+<li><a href="#D_typemap_examples">D Typemap examples</a>
+<li><a href="#D_planned_features">Work in progress and planned features</a>
+</ul>
+</div>
+<!-- INDEX -->
+
+
+
+<H2><a name="D_introduction"></a>20.1 Introduction</H2>
+
+
+<p>From the <a href="http://www.digitalmars.com/d/">D Programming Language</a> web site: <em>»D is a systems programming language. Its focus is on combining the power and high performance of C and C++ with the programmer productivity of modern languages like Ruby and Python. [...] The D language is statically typed and compiles directly to machine code.«</em> As such, it is not very surprising that D is able to directly <a href="http://www.digitalmars.com/d/1.0/interfaceToC.html">interface with C libraries</a>. Why would a SWIG module for D be needed then in the first place?</p>
+
+<p>Well, besides the obvious downside that the C header files have to be manually converted to D modules for this to work, there is one major inconvenience with this approach: D code usually is on a higher abstraction level than C, and many of the features that make D interesting are simply not available when dealing with C libraries, requiring you e.g. to manually convert strings between pointers to <tt>\0</tt>-terminated char arrays and D char arrays, making the algorithms from the D2 standard library unusable with C arrays and data structures, and so on.</p>
+
+<p>While these issues can be worked around relatively easy by hand-coding a thin wrapper layer around the C library in question, there is another issue where writing wrapper code per hand is not feasible: C++ libraries. D did not support interfacing to C++ in version 1 at all, and even if <tt>extern(C++)</tt> has been added to D2, the support is still very limited, and a custom wrapper layer is still required in many cases. </p>
+
+<p>To help addressing these issues, the SWIG C# module has been forked to support D. Is has evolved quite a lot since then, but there are still many similarities, so if you do not find what you are looking for on this page, it might be worth having a look at the chapter on <a href="CSharp.html">C#</a> (and also on <a href="Java.html">Java</a>, since the C# module was in turn forked from it).</p>
+
+
+<H2><a name="D_command_line_invocation"></a>20.2 Command line invocation</H2>
+
+
+<p>To activate the D module, pass the <tt>-d</tt> option to SWIG at the command line. The same standard command line switches as with any other language module are available, plus the following D specific ones:</p>
+
+<dl>
+ <dt><tt>-d2</tt></dt>
+ <dd>
+ <p>By default, SWIG generates code for D1/Tango. Use the <tt>-d2</tt> flag to target D2/Phobos instead.</p>
+ </dd>
+
+ <dt id="D_splitproxy"><tt>-splitproxy</tt></dt>
+ <dd>
+ <p>By default, SWIG generates two D modules: the <em>proxy</em> module, named like the source module (either specified via the <tt>%module</tt> directive or via the <tt>module</tt> command line switch), which contains all the proxy classes, functions, enums, etc., and the <em>intermediary</em> module (named like the proxy module, but suffixed with <tt>_im</tt>), which contains all the <tt>extern(C)</tt> function declarations and other private parts only used internally by the proxy module.</p>
+ <p>If the split proxy mode is enabled by passing this switch at the command line, all proxy classes and enums are emitted to their own D module instead. The main proxy module only contains free functions and constants in this case.</p>
+ </dd>
+
+ <dt><tt>-package &lt;pkg&gt;</tt></dt>
+ <dd>
+ <p>By default, the proxy D modules and the intermediary D module are written to the root package. Using this option, you can specify another target package instead.</p>
+ </dd>
+
+ <dt><tt>-wrapperlibrary &lt;wl&gt;</tt></dt>
+ <dd>
+ <p>The code SWIG generates to dynamically load the C/C++ wrapper layer looks for a library called <tt>$module_wrap</tt> by default. With this switch, you can override the name of the file the wrapper code loads at runtime (the <tt>lib</tt> prefix and the suffix for shared libraries are appended automatically, depending on the OS).</p>
+ <p>This might especially be useful if you want to invoke SWIG several times on separate modules, but compile the resulting code into a single shared library.</p>
+ </dd>
+</dl>
+
+
+<H2><a name="D_typemaps"></a>20.3 Typemaps</H2>
+
+
+<H3><a name="D_typemap_name_comparison"></a>20.3.1 C# &lt;-&gt; D name comparison</H3>
+
+
+<p>If you already know the SWIG C# module, you might find the following name comparison table useful:</p>
+
+<div class="diagram"><pre>
+ ctype &lt;-&gt; ctype
+ imtype &lt;-&gt; imtype
+ cstype &lt;-&gt; dtype
+ csin &lt;-&gt; din
+ csout &lt;-&gt; dout
+ csdirectorin &lt;-&gt; ddirectorin
+ csdirectorout &lt;-&gt; ddirectorout
+ csinterfaces &lt;-&gt; dinterfaces
+ csinterfaces_derived &lt;-&gt; dinterfaces_derived
+ csbase &lt;-&gt; dbase
+ csclassmodifiers &lt;-&gt; dclassmodifiers
+ cscode &lt;-&gt; dcode
+ csimports &lt;-&gt; dimports
+ csbody &lt;-&gt; dbody
+ csfinalize &lt;-&gt; ddestructor
+ csdestruct &lt;-&gt; ddispose
+ csdestruct_derived &lt;-&gt; ddispose_derived
+</pre></div>
+
+
+<H3><a name="D_ctype_imtype_dtype"></a>20.3.2 ctype, imtype, dtype</H3>
+
+
+<p>Mapping of types between the C/C++ library, the C/C++ library wrapper exposing the C functions, the D wrapper module importing these functions and the D proxy code.</p>
+
+<p>The <tt>ctype</tt> typemap is used to determine the types to use in the C wrapper functions. The types from the <tt>imtype</tt> typemap are used in the extern(C) declarations of these functions in the intermediary D module. The <tt>dtype</tt> typemap contains the D types used in the D proxy module/class.</p>
+
+
+<H3><a name="D_in_out_directorin_direcetorout"></a>20.3.3 in, out, directorin, directorout</H3>
+
+
+<p>Used for converting between the types for C/C++ and D when generating the code for the wrapper functions (on the C++ side).</p>
+
+<p>The code from the <tt>in</tt> typemap is used to convert arguments to the C wrapper function to the type used in the wrapped code (<tt>ctype</tt>->original C++ type), the <tt>out</tt> typemap is utilized to convert values from the wrapped code to wrapper function return types (original C++ type-><tt>ctype</tt>).</p>
+
+<p>The <tt>directorin</tt> typemap is used to convert parameters to the type used in the D director callback function, its return value is processed by <tt>directorout</tt> (see below).</p>
+
+
+<H3><a name="D_din_dout_ddirectorin_ddirectorout"></a>20.3.4 din, dout, ddirectorin, ddirectorout</H3>
+
+
+<p>Typemaps for code generation in D proxy and type wrapper classes.</p>
+
+<p id="D_din">The <tt>din</tt> typemap is used for converting function parameter types from the type used in the proxy module or class to the type used in the intermediary D module (the <a href="D.html#D_dinput"><tt>$dinput</tt></a> macro is replaced). To inject further parameter processing code before or after the call to the intermediary layer, the <tt>pre</tt>, <tt>post</tt> and <tt>terminator</tt> attributes can be used (please refer to the <a href="CSharp.html#CSharp_date_marshalling">C# date marshalling example</a> for more information on these).</p>
+
+<p id="D_dout">The <tt>dout</tt> typemap is used for converting function return values from the return type used in the intermediary D module to the type returned by the proxy function. The <tt>$excode</tt> special variable in <tt>dout</tt> typemaps is replaced by the <tt>excode</tt> typemap attribute code if the method can throw any exceptions from unmanaged code, otherwise by nothing (the <a href="D.html#D_imcall"><tt>$imcall</tt> and <tt>$owner</tt></a> macros are replaced).</p>
+
+<p id="D_ddirectorinout">The code from the <tt>ddirectorin</tt> and <tt>ddirectorout</tt> typemaps is used for conversion in director callback functions. Arguments are converted to the type used in the proxy class method they are calling by using the code from <tt>ddirectorin</tt>, the proxy class method return value is converted to the type the C++ code expects via the <tt>ddirectorout</tt> typemap (the <a href="D.html#D_dpcall"><tt>$dcall</tt> and <tt>$winput</tt></a> macros are replaced).</p>
+
+<p>The full chain of type conversions when a director callback is invoked looks like this:</p>
+
+ <div class="diagram"><pre>
+ type CPPClass::method(type a)
+ &uarr; &darr;
+ &lt;directorout&gt; &lt;directorin&gt;
+ &uarr; &darr;
+ ctype methodCallback(ctype a) C++
+ :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
+ imtype methodCallback(imtype a) D
+ &uarr; &darr;
+ &lt;ddirectorout&gt; &lt;ddirectorin&gt;
+ &uarr; &darr;
+ dtype DClass.method(dtype a)</pre></div>
+
+
+<H3><a name="D_typecheck_typemaps"></a>20.3.5 typecheck typemaps</H3>
+
+
+<p>Because, unlike many scripting languages supported by SWIG, D does not need any dynamic dispatch helper to access an overloaded function, the purpose of these is merely to issue a warning for overloaded C++ functions that cannot be overloaded in D (as more than one C++ type maps to a single D type).</p>
+
+
+<H3><a name="D_code_injection_typemaps"></a>20.3.6 Code injection typemaps</H3>
+
+
+<p>These typemaps are used for generating the skeleton of proxy classes for C++ types.</p>
+
+<p>By overriding <tt>dbase</tt>, <tt>dinterfaces</tt> or <tt>dinterfaces_derived</tt>, the inheritance chain of the generated proxy class for a type can be modified. <tt>dclassmodifiers</tt> allows you to add any custom modifiers around the class keyword.</p>
+
+<p>Using <tt>dcode</tt> and <tt>dimports</tt>, you can specify additional D code which will be emitted into the class body respectively the imports section of the D module the class is written to.</p>
+
+<p id="D_class_code_typemaps"><tt>dconstructor</tt>, <tt>ddestructor</tt>, <tt>ddispose</tt> and <tt>ddispose_derived</tt> are used to generate the class constructor, destructor and <tt>dispose()</tt> method, respectively. The auxiliary code for handling the pointer to the C++ object is stored in <tt>dbody</tt> and <tt>dbody_derived</tt>. You can override them for specific types.</p>
+
+
+<H3><a name="D_special_variables"></a>20.3.7 Special variable macros</H3>
+
+
+<p>The standard SWIG special variables are available for use within typemaps as described in the <a href="Typemaps.html#Typemaps">Typemaps documentation</a>, for example <tt>$1</tt>, <tt>$input</tt>, <tt>$result</tt> etc.</p>
+
+<p>When generating D wrappers, a few additional macros are available:</p>
+<dl>
+ <dt><tt>$dclassname</tt> (C#: <tt>$csclassname</tt>)</dt>
+ <dd>
+ <p>This special variable works similar to <a href="Typemaps.html#Typemaps_special_variables"><tt>$n_type</tt></a> in that it returns the name of a type - it expands to the D proxy class name of the type being wrapped. If the type does not have an associated proxy class, it expands to the type wrapper class name, for example, <tt>SWIGTYPE_p_p_SomeCppClass</tt> is generated when wrapping <tt>SomeCppClass **</tt>.</p>
+ <p>There are two other variants available, <tt>$&amp;dclassname</tt> and <tt>$*dclassname</tt>. The former adds a level of indirection, while the latter removes one. For instance, when wrapping <tt>Foo **</tt>, <tt>$*dclassname</tt> would be replaced by the proxy class name corresponding to <tt>Foo *</tt>.</p>
+ </dd>
+
+ <dt><tt>$null</tt></dt>
+ <dd><p>In code inserted into the generated C/C++ wrapper functions, this variable is replaced by either <tt>0</tt> or nothing at all, depending on whether the function has a return value or not. It can be used to bail out early e.g. in case of errors (<tt>return $null;</tt>).</p></dd>
+
+ <dt id="D_dinput"><tt>$dinput</tt> (C#: <tt>$csinput</tt>)</dt>
+ <dd>
+ <p>This variable is used in <tt><a href="D.html#D_din">din</a></tt> typemaps and is replaced by the expression which is to be passed to C/C++.</p>
+ <p>For example, this input</p>
+ <div class="code"><pre>
+%typemap(din) SomeClass * "SomeClass.getCPointer($dinput)"
+
+%inline %{
+ class SomeClass {};
+ void foo(SomeClass *arg);
+%}</pre></div>
+ <p>leads to the following D proxy code being generated:</p>
+<div class="targetlang"><pre>
+void foo(SomeClass arg) {
+ example_im.foo(SomeClass.getCPointer(arg));
+}</pre></div></dd>
+
+ <dt id="D_imcall"><tt>$imcall</tt> and <tt>$owner</tt> (C#: <tt>$imcall</tt>)</dt>
+ <dd>
+ <p>These variables are used in <tt><a href="D.html#D_dout">dout</a></tt> typemaps. <tt>$imcall</tt> contains the call to the intermediary module which provides the value to be used, and <tt>$owner</tt> signals if the caller is responsible for managing the object lifetime (that is, if the called method is a constructor or has been marked via <tt>%newobject</tt>).</p>
+ <p>Consider the following example:</p>
+<div class="code"><pre>
+%typemap(dout) SomeClass * {
+ return new SomeClass($imcall, $owner);
+}
+
+%inline %{
+ class SomeClass;
+ SomeClass *foo();
+
+ %newobject bar();
+ SomeClass *bar();
+%}</pre></div>
+ <p>The code generated for <tt>foo()</tt> and <tt>bar()</tt> looks like this:</p>
+<div class="targetlang"><pre>
+SomeClass foo() {
+ return new SomeClass(example_im.foo(), false);
+}
+
+SomeClass bar() {
+ return new SomeClass(example_im.bar(), true);
+}
+</pre></div>
+ </dd>
+
+ <dt><tt>$dcall</tt> and <tt>$winput</tt> (C#: <tt>$cscall</tt>, <tt>$iminput</tt>)</dt>
+ <dd id="D_dpcall"><p>These variables are used in the director-specific typemaps <a href="D.html#D_ddirectorinout"><tt>ddirectorin</tt></a> and <a href="D.html#D_ddirectorinout"><tt>ddirectorout</tt></a>. They are more or less the reverse of the <tt>$imcall</tt> and <tt>$dinput</tt> macros: <tt>$dcall</tt> contains the invocation of the D proxy method of which the return value is to be passed back to C++, <tt>$winput</tt> contains the parameter value from C++.</p></dd>
+
+ <dt><tt>$excode</tt></dt>
+ <dd><p>This variable is used in <tt>dout</tt> and <tt>dconstructor</tt> typemaps and is filled with the contents of the <tt>excode</tt> typemap attribute if an exception could be thrown from the C++ side. See the <a href="CSharp.html#CSharp_exceptions">C# documentation</a> for details.</p></dd>
+
+ <dt><tt>$dbaseclass</tt></dt>
+ <dd><p>Currently for internal use only, it contains the D name of the C++ base class (if any) inside proxy classes.</p></dd>
+
+ <dt><tt>$directorconnect</tt></dt>
+ <dd>
+ <p>This macro is only valid inside the <tt><a href="D.html#D_class_code_typemaps">dconstructor</a></tt> typemap and contains the value of the <tt>dconstructor</tt> typemap attribute if the currently wrapped class has directors enabled.</p>
+ <p>This is how the default <tt>dconstructor</tt> typemap looks like (you usually do not want to specify a custom one):</p>
+<div class="code"><pre>
+%typemap(dconstructor, excode=SWIGEXCODE,
+ directorconnect="\n swigDirectorConnect();") SWIGTYPE {
+ this($imcall, true);$excode$directorconnect
+}
+</pre></div>
+ </dd>
+
+ <dt id="D_importtype"><tt>$importtype(SomeDType)</tt></dt>
+ <dd>
+ <p>This macro is used in the <tt>dimports</tt> typemap if a dependency on another D type generated by SWIG is added by a custom typemap.</p>
+ <p>Consider the following code snippet:</p>
+<div class="code"><pre>
+%typemap(dinterfaces) SomeClass "AnInterface, AnotherInterface";
+</pre></div>
+ <p>This causes SWIG to add <tt>AnInterface</tt> and <tt>AnotherInterface</tt> to the base class list of <tt>SomeClass</tt>:</p>
+<div class="targetlang"><pre>
+class SomeClass : AnInterface, AnotherInterface {
+ ...
+}
+</pre></div>
+ <p>For this to work, <tt>AnInterface</tt> and <tt>AnotherInterface</tt> have to be in scope. If SWIG is not in split proxy mode, this is already the case, but it it is, they have to be added to the import list via the <tt>dimports</tt> typemap. Additionally, the import statement depends on the package SWIG is configured to emit the modules to.</p>
+ <p>The <tt>$importtype</tt> macro helps you to elegantly solve this problem:</p>
+<div class="code"><pre>
+%typemap(dimports) RemoteMpe %{
+$importtype(AnInterface)
+$importtype(AnotherInterface)
+%}
+</pre></div>
+ <p>If SWIG is in split proxy mode, it expands to an <tt>import</tt> statement for the specified type, to nothing if not.</p>
+ </dd>
+
+ <dt><tt>$module</tt></dt>
+ <dd><p>Expands to the name of the main proxy D module.</p></dd>
+
+ <dt><tt>$imdmodule</tt></dt>
+ <dd><p>Contains the fully qualified name of the intermediary D module.</p></dd>
+</dl>
+
+
+<H2><a name="D_features"></a>20.4 <tt>%feature</tt>s</H2>
+
+
+<p>The D module defines a number of directives which modify the <a href="Customization.html#Customization_features">SWIG features</a> set globally or for a specific declaration:</p>
+
+
+<dl>
+ <dt><tt>%dmanifestconst</tt> and <tt>%dconstvalue(value)</tt></dt>
+ <dd>
+ <p>Out of the box, SWIG generates accessor methods for C <tt>#defines</tt> and C++ constants. The <tt>%dmanifestconst</tt> directive enables wrapping these constants as D manifest constants (<tt>const</tt> in D1, <tt>enum</tt> in D2).</p>
+ <p>For this to work, the C/C++ code for the constant value must directly compile as D code, though. If this is not the case, you can manually override the expression written to the D proxy module using the <tt>%dconstvalue</tt> directive, passing the new value as parameter.</p>
+ <p>For <tt>enum</tt>s, again <tt>%dconstvalue</tt> can be used to override the value of an enum item if the initializer should not compile in D.</p>
+ </dd>
+
+ <dt><tt>%dmethodmodifiers</tt></dt>
+ <dd>
+ <p>This directive can be used to override the modifiers for a proxy function. For instance, you could make a <tt>public</tt> C++ member function <tt>private</tt> in D like this:</p>
+<div class="code"><pre>
+%dmethodmodifiers A::foo "private";
+
+%inline %{
+struct A {
+ void foo();
+};
+%}
+</pre></div>
+ </dd>
+</dl>
+
+
+<H2><a name="D_pragmas"></a>20.5 Pragmas</H2>
+
+
+<p>There are a few SWIG pragmas specific to the D module, which you can use to influence the D code SWIG generates:</p>
+
+<dl>
+ <dt><tt>%pragma(d) imdmodulecode</tt></dt>
+ <dd><p>The passed text (D code) is copied verbatim to the intermediary D module. For example, it can be (and is, internally) used to emit additional private helper code for the use by proxy typemaps.</p></dd>
+
+ <dt><tt>%pragma(d) imdmoduleimports</tt></dt>
+ <dd><p>Additional code to be emitted to the imports section of the intermediary D module (the <a href="D.html#D_importtype">$importtype</a> macro can be used here). You probably want to use this in conjunction with the <tt>imdmodulecode</tt> pragma.</p></dd>
+
+ <dt><tt>%pragma(d) proxydmodulecode</tt></dt>
+ <dd><p>Just like <tt>proxydmodulecode</tt>, the argument is copied to the proxy D module (if SWIG is in <a href="D.html#D_splitproxy">split proxy mode</a>, it is emitted to the main proxy D module only).</p></dd>
+
+ <dt><tt>%pragma(d) globalproxyimports</tt></dt>
+ <dd>
+ <p>The D module currently does not support specifying dependencies on external modules (e.g. from the standard library) for the D typemaps. To add the import statements to the proxy modules (resp. to <em>all</em> proxy modules if in split proxy mode), you can use the <tt>globalproxyimports</tt> directive.</p>
+ <p>For example:</p>
+<div class="code"><pre>
+%typemap(din) char[] "($dinput ? tango.stdc.stringz.toStringz($dinput) : null)"
+%pragma(d) globalproxyimports = "static import tango.stdc.stringz;";
+</pre></div>
+ </dd>
+
+ <dt><tt>%pragma(d) wrapperloadercode</tt></dt>
+ <dd>
+ <p>The D code for loading the wrapper library (it is copied to the intermediary D module). The <tt>$wrapperloaderbindcode</tt> variable is replaced by the list of commands for binding the functions from the wrapper library to the symbols in the intermediary D module.</p>
+ <p>Each time this pragma is specified, the previous value is overwritten.</p>
+ </dd>
+
+ <dt><tt>%pragma(d) wrapperloaderbindcommand</tt></dt>
+ <dd>
+ <p>The D command to use for binding the wrapper functions from the C/C++ library to the symbols in the intermediary D module. The <tt>$function</tt> variable contains the name of the D function in the wrap module, the <tt>$symbol</tt> variable is replaced by the name of the symbol in the library.</p>
+ <p>Each time this pragma is specified, the previous value is overwritten.</p>
+ </dd>
+</dl>
+
+
+<H2><a name="D_exceptions"></a>20.6 D Exceptions</H2>
+
+
+<p>Out of the box, C++ exceptions are fundamentally incompatible to their equivalent in the D world and cannot simply be propagated to a calling D method. There is, however, an easy way to solve this problem: Just catch the exception in the C/C++ wrapper layer, pass the contents to D, and make the wrapper code rethrow the exception in the D world.</p>
+
+<p>The implementation details of this are a bit crude, but the SWIG D module automatically takes care of this, as long as it is able to detect that an exception could potentially be thrown (e.g. because the C++ method has a <tt>throw(...)</tt> exception specification).</p>
+
+<p>As this feature is implemented in exactly the same way it is for C#, please see the <a href="CSharp.html#CSharp_exceptions">C# documentation</a> for a more detailed explanation.</p>
+
+
+<H2><a name="D_directors"></a>20.7 D Directors</H2>
+
+
+<p>When the directors feature is activated, SWIG generates extra code on both the C++ and the D side to enable cross-language polymorphism. Essentially, this means that if you subclass a proxy class in D, C++ code can access any overridden virtual methods just as if you created a derived class in C++.</p>
+
+<p>There is no D specific documentation yet, but the way the feature is implemented is very similar to how it is done in <a href="Java.html#Java_directors">Java</a> and <a href="CSharp.html#CSharp_directors">C#</a>.
+</p>
+
+
+<H2><a name="D_other_features"></a>20.8 Other features</H2>
+
+
+<p>The <a href="SWIGPlus.html#SWIGPlus_nspace"><tt>nspace</tt></a> feature of SWIG is not yet supported for D - all class modules are written to the same package, regardless of which C++ namespace they are in.</p>
+
+
+<H3><a name="D_native_pointer_support"></a>20.8.1 Native pointer support</H3>
+
+
+<p>Contrary to many of the scripting languages supported by SWIG, D fully supports C-style pointers. The D module thus includes a custom mechanism to wrap C pointers directly as D pointers where applicable, that is, if the type that is pointed to is represented the same in C and D (on the bit-level), dubbed a »primtive type« below.</p>
+
+<p>Central to this custom pointer handling scheme are two typemap attributes: the <tt>cprimitive</tt> attribute on the <tt>dtype</tt> typemap and the <tt>nativepointer</tt> attribute on all the typemaps which influence the D side of the code (<tt>dtype</tt>, <tt>din</tt>, <tt>dout</tt>, ...). When a D typemap is looked up, the following happens behind the scenes:</p>
+
+<p>First, the matching typemap is determined by the usual typemap lookup rules. Then, it is checked if the result has the <tt>nativepointer</tt> attribute set. If it is present, it means that its value should replace the typemap value <em>if and only if</em> the actual type the typemap is looked up for is a primitive type, a pointer to a primitive type (through an arbitrary level of indirections), or a function pointer with only primitive types in its signature.</p>
+
+<p>To determine if a type should be considered primitive, the <tt>cprimitive</tt> attribute on its <tt>dtype</tt> attribute is used. For example, the <tt>dtype</tt> typemap for <tt>float</tt> has <tt>cprimitive="1"</tt>, so the code from the <tt>nativepointer</tt> attribute is taken into account e.g. for <tt>float **</tt> or the function pointer <tt>float (*)(float *)</tt>.</p>
+
+
+<H3><a name="D_operator_overloading"></a>20.8.2 Operator overloading</H3>
+
+
+<p>The D module comes with basic operator overloading support for both D1 and D2. There are, however, a few limitations arising from conceptual differences between C++ and D:</p>
+
+<p>The first key difference is that C++ supports free functions as operators (along with argument-dependent lookup), while D requires operators to be member functions of the class they are operating on. SWIG can only automatically generate wrapping code for member function operators; if you want to use operators defined as free functions in D, you need to handle them manually.</p>
+
+<p>Another set of differences between C++ and D concerns individual operators. For example, there are quite a few operators which are overloadable in C++, but not in D, for example <tt>&amp;&amp;</tt> and <tt>||</tt>, but also <tt>!</tt>, and prefix increment/decrement operators in <a href="http://www.digitalmars.com/d/1.0/operatoroverloading.html">D1</a> resp. their postfix pendants in <a href="http://www.digitalmars.com/d/2.0/operatoroverloading.html">D2</a>.</p>
+
+<p>There are also some cases where the operators can be translated to D, but the differences in the implementation details are big enough that a rather involved scheme would be required for automatic wrapping them, which has not been implemented yet. This affects, for example, the array subscript operator, <tt>[]</tt>, in combination with assignments - while <tt>operator []</tt> in C++ simply returns a reference which is then written to, D resorts to a separate <tt>opIndexAssign</tt> method -, or implicit casting (which was introduced in D2 via <tt>alias this</tt>). Despite the lack of automatic support, manually handling these cases should be perfectly possible.</p>
+
+
+<H3><a name="D_test_suite"></a>20.8.3 Running the test-suite</H3>
+
+
+<p>As with any other language, the SWIG test-suite can be built for D using the <tt>*-d-test-suite</tt> targets of the top-level Makefile. By default, D1 is targeted, to build it with D2, use the optional <tt>D_VERSION</tt> variable, e.g. <tt>make check-d-test-suite D_VERSION=2</tt>.</p>
+
+<p>Note: If you want to use GDC on Linux or another platform which requires you to link <tt>libdl</tt> for dynamically loading the shared library, you might have to add <tt>-ldl</tt> manually to the <tt>d_compile</tt> target in <tt>Examples/Makefile</tt>, because GDC does not currently honor the <tt>pragma(lib,...)</tt> statement.</p>
+
+
+<H2><a name="D_typemap_examples"></a>20.9 D Typemap examples</H2>
+
+
+<p>There are no D-specific typemap examples yet. However, with the above <a href="D.html#D_typemap_name_comparison">name comparison table</a>, you should be able to get an idea what can be done by looking at the <a href="CSharp.html#CSharp_typemap_examples">corresponding C# section</a>.</p>
+
+
+
+<H2><a name="D_planned_features"></a>20.10 Work in progress and planned features</H2>
+
+
+<p>There are a couple of features which are not implemented yet, but would be very useful and might be added in the near future:</p>
+
+<ul>
+ <li><em>Static linking:</em> Currently, the C wrapper code is compiled into a dynamic library, out of which the symbol addresses are looked up at runtime by the D part. If statically linking the different languages into one binary was supported, a tool-chain capable of performing IPO at link time could inline the wrapping code, effectively reducing the overhead for simple calls to zero.</li>
+ <li><em>C array handling:</em> Many data structures in some C/C++ libraries contain array containing of a pointer to the first element and the element count. Currently, one must manually writing wrapper code to be able to access these from D. It should be possible to add a set of SWIG macros to semi-automatically generate conversion code.</li>
+</ul>
+
+<p>Some generated code might also be a bit rough around the edges, particularly in the following areas:</p>
+
+<ul>
+ <li><em>Memory management:</em> Although the currently generated wrapper code works fine with regard to the GC for the test-suite, there might be issues coming up in real-world multi-threaded usage.</li>
+ <li><em>D2 support</em>: Originally, the module has been developed for the use with D1, D2/Phobos support has been added in later. The basic features should work equally well for both, but there <em>could</em> be issues concerning const-correctness etc.</li>
+</ul>
+
+
+</body>
+</html>
+
diff --git a/Doc/Manual/Extending.html b/Doc/Manual/Extending.html
index c554d9f05..c6e006033 100644
--- a/Doc/Manual/Extending.html
+++ b/Doc/Manual/Extending.html
@@ -6,7 +6,7 @@
</head>
<body bgcolor="#ffffff">
-<H1><a name="Extending"></a>36 Extending SWIG to support new languages</H1>
+<H1><a name="Extending"></a>37 Extending SWIG to support new languages</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -75,7 +75,7 @@
-<H2><a name="Extending_nn2"></a>36.1 Introduction</H2>
+<H2><a name="Extending_nn2"></a>37.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>36.2 Prerequisites</H2>
+<H2><a name="Extending_nn3"></a>37.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>36.3 The Big Picture</H2>
+<H2><a name="Extending_nn4"></a>37.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>36.4 Execution Model</H2>
+<H2><a name="Extending_nn5"></a>37.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>36.4.1 Preprocessing</H3>
+<H3><a name="Extending_nn6"></a>37.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>36.4.2 Parsing</H3>
+<H3><a name="Extending_nn7"></a>37.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>36.4.3 Parse Trees</H3>
+<H3><a name="Extending_nn8"></a>37.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>36.4.4 Attribute namespaces</H3>
+<H3><a name="Extending_nn9"></a>37.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>36.4.5 Symbol Tables</H3>
+<H3><a name="Extending_nn10"></a>37.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>36.4.6 The %feature directive</H3>
+<H3><a name="Extending_nn11"></a>37.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>36.4.7 Code Generation</H3>
+<H3><a name="Extending_nn12"></a>37.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>36.4.8 SWIG and XML</H3>
+<H3><a name="Extending_nn13"></a>37.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>36.5 Primitive Data Structures</H2>
+<H2><a name="Extending_nn14"></a>37.5 Primitive Data Structures</H2>
<p>
@@ -987,7 +987,7 @@ typedef Hash Typetab;
</pre>
</div>
-<H3><a name="Extending_nn15"></a>36.5.1 Strings</H3>
+<H3><a name="Extending_nn15"></a>37.5.1 Strings</H3>
<p>
@@ -1128,7 +1128,7 @@ Returns the number of replacements made (if any).
</div>
-<H3><a name="Extending_nn16"></a>36.5.2 Hashes</H3>
+<H3><a name="Extending_nn16"></a>37.5.2 Hashes</H3>
<p>
@@ -1205,7 +1205,7 @@ Returns the list of hash table keys.
</div>
-<H3><a name="Extending_nn17"></a>36.5.3 Lists</H3>
+<H3><a name="Extending_nn17"></a>37.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>36.5.4 Common operations</H3>
+<H3><a name="Extending_nn18"></a>37.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>36.5.5 Iterating over Lists and Hashes</H3>
+<H3><a name="Extending_nn19"></a>37.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>36.5.6 I/O</H3>
+<H3><a name="Extending_nn20"></a>37.5.6 I/O</H3>
Special I/O functions are used for all internal I/O. These operations
@@ -1531,7 +1531,7 @@ Similarly, the preprocessor and parser all operate on string-files.
</div>
-<H2><a name="Extending_nn21"></a>36.6 Navigating and manipulating parse trees</H2>
+<H2><a name="Extending_nn21"></a>37.6 Navigating and manipulating parse trees</H2>
Parse trees are built as collections of hash tables. Each node is a hash table in which
@@ -1665,7 +1665,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>36.7 Working with attributes</H2>
+<H2><a name="Extending_nn22"></a>37.7 Working with attributes</H2>
<p>
@@ -1782,7 +1782,7 @@ the attribute is optional. <tt>Swig_restore()</tt> must always be called after
function.
</div>
-<H2><a name="Extending_nn23"></a>36.8 Type system</H2>
+<H2><a name="Extending_nn23"></a>37.8 Type system</H2>
<p>
@@ -1791,7 +1791,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>36.8.1 String encoding of types</H3>
+<H3><a name="Extending_nn24"></a>37.8.1 String encoding of types</H3>
<p>
@@ -1892,7 +1892,7 @@ make the final type, the two parts are just joined together using
string concatenation.
</p>
-<H3><a name="Extending_nn25"></a>36.8.2 Type construction</H3>
+<H3><a name="Extending_nn25"></a>37.8.2 Type construction</H3>
<p>
@@ -2061,7 +2061,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>36.8.3 Type tests</H3>
+<H3><a name="Extending_nn26"></a>37.8.3 Type tests</H3>
<p>
@@ -2148,7 +2148,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>36.8.4 Typedef and inheritance</H3>
+<H3><a name="Extending_nn27"></a>37.8.4 Typedef and inheritance</H3>
<p>
@@ -2250,7 +2250,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>36.8.5 Lvalues</H3>
+<H3><a name="Extending_nn28"></a>37.8.5 Lvalues</H3>
<p>
@@ -2287,7 +2287,7 @@ Literal y; // type = 'Literal', ltype='p.char'
</pre>
</div>
-<H3><a name="Extending_nn29"></a>36.8.6 Output functions</H3>
+<H3><a name="Extending_nn29"></a>37.8.6 Output functions</H3>
<p>
@@ -2349,7 +2349,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>36.9 Parameters</H2>
+<H2><a name="Extending_nn30"></a>37.9 Parameters</H2>
<p>
@@ -2448,7 +2448,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>36.10 Writing a Language Module</H2>
+<H2><a name="Extending_nn31"></a>37.10 Writing a Language Module</H2>
<p>
@@ -2463,7 +2463,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>36.10.1 Execution model</H3>
+<H3><a name="Extending_nn32"></a>37.10.1 Execution model</H3>
<p>
@@ -2473,7 +2473,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>36.10.2 Starting out</H3>
+<H3><a name="Extending_starting_out"></a>37.10.2 Starting out</H3>
<p>
@@ -2581,7 +2581,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>36.10.3 Command line options</H3>
+<H3><a name="Extending_nn34"></a>37.10.3 Command line options</H3>
<p>
@@ -2640,7 +2640,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>36.10.4 Configuration and preprocessing</H3>
+<H3><a name="Extending_nn35"></a>37.10.4 Configuration and preprocessing</H3>
<p>
@@ -2689,7 +2689,7 @@ an implementation file <tt>python.cxx</tt> and a configuration file
<tt>python.swg</tt>.
</p>
-<H3><a name="Extending_nn36"></a>36.10.5 Entry point to code generation</H3>
+<H3><a name="Extending_nn36"></a>37.10.5 Entry point to code generation</H3>
<p>
@@ -2747,7 +2747,7 @@ int Python::top(Node *n) {
</pre>
</div>
-<H3><a name="Extending_nn37"></a>36.10.6 Module I/O and wrapper skeleton</H3>
+<H3><a name="Extending_nn37"></a>37.10.6 Module I/O and wrapper skeleton</H3>
<!-- please report bugs in this section to mgossage -->
@@ -2895,7 +2895,7 @@ functionWrapper : void Shape_y_set(Shape *self,double y)
</pre>
</div>
-<H3><a name="Extending_nn38"></a>36.10.7 Low-level code generators</H3>
+<H3><a name="Extending_nn38"></a>37.10.7 Low-level code generators</H3>
<!-- please report bugs in this section to mgossage -->
@@ -3049,7 +3049,7 @@ but without the typemaps, there is still work to do.
</p>
-<H3><a name="Extending_configuration_files"></a>36.10.8 Configuration files</H3>
+<H3><a name="Extending_configuration_files"></a>37.10.8 Configuration files</H3>
<!-- please report bugs in this section to ttn -->
@@ -3193,7 +3193,7 @@ politely displays the ignoring language message.
</dl>
-<H3><a name="Extending_nn40"></a>36.10.9 Runtime support</H3>
+<H3><a name="Extending_nn40"></a>37.10.9 Runtime support</H3>
<p>
@@ -3202,7 +3202,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>36.10.10 Standard library files</H3>
+<H3><a name="Extending_nn41"></a>37.10.10 Standard library files</H3>
<p>
@@ -3221,7 +3221,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>36.10.11 User examples</H3>
+<H3><a name="Extending_nn42"></a>37.10.11 User examples</H3>
<p>
@@ -3250,7 +3250,7 @@ during this process, see the section on <a href="#Extending_configuration_files"
files</a>.
</p>
-<H3><a name="Extending_test_suite"></a>36.10.12 Test driven development and the test-suite</H3>
+<H3><a name="Extending_test_suite"></a>37.10.12 Test driven development and the test-suite</H3>
<p>
@@ -3309,7 +3309,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>36.10.12.1 Running the test-suite</H4>
+<H4><a name="Extending_running_test_suite"></a>37.10.12.1 Running the test-suite</H4>
<p>
@@ -3477,7 +3477,25 @@ A debugger can also be invoked easily on an individual test, for example gdb:
make ret_by_value.ctest RUNTOOL="gdb --args"
</pre></div>
-<H3><a name="Extending_nn43"></a>36.10.13 Documentation</H3>
+<p>
+SWIG reads the <tt>SWIG_FEATURES</tt> environment variable to obtain options in addition to those passed on the command line.
+This is particularly useful as the entire test-suite or a particular testcase can be run customized by using additional
+arguments, for example the -O optimization flag can be added in, as shown below for the bash shell:
+</p>
+
+<div class="shell"><pre>
+env SWIG_FEATURES=-O make check-python-test-suite
+</pre></div>
+
+<p>
+The syntax for setting environment variables varies from one shell to the next, but it also works as shown in the example below, where some typemap debugging is added in:
+</p>
+
+<div class="shell"><pre>
+make ret_by_value.ctest SWIG_FEATURES="-debug-tmsearch"
+</pre></div>
+
+<H3><a name="Extending_nn43"></a>37.10.13 Documentation</H3>
<p>
@@ -3509,7 +3527,7 @@ Some topics that you'll want to be sure to address include:
if available.
</ul>
-<H3><a name="Extending_prerequisites"></a>36.10.14 Prerequisites for adding a new language module to the SWIG distribution</H3>
+<H3><a name="Extending_prerequisites"></a>37.10.14 Prerequisites for adding a new language module to the SWIG distribution</H3>
<p>
@@ -3566,7 +3584,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>36.10.15 Coding style guidelines</H3>
+<H3><a name="Extending_coding_style_guidelines"></a>37.10.15 Coding style guidelines</H3>
<p>
@@ -3590,7 +3608,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>36.11 Debugging Options</H2>
+<H2><a name="Extending_debugging_options"></a>37.11 Debugging Options</H2>
<p>
@@ -3609,13 +3627,15 @@ There are various command line options which can aid debugging a SWIG interface
-debug-top &lt;n&gt; - Display entire parse tree at stages 1-4, &lt;n&gt; is a csv list of stages
-debug-typedef - Display information about the types and typedefs in the interface
-debug-typemap - Display information for debugging typemaps
+-debug-tmsearch - Display typemap search debugging information
+-debug-tmused - Display typemaps used debugging information
</pre></div>
<p>
The complete list of command line options for SWIG are available by running <tt>swig -help</tt>.
</p>
-<H2><a name="Extending_nn46"></a>36.12 Guide to parse tree nodes</H2>
+<H2><a name="Extending_nn46"></a>37.12 Guide to parse tree nodes</H2>
<p>
@@ -4023,7 +4043,7 @@ extern "X" { ... } declaration.
</pre>
</div>
-<H2><a name="Extending_further_info"></a>36.13 Further Development Information</H2>
+<H2><a name="Extending_further_info"></a>37.13 Further Development Information</H2>
<p>
diff --git a/Doc/Manual/Go.html b/Doc/Manual/Go.html
index 5e99a5156..d5275efea 100644
--- a/Doc/Manual/Go.html
+++ b/Doc/Manual/Go.html
@@ -5,7 +5,7 @@
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body bgcolor="#FFFFFF">
-<H1><a name="Go"></a>20 SWIG and Go</H1>
+<H1><a name="Go"></a>21 SWIG and Go</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -41,7 +41,7 @@ the Go programming language
see <a href="http://golang.org/">golang.org</a>.
</p>
-<H2><a name="Go_overview"></a>20.1 Overview</H2>
+<H2><a name="Go_overview"></a>21.1 Overview</H2>
<p>
@@ -65,7 +65,7 @@ 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>20.2 Running SWIG with Go</H2>
+<H2><a name="Go_running_swig"></a>21.2 Running SWIG with Go</H2>
<p>
@@ -74,7 +74,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>20.2.1 Additional Commandline Options</H3>
+<H3><a name="Go_commandline"></a>21.2.1 Additional Commandline Options</H3>
<p>
@@ -118,7 +118,7 @@ swig -go -help
</table>
-<H3><a name="Go_outputs"></a>20.2.2 Go Output Files</H3>
+<H3><a name="Go_outputs"></a>21.2.2 Go Output Files</H3>
<p> When generating Go code, SWIG will generate the following
@@ -163,7 +163,7 @@ A typical command sequence would look like this:
% 6l main.6
</pre></div>
-<H2><a name="Go_basic_tour"></a>20.3 A tour of basic C/C++ wrapping</H2>
+<H2><a name="Go_basic_tour"></a>21.3 A tour of basic C/C++ wrapping</H2>
<p>
@@ -173,7 +173,7 @@ modifications have to occur. This section briefly covers the
essential aspects of this wrapping.
</p>
-<H3><a name="Go_package"></a>20.3.1 Go Package Name</H3>
+<H3><a name="Go_package"></a>21.3.1 Go Package Name</H3>
<p>
@@ -183,7 +183,7 @@ directive. You may override this by using SWIG's <tt>-package</tt>
command line option.
</p>
-<H3><a name="Go_names"></a>20.3.2 Go Names</H3>
+<H3><a name="Go_names"></a>21.3.2 Go Names</H3>
<p>
@@ -215,7 +215,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>20.3.3 Go Constants</H3>
+<H3><a name="Go_constants"></a>21.3.3 Go Constants</H3>
<p>
@@ -223,7 +223,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>20.3.4 Go Enumerations</H3>
+<H3><a name="Go_enumerations"></a>21.3.4 Go Enumerations</H3>
<p>
@@ -233,7 +233,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>20.3.5 Go Classes</H3>
+<H3><a name="Go_classes"></a>21.3.5 Go Classes</H3>
<p>
@@ -280,7 +280,7 @@ to <tt>reinterpret_cast</tt>. This should only be used for very
special cases, such as where C++ would use a <tt>dynamic_cast</tt>.
</p>
-<H4><a name="Go_class_inheritance"></a>20.3.5.1 Go Class Inheritance</H4>
+<H4><a name="Go_class_inheritance"></a>21.3.5.1 Go Class Inheritance</H4>
<p>
@@ -292,7 +292,7 @@ Doing the reverse will require an explicit type assertion, which will
be checked dynamically.
</p>
-<H3><a name="Go_templates"></a>20.3.6 Go Templates</H3>
+<H3><a name="Go_templates"></a>21.3.6 Go Templates</H3>
<p>
@@ -300,7 +300,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>20.3.7 Go Director Classes</H3>
+<H3><a name="Go_director_classes"></a>21.3.7 Go Director Classes</H3>
<p>
@@ -343,7 +343,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>20.3.8 Default Go primitive type mappings</H3>
+<H3><a name="Go_primitive_type_mappings"></a>21.3.8 Default Go primitive type mappings</H3>
<p>
diff --git a/Doc/Manual/Guile.html b/Doc/Manual/Guile.html
index 75c3d3473..111c48214 100644
--- a/Doc/Manual/Guile.html
+++ b/Doc/Manual/Guile.html
@@ -8,7 +8,7 @@
<body bgcolor="#ffffff">
-<H1><a name="Guile"></a>21 SWIG and Guile</H1>
+<H1><a name="Guile"></a>22 SWIG and Guile</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -47,7 +47,7 @@
<p>
This section details guile-specific support in SWIG.
-<H2><a name="Guile_nn2"></a>21.1 Meaning of "Module"</H2>
+<H2><a name="Guile_nn2"></a>22.1 Meaning of "Module"</H2>
<p>
@@ -55,7 +55,7 @@ There are three different concepts of "module" involved, defined
separately for SWIG, Guile, and Libtool. To avoid horrible confusion,
we explicitly prefix the context, e.g., "guile-module".
-<H2><a name="Guile_nn3"></a>21.2 Using the SCM or GH Guile API</H2>
+<H2><a name="Guile_nn3"></a>22.2 Using the SCM or GH Guile API</H2>
<p>The guile module can currently export wrapper files that use the guile GH interface or the
@@ -103,7 +103,7 @@ for the specific API. Currently only the guile language module has created a ma
but there is no reason other languages (like mzscheme or chicken) couldn't also use this.
If that happens, there is A LOT less code duplication in the standard typemaps.</p>
-<H2><a name="Guile_nn4"></a>21.3 Linkage</H2>
+<H2><a name="Guile_nn4"></a>22.3 Linkage</H2>
<p>
@@ -111,7 +111,7 @@ Guile support is complicated by a lack of user community cohesiveness,
which manifests in multiple shared-library usage conventions. A set of
policies implementing a usage convention is called a <b>linkage</b>.
-<H3><a name="Guile_nn5"></a>21.3.1 Simple Linkage</H3>
+<H3><a name="Guile_nn5"></a>22.3.1 Simple Linkage</H3>
<p>
@@ -206,7 +206,7 @@ placed between the <code>define-module</code> form and the
<code>SWIG_init</code> via a preprocessor define to avoid symbol
clashes. For this case, however, passive linkage is available.
-<H3><a name="Guile_nn6"></a>21.3.2 Passive Linkage</H3>
+<H3><a name="Guile_nn6"></a>22.3.2 Passive Linkage</H3>
<p>Passive linkage is just like simple linkage, but it generates an
@@ -216,7 +216,7 @@ package name (see below).
<p>You should use passive linkage rather than simple linkage when you
are using multiple modules.
-<H3><a name="Guile_nn7"></a>21.3.3 Native Guile Module Linkage</H3>
+<H3><a name="Guile_nn7"></a>22.3.3 Native Guile Module Linkage</H3>
<p>SWIG can also generate wrapper code that does all the Guile module
@@ -257,7 +257,7 @@ Newer Guile versions have a shorthand procedure for this:
</div>
</ul>
-<H3><a name="Guile_nn8"></a>21.3.4 Old Auto-Loading Guile Module Linkage</H3>
+<H3><a name="Guile_nn8"></a>22.3.4 Old Auto-Loading Guile Module Linkage</H3>
<p>Guile used to support an autoloading facility for object-code
@@ -283,7 +283,7 @@ option, SWIG generates an exported module initialization function with
an appropriate name.
-<H3><a name="Guile_nn9"></a>21.3.5 Hobbit4D Linkage</H3>
+<H3><a name="Guile_nn9"></a>22.3.5 Hobbit4D Linkage</H3>
<p>
@@ -308,7 +308,7 @@ my/lib/libfoo.so.X.Y.Z and friends. This scheme is still very
experimental; the (hobbit4d link) conventions are not well understood.
</p>
-<H2><a name="Guile_nn10"></a>21.4 Underscore Folding</H2>
+<H2><a name="Guile_nn10"></a>22.4 Underscore Folding</H2>
<p>
@@ -320,7 +320,7 @@ complained so far.
<code>%rename</code> to specify the Guile name of the wrapped
functions and variables (see CHANGES).
-<H2><a name="Guile_nn11"></a>21.5 Typemaps</H2>
+<H2><a name="Guile_nn11"></a>22.5 Typemaps</H2>
<p>
@@ -412,7 +412,7 @@ constant will appear as a scheme variable. See
<a href="Customization.html#Customization_features">Features and the %feature directive</a>
for info on how to apply the %feature.</p>
-<H2><a name="Guile_nn12"></a>21.6 Representation of pointers as smobs</H2>
+<H2><a name="Guile_nn12"></a>22.6 Representation of pointers as smobs</H2>
<p>
@@ -429,11 +429,11 @@ upper half of the CAR is read from this struct.
To get the pointer represented by a smob, the wrapper code calls the
function <code>SWIG_ConvertPtr()</code>, passing a pointer to a struct
representing the expected pointer type. See also
-<a href="Typemaps.html#runtime_type_checker">The run-time type checker</a>.
+<a href="Typemaps.html#Typemaps_runtime_type_checker">The run-time type checker</a>.
If the Scheme object passed was not a SWIG smob representing a compatible
pointer, a <code>wrong-type-arg</code> exception is raised.
-<H3><a name="Guile_nn13"></a>21.6.1 GH Smobs</H3>
+<H3><a name="Guile_nn13"></a>22.6.1 GH Smobs</H3>
<p>
@@ -462,7 +462,7 @@ that created them, so the first module we check will most likely be correct.
Once we have a swig_type_info structure, we loop through the linked list of
casts, using pointer comparisons.</p>
-<H3><a name="Guile_nn14"></a>21.6.2 SCM Smobs</H3>
+<H3><a name="Guile_nn14"></a>22.6.2 SCM Smobs</H3>
<p>The SCM interface (using the "-scm" argument to swig) uses swigrun.swg.
@@ -477,7 +477,7 @@ in the smob tag. If a generated GOOPS module has been loaded, smobs will be wra
GOOPS class.</p>
-<H3><a name="Guile_nn15"></a>21.6.3 Garbage Collection</H3>
+<H3><a name="Guile_nn15"></a>22.6.3 Garbage Collection</H3>
<p>Garbage collection is a feature of the new SCM interface, and it is automatically included
@@ -491,7 +491,7 @@ is exactly like described in <a href="Customization.html#Customization_ownership
Object ownership and %newobject</a> in the SWIG manual. All typemaps use an $owner var, and
the guile module replaces $owner with 0 or 1 depending on feature:new.</p>
-<H2><a name="Guile_nn16"></a>21.7 Exception Handling</H2>
+<H2><a name="Guile_nn16"></a>22.7 Exception Handling</H2>
<p>
@@ -517,7 +517,7 @@ mapping:
The default when not specified here is to use "swig-error".
See Lib/exception.i for details.
-<H2><a name="Guile_nn17"></a>21.8 Procedure documentation</H2>
+<H2><a name="Guile_nn17"></a>22.8 Procedure documentation</H2>
<p>If invoked with the command-line option <code>-procdoc
@@ -553,7 +553,7 @@ like this:
typemap argument <code>doc</code>. See <code>Lib/guile/typemaps.i</code> for
details.
-<H2><a name="Guile_nn18"></a>21.9 Procedures with setters</H2>
+<H2><a name="Guile_nn18"></a>22.9 Procedures with setters</H2>
<p>For global variables, SWIG creates a single wrapper procedure
@@ -581,7 +581,7 @@ struct members, the procedures <code>(<var>struct</var>-<var>member</var>-get
pointer)</code> and <code>(<var>struct-member</var>-set pointer
value)</code> are <em>not</em> generated.
-<H2><a name="Guile_nn19"></a>21.10 GOOPS Proxy Classes</H2>
+<H2><a name="Guile_nn19"></a>22.10 GOOPS Proxy Classes</H2>
<p>SWIG can also generate classes and generic functions for use with
@@ -730,7 +730,7 @@ Notice that &lt;Foo&gt; is used before it is defined. The fix is to just put th
<code>%import "foo.h"</code> before the <code>%inline</code> block.
</p>
-<H3><a name="Guile_nn20"></a>21.10.1 Naming Issues</H3>
+<H3><a name="Guile_nn20"></a>22.10.1 Naming Issues</H3>
<p>As you can see in the example above, there are potential naming conflicts. The default exported
@@ -767,7 +767,7 @@ guile-modules. For example,</p>
(use-modules ((Test) #:renamer (symbol-prefix-proc 'goops:)))
</pre></div>
-<H3><a name="Guile_nn21"></a>21.10.2 Linking</H3>
+<H3><a name="Guile_nn21"></a>22.10.2 Linking</H3>
<p>The guile-modules generated above all need to be linked together. GOOPS support requires
diff --git a/Doc/Manual/Introduction.html b/Doc/Manual/Introduction.html
index 3bac9484e..a8d15a5c2 100644
--- a/Doc/Manual/Introduction.html
+++ b/Doc/Manual/Introduction.html
@@ -195,9 +195,9 @@ extern int my_mod(int n, int m);
<p>
The interface file contains ANSI C function prototypes and variable
declarations. The <tt>%module</tt> directive defines the name of the
-module that will be created by SWIG. The <tt>%{,%}</tt> block
-provides a location for inserting additional code such as C header
-files or additional C declarations.
+module that will be created by SWIG. The <tt>%{ %}</tt> block
+provides a location for inserting additional code, such as C header
+files or additional C declarations, into the generated C wrapper code.
<H3><a name="Introduction_nn6"></a>2.3.2 The swig command</H3>
@@ -372,9 +372,9 @@ Microsoft Visual Studio.
<p>
If you are using the GNU Autotools
-(<a href="http://www.gnu.org/software/autoconf">Autoconf</a>/
-<a href="http://www.gnu.org/software/automake">Automake</a>/
-<a href="http://www.gnu.org/software/libtool">Libtool</a>)
+(<a href="http://www.gnu.org/software/autoconf/">Autoconf</a>/
+<a href="http://www.gnu.org/software/automake/">Automake</a>/
+<a href="http://www.gnu.org/software/libtool/">Libtool</a>)
to configure SWIG use in your project, the SWIG Autoconf macros can be used.
The primary macro is <tt>ax_pkg_swig</tt>, see
<a href="http://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html#ax_pkg_swig">http://www.gnu.org/software/autoconf-archive/ax_pkg_swig.html#ax_pkg_swig</a>.
diff --git a/Doc/Manual/Java.html b/Doc/Manual/Java.html
index f572ffa32..c6ef2b425 100644
--- a/Doc/Manual/Java.html
+++ b/Doc/Manual/Java.html
@@ -5,7 +5,7 @@
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body bgcolor="#FFFFFF">
-<H1><a name="Java"></a>22 SWIG and Java</H1>
+<H1><a name="Java"></a>23 SWIG and Java</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -154,7 +154,7 @@ It covers most SWIG features, but certain low-level details are covered in less
</p>
-<H2><a name="Java_overview"></a>22.1 Overview</H2>
+<H2><a name="Java_overview"></a>23.1 Overview</H2>
<p>
@@ -166,7 +166,7 @@ SWIG wraps C/C++ code using Java proxy classes and is very useful if you want to
If only one or two JNI functions are needed then using SWIG may be overkill.
SWIG enables a Java program to easily call into C/C++ code from Java.
Historically, SWIG was not able to generate any code to call into Java code from C++.
-However, SWIG now supports full cross language polymorphism and code is generated to call up from C++ to Java when wrapping C++ virtual methods.
+However, SWIG now supports full cross language polymorphism and code is generated to call up from C++ to Java when wrapping C++ virtual methods via the director feature.
</p>
<p>
@@ -189,7 +189,7 @@ Various customisation tips and techniques using SWIG directives are covered.
The latter sections cover the advanced techniques of using typemaps for complete control of the wrapping process.
</p>
-<H2><a name="Java_preliminaries"></a>22.2 Preliminaries</H2>
+<H2><a name="Java_preliminaries"></a>23.2 Preliminaries</H2>
<p>
@@ -205,7 +205,7 @@ Run <tt>make -k check</tt> from the SWIG root directory after installing SWIG on
The Java module requires your system to support shared libraries and dynamic loading.
This is the commonly used method to load JNI code so your system will more than likely support this.</p>
-<H3><a name="Java_running_swig"></a>22.2.1 Running SWIG</H3>
+<H3><a name="Java_running_swig"></a>23.2.1 Running SWIG</H3>
<p>
@@ -264,7 +264,7 @@ The following sections have further practical examples and details on how you mi
compiling and using the generated files.
</p>
-<H3><a name="Java_commandline"></a>22.2.2 Additional Commandline Options</H3>
+<H3><a name="Java_commandline"></a>23.2.2 Additional Commandline Options</H3>
<p>
@@ -301,7 +301,7 @@ swig -java -help
Their use will become clearer by the time you have finished reading this section on SWIG and Java.
</p>
-<H3><a name="Java_getting_right_headers"></a>22.2.3 Getting the right header files</H3>
+<H3><a name="Java_getting_right_headers"></a>23.2.3 Getting the right header files</H3>
<p>
@@ -316,7 +316,7 @@ They are usually in directories like this:</p>
<p>
The exact location may vary on your machine, but the above locations are typical. </p>
-<H3><a name="Java_compiling_dynamic"></a>22.2.4 Compiling a dynamic module</H3>
+<H3><a name="Java_compiling_dynamic"></a>23.2.4 Compiling a dynamic module</H3>
<p>
@@ -352,7 +352,7 @@ The name of the shared library output file is important.
If the name of your SWIG module is "<tt>example</tt>", the name of the corresponding shared library file should be "<tt>libexample.so</tt>" (or equivalent depending on your machine, see <a href="#Java_dynamic_linking_problems">Dynamic linking problems</a> for more information).
The name of the module is specified using the <tt>%module</tt> directive or<tt> -module</tt> command line option.</p>
-<H3><a name="Java_using_module"></a>22.2.5 Using your module</H3>
+<H3><a name="Java_using_module"></a>23.2.5 Using your module</H3>
<p>
@@ -363,7 +363,7 @@ To load your shared native library module in Java, simply use Java's <tt>System.
public class runme {
static {
-  System.loadLibrary("example");
+  System.loadLibrary("example");
}
public static void main(String argv[]) {
@@ -387,7 +387,7 @@ $
If it doesn't work have a look at the following section which discusses problems loading the shared library.
</p>
-<H3><a name="Java_dynamic_linking_problems"></a>22.2.6 Dynamic linking problems</H3>
+<H3><a name="Java_dynamic_linking_problems"></a>23.2.6 Dynamic linking problems</H3>
<p>
@@ -474,7 +474,7 @@ The following section also contains some C++ specific linking problems and solut
</p>
-<H3><a name="Java_compilation_problems_cpp"></a>22.2.7 Compilation problems and compiling with C++</H3>
+<H3><a name="Java_compilation_problems_cpp"></a>23.2.7 Compilation problems and compiling with C++</H3>
<p>
@@ -527,7 +527,7 @@ Finally make sure the version of JDK header files matches the version of Java th
</p>
-<H3><a name="Java_building_windows"></a>22.2.8 Building on Windows</H3>
+<H3><a name="Java_building_windows"></a>23.2.8 Building on Windows</H3>
<p>
@@ -536,7 +536,7 @@ You will want to produce a DLL that can be loaded by the Java Virtual Machine.
This section covers the process of using SWIG with Microsoft Visual C++ 6 although the procedure may be similar with other compilers.
In order for everything to work, you will need to have a JDK installed on your machine in order to read the JNI header files.</p>
-<H4><a name="Java_visual_studio"></a>22.2.8.1 Running SWIG from Visual Studio</H4>
+<H4><a name="Java_visual_studio"></a>23.2.8.1 Running SWIG from Visual Studio</H4>
<p>
@@ -575,7 +575,7 @@ To run the native code in the DLL (example.dll), make sure that it is in your pa
If the library fails to load have a look at <a href="#Java_dynamic_linking_problems">Dynamic linking problems</a>.
</p>
-<H4><a name="Java_nmake"></a>22.2.8.2 Using NMAKE</H4>
+<H4><a name="Java_nmake"></a>23.2.8.2 Using NMAKE</H4>
<p>
@@ -634,7 +634,7 @@ Of course you may want to make changes for it to work for C++ by adding in the -
</p>
-<H2><a name="Java_basic_tour"></a>22.3 A tour of basic C/C++ wrapping</H2>
+<H2><a name="Java_basic_tour"></a>23.3 A tour of basic C/C++ wrapping</H2>
<p>
@@ -644,7 +644,7 @@ variables are wrapped with JavaBean type getters and setters and so forth.
This section briefly covers the essential aspects of this wrapping.
</p>
-<H3><a name="Java_module_packages_classes"></a>22.3.1 Modules, packages and generated Java classes</H3>
+<H3><a name="Java_module_packages_classes"></a>23.3.1 Modules, packages and generated Java classes</H3>
<p>
@@ -680,7 +680,7 @@ swig -java -package com.bloggs.swig -outdir com/bloggs/swig example.i
SWIG won't create the directory, so make sure it exists beforehand.
</p>
-<H3><a name="Java_functions"></a>22.3.2 Functions</H3>
+<H3><a name="Java_functions"></a>23.3.2 Functions</H3>
<p>
@@ -714,7 +714,7 @@ System.out.println(example.fact(4));
</pre></div>
-<H3><a name="Java_global_variables"></a>22.3.3 Global variables</H3>
+<H3><a name="Java_global_variables"></a>23.3.3 Global variables</H3>
<p>
@@ -801,7 +801,7 @@ extern char *path; // Read-only (due to %immutable)
</div>
-<H3><a name="Java_constants"></a>22.3.4 Constants</H3>
+<H3><a name="Java_constants"></a>23.3.4 Constants</H3>
<p>
@@ -941,7 +941,7 @@ Or if you decide this practice isn't so bad and your own class implements <tt>ex
</p>
-<H3><a name="Java_enumerations"></a>22.3.5 Enumerations</H3>
+<H3><a name="Java_enumerations"></a>23.3.5 Enumerations</H3>
<p>
@@ -955,7 +955,7 @@ The final two approaches use simple integers for each enum item.
Before looking at the various approaches for wrapping named C/C++ enums, anonymous enums are considered.
</p>
-<H4><a name="Java_anonymous_enums"></a>22.3.5.1 Anonymous enums</H4>
+<H4><a name="Java_anonymous_enums"></a>23.3.5.1 Anonymous enums</H4>
<p>
@@ -1018,7 +1018,7 @@ As in the case of constants, you can access them through either the module class
</p>
-<H4><a name="Java_typesafe_enums"></a>22.3.5.2 Typesafe enums</H4>
+<H4><a name="Java_typesafe_enums"></a>23.3.5.2 Typesafe enums</H4>
<p>
@@ -1112,7 +1112,7 @@ When upgrading to JDK 1.5 or later, proper Java enums could be used instead, wit
The following section details proper Java enum generation.
</p>
-<H4><a name="Java_proper_enums"></a>22.3.5.3 Proper Java enums</H4>
+<H4><a name="Java_proper_enums"></a>23.3.5.3 Proper Java enums</H4>
<p>
@@ -1165,7 +1165,7 @@ The additional support methods need not be generated if none of the enum items h
<a href="#Java_simpler_enum_classes">Simpler Java enums for enums without initializers</a> section.
</p>
-<H4><a name="Java_typeunsafe_enums"></a>22.3.5.4 Type unsafe enums</H4>
+<H4><a name="Java_typeunsafe_enums"></a>23.3.5.4 Type unsafe enums</H4>
<p>
@@ -1213,7 +1213,7 @@ Note that unlike typesafe enums, this approach requires users to mostly use diff
Thus the upgrade path to proper enums provided in JDK 1.5 is more painful.
</p>
-<H4><a name="Java_simple_enums"></a>22.3.5.5 Simple enums</H4>
+<H4><a name="Java_simple_enums"></a>23.3.5.5 Simple enums</H4>
<p>
@@ -1232,7 +1232,7 @@ SWIG-1.3.21 and earlier versions wrapped all enums using this approach.
The type unsafe approach is preferable to this one and this simple approach is only included for backwards compatibility with these earlier versions of SWIG.
</p>
-<H3><a name="Java_pointers"></a>22.3.6 Pointers</H3>
+<H3><a name="Java_pointers"></a>23.3.6 Pointers</H3>
<p>
@@ -1320,7 +1320,7 @@ C-style cast may return a bogus result whereas as the C++-style cast will return
a NULL pointer if the conversion can't be performed.
</p>
-<H3><a name="Java_structures"></a>22.3.7 Structures</H3>
+<H3><a name="Java_structures"></a>23.3.7 Structures</H3>
<p>
@@ -1488,7 +1488,7 @@ x.setA(3); // Modify x.a - this is the same as b.f.a
</div>
-<H3><a name="Java_classes"></a>22.3.8 C++ classes</H3>
+<H3><a name="Java_classes"></a>23.3.8 C++ classes</H3>
<p>
@@ -1551,7 +1551,7 @@ int bar = Spam.getBar();
</div>
-<H3><a name="Java_inheritance"></a>22.3.9 C++ inheritance</H3>
+<H3><a name="Java_inheritance"></a>23.3.9 C++ inheritance</H3>
<p>
@@ -1612,7 +1612,7 @@ Note that Java does not support multiple inheritance so any multiple inheritance
A warning is given when multiple inheritance is detected and only the first base class is used.
</p>
-<H3><a name="Java_pointers_refs_arrays"></a>22.3.10 Pointers, references, arrays and pass by value</H3>
+<H3><a name="Java_pointers_refs_arrays"></a>23.3.10 Pointers, references, arrays and pass by value</H3>
<p>
@@ -1667,7 +1667,7 @@ to hold the result and a pointer is returned (Java will release this memory
when the returned object's finalizer is run by the garbage collector).
</p>
-<H4><a name="Java_null_pointers"></a>22.3.10.1 Null pointers</H4>
+<H4><a name="Java_null_pointers"></a>23.3.10.1 Null pointers</H4>
<p>
@@ -1691,7 +1691,7 @@ For <tt>spam1</tt> and <tt>spam4</tt> above the Java <tt>null</tt> gets translat
The converse also occurs, that is, NULL pointers are translated into <tt>null</tt> Java objects when returned from a C/C++ function.
</p>
-<H3><a name="Java_overloaded_functions"></a>22.3.11 C++ overloaded functions</H3>
+<H3><a name="Java_overloaded_functions"></a>23.3.11 C++ overloaded functions</H3>
<p>
@@ -1806,7 +1806,7 @@ void spam(unsigned short); // Ignored
</pre>
</div>
-<H3><a name="Java_default_arguments"></a>22.3.12 C++ default arguments</H3>
+<H3><a name="Java_default_arguments"></a>23.3.12 C++ default arguments</H3>
<p>
@@ -1849,7 +1849,7 @@ Further details on default arguments and how to restore this approach are given
</p>
-<H3><a name="Java_namespaces"></a>22.3.13 C++ namespaces</H3>
+<H3><a name="Java_namespaces"></a>23.3.13 C++ namespaces</H3>
<p>
@@ -1922,12 +1922,14 @@ So if SWIG is run using the <tt>-package com.myco</tt> option, a wrapped class,
<div class="shell">
<pre>
-example.i:16: Error: The nspace feature used on 'MyWorld::Material::Color' is not supported unless a package is specified
-with -package - Java does not support types declared in a named package accessing types declared in an unnamed package.
+example.i:16: Error: The nspace feature used on 'MyWorld::Material::Color' is not supported unless
+a package is specified
+with -package - Java does not support types declared in a named package accessing types declared
+in an unnamed package.
</pre>
</div>
-<H3><a name="Java_templates"></a>22.3.14 C++ templates</H3>
+<H3><a name="Java_templates"></a>23.3.14 C++ templates</H3>
<p>
@@ -1976,7 +1978,7 @@ Obviously, there is more to template wrapping than shown in this example.
More details can be found in the <a href="SWIGPlus.html#SWIGPlus">SWIG and C++</a> chapter.
</p>
-<H3><a name="Java_smart_pointers"></a>22.3.15 C++ Smart Pointers</H3>
+<H3><a name="Java_smart_pointers"></a>23.3.15 C++ Smart Pointers</H3>
<p>
@@ -2060,7 +2062,7 @@ Foo f = p.__deref__(); // Returns underlying Foo *
</pre>
</div>
-<H2><a name="Java_further_details"></a>22.4 Further details on the generated Java classes</H2>
+<H2><a name="Java_further_details"></a>23.4 Further details on the generated Java classes</H2>
<p>
@@ -2075,7 +2077,7 @@ Finally enum classes are covered.
First, the crucial intermediary JNI class is considered.
</p>
-<H3><a name="Java_imclass"></a>22.4.1 The intermediary JNI class</H3>
+<H3><a name="Java_imclass"></a>23.4.1 The intermediary JNI class</H3>
<p>
@@ -2195,7 +2197,7 @@ If <tt>name</tt> is the same as <tt>modulename</tt> then the module class name g
from <tt>modulename</tt> to <tt>modulenameModule</tt>.
</p>
-<H4><a name="Java_imclass_pragmas"></a>22.4.1.1 The intermediary JNI class pragmas</H4>
+<H4><a name="Java_imclass_pragmas"></a>23.4.1.1 The intermediary JNI class pragmas</H4>
<p>
@@ -2274,7 +2276,7 @@ For example, let's change the intermediary JNI class access to just the default
All the methods in the intermediary JNI class will then not be callable outside of the package as the method modifiers have been changed from public access to default access. This is useful if you want to prevent users calling these low level functions.
</p>
-<H3><a name="Java_module_class"></a>22.4.2 The Java module class</H3>
+<H3><a name="Java_module_class"></a>23.4.2 The Java module class</H3>
<p>
@@ -2305,7 +2307,7 @@ example.egg(new Foo());
The primary reason for having the module class wrapping the calls in the intermediary JNI class is to implement static type checking. In this case only a <tt>Foo</tt> can be passed to the <tt>egg</tt> function, whereas any <tt>long</tt> can be passed to the <tt>egg</tt> function in the intermediary JNI class.
</p>
-<H4><a name="Java_module_class_pragmas"></a>22.4.2.1 The Java module class pragmas</H4>
+<H4><a name="Java_module_class_pragmas"></a>23.4.2.1 The Java module class pragmas</H4>
<p>
@@ -2356,7 +2358,7 @@ See <a href="#Java_imclass_pragmas">The intermediary JNI class pragmas</a> secti
</p>
-<H3><a name="Java_proxy_classes"></a>22.4.3 Java proxy classes</H3>
+<H3><a name="Java_proxy_classes"></a>23.4.3 Java proxy classes</H3>
<p>
@@ -2432,7 +2434,7 @@ int y = f.spam(5, new Foo());
</pre>
</div>
-<H4><a name="Java_memory_management"></a>22.4.3.1 Memory management</H4>
+<H4><a name="Java_memory_management"></a>23.4.3.1 Memory management</H4>
<p>
@@ -2594,7 +2596,7 @@ and
</p>
-<H4><a name="Java_inheritance_mirroring"></a>22.4.3.2 Inheritance</H4>
+<H4><a name="Java_inheritance_mirroring"></a>23.4.3.2 Inheritance</H4>
<p>
@@ -2710,7 +2712,7 @@ However, true cross language polymorphism can be achieved using the <a href="#Ja
</p>
-<H4><a name="Java_proxy_classes_gc"></a>22.4.3.3 Proxy classes and garbage collection</H4>
+<H4><a name="Java_proxy_classes_gc"></a>23.4.3.3 Proxy classes and garbage collection</H4>
<p>
@@ -2743,7 +2745,7 @@ Call the <tt>System.runFinalizersOnExit(true)</tt> or <tt>Runtime.getRuntime().r
This method is inherently unsafe. It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects, resulting in erratic behavior or deadlock.
</i></div>
<p>In many cases you will be lucky and find that it works, but it is not to be advocated.
-Have a look at <a href="http://java.sun.com">Sun's Java web site</a> and search for <tt>runFinalizersOnExit</tt>.
+Have a look at <a href="http://www.oracle.com/technetwork/java/index.html">Java web site</a> and search for <tt>runFinalizersOnExit</tt>.
</p></li>
<li><p>
@@ -2793,7 +2795,7 @@ The section on <a href="#Java_typemaps">Java typemaps</a> details how to specify
See the <a href="http://www.devx.com/Java/Article/30192">How to Handle Java Finalization's Memory-Retention Issues</a> article for alternative approaches to managing memory by avoiding finalizers altogether.
</p>
-<H4><a name="Java_pgcpp"></a>22.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling</H4>
+<H4><a name="Java_pgcpp"></a>23.4.3.4 The premature garbage collection prevention parameter for proxy class marshalling</H4>
<p>
@@ -2915,7 +2917,7 @@ For example:
<b>Compatibility note:</b> The generation of this additional parameter did not occur in versions prior to SWIG-1.3.30.
</p>
-<H4><a name="Java_multithread_libraries"></a>22.4.3.5 Single threaded applications and thread safety</H4>
+<H4><a name="Java_multithread_libraries"></a>23.4.3.5 Single threaded applications and thread safety</H4>
<p>
@@ -3003,7 +3005,7 @@ for (int i=0; i&lt;100000; i++) {
</pre></div>
-<H3><a name="Java_type_wrapper_classes"></a>22.4.4 Type wrapper classes</H3>
+<H3><a name="Java_type_wrapper_classes"></a>23.4.4 Type wrapper classes</H3>
<p>
@@ -3090,7 +3092,7 @@ public static void spam(SWIGTYPE_p_int x, SWIGTYPE_p_int y, int z) { ... }
</div>
-<H3><a name="Java_enum_classes"></a>22.4.5 Enum classes</H3>
+<H3><a name="Java_enum_classes"></a>23.4.5 Enum classes</H3>
<p>
@@ -3099,7 +3101,7 @@ The <a href="#Java_enumerations">Enumerations</a> section discussed these but om
The following sub-sections detail the various types of enum classes that can be generated.
</p>
-<H4><a name="Java_typesafe_enums_classes"></a>22.4.5.1 Typesafe enum classes</H4>
+<H4><a name="Java_typesafe_enums_classes"></a>23.4.5.1 Typesafe enum classes</H4>
<p>
@@ -3183,7 +3185,7 @@ The <tt>swigValue</tt> method is used for marshalling in the other direction.
The <tt>toString</tt> method is overridden so that the enum name is available.
</p>
-<H4><a name="Java_proper_enums_classes"></a>22.4.5.2 Proper Java enum classes</H4>
+<H4><a name="Java_proper_enums_classes"></a>23.4.5.2 Proper Java enum classes</H4>
<p>
@@ -3261,7 +3263,7 @@ These needn't be generated if the enum being wrapped does not have any initializ
<a href="#Java_simpler_enum_classes">Simpler Java enums for enums without initializers</a> section describes how typemaps can be used to achieve this.
</p>
-<H4><a name="Java_typeunsafe_enums_classes"></a>22.4.5.3 Type unsafe enum classes</H4>
+<H4><a name="Java_typeunsafe_enums_classes"></a>23.4.5.3 Type unsafe enum classes</H4>
<p>
@@ -3292,7 +3294,7 @@ public final class Beverage {
</pre>
</div>
-<H2><a name="Java_directors"></a>22.5 Cross language polymorphism using directors</H2>
+<H2><a name="Java_directors"></a>23.5 Cross language polymorphism using directors</H2>
<p>
@@ -3314,7 +3316,7 @@ The upshot is that C++ classes can be extended in Java and from C++ these extens
Neither C++ code nor Java code needs to know where a particular method is implemented: the combination of proxy classes, director classes, and C wrapper functions transparently takes care of all the cross-language method routing.
</p>
-<H3><a name="Java_enabling_directors"></a>22.5.1 Enabling directors</H3>
+<H3><a name="Java_enabling_directors"></a>23.5.1 Enabling directors</H3>
<p>
@@ -3385,7 +3387,7 @@ public:
</pre>
</div>
-<H3><a name="Java_directors_classes"></a>22.5.2 Director classes</H3>
+<H3><a name="Java_directors_classes"></a>23.5.2 Director classes</H3>
<p>
@@ -3412,7 +3414,7 @@ If the correct implementation is in Java, the Java API is used to call the metho
</p>
-<H3><a name="Java_directors_overhead"></a>22.5.3 Overhead and code bloat</H3>
+<H3><a name="Java_directors_overhead"></a>23.5.3 Overhead and code bloat</H3>
<p>
@@ -3430,7 +3432,7 @@ This situation can be optimized by selectively enabling director methods (using
</p>
-<H3><a name="Java_directors_example"></a>22.5.4 Simple directors example</H3>
+<H3><a name="Java_directors_example"></a>23.5.4 Simple directors example</H3>
<p>
@@ -3495,7 +3497,7 @@ DirectorDerived::upcall_method() invoked.
</pre>
</div>
-<H3><a name="Java_directors_threading"></a>22.5.5 Director threading issues</H3>
+<H3><a name="Java_directors_threading"></a>23.5.5 Director threading issues</H3>
<p>
@@ -3515,7 +3517,7 @@ Macros can be defined on the commandline when compiling your C++ code, or altern
</pre>
</div>
-<H2><a name="Java_allprotected"></a>22.6 Accessing protected members</H2>
+<H2><a name="Java_allprotected"></a>23.6 Accessing protected members</H2>
<p>
@@ -3611,7 +3613,7 @@ class MyProtectedBase extends ProtectedBase
-<H2><a name="Java_common_customization"></a>22.7 Common customization features</H2>
+<H2><a name="Java_common_customization"></a>23.7 Common customization features</H2>
<p>
@@ -3623,7 +3625,7 @@ be awkward. This section describes some common SWIG features that are used
to improve the interface to existing C/C++ code.
</p>
-<H3><a name="Java_helper_functions"></a>22.7.1 C/C++ helper functions</H3>
+<H3><a name="Java_helper_functions"></a>23.7.1 C/C++ helper functions</H3>
<p>
@@ -3689,7 +3691,7 @@ hard to implement. It is possible to improve on this using Java code, typemaps,
customization features as covered in later sections, but sometimes helper functions are a quick and easy solution to difficult cases.
</p>
-<H3><a name="Java_class_extension"></a>22.7.2 Class extension with %extend</H3>
+<H3><a name="Java_class_extension"></a>23.7.2 Class extension with %extend</H3>
<p>
@@ -3752,7 +3754,7 @@ Vector(2,3,4)
in any way---the extensions only show up in the Java interface.
</p>
-<H3><a name="Java_exception_handling"></a>22.7.3 Exception handling with %exception and %javaexception</H3>
+<H3><a name="Java_exception_handling"></a>23.7.3 Exception handling with %exception and %javaexception</H3>
<p>
@@ -3911,7 +3913,7 @@ to raise exceptions. See the <a href="Library.html#Library">SWIG Library</a> ch
The typemap example <a href="#Java_exception_typemap">Handling C++ exception specifications as Java exceptions</a> provides further exception handling capabilities.
</p>
-<H3><a name="Java_method_access"></a>22.7.4 Method access with %javamethodmodifiers</H3>
+<H3><a name="Java_method_access"></a>23.7.4 Method access with %javamethodmodifiers</H3>
<p>
@@ -3937,7 +3939,7 @@ protected static void protect_me() {
</pre>
</div>
-<H2><a name="Java_tips_techniques"></a>22.8 Tips and techniques</H2>
+<H2><a name="Java_tips_techniques"></a>23.8 Tips and techniques</H2>
<p>
@@ -3947,7 +3949,7 @@ strings and arrays. This chapter discusses the common techniques for
solving these problems.
</p>
-<H3><a name="Java_input_output_parameters"></a>22.8.1 Input and output parameters using primitive pointers and references</H3>
+<H3><a name="Java_input_output_parameters"></a>23.8.1 Input and output parameters using primitive pointers and references</H3>
<p>
@@ -4121,7 +4123,7 @@ void foo(Bar *OUTPUT);
will not have the intended effect since <tt>typemaps.i</tt> does not define an OUTPUT rule for <tt>Bar</tt>.
</p>
-<H3><a name="Java_simple_pointers"></a>22.8.2 Simple pointers</H3>
+<H3><a name="Java_simple_pointers"></a>23.8.2 Simple pointers</H3>
<p>
@@ -4187,7 +4189,7 @@ System.out.println("3 + 4 = " + result);
See the <a href="Library.html#Library">SWIG Library</a> chapter for further details.
</p>
-<H3><a name="Java_c_arrays"></a>22.8.3 Wrapping C arrays with Java arrays</H3>
+<H3><a name="Java_c_arrays"></a>23.8.3 Wrapping C arrays with Java arrays</H3>
<p>
@@ -4254,7 +4256,7 @@ Please be aware that the typemaps in this library are not efficient as all the e
There is an alternative approach using the SWIG array library and this is covered in the next section.
</p>
-<H3><a name="Java_unbounded_c_arrays"></a>22.8.4 Unbounded C Arrays</H3>
+<H3><a name="Java_unbounded_c_arrays"></a>23.8.4 Unbounded C Arrays</H3>
<p>
@@ -4399,7 +4401,50 @@ well suited for applications in which you need to create buffers,
package binary data, etc.
</p>
-<H3><a name="Java_heap_allocations"></a>22.8.5 Overriding new and delete to allocate from Java heap</H3>
+<H3><a name="Java_binary_char"></a>Binary data vs Strings</H3>
+
+<p>
+By default SWIG handles <tt>char *</tt> as a string but there is a handy multi-argument typemap available as mentioned in <a href="Library.html#Library_nn10">Passing binary data</a>.
+The following simple example demonstrates using a byte array instead of passing the default string type and length to the wrapped function.
+</p>
+
+
+<div class="code">
+<pre>
+%apply (char *STRING, size_t LENGTH) { (const char data[], size_t len) }
+%inline %{
+void binaryChar1(const char data[], size_t len) {
+ printf("len: %d data: ", len);
+ for (size_t i=0; i&lt;len; ++i)
+ printf("%x ", data[i]);
+ printf("\n");
+}
+%}
+</pre>
+</div>
+
+<p>
+Calling from Java requires just the byte array to be passed in as the multi-argument typemap being applied reduces the number of arguments in the target language to one, from the original two:
+</p>
+
+<div class="code">
+<pre>
+byte[] data = "hi\0jk".getBytes();
+example.binaryChar1(data);
+</pre>
+</div>
+
+<p>
+resulting in the output
+</p>
+
+<div class="code"><pre>
+$ java runme
+len: 5 data: 68 69 0 6a 6b
+</pre></div>
+
+
+<H3><a name="Java_heap_allocations"></a>23.8.5 Overriding new and delete to allocate from Java heap</H3>
<p>
@@ -4516,7 +4561,7 @@ model and use these functions in place of malloc and free in your own
code.
</p>
-<H2><a name="Java_typemaps"></a>22.9 Java typemaps</H2>
+<H2><a name="Java_typemaps"></a>23.9 Java typemaps</H2>
<p>
@@ -4537,7 +4582,7 @@ Before proceeding, it should be stressed that typemaps are not a required
part of using SWIG---the default wrapping behavior is enough in most cases.
Typemaps are only used if you want to change some aspect of the generated code.
-<H3><a name="Java_default_primitive_type_mappings"></a>22.9.1 Default primitive type mappings</H3>
+<H3><a name="Java_default_primitive_type_mappings"></a>23.9.1 Default primitive type mappings</H3>
<p>
@@ -4689,7 +4734,7 @@ However, the mappings allow the full range of values for each C type from Java.
</p>
-<H3><a name="Java_default_non_primitive_typemaps"></a>22.9.2 Default typemaps for non-primitive types</H3>
+<H3><a name="Java_default_non_primitive_typemaps"></a>23.9.2 Default typemaps for non-primitive types</H3>
<p>
@@ -4704,7 +4749,7 @@ So in summary, the C/C++ pointer to non-primitive types is cast into the 64 bit
The Java type is either the proxy class or type wrapper class.
</p>
-<H3><a name="Java_jvm64"></a>22.9.3 Sixty four bit JVMs</H3>
+<H3><a name="Java_jvm64"></a>23.9.3 Sixty four bit JVMs</H3>
<p>
@@ -4717,7 +4762,7 @@ Unfortunately it won't of course hold true for JNI code.
</p>
-<H3><a name="Java_what_is_typemap"></a>22.9.4 What is a typemap?</H3>
+<H3><a name="Java_what_is_typemap"></a>23.9.4 What is a typemap?</H3>
<p>
@@ -4840,7 +4885,7 @@ int c = example.count('e',"Hello World");
</pre>
</div>
-<H3><a name="Java_typemaps_c_to_java_types"></a>22.9.5 Typemaps for mapping C/C++ types to Java types</H3>
+<H3><a name="Java_typemaps_c_to_java_types"></a>23.9.5 Typemaps for mapping C/C++ types to Java types</H3>
<p>
@@ -5100,7 +5145,7 @@ These are listed below:
</table>
-<H3><a name="Java_typemap_attributes"></a>22.9.6 Java typemap attributes</H3>
+<H3><a name="Java_typemap_attributes"></a>23.9.6 Java typemap attributes</H3>
<p>
@@ -5146,7 +5191,7 @@ The "javain" typemap has the optional 'pre', 'post' and 'pgcppname' attributes.
Note that when the 'pre' or 'post' attributes are specified and the associated type is used in a constructor, a constructor helper function is generated. This is necessary as the Java proxy constructor wrapper makes a call to a support constructor using a <i>this</i> call. In Java the <i>this</i> call must be the first statement in the constructor body. The constructor body thus calls the helper function and the helper function instead makes the JNI call, ensuring the 'pre' code is called before the JNI call is made. There is a <a href="#Java_date_marshalling">Date marshalling</a> example showing 'pre', 'post' and 'pgcppname' attributes in action.
</p>
-<H3><a name="Java_special_variables"></a>22.9.7 Java special variables</H3>
+<H3><a name="Java_special_variables"></a>23.9.7 Java special variables</H3>
<p>
@@ -5297,7 +5342,7 @@ This special variable expands to the intermediary class name. Usually this is th
unless the jniclassname attribute is specified in the <a href="Java.html#Java_module_directive">%module directive</a>.
</p>
-<H3><a name="Java_typemaps_for_c_and_cpp"></a>22.9.8 Typemaps for both C and C++ compilation</H3>
+<H3><a name="Java_typemaps_for_c_and_cpp"></a>23.9.8 Typemaps for both C and C++ compilation</H3>
<p>
@@ -5334,7 +5379,7 @@ If you do not intend your code to be targeting both C and C++ then your typemaps
</p>
-<H3><a name="Java_code_typemaps"></a>22.9.9 Java code typemaps</H3>
+<H3><a name="Java_code_typemaps"></a>23.9.9 Java code typemaps</H3>
<p>
@@ -5540,7 +5585,7 @@ For the typemap to be used in all type wrapper classes, all the different types
Again this is the same that is in "<tt>java.swg</tt>", barring the method modifier for <tt>getCPtr</tt>.
</p>
-<H3><a name="Java_directors_typemaps"></a>22.9.10 Director specific typemaps</H3>
+<H3><a name="Java_directors_typemaps"></a>23.9.10 Director specific typemaps</H3>
<p>
@@ -5765,7 +5810,7 @@ The basic strategy here is to provide a default package typemap for the majority
</div>
-<H2><a name="Java_typemap_examples"></a>22.10 Typemap Examples</H2>
+<H2><a name="Java_typemap_examples"></a>23.10 Typemap Examples</H2>
<p>
@@ -5775,7 +5820,7 @@ the SWIG library.
</p>
-<H3><a name="Java_simpler_enum_classes"></a>22.10.1 Simpler Java enums for enums without initializers</H3>
+<H3><a name="Java_simpler_enum_classes"></a>23.10.1 Simpler Java enums for enums without initializers</H3>
<p>
@@ -5854,7 +5899,7 @@ This would be done by using the original versions of these typemaps in "enums.sw
</p>
-<H3><a name="Java_exception_typemap"></a>22.10.2 Handling C++ exception specifications as Java exceptions</H3>
+<H3><a name="Java_exception_typemap"></a>23.10.2 Handling C++ exception specifications as Java exceptions</H3>
<p>
@@ -5979,7 +6024,7 @@ We could alternatively have used <tt>%rename</tt> to rename <tt>what()</tt> into
</p>
-<H3><a name="Java_nan_exception_typemap"></a>22.10.3 NaN Exception - exception handling for a particular type</H3>
+<H3><a name="Java_nan_exception_typemap"></a>23.10.3 NaN Exception - exception handling for a particular type</H3>
<p>
@@ -6134,7 +6179,7 @@ If we were a martyr to the JNI cause, we could replace the succinct code within
If we had, we would have put it in the "in" typemap which, like all JNI and Java typemaps, also supports the 'throws' attribute.
</p>
-<H3><a name="Java_converting_java_string_arrays"></a>22.10.4 Converting Java String arrays to char ** </H3>
+<H3><a name="Java_converting_java_string_arrays"></a>23.10.4 Converting Java String arrays to char ** </H3>
<p>
@@ -6234,7 +6279,7 @@ public class runme {
static {
try {
-  System.loadLibrary("example");
+  System.loadLibrary("example");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. " + e);
System.exit(1);
@@ -6278,7 +6323,7 @@ Lastly the "jni", "jtype" and "jstype" typemaps are also required to specify
what Java types to use.
</p>
-<H3><a name="Java_expanding_java_object"></a>22.10.5 Expanding a Java object to multiple arguments</H3>
+<H3><a name="Java_expanding_java_object"></a>23.10.5 Expanding a Java object to multiple arguments</H3>
<p>
@@ -6360,7 +6405,7 @@ example.foo(new String[]{"red", "green", "blue", "white"});
</div>
-<H3><a name="Java_using_typemaps_return_arguments"></a>22.10.6 Using typemaps to return arguments</H3>
+<H3><a name="Java_using_typemaps_return_arguments"></a>23.10.6 Using typemaps to return arguments</H3>
<p>
@@ -6453,7 +6498,7 @@ public class runme {
static {
try {
-  System.loadLibrary("example");
+  System.loadLibrary("example");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. " + e);
System.exit(1);
@@ -6478,7 +6523,7 @@ $ java runme
1 12.0 340.0
</pre></div>
-<H3><a name="Java_adding_downcasts"></a>22.10.7 Adding Java downcasts to polymorphic return types</H3>
+<H3><a name="Java_adding_downcasts"></a>23.10.7 Adding Java downcasts to polymorphic return types</H3>
<p>
@@ -6684,7 +6729,7 @@ SWIG usually generates code which constructs the proxy classes using Java code a
Note that the JNI code above uses a number of string lookups to call a constructor, whereas this would not occur using byte compiled Java code.
</p>
-<H3><a name="Java_adding_equals_method"></a>22.10.8 Adding an equals method to the Java classes</H3>
+<H3><a name="Java_adding_equals_method"></a>23.10.8 Adding an equals method to the Java classes</H3>
<p>
@@ -6728,7 +6773,7 @@ System.out.println("foo1? " + foo1.equals(foo2));
</div>
-<H3><a name="Java_void_pointers"></a>22.10.9 Void pointers and a common Java base class</H3>
+<H3><a name="Java_void_pointers"></a>23.10.9 Void pointers and a common Java base class</H3>
<p>
@@ -6787,7 +6832,7 @@ This example contains some useful functionality which you may want in your code.
<li> It also has a function which effectively implements a cast from the type of the proxy/type wrapper class to a void pointer. This is necessary for passing a proxy class or a type wrapper class to a function that takes a void pointer.
</ul>
-<H3><a name="Java_struct_pointer_pointer"></a>22.10.10 Struct pointer to pointer</H3>
+<H3><a name="Java_struct_pointer_pointer"></a>23.10.10 Struct pointer to pointer</H3>
<p>
@@ -6967,7 +7012,7 @@ The C functional interface has been completely morphed into an object-oriented i
the Butler class would behave much like any pure Java class and feel more natural to Java users.
</p>
-<H3><a name="Java_memory_management_member_variables"></a>22.10.11 Memory management when returning references to member variables</H3>
+<H3><a name="Java_memory_management_member_variables"></a>23.10.11 Memory management when returning references to member variables</H3>
<p>
@@ -7090,7 +7135,7 @@ public class Bike {
Note the <tt>addReference</tt> call.
</p>
-<H3><a name="Java_memory_management_objects"></a>22.10.12 Memory management for objects passed to the C++ layer</H3>
+<H3><a name="Java_memory_management_objects"></a>23.10.12 Memory management for objects passed to the C++ layer</H3>
<p>
@@ -7206,7 +7251,7 @@ The 'javacode' typemap simply adds in the specified code into the Java proxy cla
</div>
-<H3><a name="Java_date_marshalling"></a>22.10.13 Date marshalling using the javain typemap and associated attributes</H3>
+<H3><a name="Java_date_marshalling"></a>23.10.13 Date marshalling using the javain typemap and associated attributes</H3>
<p>
@@ -7383,7 +7428,7 @@ A few things to note:
-<H2><a name="Java_directors_faq"></a>22.11 Living with Java Directors</H2>
+<H2><a name="Java_directors_faq"></a>23.11 Living with Java Directors</H2>
<p>
@@ -7564,10 +7609,10 @@ public abstract class UserVisibleFoo extends Foo {
</li>
</ol>
-<H2><a name="Java_odds_ends"></a>22.12 Odds and ends</H2>
+<H2><a name="Java_odds_ends"></a>23.12 Odds and ends</H2>
-<H3><a name="Java_javadoc_comments"></a>22.12.1 JavaDoc comments</H3>
+<H3><a name="Java_javadoc_comments"></a>23.12.1 JavaDoc comments</H3>
<p>
@@ -7623,7 +7668,7 @@ public class Barmy {
-<H3><a name="Java_functional_interface"></a>22.12.2 Functional interface without proxy classes</H3>
+<H3><a name="Java_functional_interface"></a>23.12.2 Functional interface without proxy classes</H3>
<p>
@@ -7684,7 +7729,7 @@ All destructors have to be called manually for example the <tt>delete_Foo(foo)</
</p>
-<H3><a name="Java_using_own_jni_functions"></a>22.12.3 Using your own JNI functions</H3>
+<H3><a name="Java_using_own_jni_functions"></a>23.12.3 Using your own JNI functions</H3>
<p>
@@ -7734,7 +7779,7 @@ This directive is only really useful if you want to mix your own hand crafted JN
</p>
-<H3><a name="Java_performance"></a>22.12.4 Performance concerns and hints</H3>
+<H3><a name="Java_performance"></a>23.12.4 Performance concerns and hints</H3>
<p>
@@ -7755,7 +7800,7 @@ However, you will have to be careful about memory management and make sure that
This method normally calls the C++ destructor or <tt>free()</tt> for C code.
</p>
-<H3><a name="Java_debugging"></a>22.12.5 Debugging</H3>
+<H3><a name="Java_debugging"></a>23.12.5 Debugging</H3>
<p>
@@ -7777,7 +7822,7 @@ The -verbose:jni and -verbose:gc are also useful options for monitoring code beh
</p>
-<H2><a name="Java_examples"></a>22.13 Examples</H2>
+<H2><a name="Java_examples"></a>23.13 Examples</H2>
<p>
diff --git a/Doc/Manual/Library.html b/Doc/Manual/Library.html
index 285192d5e..02b8e53bd 100644
--- a/Doc/Manual/Library.html
+++ b/Doc/Manual/Library.html
@@ -824,20 +824,20 @@ If you have a function that expects binary data,
<div class="code">
<pre>
-int parity(char *str, int len, int initial);
+size_t parity(char *str, size_t len, size_t initial);
</pre>
</div>
<p>
-you can wrap the parameters <tt>(char *str, int len)</tt> as a single
+you can wrap the parameters <tt>(char *str, size_t len)</tt> as a single
argument using a typemap. Just do this:
</p>
<div class="code">
<pre>
-%apply (char *STRING, int LENGTH) { (char *str, int len) };
+%apply (char *STRING, size_t LENGTH) { (char *str, size_t len) };
...
-int parity(char *str, int len, int initial);
+size_t parity(char *str, size_t len, size_t initial);
</pre>
</div>
@@ -854,6 +854,7 @@ Now, in the target language, you can use binary string data like this:
<p>
In the wrapper function, the passed string will be expanded to a pointer and length parameter.
+The <tt>(char *STRING, int LENGTH)</tt> multi-argument typemap is also available in addition to <tt>(char *STRING, size_t LENGTH)</tt>.
</p>
<H3><a name="Library_nn11"></a>8.3.3 Using %newobject to release memory</H3>
@@ -1802,27 +1803,67 @@ struct DerivedIntValue : IntValue {
</div>
<p>
-Note that if the <tt>%shared_ptr</tt> macro is omitted for any class in the inheritance hierarchy, it will
-result in a C++ compiler error.
-For example if the above <tt>%shared_ptr(DerivedIntValue)</tt> is omitted, the following is typical of the compiler error that will result:
+A shared_ptr of the derived class can now be passed to a method where the base is expected in the target language, just as it can in C++:
+</p>
+
+<div class="targetlang">
+<pre>
+DerivedIntValue div = new DerivedIntValue(5678);
+int val3 = example.extractValue(div);
+int val4 = example.extractValueSmart(div);
+</pre>
+</div>
+
+<p>
+If the <tt>%shared_ptr</tt> macro is omitted for any class in the inheritance hierarchy, SWIG will warn about this and the generated code may or may not result in a C++ compilation error.
+For example, the following input:
+</p>
+
+<div class="code">
+<pre>
+%include "boost_shared_ptr.i"
+%shared_ptr(Parent);
+
+%inline %{
+ #include &lt;boost/shared_ptr.hpp&gt;
+ struct GrandParent {
+ virtual ~GrandParent() {}
+ };
+
+ struct Parent : GrandParent {
+ virtual ~Parent() {}
+ };
+
+ struct Child : Parent {
+ virtual ~Child() {}
+ };
+%}
+</pre>
+</div>
+
+<p>
+warns about the missing smart pointer information:
</p>
<div class="shell">
<pre>
-example_wrap.cxx: In function 'void Java_exampleJNI_delete_1DerivedIntValue(JNIEnv*, _jclass*, jlong)':
-example_wrap.cxx:3169: error: 'smartarg1' was not declared in this scope
+example.i:12: Warning 520: Base class 'GrandParent' of 'Parent' is not similarly marked as a smart pointer.
+example.i:16: Warning 520: Derived class 'Child' of 'Parent' is not similarly marked as a smart pointer.
</pre>
</div>
<p>
-A shared_ptr of the derived class can now be passed to a method where the base is expected in the target language, just as it can in C++:
+Adding the missing <tt>%shared_ptr</tt> macros will fix this:
</p>
-<div class="targetlang">
+<div class="code">
<pre>
-DerivedIntValue div = new DerivedIntValue(5678);
-int val3 = example.extractValue(div);
-int val4 = example.extractValueSmart(div);
+%include "boost_shared_ptr.i"
+%shared_ptr(GrandParent);
+%shared_ptr(Parent);
+%shared_ptr(Child);
+
+... as before ...
</pre>
</div>
diff --git a/Doc/Manual/Lisp.html b/Doc/Manual/Lisp.html
index b9b5b6c1e..92af4e6c9 100644
--- a/Doc/Manual/Lisp.html
+++ b/Doc/Manual/Lisp.html
@@ -6,7 +6,7 @@
</head>
<body bgcolor="#ffffff">
-<H1><a name="Lisp"></a>23 SWIG and Common Lisp</H1>
+<H1><a name="Lisp"></a>24 SWIG and Common Lisp</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -41,7 +41,7 @@
Lisp, Common Foreign Function Interface(CFFI), CLisp and UFFI
foreign function interfaces.
</p>
-<H2><a name="Lisp_nn2"></a>23.1 Allegro Common Lisp</H2>
+<H2><a name="Lisp_nn2"></a>24.1 Allegro Common Lisp</H2>
<p>
@@ -50,7 +50,7 @@
<a href="Allegrocl.html#Allegrocl">here</a>
</p>
-<H2><a name="Lisp_nn3"></a>23.2 Common Foreign Function Interface(CFFI)</H2>
+<H2><a name="Lisp_nn3"></a>24.2 Common Foreign Function Interface(CFFI)</H2>
<p>
@@ -77,7 +77,7 @@ swig -cffi -module <i>module-name</i> <i>file-name</i>
files and the various things which you can do with them.
</p>
-<H3><a name="Lisp_nn4"></a>23.2.1 Additional Commandline Options </H3>
+<H3><a name="Lisp_nn4"></a>24.2.1 Additional Commandline Options </H3>
<p>
@@ -118,7 +118,7 @@ swig -cffi -help
</table>
-<H3><a name="Lisp_nn5"></a>23.2.2 Generating CFFI bindings</H3>
+<H3><a name="Lisp_nn5"></a>24.2.2 Generating CFFI bindings</H3>
As we mentioned earlier the ideal way to use SWIG is to use interface
@@ -392,7 +392,7 @@ The feature <i>intern_function</i> ensures that all C names are
</pre></div>
-<H3><a name="Lisp_nn6"></a>23.2.3 Generating CFFI bindings for C++ code</H3>
+<H3><a name="Lisp_nn6"></a>24.2.3 Generating CFFI bindings for C++ code</H3>
<p>This feature to SWIG (for CFFI) is very new and still far from
@@ -568,7 +568,7 @@ If you have any questions, suggestions, patches, etc., related to CFFI
module feel free to contact us on the SWIG mailing list, and
also please add a "[CFFI]" tag in the subject line.
-<H3><a name="Lisp_nn7"></a>23.2.4 Inserting user code into generated files</H3>
+<H3><a name="Lisp_nn7"></a>24.2.4 Inserting user code into generated files</H3>
<p>
@@ -608,7 +608,7 @@ Note that the block <tt>%{ ... %}</tt> is effectively a shortcut for
</p>
-<H2><a name="Lisp_nn8"></a>23.3 CLISP</H2>
+<H2><a name="Lisp_nn8"></a>24.3 CLISP</H2>
<p>
@@ -638,7 +638,7 @@ swig -clisp -module <i>module-name</i> <i>file-name</i>
interface file for the CLISP module. The CLISP module tries to
produce code which is both human readable and easily modifyable.
</p>
-<H3><a name="Lisp_nn9"></a>23.3.1 Additional Commandline Options </H3>
+<H3><a name="Lisp_nn9"></a>24.3.1 Additional Commandline Options </H3>
<p>
@@ -671,7 +671,7 @@ and global variables will be created otherwise only definitions for<br/>
</table>
-<H3><a name="Lisp_nn10"></a>23.3.2 Details on CLISP bindings</H3>
+<H3><a name="Lisp_nn10"></a>24.3.2 Details on CLISP bindings</H3>
<p>
@@ -795,7 +795,7 @@ struct bar {
</pre></div>
-<H2><a name="Lisp_nn11"></a>23.4 UFFI </H2>
+<H2><a name="Lisp_nn11"></a>24.4 UFFI </H2>
</body>
diff --git a/Doc/Manual/Lua.html b/Doc/Manual/Lua.html
index c07fe66c8..04f96f2f3 100644
--- a/Doc/Manual/Lua.html
+++ b/Doc/Manual/Lua.html
@@ -6,7 +6,7 @@
</head>
<body bgcolor="#ffffff">
-<H1><a name="Lua"></a>24 SWIG and Lua</H1>
+<H1><a name="Lua"></a>25 SWIG and Lua</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -67,13 +67,13 @@
<p>
Lua is an extension programming language designed to support general procedural programming with data description facilities. It also offers good support for object-oriented programming, functional programming, and data-driven programming. Lua is intended to be used as a powerful, light-weight configuration language for any program that needs one. Lua is implemented as a library, written in clean C (that is, in the common subset of ANSI C and C++). Its also a <em>really</em> tiny language, less than 6000 lines of code, which compiles to &lt;100 kilobytes of binary code. It can be found at <a href="http://www.lua.org">http://www.lua.org</a>
</p>
-<H2><a name="Lua_nn2"></a>24.1 Preliminaries</H2>
+<H2><a name="Lua_nn2"></a>25.1 Preliminaries</H2>
<p>
The current SWIG implementation is designed to work with Lua 5.0.x and Lua 5.1.x. It should work with later versions of Lua, but certainly not with Lua 4.0 due to substantial API changes. ((Currently SWIG generated code has only been tested on Windows with MingW, though given the nature of Lua, is should not have problems on other OS's)). It is possible to either static link or dynamic link a Lua module into the interpreter (normally Lua static links its libraries, as dynamic linking is not available on all platforms).
</p>
-<H2><a name="Lua_nn3"></a>24.2 Running SWIG</H2>
+<H2><a name="Lua_nn3"></a>25.2 Running SWIG</H2>
<p>
@@ -105,7 +105,7 @@ This creates a C/C++ source file <tt>example_wrap.c</tt> or <tt>example_wrap.cxx
<p>
The name of the wrapper file is derived from the name of the input file. For example, if the input file is <tt>example.i</tt>, the name of the wrapper file is <tt>example_wrap.c</tt>. To change this, you can use the -o option. The wrappered module will export one function <tt>"int luaopen_example(lua_State* L)"</tt> which must be called to register the module with the Lua interpreter. The name "luaopen_example" depends upon the name of the module.
</p>
-<H3><a name="Lua_nn4"></a>24.2.1 Compiling and Linking and Interpreter</H3>
+<H3><a name="Lua_nn4"></a>25.2.1 Compiling and Linking and Interpreter</H3>
<p>
@@ -152,7 +152,7 @@ $ gcc -c example.c -o example.o
$ gcc -I/usr/include/lua -L/usr/lib/lua min.o example_wrap.o example.o -o my_lua
</pre></div>
-<H3><a name="Lua_nn5"></a>24.2.2 Compiling a dynamic module</H3>
+<H3><a name="Lua_nn5"></a>25.2.2 Compiling a dynamic module</H3>
<p>
@@ -220,7 +220,7 @@ Is quite obvious (Go back and consult the Lua documents on how to enable loadlib
-<H3><a name="Lua_nn6"></a>24.2.3 Using your module</H3>
+<H3><a name="Lua_nn6"></a>25.2.3 Using your module</H3>
<p>
@@ -238,19 +238,19 @@ $ ./my_lua
&gt;
</pre></div>
-<H2><a name="Lua_nn7"></a>24.3 A tour of basic C/C++ wrapping</H2>
+<H2><a name="Lua_nn7"></a>25.3 A tour of basic C/C++ wrapping</H2>
<p>
By default, SWIG tries to build a very natural Lua interface to your C/C++ code. This section briefly covers the essential aspects of this wrapping.
</p>
-<H3><a name="Lua_nn8"></a>24.3.1 Modules</H3>
+<H3><a name="Lua_nn8"></a>25.3.1 Modules</H3>
<p>
The SWIG module directive specifies the name of the Lua module. If you specify `module example', then everything is wrapped into a Lua table 'example' containing all the functions and variables. When choosing a module name, make sure you don't use the same name as a built-in Lua command or standard module name.
</p>
-<H3><a name="Lua_nn9"></a>24.3.2 Functions</H3>
+<H3><a name="Lua_nn9"></a>25.3.2 Functions</H3>
<p>
@@ -288,7 +288,7 @@ It is also possible to rename the module with an assignment.
24
</pre></div>
-<H3><a name="Lua_nn10"></a>24.3.3 Global variables</H3>
+<H3><a name="Lua_nn10"></a>25.3.3 Global variables</H3>
<p>
@@ -362,7 +362,7 @@ nil
3.142
</pre></div>
-<H3><a name="Lua_nn11"></a>24.3.4 Constants and enums</H3>
+<H3><a name="Lua_nn11"></a>25.3.4 Constants and enums</H3>
<p>
@@ -385,7 +385,7 @@ example.SUNDAY=0
<p>
Constants are not guaranteed to remain constant in Lua. The name of the constant could be accidentally reassigned to refer to some other object. Unfortunately, there is no easy way for SWIG to generate code that prevents this. You will just have to be careful.
</p>
-<H3><a name="Lua_nn12"></a>24.3.5 Pointers</H3>
+<H3><a name="Lua_nn12"></a>25.3.5 Pointers</H3>
<p>
@@ -423,7 +423,7 @@ Lua enforces the integrity of its userdata, so it is virtually impossible to cor
nil
</pre></div>
-<H3><a name="Lua_nn13"></a>24.3.6 Structures</H3>
+<H3><a name="Lua_nn13"></a>25.3.6 Structures</H3>
<p>
@@ -509,7 +509,7 @@ Because the pointer points inside the structure, you can modify the contents and
&gt; x.a = 3 -- Modifies the same structure
</pre></div>
-<H3><a name="Lua_nn14"></a>24.3.7 C++ classes</H3>
+<H3><a name="Lua_nn14"></a>25.3.7 C++ classes</H3>
<p>
@@ -570,7 +570,7 @@ It is not (currently) possible to access static members of an instance:
-- does NOT work
</pre></div>
-<H3><a name="Lua_nn15"></a>24.3.8 C++ inheritance</H3>
+<H3><a name="Lua_nn15"></a>25.3.8 C++ inheritance</H3>
<p>
@@ -595,7 +595,7 @@ then the function <tt>spam()</tt> accepts a Foo pointer or a pointer to any clas
<p>
It is safe to use multiple inheritance with SWIG.
</p>
-<H3><a name="Lua_nn16"></a>24.3.9 Pointers, references, values, and arrays</H3>
+<H3><a name="Lua_nn16"></a>25.3.9 Pointers, references, values, and arrays</H3>
<p>
@@ -626,7 +626,7 @@ Foo spam7();
<p>
then all three functions will return a pointer to some Foo object. Since the third function (spam7) returns a value, newly allocated memory is used to hold the result and a pointer is returned (Lua will release this memory when the return value is garbage collected). The other two are pointers which are assumed to be managed by the C code and so will not be garbage collected.
</p>
-<H3><a name="Lua_nn17"></a>24.3.10 C++ overloaded functions</H3>
+<H3><a name="Lua_nn17"></a>25.3.10 C++ overloaded functions</H3>
<p>
@@ -712,7 +712,7 @@ Please refer to the "SWIG and C++" chapter for more information about overloadin
<p>
Dealing with the Lua coercion mechanism, the priority is roughly (integers, floats, strings, userdata). But it is better to rename the functions rather than rely upon the ordering.
</p>
-<H3><a name="Lua_nn18"></a>24.3.11 C++ operators</H3>
+<H3><a name="Lua_nn18"></a>25.3.11 C++ operators</H3>
<p>
@@ -824,7 +824,7 @@ It is also possible to overload the operator<tt>[]</tt>, but currently this cann
};
</pre></div>
-<H3><a name="Lua_nn19"></a>24.3.12 Class extension with %extend</H3>
+<H3><a name="Lua_nn19"></a>25.3.12 Class extension with %extend</H3>
<p>
@@ -879,7 +879,7 @@ true
<p>
Extend works with both C and C++ code, on classes and structs. It does not modify the underlying object in any way---the extensions only show up in the Lua interface. The only item to take note of is the code has to use the '$self' instead of 'this', and that you cannot access protected/private members of the code (as you are not officially part of the class).
</p>
-<H3><a name="Lua_nn20"></a>24.3.13 C++ templates</H3>
+<H3><a name="Lua_nn20"></a>25.3.13 C++ templates</H3>
<p>
@@ -914,7 +914,7 @@ In Lua:
<p>
Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter. Some more complicated examples will appear later.
</p>
-<H3><a name="Lua_nn21"></a>24.3.14 C++ Smart Pointers</H3>
+<H3><a name="Lua_nn21"></a>25.3.14 C++ Smart Pointers</H3>
<p>
@@ -966,7 +966,7 @@ If you ever need to access the underlying pointer returned by <tt>operator-&gt;(
&gt; f = p:__deref__() -- Returns underlying Foo *
</pre></div>
-<H3><a name="Lua_nn22"></a>24.3.15 C++ Exceptions</H3>
+<H3><a name="Lua_nn22"></a>25.3.15 C++ Exceptions</H3>
<p>
@@ -1110,12 +1110,12 @@ add exception specification to functions or globally (respectively).
</p>
-<H2><a name="Lua_nn23"></a>24.4 Typemaps</H2>
+<H2><a name="Lua_nn23"></a>25.4 Typemaps</H2>
<p>This section explains what typemaps are and the usage of them. The default wrappering behaviour of SWIG is enough in most cases. However sometimes SWIG may need a little additional assistance to know which typemap to apply to provide the best wrappering. This section will be explaining how to use typemaps to best effect</p>
-<H3><a name="Lua_nn24"></a>24.4.1 What is a typemap?</H3>
+<H3><a name="Lua_nn24"></a>25.4.1 What is a typemap?</H3>
<p>A typemap is nothing more than a code generation rule that is attached to a specific C datatype. For example, to convert integers from Lua to C, you might define a typemap like this:</p>
@@ -1143,7 +1143,7 @@ Received an integer : 6
720
</pre></div>
-<H3><a name="Lua_nn25"></a>24.4.2 Using typemaps</H3>
+<H3><a name="Lua_nn25"></a>25.4.2 Using typemaps</H3>
<p>There are many ready written typemaps built into SWIG for all common types (int, float, short, long, char*, enum and more), which SWIG uses automatically, with no effort required on your part.</p>
@@ -1196,7 +1196,7 @@ void swap(int *sx, int *sy);
<p>Note: C++ references must be handled exactly the same way. However SWIG will automatically wrap a <tt>const int&amp;</tt> as an input parameter (since that it obviously input).</p>
-<H3><a name="Lua_nn26"></a>24.4.3 Typemaps and arrays</H3>
+<H3><a name="Lua_nn26"></a>25.4.3 Typemaps and arrays</H3>
<p>Arrays present a challenge for SWIG, because like pointers SWIG does not know whether these are input or output values, nor
@@ -1260,7 +1260,7 @@ and Lua tables to be 1..N, (the indexing follows the norm for the language). In
<p>Note: SWIG also can support arrays of pointers in a similar manner.</p>
-<H3><a name="Lua_nn27"></a>24.4.4 Typemaps and pointer-pointer functions</H3>
+<H3><a name="Lua_nn27"></a>25.4.4 Typemaps and pointer-pointer functions</H3>
<p>Several C++ libraries use a pointer-pointer functions to create its objects. These functions require a pointer to a pointer which is then filled with the pointer to the new object. Microsoft's COM and DirectX as well as many other libraries have this kind of function. An example is given below:</p>
@@ -1294,7 +1294,7 @@ int Create_Math(iMath** pptr); // its creator (assume it mallocs)
ptr=nil -- the iMath* will be GC'ed as normal
</pre></div>
-<H2><a name="Lua_nn28"></a>24.5 Writing typemaps</H2>
+<H2><a name="Lua_nn28"></a>25.5 Writing typemaps</H2>
<p>This section describes how you can modify SWIG's default wrapping behavior for various C/C++ datatypes using the <tt>%typemap</tt> directive. This is an advanced topic that assumes familiarity with the Lua C API as well as the material in the "<a href="Typemaps.html#Typemaps">Typemaps</a>" chapter.</p>
@@ -1303,7 +1303,7 @@ ptr=nil -- the iMath* will be GC'ed as normal
<p>Before proceeding, you should read the previous section on using typemaps, as well as read the ready written typemaps found in luatypemaps.swg and typemaps.i. These are both well documented and fairly easy to read. You should not attempt to write your own typemaps until you have read and can understand both of these files (they may well also give you a idea to base your worn on).</p>
-<H3><a name="Lua_nn29"></a>24.5.1 Typemaps you can write</H3>
+<H3><a name="Lua_nn29"></a>25.5.1 Typemaps you can write</H3>
<p>There are many different types of typemap that can be written, the full list can be found in the "<a href="Typemaps.html#Typemaps">Typemaps</a>" chapter. However the following are the most commonly used ones.</p>
@@ -1316,7 +1316,7 @@ ptr=nil -- the iMath* will be GC'ed as normal
(the syntax for the typecheck is different from the typemap, see typemaps for details).</li>
</ul>
-<H3><a name="Lua_nn30"></a>24.5.2 SWIG's Lua-C API</H3>
+<H3><a name="Lua_nn30"></a>25.5.2 SWIG's Lua-C API</H3>
<p>This section explains the SWIG specific Lua-C API. It does not cover the main Lua-C api, as this is well documented and not worth covering.</p>
@@ -1365,7 +1365,7 @@ This macro, when called within the context of a SWIG wrappered function, will di
<div class="indent">
Similar to SWIG_fail_arg, except that it will display the swig_type_info information instead.</div>
-<H2><a name="Lua_nn31"></a>24.6 Customization of your Bindings</H2>
+<H2><a name="Lua_nn31"></a>25.6 Customization of your Bindings</H2>
<p>
@@ -1374,7 +1374,7 @@ This section covers adding of some small extra bits to your module to add the la
-<H3><a name="Lua_nn32"></a>24.6.1 Writing your own custom wrappers</H3>
+<H3><a name="Lua_nn32"></a>25.6.1 Writing your own custom wrappers</H3>
<p>
@@ -1393,7 +1393,7 @@ int native_function(lua_State*L) // my native code
The <tt>%native</tt> directive in the above example, tells SWIG that there is a function <tt>int native_function(lua_State*L);</tt> which is to be added into the module under the name '<tt>my_func</tt>'. SWIG will not add any wrappering for this function, beyond adding it into the function table. How you write your code is entirely up to you.
</p>
-<H3><a name="Lua_nn33"></a>24.6.2 Adding additional Lua code</H3>
+<H3><a name="Lua_nn33"></a>25.6.2 Adding additional Lua code</H3>
<p>
@@ -1431,7 +1431,7 @@ Good uses for this feature is adding of new code, or writing helper functions to
See Examples/lua/arrays for an example of this code.
</p>
-<H2><a name="Lua_nn34"></a>24.7 Details on the Lua binding</H2>
+<H2><a name="Lua_nn34"></a>25.7 Details on the Lua binding</H2>
<p>
@@ -1442,7 +1442,7 @@ See Examples/lua/arrays for an example of this code.
</i>
</p>
-<H3><a name="Lua_nn35"></a>24.7.1 Binding global data into the module.</H3>
+<H3><a name="Lua_nn35"></a>25.7.1 Binding global data into the module.</H3>
<p>
@@ -1502,7 +1502,7 @@ end
<p>
That way when you call '<tt>a=example.Foo</tt>', the interpreter looks at the table 'example' sees that there is no field 'Foo' and calls __index. This will in turn check in '.get' table and find the existence of 'Foo' and then return the value of the C function call 'Foo_get()'. Similarly for the code '<tt>example.Foo=10</tt>', the interpreter will check the table, then call the __newindex which will then check the '.set' table and call the C function 'Foo_set(10)'.
</p>
-<H3><a name="Lua_nn36"></a>24.7.2 Userdata and Metatables</H3>
+<H3><a name="Lua_nn36"></a>25.7.2 Userdata and Metatables</H3>
<p>
@@ -1582,7 +1582,7 @@ Note: Both the opaque structures (like the FILE*) and normal wrappered classes/s
<p>
Note: Operator overloads are basically done in the same way, by adding functions such as '__add' &amp; '__call' to the classes metatable. The current implementation is a bit rough as it will add any member function beginning with '__' into the metatable too, assuming its an operator overload.
</p>
-<H3><a name="Lua_nn37"></a>24.7.3 Memory management</H3>
+<H3><a name="Lua_nn37"></a>25.7.3 Memory management</H3>
<p>
diff --git a/Doc/Manual/Makefile b/Doc/Manual/Makefile
index 69d361f07..42149ba3a 100644
--- a/Doc/Manual/Makefile
+++ b/Doc/Manual/Makefile
@@ -15,7 +15,7 @@
# Note the # and " are escaped
HTMLDOC_OPTIONS = "--book --toclevels 4 --no-numbered --toctitle \"Table of Contents\" --title --titleimage swig16.png --linkcolor \#0000ff --linkstyle underline --size Universal --left 0.50in --right 0.50in --top 0.50in --bottom 0.50in --header .t. --footer h.1 --nup 1 --tocheader .t. --tocfooter ..i --portrait --color --no-pscommands --no-xrxcomments --compression=1 --jpeg=0 --fontsize 10.0 --fontspacing 1.2 --headingfont Helvetica --bodyfont Times --headfootsize 10.0 --headfootfont Helvetica --charset iso-8859-1 --links --no-embedfonts --pagemode outline --pagelayout single --firstpage c1 --pageeffect none --pageduration 10 --effectduration 1.0 --no-encryption --permissions all --owner-password \"\" --user-password \"\" --browserwidth 680"
-.PHONY: maketoc check generate all clean validate test
+.PHONY: maketoc check generate all maintainer-clean validate test
all: maketoc check generate
@@ -38,13 +38,13 @@ generate: swightml.book swigpdf.book
htmldoc --batch swigpdf.book || true
python fixstyle.py SWIGDocumentation.html
-swigpdf.book:
+swigpdf.book: chapters Sections.html
echo "#HTMLDOC 1.8.24" > swigpdf.book
echo -t pdf13 -f SWIGDocumentation.pdf $(HTMLDOC_OPTIONS) --stylesheet style.css >> swigpdf.book
echo "Sections.html" >> swigpdf.book
cat chapters >> swigpdf.book
-swightml.book:
+swightml.book: chapters Sections.html
echo "#HTMLDOC 1.8.24" > swightml.book
echo -t html -f SWIGDocumentation.html $(HTMLDOC_OPTIONS) >> swightml.book
echo "Sections.html" >> swightml.book
@@ -69,7 +69,10 @@ test:
validate:
all=`sed '/^#/d' chapters`; for a in $$all; do validate --emacs $$a; done;
-# Link checking using linkchecker (can take a while - 30 mins)
+# Link checking using linkchecker
linkchecker:
- linkchecker --anchors Contents.html
+ @echo -----------------------------------------------------------------------
+ @echo Note linkchecker versions prior to 6.1 do not work properly wrt anchors
+ @echo -----------------------------------------------------------------------
+ linkchecker --config=./linkchecker.config index.html
diff --git a/Doc/Manual/Modula3.html b/Doc/Manual/Modula3.html
index 71611e3c5..f9400abee 100644
--- a/Doc/Manual/Modula3.html
+++ b/Doc/Manual/Modula3.html
@@ -5,7 +5,7 @@
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body bgcolor="#FFFFFF">
-<H1><a name="Modula3"></a>25 SWIG and Modula-3</H1>
+<H1><a name="Modula3"></a>26 SWIG and Modula-3</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -54,7 +54,7 @@ especially
<a href="Typemaps.html#Typemaps">typemaps</a>.
</p>
-<H2><a name="Modula3_modula3_overview"></a>25.1 Overview</H2>
+<H2><a name="Modula3_modula3_overview"></a>26.1 Overview</H2>
<p>
@@ -84,7 +84,7 @@ FFTW
</li>
</ol>
-<H3><a name="Modula3_motivation"></a>25.1.1 Motivation</H3>
+<H3><a name="Modula3_motivation"></a>26.1.1 Motivation</H3>
<p>
@@ -131,10 +131,10 @@ functions), but it doesn't allow you to easily integrate a Module-3 module into
a C/C++ project.
</p>
-<H2><a name="Modula3_conception"></a>25.2 Conception</H2>
+<H2><a name="Modula3_conception"></a>26.2 Conception</H2>
-<H3><a name="Modula3_cinterface"></a>25.2.1 Interfaces to C libraries</H3>
+<H3><a name="Modula3_cinterface"></a>26.2.1 Interfaces to C libraries</H3>
<p>
@@ -142,7 +142,7 @@ Modula-3 has integrated support for calling C functions.
This is also extensively used by the standard Modula-3 libraries
to call OS functions.
The Modula-3 part of SWIG and the corresponding SWIG library
-<a href="../../Lib/modula3/modula3.swg"><tt>modula3.swg</tt></a>
+modula3.swg
contain code that uses these features.
Because of the built-in support there is no need
for calling the SWIG kernel to generate wrappers written in C.
@@ -283,7 +283,7 @@ and the principal type must be renamed (<tt>%typemap</tt>).
</p>
-<H3><a name="Modula3_cppinterface"></a>25.2.2 Interfaces to C++ libraries</H3>
+<H3><a name="Modula3_cppinterface"></a>26.2.2 Interfaces to C++ libraries</H3>
<p>
@@ -384,24 +384,23 @@ There is no C++ library I wrote a SWIG interface for,
so I'm not sure if this is possible or sensible, yet.
</p>
-<H2><a name="Modula3_preliminaries"></a>25.3 Preliminaries</H2>
+<H2><a name="Modula3_preliminaries"></a>26.3 Preliminaries</H2>
-<H3><a name="Modula3_compilers"></a>25.3.1 Compilers</H3>
+<H3><a name="Modula3_compilers"></a>26.3.1 Compilers</H3>
<p>
There are different Modula-3 compilers around:
cm3, pm3, ezm3, Klagenfurth Modula-3, Cambridge Modula-3.
SWIG itself does not contain compiler specific code
-but the library file
-<a href="../../Lib/modula3/modula3.swg"><tt>modula3.swg</tt></a>
+but the modula3.swg library file
may do so.
For testing examples I use Critical Mass cm3.
</p>
-<H3><a name="Modula3_commandline"></a>25.3.2 Additional Commandline Options</H3>
+<H3><a name="Modula3_commandline"></a>26.3.2 Additional Commandline Options</H3>
<p>
@@ -478,10 +477,10 @@ Instead generate templates for some basic typemaps.
</tr>
</table>
-<H2><a name="Modula3_typemaps"></a>25.4 Modula-3 typemaps</H2>
+<H2><a name="Modula3_typemaps"></a>26.4 Modula-3 typemaps</H2>
-<H3><a name="Modula3_inoutparam"></a>25.4.1 Inputs and outputs</H3>
+<H3><a name="Modula3_inoutparam"></a>26.4.1 Inputs and outputs</H3>
<p>
@@ -499,9 +498,7 @@ or for a return value.
A further typemap may specify
the direction that is used for certain parameters.
I have chosen this separation
-in order to be able to write general typemaps for the typemap library
-<a href="../../Lib/modula3/modula3.swg"><tt>modula3.swg</tt></a>
-.
+in order to be able to write general typemaps for the modula3.swg typemap library.
In the library code the final usage of the type is not known.
Using separate typemaps for each possible use
allows appropriate definitions for each case.
@@ -697,7 +694,7 @@ consist of the following parts:
</table>
-<H3><a name="Modula3_ordinals"></a>25.4.2 Subranges, Enumerations, Sets</H3>
+<H3><a name="Modula3_ordinals"></a>26.4.2 Subranges, Enumerations, Sets</H3>
<p>
@@ -749,7 +746,7 @@ that I'd like to automate.
</p>
-<H3><a name="Modula3_class"></a>25.4.3 Objects</H3>
+<H3><a name="Modula3_class"></a>26.4.3 Objects</H3>
<p>
@@ -762,7 +759,7 @@ is not really useful, yet.
</p>
-<H3><a name="Modula3_imports"></a>25.4.4 Imports</H3>
+<H3><a name="Modula3_imports"></a>26.4.4 Imports</H3>
<p>
@@ -782,9 +779,7 @@ Unqualified import is not supported.
<p>
It is cumbersome to add this typemap to each piece of Modula-3 code.
It is especially useful when writing general typemaps
-for the typemap library
-<a href="../../Lib/modula3/modula3.swg"><tt>modula3.swg</tt></a>
-.
+for the modula3.swg typemap library.
For a monolithic module you might be better off
if you add the imports directly:
</p>
@@ -797,7 +792,7 @@ IMPORT M3toC;
</pre></div>
-<H3><a name="Modula3_exceptions"></a>25.4.5 Exceptions</H3>
+<H3><a name="Modula3_exceptions"></a>26.4.5 Exceptions</H3>
<p>
@@ -821,7 +816,7 @@ you should declare
<tt>%typemap("m3wrapinconv:throws") blah * %{OSError.E%}</tt>.
</p>
-<H3><a name="Modula3_typemap_example"></a>25.4.6 Example</H3>
+<H3><a name="Modula3_typemap_example"></a>26.4.6 Example</H3>
<p>
@@ -868,10 +863,10 @@ where almost everything is generated by a typemap:
</pre></div>
-<H2><a name="Modula3_hints"></a>25.5 More hints to the generator</H2>
+<H2><a name="Modula3_hints"></a>26.5 More hints to the generator</H2>
-<H3><a name="Modula3_features"></a>25.5.1 Features</H3>
+<H3><a name="Modula3_features"></a>26.5.1 Features</H3>
<table border summary="Modula-3 features">
@@ -908,7 +903,7 @@ where almost everything is generated by a typemap:
</tr>
</table>
-<H3><a name="Modula3_pragmas"></a>25.5.2 Pragmas</H3>
+<H3><a name="Modula3_pragmas"></a>26.5.2 Pragmas</H3>
<table border summary="Modula-3 pragmas">
@@ -931,7 +926,7 @@ where almost everything is generated by a typemap:
</tr>
</table>
-<H2><a name="Modula3_remarks"></a>25.6 Remarks</H2>
+<H2><a name="Modula3_remarks"></a>26.6 Remarks</H2>
<ul>
diff --git a/Doc/Manual/Modules.html b/Doc/Manual/Modules.html
index 69cc58c30..70b0f1181 100644
--- a/Doc/Manual/Modules.html
+++ b/Doc/Manual/Modules.html
@@ -138,7 +138,8 @@ base class's methods. Typically you will get a warning when the module name is m
</p>
<div class="shell"> <pre>
-derived_module.i:8: Warning 401: Base class 'base' ignored - unknown module name for base. Either import
+derived_module.i:8: Warning 401: Base class 'base' ignored - unknown module name for base. Either
+import
the appropriate module interface file or specify the name of the module in the %import directive.
</pre></div>
diff --git a/Doc/Manual/Mzscheme.html b/Doc/Manual/Mzscheme.html
index 4351e34a7..984b2dded 100644
--- a/Doc/Manual/Mzscheme.html
+++ b/Doc/Manual/Mzscheme.html
@@ -2,17 +2,19 @@
<!-- Hand-written HTML -->
<html>
<head>
-<title>SWIG and MzScheme</title>
+<title>SWIG and MzScheme/Racket</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body bgcolor="#ffffff">
-<H1><a name="Mzscheme"></a>26 SWIG and MzScheme</H1>
+<H1><a name="Mzscheme"></a>27 SWIG and MzScheme/Racket</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
-<li><a href="#MzScheme_nn2">Creating native MzScheme structures</a>
+<li><a href="#MzScheme_nn2">Creating native structures</a>
+<li><a href="#MzScheme_simple">Simple example</a>
+<li><a href="#MzScheme_external_docs">External documentation</a>
</ul>
</div>
<!-- INDEX -->
@@ -20,9 +22,9 @@
<p>
-This section contains information on SWIG's support of MzScheme.
+This section contains information on SWIG's support of Racket, formally known as MzScheme.
-<H2><a name="MzScheme_nn2"></a>26.1 Creating native MzScheme structures</H2>
+<H2><a name="MzScheme_nn2"></a>27.1 Creating native structures</H2>
<p>
@@ -63,8 +65,116 @@ Then in scheme, you can use regular struct access procedures like
</pre>
</div>
+<H2><a name="MzScheme_simple"></a>27.2 Simple example</H2>
+
+
+<p>
+A few examples are available in the Examples/mzscheme directory.
+The code and log of a session using SWIG below should help getting started.
+</p>
+
+<p>
+C header file:
+</p>
+
+<div class="code">
+<pre>
+// example.h
+int fact(int n);
+</pre>
+</div>
+
+<p>
+C source code:
+</p>
+
+<div class="code">
+<pre>
+// File: example.c
+#include "example.h"
+
+int fact(int n) {
+ if (n &lt; 0) { /* This should probably return an error, but this is simpler */
+ return 0;
+ }
+ if (n == 0) {
+ return 1;
+ }
+ else {
+ /* testing for overflow would be a good idea here */
+ return n * fact(n-1);
+ }
+}
+</pre>
+</div>
+
+<p>
+SWIG interface file:
+</p>
+
+<div class="code">
+<pre>
+/* File: example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+int fact(int n);
+</pre>
+</div>
+
+<p>
+The session below using the above files is on an OS X machine, but the points to be made are more general. On OS X, libtool is the tool which creates libraries, which are named .dylib, rather than .so on other unixes, or .dll on Windows.
+</p>
+
+<div class="shell">
+<pre>
+% swig -mzscheme -declaremodule example.i
+% gcc -c -m32 -o example.o example.c # force 32-bit object file (mzscheme is 32-bit only)
+% libtool -dynamic -o libexample.dylib example.o # make it into a library
+% ls # what've we got so far?
+example.c example.o
+example.h example_wrap.c
+example.i libexample.dylib*
+% mzc --cgc --cc example_wrap.c # compile the wrapping code
+% LDFLAGS="-L. -lexample" mzc --ld example_wrap.dylib example_wrap.o # ...and link it
+% mzscheme -e '(path-&gt;string (build-path "compiled" "native" (system-library-subpath)))'
+"compiled/native/i386-macosx/3m"
+% mkdir -p compiled/native/i386-macosx/3m # move the extension library to a magic place
+% mv example_wrap.dylib compiled/native/i386-macosx/3m/example_ss.dylib
+% mzscheme
+Welcome to MzScheme v4.2.4 [3m], Copyright (c) 2004-2010 PLT Scheme Inc.
+&gt; (require "example.ss")
+&gt; (fact 5)
+120
+&gt; ^D
+% echo 'It works!'
+</pre>
+</div>
+
+
+<p>
+Some points of interest:
+</p>
+<ul>
+ <li> This is on a 64-bit machine, so we have to include the -m32 option when building the object file
+ <li> If you want to declare a scheme module (and you probably do), it's important that you include the -declaremodule option to swig (if you miss this out, it'll appear to work, but fail later).
+ <li> Use mzc to compile and then link the wrapped code. You'll probably need to adjust the link flags to refer to the library you're wrapping (you can either do this with an LDFLAGS declaration, as here, or with multiple ++ldf options to mzc).
+ <li> Create the directory with path (build-path "compiled" "native" (system-library-subpath)) and move the freshly-generated .dylib to there, changing its name to module-name_ss.dylib. After that, you can REQUIRE the new module with (require "module-name.ss").
+ <li> The above requests mzc to create an extension using the CGC garbage-collector. The alternative -- the 3m collector -- has generally better performance, but work is still required for SWIG to emit code which is compatible with it.
+</ul>
+
+<H2><a name="MzScheme_external_docs"></a>27.3 External documentation</H2>
+
+
+<p>
+See the <a href="http://docs.racket-lang.org/inside/index.html">C API</a> for more description of using the mechanism for adding extensions. The main documentation is <a href="http://docs.racket-lang.org/">here</a>.
+</p>
+
<p>
-That's pretty much it. It works with nested structs as well.
+Tip: mzc's --vv option is very useful for debugging the inevitable library problems you'll encounter.
</p>
</body>
diff --git a/Doc/Manual/Ocaml.html b/Doc/Manual/Ocaml.html
index 6cbfa5510..56c3db142 100644
--- a/Doc/Manual/Ocaml.html
+++ b/Doc/Manual/Ocaml.html
@@ -6,7 +6,7 @@
</head>
<body bgcolor="#ffffff">
<a name="n1"></a>
-<H1><a name="Ocaml"></a>27 SWIG and Ocaml</H1>
+<H1><a name="Ocaml"></a>28 SWIG and Ocaml</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -80,7 +80,7 @@ If you're not familiar with the Objective Caml language, you can visit
<a href="http://www.ocaml.org/">The Ocaml Website</a>.
</p>
-<H2><a name="Ocaml_nn2"></a>27.1 Preliminaries</H2>
+<H2><a name="Ocaml_nn2"></a>28.1 Preliminaries</H2>
<p>
@@ -93,13 +93,13 @@ examples and test-suite which come with SWIG. You can do this by running
The Ocaml module has been tested using the system's dynamic linking (the
usual -lxxx against libxxx.so, as well as with Gerd Stolpmann's
<a
- href="http://www.ocaml-programming.de/packages/documentation/dl/">Dl package
+ href="http://download.camlcity.org/download/">Dl package
</a>. The ocaml_dynamic and ocaml_dynamic_cpp targets in the
file Examples/Makefile illustrate how to compile and link SWIG modules that
will be loaded dynamically. This has only been tested on Linux so far.
</p>
-<H3><a name="Ocaml_nn3"></a>27.1.1 Running SWIG</H3>
+<H3><a name="Ocaml_nn3"></a>28.1.1 Running SWIG</H3>
<p>
@@ -122,7 +122,7 @@ you will compile the file <tt>example_wrap.c</tt> with <tt>ocamlc</tt> or
the resulting .ml and .mli files as well, and do the final link with -custom
(not needed for native link). </p>
-<H3><a name="Ocaml_nn4"></a>27.1.2 Compiling the code</H3>
+<H3><a name="Ocaml_nn4"></a>28.1.2 Compiling the code</H3>
<p>
@@ -158,7 +158,7 @@ the user more freedom with respect to custom typing.
</pre>
</div>
-<H3><a name="Ocaml_nn5"></a>27.1.3 The camlp4 module</H3>
+<H3><a name="Ocaml_nn5"></a>28.1.3 The camlp4 module</H3>
<p>
@@ -234,7 +234,7 @@ let b = C_string (getenv "PATH")
</td></tr>
</table>
-<H3><a name="Ocaml_nn6"></a>27.1.4 Using your module</H3>
+<H3><a name="Ocaml_nn6"></a>28.1.4 Using your module</H3>
<p>
@@ -248,7 +248,7 @@ When linking any ocaml bytecode with your module, use the -custom
option is not needed when you build native code.
</p>
-<H3><a name="Ocaml_nn7"></a>27.1.5 Compilation problems and compiling with C++</H3>
+<H3><a name="Ocaml_nn7"></a>28.1.5 Compilation problems and compiling with C++</H3>
<p>
@@ -259,7 +259,7 @@ liberal with pointer types may not compile under the C++ compiler.
Most code meant to be compiled as C++ will not have problems.
</p>
-<H2><a name="Ocaml_nn8"></a>27.2 The low-level Ocaml/C interface</H2>
+<H2><a name="Ocaml_nn8"></a>28.2 The low-level Ocaml/C interface</H2>
<p>
@@ -360,7 +360,7 @@ is that you must append them to the return list with swig_result = caml_list_a
signature for a function that uses value in this way.
</p>
-<H3><a name="Ocaml_nn9"></a>27.2.1 The generated module</H3>
+<H3><a name="Ocaml_nn9"></a>28.2.1 The generated module</H3>
<p>
@@ -394,7 +394,7 @@ it describes the output SWIG will generate for class definitions.
</td></tr>
</table>
-<H3><a name="Ocaml_nn10"></a>27.2.2 Enums</H3>
+<H3><a name="Ocaml_nn10"></a>28.2.2 Enums</H3>
<p>
@@ -457,7 +457,7 @@ val x : Enum_test.c_obj = C_enum `a
</pre>
</div>
-<H4><a name="Ocaml_nn11"></a>27.2.2.1 Enum typing in Ocaml</H4>
+<H4><a name="Ocaml_nn11"></a>28.2.2.1 Enum typing in Ocaml</H4>
<p>
@@ -470,10 +470,10 @@ functions imported from different modules. You must convert values to master
values using the swig_val function before sharing them with another module.
</p>
-<H3><a name="Ocaml_nn12"></a>27.2.3 Arrays</H3>
+<H3><a name="Ocaml_nn12"></a>28.2.3 Arrays</H3>
-<H4><a name="Ocaml_nn13"></a>27.2.3.1 Simple types of bounded arrays</H4>
+<H4><a name="Ocaml_nn13"></a>28.2.3.1 Simple types of bounded arrays</H4>
<p>
@@ -494,7 +494,7 @@ arrays of simple types with known bounds in your code, but this only works
for arrays whose bounds are completely specified.
</p>
-<H4><a name="Ocaml_nn14"></a>27.2.3.2 Complex and unbounded arrays</H4>
+<H4><a name="Ocaml_nn14"></a>28.2.3.2 Complex and unbounded arrays</H4>
<p>
@@ -507,7 +507,7 @@ SWIG can't predict which of these methods will be used in the array,
so you have to specify it for yourself in the form of a typemap.
</p>
-<H4><a name="Ocaml_nn15"></a>27.2.3.3 Using an object</H4>
+<H4><a name="Ocaml_nn15"></a>28.2.3.3 Using an object</H4>
<p>
@@ -521,7 +521,7 @@ Consider writing an object when the ending condition of your array is complex,
such as using a required sentinel, etc.
</p>
-<H4><a name="Ocaml_nn16"></a>27.2.3.4 Example typemap for a function taking float * and int</H4>
+<H4><a name="Ocaml_nn16"></a>28.2.3.4 Example typemap for a function taking float * and int</H4>
<p>
@@ -572,7 +572,7 @@ void printfloats( float *tab, int len );
</pre></td></tr></table>
-<H3><a name="Ocaml_nn17"></a>27.2.4 C++ Classes</H3>
+<H3><a name="Ocaml_nn17"></a>28.2.4 C++ Classes</H3>
<p>
@@ -615,7 +615,7 @@ the underlying pointer, so using create_[x]_from_ptr alters the
returned value for the same object.
</p>
-<H4><a name="Ocaml_nn18"></a>27.2.4.1 STL vector and string Example</H4>
+<H4><a name="Ocaml_nn18"></a>28.2.4.1 STL vector and string Example</H4>
<p>
@@ -695,7 +695,7 @@ baz
#
</pre></div>
-<H4><a name="Ocaml_nn19"></a>27.2.4.2 C++ Class Example</H4>
+<H4><a name="Ocaml_nn19"></a>28.2.4.2 C++ Class Example</H4>
<p>
@@ -725,7 +725,7 @@ public:
};
</pre></td></tr></table>
-<H4><a name="Ocaml_nn20"></a>27.2.4.3 Compiling the example</H4>
+<H4><a name="Ocaml_nn20"></a>28.2.4.3 Compiling the example</H4>
<div class="code"><pre>
@@ -743,7 +743,7 @@ bash-2.05a$ ocamlmktop -custom swig.cmo -I `camlp4 -where` \
-L$QTPATH/lib -cclib -lqt
</pre></div>
-<H4><a name="Ocaml_nn21"></a>27.2.4.4 Sample Session</H4>
+<H4><a name="Ocaml_nn21"></a>28.2.4.4 Sample Session</H4>
<div class="code"><pre>
@@ -770,10 +770,10 @@ Assuming you have a working installation of QT, you will see a window
containing the string "hi" in a button.
</p>
-<H3><a name="Ocaml_nn22"></a>27.2.5 Director Classes</H3>
+<H3><a name="Ocaml_nn22"></a>28.2.5 Director Classes</H3>
-<H4><a name="Ocaml_nn23"></a>27.2.5.1 Director Introduction</H4>
+<H4><a name="Ocaml_nn23"></a>28.2.5.1 Director Introduction</H4>
<p>
@@ -800,7 +800,7 @@ class foo {
};
</pre></div>
-<H4><a name="Ocaml_nn24"></a>27.2.5.2 Overriding Methods in Ocaml</H4>
+<H4><a name="Ocaml_nn24"></a>28.2.5.2 Overriding Methods in Ocaml</H4>
<p>
@@ -828,7 +828,7 @@ In this example, I'll examine the objective caml code involved in providing
an overloaded class. This example is contained in Examples/ocaml/shapes.
</p>
-<H4><a name="Ocaml_nn25"></a>27.2.5.3 Director Usage Example</H4>
+<H4><a name="Ocaml_nn25"></a>28.2.5.3 Director Usage Example</H4>
<table border="1" bgcolor="#dddddd" summary="Director usage example">
@@ -887,7 +887,7 @@ in a more effortless style in ocaml, while leaving the "engine" part of the
program in C++.
</p>
-<H4><a name="Ocaml_nn26"></a>27.2.5.4 Creating director objects</H4>
+<H4><a name="Ocaml_nn26"></a>28.2.5.4 Creating director objects</H4>
<p>
@@ -928,7 +928,7 @@ object from causing a core dump, as long as the object is destroyed
properly.
</p>
-<H4><a name="Ocaml_nn27"></a>27.2.5.5 Typemaps for directors, <tt>directorin, directorout, directorargout</tt></H4>
+<H4><a name="Ocaml_nn27"></a>28.2.5.5 Typemaps for directors, <tt>directorin, directorout, directorargout</tt></H4>
<p>
@@ -939,7 +939,7 @@ well as a function return value in the same way you provide function arguments,
and to receive arguments the same way you normally receive function returns.
</p>
-<H4><a name="Ocaml_nn28"></a>27.2.5.6 <tt>directorin</tt> typemap</H4>
+<H4><a name="Ocaml_nn28"></a>28.2.5.6 <tt>directorin</tt> typemap</H4>
<p>
@@ -950,7 +950,7 @@ code receives when you are called. In general, a simple <tt>directorin</tt> typ
can use the same body as a simple <tt>out</tt> typemap.
</p>
-<H4><a name="Ocaml_nn29"></a>27.2.5.7 <tt>directorout</tt> typemap</H4>
+<H4><a name="Ocaml_nn29"></a>28.2.5.7 <tt>directorout</tt> typemap</H4>
<p>
@@ -961,7 +961,7 @@ for the same type, except when there are special requirements for object
ownership, etc.
</p>
-<H4><a name="Ocaml_nn30"></a>27.2.5.8 <tt>directorargout</tt> typemap</H4>
+<H4><a name="Ocaml_nn30"></a>28.2.5.8 <tt>directorargout</tt> typemap</H4>
<p>
@@ -978,7 +978,7 @@ In the event that you don't specify all of the necessary values, integral
values will read zero, and struct or object returns have undefined results.
</p>
-<H3><a name="Ocaml_nn31"></a>27.2.6 Exceptions</H3>
+<H3><a name="Ocaml_nn31"></a>28.2.6 Exceptions</H3>
<p>
diff --git a/Doc/Manual/Octave.html b/Doc/Manual/Octave.html
index be512f0ce..3c08d849b 100644
--- a/Doc/Manual/Octave.html
+++ b/Doc/Manual/Octave.html
@@ -8,7 +8,7 @@
<body bgcolor="#ffffff">
-<H1><a name="Octave"></a>28 SWIG and Octave</H1>
+<H1><a name="Octave"></a>29 SWIG and Octave</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -46,7 +46,7 @@
<p>
Octave is a high-level language intended for numerical programming that is mostly compatible with MATLAB.
-More information can be found at <a href="http://www.octave.org">www.octave.org</a>.
+More information can be found at <a href="http://www.gnu.org/software/octave/">Octave web site</a>.
</p>
<p>
@@ -54,14 +54,14 @@ More information can be found at <a href="http://www.octave.org">www.octave.org<
Also, there are a dozen or so examples in the Examples/octave directory, and hundreds in the test suite (Examples/test-suite and Examples/test-suite/octave).
</p>
-<H2><a name="Octave_nn2"></a>28.1 Preliminaries</H2>
+<H2><a name="Octave_nn2"></a>29.1 Preliminaries</H2>
<p>
The SWIG implemention was first based on Octave 2.9.12, so this is the minimum version required. Testing has only been done on Linux.
</p>
-<H2><a name="Octave_nn3"></a>28.2 Running SWIG</H2>
+<H2><a name="Octave_nn3"></a>29.2 Running SWIG</H2>
<p>
@@ -97,7 +97,7 @@ This creates a C++ source file <tt>example_wrap.cxx</tt>. A C++ file is generate
The swig command line has a number of options you can use, like to redirect it's output. Use <tt>swig --help</tt> to learn about these.
</p>
-<H3><a name="Octave_nn5"></a>28.2.1 Compiling a dynamic module</H3>
+<H3><a name="Octave_nn5"></a>29.2.1 Compiling a dynamic module</H3>
<p>
@@ -124,7 +124,7 @@ $ mkoctfile example_wrap.cxx example.c
<div class="targetlang"><pre>octave:1&gt; example</pre></div>
-<H3><a name="Octave_nn6"></a>28.2.2 Using your module</H3>
+<H3><a name="Octave_nn6"></a>29.2.2 Using your module</H3>
<p>
@@ -142,10 +142,10 @@ octave:4&gt; example.cvar.Foo=4;
octave:5&gt; example.cvar.Foo
ans = 4 </pre></div>
-<H2><a name="Octave_nn7"></a>28.3 A tour of basic C/C++ wrapping</H2>
+<H2><a name="Octave_nn7"></a>29.3 A tour of basic C/C++ wrapping</H2>
-<H3><a name="Octave_nn8"></a>28.3.1 Modules</H3>
+<H3><a name="Octave_nn8"></a>29.3.1 Modules</H3>
<p>
@@ -187,7 +187,7 @@ One can also rename it by simple assignment, e.g.,
octave:1&gt; some_vars = cvar;
</pre></div>
-<H3><a name="Octave_nn9"></a>28.3.2 Functions</H3>
+<H3><a name="Octave_nn9"></a>29.3.2 Functions</H3>
<p>
@@ -204,7 +204,7 @@ int fact(int n); </pre></div>
<div class="targetlang"><pre>octave:1&gt; example.fact(4)
24 </pre></div>
-<H3><a name="Octave_nn10"></a>28.3.3 Global variables</H3>
+<H3><a name="Octave_nn10"></a>29.3.3 Global variables</H3>
<p>
@@ -257,7 +257,7 @@ octave:2&gt; example.PI=3.142;
octave:3&gt; example.PI
ans = 3.1420 </pre></div>
-<H3><a name="Octave_nn11"></a>28.3.4 Constants and enums</H3>
+<H3><a name="Octave_nn11"></a>29.3.4 Constants and enums</H3>
<p>
@@ -279,7 +279,7 @@ example.SCONST="Hello World"
example.SUNDAY=0
.... </pre></div>
-<H3><a name="Octave_nn12"></a>28.3.5 Pointers</H3>
+<H3><a name="Octave_nn12"></a>29.3.5 Pointers</H3>
<p>
@@ -326,7 +326,7 @@ octave:2&gt; f=example.fopen("not there","r");
error: value on right hand side of assignment is undefined
error: evaluating assignment expression near line 2, column 2 </pre></div>
-<H3><a name="Octave_nn13"></a>28.3.6 Structures and C++ classes</H3>
+<H3><a name="Octave_nn13"></a>29.3.6 Structures and C++ classes</H3>
<p>
@@ -461,7 +461,7 @@ ans = 1
Depending on the ownership setting of a <tt>swig_ref</tt>, it may call C++ destructors when its reference count goes to zero. See the section on memory management below for details.
</p>
-<H3><a name="Octave_nn15"></a>28.3.7 C++ inheritance</H3>
+<H3><a name="Octave_nn15"></a>29.3.7 C++ inheritance</H3>
<p>
@@ -470,7 +470,7 @@ This information contains the full class hierarchy. When an indexing operation (
the tree is walked to find a match in the current class as well as any of its bases. The lookup is then cached in the <tt>swig_ref</tt>.
</p>
-<H3><a name="Octave_nn17"></a>28.3.8 C++ overloaded functions</H3>
+<H3><a name="Octave_nn17"></a>29.3.8 C++ overloaded functions</H3>
<p>
@@ -480,7 +480,7 @@ The dispatch function selects which overload to call (if any) based on the passe
<tt>typecheck</tt> typemaps are used to analyze each argument, as well as assign precedence. See the chapter on typemaps for details.
</p>
-<H3><a name="Octave_nn18"></a>28.3.9 C++ operators</H3>
+<H3><a name="Octave_nn18"></a>29.3.9 C++ operators</H3>
<p>
@@ -580,7 +580,7 @@ On the C++ side, the default mappings are as follows:
%rename(__brace) *::operator[];
</pre></div>
-<H3><a name="Octave_nn19"></a>28.3.10 Class extension with %extend</H3>
+<H3><a name="Octave_nn19"></a>29.3.10 Class extension with %extend</H3>
<p>
@@ -610,7 +610,7 @@ octave:3&gt; printf("%s\n",a);
octave:4&gt; a.__str()
4
</pre></div>
-<H3><a name="Octave_nn20"></a>28.3.11 C++ templates</H3>
+<H3><a name="Octave_nn20"></a>29.3.11 C++ templates</H3>
<p>
@@ -687,14 +687,14 @@ ans =
</pre></div>
-<H3><a name="Octave_nn21"></a>28.3.12 C++ Smart Pointers</H3>
+<H3><a name="Octave_nn21"></a>29.3.12 C++ Smart Pointers</H3>
<p>
C++ smart pointers are fully supported as in other modules.
</p>
-<H3><a name="Octave_nn22"></a>28.3.13 Directors (calling Octave from C++ code)</H3>
+<H3><a name="Octave_nn22"></a>29.3.13 Directors (calling Octave from C++ code)</H3>
<p>
@@ -755,7 +755,8 @@ Note that you have to enable directors via the %feature directive (see other mod
<tt>subclass()</tt> will accept any number of C++ bases or other <tt>subclass()</tt>'ed objects, <tt>(string,octave_value)</tt> pairs, and <tt>function_handles</tt>. In the first case, these are taken as base classes; in the second case, as named members (either variables or functions, depending on whether the given value is a function handle); in the third case, as member functions whose name is taken from the given function handle. E.g.,
</p>
<div class="targetlang"><pre>
-octave:1&gt; B=@(some_var=2) subclass(A(),'some_var',some_var,@some_func,'another_func',@(self) do_stuff())
+octave:1&gt; B=@(some_var=2) subclass(A(),'some_var',some_var,@some_func,'another_func',
+@(self) do_stuff())
</pre></div>
<p>
You can also assign non-C++ member variables and functions after construct time. There is no support for non-C++ static members.
@@ -774,14 +775,14 @@ c-side routine called
octave-side routine called
</pre></div>
-<H3><a name="Octave_nn23"></a>28.3.14 Threads</H3>
+<H3><a name="Octave_nn23"></a>29.3.14 Threads</H3>
<p>
The use of threads in wrapped Director code is not supported; i.e., an Octave-side implementation of a C++ class must be called from the Octave interpreter's thread. Anything fancier (apartment/queue model, whatever) is left to the user. Without anything fancier, this amounts to the limitation that Octave must drive the module... like, for example, an optimization package that calls Octave to evaluate an objective function.
</p>
-<H3><a name="Octave_nn24"></a>28.3.15 Memory management</H3>
+<H3><a name="Octave_nn24"></a>29.3.15 Memory management</H3>
<p>
@@ -815,14 +816,14 @@ The %newobject directive may be used to control this behavior for pointers retur
In the case where one wishes for the C++ side to own an object that was created in Octave (especially a Director object), one can use the __disown() method to invert this logic. Then letting the Octave reference count go to zero will not destroy the object, but destroying the object will invalidate the Octave-side object if it still exists (and call destructors of other C++ bases in the case of multiple inheritance/<tt>subclass()</tt>'ing).
</p>
-<H3><a name="Octave_nn25"></a>28.3.16 STL support</H3>
+<H3><a name="Octave_nn25"></a>29.3.16 STL support</H3>
<p>
Various STL library files are provided for wrapping STL containers.
</p>
-<H3><a name="Octave_nn26"></a>28.3.17 Matrix typemaps</H3>
+<H3><a name="Octave_nn26"></a>29.3.17 Matrix typemaps</H3>
<p>
diff --git a/Doc/Manual/Perl5.html b/Doc/Manual/Perl5.html
index 0c2733c0e..5aae51888 100644
--- a/Doc/Manual/Perl5.html
+++ b/Doc/Manual/Perl5.html
@@ -6,7 +6,7 @@
</head>
<body bgcolor="#ffffff">
-<H1><a name="Perl5"></a>29 SWIG and Perl5</H1>
+<H1><a name="Perl5"></a>30 SWIG and Perl5</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -87,7 +87,7 @@ later. Earlier versions are problematic and SWIG generated extensions
may not compile or run correctly.
</p>
-<H2><a name="Perl5_nn2"></a>29.1 Overview</H2>
+<H2><a name="Perl5_nn2"></a>30.1 Overview</H2>
<p>
@@ -108,7 +108,7 @@ described. Advanced customization features, typemaps, and other
options are found near the end of the chapter.
</p>
-<H2><a name="Perl5_nn3"></a>29.2 Preliminaries</H2>
+<H2><a name="Perl5_nn3"></a>30.2 Preliminaries</H2>
<p>
@@ -133,7 +133,7 @@ To build the module, you will need to compile the file
<tt>example_wrap.c</tt> and link it with the rest of your program.
</p>
-<H3><a name="Perl5_nn4"></a>29.2.1 Getting the right header files</H3>
+<H3><a name="Perl5_nn4"></a>30.2.1 Getting the right header files</H3>
<p>
@@ -165,7 +165,7 @@ loaded, an easy way to find out is to run Perl itself.
</pre>
</div>
-<H3><a name="Perl5_nn5"></a>29.2.2 Compiling a dynamic module</H3>
+<H3><a name="Perl5_nn5"></a>30.2.2 Compiling a dynamic module</H3>
<p>
@@ -198,7 +198,7 @@ the target should be named `<tt>example.so</tt>',
`<tt>example.sl</tt>', or the appropriate dynamic module name on your system.
</p>
-<H3><a name="Perl5_nn6"></a>29.2.3 Building a dynamic module with MakeMaker</H3>
+<H3><a name="Perl5_nn6"></a>30.2.3 Building a dynamic module with MakeMaker</H3>
<p>
@@ -232,7 +232,7 @@ the preferred approach to compilation. More information about MakeMaker can be
found in "Programming Perl, 2nd ed." by Larry Wall, Tom Christiansen,
and Randal Schwartz.</p>
-<H3><a name="Perl5_nn7"></a>29.2.4 Building a static version of Perl</H3>
+<H3><a name="Perl5_nn7"></a>30.2.4 Building a static version of Perl</H3>
<p>
@@ -301,7 +301,7 @@ added to it. Depending on your machine, you may need to link with
additional libraries such as <tt>-lsocket, -lnsl, -ldl</tt>, etc.
</p>
-<H3><a name="Perl5_nn8"></a>29.2.5 Using the module</H3>
+<H3><a name="Perl5_nn8"></a>30.2.5 Using the module</H3>
<p>
@@ -456,7 +456,7 @@ system configuration (this requires root access and you will need to
read the man pages).
</p>
-<H3><a name="Perl5_nn9"></a>29.2.6 Compilation problems and compiling with C++</H3>
+<H3><a name="Perl5_nn9"></a>30.2.6 Compilation problems and compiling with C++</H3>
<p>
@@ -599,7 +599,7 @@ have to find the macro that conflicts and add an #undef into the .i file. Pleas
any conflicting macros you find to <a href="http://www.swig.org/mail.html">swig-user mailing list</a>.
</p>
-<H3><a name="Perl5_nn10"></a>29.2.7 Compiling for 64-bit platforms</H3>
+<H3><a name="Perl5_nn10"></a>30.2.7 Compiling for 64-bit platforms</H3>
<p>
@@ -626,7 +626,7 @@ also introduce problems on platforms that support more than one
linking standard (e.g., -o32 and -n32 on Irix).
</p>
-<H2><a name="Perl5_nn11"></a>29.3 Building Perl Extensions under Windows</H2>
+<H2><a name="Perl5_nn11"></a>30.3 Building Perl Extensions under Windows</H2>
<p>
@@ -637,7 +637,7 @@ section assumes you are using SWIG with Microsoft Visual C++
although the procedure may be similar with other compilers.
</p>
-<H3><a name="Perl5_nn12"></a>29.3.1 Running SWIG from Developer Studio</H3>
+<H3><a name="Perl5_nn12"></a>30.3.1 Running SWIG from Developer Studio</H3>
<p>
@@ -700,7 +700,7 @@ print "$a\n";
</pre></div>
-<H3><a name="Perl5_nn13"></a>29.3.2 Using other compilers</H3>
+<H3><a name="Perl5_nn13"></a>30.3.2 Using other compilers</H3>
<p>
@@ -708,7 +708,7 @@ SWIG is known to work with Cygwin and may work with other compilers on Windows.
For general hints and suggestions refer to the <a href="Windows.html#Windows">Windows</a> chapter.
</p>
-<H2><a name="Perl5_nn14"></a>29.4 The low-level interface</H2>
+<H2><a name="Perl5_nn14"></a>30.4 The low-level interface</H2>
<p>
@@ -718,7 +718,7 @@ can be used to control your application. However, it is also used to
construct more user-friendly proxy classes as described in the next section.
</p>
-<H3><a name="Perl5_nn15"></a>29.4.1 Functions</H3>
+<H3><a name="Perl5_nn15"></a>30.4.1 Functions</H3>
<p>
@@ -741,7 +741,7 @@ use example;
$a = &amp;example::fact(2);
</pre></div>
-<H3><a name="Perl5_nn16"></a>29.4.2 Global variables</H3>
+<H3><a name="Perl5_nn16"></a>30.4.2 Global variables</H3>
<p>
@@ -811,7 +811,7 @@ extern char *path; // Declared later in the input
</pre>
</div>
-<H3><a name="Perl5_nn17"></a>29.4.3 Constants</H3>
+<H3><a name="Perl5_nn17"></a>30.4.3 Constants</H3>
<p>
@@ -851,7 +851,7 @@ print example::FOO,"\n";
</pre>
</div>
-<H3><a name="Perl5_nn18"></a>29.4.4 Pointers</H3>
+<H3><a name="Perl5_nn18"></a>30.4.4 Pointers</H3>
<p>
@@ -960,7 +960,7 @@ as XS and <tt>xsubpp</tt>. Given the advancement of the SWIG typesystem and the
SWIG and XS, this is no longer supported.
</p>
-<H3><a name="Perl5_nn19"></a>29.4.5 Structures</H3>
+<H3><a name="Perl5_nn19"></a>30.4.5 Structures</H3>
<p>
@@ -1094,7 +1094,7 @@ void Bar_f_set(Bar *b, Foo *val) {
</div>
-<H3><a name="Perl5_nn20"></a>29.4.6 C++ classes</H3>
+<H3><a name="Perl5_nn20"></a>30.4.6 C++ classes</H3>
<p>
@@ -1159,7 +1159,7 @@ provides direct access to C++ objects. A higher level interface using Perl prox
can be built using these low-level accessors. This is described shortly.
</p>
-<H3><a name="Perl5_nn21"></a>29.4.7 C++ classes and type-checking</H3>
+<H3><a name="Perl5_nn21"></a>30.4.7 C++ classes and type-checking</H3>
<p>
@@ -1195,7 +1195,7 @@ If necessary, the type-checker also adjusts the value of the pointer (as is nece
multiple inheritance is used).
</p>
-<H3><a name="Perl5_nn22"></a>29.4.8 C++ overloaded functions</H3>
+<H3><a name="Perl5_nn22"></a>30.4.8 C++ overloaded functions</H3>
<p>
@@ -1239,7 +1239,7 @@ example::Spam_foo_d($s,3.14);
Please refer to the "SWIG Basics" chapter for more information.
</p>
-<H3><a name="Perl5_nn23"></a>29.4.9 Operators</H3>
+<H3><a name="Perl5_nn23"></a>30.4.9 Operators</H3>
<p>
@@ -1266,7 +1266,7 @@ The following C++ operators are currently supported by the Perl module:
<li>operator or </li>
</ul>
-<H3><a name="Perl5_nn24"></a>29.4.10 Modules and packages</H3>
+<H3><a name="Perl5_nn24"></a>30.4.10 Modules and packages</H3>
<p>
@@ -1361,7 +1361,7 @@ print Foo::fact(4),"\n"; # Call a function in package FooBar
</pre></div>
-->
-<H2><a name="Perl5_nn25"></a>29.5 Input and output parameters</H2>
+<H2><a name="Perl5_nn25"></a>30.5 Input and output parameters</H2>
<p>
@@ -1580,7 +1580,7 @@ print "$c\n";
<b>Note:</b> The <tt>REFERENCE</tt> feature is only currently supported for numeric types (integers and floating point).
</p>
-<H2><a name="Perl5_nn26"></a>29.6 Exception handling</H2>
+<H2><a name="Perl5_nn26"></a>30.6 Exception handling</H2>
<p>
@@ -1745,7 +1745,7 @@ This is still supported, but it is deprecated. The newer <tt>%exception</tt> di
functionality, but it has additional capabilities that make it more powerful.
</p>
-<H2><a name="Perl5_nn27"></a>29.7 Remapping datatypes with typemaps</H2>
+<H2><a name="Perl5_nn27"></a>30.7 Remapping datatypes with typemaps</H2>
<p>
@@ -1762,7 +1762,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Perl interface.
</p>
-<H3><a name="Perl5_nn28"></a>29.7.1 A simple typemap example</H3>
+<H3><a name="Perl5_nn28"></a>30.7.1 A simple typemap example</H3>
<p>
@@ -1866,7 +1866,7 @@ example::count("e","Hello World");
</div>
-<H3><a name="Perl5_nn29"></a>29.7.2 Perl5 typemaps</H3>
+<H3><a name="Perl5_nn29"></a>30.7.2 Perl5 typemaps</H3>
<p>
@@ -1971,7 +1971,7 @@ Return of C++ member data (all languages).
Check value of input parameter.
</div>
-<H3><a name="Perl5_nn30"></a>29.7.3 Typemap variables</H3>
+<H3><a name="Perl5_nn30"></a>30.7.3 Typemap variables</H3>
<p>
@@ -2042,7 +2042,7 @@ properly assigned.
The Perl name of the wrapper function being created.
</div>
-<H3><a name="Perl5_nn31"></a>29.7.4 Useful functions</H3>
+<H3><a name="Perl5_nn31"></a>30.7.4 Useful functions</H3>
<p>
@@ -2111,7 +2111,7 @@ int sv_isa(SV *, char *0;
</div>
-<H2><a name="Perl5_nn32"></a>29.8 Typemap Examples</H2>
+<H2><a name="Perl5_nn32"></a>30.8 Typemap Examples</H2>
<p>
@@ -2120,7 +2120,7 @@ might look at the files "<tt>perl5.swg</tt>" and "<tt>typemaps.i</tt>" in
the SWIG library.
</p>
-<H3><a name="Perl5_nn33"></a>29.8.1 Converting a Perl5 array to a char **</H3>
+<H3><a name="Perl5_nn33"></a>30.8.1 Converting a Perl5 array to a char **</H3>
<p>
@@ -2212,7 +2212,7 @@ print @$b,"\n"; # Print it out
</pre></div>
-<H3><a name="Perl5_nn34"></a>29.8.2 Return values</H3>
+<H3><a name="Perl5_nn34"></a>30.8.2 Return values</H3>
<p>
@@ -2241,7 +2241,7 @@ can be done using the <tt>EXTEND()</tt> macro as in :
}
</pre></div>
-<H3><a name="Perl5_nn35"></a>29.8.3 Returning values from arguments</H3>
+<H3><a name="Perl5_nn35"></a>30.8.3 Returning values from arguments</H3>
<p>
@@ -2295,7 +2295,7 @@ print "multout(7,13) = @r\n";
($x,$y) = multout(7,13);
</pre></div>
-<H3><a name="Perl5_nn36"></a>29.8.4 Accessing array structure members</H3>
+<H3><a name="Perl5_nn36"></a>30.8.4 Accessing array structure members</H3>
<p>
@@ -2358,7 +2358,7 @@ the "in" typemap in the previous section would be used to convert an
to copy the converted array into a C data structure.
</p>
-<H3><a name="Perl5_nn37"></a>29.8.5 Turning Perl references into C pointers</H3>
+<H3><a name="Perl5_nn37"></a>30.8.5 Turning Perl references into C pointers</H3>
<p>
@@ -2423,7 +2423,7 @@ print "$c\n";
</pre></div>
-<H3><a name="Perl5_nn38"></a>29.8.6 Pointer handling</H3>
+<H3><a name="Perl5_nn38"></a>30.8.6 Pointer handling</H3>
<p>
@@ -2502,7 +2502,7 @@ For example:
</pre>
</div>
-<H2><a name="Perl5_nn39"></a>29.9 Proxy classes</H2>
+<H2><a name="Perl5_nn39"></a>30.9 Proxy classes</H2>
<p>
@@ -2518,7 +2518,7 @@ to the underlying code. This section describes the implementation
details of the proxy interface.
</p>
-<H3><a name="Perl5_nn40"></a>29.9.1 Preliminaries</H3>
+<H3><a name="Perl5_nn40"></a>30.9.1 Preliminaries</H3>
<p>
@@ -2540,7 +2540,7 @@ SWIG creates a collection of high-level Perl wrappers. In your scripts, you wil
high level wrappers. The wrappers, in turn, interact with the low-level procedural module.
</p>
-<H3><a name="Perl5_nn41"></a>29.9.2 Structure and class wrappers</H3>
+<H3><a name="Perl5_nn41"></a>30.9.2 Structure and class wrappers</H3>
<p>
@@ -2666,7 +2666,7 @@ $v-&gt;DESTROY();
</pre></div>
-<H3><a name="Perl5_nn42"></a>29.9.3 Object Ownership</H3>
+<H3><a name="Perl5_nn42"></a>30.9.3 Object Ownership</H3>
<p>
@@ -2753,7 +2753,7 @@ counting, garbage collection, or advanced features one might find in
sophisticated languages.
</p>
-<H3><a name="Perl5_nn43"></a>29.9.4 Nested Objects</H3>
+<H3><a name="Perl5_nn43"></a>30.9.4 Nested Objects</H3>
<p>
@@ -2806,7 +2806,7 @@ $p-&gt;{f}-&gt;{x} = 0.0;
%${$p-&gt;{v}} = ( x=&gt;0, y=&gt;0, z=&gt;0);
</pre></div>
-<H3><a name="Perl5_nn44"></a>29.9.5 Proxy Functions</H3>
+<H3><a name="Perl5_nn44"></a>30.9.5 Proxy Functions</H3>
<p>
@@ -2840,7 +2840,7 @@ This function replaces the original function, but operates in an
identical manner.
</p>
-<H3><a name="Perl5_nn45"></a>29.9.6 Inheritance</H3>
+<H3><a name="Perl5_nn45"></a>30.9.6 Inheritance</H3>
<p>
@@ -2916,7 +2916,7 @@ particular, inheritance of data members is extremely tricky (and I'm
not even sure if it really works).
</p>
-<H3><a name="Perl5_nn46"></a>29.9.7 Modifying the proxy methods</H3>
+<H3><a name="Perl5_nn46"></a>30.9.7 Modifying the proxy methods</H3>
<p>
@@ -2944,7 +2944,7 @@ public:
};
</pre></div>
-<H2><a name="Perl5_nn47"></a>29.10 Adding additional Perl code</H2>
+<H2><a name="Perl5_nn47"></a>30.10 Adding additional Perl code</H2>
<p>
diff --git a/Doc/Manual/Php.html b/Doc/Manual/Php.html
index c9ee74f38..797cb058e 100644
--- a/Doc/Manual/Php.html
+++ b/Doc/Manual/Php.html
@@ -7,7 +7,7 @@
</head>
<body bgcolor="#ffffff">
-<H1><a name="Php"></a>30 SWIG and PHP</H1>
+<H1><a name="Php"></a>31 SWIG and PHP</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -75,7 +75,7 @@ your extension into php directly, you will need the complete PHP source tree
available.
</p>
-<H2><a name="Php_nn1"></a>30.1 Generating PHP Extensions</H2>
+<H2><a name="Php_nn1"></a>31.1 Generating PHP Extensions</H2>
<p>
@@ -122,7 +122,7 @@ and it doesn't play nicely with package system. We don't recommend
this approach, or provide explicit support for it.
</p>
-<H3><a name="Php_nn1_1"></a>30.1.1 Building a loadable extension</H3>
+<H3><a name="Php_nn1_1"></a>31.1.1 Building a loadable extension</H3>
<p>
@@ -137,7 +137,7 @@ least work for Linux though):
gcc -shared example_wrap.o -o example.so
</pre></div>
-<H3><a name="Php_nn1_3"></a>30.1.2 Using PHP Extensions</H3>
+<H3><a name="Php_nn1_3"></a>31.1.2 Using PHP Extensions</H3>
<p>
@@ -168,7 +168,7 @@ attempts to do the <tt>dl()</tt> call for you:
include("example.php");
</pre></div>
-<H2><a name="Php_nn2"></a>30.2 Basic PHP interface</H2>
+<H2><a name="Php_nn2"></a>31.2 Basic PHP interface</H2>
<p>
@@ -178,7 +178,7 @@ possible for names of symbols in one extension module to clash with
other symbols unless care is taken to <tt>%rename</tt> them.
</p>
-<H3><a name="Php_nn2_1"></a>30.2.1 Constants</H3>
+<H3><a name="Php_nn2_1"></a>31.2.1 Constants</H3>
<p>
@@ -303,7 +303,7 @@ both point to the same value, without the case test taking place. (
Apologies, this paragraph needs rewriting to make some sense. )
</p>
-<H3><a name="Php_nn2_2"></a>30.2.2 Global Variables</H3>
+<H3><a name="Php_nn2_2"></a>31.2.2 Global Variables</H3>
<p>
@@ -352,7 +352,7 @@ undefined.
At this time SWIG does not support custom accessor methods.
</p>
-<H3><a name="Php_nn2_3"></a>30.2.3 Functions</H3>
+<H3><a name="Php_nn2_3"></a>31.2.3 Functions</H3>
<p>
@@ -405,7 +405,7 @@ print $s; # The value of $s was not changed.
-->
-<H3><a name="Php_nn2_4"></a>30.2.4 Overloading</H3>
+<H3><a name="Php_nn2_4"></a>31.2.4 Overloading</H3>
<p>
@@ -461,7 +461,7 @@ taking the integer argument.
</p>
-->
-<H3><a name="Php_nn2_5"></a>30.2.5 Pointers and References</H3>
+<H3><a name="Php_nn2_5"></a>31.2.5 Pointers and References</H3>
<p>
@@ -593,7 +593,7 @@ PHP in a number of ways: by using <tt>unset</tt> on an existing
variable, or assigning <tt>NULL</tt> to a variable.
</p>
-<H3><a name="Php_nn2_6"></a>30.2.6 Structures and C++ classes</H3>
+<H3><a name="Php_nn2_6"></a>31.2.6 Structures and C++ classes</H3>
<p>
@@ -652,7 +652,7 @@ Would be used in the following way from PHP5:
Member variables and methods are accessed using the <tt>-&gt;</tt> operator.
</p>
-<H4><a name="Php_nn2_6_1"></a>30.2.6.1 Using <tt>-noproxy</tt></H4>
+<H4><a name="Php_nn2_6_1"></a>31.2.6.1 Using <tt>-noproxy</tt></H4>
<p>
@@ -678,7 +678,7 @@ Complex_im_set($obj,$d);
Complex_im_get($obj);
</pre></div>
-<H4><a name="Php_nn2_6_2"></a>30.2.6.2 Constructors and Destructors</H4>
+<H4><a name="Php_nn2_6_2"></a>31.2.6.2 Constructors and Destructors</H4>
<p>
@@ -719,7 +719,7 @@ the programmer can either reassign the variable or call
<tt>unset($v)</tt>
</p>
-<H4><a name="Php_nn2_6_3"></a>30.2.6.3 Static Member Variables</H4>
+<H4><a name="Php_nn2_6_3"></a>31.2.6.3 Static Member Variables</H4>
<p>
@@ -762,7 +762,7 @@ Ko::threats(10);
echo "There has now been " . Ko::threats() . " threats\n";
</pre></div>
-<H4><a name="Php_nn2_6_4"></a>30.2.6.4 Static Member Functions</H4>
+<H4><a name="Php_nn2_6_4"></a>31.2.6.4 Static Member Functions</H4>
<p>
@@ -784,7 +784,7 @@ Ko::threats();
</pre></div>
-<H3><a name="Php_nn2_7"></a>30.2.7 PHP Pragmas, Startup and Shutdown code</H3>
+<H3><a name="Php_nn2_7"></a>31.2.7 PHP Pragmas, Startup and Shutdown code</H3>
<p>
@@ -872,7 +872,7 @@ The <tt>%rinit</tt> and <tt>%rshutdown</tt> statements are very similar but inse
into the request init (PHP_RINIT_FUNCTION) and request shutdown (PHP_RSHUTDOWN_FUNCTION) code respectively.
</p>
-<H2><a name="Php_nn3"></a>30.3 Cross language polymorphism</H2>
+<H2><a name="Php_nn3"></a>31.3 Cross language polymorphism</H2>
<p>
@@ -907,7 +907,7 @@ wrapper functions takes care of all the cross-language method routing
transparently.
</p>
-<H3><a name="Php_nn3_1"></a>30.3.1 Enabling directors</H3>
+<H3><a name="Php_nn3_1"></a>31.3.1 Enabling directors</H3>
<p>
@@ -999,7 +999,7 @@ class MyFoo extends Foo {
</div>
-<H3><a name="Php_nn3_2"></a>30.3.2 Director classes</H3>
+<H3><a name="Php_nn3_2"></a>31.3.2 Director classes</H3>
@@ -1079,7 +1079,7 @@ so there is no need for the extra overhead involved with routing the
calls through PHP.
</p>
-<H3><a name="Php_nn3_3"></a>30.3.3 Ownership and object destruction</H3>
+<H3><a name="Php_nn3_3"></a>31.3.3 Ownership and object destruction</H3>
<p>
@@ -1135,7 +1135,7 @@ In this example, we are assuming that FooContainer will take care of
deleting all the Foo pointers it contains at some point.
</p>
-<H3><a name="Php_nn3_4"></a>30.3.4 Exception unrolling</H3>
+<H3><a name="Php_nn3_4"></a>31.3.4 Exception unrolling</H3>
<p>
@@ -1194,7 +1194,7 @@ Swig::DirectorMethodException is thrown, PHP will register the exception
as soon as the C wrapper function returns.
</p>
-<H3><a name="Php_nn3_5"></a>30.3.5 Overhead and code bloat</H3>
+<H3><a name="Php_nn3_5"></a>31.3.5 Overhead and code bloat</H3>
<p>
@@ -1227,7 +1227,7 @@ optimized by selectively enabling director methods (using the %feature
directive) for only those methods that are likely to be extended in PHP.
</p>
-<H3><a name="Php_nn3_6"></a>30.3.6 Typemaps</H3>
+<H3><a name="Php_nn3_6"></a>31.3.6 Typemaps</H3>
<p>
@@ -1241,7 +1241,7 @@ need to be supported.
</p>
-<H3><a name="Php_nn3_7"></a>30.3.7 Miscellaneous</H3>
+<H3><a name="Php_nn3_7"></a>31.3.7 Miscellaneous</H3>
<p> Director typemaps for STL classes are mostly in place, and hence you
diff --git a/Doc/Manual/Pike.html b/Doc/Manual/Pike.html
index 8f9e43735..8bd6b410f 100644
--- a/Doc/Manual/Pike.html
+++ b/Doc/Manual/Pike.html
@@ -6,7 +6,7 @@
</head>
<body bgcolor="#ffffff">
-<H1><a name="Pike"></a>31 SWIG and Pike</H1>
+<H1><a name="Pike"></a>32 SWIG and Pike</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -46,10 +46,10 @@ least, make sure you read the "<a href="SWIG.html#SWIG">SWIG Basics</a>"
chapter.<br>
</p>
-<H2><a name="Pike_nn2"></a>31.1 Preliminaries</H2>
+<H2><a name="Pike_nn2"></a>32.1 Preliminaries</H2>
-<H3><a name="Pike_nn3"></a>31.1.1 Running SWIG</H3>
+<H3><a name="Pike_nn3"></a>32.1.1 Running SWIG</H3>
<p>
@@ -94,7 +94,7 @@ can use the <tt>-o</tt> option:
<div class="code">
<pre>$ <b>swig -pike -o pseudonym.c example.i</b><br></pre>
</div>
-<H3><a name="Pike_nn4"></a>31.1.2 Getting the right header files</H3>
+<H3><a name="Pike_nn4"></a>32.1.2 Getting the right header files</H3>
<p>
@@ -114,7 +114,7 @@ You're looking for files with the names <tt>global.h</tt>, <tt>program.h</tt>
and so on.
</p>
-<H3><a name="Pike_nn5"></a>31.1.3 Using your module</H3>
+<H3><a name="Pike_nn5"></a>32.1.3 Using your module</H3>
<p>
@@ -129,10 +129,10 @@ Pike v7.4 release 10 running Hilfe v3.5 (Incremental Pike Frontend)
(1) Result: 24
</pre></div>
-<H2><a name="Pike_nn6"></a>31.2 Basic C/C++ Mapping</H2>
+<H2><a name="Pike_nn6"></a>32.2 Basic C/C++ Mapping</H2>
-<H3><a name="Pike_nn7"></a>31.2.1 Modules</H3>
+<H3><a name="Pike_nn7"></a>32.2.1 Modules</H3>
<p>
@@ -143,7 +143,7 @@ concerned), SWIG's <tt>%module</tt> directive doesn't really have any
significance.
</p>
-<H3><a name="Pike_nn8"></a>31.2.2 Functions</H3>
+<H3><a name="Pike_nn8"></a>32.2.2 Functions</H3>
<p>
@@ -168,7 +168,7 @@ exactly as you'd expect it to:
(1) Result: 24
</pre></div>
-<H3><a name="Pike_nn9"></a>31.2.3 Global variables</H3>
+<H3><a name="Pike_nn9"></a>32.2.3 Global variables</H3>
<p>
@@ -197,7 +197,7 @@ will result in two functions, <tt>Foo_get()</tt> and <tt>Foo_set()</tt>:
(3) Result: 3.141590
</pre></div>
-<H3><a name="Pike_nn10"></a>31.2.4 Constants and enumerated types</H3>
+<H3><a name="Pike_nn10"></a>32.2.4 Constants and enumerated types</H3>
<p>
@@ -205,7 +205,7 @@ Enumerated types in C/C++ declarations are wrapped as Pike constants,
not as Pike enums.
</p>
-<H3><a name="Pike_nn11"></a>31.2.5 Constructors and Destructors</H3>
+<H3><a name="Pike_nn11"></a>32.2.5 Constructors and Destructors</H3>
<p>
@@ -213,7 +213,7 @@ Constructors are wrapped as <tt>create()</tt> methods, and destructors are
wrapped as <tt>destroy()</tt> methods, for Pike classes.
</p>
-<H3><a name="Pike_nn12"></a>31.2.6 Static Members</H3>
+<H3><a name="Pike_nn12"></a>32.2.6 Static Members</H3>
<p>
diff --git a/Doc/Manual/Python.html b/Doc/Manual/Python.html
index 23271e649..1b8a3f671 100644
--- a/Doc/Manual/Python.html
+++ b/Doc/Manual/Python.html
@@ -6,7 +6,7 @@
</head>
<body bgcolor="#ffffff">
-<H1><a name="Python"></a>32 SWIG and Python</H1>
+<H1><a name="Python"></a>33 SWIG and Python</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -128,7 +128,7 @@ very least, make sure you read the "<a href="SWIG.html#SWIG">SWIG
Basics</a>" chapter.
</p>
-<H2><a name="Python_nn2"></a>32.1 Overview</H2>
+<H2><a name="Python_nn2"></a>33.1 Overview</H2>
<p>
@@ -155,10 +155,10 @@ described followed by a discussion of low-level implementation
details.
</p>
-<H2><a name="Python_nn3"></a>32.2 Preliminaries</H2>
+<H2><a name="Python_nn3"></a>33.2 Preliminaries</H2>
-<H3><a name="Python_nn4"></a>32.2.1 Running SWIG</H3>
+<H3><a name="Python_nn4"></a>33.2.1 Running SWIG</H3>
<p>
@@ -256,13 +256,13 @@ The following sections have further practical examples and details on
how you might go about compiling and using the generated files.
</p>
-<H3><a name="Python_nn6"></a>32.2.2 Using distutils</H3>
+<H3><a name="Python_nn6"></a>33.2.2 Using distutils</H3>
<p>
The preferred approach to building an extension module for python is to compile it with
distutils, which comes with all recent versions of python
-(<a href="http://docs.python.org/dist/dist.html">Distutils Docs</a>).
+(<a href="http://docs.python.org/distutils/index.html">Distutils Docs</a>).
</p>
<p>
@@ -348,7 +348,7 @@ This same approach works on all platforms if the appropriate compiler is install
can even build extensions to the standard Windows Python using MingGW)
</p>
-<H3><a name="Python_nn7"></a>32.2.3 Hand compiling a dynamic module</H3>
+<H3><a name="Python_nn7"></a>33.2.3 Hand compiling a dynamic module</H3>
<p>
@@ -396,7 +396,7 @@ module actually consists of two files; <tt>socket.py</tt> and
</p>
-<H3><a name="Python_nn8"></a>32.2.4 Static linking</H3>
+<H3><a name="Python_nn8"></a>33.2.4 Static linking</H3>
<p>
@@ -475,7 +475,7 @@ If using static linking, you might want to rely on a different approach
(perhaps using distutils).
</p>
-<H3><a name="Python_nn9"></a>32.2.5 Using your module</H3>
+<H3><a name="Python_nn9"></a>33.2.5 Using your module</H3>
<p>
@@ -632,7 +632,7 @@ system configuration (this requires root access and you will need to
read the man pages).
</p>
-<H3><a name="Python_nn10"></a>32.2.6 Compilation of C++ extensions</H3>
+<H3><a name="Python_nn10"></a>33.2.6 Compilation of C++ extensions</H3>
<p>
@@ -724,7 +724,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="Python_nn11"></a>32.2.7 Compiling for 64-bit platforms</H3>
+<H3><a name="Python_nn11"></a>33.2.7 Compiling for 64-bit platforms</H3>
<p>
@@ -761,7 +761,7 @@ and -m64 allow you to choose the desired binary format for your python
extension.
</p>
-<H3><a name="Python_nn12"></a>32.2.8 Building Python Extensions under Windows</H3>
+<H3><a name="Python_nn12"></a>33.2.8 Building Python Extensions under Windows</H3>
<p>
@@ -870,7 +870,7 @@ SWIG Wiki</a>.
</p>
-<H2><a name="Python_nn13"></a>32.3 A tour of basic C/C++ wrapping</H2>
+<H2><a name="Python_nn13"></a>33.3 A tour of basic C/C++ wrapping</H2>
<p>
@@ -879,7 +879,7 @@ to your C/C++ code. Functions are wrapped as functions, classes are wrapped as
This section briefly covers the essential aspects of this wrapping.
</p>
-<H3><a name="Python_nn14"></a>32.3.1 Modules</H3>
+<H3><a name="Python_nn14"></a>33.3.1 Modules</H3>
<p>
@@ -892,7 +892,7 @@ module name, make sure you don't use the same name as a built-in
Python command or standard module name.
</p>
-<H3><a name="Python_nn15"></a>32.3.2 Functions</H3>
+<H3><a name="Python_nn15"></a>33.3.2 Functions</H3>
<p>
@@ -916,7 +916,7 @@ like you think it does:
&gt;&gt;&gt;
</pre></div>
-<H3><a name="Python_nn16"></a>32.3.3 Global variables</H3>
+<H3><a name="Python_nn16"></a>33.3.3 Global variables</H3>
<p>
@@ -1054,7 +1054,7 @@ that starts with a leading underscore. SWIG does not create <tt>cvar</tt>
if there are no global variables in a module.
</p>
-<H3><a name="Python_nn17"></a>32.3.4 Constants and enums</H3>
+<H3><a name="Python_nn17"></a>33.3.4 Constants and enums</H3>
<p>
@@ -1094,7 +1094,7 @@ other object. Unfortunately, there is no easy way for SWIG to
generate code that prevents this. You will just have to be careful.
</p>
-<H3><a name="Python_nn18"></a>32.3.5 Pointers</H3>
+<H3><a name="Python_nn18"></a>33.3.5 Pointers</H3>
<p>
@@ -1235,7 +1235,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="Python_nn19"></a>32.3.6 Structures</H3>
+<H3><a name="Python_nn19"></a>33.3.6 Structures</H3>
<p>
@@ -1424,7 +1424,7 @@ everything works just like you would expect. For example:
</pre>
</div>
-<H3><a name="Python_nn20"></a>32.3.7 C++ classes</H3>
+<H3><a name="Python_nn20"></a>33.3.7 C++ classes</H3>
<p>
@@ -1513,7 +1513,7 @@ they are accessed through <tt>cvar</tt> like this:
</pre>
</div>
-<H3><a name="Python_nn21"></a>32.3.8 C++ inheritance</H3>
+<H3><a name="Python_nn21"></a>33.3.8 C++ inheritance</H3>
<p>
@@ -1568,7 +1568,7 @@ then the function <tt>spam()</tt> accepts <tt>Foo *</tt> or a pointer to any cla
It is safe to use multiple inheritance with SWIG.
</p>
-<H3><a name="Python_nn22"></a>32.3.9 Pointers, references, values, and arrays</H3>
+<H3><a name="Python_nn22"></a>33.3.9 Pointers, references, values, and arrays</H3>
<p>
@@ -1629,7 +1629,7 @@ treated as a returning value, and it will follow the same
allocation/deallocation process.
</p>
-<H3><a name="Python_nn23"></a>32.3.10 C++ overloaded functions</H3>
+<H3><a name="Python_nn23"></a>33.3.10 C++ overloaded functions</H3>
<p>
@@ -1752,7 +1752,7 @@ first declaration takes precedence.
Please refer to the "SWIG and C++" chapter for more information about overloading.
</p>
-<H3><a name="Python_nn24"></a>32.3.11 C++ operators</H3>
+<H3><a name="Python_nn24"></a>33.3.11 C++ operators</H3>
<p>
@@ -1841,7 +1841,7 @@ Also, be aware that certain operators don't map cleanly to Python. For instance
overloaded assignment operators don't map to Python semantics and will be ignored.
</p>
-<H3><a name="Python_nn25"></a>32.3.12 C++ namespaces</H3>
+<H3><a name="Python_nn25"></a>33.3.12 C++ namespaces</H3>
<p>
@@ -1908,7 +1908,7 @@ utilizes thousands of small deeply nested namespaces each with
identical symbol names, well, then you get what you deserve.
</p>
-<H3><a name="Python_nn26"></a>32.3.13 C++ templates</H3>
+<H3><a name="Python_nn26"></a>33.3.13 C++ templates</H3>
<p>
@@ -1962,7 +1962,7 @@ Some more complicated
examples will appear later.
</p>
-<H3><a name="Python_nn27"></a>32.3.14 C++ Smart Pointers</H3>
+<H3><a name="Python_nn27"></a>33.3.14 C++ Smart Pointers</H3>
<p>
@@ -2047,7 +2047,7 @@ simply use the <tt>__deref__()</tt> method. For example:
</div>
-<H3><a name="Python_nn27a"></a>32.3.15 C++ Reference Counted Objects (ref/unref)</H3>
+<H3><a name="Python_nn27a"></a>33.3.15 C++ Reference Counted Objects (ref/unref)</H3>
<p>
@@ -2190,7 +2190,7 @@ python releases the proxy instance.
</p>
-<H2><a name="Python_nn28"></a>32.4 Further details on the Python class interface</H2>
+<H2><a name="Python_nn28"></a>33.4 Further details on the Python class interface</H2>
<p>
@@ -2203,7 +2203,7 @@ of low-level details were omitted. This section provides a brief overview
of how the proxy classes work.
</p>
-<H3><a name="Python_nn29"></a>32.4.1 Proxy classes</H3>
+<H3><a name="Python_nn29"></a>33.4.1 Proxy classes</H3>
<p>
@@ -2292,7 +2292,7 @@ you can attach new Python methods to the class and you can even inherit from it
by Python built-in types until Python 2.2).
</p>
-<H3><a name="Python_nn30"></a>32.4.2 Memory management</H3>
+<H3><a name="Python_nn30"></a>33.4.2 Memory management</H3>
<p>
@@ -2484,7 +2484,7 @@ It is also possible to deal with situations like this using
typemaps--an advanced topic discussed later.
</p>
-<H3><a name="Python_nn31"></a>32.4.3 Python 2.2 and classic classes</H3>
+<H3><a name="Python_nn31"></a>33.4.3 Python 2.2 and classic classes</H3>
<p>
@@ -2521,7 +2521,7 @@ class itself. In Python-2.1 and earlier, they have to be accessed as a global
function or through an instance (see the earlier section).
</p>
-<H2><a name="Python_directors"></a>32.5 Cross language polymorphism</H2>
+<H2><a name="Python_directors"></a>33.5 Cross language polymorphism</H2>
<p>
@@ -2555,7 +2555,7 @@ proxy classes, director classes, and C wrapper functions takes care of
all the cross-language method routing transparently.
</p>
-<H3><a name="Python_nn33"></a>32.5.1 Enabling directors</H3>
+<H3><a name="Python_nn33"></a>33.5.1 Enabling directors</H3>
<p>
@@ -2648,7 +2648,7 @@ class MyFoo(mymodule.Foo):
</div>
-<H3><a name="Python_nn34"></a>32.5.2 Director classes</H3>
+<H3><a name="Python_nn34"></a>33.5.2 Director classes</H3>
@@ -2730,7 +2730,7 @@ so there is no need for the extra overhead involved with routing the
calls through Python.
</p>
-<H3><a name="Python_nn35"></a>32.5.3 Ownership and object destruction</H3>
+<H3><a name="Python_nn35"></a>33.5.3 Ownership and object destruction</H3>
<p>
@@ -2797,7 +2797,7 @@ deleting all the Foo pointers it contains at some point. Note that no hard
references to the Foo objects remain in Python.
</p>
-<H3><a name="Python_nn36"></a>32.5.4 Exception unrolling</H3>
+<H3><a name="Python_nn36"></a>33.5.4 Exception unrolling</H3>
<p>
@@ -2856,7 +2856,7 @@ Swig::DirectorMethodException is thrown, Python will register the
exception as soon as the C wrapper function returns.
</p>
-<H3><a name="Python_nn37"></a>32.5.5 Overhead and code bloat</H3>
+<H3><a name="Python_nn37"></a>33.5.5 Overhead and code bloat</H3>
<p>
@@ -2890,7 +2890,7 @@ directive) for only those methods that are likely to be extended in
Python.
</p>
-<H3><a name="Python_nn38"></a>32.5.6 Typemaps</H3>
+<H3><a name="Python_nn38"></a>33.5.6 Typemaps</H3>
<p>
@@ -2904,7 +2904,7 @@ need to be supported.
</p>
-<H3><a name="Python_nn39"></a>32.5.7 Miscellaneous</H3>
+<H3><a name="Python_nn39"></a>33.5.7 Miscellaneous</H3>
<p>
@@ -2951,7 +2951,7 @@ methods that return const references.
</p>
-<H2><a name="Python_nn40"></a>32.6 Common customization features</H2>
+<H2><a name="Python_nn40"></a>33.6 Common customization features</H2>
<p>
@@ -2964,7 +2964,7 @@ This section describes some common SWIG features that are used to
improve your the interface to an extension module.
</p>
-<H3><a name="Python_nn41"></a>32.6.1 C/C++ helper functions</H3>
+<H3><a name="Python_nn41"></a>33.6.1 C/C++ helper functions</H3>
<p>
@@ -3045,7 +3045,7 @@ hard to implement. It is possible to clean this up using Python code, typemaps,
customization features as covered in later sections.
</p>
-<H3><a name="Python_nn42"></a>32.6.2 Adding additional Python code</H3>
+<H3><a name="Python_nn42"></a>33.6.2 Adding additional Python code</H3>
<p>
@@ -3194,7 +3194,7 @@ public:
-<H3><a name="Python_nn43"></a>32.6.3 Class extension with %extend</H3>
+<H3><a name="Python_nn43"></a>33.6.3 Class extension with %extend</H3>
<p>
@@ -3283,7 +3283,7 @@ Vector(12,14,16)
in any way---the extensions only show up in the Python interface.
</p>
-<H3><a name="Python_nn44"></a>32.6.4 Exception handling with %exception</H3>
+<H3><a name="Python_nn44"></a>33.6.4 Exception handling with %exception</H3>
<p>
@@ -3409,7 +3409,7 @@ The language-independent <tt>exception.i</tt> library file can also be used
to raise exceptions. See the <a href="Library.html#Library">SWIG Library</a> chapter.
</p>
-<H2><a name="Python_nn45"></a>32.7 Tips and techniques</H2>
+<H2><a name="Python_nn45"></a>33.7 Tips and techniques</H2>
<p>
@@ -3419,7 +3419,7 @@ strings, binary data, and arrays. This chapter discusses the common techniques
solving these problems.
</p>
-<H3><a name="Python_nn46"></a>32.7.1 Input and output parameters</H3>
+<H3><a name="Python_nn46"></a>33.7.1 Input and output parameters</H3>
<p>
@@ -3632,7 +3632,7 @@ void foo(Bar *OUTPUT);
may not have the intended effect since <tt>typemaps.i</tt> does not define an OUTPUT rule for <tt>Bar</tt>.
</p>
-<H3><a name="Python_nn47"></a>32.7.2 Simple pointers</H3>
+<H3><a name="Python_nn47"></a>33.7.2 Simple pointers</H3>
<p>
@@ -3701,7 +3701,7 @@ If you replace <tt>%pointer_functions()</tt> by <tt>%pointer_class(type,name)</t
See the <a href="Library.html#Library">SWIG Library</a> chapter for further details.
</p>
-<H3><a name="Python_nn48"></a>32.7.3 Unbounded C Arrays</H3>
+<H3><a name="Python_nn48"></a>33.7.3 Unbounded C Arrays</H3>
<p>
@@ -3763,7 +3763,7 @@ well suited for applications in which you need to create buffers,
package binary data, etc.
</p>
-<H3><a name="Python_nn49"></a>32.7.4 String handling</H3>
+<H3><a name="Python_nn49"></a>33.7.4 String handling</H3>
<p>
@@ -3832,7 +3832,7 @@ If you need to return binary data, you might use the
also be used to extra binary data from arbitrary pointers.
</p>
-<H2><a name="Python_nn53"></a>32.8 Typemaps</H2>
+<H2><a name="Python_nn53"></a>33.8 Typemaps</H2>
<p>
@@ -3849,7 +3849,7 @@ Typemaps are only used if you want to change some aspect of the primitive
C-Python interface or if you want to elevate your guru status.
</p>
-<H3><a name="Python_nn54"></a>32.8.1 What is a typemap?</H3>
+<H3><a name="Python_nn54"></a>33.8.1 What is a typemap?</H3>
<p>
@@ -3965,7 +3965,7 @@ parameter is omitted):
</pre>
</div>
-<H3><a name="Python_nn55"></a>32.8.2 Python typemaps</H3>
+<H3><a name="Python_nn55"></a>33.8.2 Python typemaps</H3>
<p>
@@ -4006,7 +4006,7 @@ a look at the SWIG library version 1.3.20 or so.
</p>
-<H3><a name="Python_nn56"></a>32.8.3 Typemap variables</H3>
+<H3><a name="Python_nn56"></a>33.8.3 Typemap variables</H3>
<p>
@@ -4077,7 +4077,7 @@ properly assigned.
The Python name of the wrapper function being created.
</div>
-<H3><a name="Python_nn57"></a>32.8.4 Useful Python Functions</H3>
+<H3><a name="Python_nn57"></a>33.8.4 Useful Python Functions</H3>
<p>
@@ -4205,7 +4205,7 @@ write me
</pre>
</div>
-<H2><a name="Python_nn58"></a>32.9 Typemap Examples</H2>
+<H2><a name="Python_nn58"></a>33.9 Typemap Examples</H2>
<p>
@@ -4214,7 +4214,7 @@ might look at the files "<tt>python.swg</tt>" and "<tt>typemaps.i</tt>" in
the SWIG library.
</p>
-<H3><a name="Python_nn59"></a>32.9.1 Converting Python list to a char ** </H3>
+<H3><a name="Python_nn59"></a>33.9.1 Converting Python list to a char ** </H3>
<p>
@@ -4294,7 +4294,7 @@ memory allocation is used to allocate memory for the array, the
the C function.
</p>
-<H3><a name="Python_nn60"></a>32.9.2 Expanding a Python object into multiple arguments</H3>
+<H3><a name="Python_nn60"></a>33.9.2 Expanding a Python object into multiple arguments</H3>
<p>
@@ -4373,7 +4373,7 @@ to supply the argument count. This is automatically set by the typemap code. F
</pre>
</div>
-<H3><a name="Python_nn61"></a>32.9.3 Using typemaps to return arguments</H3>
+<H3><a name="Python_nn61"></a>33.9.3 Using typemaps to return arguments</H3>
<p>
@@ -4462,7 +4462,7 @@ function can now be used as follows:
&gt;&gt;&gt;
</pre></div>
-<H3><a name="Python_nn62"></a>32.9.4 Mapping Python tuples into small arrays</H3>
+<H3><a name="Python_nn62"></a>33.9.4 Mapping Python tuples into small arrays</H3>
<p>
@@ -4511,7 +4511,7 @@ array, such an approach would not be recommended for huge arrays, but
for small structures, this approach works fine.
</p>
-<H3><a name="Python_nn63"></a>32.9.5 Mapping sequences to C arrays</H3>
+<H3><a name="Python_nn63"></a>33.9.5 Mapping sequences to C arrays</H3>
<p>
@@ -4592,7 +4592,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) {
%}
%typemap(in) double [ANY](double temp[$1_dim0]) {
- if (!convert_darray($input,temp,$1_dim0))) {
+ if (!convert_darray($input,temp,$1_dim0)) {
return NULL;
}
$1 = &amp;temp[0];
@@ -4600,7 +4600,7 @@ static int convert_darray(PyObject *input, double *ptr, int size) {
</pre>
</div>
-<H3><a name="Python_nn64"></a>32.9.6 Pointer handling</H3>
+<H3><a name="Python_nn64"></a>33.9.6 Pointer handling</H3>
<p>
@@ -4697,7 +4697,7 @@ class object (if applicable).
-<H2><a name="Python_nn65"></a>32.10 Docstring Features</H2>
+<H2><a name="Python_nn65"></a>33.10 Docstring Features</H2>
<p>
@@ -4725,7 +4725,7 @@ of your users much simpler.
</p>
-<H3><a name="Python_nn66"></a>32.10.1 Module docstring</H3>
+<H3><a name="Python_nn66"></a>33.10.1 Module docstring</H3>
<p>
@@ -4759,7 +4759,7 @@ layout of controls on a panel, etc. to be loaded from an XML file."
</div>
-<H3><a name="Python_nn67"></a>32.10.2 %feature("autodoc")</H3>
+<H3><a name="Python_nn67"></a>33.10.2 %feature("autodoc")</H3>
<p>
@@ -4786,7 +4786,7 @@ names, default values if any, and return type if any. There are also
three options for autodoc controlled by the value given to the
feature, described below.
-<H4><a name="Python_nn68"></a>32.10.2.1 %feature("autodoc", "0")</H4>
+<H4><a name="Python_nn68"></a>33.10.2.1 %feature("autodoc", "0")</H4>
<p>
@@ -4815,7 +4815,7 @@ def function_name(*args, **kwargs):
</div>
-<H4><a name="Python_nn69"></a>32.10.2.2 %feature("autodoc", "1")</H4>
+<H4><a name="Python_nn69"></a>33.10.2.2 %feature("autodoc", "1")</H4>
<p>
@@ -4840,7 +4840,7 @@ def function_name(*args, **kwargs):
-<H4><a name="Python_nn70"></a>32.10.2.3 %feature("autodoc", "docstring")</H4>
+<H4><a name="Python_nn70"></a>33.10.2.3 %feature("autodoc", "docstring")</H4>
<p>
@@ -4859,7 +4859,7 @@ void GetPosition(int* OUTPUT, int* OUTPUT);
</div>
-<H3><a name="Python_nn71"></a>32.10.3 %feature("docstring")</H3>
+<H3><a name="Python_nn71"></a>33.10.3 %feature("docstring")</H3>
<p>
@@ -4891,7 +4891,7 @@ with more than one line.
</pre>
</div>
-<H2><a name="Python_nn72"></a>32.11 Python Packages</H2>
+<H2><a name="Python_nn72"></a>33.11 Python Packages</H2>
<p>
@@ -4918,7 +4918,7 @@ and also in base class declarations, etc. if the package name is
different than its own.
</p>
-<H2><a name="Python_python3support"></a>32.12 Python 3 Support</H2>
+<H2><a name="Python_python3support"></a>33.12 Python 3 Support</H2>
<p>
@@ -4945,7 +4945,7 @@ The following are Python 3.0 new features that are currently supported by
SWIG.
</p>
-<H3><a name="Python_nn74"></a>32.12.1 Function annotation</H3>
+<H3><a name="Python_nn74"></a>33.12.1 Function annotation</H3>
<p>
@@ -4977,7 +4977,7 @@ all overloaded functions share the same function in SWIG generated proxy class.
For detailed usage of function annotation, see PEP 3107.
</p>
-<H3><a name="Python_nn75"></a>32.12.2 Buffer interface</H3>
+<H3><a name="Python_nn75"></a>33.12.2 Buffer interface</H3>
<p>
@@ -5129,7 +5129,7 @@ modify the buffer.
</div>
-<H3><a name="Python_nn76"></a>32.12.3 Abstract base classes</H3>
+<H3><a name="Python_nn76"></a>33.12.3 Abstract base classes</H3>
<p>
diff --git a/Doc/Manual/R.html b/Doc/Manual/R.html
index ceea32146..e8cee6448 100644
--- a/Doc/Manual/R.html
+++ b/Doc/Manual/R.html
@@ -6,7 +6,7 @@
</head>
<body bgcolor="#ffffff">
-<H1><a name="R"></a>35 SWIG and R</H1>
+<H1><a name="R"></a>34 SWIG and R</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -33,7 +33,7 @@ compile and run an R interface to QuantLib running on Mandriva Linux
with gcc. The R bindings also work on Microsoft Windows using Visual C++.
</p>
-<H2><a name="R_nn2"></a>35.1 Bugs</H2>
+<H2><a name="R_nn2"></a>34.1 Bugs</H2>
<p>
@@ -45,7 +45,7 @@ Currently the following features are not implemented or broken:
<li>C Array wrappings
</ul>
-<H2><a name="R_nn3"></a>35.2 Using R and SWIG</H2>
+<H2><a name="R_nn3"></a>34.2 Using R and SWIG</H2>
<p>
@@ -119,7 +119,7 @@ Without it, inheritance of wrapped objects may fail.
These two files can be loaded in any order
</p>
-<H2><a name="R_nn4"></a>35.3 Precompiling large R files</H2>
+<H2><a name="R_nn4"></a>34.3 Precompiling large R files</H2>
In cases where the R file is large, one make save a lot of loading
@@ -137,7 +137,7 @@ will save a large amount of loading time.
-<H2><a name="R_nn5"></a>35.4 General policy</H2>
+<H2><a name="R_nn5"></a>34.4 General policy</H2>
<p>
@@ -146,7 +146,7 @@ wrapping over the underlying functions and rely on the R type system
to provide R syntax.
</p>
-<H2><a name="R_language_conventions"></a>35.5 Language conventions</H2>
+<H2><a name="R_language_conventions"></a>34.5 Language conventions</H2>
<p>
@@ -155,7 +155,7 @@ and [ are overloaded to allow for R syntax (one based indices and
slices)
</p>
-<H2><a name="R_nn6"></a>35.6 C++ classes</H2>
+<H2><a name="R_nn6"></a>34.6 C++ classes</H2>
<p>
@@ -167,7 +167,7 @@ keep track of the pointer object which removes the necessity for a lot
of the proxy class baggage you see in other languages.
</p>
-<H2><a name="R_nn7"></a>35.7 Enumerations</H2>
+<H2><a name="R_nn7"></a>34.7 Enumerations</H2>
<p>
diff --git a/Doc/Manual/Ruby.html b/Doc/Manual/Ruby.html
index b61ded8e5..f21e353ce 100644
--- a/Doc/Manual/Ruby.html
+++ b/Doc/Manual/Ruby.html
@@ -1,32 +1,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<title>SWIG and Ruby</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
+<body bgcolor="#ffffff">
-<body style="background-color: rgb(255, 255, 255);">
-
-
-
-
-
-<H1><a name="Ruby"></a>33 SWIG and Ruby</H1>
+<H1><a name="Ruby"></a>35 SWIG and Ruby</H1>
<!-- INDEX -->
<div class="sectiontoc">
<ul>
@@ -167,7 +148,7 @@
-<H2><a name="Ruby_nn2"></a>33.1 Preliminaries</H2>
+<H2><a name="Ruby_nn2"></a>35.1 Preliminaries</H2>
<p> SWIG 1.3 is known to work with Ruby versions 1.6 and later.
@@ -190,7 +171,7 @@ of Ruby. </p>
-<H3><a name="Ruby_nn3"></a>33.1.1 Running SWIG</H3>
+<H3><a name="Ruby_nn3"></a>35.1.1 Running SWIG</H3>
<p> To build a Ruby module, run SWIG using the <tt>-ruby</tt>
@@ -244,7 +225,7 @@ to compile this file and link it with the rest of your program. </p>
-<H3><a name="Ruby_nn4"></a>33.1.2 Getting the right header files</H3>
+<H3><a name="Ruby_nn4"></a>35.1.2 Getting the right header files</H3>
<p> In order to compile the wrapper code, the compiler needs the <tt>ruby.h</tt>
@@ -255,7 +236,9 @@ 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<br>/usr/local/lib/ruby/1.6/i686-linux/ruby.h<br></pre>
+<pre>/usr/lib/ruby/1.8/x86_64-linux-gnu/ruby.h
+/usr/local/lib/ruby/1.6/i686-linux/ruby.h
+</pre>
@@ -276,7 +259,10 @@ installed, you can run Ruby to find out. For example: </p>
<div class="code shell">
-<pre>$ <b>ruby -e 'puts $:.join("\n")'</b><br>/usr/local/lib/ruby/site_ruby/1.6 /usr/local/lib/ruby/site_ruby/1.6/i686-linux<br>/usr/local/lib/ruby/site_ruby /usr/local/lib/ruby/1.6 /usr/local/lib/ruby/1.6/i686-linux .<br> </pre>
+<pre>$ <b>ruby -e 'puts $:.join("\n")'</b>
+/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 .
+</pre>
@@ -288,7 +274,7 @@ installed, you can run Ruby to find out. For example: </p>
-<H3><a name="Ruby_nn5"></a>33.1.3 Compiling a dynamic module</H3>
+<H3><a name="Ruby_nn5"></a>35.1.3 Compiling a dynamic module</H3>
<p> Ruby extension modules are typically compiled into shared
@@ -324,16 +310,7 @@ looks like the following:</p>
<div class="code targetlang">
-
-
-
-
<pre>require 'mkmf'<br>create_makefile('example')<br></pre>
-
-
-
-
-
</div>
@@ -401,7 +378,12 @@ can add this: </p>
<div class="code targetlang">
-<pre>open("Makefile", "a") { |mf|<br> puts &lt;&lt;EOM<br> # Your make rules go here<br> EOM<br>}<br></pre>
+<pre>open("Makefile", "a") { |mf|
+ puts &lt;&lt;EOM
+ # Your make rules go here
+ EOM
+}
+</pre>
@@ -424,7 +406,10 @@ operating system would look something like this: </p>
<div class="code shell">
-<pre>$ <b>swig -ruby example.i</b><br>$ <b>gcc -c example.c</b><br>$ <b>gcc -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux</b> <br>$ <b>gcc -shared example.o example_wrap.o -o example.so</b>
+<pre>$ <b>swig -ruby example.i</b>
+$ <b>gcc -c example.c</b>
+$ <b>gcc -c example_wrap.c -I/usr/local/lib/ruby/1.6/i686-linux</b>
+$ <b>gcc -shared example.o example_wrap.o -o example.so</b>
</pre>
@@ -443,7 +428,7 @@ manual pages for your compiler and linker to determine the correct set
of options. You might also check the <a href="http://www.dabeaz.com/cgi-bin/wiki.pl">SWIG Wiki</a>
for additional information. </p>
-<H3><a name="Ruby_nn6"></a>33.1.4 Using your module</H3>
+<H3><a name="Ruby_nn6"></a>35.1.4 Using your module</H3>
<p> Ruby <i>module</i> names must be capitalized,
@@ -456,7 +441,12 @@ module is imported by requiring the <b>etc</b> feature: </p>
<div class="code targetlang">
-<pre># The feature name begins with a lowercase letter...<br>require 'etc'<br><br># ... but the module name begins with an uppercase letter<br>puts "Your login name: #{Etc.getlogin}"<br></pre>
+<pre># The feature name begins with a lowercase letter...
+require 'etc'
+
+# ... but the module name begins with an uppercase letter
+puts "Your login name: #{Etc.getlogin}"
+</pre>
@@ -498,7 +488,7 @@ begins with: </p>
-<H3><a name="Ruby_nn7"></a>33.1.5 Static linking</H3>
+<H3><a name="Ruby_nn7"></a>35.1.5 Static linking</H3>
<p> An alternative approach to dynamic linking is to rebuild the
@@ -519,7 +509,7 @@ finally rebuilding Ruby. </p>
-<H3><a name="Ruby_nn8"></a>33.1.6 Compilation of C++ extensions</H3>
+<H3><a name="Ruby_nn8"></a>35.1.6 Compilation of C++ extensions</H3>
<p> On most machines, C++ extension modules should be linked
@@ -571,7 +561,7 @@ extension, e.g. </p>
-<H2><a name="Ruby_nn9"></a>33.2 Building Ruby Extensions under Windows 95/NT</H2>
+<H2><a name="Ruby_nn9"></a>35.2 Building Ruby Extensions under Windows 95/NT</H2>
<p> Building a SWIG extension to Ruby under Windows 95/NT is
@@ -610,7 +600,7 @@ files. </p>
-<H3><a name="Ruby_nn10"></a>33.2.1 Running SWIG from Developer Studio</H3>
+<H3><a name="Ruby_nn10"></a>35.2.1 Running SWIG from Developer Studio</H3>
<p> If you are developing your application within Microsoft
@@ -752,7 +742,7 @@ directory, then run the Ruby script from the DOS/Command prompt: </p>
-<H2><a name="Ruby_nn11"></a>33.3 The Ruby-to-C/C++ Mapping</H2>
+<H2><a name="Ruby_nn11"></a>35.3 The Ruby-to-C/C++ Mapping</H2>
<p> This section describes the basics of how SWIG maps C or C++
@@ -762,7 +752,7 @@ declarations in your SWIG interface files to Ruby constructs. </p>
-<H3><a name="Ruby_nn12"></a>33.3.1 Modules</H3>
+<H3><a name="Ruby_nn12"></a>35.3.1 Modules</H3>
<p> The SWIG <tt>%module</tt> directive specifies
@@ -931,7 +921,7 @@ Ruby's built-in names. </p>
-<H3><a name="Ruby_nn13"></a>33.3.2 Functions</H3>
+<H3><a name="Ruby_nn13"></a>35.3.2 Functions</H3>
<p> Global functions are wrapped as Ruby module methods. For
@@ -994,7 +984,7 @@ module that can be used like so: </p>
-<H3><a name="Ruby_nn14"></a>33.3.3 Variable Linking</H3>
+<H3><a name="Ruby_nn14"></a>35.3.3 Variable Linking</H3>
<p> C/C++ global variables are wrapped as a pair of singleton
@@ -1094,7 +1084,7 @@ effect until it is explicitly disabled using <tt>%mutable</tt>.
-<H3><a name="Ruby_nn15"></a>33.3.4 Constants</H3>
+<H3><a name="Ruby_nn15"></a>35.3.4 Constants</H3>
<p> C/C++ constants are wrapped as module constants initialized
@@ -1138,7 +1128,7 @@ constant values, e.g. </p>
-<H3><a name="Ruby_nn16"></a>33.3.5 Pointers</H3>
+<H3><a name="Ruby_nn16"></a>35.3.5 Pointers</H3>
<p> "Opaque" pointers to arbitrary C/C++ types (i.e. types that
@@ -1190,7 +1180,7 @@ the Ruby <tt>nil</tt> object. </p>
-<H3><a name="Ruby_nn17"></a>33.3.6 Structures</H3>
+<H3><a name="Ruby_nn17"></a>35.3.6 Structures</H3>
<p> C/C++ structs are wrapped as Ruby classes, with accessor
@@ -1365,7 +1355,7 @@ pointers. For example, </p>
-<H3><a name="Ruby_nn18"></a>33.3.7 C++ classes</H3>
+<H3><a name="Ruby_nn18"></a>35.3.7 C++ classes</H3>
<p> Like structs, C++ classes are wrapped by creating a new Ruby
@@ -1451,7 +1441,7 @@ class. </li>
-<H3><a name="Ruby_nn19"></a>33.3.8 C++ Inheritance</H3>
+<H3><a name="Ruby_nn19"></a>35.3.8 C++ Inheritance</H3>
<p> The SWIG type-checker is fully aware of C++ inheritance.
@@ -1682,7 +1672,7 @@ Typing"</a>). </p>
-<H3><a name="Ruby_nn20"></a>33.3.9 C++ Overloaded Functions</H3>
+<H3><a name="Ruby_nn20"></a>35.3.9 C++ Overloaded Functions</H3>
<p> C++ overloaded functions, methods, and constructors are
@@ -1882,7 +1872,7 @@ and C++"</a> chapter for more information about overloading. </p>
-<H3><a name="Ruby_nn21"></a>33.3.10 C++ Operators</H3>
+<H3><a name="Ruby_nn21"></a>35.3.10 C++ Operators</H3>
<p> For the most part, overloaded operators are handled
@@ -1963,7 +1953,7 @@ on operator overloading</a>. </p>
-<H3><a name="Ruby_nn22"></a>33.3.11 C++ namespaces</H3>
+<H3><a name="Ruby_nn22"></a>35.3.11 C++ namespaces</H3>
<p> SWIG is aware of C++ namespaces, but namespace names do not
@@ -2039,7 +2029,7 @@ identical symbol names, well, then you get what you deserve. </p>
-<H3><a name="Ruby_nn23"></a>33.3.12 C++ templates</H3>
+<H3><a name="Ruby_nn23"></a>35.3.12 C++ templates</H3>
<p> C++ templates don't present a huge problem for SWIG. However,
@@ -2083,7 +2073,7 @@ directive. For example: </p>
-<H3><a name="Ruby_nn23_1"></a>33.3.13 C++ Standard Template Library (STL)</H3>
+<H3><a name="Ruby_nn23_1"></a>35.3.13 C++ Standard Template Library (STL)</H3>
<p> On a related note, the standard SWIG library contains a
@@ -2336,7 +2326,7 @@ chapter.</p>
-<H3><a name="Ruby_C_STL_Functors"></a>33.3.14 C++ STL Functors</H3>
+<H3><a name="Ruby_C_STL_Functors"></a>35.3.14 C++ STL Functors</H3>
<p>Some containers in the STL allow you to modify their default
@@ -2536,7 +2526,7 @@ b<br style="font-weight: bold;">
-<H3><a name="Ruby_C_Iterators"></a>33.3.15 C++ STL Iterators</H3>
+<H3><a name="Ruby_C_Iterators"></a>35.3.15 C++ STL Iterators</H3>
<p>The STL is well known for the use of iterators. &nbsp;There
@@ -2733,7 +2723,7 @@ i<br>
-<span style="font-weight: bold;">&gt;&gt; [3, 4, 5 ]</span></div>
+<b>&gt;&gt; [3, 4, 5 ]</b></div>
@@ -2747,7 +2737,7 @@ i<br>
-<H3><a name="Ruby_nn24"></a>33.3.16 C++ Smart Pointers</H3>
+<H3><a name="Ruby_nn24"></a>35.3.16 C++ Smart Pointers</H3>
<p> In certain C++ programs, it is common to use classes that
@@ -2872,7 +2862,7 @@ method. For example: </p>
-<H3><a name="Ruby_nn25"></a>33.3.17 Cross-Language Polymorphism</H3>
+<H3><a name="Ruby_nn25"></a>35.3.17 Cross-Language Polymorphism</H3>
<p> SWIG's Ruby module supports cross-language polymorphism
@@ -2885,7 +2875,7 @@ using this feature with Ruby. </p>
-<H4><a name="Ruby_nn26"></a>33.3.17.1 Exception Unrolling</H4>
+<H4><a name="Ruby_nn26"></a>35.3.17.1 Exception Unrolling</H4>
<p> Whenever a C++ director class routes one of its virtual
@@ -2923,7 +2913,7 @@ caught here and a C++ exception is raised in its place. </p>
-<H2><a name="Ruby_nn27"></a>33.4 Naming</H2>
+<H2><a name="Ruby_nn27"></a>35.4 Naming</H2>
<p>Ruby has several common naming conventions. Constants are
@@ -3019,7 +3009,7 @@ planned to become the default option in future releases.</p>
-<H3><a name="Ruby_nn28"></a>33.4.1 Defining Aliases</H3>
+<H3><a name="Ruby_nn28"></a>35.4.1 Defining Aliases</H3>
<p> It's a fairly common practice in the Ruby built-ins and
@@ -3111,7 +3101,7 @@ Features"</a>) for more details).</p>
-<H3><a name="Ruby_nn29"></a>33.4.2 Predicate Methods</H3>
+<H3><a name="Ruby_nn29"></a>35.4.2 Predicate Methods</H3>
<p> Ruby methods that return a boolean value and end in a
@@ -3200,7 +3190,7 @@ Features"</a>) for more details). </p>
-<H3><a name="Ruby_nn30"></a>33.4.3 Bang Methods</H3>
+<H3><a name="Ruby_nn30"></a>35.4.3 Bang Methods</H3>
<p> Ruby methods that modify an object in-place and end in an
@@ -3264,7 +3254,7 @@ Features"</a>) for more details). </p>
-<H3><a name="Ruby_nn31"></a>33.4.4 Getters and Setters</H3>
+<H3><a name="Ruby_nn31"></a>35.4.4 Getters and Setters</H3>
<p> Often times a C++ library will expose properties through
@@ -3334,7 +3324,7 @@ methods to be exposed in Ruby as <tt>value</tt> and <tt>value=.
-<H2><a name="Ruby_nn32"></a>33.5 Input and output parameters</H2>
+<H2><a name="Ruby_nn32"></a>35.5 Input and output parameters</H2>
<p> A common problem in some C programs is handling parameters
@@ -3585,10 +3575,10 @@ of <tt>%apply</tt> </p>
-<H2><a name="Ruby_nn33"></a>33.6 Exception handling </H2>
+<H2><a name="Ruby_nn33"></a>35.6 Exception handling </H2>
-<H3><a name="Ruby_nn34"></a>33.6.1 Using the %exception directive </H3>
+<H3><a name="Ruby_nn34"></a>35.6.1 Using the %exception directive </H3>
<p>The SWIG <tt>%exception</tt> directive can be
@@ -3683,7 +3673,7 @@ Features</a> for more examples.</p>
-<H3><a name="Ruby_nn34_2"></a>33.6.2 Handling Ruby Blocks </H3>
+<H3><a name="Ruby_nn34_2"></a>35.6.2 Handling Ruby Blocks </H3>
<p>One of the highlights of Ruby and most of its standard library
@@ -3864,7 +3854,7 @@ RUBY_YIELD_SELF );<br>
<p>For more information on typemaps, see <a href="#Ruby_nn37">Typemaps</a>.</p>
-<H3><a name="Ruby_nn35"></a>33.6.3 Raising exceptions </H3>
+<H3><a name="Ruby_nn35"></a>35.6.3 Raising exceptions </H3>
<p>There are three ways to raise exceptions from C++ code to
@@ -4625,7 +4615,7 @@ the built-in Ruby exception types.</p>
-<H3><a name="Ruby_nn36"></a>33.6.4 Exception classes </H3>
+<H3><a name="Ruby_nn36"></a>35.6.4 Exception classes </H3>
<p>Starting with SWIG 1.3.28, the Ruby module supports the <tt>%exceptionclass</tt>
@@ -4683,7 +4673,7 @@ providing for a more natural integration between C++ code and Ruby code.</p>
-<H2><a name="Ruby_nn37"></a>33.7 Typemaps</H2>
+<H2><a name="Ruby_nn37"></a>35.7 Typemaps</H2>
<p> This section describes how you can modify SWIG's default
@@ -4706,7 +4696,7 @@ of the primitive C-Ruby interface.</p>
-<H3><a name="Ruby_nn38"></a>33.7.1 What is a typemap?</H3>
+<H3><a name="Ruby_nn38"></a>35.7.1 What is a typemap?</H3>
<p> A typemap is nothing more than a code generation rule that is
@@ -4968,7 +4958,7 @@ to be used as follows (notice how the length parameter is omitted): </p>
-<H3><a name="Ruby_Typemap_scope"></a>33.7.2 Typemap scope</H3>
+<H3><a name="Ruby_Typemap_scope"></a>35.7.2 Typemap scope</H3>
<p> Once defined, a typemap remains in effect for all of the
@@ -5016,7 +5006,7 @@ where the class itself is defined. For example:</p>
-<H3><a name="Ruby_Copying_a_typemap"></a>33.7.3 Copying a typemap</H3>
+<H3><a name="Ruby_Copying_a_typemap"></a>35.7.3 Copying a typemap</H3>
<p> A typemap is copied by using assignment. For example:</p>
@@ -5118,7 +5108,7 @@ rules as for <tt>
-<H3><a name="Ruby_Deleting_a_typemap"></a>33.7.4 Deleting a typemap</H3>
+<H3><a name="Ruby_Deleting_a_typemap"></a>35.7.4 Deleting a typemap</H3>
<p> A typemap can be deleted by simply defining no code. For
@@ -5170,7 +5160,7 @@ typemaps immediately after the clear operation.</p>
-<H3><a name="Ruby_Placement_of_typemaps"></a>33.7.5 Placement of typemaps</H3>
+<H3><a name="Ruby_Placement_of_typemaps"></a>35.7.5 Placement of typemaps</H3>
<p> Typemap declarations can be declared in the global scope,
@@ -5254,7 +5244,7 @@ string</tt>
-<H3><a name="Ruby_nn39"></a>33.7.6 Ruby typemaps</H3>
+<H3><a name="Ruby_nn39"></a>35.7.6 Ruby typemaps</H3>
<p>The following list details all of the typemap methods that
@@ -5264,7 +5254,7 @@ can be used by the Ruby module: </p>
-<H4><a name="Ruby_in_typemap"></a>33.7.6.1 &nbsp;"in" typemap</H4>
+<H4><a name="Ruby_in_typemap"></a>35.7.6.1 &nbsp;"in" typemap</H4>
<p>Converts Ruby objects to input
@@ -5507,7 +5497,7 @@ arguments to be specified. For example:</p>
-<H4><a name="Ruby_typecheck_typemap"></a>33.7.6.2 "typecheck" typemap</H4>
+<H4><a name="Ruby_typecheck_typemap"></a>35.7.6.2 "typecheck" typemap</H4>
<p> The "typecheck" typemap is used to support overloaded
@@ -5548,7 +5538,7 @@ on "Typemaps and Overloading."</p>
-<H4><a name="Ruby_out_typemap"></a>33.7.6.3 &nbsp;"out" typemap</H4>
+<H4><a name="Ruby_out_typemap"></a>35.7.6.3 &nbsp;"out" typemap</H4>
<p>Converts return value of a C function
@@ -5780,7 +5770,7 @@ version of the C datatype matched by the typemap.</td>
-<H4><a name="Ruby_arginit_typemap"></a>33.7.6.4 "arginit" typemap</H4>
+<H4><a name="Ruby_arginit_typemap"></a>35.7.6.4 "arginit" typemap</H4>
<p> The "arginit" typemap is used to set the initial value of a
@@ -5805,7 +5795,7 @@ applications. For example:</p>
-<H4><a name="Ruby_default_typemap"></a>33.7.6.5 "default" typemap</H4>
+<H4><a name="Ruby_default_typemap"></a>35.7.6.5 "default" typemap</H4>
<p> The "default" typemap is used to turn an argument into a
@@ -5847,7 +5837,7 @@ default argument wrapping.</p>
-<H4><a name="Ruby_check_typemap"></a>33.7.6.6 "check" typemap</H4>
+<H4><a name="Ruby_check_typemap"></a>35.7.6.6 "check" typemap</H4>
<p> The "check" typemap is used to supply value checking code
@@ -5871,7 +5861,7 @@ arguments have been converted. For example:</p>
-<H4><a name="Ruby_argout_typemap_"></a>33.7.6.7 "argout" typemap</H4>
+<H4><a name="Ruby_argout_typemap_"></a>35.7.6.7 "argout" typemap</H4>
<p> The "argout" typemap is used to return values from arguments.
@@ -6029,7 +6019,7 @@ some function like SWIG_Ruby_AppendOutput.</p>
-<H4><a name="Ruby_freearg_typemap_"></a>33.7.6.8 "freearg" typemap</H4>
+<H4><a name="Ruby_freearg_typemap_"></a>35.7.6.8 "freearg" typemap</H4>
<p> The "freearg" typemap is used to cleanup argument data. It is
@@ -6065,7 +6055,7 @@ abort prematurely.</p>
-<H4><a name="Ruby_newfree_typemap"></a>33.7.6.9 "newfree" typemap</H4>
+<H4><a name="Ruby_newfree_typemap"></a>35.7.6.9 "newfree" typemap</H4>
<p> The "newfree" typemap is used in conjunction with the <tt>%newobject</tt>
@@ -6096,7 +6086,7 @@ ownership and %newobject</a> for further details.</p>
-<H4><a name="Ruby_memberin_typemap"></a>33.7.6.10 "memberin" typemap</H4>
+<H4><a name="Ruby_memberin_typemap"></a>35.7.6.10 "memberin" typemap</H4>
<p> The "memberin" typemap is used to copy data from<em> an
@@ -6129,7 +6119,7 @@ other objects.</p>
-<H4><a name="Ruby_varin_typemap"></a>33.7.6.11 "varin" typemap</H4>
+<H4><a name="Ruby_varin_typemap"></a>35.7.6.11 "varin" typemap</H4>
<p> The "varin" typemap is used to convert objects in the target
@@ -6140,7 +6130,7 @@ This is implementation specific.</p>
-<H4><a name="Ruby_varout_typemap_"></a>33.7.6.12 "varout" typemap</H4>
+<H4><a name="Ruby_varout_typemap_"></a>35.7.6.12 "varout" typemap</H4>
<p> The "varout" typemap is used to convert a C/C++ object to an
@@ -6151,7 +6141,7 @@ This is implementation specific.</p>
-<H4><a name="Ruby_throws_typemap"></a>33.7.6.13 "throws" typemap</H4>
+<H4><a name="Ruby_throws_typemap"></a>35.7.6.13 "throws" typemap</H4>
<p> The "throws" typemap is only used when SWIG parses a C++
@@ -6210,7 +6200,7 @@ handling with %exception</a> section.</p>
-<H4><a name="Ruby_directorin_typemap"></a>33.7.6.14 directorin typemap</H4>
+<H4><a name="Ruby_directorin_typemap"></a>35.7.6.14 directorin typemap</H4>
<p>Converts C++ objects in director
@@ -6464,7 +6454,7 @@ referring to the class itself.</td>
-<H4><a name="Ruby_directorout_typemap"></a>33.7.6.15 directorout typemap</H4>
+<H4><a name="Ruby_directorout_typemap"></a>35.7.6.15 directorout typemap</H4>
<p>Converts Ruby objects in director
@@ -6724,7 +6714,7 @@ exception.<br>
-<H4><a name="Ruby_directorargout_typemap"></a>33.7.6.16 directorargout typemap</H4>
+<H4><a name="Ruby_directorargout_typemap"></a>35.7.6.16 directorargout typemap</H4>
<p>Output argument processing in director
@@ -6964,7 +6954,7 @@ referring to the instance of the class itself</td>
-<H4><a name="Ruby_ret_typemap"></a>33.7.6.17 ret typemap</H4>
+<H4><a name="Ruby_ret_typemap"></a>35.7.6.17 ret typemap</H4>
<p>Cleanup of function return values
@@ -6974,7 +6964,7 @@ referring to the instance of the class itself</td>
-<H4><a name="Ruby_globalin_typemap"></a>33.7.6.18 globalin typemap</H4>
+<H4><a name="Ruby_globalin_typemap"></a>35.7.6.18 globalin typemap</H4>
<p>Setting of C global variables
@@ -6984,7 +6974,7 @@ referring to the instance of the class itself</td>
-<H3><a name="Ruby_nn40"></a>33.7.7 Typemap variables</H3>
+<H3><a name="Ruby_nn40"></a>35.7.7 Typemap variables</H3>
<p>
@@ -7094,7 +7084,7 @@ being created. </div>
-<H3><a name="Ruby_nn41"></a>33.7.8 Useful Functions</H3>
+<H3><a name="Ruby_nn41"></a>35.7.8 Useful Functions</H3>
<p> When you write a typemap, you usually have to work directly
@@ -7118,7 +7108,7 @@ across multiple languages.</p>
-<H4><a name="Ruby_nn42"></a>33.7.8.1 C Datatypes to Ruby Objects</H4>
+<H4><a name="Ruby_nn42"></a>35.7.8.1 C Datatypes to Ruby Objects</H4>
<div class="diagram">
@@ -7174,7 +7164,7 @@ SWIG_From_float(float)</td>
-<H4><a name="Ruby_nn43"></a>33.7.8.2 Ruby Objects to C Datatypes</H4>
+<H4><a name="Ruby_nn43"></a>35.7.8.2 Ruby Objects to C Datatypes</H4>
<p>Here, while the Ruby versions return the value directly, the SWIG
@@ -7263,7 +7253,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input
-<H4><a name="Ruby_nn44"></a>33.7.8.3 Macros for VALUE</H4>
+<H4><a name="Ruby_nn44"></a>35.7.8.3 Macros for VALUE</H4>
<p> <tt>RSTRING_LEN(str)</tt> </p>
@@ -7326,7 +7316,7 @@ Ruby_Format_TypeError( "$1_name", "$1_type","$symname", $argnum, $input
-<H4><a name="Ruby_nn45"></a>33.7.8.4 Exceptions</H4>
+<H4><a name="Ruby_nn45"></a>35.7.8.4 Exceptions</H4>
<p> <tt>void rb_raise(VALUE exception, const char *fmt,
@@ -7493,7 +7483,7 @@ arguments are interpreted as with <tt>printf()</tt>. </div>
-<H4><a name="Ruby_nn46"></a>33.7.8.5 Iterators</H4>
+<H4><a name="Ruby_nn46"></a>35.7.8.5 Iterators</H4>
<p> <tt>void rb_iter_break()</tt> </p>
@@ -7595,7 +7585,7 @@ VALUE), VALUE value)</tt></p>
-<H3><a name="Ruby_nn47"></a>33.7.9 Typemap Examples</H3>
+<H3><a name="Ruby_nn47"></a>35.7.9 Typemap Examples</H3>
<p> This section includes a few examples of typemaps. For more
@@ -7606,7 +7596,7 @@ directory. </p>
-<H3><a name="Ruby_nn48"></a>33.7.10 Converting a Ruby array to a char **</H3>
+<H3><a name="Ruby_nn48"></a>35.7.10 Converting a Ruby array to a char **</H3>
<p> A common problem in many C programs is the processing of
@@ -7661,7 +7651,7 @@ after the execution of the C function. </p>
-<H3><a name="Ruby_nn49"></a>33.7.11 Collecting arguments in a hash</H3>
+<H3><a name="Ruby_nn49"></a>35.7.11 Collecting arguments in a hash</H3>
<p> Ruby's solution to the "keyword arguments" capability of some
@@ -7940,7 +7930,7 @@ directory of the SWIG distribution. </p>
-<H3><a name="Ruby_nn50"></a>33.7.12 Pointer handling</H3>
+<H3><a name="Ruby_nn50"></a>35.7.12 Pointer handling</H3>
<p> Occasionally, it might be necessary to convert pointer values
@@ -8039,7 +8029,7 @@ For example: </p>
-<H4><a name="Ruby_nn51"></a>33.7.12.1 Ruby Datatype Wrapping</H4>
+<H4><a name="Ruby_nn51"></a>35.7.12.1 Ruby Datatype Wrapping</H4>
<p> <tt>VALUE Data_Wrap_Struct(VALUE class, void
@@ -8090,7 +8080,7 @@ and assigns that pointer to <i>ptr</i>. </div>
-<H3><a name="Ruby_nn52"></a>33.7.13 Example: STL Vector to Ruby Array</H3>
+<H3><a name="Ruby_nn52"></a>35.7.13 Example: STL Vector to Ruby Array</H3>
<p>Another use for macros and type maps is to create a Ruby array
@@ -8199,7 +8189,7 @@ the<a href="#Ruby_nn23_1"> C++ Standard Template Library</a>.<br>
-<H2><a name="Ruby_nn65"></a>33.8 Docstring Features</H2>
+<H2><a name="Ruby_nn65"></a>35.8 Docstring Features</H2>
<p>
@@ -8260,7 +8250,7 @@ generate ri documentation from a c wrap file, you could do:</p>
-<H3><a name="Ruby_nn66"></a>33.8.1 Module docstring</H3>
+<H3><a name="Ruby_nn66"></a>35.8.1 Module docstring</H3>
<p>
@@ -8311,7 +8301,7 @@ macro. For example:
-<H3><a name="Ruby_nn67"></a>33.8.2 %feature("autodoc")</H3>
+<H3><a name="Ruby_nn67"></a>35.8.2 %feature("autodoc")</H3>
<p>Since SWIG does know everything about the function it wraps,
@@ -8340,7 +8330,7 @@ feature, described below.
-<H4><a name="Ruby_nn68"></a>33.8.2.1 %feature("autodoc", "0")</H4>
+<H4><a name="Ruby_nn68"></a>35.8.2.1 %feature("autodoc", "0")</H4>
<p>
@@ -8388,7 +8378,7 @@ Then Ruby code like this will be generated:
-<H4><a name="Ruby_autodoc1"></a>33.8.2.2 %feature("autodoc", "1")</H4>
+<H4><a name="Ruby_autodoc1"></a>35.8.2.2 %feature("autodoc", "1")</H4>
<p>
@@ -8420,7 +8410,7 @@ this:
-<H4><a name="Ruby_autodoc2"></a>33.8.2.3 %feature("autodoc", "2")</H4>
+<H4><a name="Ruby_autodoc2"></a>35.8.2.3 %feature("autodoc", "2")</H4>
<p>
@@ -8436,7 +8426,7 @@ this:
-<H4><a name="Ruby_feature_autodoc3"></a>33.8.2.4 %feature("autodoc", "3")</H4>
+<H4><a name="Ruby_feature_autodoc3"></a>35.8.2.4 %feature("autodoc", "3")</H4>
<p>
@@ -8464,7 +8454,7 @@ this:
-<H4><a name="Ruby_nn70"></a>33.8.2.5 %feature("autodoc", "docstring")</H4>
+<H4><a name="Ruby_nn70"></a>35.8.2.5 %feature("autodoc", "docstring")</H4>
<p>
@@ -8492,7 +8482,7 @@ generated string. For example:
-<H3><a name="Ruby_nn71"></a>33.8.3 %feature("docstring")</H3>
+<H3><a name="Ruby_nn71"></a>35.8.3 %feature("docstring")</H3>
<p>
@@ -8507,10 +8497,10 @@ docstring and they are output together. </p>
-<H2><a name="Ruby_nn53"></a>33.9 Advanced Topics</H2>
+<H2><a name="Ruby_nn53"></a>35.9 Advanced Topics</H2>
-<H3><a name="Ruby_operator_overloading"></a>33.9.1 Operator overloading</H3>
+<H3><a name="Ruby_operator_overloading"></a>35.9.1 Operator overloading</H3>
<p> SWIG allows operator overloading with, by using the <tt>%extend</tt>
@@ -9527,7 +9517,7 @@ parses the expression <i>a != b</i> as <i>!(a == b)</i>.
-<H3><a name="Ruby_nn55"></a>33.9.2 Creating Multi-Module Packages</H3>
+<H3><a name="Ruby_nn55"></a>35.9.2 Creating Multi-Module Packages</H3>
<p> The chapter on <a href="Modules.html#Modules">Working
@@ -9708,7 +9698,7 @@ initialized: </p>
-<H3><a name="Ruby_nn56"></a>33.9.3 Specifying Mixin Modules</H3>
+<H3><a name="Ruby_nn56"></a>35.9.3 Specifying Mixin Modules</H3>
<p> The Ruby language doesn't support multiple inheritance, but
@@ -9806,7 +9796,7 @@ Features"</a>) for more details). </p>
-<H2><a name="Ruby_nn57"></a>33.10 Memory Management</H2>
+<H2><a name="Ruby_nn57"></a>35.10 Memory Management</H2>
<p>One of the most common issues in generating SWIG bindings for
@@ -9853,7 +9843,7 @@ understanding of how the underlying library manages memory.</p>
-<H3><a name="Ruby_nn58"></a>33.10.1 Mark and Sweep Garbage Collector </H3>
+<H3><a name="Ruby_nn58"></a>35.10.1 Mark and Sweep Garbage Collector </H3>
<p>Ruby uses a mark and sweep garbage collector. When the garbage
@@ -9901,7 +9891,7 @@ this memory. </p>
-<H3><a name="Ruby_nn59"></a>33.10.2 Object Ownership</H3>
+<H3><a name="Ruby_nn59"></a>35.10.2 Object Ownership</H3>
<p>As described above, memory management depends on clearly
@@ -10098,7 +10088,38 @@ classes is:</p>
<div class="code">
-<pre>/* File RubyOwnershipExample.i */<br><br>%module RubyOwnershipExample<br><br>%{<br>#include "RubyOwnershipExample.h"<br>%}<br><br>class Foo<br>{<br>public:<br> Foo();<br> ~Foo();<br>};<br><br>class Bar<br>{<br> Foo *foo_;<br>public:<br> Bar();<br> ~Bar();<br> Foo* get_foo();<br><br><span style="font-weight: bold;"> %newobject get_new_foo;</span><br> Foo* get_new_foo();<br><br><span style="font-weight: bold;"> %apply SWIGTYPE *DISOWN {Foo *foo};</span><br> void set_foo(Foo *foo);<br><span style="font-weight: bold;"> %clear Foo *foo;</span><br>};<br><br></pre>
+<pre>/* File RubyOwnershipExample.i */
+
+%module RubyOwnershipExample
+
+%{
+#include "RubyOwnershipExample.h"
+%}
+
+class Foo
+{
+public:
+ Foo();
+ ~Foo();
+};
+
+class Bar
+{
+ Foo *foo_;
+public:
+ Bar();
+ ~Bar();
+ Foo* get_foo();
+
+<b> %newobject get_new_foo;</b>
+ Foo* get_new_foo();
+
+<b> %apply SWIGTYPE *DISOWN {Foo *foo};</b>
+ void set_foo(Foo *foo);
+<b> %clear Foo *foo;</b>
+};
+
+</pre>
@@ -10128,7 +10149,7 @@ classes is:</p>
-<H3><a name="Ruby_nn60"></a>33.10.3 Object Tracking</H3>
+<H3><a name="Ruby_nn60"></a>35.10.3 Object Tracking</H3>
<p>The remaining parts of this section will use the class library
@@ -10165,7 +10186,35 @@ class library models a zoo and the animals it contains. </p>
<div class="code targetlang">
-<pre>$ <span style="font-weight: bold;">irb</span><br>irb(main):001:0&gt; <span style="font-weight: bold;">require 'example'</span><br>=&gt; true<br><br>irb(main):002:0&gt; <span style="font-weight: bold;">tiger1 = Example::Animal.new("tiger1")</span><br>=&gt; #&lt;Example::Animal:0x2be3820&gt;<br><br>irb(main):004:0&gt; <span style="font-weight: bold;">tiger1.get_name()</span><br>=&gt; "tiger1"<br><br>irb(main):003:0&gt; <span style="font-weight: bold;">zoo = Example::Zoo.new()</span><br>=&gt; #&lt;Example::Zoo:0x2be0a60&gt;<br><br>irb(main):006:0&gt; <span style="font-weight: bold;">zoo.add_animal(tiger)</span><br>=&gt; nil<br><br>irb(main):007:0&gt; <span style="font-weight: bold;">zoo.get_num_animals()</span><br>=&gt; 1<br><br>irb(main):007:0&gt; <span style="font-weight: bold;">tiger2 = zoo.remove_animal(0)</span><br>=&gt; #&lt;Example::Animal:0x2bd4a18&gt;<br><br>irb(main):008:0&gt; <span style="font-weight: bold;">tiger2.get_name()</span><br>=&gt; "tiger1"<br><br>irb(main):009:0&gt; <span style="font-weight: bold;">tiger1.equal?(tiger2)</span><br>=&gt; false<br><br></pre>
+<pre>$ <b>irb</b>
+irb(main):001:0&gt; <b>require 'example'</b>
+=&gt; true
+
+irb(main):002:0&gt; <b>tiger1 = Example::Animal.new("tiger1")</b>
+=&gt; #&lt;Example::Animal:0x2be3820&gt;
+
+irb(main):004:0&gt; <b>tiger1.get_name()</b>
+=&gt; "tiger1"
+
+irb(main):003:0&gt; <b>zoo = Example::Zoo.new()</b>
+=&gt; #&lt;Example::Zoo:0x2be0a60&gt;
+
+irb(main):006:0&gt; <b>zoo.add_animal(tiger)</b>
+=&gt; nil
+
+irb(main):007:0&gt; <b>zoo.get_num_animals()</b>
+=&gt; 1
+
+irb(main):007:0&gt; <b>tiger2 = zoo.remove_animal(0)</b>
+=&gt; #&lt;Example::Animal:0x2bd4a18&gt;
+
+irb(main):008:0&gt; <b>tiger2.get_name()</b>
+=&gt; "tiger1"
+
+irb(main):009:0&gt; <b>tiger1.equal?(tiger2)</b>
+=&gt; false
+
+</pre>
@@ -10192,7 +10241,16 @@ the same underlying C++ object. This can cause problems. For example:<br>
<div class="code targetlang">
-<pre>irb(main):010:0&gt; <span style="font-weight: bold;">tiger1 = nil</span><br>=&gt; nil<br><br>irb(main):011:0&gt; <span style="font-weight: bold;">GC.start</span><br>=&gt; nil<br><br>irb(main):012:0&gt; <span style="font-weight: bold;">tiger2.get_name()</span><br>(irb):12: [BUG] Segmentation fault<br><br></pre>
+<pre>irb(main):010:0&gt; <b>tiger1 = nil</b>
+=&gt; nil
+
+irb(main):011:0&gt; <b>GC.start</b>
+=&gt; nil
+
+irb(main):012:0&gt; <b>tiger2.get_name()</b>
+(irb):12: [BUG] Segmentation fault
+
+</pre>
@@ -10251,7 +10309,7 @@ class-by-class basis if needed. To fix the example above:</p>
<div class="code">
-<pre>%module example<br><br>%{<br>#include "example.h"<br>%}<br><br><span style="font-weight: bold;">/* Tell SWIG that create_animal creates a new object */</span><br><span style="font-weight: bold;">%newobject Zoo::create_animal;</span><br><br><span style="font-weight: bold;">/* Tell SWIG to keep track of mappings between C/C++ structs/classes. */</span><br style="font-weight: bold;"><span style="font-weight: bold;">%trackobjects;</span><br><br>%include "example.h"</pre>
+<pre>%module example<br><br>%{<br>#include "example.h"<br>%}<br><br><b>/* Tell SWIG that create_animal creates a new object */</b><br><b>%newobject Zoo::create_animal;</b><br><br><b>/* Tell SWIG to keep track of mappings between C/C++ structs/classes. */</b><br style="font-weight: bold;"><b>%trackobjects;</b><br><br>%include "example.h"</pre>
@@ -10282,7 +10340,7 @@ class-by-class basis if needed. To fix the example above:</p>
<div class="code targetlang">
-<pre>$ <span style="font-weight: bold;">irb</span><br>irb(main):001:0&gt; <span style="font-weight: bold;">require 'example'</span><br>=&gt; true<br><br>irb(main):002:0&gt; <span style="font-weight: bold;">tiger1 = Example::Animal.new("tiger1")</span><br>=&gt; #&lt;Example::Animal:0x2be37d8&gt;<br><br>irb(main):003:0&gt; <span style="font-weight: bold;">zoo = Example::Zoo.new()</span><br>=&gt; #&lt;Example::Zoo:0x2be0a18&gt;<br><br>irb(main):004:0&gt; <span style="font-weight: bold;">zoo.add_animal(tiger1)</span><br>=&gt; nil<br><br>irb(main):006:0&gt; <span style="font-weight: bold;">tiger2 = zoo.remove_animal(0)</span><br>=&gt; #&lt;Example::Animal:0x2be37d8&gt;<br><br>irb(main):007:0&gt; <span style="font-weight: bold;">tiger1.equal?(tiger2)</span><br>=&gt; true<br><br>irb(main):008:0&gt; <span style="font-weight: bold;">tiger1 = nil</span><br>=&gt; nil<br><br>irb(main):009:0&gt; <span style="font-weight: bold;">GC.start</span><br>=&gt; nil<br><br>irb(main):010:0&gt; <span style="font-weight: bold;">tiger.get_name()</span><br>=&gt; "tiger1"<br>irb(main):011:0&gt;<br><br></pre>
+<pre>$ <b>irb</b><br>irb(main):001:0&gt; <b>require 'example'</b><br>=&gt; true<br><br>irb(main):002:0&gt; <b>tiger1 = Example::Animal.new("tiger1")</b><br>=&gt; #&lt;Example::Animal:0x2be37d8&gt;<br><br>irb(main):003:0&gt; <b>zoo = Example::Zoo.new()</b><br>=&gt; #&lt;Example::Zoo:0x2be0a18&gt;<br><br>irb(main):004:0&gt; <b>zoo.add_animal(tiger1)</b><br>=&gt; nil<br><br>irb(main):006:0&gt; <b>tiger2 = zoo.remove_animal(0)</b><br>=&gt; #&lt;Example::Animal:0x2be37d8&gt;<br><br>irb(main):007:0&gt; <b>tiger1.equal?(tiger2)</b><br>=&gt; true<br><br>irb(main):008:0&gt; <b>tiger1 = nil</b><br>=&gt; nil<br><br>irb(main):009:0&gt; <b>GC.start</b><br>=&gt; nil<br><br>irb(main):010:0&gt; <b>tiger.get_name()</b><br>=&gt; "tiger1"<br>irb(main):011:0&gt;<br><br></pre>
@@ -10342,7 +10400,7 @@ methods.</p>
-<H3><a name="Ruby_nn61"></a>33.10.4 Mark Functions</H3>
+<H3><a name="Ruby_nn61"></a>35.10.4 Mark Functions</H3>
<p>With a bit more testing, we see that our class library still
@@ -10359,7 +10417,7 @@ has problems. For example:<br>
<div class="targetlang">
-<pre>$ <b>irb</b><br>irb(main):001:0&gt; <span style="font-weight: bold;">require 'example'</span><br>=&gt; true<br><br>irb(main):002:0&gt; tiger1 = <span style="font-weight: bold;">Example::Animal.new("tiger1")</span><br>=&gt; #&lt;Example::Animal:0x2bea6a8&gt;<br><br>irb(main):003:0&gt; zoo = <span style="font-weight: bold;">Example::Zoo.new()</span><br>=&gt; #&lt;Example::Zoo:0x2be7960&gt;<br><br>irb(main):004:0&gt; <span style="font-weight: bold;">zoo.add_animal(tiger1)</span><br>=&gt; nil<br><br>irb(main):007:0&gt; <span style="font-weight: bold;">tiger1 = nil</span><br>=&gt; nil<br><br>irb(main):007:0&gt; <span style="font-weight: bold;">GC.start</span><br>=&gt; nil<br><br>irb(main):005:0&gt; <span style="font-weight: bold;">tiger2 = zoo.get_animal(0)</span><br>(irb):12: [BUG] Segmentation fault</pre>
+<pre>$ <b>irb</b><br>irb(main):001:0&gt; <b>require 'example'</b><br>=&gt; true<br><br>irb(main):002:0&gt; tiger1 = <b>Example::Animal.new("tiger1")</b><br>=&gt; #&lt;Example::Animal:0x2bea6a8&gt;<br><br>irb(main):003:0&gt; zoo = <b>Example::Zoo.new()</b><br>=&gt; #&lt;Example::Zoo:0x2be7960&gt;<br><br>irb(main):004:0&gt; <b>zoo.add_animal(tiger1)</b><br>=&gt; nil<br><br>irb(main):007:0&gt; <b>tiger1 = nil</b><br>=&gt; nil<br><br>irb(main):007:0&gt; <b>GC.start</b><br>=&gt; nil<br><br>irb(main):005:0&gt; <b>tiger2 = zoo.get_animal(0)</b><br>(irb):12: [BUG] Segmentation fault</pre>
@@ -10407,7 +10465,7 @@ implementation is:</p>
<div class="code">
-<pre>%module example<br><br>%{<br>#include "example.h"<br>%}<br><br>/* Keep track of mappings between C/C++ structs/classes<br> and Ruby objects so we can implement a mark function. */<br><span style="font-weight: bold;">%trackobjects;</span><br><br>/* Specify the mark function */<br><span style="font-weight: bold;">%markfunc Zoo "mark_Zoo";</span><br><br>%include "example.h"<br><br>%header %{<br><br>static void mark_Zoo(void* ptr) {<br> Zoo* zoo = (Zoo*) ptr;<br><br> /* Loop over each object and tell the garbage collector<br> that we are holding a reference to them. */<br> int count = zoo-&gt;get_num_animals();<br><br> for(int i = 0; i &lt; count; ++i) {<br> Animal* animal = zoo-&gt;get_animal(i);<br> VALUE object = SWIG_RubyInstanceFor(animal);<br><br> if (object != Qnil) {<br> rb_gc_mark(object);<br> }<br> }<br>}<br>%}<br><br></pre>
+<pre>%module example<br><br>%{<br>#include "example.h"<br>%}<br><br>/* Keep track of mappings between C/C++ structs/classes<br> and Ruby objects so we can implement a mark function. */<br><b>%trackobjects;</b><br><br>/* Specify the mark function */<br><b>%markfunc Zoo "mark_Zoo";</b><br><br>%include "example.h"<br><br>%header %{<br><br>static void mark_Zoo(void* ptr) {<br> Zoo* zoo = (Zoo*) ptr;<br><br> /* Loop over each object and tell the garbage collector<br> that we are holding a reference to them. */<br> int count = zoo-&gt;get_num_animals();<br><br> for(int i = 0; i &lt; count; ++i) {<br> Animal* animal = zoo-&gt;get_animal(i);<br> VALUE object = SWIG_RubyInstanceFor(animal);<br><br> if (object != Qnil) {<br> rb_gc_mark(object);<br> }<br> }<br>}<br>%}<br><br></pre>
@@ -10436,7 +10494,7 @@ test suite.</p>
<div class="targetlang">
-<pre>$ <b>irb<br></b>irb(main):002:0&gt; <span style="font-weight: bold;">tiger1=Example::Animal.new("tiger1")</span><br>=&gt; #&lt;Example::Animal:0x2be3bf8&gt;<br><br>irb(main):003:0&gt; <span style="font-weight: bold;">Example::Zoo.new()</span><br>=&gt; #&lt;Example::Zoo:0x2be1780&gt;<br><br>irb(main):004:0&gt; <span style="font-weight: bold;">zoo = Example::Zoo.new()</span><br>=&gt; #&lt;Example::Zoo:0x2bde9c0&gt;<br><br>irb(main):005:0&gt; <span style="font-weight: bold;">zoo.add_animal(tiger1)</span><br>=&gt; nil<br><br>irb(main):009:0&gt; <span style="font-weight: bold;">tiger1 = nil</span><br>=&gt; nil<br><br>irb(main):010:0&gt; <span style="font-weight: bold;">GC.start</span><br>=&gt; nil<br>irb(main):014:0&gt; <span style="font-weight: bold;">tiger2 = zoo.get_animal(0)</span><br>=&gt; #&lt;Example::Animal:0x2be3bf8&gt;<br><br>irb(main):015:0&gt; <span style="font-weight: bold;">tiger2.get_name()</span><br>=&gt; "tiger1"<br>irb(main):016:0&gt;<br><br></pre>
+<pre>$ <b>irb<br></b>irb(main):002:0&gt; <b>tiger1=Example::Animal.new("tiger1")</b><br>=&gt; #&lt;Example::Animal:0x2be3bf8&gt;<br><br>irb(main):003:0&gt; <b>Example::Zoo.new()</b><br>=&gt; #&lt;Example::Zoo:0x2be1780&gt;<br><br>irb(main):004:0&gt; <b>zoo = Example::Zoo.new()</b><br>=&gt; #&lt;Example::Zoo:0x2bde9c0&gt;<br><br>irb(main):005:0&gt; <b>zoo.add_animal(tiger1)</b><br>=&gt; nil<br><br>irb(main):009:0&gt; <b>tiger1 = nil</b><br>=&gt; nil<br><br>irb(main):010:0&gt; <b>GC.start</b><br>=&gt; nil<br>irb(main):014:0&gt; <b>tiger2 = zoo.get_animal(0)</b><br>=&gt; #&lt;Example::Animal:0x2be3bf8&gt;<br><br>irb(main):015:0&gt; <b>tiger2.get_name()</b><br>=&gt; "tiger1"<br>irb(main):016:0&gt;<br><br></pre>
@@ -10460,7 +10518,7 @@ test suite.</p>
-<H3><a name="Ruby_nn62"></a>33.10.5 Free Functions</H3>
+<H3><a name="Ruby_nn62"></a>35.10.5 Free Functions</H3>
<p>By default, SWIG creates a "free" function that is called when
@@ -10512,14 +10570,22 @@ directive, let's slightly change our example. Assume that the zoo
object is responsible for freeing animal that it contains. This means
that the <span style="font-family: monospace;">Zoo::add_animal</span>
function should be marked with a <span style="font-family: monospace;">DISOWN</span> typemap
-and the destructor should be updated as below::</p>
+and the destructor should be updated as below:</p>
<div class="code">
-<pre>Zoo::~Zoo() {<br> IterType iter = this-&gt;animals.begin();<br> IterType end = this-&gt;animals.end();<br><br> for(iter; iter != end; ++iter) {<br> Animal* animal = *iter;<br> delete animal;<br> }<br>}</pre>
+<pre>Zoo::~Zoo() {
+ IterType iter = this-&gt;animals.begin();
+ IterType end = this-&gt;animals.end();
+
+ for(iter; iter != end; ++iter) {
+ Animal* animal = *iter;
+ delete animal;
+ }
+}</pre>
@@ -10538,7 +10604,29 @@ and the destructor should be updated as below::</p>
<div class="code targetlang">
-<pre class="targetlang"><span style="font-weight: bold;">$irb</span><br>irb(main):002:0&gt; <span style="font-weight: bold;">require 'example'</span><br>=&gt; true<br><br>irb(main):003:0&gt; <span style="font-weight: bold;">zoo = Example::Zoo.new()</span><br>=&gt; #&lt;Example::Zoo:0x2be0fe8&gt;<br><br>irb(main):005:0&gt; <span style="font-weight: bold;">tiger1 = Example::Animal.new("tiger1")</span><br>=&gt; #&lt;Example::Animal:0x2bda760&gt;<br><br>irb(main):006:0&gt; <span style="font-weight: bold;">zoo.add_animal(tiger1)</span><br>=&gt; nil<br><br>irb(main):007:0&gt; <span style="font-weight: bold;">zoo = nil</span><br>=&gt; nil<br><br>irb(main):008:0&gt; <span style="font-weight: bold;">GC.start</span><br>=&gt; nil<br><br>irb(main):009:0&gt; <span style="font-weight: bold;">tiger1.get_name()</span><br>(irb):12: [BUG] Segmentation fault<br><br></pre>
+<pre class="targetlang"><b>$irb</b>
+irb(main):002:0&gt; <b>require 'example'</b>
+=&gt; true
+
+irb(main):003:0&gt; <b>zoo = Example::Zoo.new()</b>
+=&gt; #&lt;Example::Zoo:0x2be0fe8&gt;
+
+irb(main):005:0&gt; <b>tiger1 = Example::Animal.new("tiger1")</b>
+=&gt; #&lt;Example::Animal:0x2bda760&gt;
+
+irb(main):006:0&gt; <b>zoo.add_animal(tiger1)</b>
+=&gt; nil
+
+irb(main):007:0&gt; <b>zoo = nil</b>
+=&gt; nil
+
+irb(main):008:0&gt; <b>GC.start</b>
+=&gt; nil
+
+irb(main):009:0&gt; <b>tiger1.get_name()</b>
+(irb):12: [BUG] Segmentation fault
+
+</pre>
@@ -10571,7 +10659,49 @@ existing Ruby object to the destroyed C++ object and raise an exception.<br>
<div class="code">
-<pre>%module example<br><br>%{<br>#include "example.h"<br>%}<br><br>/* Specify that ownership is transferred to the zoo<br> when calling add_animal */<br>%apply SWIGTYPE *DISOWN { Animal* animal };<br><br>/* Track objects */<br>%trackobjects;<br><br>/* Specify the mark function */<br>%freefunc Zoo "free_Zoo";<br><br>%include "example.h"<br><br>%header %{<br> static void free_Zoo(void* ptr) {<br> Zoo* zoo = (Zoo*) ptr;<br><br> /* Loop over each animal */<br> int count = zoo-&gt;get_num_animals();<br><br> for(int i = 0; i &lt; count; ++i) {<br> /* Get an animal */<br> Animal* animal = zoo-&gt;get_animal(i);<br><br> /* Unlink the Ruby object from the C++ object */<br> SWIG_RubyUnlinkObjects(animal);<br><br> /* Now remove the tracking for this animal */<br> SWIG_RubyRemoveTracking(animal);<br> }<br><br> /* Now call SWIG_RubyRemoveTracking for the zoo */<br> SWIG_RubyRemoveTracking(ptr);<br> <br> /* Now free the zoo which will free the animals it contains */<br> delete zoo;<br> }<br>%} </pre>
+<pre>%module example
+
+%{
+#include "example.h"
+%}
+
+/* Specify that ownership is transferred to the zoo
+ when calling add_animal */
+%apply SWIGTYPE *DISOWN { Animal* animal };
+
+/* Track objects */
+%trackobjects;
+
+/* Specify the mark function */
+%freefunc Zoo "free_Zoo";
+
+%include "example.h"
+
+%header %{
+ static void free_Zoo(void* ptr) {
+ Zoo* zoo = (Zoo*) ptr;
+
+ /* Loop over each animal */
+ int count = zoo-&gt;get_num_animals();
+
+ for(int i = 0; i &lt; count; ++i) {
+ /* Get an animal */
+ Animal* animal = zoo-&gt;get_animal(i);
+
+ /* Unlink the Ruby object from the C++ object */
+ SWIG_RubyUnlinkObjects(animal);
+
+ /* Now remove the tracking for this animal */
+ SWIG_RubyRemoveTracking(animal);
+ }
+
+ /* Now call SWIG_RubyRemoveTracking for the zoo */
+ SWIG_RubyRemoveTracking(ptr);
+
+ /* Now free the zoo which will free the animals it contains */
+ delete zoo;
+ }
+%} </pre>
@@ -10590,7 +10720,30 @@ existing Ruby object to the destroyed C++ object and raise an exception.<br>
<div class="code targetlang">
-<pre><span style="font-weight: bold;">$irb</span><br>irb(main):002:0&gt; <span style="font-weight: bold;">require 'example'</span><br>=&gt; true<br><br>irb(main):003:0&gt; <span style="font-weight: bold;">zoo = Example::Zoo.new()</span><br>=&gt; #&lt;Example::Zoo:0x2be0fe8&gt;<br><br>irb(main):005:0&gt; <span style="font-weight: bold;">tiger1 = Example::Animal.new("tiger1")</span><br>=&gt; #&lt;Example::Animal:0x2bda760&gt;<br><br>irb(main):006:0&gt; <span style="font-weight: bold;">zoo.add_animal(tiger1)</span><br>=&gt; nil<br><br>irb(main):007:0&gt; <span style="font-weight: bold;">zoo = nil</span><br>=&gt; nil<br><br>irb(main):008:0&gt; <span style="font-weight: bold;">GC.start</span><br>=&gt; nil<br><br>irb(main):009:0&gt; <span style="font-weight: bold;">tiger1.get_name()</span><br>RuntimeError: This Animal * already released<br> from (irb):10:in `get_name'<br> from (irb):10<br>irb(main):011:0&gt;</pre>
+<pre><b>$irb</b>
+irb(main):002:0&gt; <b>require 'example'</b>
+=&gt; true
+
+irb(main):003:0&gt; <b>zoo = Example::Zoo.new()</b>
+=&gt; #&lt;Example::Zoo:0x2be0fe8&gt;
+
+irb(main):005:0&gt; <b>tiger1 = Example::Animal.new("tiger1")</b>
+=&gt; #&lt;Example::Animal:0x2bda760&gt;
+
+irb(main):006:0&gt; <b>zoo.add_animal(tiger1)</b>
+=&gt; nil
+
+irb(main):007:0&gt; <b>zoo = nil</b>
+=&gt; nil
+
+irb(main):008:0&gt; <b>GC.start</b>
+=&gt; nil
+
+irb(main):009:0&gt; <b>tiger1.get_name()</b>
+RuntimeError: This Animal * already released
+ from (irb):10:in `get_name'
+ from (irb):10
+irb(main):011:0&gt;</pre>
@@ -10615,7 +10768,7 @@ been freed, and thus raises a runtime exception.</p>
-<H3><a name="Ruby_nn63"></a>33.10.6 Embedded Ruby and the C++ Stack</H3>
+<H3><a name="Ruby_nn63"></a>35.10.6 Embedded Ruby and the C++ Stack</H3>
<p>As has been said, the Ruby GC runs and marks objects before
diff --git a/Doc/Manual/SWIG.html b/Doc/Manual/SWIG.html
index d523bee77..fd510f2a4 100644
--- a/Doc/Manual/SWIG.html
+++ b/Doc/Manual/SWIG.html
@@ -44,6 +44,11 @@
<li><a href="#SWIG_nn26">Arrays</a>
<li><a href="#SWIG_readonly_variables">Creating read-only variables</a>
<li><a href="#SWIG_rename_ignore">Renaming and ignoring declarations</a>
+<ul>
+<li><a href="#SWIG_nn29">Simple renaming of specific identifiers</a>
+<li><a href="#SWIG_advanced_renaming">Advanced renaming support</a>
+<li><a href="#SWIG_limiting_renaming">Limiting global renaming rules</a>
+</ul>
<li><a href="#SWIG_default_args">Default/optional arguments</a>
<li><a href="#SWIG_nn30">Pointers to functions and callbacks</a>
</ul>
@@ -142,6 +147,7 @@ can be obtained by typing <tt>swig -help</tt> or <tt>swig
-o <em>outfile</em> Name of output file
-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
-version Show SWIG version number
@@ -1662,6 +1668,9 @@ generate a warning message. Simply change the directives to <tt>%immutable;</t
<H3><a name="SWIG_rename_ignore"></a>5.4.7 Renaming and ignoring declarations</H3>
+<H4><a name="SWIG_nn29"></a>5.4.7.1 Simple renaming of specific identifiers</H4>
+
+
<p>
Normally, the name of a C declaration is used when that declaration is
wrapped into the target language. However, this may generate a
@@ -1742,12 +1751,6 @@ declarations. If you need to remove a whole section of problematic code, the SW
</p>
<p>
-More powerful variants of <tt>%rename</tt> and <tt>%ignore</tt> directives can be used to help
-wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the
-<a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Ambiguity resolution and renaming</a> section in the C++ chapter.
-</p>
-
-<p>
<b>Compatibility note: </b> Older versions of SWIG provided a special <tt>%name</tt> directive for renaming declarations.
For example:
</p>
@@ -1763,6 +1766,290 @@ This directive is still supported, but it is deprecated and should probably be a
directive is more powerful and better supports wrapping of raw header file information.
</p>
+<H4><a name="SWIG_advanced_renaming"></a>5.4.7.2 Advanced renaming support</H4>
+
+
+<p>
+While writing <tt>%rename</tt> for specific declarations is simple enough,
+sometimes the same renaming rule needs to be applied to many, maybe all,
+identifiers in the SWIG input. For example, it may be necessary to apply some
+transformation to all the names in the target language to better follow its
+naming conventions, like adding a specific prefix to all wrapped functions. Doing it individually
+for each function is impractical so SWIG supports applying a renaming rule to
+all declarations if the name of the identifier to be renamed is not specified:
+</p>
+
+<div class="code">
+<pre>
+%rename("myprefix_%s") ""; // print&nbsp;-&gt;&nbsp;myprefix_print
+</pre>
+</div>
+
+<p>
+This also shows that the argument of <tt>%rename</tt> doesn't have to be a
+literal string but can be a <tt>printf()</tt>-like format string. In the
+simplest form, <tt>"%s"</tt> is replaced with the name of the original
+declaration, as shown above. However this is not always enough and SWIG
+provides extensions to the usual format string syntax to allow applying a
+(SWIG-defined) function to the argument. For example, to wrap all C functions
+<tt>do_something_long()</tt> as more Java-like <tt>doSomethingLong()</tt> you
+can use the <tt>"lowercamelcase"</tt> extended format specifier like this:
+</p>
+
+<div class="code">
+<pre>
+%rename("%(lowercamelcase)s") ""; // foo_bar -&gt; fooBar; FooBar -&gt; fooBar
+</pre>
+</div>
+
+<p>
+Some functions can be parametrized, for example the <tt>"strip"</tt> one
+strips the provided prefix from its argument. The prefix is specified as part
+of the format string, following a colon after the function name:
+</p>
+<div class="code">
+<pre>
+%rename("%(strip:[wx])s") ""; // wxHello -&gt; Hello; FooBar -&gt; FooBar
+</pre>
+</div>
+
+<p>
+Below is the table summarizing all currently defined functions with an example
+of applying each one. Note that some of them have two names, a shorter one
+and a more descriptive one, but the two functions are otherwise equivalent:
+</p>
+<table summary="Format string functions" border="1" cellpadding="5">
+<tr>
+ <th>Function</th><th>Returns</th><th colspan=2>Example (in/out)</th>
+</tr>
+<tr>
+ <td><tt>uppercase</tt> or <tt>upper</tt></td>
+ <td>Upper case version of the string.</td>
+ <td><tt>Print</tt></td><td><tt>PRINT</tt></td>
+</tr>
+<tr>
+ <td><tt>lowercase</tt> or <tt>lower</tt></td>
+ <td>Lower case version of the string.</td>
+ <td><tt>Print</tt></td><td><tt>print</tt></td>
+</tr>
+<tr>
+ <td><tt>title</tt></td>
+ <td>String with first letter capitalized and the rest in lower case.</td>
+ <td><tt>print</tt></td><td><tt>Print</tt></td>
+</tr>
+<tr>
+ <td><tt>firstuppercase</tt></td>
+ <td>String with the first letter capitalized and the rest unchanged.</td>
+ <td><tt>printIt</tt></td><td><tt>PrintIt</tt></td>
+</tr>
+<tr>
+ <td><tt>firstlowercase</tt></td>
+ <td>String with the first letter in lower case and the rest unchanged.</td>
+ <td><tt>PrintIt</tt></td><td><tt>printIt</tt></td>
+</tr>
+<tr>
+ <td><tt>camelcase</tt> or <tt>ctitle</tt></td>
+ <td>String with capitalized first letter and any letter following an
+ underscore (which are removed in the process) and rest in lower case.</td>
+ <td><tt>print_it</tt></td><td><tt>PrintIt</tt></td>
+</tr>
+<tr>
+ <td><tt>lowercamelcase</tt> or <tt>lctitle</tt></td>
+ <td>String with every letter following an underscore (which is removed in
+ the process) capitalized and rest, including the first letter, in lower
+ case.</td>
+ <td><tt>print_it</tt></td><td><tt>printIt</tt></td>
+</tr>
+<tr>
+ <td><tt>undercase</tt> or <tt>utitle</tt></td>
+ <td>Lower case string with underscores inserted before every upper case
+ letter in the original string and any number not at the end of string.
+ Logically, this is the reverse of <tt>camelcase</tt>.</td>
+ <td><tt>PrintIt</tt></td><td><tt>print_it</tt></td>
+</tr>
+<tr>
+ <td><tt>schemify</tt></td>
+ <td>String with all underscores replaced with dashes, resulting in more
+ Lispers/Schemers-pleasing name.</td>
+ <td><tt>print_it</tt></td><td><tt>print-it</tt></td>
+</tr>
+<tr>
+ <td><tt>strip:[prefix]</tt></td>
+ <td>String without the given prefix or the original string if it doesn't
+ start with this prefix. Note that square brackets should be used
+ literally, e.g. <tt>%rename("strip:[wx]")</tt></td>
+ <td><tt>wxPrint</tt></td><td><tt>Print</tt></td>
+</tr>
+<tr>
+ <td><span style="white-space: nowrap;"><tt>regex:/pattern/subst/</tt></span></td>
+ <td>String after (Perl-like) regex substitution operation. This function
+ allows to apply arbitrary regular expressions to the identifier names. The
+ <i>pattern</i> part is a regular expression in Perl syntax (as supported
+ by the <a href="http://www.pcre.org/">Perl Compatible Regular Expressions (PCRE)</a>)
+ library and the <i>subst</i> string
+ can contain back-references introduced by <tt>'\'</tt> or, as backslashes need
+ to be escaped in C strings, rather by <tt>"\\"</tt>. For example, to remove
+ any alphabetic prefix before an underscore you could use the following directive:
+ <tt>%rename("regex:/(\\w+)_(.*)/\\2/")</tt></td>
+ <td><tt>Prefix_Print</tt></td><td><tt>Print</tt></td>
+</tr>
+<tr>
+ <td><tt>command:cmd</tt></td>
+ <td>Output of an external command <tt>cmd</tt> with the string passed to
+ it as input. Notice that this function is extremely slow compared to all
+ the other ones as it involves spawning a separate process and using it for
+ many declarations is not recommended. The <i>cmd</i> is not enclosed in
+ square brackets but must be terminated with a triple <tt>'&lt;'</tt> sign,
+ e.g. <tt>%rename("command:tr&nbsp;-d&nbsp;aeiou &lt;&lt;&lt;")</tt>
+ (nonsensical example removing all vowels)</td>
+ <td><tt>Print</tt></td><td><tt>Prnt</tt></td>
+</tr>
+</table>
+
+<p>
+The most general function of all of the above ones (not counting
+<tt>command</tt> which is even more powerful in principle but which should
+generally be avoided because of performance considerations) is the
+<tt>regex</tt> one. Here are some more examples of its use:
+</p>
+
+<div class="code">
+<pre>
+// Strip the wx prefix from all identifiers except those starting with wxEVT
+%rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") ""; // wxSomeWidget -&gt; SomeWidget
+ // wxEVT_PAINT -&gt; wxEVT_PAINT
+
+// Apply a rule for renaming the enum elements to avoid the common prefixes
+// which are redundant in C#/Java
+%rename("%(regex:/^([A-Z][a-z]+)+_(.*)/\\2/)s", %$isenumitem) ""; // Colour_Red -&gt; Red
+
+// Remove all "Set/Get" prefixes.
+%rename("%(regex:/^(Set|Get)(.*)/\\2/)s") ""; // SetValue -&gt; Value
+ // GetValue -&gt; Value
+</pre>
+</div>
+
+<p>
+As before, everything that was said above about <tt>%rename</tt> also applies to
+<tt>%ignore</tt>. In fact, the latter is just a special case of the former and
+ignoring an identifier is the same as renaming it to the special
+<tt>"$ignore"</tt> value. So the following snippets
+</p>
+
+<div class="code">
+<pre>
+%ignore print;
+</pre>
+</div>
+
+<p>
+and
+</p>
+
+<div class="code">
+<pre>
+%rename("$ignore") print;
+</pre>
+</div>
+
+<p>
+are exactly equivalent and <tt>%rename</tt> can be used to selectively ignore
+multiple declarations using the previously described matching possibilities.
+</p>
+
+<H4><a name="SWIG_limiting_renaming"></a>5.4.7.3 Limiting global renaming rules</H4>
+
+
+<p>
+As explained in the previous sections, it is possible to either rename
+individual declarations or apply a rename rule to all of them at once. In
+practice, the latter is however rarely appropriate as there are always some
+exceptions to the general rules. To deal with them, the scope of an unnamed
+<tt>%rename</tt> can be limited using subsequent <tt>match</tt> parameters.
+They can be applied to any of the attributes associated by SWIG with the
+declarations appearing in its input. For example:
+</p>
+<div class="code">
+<pre>
+%rename("foo", match$name="bar") "";
+</pre>
+</div>
+<p>
+can be used to achieve the same effect as the simpler
+</p>
+<div class="code">
+<pre>
+%rename("foo") bar;
+</pre>
+</div>
+<p>
+and so is not very interesting on its own. However <tt>match</tt> can also be
+applied to the declaration type, for example <tt>match="class"</tt> restricts
+the match to class declarations only (in C++) and <tt>match="enumitem"</tt>
+restricts it to the enum elements. SWIG also provides convenience macros for
+such match expressions, for example
+</p>
+<div class="code">
+<pre>
+%rename("%(title)s", %$isenumitem) "";
+</pre>
+</div>
+<p>
+will capitalize the names of all the enum elements but not change the case of
+the other declarations. Similarly, <tt>%$isclass</tt>, <tt>%$isfunction</tt>
+and <tt>%$isvariable</tt> can be used. Many other checks are possible and this
+documentation is not exhaustive, see "%rename predicates" section of
+<tt>swig.swg</tt> for the full list of supported match expressions.
+</p>
+
+<p>
+In addition to literally matching some string with <tt>match</tt> you can
+also use <tt>regexmatch</tt> or <tt>notregexmatch</tt> to match a string
+against a regular expression. For example, to ignore all functions having
+"Old" as a suffix you could use
+</p>
+<div class="code">
+<pre>
+%rename("$ignore", regexmatch$name="Old$") "";
+</pre>
+</div>
+<p>
+For simple cases like this, specifying the regular expression for the
+declaration name directly can be preferable and can also be done using
+<tt>regextarget</tt>:
+</p>
+<div class="code">
+<pre>
+%rename("$ignore", regextarget=1) "Old$";
+</pre>
+</div>
+Notice that the check is done only against the name of the declaration
+itself, if you need to match the full name of a C++ declaration you
+must use <tt>fullname</tt> attribute:
+<div class="code">
+<pre>
+%rename("$ignore", regextarget=1, fullname=1) "NameSpace::ClassName::.*Old$";
+</pre>
+</div>
+
+<p>
+As for <tt>notregexmatch</tt>, it restricts the match only to the strings not
+matching the specified regular expression. So to rename all declarations to lower case
+except those consisting of capital letters only:
+</p>
+<div class="code">
+<pre>
+%rename("$(lower)s", notregexmatch$name="^[A-Z]+$") "";
+</pre>
+</div>
+
+<p>
+Finally, variants of <tt>%rename</tt> and <tt>%ignore</tt> directives can be used to help
+wrap C++ overloaded functions and methods or C++ methods which use default arguments. This is described in the
+<a href="SWIGPlus.html#SWIGPlus_ambiguity_resolution_renaming">Ambiguity resolution and renaming</a> section in the C++ chapter.
+</p>
+
+
<H3><a name="SWIG_default_args"></a>5.4.8 Default/optional arguments</H3>
@@ -1926,13 +2213,13 @@ normally, just use the original function name such as <tt>add()</tt>.
<p>
SWIG provides a number of extensions to standard C printf formatting
that may be useful in this context. For instance, the following
-variation installs the callbacks as all upper-case constants such as
+variation installs the callbacks as all upper case constants such as
<tt>ADD</tt>, <tt>SUB</tt>, and <tt>MUL</tt>:
</p>
<div class="code"><pre>
/* Some callback functions */
-%callback("%(upper)s");
+%callback("%(uppercase)s");
int add(int,int);
int sub(int,int);
int mul(int,int);
@@ -1940,7 +2227,7 @@ int mul(int,int);
</pre></div>
<p>
-A format string of <tt>"%(lower)s"</tt> converts all characters to lower-case.
+A format string of <tt>"%(lowercase)s"</tt> converts all characters to lower case.
A string of <tt>"%(title)s"</tt> capitalizes the first character and converts the
rest to lower case.
</p>
@@ -1949,7 +2236,8 @@ rest to lower case.
And now, a final note about function pointer support. Although SWIG
does not normally allow callback functions to be written in the target language, this
can be accomplished with the use of typemaps and other advanced SWIG features.
-This is described in a later chapter.
+See the <a href="Typemaps.html#Typemaps">Typemaps chapter</a> for more about typemaps
+and individual target language chapters for more on callbacks and the 'director' feature.
</p>
<H2><a name="SWIG_nn31"></a>5.5 Structures and unions</H2>
diff --git a/Doc/Manual/SWIGPlus.html b/Doc/Manual/SWIGPlus.html
index f9bfc8ec6..c8e5ee870 100644
--- a/Doc/Manual/SWIGPlus.html
+++ b/Doc/Manual/SWIGPlus.html
@@ -4192,8 +4192,9 @@ In the example below, the generic template type is used to rename to <tt>bbb</tt
<div class="code">
<pre>
-%rename(bbb) Space::ABC::aaa(T t); // will match but with lower precedence than ccc
-%rename(ccc) Space::ABC&lt;Space::XYZ&gt;::aaa(Space::XYZ t); // will match but with higher precedence than bbb
+%rename(bbb) Space::ABC::aaa(T t); // will match but with lower precedence than ccc
+%rename(ccc) Space::ABC&lt;Space::XYZ&gt;::aaa(Space::XYZ t);// will match but with higher precedence
+ // than bbb
namespace Space {
class XYZ {};
@@ -4214,9 +4215,9 @@ Below shows how %rename can be placed inside a namespace.
<div class="code">
<pre>
namespace Space {
- %rename(bbb) ABC::aaa(T t); // will match but with lower precedence than ccc
- %rename(ccc) ABC&lt;Space::XYZ&gt;::aaa(Space::XYZ t); // will match but with higher precedence than bbb
- %rename(ddd) ABC&lt;Space::XYZ&gt;::aaa(XYZ t); // will not match
+ %rename(bbb) ABC::aaa(T t); // will match but with lower precedence than ccc
+ %rename(ccc) ABC&lt;Space::XYZ&gt;::aaa(Space::XYZ t);// will match but with higher precedence than bbb
+ %rename(ddd) ABC&lt;Space::XYZ&gt;::aaa(XYZ t); // will not match
}
namespace Space {
@@ -4238,11 +4239,11 @@ The following example shows how %rename can be placed within %extend.
<pre>
namespace Space {
%extend ABC {
- %rename(bbb) aaa(T t); // will match but with lower precedence than ccc
+ %rename(bbb) aaa(T t); // will match but with lower precedence than ccc
}
%extend ABC&lt;Space::XYZ&gt; {
- %rename(ccc) aaa(Space::XYZ t); // will match but with higher precedence than bbb
- %rename(ddd) aaa(XYZ t); // will not match
+ %rename(ccc) aaa(Space::XYZ t);// will match but with higher precedence than bbb
+ %rename(ddd) aaa(XYZ t); // will not match
}
}
diff --git a/Doc/Manual/Sections.html b/Doc/Manual/Sections.html
index 8693adc07..8f171b985 100644
--- a/Doc/Manual/Sections.html
+++ b/Doc/Manual/Sections.html
@@ -6,7 +6,7 @@
<body bgcolor="#ffffff">
<H1><a name="Sections"></a>SWIG-2.0 Documentation</H1>
-Last update : SWIG-2.0.1 (in progress)
+Last update : SWIG-2.0.2 (in progress)
<H2>Sections</H2>
@@ -19,7 +19,7 @@ Last update : SWIG-2.0.1 (in progress)
<li><a href="SWIG.html#SWIG">SWIG Basics</a> (Read this!)</li>
<li><a href="SWIGPlus.html#SWIGPlus">SWIG and C++</a></li>
<li><a href="Preprocessor.html#Preprocessor">The SWIG preprocessor</a></li>
-<li><a href="Library.html#Library">The SWIG Library</a></li>
+<li><a href="Library.html#Library">The SWIG library</a></li>
<li><a href="Arguments.html#Arguments">Argument handling</a></li>
<li><a href="Typemaps.html#Typemaps">Typemaps</a></li>
<li><a href="Customization.html#Customization">Customization features</a></li>
@@ -36,21 +36,22 @@ Last update : SWIG-2.0.1 (in progress)
<li><a href="Allegrocl.html#Allegrocl">Allegro CL support</a></li>
<li><a href="CSharp.html#CSharp">C# support</a></li>
<li><a href="Chicken.html#Chicken">Chicken support</a></li>
+<li><a href="D.html#D">D support</a></li>
<li><a href="Go.html#Go">Go support</a></li>
<li><a href="Guile.html#Guile">Guile support</a></li>
<li><a href="Java.html#Java">Java support</a></li>
-<li><a href="Lua.html#Lua">Lua support</a></li>
<li><a href="Lisp.html#Lisp">Common Lisp support</a></li>
+<li><a href="Lua.html#Lua">Lua support</a></li>
<li><a href="Modula3.html#Modula3">Modula3 support</a></li>
-<li><a href="Mzscheme.html#MzScheme">MzScheme support</a></li>
+<li><a href="Mzscheme.html#Mzscheme">MzScheme support</a></li>
<li><a href="Ocaml.html#Ocaml">Ocaml support</a></li>
<li><a href="Octave.html#Octave">Octave support</a></li>
<li><a href="Perl5.html#Perl5">Perl5 support</a></li>
<li><a href="Php.html#Php">PHP support</a></li>
<li><a href="Pike.html#Pike">Pike support</a></li>
<li><a href="Python.html#Python">Python support</a></li>
-<li><a href="Ruby.html#Ruby">Ruby 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="Tcl.html#Tcl">Tcl support</a></li>
</ul>
diff --git a/Doc/Manual/Tcl.html b/Doc/Manual/Tcl.html
index d47dae5de..c677f6eed 100644
--- a/Doc/Manual/Tcl.html
+++ b/Doc/Manual/Tcl.html
@@ -6,7 +6,7 @@
</head>
<body bgcolor="#ffffff">
-<H1><a name="Tcl"></a>34 SWIG and Tcl</H1>
+<H1><a name="Tcl"></a>36 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>34.1 Preliminaries</H2>
+<H2><a name="Tcl_nn2"></a>36.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>34.1.1 Getting the right header files</H3>
+<H3><a name="Tcl_nn3"></a>36.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>34.1.2 Compiling a dynamic module</H3>
+<H3><a name="Tcl_nn4"></a>36.1.2 Compiling a dynamic module</H3>
<p>
@@ -162,7 +162,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>34.1.3 Static linking</H3>
+<H3><a name="Tcl_nn5"></a>36.1.3 Static linking</H3>
<p>
@@ -228,7 +228,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>34.1.4 Using your module</H3>
+<H3><a name="Tcl_nn6"></a>36.1.4 Using your module</H3>
<p>
@@ -356,7 +356,7 @@ to the default system configuration (this requires root access and you will need
the man pages).
</p>
-<H3><a name="Tcl_nn7"></a>34.1.5 Compilation of C++ extensions</H3>
+<H3><a name="Tcl_nn7"></a>36.1.5 Compilation of C++ extensions</H3>
<p>
@@ -439,7 +439,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>34.1.6 Compiling for 64-bit platforms</H3>
+<H3><a name="Tcl_nn8"></a>36.1.6 Compiling for 64-bit platforms</H3>
<p>
@@ -466,7 +466,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>34.1.7 Setting a package prefix</H3>
+<H3><a name="Tcl_nn9"></a>36.1.7 Setting a package prefix</H3>
<p>
@@ -485,7 +485,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>34.1.8 Using namespaces</H3>
+<H3><a name="Tcl_nn10"></a>36.1.8 Using namespaces</H3>
<p>
@@ -507,7 +507,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>34.2 Building Tcl/Tk Extensions under Windows 95/NT</H2>
+<H2><a name="Tcl_nn11"></a>36.2 Building Tcl/Tk Extensions under Windows 95/NT</H2>
<p>
@@ -518,7 +518,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>34.2.1 Running SWIG from Developer Studio</H3>
+<H3><a name="Tcl_nn12"></a>36.2.1 Running SWIG from Developer Studio</H3>
<p>
@@ -576,7 +576,7 @@ MSDOS &gt; tclsh80
%
</pre></div>
-<H3><a name="Tcl_nn13"></a>34.2.2 Using NMAKE</H3>
+<H3><a name="Tcl_nn13"></a>36.2.2 Using NMAKE</H3>
<p>
@@ -639,7 +639,7 @@ to get you started. With a little practice, you'll be making lots of
Tcl extensions.
</p>
-<H2><a name="Tcl_nn14"></a>34.3 A tour of basic C/C++ wrapping</H2>
+<H2><a name="Tcl_nn14"></a>36.3 A tour of basic C/C++ wrapping</H2>
<p>
@@ -650,7 +650,7 @@ classes. This section briefly covers the essential aspects of this
wrapping.
</p>
-<H3><a name="Tcl_nn15"></a>34.3.1 Modules</H3>
+<H3><a name="Tcl_nn15"></a>36.3.1 Modules</H3>
<p>
@@ -684,7 +684,7 @@ To fix this, supply an extra argument to <tt>load</tt> like this:
</pre>
</div>
-<H3><a name="Tcl_nn16"></a>34.3.2 Functions</H3>
+<H3><a name="Tcl_nn16"></a>36.3.2 Functions</H3>
<p>
@@ -709,7 +709,7 @@ like you think it does:
%
</pre></div>
-<H3><a name="Tcl_nn17"></a>34.3.3 Global variables</H3>
+<H3><a name="Tcl_nn17"></a>36.3.3 Global variables</H3>
<p>
@@ -789,7 +789,7 @@ extern char *path; // Read-only (due to %immutable)
</pre>
</div>
-<H3><a name="Tcl_nn18"></a>34.3.4 Constants and enums</H3>
+<H3><a name="Tcl_nn18"></a>36.3.4 Constants and enums</H3>
<p>
@@ -873,7 +873,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>34.3.5 Pointers</H3>
+<H3><a name="Tcl_nn19"></a>36.3.5 Pointers</H3>
<p>
@@ -969,7 +969,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>34.3.6 Structures</H3>
+<H3><a name="Tcl_nn20"></a>36.3.6 Structures</H3>
<p>
@@ -1251,7 +1251,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>34.3.7 C++ classes</H3>
+<H3><a name="Tcl_nn21"></a>36.3.7 C++ classes</H3>
<p>
@@ -1318,7 +1318,7 @@ In Tcl, the static member is accessed as follows:
</pre>
</div>
-<H3><a name="Tcl_nn22"></a>34.3.8 C++ inheritance</H3>
+<H3><a name="Tcl_nn22"></a>36.3.8 C++ inheritance</H3>
<p>
@@ -1367,7 +1367,7 @@ For instance:
It is safe to use multiple inheritance with SWIG.
</p>
-<H3><a name="Tcl_nn23"></a>34.3.9 Pointers, references, values, and arrays</H3>
+<H3><a name="Tcl_nn23"></a>36.3.9 Pointers, references, values, and arrays</H3>
<p>
@@ -1421,7 +1421,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>34.3.10 C++ overloaded functions</H3>
+<H3><a name="Tcl_nn24"></a>36.3.10 C++ overloaded functions</H3>
<p>
@@ -1544,7 +1544,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>34.3.11 C++ operators</H3>
+<H3><a name="Tcl_nn25"></a>36.3.11 C++ operators</H3>
<p>
@@ -1646,7 +1646,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>34.3.12 C++ namespaces</H3>
+<H3><a name="Tcl_nn26"></a>36.3.12 C++ namespaces</H3>
<p>
@@ -1710,7 +1710,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>34.3.13 C++ templates</H3>
+<H3><a name="Tcl_nn27"></a>36.3.13 C++ templates</H3>
<p>
@@ -1762,7 +1762,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>34.3.14 C++ Smart Pointers</H3>
+<H3><a name="Tcl_nn28"></a>36.3.14 C++ Smart Pointers</H3>
<p>
@@ -1846,7 +1846,7 @@ simply use the <tt>__deref__()</tt> method. For example:
</pre>
</div>
-<H2><a name="Tcl_nn29"></a>34.4 Further details on the Tcl class interface</H2>
+<H2><a name="Tcl_nn29"></a>36.4 Further details on the Tcl class interface</H2>
<p>
@@ -1859,7 +1859,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>34.4.1 Proxy classes</H3>
+<H3><a name="Tcl_nn30"></a>36.4.1 Proxy classes</H3>
<p>
@@ -1924,7 +1924,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>34.4.2 Memory management</H3>
+<H3><a name="Tcl_nn31"></a>36.4.2 Memory management</H3>
<p>
@@ -2112,7 +2112,7 @@ typemaps--an advanced topic discussed later.
</p>
-<H2><a name="Tcl_nn32"></a>34.5 Input and output parameters</H2>
+<H2><a name="Tcl_nn32"></a>36.5 Input and output parameters</H2>
<p>
@@ -2300,7 +2300,7 @@ set c [lindex $dim 1]
</pre>
</div>
-<H2><a name="Tcl_nn33"></a>34.6 Exception handling </H2>
+<H2><a name="Tcl_nn33"></a>36.6 Exception handling </H2>
<p>
@@ -2434,7 +2434,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>34.7 Typemaps</H2>
+<H2><a name="Tcl_nn34"></a>36.7 Typemaps</H2>
<p>
@@ -2451,7 +2451,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>34.7.1 What is a typemap?</H3>
+<H3><a name="Tcl_nn35"></a>36.7.1 What is a typemap?</H3>
<p>
@@ -2568,7 +2568,7 @@ parameter is omitted):
</pre>
</div>
-<H3><a name="Tcl_nn36"></a>34.7.2 Tcl typemaps</H3>
+<H3><a name="Tcl_nn36"></a>36.7.2 Tcl typemaps</H3>
<p>
@@ -2706,7 +2706,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>34.7.3 Typemap variables</H3>
+<H3><a name="Tcl_nn37"></a>36.7.3 Typemap variables</H3>
<p>
@@ -2777,7 +2777,7 @@ properly assigned.
The Tcl name of the wrapper function being created.
</div>
-<H3><a name="Tcl_nn38"></a>34.7.4 Converting a Tcl list to a char ** </H3>
+<H3><a name="Tcl_nn38"></a>36.7.4 Converting a Tcl list to a char ** </H3>
<p>
@@ -2839,7 +2839,7 @@ argv[2] = Larry
3
</pre></div>
-<H3><a name="Tcl_nn39"></a>34.7.5 Returning values in arguments</H3>
+<H3><a name="Tcl_nn39"></a>36.7.5 Returning values in arguments</H3>
<p>
@@ -2881,7 +2881,7 @@ result, a Tcl function using these typemaps will work like this :
%
</pre></div>
-<H3><a name="Tcl_nn40"></a>34.7.6 Useful functions</H3>
+<H3><a name="Tcl_nn40"></a>36.7.6 Useful functions</H3>
<p>
@@ -2958,7 +2958,7 @@ int Tcl_IsShared(Tcl_Obj *obj);
</pre>
</div>
-<H3><a name="Tcl_nn41"></a>34.7.7 Standard typemaps</H3>
+<H3><a name="Tcl_nn41"></a>36.7.7 Standard typemaps</H3>
<p>
@@ -3042,7 +3042,7 @@ work)
</pre>
</div>
-<H3><a name="Tcl_nn42"></a>34.7.8 Pointer handling</H3>
+<H3><a name="Tcl_nn42"></a>36.7.8 Pointer handling</H3>
<p>
@@ -3118,7 +3118,7 @@ For example:
</pre>
</div>
-<H2><a name="Tcl_nn43"></a>34.8 Turning a SWIG module into a Tcl Package.</H2>
+<H2><a name="Tcl_nn43"></a>36.8 Turning a SWIG module into a Tcl Package.</H2>
<p>
@@ -3190,7 +3190,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>34.9 Building new kinds of Tcl interfaces (in Tcl)</H2>
+<H2><a name="Tcl_nn44"></a>36.9 Building new kinds of Tcl interfaces (in Tcl)</H2>
<p>
@@ -3289,7 +3289,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>34.9.1 Proxy classes</H3>
+<H3><a name="Tcl_nn45"></a>36.9.1 Proxy classes</H3>
<p>
@@ -3410,7 +3410,7 @@ short, but clever Tcl script can be combined with SWIG to do many
interesting things.
</p>
-<H2><a name="Tcl_nn46"></a>34.10 Tcl/Tk Stubs</H2>
+<H2><a name="Tcl_nn46"></a>36.10 Tcl/Tk Stubs</H2>
<p>
diff --git a/Doc/Manual/Typemaps.html b/Doc/Manual/Typemaps.html
index 1568c082e..6331aa1ac 100644
--- a/Doc/Manual/Typemaps.html
+++ b/Doc/Manual/Typemaps.html
@@ -1711,7 +1711,8 @@ you'll find the full typemap contents (example shown below for Python):
%typemap(in, noblock=1) SWIGTYPE [] (void *argp = 0, int res = 0) {
res = SWIG_ConvertPtr($input, &amp;argp,$descriptor, $disown | 0 );
if (!SWIG_IsOK(res)) {
- SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument " "$argnum"" of type '" "$type""'");
+ SWIG_exception_fail(SWIG_ArgError(res), "in method '" "$symname" "', argument "
+ "$argnum"" of type '" "$type""'");
}
$1 = ($ltype)(argp);
}
@@ -1732,7 +1733,8 @@ SWIGINTERN PyObject *_wrap_foo(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
...
res1 = SWIG_ConvertPtr(obj0, &amp;argp1,SWIGTYPE_p_a_4__int, 0 | 0 );
if (!SWIG_IsOK(res1)) {
- SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "foo" "', argument " "1"" of type '" "int [10][4]""'");
+ SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "foo" "', argument "
+ "1"" of type '" "int [10][4]""'");
}
arg1 = (int (*)[4])(argp1);
...
@@ -1791,7 +1793,8 @@ void set_value(const char* val) {}
}
}
-%apply SWIGTYPE * { const char* val, const char* another_value } // use default pointer handling instead of strings
+// use default pointer handling instead of strings
+%apply SWIGTYPE * { const char* val, const char* another_value }
%typemap(check) const char* val = char* NON_NULL;
@@ -3296,7 +3299,8 @@ SWIG can detect when the "optimal" attribute cannot be used and will ignore it a
<div class="targetlang">
<pre>
example.i:28: Warning 474: Method XX::create() usage of the optimal attribute ignored
-example.i:14: Warning 474: in the out typemap as the following cannot be used to generate optimal code:
+example.i:14: Warning 474: in the out typemap as the following cannot be used to generate
+optimal code:
try {
result = XX::create();
} catch(const std::exception &amp;e) {
@@ -3317,8 +3321,8 @@ In fact SWIG attempts to detect this and will issue a warning something like:
<div class="targetlang">
<pre>
-example.i:21: Warning 475: Multiple calls to XX::create() might be generated due to optimal attribute usage in
-example.i:7: Warning 475: the out typemap.
+example.i:21: Warning 475: Multiple calls to XX::create() might be generated due to
+example.i:7: Warning 475: optimal attribute usage in the out typemap.
</pre>
</div>
diff --git a/Doc/Manual/Warnings.html b/Doc/Manual/Warnings.html
index 96e35902a..325bf2f5f 100644
--- a/Doc/Manual/Warnings.html
+++ b/Doc/Manual/Warnings.html
@@ -25,7 +25,7 @@
<li><a href="#Warnings_nn12">C/C++ Parser (300-399)</a>
<li><a href="#Warnings_nn13">Types and typemaps (400-499) </a>
<li><a href="#Warnings_nn14">Code generation (500-599)</a>
-<li><a href="#Warnings_nn15">Language module specific (800-899) </a>
+<li><a href="#Warnings_nn15">Language module specific (700-899) </a>
<li><a href="#Warnings_nn16">User defined (900-999)</a>
</ul>
<li><a href="#Warnings_nn17">History</a>
@@ -513,9 +513,10 @@ example.i(4) : Syntax error in input.
<li>517.
<li>518. Portability warning: File <em>file1</em> will be overwritten by <em>file2</em> on case insensitive filesystems such as Windows' FAT32 and NTFS unless the class/module name is renamed.
<li>519. %template() contains no name. Template method ignored: <em>declaration</em>
+<li>520. <em>Base/Derived</em> class '<em>classname1</em>' of '<em>classname2</em>' is not similarly marked as a smart pointer.
</ul>
-<H3><a name="Warnings_nn15"></a>14.9.6 Language module specific (800-899) </H3>
+<H3><a name="Warnings_nn15"></a>14.9.6 Language module specific (700-899) </H3>
<ul>
diff --git a/Doc/Manual/chapters b/Doc/Manual/chapters
index cd399996b..924c8cfde 100644
--- a/Doc/Manual/chapters
+++ b/Doc/Manual/chapters
@@ -17,6 +17,7 @@ CCache.html
Allegrocl.html
CSharp.html
Chicken.html
+D.html
Go.html
Guile.html
Java.html
@@ -30,8 +31,7 @@ Perl5.html
Php.html
Pike.html
Python.html
+R.html
Ruby.html
Tcl.html
-R.html
Extending.html
-
diff --git a/Doc/Manual/linkchecker.config b/Doc/Manual/linkchecker.config
new file mode 100644
index 000000000..a947b278a
--- /dev/null
+++ b/Doc/Manual/linkchecker.config
@@ -0,0 +1,5 @@
+[checking]
+anchors=1
+
+[filtering]
+ignorewarnings=http-robots-denied
diff --git a/Doc/Manual/makechap.py b/Doc/Manual/makechap.py
index 4dd048c36..8225bfc79 100644
--- a/Doc/Manual/makechap.py
+++ b/Doc/Manual/makechap.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python
+#!/usr/bin/env python
###############################################################################
# Takes a chapter as input and adds internal links and numbering to all
diff --git a/Doc/Manual/maketoc.py b/Doc/Manual/maketoc.py
index c78bcfd13..d8c4aa759 100644
--- a/Doc/Manual/maketoc.py
+++ b/Doc/Manual/maketoc.py
@@ -1,4 +1,4 @@
-#!/usr/local/bin/python
+#!/usr/bin/env python
import sys
import os
@@ -12,7 +12,7 @@ print >>f, """
<TITLE>SWIG Users Manual</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
-<H1>SWIG Users Manual</H1>
+<H1><a name="Contents"></a>SWIG Users Manual</H1>
<p>
"""
diff --git a/Examples/Makefile.in b/Examples/Makefile.in
index 06965fa29..9641103c4 100644
--- a/Examples/Makefile.in
+++ b/Examples/Makefile.in
@@ -69,7 +69,7 @@ IOBJS = $(IWRAP:.i=.@OBJEXT@)
CPP_DLLIBS = #-L/usr/local/lib/gcc-lib/sparc-sun-solaris2.5.1/2.7.2 \
-L/usr/local/lib -lg++ -lstdc++ -lgcc
-# Solaris workshop 5.0
+# Solaris workshop 5.0
# CPP_DLLIBS = -L/opt/SUNWspro/lib -lCrun
# Symbols used for using shared libraries
@@ -159,7 +159,7 @@ tcl_cpp: $(SRCS)
# -----------------------------------------------------------------
tcl_clean:
- rm -f *_wrap* *~ .~* mytclsh@EXEEXT@
+ rm -f *_wrap* *~ .~* mytclsh@EXEEXT@
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@
@@ -296,9 +296,9 @@ python_static_cpp: $(SRCS)
$(CXX) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES) \
$(PYTHON_INCLUDE) $(LIBS) -L$(PYTHON_LIB) $(PYTHON_LIBOPTS) -o $(TARGET)
-# -----------------------------------------------------------------
+# -----------------------------------------------------------------
# Running a Python example
-# -----------------------------------------------------------------
+# -----------------------------------------------------------------
ifeq (,$(PY3))
PYSCRIPT = runme.py
@@ -313,7 +313,7 @@ python_run: $(PYSCRIPT)
runme3.py: runme.py
cp $< $@
- $(PY2TO3) -w $@ >/dev/null 2>&1
+ $(PY2TO3) -w $@ >/dev/null 2>&1
# -----------------------------------------------------------------
# Cleaning the python examples
@@ -332,7 +332,7 @@ python_clean:
# Make sure these locate your Octave installation
OCTAVE_INCLUDE= $(DEFS) @OCTAVEEXT@
-OCTAVE_LIB =
+OCTAVE_LIB =
# Extra Octave specific dynamic linking options
OCTAVE_DLNK = @OCTAVEDYNAMICLINKING@
@@ -548,14 +548,14 @@ mzscheme: $(SRCS)
mzscheme_cpp: $(SRCS)
$(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACEPATH)
$(COMPILETOOL) $(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS)
- $(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
+ $(CXXSHARED) $(CFLAGS) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
# -----------------------------------------------------------------
# Cleaning the mzscheme examples
# -----------------------------------------------------------------
mzscheme_clean:
- rm -f *_wrap* *~ .~*
+ rm -f *_wrap* *~ .~*
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@
@@ -632,7 +632,7 @@ ocaml_static_cpp: $(SRCS)
$(OCAMLCORE)
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
- $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
+ $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
$(OCC) -g -c $(INTERFACE:%.i=%.ml)
@@ -643,13 +643,13 @@ ocaml_static_cpp: $(SRCS)
$(INTERFACE:%.i=%.cmo) \
$(PROGFILE:%.ml=%.cmo) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
- -cclib "$(LIBS)" -cc '$(CXX)'
+ -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
ocaml_static_cpp_toplevel: $(SRCS)
$(OCAMLCORE)
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
- $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
+ $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS)
$(OCC) -g -c $(INTERFACE:%.i=%.mli)
$(OCC) -g -c $(INTERFACE:%.i=%.ml)
@@ -657,17 +657,17 @@ ocaml_static_cpp_toplevel: $(SRCS)
$(OCC) $(OCAMLPP) -c $(PROGFILE)
$(NOLINK) || $(OCAMLMKTOP) \
swig.cmo \
- -I $(OCAMLP4WHERE) camlp4o.cma swigp4.cmo \
+ -I $(OCAMLP4WHERE) dynlink.cma camlp4o.cma swigp4.cmo \
-g -ccopt -g -cclib -g -custom -o $(TARGET)_top \
$(INTERFACE:%.i=%.cmo) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
- -cclib "$(LIBS)" -cc '$(CXX)'
+ -cclib "$(LIBS)" -cc '$(CXX) -Wno-write-strings'
ocaml_dynamic_cpp: $(SRCS)
$(OCAMLCORE)
$(SWIG) -ocaml -c++ $(SWIGOPT) $(INTERFACEPATH)
cp $(ICXXSRCS) $(ICXXSRCS:%.cxx=%.c)
- $(OCC) -cc '$(CXX)' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
+ $(OCC) -cc '$(CXX) -Wno-write-strings' -g -c -ccopt -g -ccopt "-xc++ $(INCLUDES)" \
$(ICXXSRCS:%.cxx=%.c) $(SRCS) $(CXXSRCS) -ccopt -fPIC
$(CXXSHARED) $(CFLAGS) -o $(INTERFACE:%.i=%@SO@) \
$(INTERFACE:%.i=%_wrap.@OBJEXT@) $(OBJS) \
@@ -684,7 +684,7 @@ ocaml_dynamic_cpp: $(SRCS)
$(OCC) -cclib -export-dynamic -g -ccopt -g -cclib -g -custom \
-o $(TARGET) \
-package dl -linkpkg \
- $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX)'
+ $(INTERFACE:%.i=%.cmo) $(PROGFILE:%.ml=%.cmo) -cc '$(CXX) -Wno-write-strings'
ocaml_clean:
rm -f *_wrap* *~ .~* *.cmo *.cmi $(MLFILE) $(MLFILE)i swig.mli swig.cmi swig.ml swig.cmo swigp4.ml swigp4.cmo
@@ -844,7 +844,7 @@ pike_cpp_static: $(SRCS)
# -----------------------------------------------------------------
pike_clean:
- rm -f *_wrap* *~ .~* mypike@EXEEXT@
+ rm -f *_wrap* *~ .~* mypike@EXEEXT@
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *@SO@
@@ -861,7 +861,7 @@ CHICKEN_CFLAGS = @CHICKENOPTS@
CHICKENOPTS = -quiet
CHICKEN_MAIN =
-# SWIG produces $(ISRCS) (the C wrapper file)
+# SWIG produces $(ISRCS) (the C wrapper file)
# and $(CHICKEN_GENERATED_SCHEME) (the Scheme wrapper file):
CHICKEN_GENERATED_SCHEME = $(INTERFACE:.i=.scm)
CHICKEN_COMPILED_SCHEME = $(INTERFACE:.i=_chicken.c)
@@ -1053,12 +1053,12 @@ lua_clean:
allegrocl: $(SRCS)
$(SWIG) -allegrocl -cwrap $(SWIGOPT) $(INTERFACEPATH)
- $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
$(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
allegrocl_cpp: $(SRCS)
$(SWIG) -c++ -allegrocl $(SWIGOPT) $(INTERFACEPATH)
- $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
allegrocl_clean:
@@ -1087,12 +1087,12 @@ clisp_clean:
cffi: $(SRCS)
$(SWIG) -cffi $(SWIGOPT) $(INTERFACEPATH)
-# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
+# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
# $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
cffi_cpp: $(SRCS)
$(SWIG) -c++ -cffi $(SWIGOPT) $(INTERFACEPATH)
- $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
$(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
cffi_clean:
@@ -1106,12 +1106,12 @@ cffi_clean:
uffi: $(SRCS)
$(SWIG) -uffi $(SWIGOPT) $(INTERFACEPATH)
-# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
+# $(CC) -c $(CCSHARED) $(CFLAGS) $(ISRCS) $(INCLUDES) $(SRCS)
# $(LDSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
uffi_cpp: $(SRCS)
$(SWIG) -c++ -uffi $(SWIGOPT) $(INTERFACEPATH)
-# $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
+# $(CXX) -c $(CCSHARED) $(CFLAGS) $(ICXXSRCS) $(SRCS) $(CXXSRCS) $(INCLUDES)
# $(CXXSHARED) $(CFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(LIBPREFIX)$(TARGET)$(SO)
uffi_clean:
@@ -1241,3 +1241,69 @@ go_clean:
rm -f *_wrap* *_gc* .~* runme
rm -f core @EXTRA_CLEAN@
rm -f *.@OBJEXT@ *.[568] *.a *@SO@
+
+##################################################################
+##### D ######
+##################################################################
+
+DLIBPREFIX = @DLIBPREFIX@
+
+ifeq (,$(D_VERSION))
+ D_VERSION = @DDEFAULTVERSION@
+endif
+
+ifeq (2,$(D_VERSION))
+ SWIGD = $(SWIG) -d -d2
+ DCOMPILER = @D2COMPILER@
+else
+ SWIGD = $(SWIG) -d
+ DCOMPILER = @D1COMPILER@
+endif
+
+ifeq (dmd,$(DCOMPILER))
+ # DMD is 32bit only by now
+ DCFLAGS = -m32
+endif
+
+# ----------------------------------------------------------------
+# Build a dynamically loadable D wrapper for a C module
+# ----------------------------------------------------------------
+
+d: $(SRCS)
+ $(SWIGD) $(SWIGOPT) $(INTERFACEPATH)
+ $(CC) -c $(CCSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(ISRCS) $(INCLUDES)
+ $(LDSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
+
+# ----------------------------------------------------------------
+# Build a dynamically loadable D wrapper for a C++ module
+# ----------------------------------------------------------------
+
+d_cpp: $(SRCS)
+ $(SWIGD) -c++ $(SWIGOPT) $(INTERFACEPATH)
+ $(CXX) -c $(CCSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_CFLAGS) $(SRCS) $(CXXSRCS) $(ICXXSRCS) $(INCLUDES)
+ $(CXXSHARED) $(CFLAGS) $(DCFLAGS) $(EXTRA_LDFLAGS) $(OBJS) $(IOBJS) $(LIBS) $(CPP_DLLIBS) -o $(DLIBPREFIX)$(TARGET)$(SO)
+
+# ----------------------------------------------------------------
+# Compile D files
+# ----------------------------------------------------------------
+
+# Clear the DFLAGS environment variable for the compiler call itself
+# to work around a discrepancy in argument handling between DMD and LDC.
+d_compile: $(SRCS)
+ DFLAGS="" $(COMPILETOOL) $(DCOMPILER) $(DFLAGS) $(DSRCS)
+
+# -----------------------------------------------------------------
+# Run D example
+# -----------------------------------------------------------------
+
+d_run:
+ env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./runme
+
+# -----------------------------------------------------------------
+# Clean the D examples
+# -----------------------------------------------------------------
+
+d_clean:
+ rm -f *_wrap* *~ .~* runme runme.exe `find . -name \*.d | grep -v runme.d`
+ rm -f core @EXTRA_CLEAN@
+ rm -f *.@OBJEXT@ *@SO@
diff --git a/Examples/d/callback/Makefile b/Examples/d/callback/Makefile
new file mode 100644
index 000000000..b5808cf0d
--- /dev/null
+++ b/Examples/d/callback/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
+EXTRA_LDFLAGS = example.o example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/callback/d1/runme.d b/Examples/d/callback/d1/runme.d
new file mode 100644
index 000000000..e34e09603
--- /dev/null
+++ b/Examples/d/callback/d1/runme.d
@@ -0,0 +1,36 @@
+module runme;
+
+import tango.io.Stdout;
+import example;
+
+public class DCallback : Callback {
+ public override void run() {
+ Stdout( "DCallback.run()" ).newline;
+ }
+}
+
+void main() {
+ auto caller = new Caller();
+
+ Stdout( "Adding and calling a normal C++ callback" ).newline;
+ Stdout( "----------------------------------------" ).newline;
+ {
+ scope auto callback = new Callback();
+ caller.setCallback(callback);
+ caller.call();
+ caller.resetCallback();
+ }
+
+ Stdout.newline;
+ Stdout( "Adding and calling a D callback" ).newline;
+ Stdout( "-------------------------------" ).newline;
+ {
+ scope auto callback = new DCallback();
+ caller.setCallback(callback);
+ caller.call();
+ caller.resetCallback();
+ }
+
+ Stdout.newline;
+ Stdout( "D exit" ).newline;
+}
diff --git a/Examples/d/callback/d2/runme.d b/Examples/d/callback/d2/runme.d
new file mode 100644
index 000000000..88ffcdefd
--- /dev/null
+++ b/Examples/d/callback/d2/runme.d
@@ -0,0 +1,36 @@
+module runme;
+
+import std.stdio;
+import example;
+
+public class DCallback : Callback {
+ public override void run() {
+ writeln( "DCallback.run()" );
+ }
+}
+
+void main() {
+ auto caller = new Caller();
+
+ writeln( "Adding and calling a normal C++ callback" );
+ writeln( "----------------------------------------" );
+ {
+ scope auto callback = new Callback();
+ caller.setCallback(callback);
+ caller.call();
+ caller.resetCallback();
+ }
+
+ writeln();
+ writeln( "Adding and calling a D callback" );
+ writeln( "-------------------------------" );
+ {
+ scope auto callback = new DCallback();
+ caller.setCallback(callback);
+ caller.call();
+ caller.resetCallback();
+ }
+
+ writeln();
+ writeln( "D exit" );
+}
diff --git a/Examples/d/callback/example.cxx b/Examples/d/callback/example.cxx
new file mode 100644
index 000000000..450d75608
--- /dev/null
+++ b/Examples/d/callback/example.cxx
@@ -0,0 +1,4 @@
+/* File : example.cxx */
+
+#include "example.h"
+
diff --git a/Examples/d/callback/example.h b/Examples/d/callback/example.h
new file mode 100644
index 000000000..38d25a043
--- /dev/null
+++ b/Examples/d/callback/example.h
@@ -0,0 +1,24 @@
+/* File : example.h */
+
+#include <cstdio>
+#include <iostream>
+
+class Callback {
+public:
+ virtual ~Callback() { std::cout << "Callback::~Callback()" << std:: endl; }
+ virtual void run() { std::cout << "Callback::run()" << std::endl; }
+};
+
+
+class Caller {
+private:
+ Callback *_callback;
+public:
+ Caller(): _callback(0) {}
+ ~Caller() { delCallback(); }
+ void delCallback() { delete _callback; _callback = 0; }
+ void setCallback(Callback *cb) { delCallback(); _callback = cb; }
+ void resetCallback() { _callback = 0; }
+ void call() { if (_callback) _callback->run(); }
+};
+
diff --git a/Examples/d/callback/example.i b/Examples/d/callback/example.i
new file mode 100644
index 000000000..90beda01a
--- /dev/null
+++ b/Examples/d/callback/example.i
@@ -0,0 +1,13 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_string.i"
+
+/* turn on director wrapping Callback */
+%feature("director") Callback;
+
+%include "example.h"
+
diff --git a/Examples/d/check.list b/Examples/d/check.list
new file mode 100644
index 000000000..010e7bbfc
--- /dev/null
+++ b/Examples/d/check.list
@@ -0,0 +1,9 @@
+# See top-level Makefile.in.
+callback
+class
+constants
+enum
+extend
+funcptr
+simple
+variables
diff --git a/Examples/d/class/Makefile b/Examples/d/class/Makefile
new file mode 100644
index 000000000..b5808cf0d
--- /dev/null
+++ b/Examples/d/class/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
+EXTRA_LDFLAGS = example.o example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/class/d1/runme.d b/Examples/d/class/d1/runme.d
new file mode 100644
index 000000000..b0c4263a2
--- /dev/null
+++ b/Examples/d/class/d1/runme.d
@@ -0,0 +1,58 @@
+// This example illustrates how C++ classes can be used from D using SWIG.
+// The D class gets mapped onto the C++ class and behaves as if it is a D class.
+module runme;
+
+import tango.io.Stdout;
+import example;
+
+void main() {
+ // ----- Object creation -----
+
+ Stdout( "Creating some objects:" ).newline;
+
+ {
+ scope Square s = new Square(10);
+ scope Circle c = new Circle(10);
+
+ // ----- Access a static member -----
+ Stdout.format( "{} shapes were created.", Shape.nshapes ).newline;
+
+ // ----- Member data access -----
+
+ // Notice how we can do this using functions specific to
+ // the 'Circle' class.
+ c.x = 20;
+ c.y = 30;
+
+ // Now use the same functions in the base class
+ Shape shape = s;
+ shape.x = -10;
+ shape.y = 5;
+
+ Stdout( "\nHere is their current position:" ).newline;
+ Stdout.format( " Circle = ( {}, {} )", c.x, c.y ).newline;
+ Stdout.format( " Square = ( {}, {} )", s.x, s.y ).newline;
+
+ // ----- Call some methods -----
+
+ Stdout( "\nHere are some properties of the shapes:" ).newline;
+ Shape[] shapes = [ cast(Shape) c, cast(Shape) s ];
+ foreach ( currentShape; shapes )
+ {
+ Stdout.format( " {}", currentShape.classinfo.name ).newline;
+ Stdout.format( " area = {}", currentShape.area() ).newline;
+ Stdout.format( " perimeter = {}", currentShape.perimeter() ).newline;
+ }
+
+ // Notice how the area() and perimeter() functions really
+ // invoke the appropriate virtual method on each object.
+
+ // ----- Delete everything -----
+ Stdout( "\nGuess I'll clean up now:" ).newline;
+ // Note: when this using scope is exited the D destructors are called which
+ // in turn call the C++ destructors.
+ }
+
+ Stdout.format( "{} shapes remain", Shape.nshapes ).newline;
+ Stdout( "\nGoodbye!" ).newline;
+}
diff --git a/Examples/d/class/d2/runme.d b/Examples/d/class/d2/runme.d
new file mode 100644
index 000000000..2e86c5fc7
--- /dev/null
+++ b/Examples/d/class/d2/runme.d
@@ -0,0 +1,58 @@
+// This example illustrates how C++ classes can be used from D using SWIG.
+// The D class gets mapped onto the C++ class and behaves as if it is a D class.
+module runme;
+
+import std.stdio;
+import example;
+
+void main() {
+ // ----- Object creation -----
+
+ writeln( "Creating some objects:" );
+
+ {
+ scope Square s = new Square(10);
+ scope Circle c = new Circle(10);
+
+ // ----- Access a static member -----
+ writefln( "%s shapes were created.", Shape.nshapes );
+
+ // ----- Member data access -----
+
+ // Notice how we can do this using functions specific to
+ // the 'Circle' class.
+ c.x = 20;
+ c.y = 30;
+
+ // Now use the same functions in the base class
+ Shape shape = s;
+ shape.x = -10;
+ shape.y = 5;
+
+ writeln( "\nHere is their current position:" );
+ writefln( " Circle = ( %s, %s )", c.x, c.y );
+ writefln( " Square = ( %s, %s )", s.x, s.y );
+
+ // ----- Call some methods -----
+
+ writeln( "\nHere are some properties of the shapes:" );
+ Shape[] shapes = [ cast(Shape) c, cast(Shape) s ];
+ foreach ( currentShape; shapes )
+ {
+ writefln( " %s", currentShape.classinfo.name );
+ writefln( " area = %s", currentShape.area() );
+ writefln( " perimeter = %s", currentShape.perimeter() );
+ }
+
+ // Notice how the area() and perimeter() functions really
+ // invoke the appropriate virtual method on each object.
+
+ // ----- Delete everything -----
+ writeln( "\nGuess I'll clean up now:" );
+ // Note: when this using scope is exited the D destructors are called which
+ // in turn call the C++ destructors.
+ }
+
+ writefln( "%s shapes remain", Shape.nshapes );
+ writeln( "\nGoodbye!" );
+}
diff --git a/Examples/d/class/example.cxx b/Examples/d/class/example.cxx
new file mode 100644
index 000000000..1e8e203dd
--- /dev/null
+++ b/Examples/d/class/example.cxx
@@ -0,0 +1,28 @@
+/* File : example.c */
+
+#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(void) {
+ return M_PI*radius*radius;
+}
+
+double Circle::perimeter(void) {
+ return 2*M_PI*radius;
+}
+
+double Square::area(void) {
+ return width*width;
+}
+
+double Square::perimeter(void) {
+ return 4*width;
+}
diff --git a/Examples/d/class/example.h b/Examples/d/class/example.h
new file mode 100644
index 000000000..0d4527e92
--- /dev/null
+++ b/Examples/d/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(void) = 0;
+ virtual double perimeter(void) = 0;
+ static int nshapes;
+};
+
+class Circle : public Shape {
+private:
+ double radius;
+public:
+ Circle(double r) : radius(r) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
+
+class Square : public Shape {
+private:
+ double width;
+public:
+ Square(double w) : width(w) { };
+ virtual double area(void);
+ virtual double perimeter(void);
+};
diff --git a/Examples/d/class/example.i b/Examples/d/class/example.i
new file mode 100644
index 000000000..75700b305
--- /dev/null
+++ b/Examples/d/class/example.i
@@ -0,0 +1,10 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+%include "example.h"
+
diff --git a/Examples/d/constants/Makefile b/Examples/d/constants/Makefile
new file mode 100644
index 000000000..412055243
--- /dev/null
+++ b/Examples/d/constants/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ example_wrap.c
+EXTRA_LDFLAGS = example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/constants/d1/runme.d b/Examples/d/constants/d1/runme.d
new file mode 100644
index 000000000..47362cbf3
--- /dev/null
+++ b/Examples/d/constants/d1/runme.d
@@ -0,0 +1,28 @@
+module runme;
+
+import tango.io.Stdout;
+static import example;
+
+void main() {
+ Stdout.formatln("ICONST = {} (should be 42)", example.ICONST);
+ Stdout.formatln("FCONST = {} (should be 2.18)", example.FCONST);
+ Stdout.formatln("CCONST = {} (should be 'x')", example.CCONST);
+ Stdout.formatln("CCONST2 = {} (this should be on a new line)", example.CCONST2);
+ Stdout.formatln("SCONST = {} (should be 'Hello World')", example.SCONST);
+ Stdout.formatln("SCONST2 = {} (should be '\"Hello World\"')", example.SCONST2);
+ Stdout.formatln("EXPR = {} (should be 48.55)", example.EXPR);
+ Stdout.formatln("iconst = {} (should be 37)", example.iconst);
+ Stdout.formatln("fconst = {} (should be 3.14)", example.fconst);
+
+ static if (is(typeof(example.EXTERN))) {
+ Stdout.formatln("EXTERN should not be defined, but is: {}.", example.EXTERN );
+ } else {
+ Stdout.formatln("EXTERN isn't defined (good)");
+ }
+
+ static if (is(typeof(example.FOO))) {
+ Stdout.formatln("FOO should not be defined, but is: {}.", example.FOO);
+ } else {
+ Stdout.formatln("FOO isn't defined (good)");
+ }
+}
diff --git a/Examples/d/constants/d2/runme.d b/Examples/d/constants/d2/runme.d
new file mode 100644
index 000000000..4be510d16
--- /dev/null
+++ b/Examples/d/constants/d2/runme.d
@@ -0,0 +1,28 @@
+module runme;
+
+import std.stdio;
+static import example;
+
+void main() {
+ writefln("ICONST = %s (should be 42)", example.ICONST);
+ writefln("FCONST = %s (should be 2.1828)", example.FCONST);
+ writefln("CCONST = %s (should be 'x')", example.CCONST);
+ writefln("CCONST2 = %s (this should be on a new line)", example.CCONST2);
+ writefln("SCONST = %s (should be 'Hello World')", example.SCONST);
+ writefln("SCONST2 = %s (should be '\"Hello World\"')", example.SCONST2);
+ writefln("EXPR = %s (should be 48.5484)", example.EXPR);
+ writefln("iconst = %s (should be 37)", example.iconst);
+ writefln("fconst = %s (should be 3.14)", example.fconst);
+
+ static if (is(typeof(example.EXTERN))) {
+ writefln("EXTERN should not be defined, but is: %s.", example.EXTERN );
+ } else {
+ writeln("EXTERN isn't defined (good)");
+ }
+
+ static if (is(typeof(example.FOO))) {
+ writefln("FOO should not be defined, but is: %s.", example.FOO);
+ } else {
+ writeln("FOO isn't defined (good)");
+ }
+}
diff --git a/Examples/d/constants/example.d b/Examples/d/constants/example.d
new file mode 100644
index 000000000..7448d0ad9
--- /dev/null
+++ b/Examples/d/constants/example.d
@@ -0,0 +1,23 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.41
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+module example;
+
+static import example_wrap;
+
+static import tango.stdc.stringz;
+
+public const int ICONST = 42;
+public const double FCONST = 2.1828;
+public const char CCONST = 'x';
+public const char CCONST2 = '\n';
+public const char[] SCONST = "Hello World";
+public const char[] SCONST2 = "\"Hello World\"";
+public const double EXPR = 42+3*(2.1828);
+public const int iconst = 37;
+public const double fconst = 3.14;
diff --git a/Examples/d/constants/example.i b/Examples/d/constants/example.i
new file mode 100644
index 000000000..edeb258cd
--- /dev/null
+++ b/Examples/d/constants/example.i
@@ -0,0 +1,32 @@
+/* File : example.i */
+%module example
+
+/* Force the generated D code to use the C constant values rather than
+ retrieving them at runtime. You can also try disabling the feature and
+ compare the generated code. */
+%dmanifestconst;
+
+
+/* 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/d/enum/Makefile b/Examples/d/enum/Makefile
new file mode 100644
index 000000000..b5808cf0d
--- /dev/null
+++ b/Examples/d/enum/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
+EXTRA_LDFLAGS = example.o example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/enum/d1/runme.d b/Examples/d/enum/d1/runme.d
new file mode 100644
index 000000000..d986986d1
--- /dev/null
+++ b/Examples/d/enum/d1/runme.d
@@ -0,0 +1,28 @@
+module runme;
+
+import tango.io.Stdout;
+import example;
+
+void main() {
+ Stdout( "Printing out some enum values:" ).newline;
+ Stdout(" color:").newline;
+ Stdout.formatln(" {} = {}", color.RED, cast(int)color.RED);
+ Stdout.formatln(" {} = {}", color.BLUE, cast(int)color.BLUE);
+ Stdout.formatln(" {} = {}", color.GREEN, cast(int)color.GREEN);
+
+ Stdout("\n Foo.speed:").newline;
+ Stdout.formatln(" Foo.{} = {}", Foo.speed.IMPULSE, cast(int)Foo.speed.IMPULSE);
+ Stdout.formatln(" Foo.{} = {}", Foo.speed.WARP, cast(int)Foo.speed.WARP);
+ Stdout.formatln(" Foo.{} = {}", Foo.speed.LUDICROUS , cast(int)Foo.speed.LUDICROUS);
+
+ Stdout("\nTesting use of enums with functions:").newline;
+ example.enum_test(color.RED, Foo.speed.IMPULSE);
+ example.enum_test(color.BLUE, Foo.speed.WARP);
+ example.enum_test(color.GREEN, Foo.speed.LUDICROUS);
+
+ Stdout( "\nTesting use of enum with class method:" ).newline;
+ scope f = new Foo();
+ f.enum_test(Foo.speed.IMPULSE);
+ f.enum_test(Foo.speed.WARP);
+ f.enum_test(Foo.speed.LUDICROUS);
+}
diff --git a/Examples/d/enum/d2/runme.d b/Examples/d/enum/d2/runme.d
new file mode 100644
index 000000000..acaec8ae8
--- /dev/null
+++ b/Examples/d/enum/d2/runme.d
@@ -0,0 +1,28 @@
+module runme;
+
+import std.stdio;
+import example;
+
+void main() {
+ writeln( "Printing out some enum values:" );
+ writeln(" color:");
+ writefln(" %s = %s", color.RED, cast(int)color.RED);
+ writefln(" %s = %s", color.BLUE, cast(int)color.BLUE);
+ writefln(" %s = %s", color.GREEN, cast(int)color.GREEN);
+
+ writeln("\n Foo.speed:");
+ writefln(" Foo.%s = %s", Foo.speed.IMPULSE, cast(int)Foo.speed.IMPULSE);
+ writefln(" Foo.%s = %s", Foo.speed.WARP, cast(int)Foo.speed.WARP);
+ writefln(" Foo.%s = %s", Foo.speed.LUDICROUS , cast(int)Foo.speed.LUDICROUS);
+
+ writeln("\nTesting use of enums with functions:");
+ example.enum_test(color.RED, Foo.speed.IMPULSE);
+ example.enum_test(color.BLUE, Foo.speed.WARP);
+ example.enum_test(color.GREEN, Foo.speed.LUDICROUS);
+
+ writeln( "\nTesting use of enum with class method:" );
+ scope f = new Foo();
+ f.enum_test(Foo.speed.IMPULSE);
+ f.enum_test(Foo.speed.WARP);
+ f.enum_test(Foo.speed.LUDICROUS);
+}
diff --git a/Examples/d/enum/example.cxx b/Examples/d/enum/example.cxx
new file mode 100644
index 000000000..df7bb6328
--- /dev/null
+++ b/Examples/d/enum/example.cxx
@@ -0,0 +1,37 @@
+/* File : example.cxx */
+
+#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/d/enum/example.h b/Examples/d/enum/example.h
new file mode 100644
index 000000000..9119cd9fc
--- /dev/null
+++ b/Examples/d/enum/example.h
@@ -0,0 +1,13 @@
+/* File : example.h */
+
+enum color { RED, BLUE, GREEN };
+
+class Foo {
+ public:
+ Foo() { }
+ enum speed { IMPULSE=10, WARP=20, LUDICROUS=30 };
+ void enum_test(speed s);
+};
+
+void enum_test(color c, Foo::speed s);
+
diff --git a/Examples/d/enum/example.i b/Examples/d/enum/example.i
new file mode 100644
index 000000000..23ee8a822
--- /dev/null
+++ b/Examples/d/enum/example.i
@@ -0,0 +1,11 @@
+/* File : example.i */
+%module example
+
+%{
+#include "example.h"
+%}
+
+/* Let's just grab the original header file here */
+
+%include "example.h"
+
diff --git a/Examples/d/extend/Makefile b/Examples/d/extend/Makefile
new file mode 100644
index 000000000..b5808cf0d
--- /dev/null
+++ b/Examples/d/extend/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ ../example.cxx example_wrap.cxx
+EXTRA_LDFLAGS = example.o example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d_cpp; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/extend/d1/runme.d b/Examples/d/extend/d1/runme.d
new file mode 100644
index 000000000..96501d1a4
--- /dev/null
+++ b/Examples/d/extend/d1/runme.d
@@ -0,0 +1,75 @@
+/// This file illustrates the cross language polymorphism using directors.
+module runme;
+
+import example;
+import tango.io.Stdout;
+
+// CEO class, which overrides Employee.getPosition().
+class CEO : Manager {
+public:
+ this( char[] name ) {
+ super( name );
+ }
+
+ override char[] getPosition() {
+ return "CEO";
+ }
+
+ // Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory.
+ void disownMemory() {
+ swigCMemOwn = false;
+ }
+}
+
+void main() {
+ // Create an instance of CEO, a class derived from the D proxy of the
+ // underlying C++ class. The calls to getName() and getPosition() are standard,
+ // the call to getTitle() uses the director wrappers to call CEO.getPosition().
+
+ auto e = new CEO( "Alice" );
+ Stdout.formatln( "{} is a {}.", e.getName(), e.getPosition() );
+ Stdout.formatln( "Just call her '{}'.", e.getTitle() );
+ Stdout( "----------------------" ).newline;
+
+ {
+ // Create a new EmployeeList instance. This class does not have a C++
+ // director wrapper, but can be used freely with other classes that do.
+ scope auto list = new EmployeeList();
+
+ // EmployeeList owns its items, so we must surrender ownership of objects we add.
+ e.disownMemory();
+ list.addEmployee(e);
+ Stdout( "----------------------" ).newline;
+
+ // Now we access the first four items in list (three are C++ objects that
+ // EmployeeList's constructor adds, the last is our CEO). The virtual
+ // methods of all these instances are treated the same. For items 0, 1, and
+ // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls
+ // getPosition which resolves in D. The call to getPosition is
+ // slightly different, however, because of the overidden getPosition() call, since
+ // now the object reference has been "laundered" by passing through
+ // EmployeeList as an Employee*. Previously, D resolved the call
+ // immediately in CEO, but now D thinks the object is an instance of
+ // class Employee. So the call passes through the
+ // Employee proxy class and on to the C wrappers and C++ director,
+ // eventually ending up back at the D CEO implementation of getPosition().
+ // The call to getTitle() for item 3 runs the C++ Employee::getTitle()
+ // method, which in turn calls getPosition(). This virtual method call
+ // passes down through the C++ director class to the D implementation
+ // in CEO. All this routing takes place transparently.
+
+ Stdout( "(position, title) for items 0-3:" ).newline;
+ Stdout.formatln( " {}, '{}'", list.getItem(0).getPosition(), list.getItem(0).getTitle() );
+ Stdout.formatln( " {}, '{}'", list.getItem(1).getPosition(), list.getItem(1).getTitle() );
+ Stdout.formatln( " {}, '{}'", list.getItem(2).getPosition(), list.getItem(2).getTitle() );
+ Stdout.formatln( " {}, '{}'", list.getItem(3).getPosition(), list.getItem(3).getTitle() );
+ Stdout( "----------------------" ).newline;
+
+ // All Employees will be destroyed when the EmployeeList goes out of scope,
+ // including the CEO instance.
+ }
+ Stdout( "----------------------" ).newline;
+
+ // All done.
+ Stdout( "Exiting cleanly from D code." ).newline;
+}
diff --git a/Examples/d/extend/d2/runme.d b/Examples/d/extend/d2/runme.d
new file mode 100644
index 000000000..1ea6dfd21
--- /dev/null
+++ b/Examples/d/extend/d2/runme.d
@@ -0,0 +1,75 @@
+/// This file illustrates the cross language polymorphism using directors.
+module runme;
+
+import std.stdio;
+import example;
+
+// CEO class, which overrides Employee.getPosition().
+class CEO : Manager {
+public:
+ this( string name ) {
+ super( name );
+ }
+
+ override string getPosition() const {
+ return "CEO";
+ }
+
+ // Public method to stop the SWIG proxy base class from thinking it owns the underlying C++ memory.
+ void disownMemory() {
+ swigCMemOwn = false;
+ }
+}
+
+void main() {
+ // Create an instance of CEO, a class derived from the D proxy of the
+ // underlying C++ class. The calls to getName() and getPosition() are standard,
+ // the call to getTitle() uses the director wrappers to call CEO.getPosition().
+
+ auto e = new CEO( "Alice" );
+ writefln( "%s is a %s.", e.getName(), e.getPosition() );
+ writefln( "Just call her '%s'.", e.getTitle() );
+ writeln( "----------------------" );
+
+ {
+ // Create a new EmployeeList instance. This class does not have a C++
+ // director wrapper, but can be used freely with other classes that do.
+ scope auto list = new EmployeeList();
+
+ // EmployeeList owns its items, so we must surrender ownership of objects we add.
+ e.disownMemory();
+ list.addEmployee(e);
+ writeln( "----------------------" );
+
+ // Now we access the first four items in list (three are C++ objects that
+ // EmployeeList's constructor adds, the last is our CEO). The virtual
+ // methods of all these instances are treated the same. For items 0, 1, and
+ // 2, all methods resolve in C++. For item 3, our CEO, getTitle calls
+ // getPosition which resolves in D. The call to getPosition is
+ // slightly different, however, because of the overidden getPosition() call, since
+ // now the object reference has been "laundered" by passing through
+ // EmployeeList as an Employee*. Previously, D resolved the call
+ // immediately in CEO, but now D thinks the object is an instance of
+ // class Employee. So the call passes through the
+ // Employee proxy class and on to the C wrappers and C++ director,
+ // eventually ending up back at the D CEO implementation of getPosition().
+ // The call to getTitle() for item 3 runs the C++ Employee::getTitle()
+ // method, which in turn calls getPosition(). This virtual method call
+ // passes down through the C++ director class to the D implementation
+ // in CEO. All this routing takes place transparently.
+
+ writeln( "(position, title) for items 0-3:" );
+ writefln( " %s, '%s'", list.getItem(0).getPosition(), list.getItem(0).getTitle() );
+ writefln( " %s, '%s'", list.getItem(1).getPosition(), list.getItem(1).getTitle() );
+ writefln( " %s, '%s'", list.getItem(2).getPosition(), list.getItem(2).getTitle() );
+ writefln( " %s, '%s'", list.getItem(3).getPosition(), list.getItem(3).getTitle() );
+ writeln( "----------------------" );
+
+ // All Employees will be destroyed when the EmployeeList goes out of scope,
+ // including the CEO instance.
+ }
+ writeln( "----------------------" );
+
+ // All done.
+ writeln( "Exiting cleanly from D code." );
+}
diff --git a/Examples/d/extend/example.cxx b/Examples/d/extend/example.cxx
new file mode 100644
index 000000000..450d75608
--- /dev/null
+++ b/Examples/d/extend/example.cxx
@@ -0,0 +1,4 @@
+/* File : example.cxx */
+
+#include "example.h"
+
diff --git a/Examples/d/extend/example.h b/Examples/d/extend/example.h
new file mode 100644
index 000000000..7ad93fbc1
--- /dev/null
+++ b/Examples/d/extend/example.h
@@ -0,0 +1,56 @@
+/* File : example.h */
+
+#include <cstdio>
+#include <iostream>
+#include <vector>
+#include <string>
+#include <cmath>
+
+class Employee {
+private:
+ std::string name;
+public:
+ Employee(const char* n): name(n) {}
+ virtual std::string getTitle() { return getPosition() + " " + getName(); }
+ virtual std::string getName() { return name; }
+ virtual std::string getPosition() const { return "Employee"; }
+ virtual ~Employee() { printf("~Employee() @ %p\n", this); }
+};
+
+
+class Manager: public Employee {
+public:
+ Manager(const char* n): Employee(n) {}
+ virtual std::string getPosition() const { return "Manager"; }
+};
+
+
+class EmployeeList {
+ std::vector<Employee*> list;
+public:
+ EmployeeList() {
+ list.push_back(new Employee("Bob"));
+ list.push_back(new Employee("Jane"));
+ list.push_back(new Manager("Ted"));
+ }
+ void addEmployee(Employee *p) {
+ list.push_back(p);
+ std::cout << "New employee added. Current employees are:" << std::endl;
+ std::vector<Employee*>::iterator i;
+ for (i=list.begin(); i!=list.end(); i++) {
+ std::cout << " " << (*i)->getTitle() << std::endl;
+ }
+ }
+ const Employee *getItem(int i) {
+ return list[i];
+ }
+ ~EmployeeList() {
+ std::vector<Employee*>::iterator i;
+ std::cout << "~EmployeeList, deleting " << list.size() << " employees." << std::endl;
+ for (i=list.begin(); i!=list.end(); i++) {
+ delete *i;
+ }
+ std::cout << "~EmployeeList empty." << std::endl;
+ }
+};
+
diff --git a/Examples/d/extend/example.i b/Examples/d/extend/example.i
new file mode 100644
index 000000000..0647e1319
--- /dev/null
+++ b/Examples/d/extend/example.i
@@ -0,0 +1,14 @@
+/* File : example.i */
+%module(directors="1") example
+%{
+#include "example.h"
+%}
+
+%include "std_string.i"
+
+/* turn on director wrapping for Manager */
+%feature("director") Employee;
+%feature("director") Manager;
+
+%include "example.h"
+
diff --git a/Examples/d/funcptr/Makefile b/Examples/d/funcptr/Makefile
new file mode 100644
index 000000000..09efa8d88
--- /dev/null
+++ b/Examples/d/funcptr/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ ../example.c example_wrap.c
+EXTRA_LDFLAGS = example.o example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/funcptr/d1/runme.d b/Examples/d/funcptr/d1/runme.d
new file mode 100644
index 000000000..1461c1546
--- /dev/null
+++ b/Examples/d/funcptr/d1/runme.d
@@ -0,0 +1,42 @@
+module runme;
+
+import tango.io.Stdout;
+static import example;
+
+extern(C) int add(int a, int b) {
+ return a + b;
+}
+
+extern(C) int sub(int a, int b) {
+ return a - b;
+}
+
+extern(C) int mul(int a, int b) {
+ return a * b;
+}
+
+void main() {
+ int a = 37;
+ int b = 42;
+
+ Stdout( "a = " )( a ).newline;
+ Stdout( "b = " )( b ).newline;
+
+ Stdout( "Trying some C callback functions:" ).newline;
+ Stdout( " ADD(a,b) = " )( example.do_op( a, b, example.ADD ) ).newline;
+ Stdout( " SUB(a,b) = " )( example.do_op( a, b, example.SUB ) ).newline;
+ Stdout( " MUL(a,b) = " )( example.do_op( a, b, example.MUL ) ).newline;
+
+ version (LDC) {
+ // Currently, there is no way to specify the calling convention for
+ // function pointer parameters in D, but LDC does strict typechecking for
+ // them (which is reasonable, but not covered by the language spec yet).
+ // As a result, there is no way to make the code below compile with LDC at
+ // the moment, so just skip it.
+ } else {
+ Stdout( "Now the same with callback functions defined in D:" ).newline;
+ Stdout( " add(a,b) = " )( example.do_op( a, b, &add ) ).newline;
+ Stdout( " sub(a,b) = " )( example.do_op( a, b, &sub ) ).newline;
+ Stdout( " mul(a,b) = " )( example.do_op( a, b, &mul ) ).newline;
+ }
+}
diff --git a/Examples/d/funcptr/d2/runme.d b/Examples/d/funcptr/d2/runme.d
new file mode 100644
index 000000000..929911d6c
--- /dev/null
+++ b/Examples/d/funcptr/d2/runme.d
@@ -0,0 +1,34 @@
+module runme;
+
+import std.stdio;
+static import example;
+
+extern(C) int add(int a, int b) {
+ return a + b;
+}
+
+extern(C) int sub(int a, int b) {
+ return a - b;
+}
+
+extern(C) int mul(int a, int b) {
+ return a * b;
+}
+
+void main() {
+ int a = 37;
+ int b = 42;
+
+ writefln( "a = %s", a );
+ writefln( "b = %s", b );
+
+ writeln( "Trying some C callback functions:" );
+ writefln( " ADD(a,b) = %s", example.do_op( a, b, example.ADD ) );
+ writefln( " SUB(a,b) = %s", example.do_op( a, b, example.SUB ) );
+ writefln( " MUL(a,b) = %s", example.do_op( a, b, example.MUL ) );
+
+ writeln( "Now the same with callback functions defined in D:" );
+ writefln( " add(a,b) = %s", example.do_op( a, b, &add ) );
+ writefln( " sub(a,b) = %s", example.do_op( a, b, &sub ) );
+ writefln( " mul(a,b) = %s", example.do_op( a, b, &mul ) );
+}
diff --git a/Examples/d/funcptr/example.c b/Examples/d/funcptr/example.c
new file mode 100644
index 000000000..5c4a3dabf
--- /dev/null
+++ b/Examples/d/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/d/funcptr/example.h b/Examples/d/funcptr/example.h
new file mode 100644
index 000000000..9936e24fc
--- /dev/null
+++ b/Examples/d/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/d/funcptr/example.i b/Examples/d/funcptr/example.i
new file mode 100644
index 000000000..8b3bef678
--- /dev/null
+++ b/Examples/d/funcptr/example.i
@@ -0,0 +1,16 @@
+/* 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));
+
+/* Now install a bunch of "ops" as constants */
+%constant int (*ADD)(int,int) = add;
+%constant int (*SUB)(int,int) = sub;
+%constant int (*MUL)(int,int) = mul;
+
+extern int (*funcvar)(int,int);
+
diff --git a/Examples/d/simple/Makefile b/Examples/d/simple/Makefile
new file mode 100644
index 000000000..ae173a566
--- /dev/null
+++ b/Examples/d/simple/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ ../example.c example_wrap.c
+EXTRA_LDFLAGS = example.o example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/simple/d1/runme.d b/Examples/d/simple/d1/runme.d
new file mode 100644
index 000000000..1293f1839
--- /dev/null
+++ b/Examples/d/simple/d1/runme.d
@@ -0,0 +1,27 @@
+module runme;
+
+import tango.io.Stdout;
+static import example;
+
+void main() {
+ /*
+ * Call our gcd() function.
+ */
+ int x = 42;
+ int y = 105;
+ int g = example.gcd( x, y );
+ Stdout.format( "The gcd of {} and {} is {}.", x, y, g ).newline;
+
+ /*
+ * Manipulate the Foo global variable.
+ */
+
+ // Output its current value
+ Stdout.format( "Foo = {}", example.Foo ).newline;
+
+ // Change its value
+ example.Foo = 3.1415926;
+
+ // See if the change took effect
+ Stdout.format( "Foo = {}", example.Foo ).newline;
+}
diff --git a/Examples/d/simple/d2/runme.d b/Examples/d/simple/d2/runme.d
new file mode 100644
index 000000000..7f278923b
--- /dev/null
+++ b/Examples/d/simple/d2/runme.d
@@ -0,0 +1,27 @@
+module runme;
+
+import std.stdio;
+static import example;
+
+void main() {
+ /*
+ * Call our gcd() function.
+ */
+ int x = 42;
+ int y = 105;
+ int g = example.gcd(x, y);
+ writefln("The gcd of %s and %s is %s.", x, y, g);
+
+ /*
+ * Manipulate the Foo global variable.
+ */
+
+ // Output its current value
+ writefln("Foo = %s", example.Foo);
+
+ // Change its value
+ example.Foo = 3.1415926;
+
+ // See if the change took effect
+ writefln("Foo = %s", example.Foo);
+}
diff --git a/Examples/d/simple/example.c b/Examples/d/simple/example.c
new file mode 100644
index 000000000..1c2af789c
--- /dev/null
+++ b/Examples/d/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/d/simple/example.i b/Examples/d/simple/example.i
new file mode 100644
index 000000000..24093b9bf
--- /dev/null
+++ b/Examples/d/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/d/variables/Makefile b/Examples/d/variables/Makefile
new file mode 100644
index 000000000..ae173a566
--- /dev/null
+++ b/Examples/d/variables/Makefile
@@ -0,0 +1,30 @@
+ifeq (2,$(D_VERSION))
+ WORKING_DIR = d2/
+else
+ WORKING_DIR = d1/
+endif
+
+TOP = ../../..
+SWIG = $(TOP)/../preinst-swig
+EXTRA_CFLAGS = -I../ ../example.c example_wrap.c
+EXTRA_LDFLAGS = example.o example_wrap.o
+TARGET = example_wrap
+SWIGOPT =
+DSRCS = *.d
+DFLAGS = -ofrunme
+
+
+all:: d
+
+d::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile EXTRA_CFLAGS='$(EXTRA_CFLAGS)' EXTRA_LDFLAGS='$(EXTRA_LDFLAGS)' SWIG='$(SWIG)' SWIGOPT='$(SWIGOPT) -outcurrentdir ../example.i' TARGET='$(TARGET)' d; \
+ $(MAKE) -f $(TOP)/Makefile DSRCS='$(DSRCS)' DFLAGS='$(DFLAGS)' d_compile
+
+clean::
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_clean
+
+check: all
+ cd $(WORKING_DIR); \
+ $(MAKE) -f $(TOP)/Makefile d_run
diff --git a/Examples/d/variables/d1/runme.d b/Examples/d/variables/d1/runme.d
new file mode 100644
index 000000000..35c896bdc
--- /dev/null
+++ b/Examples/d/variables/d1/runme.d
@@ -0,0 +1,71 @@
+// This example illustrates global variable access from C#.
+module runme;
+
+import tango.io.Stdout;
+static import example;
+
+void main() {
+ // Try to set the values of some global variables
+ example.ivar = 42;
+ example.svar = -31000;
+ example.lvar = 65537;
+ example.uivar = 123456;
+ example.usvar = 61000;
+ example.ulvar = 654321;
+ example.scvar = -13;
+ example.ucvar = 251;
+ example.cvar = 'S';
+ example.fvar = 3.14159f;
+ example.dvar = 2.1828;
+ example.strvar = "Hello World";
+ example.iptrvar = example.new_int(37);
+ example.ptptr = example.new_Point(37,42);
+ example.name = "Bill";
+
+ // Now print out the values of the variables
+ Stdout.formatln( "Variables (printed from D):" );
+ Stdout.formatln( "ivar = {}", example.ivar );
+ Stdout.formatln( "svar = {}", example.svar );
+ Stdout.formatln( "lvar = {}", example.lvar );
+ Stdout.formatln( "uivar = {}", example.uivar );
+ Stdout.formatln( "usvar = {}", example.usvar );
+ Stdout.formatln( "ulvar = {}", example.ulvar );
+ Stdout.formatln( "scvar = {}", example.scvar );
+ Stdout.formatln( "ucvar = {}", example.ucvar );
+ Stdout.formatln( "fvar = {}", example.fvar );
+ Stdout.formatln( "dvar = {}", example.dvar );
+ Stdout.formatln( "cvar = {}", example.cvar );
+ Stdout.formatln( "strvar = {}", example.strvar );
+ Stdout.formatln( "cstrvar = {}", example.cstrvar );
+ Stdout.formatln( "iptrvar = {}", example.iptrvar );
+ Stdout.formatln( "name = {}", example.name );
+ Stdout.formatln( "ptptr = {} {}", example.ptptr, example.Point_print(example.ptptr) );
+ Stdout.formatln( "pt = {} {}", example.pt, example.Point_print(example.pt) );
+ Stdout.formatln( "status = {}", example.status );
+
+ Stdout.formatln( "\nVariables (printed from the C library):" );
+ example.print_vars();
+
+ Stdout.formatln( "\nNow I'm going to try and modify some read only variables:" );
+ Stdout.formatln( "Checking that the read only variables are readonly..." );
+
+ Stdout( " 'path'..." );
+ static if ( is( typeof( example.path = "a" ) ) )
+ Stdout.formatln("Oh dear, this variable is not read only!");
+ else
+ Stdout.formatln("Good.");
+
+ Stdout( " 'status'..." );
+ static if ( is( typeof( example.status = 2 ) ) )
+ Stdout.formatln("Oh dear, this variable is not read only!");
+ else
+ Stdout.formatln("Good.");
+
+ Stdout.formatln( "\nI'm going to try and update a structure variable:" );
+
+ example.pt = example.ptptr;
+
+ Stdout( "The new value is " ).flush;
+ example.pt_print();
+ Stdout.formatln( "You should see the value {}", example.Point_print(example.ptptr) );
+}
diff --git a/Examples/d/variables/d2/runme.d b/Examples/d/variables/d2/runme.d
new file mode 100644
index 000000000..f80b81819
--- /dev/null
+++ b/Examples/d/variables/d2/runme.d
@@ -0,0 +1,71 @@
+// This example illustrates global variable access from C#.
+module runme;
+
+import std.stdio;
+static import example;
+
+void main() {
+ // Try to set the values of some global variables
+ example.ivar = 42;
+ example.svar = -31000;
+ example.lvar = 65537;
+ example.uivar = 123456;
+ example.usvar = 61000;
+ example.ulvar = 654321;
+ example.scvar = -13;
+ example.ucvar = 251;
+ example.cvar = 'S';
+ example.fvar = 3.14159f;
+ example.dvar = 2.1828;
+ example.strvar = "Hello World";
+ example.iptrvar = example.new_int(37);
+ example.ptptr = example.new_Point(37,42);
+ example.name = "Bill";
+
+ // Now print out the values of the variables
+ writefln( "Variables (printed from D):" );
+ writefln( "ivar = %s", example.ivar );
+ writefln( "svar = %s", example.svar );
+ writefln( "lvar = %s", example.lvar );
+ writefln( "uivar = %s", example.uivar );
+ writefln( "usvar = %s", example.usvar );
+ writefln( "ulvar = %s", example.ulvar );
+ writefln( "scvar = %s", example.scvar );
+ writefln( "ucvar = %s", example.ucvar );
+ writefln( "fvar = %s", example.fvar );
+ writefln( "dvar = %s", example.dvar );
+ writefln( "cvar = %s", example.cvar );
+ writefln( "strvar = %s", example.strvar );
+ writefln( "cstrvar = %s", example.cstrvar );
+ writefln( "iptrvar = %s", example.iptrvar );
+ writefln( "name = %s", example.name );
+ writefln( "ptptr = %s %s", example.ptptr, example.Point_print(example.ptptr) );
+ writefln( "pt = %s %s", example.pt, example.Point_print(example.pt) );
+ writefln( "status = %s", example.status );
+
+ writefln( "\nVariables (printed from the C library):" );
+ example.print_vars();
+
+ writefln( "\nNow I'm going to try and modify some read only variables:" );
+ writefln( "Checking that the read only variables are readonly..." );
+
+ writeln( " 'path'..." );
+ static if ( is( typeof( example.path = "a" ) ) )
+ writefln("Oh dear, this variable is not read only!");
+ else
+ writefln("Good.");
+
+ writeln( " 'status'..." );
+ static if ( is( typeof( example.status = 2 ) ) )
+ writefln("Oh dear, this variable is not read only!");
+ else
+ writefln("Good.");
+
+ writefln( "\nI'm going to try and update a structure variable:" );
+
+ example.pt = example.ptptr;
+
+ write( "The new value is " );
+ example.pt_print();
+ writefln( "You should see the value %s", example.Point_print(example.ptptr) );
+}
diff --git a/Examples/d/variables/example.c b/Examples/d/variables/example.c
new file mode 100644
index 000000000..1bf9c120f
--- /dev/null
+++ b/Examples/d/variables/example.c
@@ -0,0 +1,91 @@
+/* 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 ? cstrvar : "(null)");
+ printf("iptrvar = %p\n", iptrvar);
+ printf("name = %s\n", name);
+ printf("ptptr = %p (%d, %d)\n", 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;
+}
+
+/* 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/d/variables/example.h b/Examples/d/variables/example.h
new file mode 100644
index 000000000..0f7e89594
--- /dev/null
+++ b/Examples/d/variables/example.h
@@ -0,0 +1,6 @@
+/* File: example.h */
+
+typedef struct {
+ int x,y;
+} Point;
+
diff --git a/Examples/d/variables/example.i b/Examples/d/variables/example.i
new file mode 100644
index 000000000..591b871ed
--- /dev/null
+++ b/Examples/d/variables/example.i
@@ -0,0 +1,49 @@
+/* File : example.i */
+%module example
+%{
+#include "example.h"
+%}
+
+/* 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 Point *new_Point(int x, int y);
+extern char *Point_print(Point *p);
+extern void pt_print();
+%}
+
diff --git a/Examples/go/callback/example.go b/Examples/go/callback/example.go
deleted file mode 100644
index 5c0cfb051..000000000
--- a/Examples/go/callback/example.go
+++ /dev/null
@@ -1,188 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-type _swig_DirectorCallback struct {
- SwigcptrCallback
- v interface{}
-}
-
-func (p *_swig_DirectorCallback) Swigcptr() uintptr {
- return p.SwigcptrCallback.Swigcptr()
-}
-
-func (p *_swig_DirectorCallback) SwigIsCallback() {
-}
-
-func (p *_swig_DirectorCallback) DirectorInterface() interface{} {
- return p.v
-}
-
-func _swig_NewDirectorCallbackCallback(*_swig_DirectorCallback) SwigcptrCallback
-
-func NewDirectorCallback(v interface{}) Callback {
- p := &_swig_DirectorCallback{0, v}
- p.SwigcptrCallback = _swig_NewDirectorCallbackCallback(p)
- return p
-}
-
-func _swig_wrap_DeleteDirectorCallback(uintptr)
-
-func DeleteDirectorCallback(arg1 Callback) {
- _swig_wrap_DeleteDirectorCallback(arg1.Swigcptr())
-}
-
-func Swiggo_DeleteDirector_Callback(p *_swig_DirectorCallback) {
- p.SwigcptrCallback = 0
-}
-
-type _swig_DirectorInterfaceCallbackRun interface {
- Run()
-}
-
-func _swig_wrap__swig_DirectorCallback_upcall_Run(SwigcptrCallback)
-func (swig_p *_swig_DirectorCallback) Run() {
- if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceCallbackRun); swig_ok {
- swig_g.Run()
- return
- }
- _swig_wrap__swig_DirectorCallback_upcall_Run(swig_p.SwigcptrCallback)
-}
-
-func DirectorCallbackRun(p Callback) {
- _swig_wrap__swig_DirectorCallback_upcall_Run(p.(*_swig_DirectorCallback).SwigcptrCallback)
-}
-
-func Swig_DirectorCallback_callback_run(p *_swig_DirectorCallback) {
- p.Run()
-}
-
-type SwigcptrCallback uintptr
-
-func (p SwigcptrCallback) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrCallback) SwigIsCallback() {
-}
-
-func (p SwigcptrCallback) DirectorInterface() interface{} {
- return nil
-}
-
-func _swig_wrap_delete_Callback(uintptr)
-
-func DeleteCallback(arg1 Callback) {
- _swig_wrap_delete_Callback(arg1.Swigcptr())
-}
-
-func _swig_wrap_Callback_run(SwigcptrCallback)
-
-func (arg1 SwigcptrCallback) Run() {
- _swig_wrap_Callback_run(arg1)
-}
-
-func _swig_wrap_new_Callback() SwigcptrCallback
-
-func NewCallback() Callback {
- return _swig_wrap_new_Callback()
-}
-
-type Callback interface {
- Swigcptr() uintptr
- SwigIsCallback()
- DirectorInterface() interface{}
- Run()
-}
-
-type SwigcptrCaller uintptr
-
-func (p SwigcptrCaller) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrCaller) SwigIsCaller() {
-}
-
-func _swig_wrap_new_Caller() SwigcptrCaller
-
-func NewCaller() Caller {
- return _swig_wrap_new_Caller()
-}
-
-func _swig_wrap_delete_Caller(uintptr)
-
-func DeleteCaller(arg1 Caller) {
- _swig_wrap_delete_Caller(arg1.Swigcptr())
-}
-
-func _swig_wrap_Caller_delCallback(SwigcptrCaller)
-
-func (arg1 SwigcptrCaller) DelCallback() {
- _swig_wrap_Caller_delCallback(arg1)
-}
-
-func _swig_wrap_Caller_setCallback(SwigcptrCaller, uintptr)
-
-func (arg1 SwigcptrCaller) SetCallback(arg2 Callback) {
- _swig_wrap_Caller_setCallback(arg1, arg2.Swigcptr())
-}
-
-func _swig_wrap_Caller_call(SwigcptrCaller)
-
-func (arg1 SwigcptrCaller) Call() {
- _swig_wrap_Caller_call(arg1)
-}
-
-type Caller interface {
- Swigcptr() uintptr
- SwigIsCaller()
- DelCallback()
- SetCallback(arg2 Callback)
- Call()
-}
-
-
-type SwigcptrSwigDirector_Callback uintptr
-type SwigDirector_Callback interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrSwigDirector_Callback) Swigcptr() uintptr {
- return uintptr(p)
-}
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/class/example.go b/Examples/go/class/example.go
deleted file mode 100644
index ec8113ad4..000000000
--- a/Examples/go/class/example.go
+++ /dev/null
@@ -1,284 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-type SwigcptrShape uintptr
-
-func (p SwigcptrShape) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrShape) SwigIsShape() {
-}
-
-func _swig_wrap_delete_Shape(uintptr)
-
-func DeleteShape(arg1 Shape) {
- _swig_wrap_delete_Shape(arg1.Swigcptr())
-}
-
-func _swig_wrap_Shape_x_set(SwigcptrShape, float64)
-
-func (arg1 SwigcptrShape) SetX(arg2 float64) {
- _swig_wrap_Shape_x_set(arg1, arg2)
-}
-
-func _swig_wrap_Shape_x_get(SwigcptrShape) float64
-
-func (arg1 SwigcptrShape) GetX() float64 {
- return _swig_wrap_Shape_x_get(arg1)
-}
-
-func _swig_wrap_Shape_y_set(SwigcptrShape, float64)
-
-func (arg1 SwigcptrShape) SetY(arg2 float64) {
- _swig_wrap_Shape_y_set(arg1, arg2)
-}
-
-func _swig_wrap_Shape_y_get(SwigcptrShape) float64
-
-func (arg1 SwigcptrShape) GetY() float64 {
- return _swig_wrap_Shape_y_get(arg1)
-}
-
-func _swig_wrap_Shape_move(SwigcptrShape, float64, float64)
-
-func (arg1 SwigcptrShape) Move(arg2 float64, arg3 float64) {
- _swig_wrap_Shape_move(arg1, arg2, arg3)
-}
-
-func _swig_wrap_Shape_area(SwigcptrShape) float64
-
-func (arg1 SwigcptrShape) Area() float64 {
- return _swig_wrap_Shape_area(arg1)
-}
-
-func _swig_wrap_Shape_perimeter(SwigcptrShape) float64
-
-func (arg1 SwigcptrShape) Perimeter() float64 {
- return _swig_wrap_Shape_perimeter(arg1)
-}
-
-func _swig_wrap_Shape_nshapes_set(int)
-
-func SetShapeNshapes(arg1 int) {
- _swig_wrap_Shape_nshapes_set(arg1)
-}
-
-func GetShapeNshapes() int
-type Shape interface {
- Swigcptr() uintptr
- SwigIsShape()
- SetX(arg2 float64)
- GetX() float64
- SetY(arg2 float64)
- GetY() float64
- Move(arg2 float64, arg3 float64)
- Area() float64
- Perimeter() float64
-}
-
-type SwigcptrCircle uintptr
-
-func (p SwigcptrCircle) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrCircle) SwigIsCircle() {
-}
-
-func _swig_wrap_new_Circle(float64) SwigcptrCircle
-
-func NewCircle(arg1 float64) Circle {
- return _swig_wrap_new_Circle(arg1)
-}
-
-func _swig_wrap_Circle_area(SwigcptrCircle) float64
-
-func (arg1 SwigcptrCircle) Area() float64 {
- return _swig_wrap_Circle_area(arg1)
-}
-
-func _swig_wrap_Circle_perimeter(SwigcptrCircle) float64
-
-func (arg1 SwigcptrCircle) Perimeter() float64 {
- return _swig_wrap_Circle_perimeter(arg1)
-}
-
-func _swig_wrap_delete_Circle(uintptr)
-
-func DeleteCircle(arg1 Circle) {
- _swig_wrap_delete_Circle(arg1.Swigcptr())
-}
-
-func _swig_wrap_SetCircle_X(SwigcptrCircle, float64)
-
-func (_swig_base SwigcptrCircle) SetX(arg1 float64) {
- _swig_wrap_SetCircle_X(_swig_base, arg1)
-}
-
-func _swig_wrap_GetCircle_X(SwigcptrCircle) float64
-
-func (_swig_base SwigcptrCircle) GetX() float64 {
- return _swig_wrap_GetCircle_X(_swig_base)
-}
-
-func _swig_wrap_SetCircle_Y(SwigcptrCircle, float64)
-
-func (_swig_base SwigcptrCircle) SetY(arg1 float64) {
- _swig_wrap_SetCircle_Y(_swig_base, arg1)
-}
-
-func _swig_wrap_GetCircle_Y(SwigcptrCircle) float64
-
-func (_swig_base SwigcptrCircle) GetY() float64 {
- return _swig_wrap_GetCircle_Y(_swig_base)
-}
-
-func _swig_wrap_Circle_move(SwigcptrCircle, float64, float64)
-
-func (_swig_base SwigcptrCircle) Move(arg1 float64, arg2 float64) {
- _swig_wrap_Circle_move(_swig_base, arg1, arg2)
-}
-
-func (p SwigcptrCircle) SwigIsShape() {
-}
-
-func (p SwigcptrCircle) SwigGetShape() Shape {
- return SwigcptrShape(p.Swigcptr())
-}
-
-type Circle interface {
- Swigcptr() uintptr
- SwigIsCircle()
- Area() float64
- Perimeter() float64
- SetX(arg1 float64)
- GetX() float64
- SetY(arg1 float64)
- GetY() float64
- Move(arg1 float64, arg2 float64)
- SwigIsShape()
- SwigGetShape() Shape
-}
-
-type SwigcptrSquare uintptr
-
-func (p SwigcptrSquare) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrSquare) SwigIsSquare() {
-}
-
-func _swig_wrap_new_Square(float64) SwigcptrSquare
-
-func NewSquare(arg1 float64) Square {
- return _swig_wrap_new_Square(arg1)
-}
-
-func _swig_wrap_Square_area(SwigcptrSquare) float64
-
-func (arg1 SwigcptrSquare) Area() float64 {
- return _swig_wrap_Square_area(arg1)
-}
-
-func _swig_wrap_Square_perimeter(SwigcptrSquare) float64
-
-func (arg1 SwigcptrSquare) Perimeter() float64 {
- return _swig_wrap_Square_perimeter(arg1)
-}
-
-func _swig_wrap_delete_Square(uintptr)
-
-func DeleteSquare(arg1 Square) {
- _swig_wrap_delete_Square(arg1.Swigcptr())
-}
-
-func _swig_wrap_SetSquare_X(SwigcptrSquare, float64)
-
-func (_swig_base SwigcptrSquare) SetX(arg1 float64) {
- _swig_wrap_SetSquare_X(_swig_base, arg1)
-}
-
-func _swig_wrap_GetSquare_X(SwigcptrSquare) float64
-
-func (_swig_base SwigcptrSquare) GetX() float64 {
- return _swig_wrap_GetSquare_X(_swig_base)
-}
-
-func _swig_wrap_SetSquare_Y(SwigcptrSquare, float64)
-
-func (_swig_base SwigcptrSquare) SetY(arg1 float64) {
- _swig_wrap_SetSquare_Y(_swig_base, arg1)
-}
-
-func _swig_wrap_GetSquare_Y(SwigcptrSquare) float64
-
-func (_swig_base SwigcptrSquare) GetY() float64 {
- return _swig_wrap_GetSquare_Y(_swig_base)
-}
-
-func _swig_wrap_Square_move(SwigcptrSquare, float64, float64)
-
-func (_swig_base SwigcptrSquare) Move(arg1 float64, arg2 float64) {
- _swig_wrap_Square_move(_swig_base, arg1, arg2)
-}
-
-func (p SwigcptrSquare) SwigIsShape() {
-}
-
-func (p SwigcptrSquare) SwigGetShape() Shape {
- return SwigcptrShape(p.Swigcptr())
-}
-
-type Square interface {
- Swigcptr() uintptr
- SwigIsSquare()
- Area() float64
- Perimeter() float64
- SetX(arg1 float64)
- GetX() float64
- SetY(arg1 float64)
- GetY() float64
- Move(arg1 float64, arg2 float64)
- SwigIsShape()
- SwigGetShape() Shape
-}
-
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/constants/example.go b/Examples/go/constants/example.go
deleted file mode 100644
index 0e5e66418..000000000
--- a/Examples/go/constants/example.go
+++ /dev/null
@@ -1,44 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-const ICONST int = 42
-const FCONST float64 = 2.1828
-const CCONST byte = 'x'
-func _swig_getCCONST2() byte
-var CCONST2 byte = _swig_getCCONST2()
-const SCONST string = "Hello World"
-func _swig_getSCONST2() string
-var SCONST2 string = _swig_getSCONST2()
-func _swig_getEXPR() float64
-var EXPR float64 = _swig_getEXPR()
-const Iconst int = 37
-const Fconst float64 = 3.14
-
diff --git a/Examples/go/enum/example.go b/Examples/go/enum/example.go
deleted file mode 100644
index 4653ab57a..000000000
--- a/Examples/go/enum/example.go
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-type Color int
-func _swig_getRED() Color
-var RED Color = _swig_getRED()
-func _swig_getBLUE() Color
-var BLUE Color = _swig_getBLUE()
-func _swig_getGREEN() Color
-var GREEN Color = _swig_getGREEN()
-type SwigcptrFoo uintptr
-
-func (p SwigcptrFoo) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrFoo) SwigIsFoo() {
-}
-
-func _swig_wrap_new_Foo() SwigcptrFoo
-
-func NewFoo() Foo {
- return _swig_wrap_new_Foo()
-}
-
-type FooSpeed int
-func _swig_getFoo_IMPULSE_Foo() FooSpeed
-var FooIMPULSE FooSpeed = _swig_getFoo_IMPULSE_Foo()
-func _swig_getFoo_WARP_Foo() FooSpeed
-var FooWARP FooSpeed = _swig_getFoo_WARP_Foo()
-func _swig_getFoo_LUDICROUS_Foo() FooSpeed
-var FooLUDICROUS FooSpeed = _swig_getFoo_LUDICROUS_Foo()
-func _swig_wrap_Foo_enum_test(SwigcptrFoo, FooSpeed)
-
-func (arg1 SwigcptrFoo) Enum_test(arg2 FooSpeed) {
- _swig_wrap_Foo_enum_test(arg1, arg2)
-}
-
-func _swig_wrap_delete_Foo(uintptr)
-
-func DeleteFoo(arg1 Foo) {
- _swig_wrap_delete_Foo(arg1.Swigcptr())
-}
-
-type Foo interface {
- Swigcptr() uintptr
- SwigIsFoo()
- Enum_test(arg2 FooSpeed)
-}
-
-func _swig_wrap_enum_test(Color, FooSpeed)
-
-func Enum_test(arg1 Color, arg2 FooSpeed) {
- _swig_wrap_enum_test(arg1, arg2)
-}
-
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/extend/example.go b/Examples/go/extend/example.go
deleted file mode 100644
index 08f21e6ab..000000000
--- a/Examples/go/extend/example.go
+++ /dev/null
@@ -1,397 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-type _swig_DirectorEmployee struct {
- SwigcptrEmployee
- v interface{}
-}
-
-func (p *_swig_DirectorEmployee) Swigcptr() uintptr {
- return p.SwigcptrEmployee.Swigcptr()
-}
-
-func (p *_swig_DirectorEmployee) SwigIsEmployee() {
-}
-
-func (p *_swig_DirectorEmployee) DirectorInterface() interface{} {
- return p.v
-}
-
-func _swig_NewDirectorEmployeeEmployee(*_swig_DirectorEmployee, string) SwigcptrEmployee
-
-func NewDirectorEmployee(v interface{}, arg1 string) Employee {
- p := &_swig_DirectorEmployee{0, v}
- p.SwigcptrEmployee = _swig_NewDirectorEmployeeEmployee(p, arg1)
- return p
-}
-
-type _swig_DirectorInterfaceEmployeeGetTitle interface {
- GetTitle() string
-}
-
-func _swig_wrap__swig_DirectorEmployee_upcall_GetTitle(SwigcptrEmployee) string
-func (swig_p *_swig_DirectorEmployee) GetTitle() string {
- if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceEmployeeGetTitle); swig_ok {
- return swig_g.GetTitle()
- }
- return _swig_wrap__swig_DirectorEmployee_upcall_GetTitle(swig_p.SwigcptrEmployee)
-}
-
-func DirectorEmployeeGetTitle(p Employee) string {
- return _swig_wrap__swig_DirectorEmployee_upcall_GetTitle(p.(*_swig_DirectorEmployee).SwigcptrEmployee)
-}
-
-func Swig_DirectorEmployee_callback_getTitle(p *_swig_DirectorEmployee) (swig_result string) {
- return p.GetTitle()
-}
-
-type _swig_DirectorInterfaceEmployeeGetName interface {
- GetName() string
-}
-
-func _swig_wrap__swig_DirectorEmployee_upcall_GetName(SwigcptrEmployee) string
-func (swig_p *_swig_DirectorEmployee) GetName() string {
- if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceEmployeeGetName); swig_ok {
- return swig_g.GetName()
- }
- return _swig_wrap__swig_DirectorEmployee_upcall_GetName(swig_p.SwigcptrEmployee)
-}
-
-func DirectorEmployeeGetName(p Employee) string {
- return _swig_wrap__swig_DirectorEmployee_upcall_GetName(p.(*_swig_DirectorEmployee).SwigcptrEmployee)
-}
-
-func Swig_DirectorEmployee_callback_getName(p *_swig_DirectorEmployee) (swig_result string) {
- return p.GetName()
-}
-
-type _swig_DirectorInterfaceEmployeeGetPosition interface {
- GetPosition() string
-}
-
-func _swig_wrap__swig_DirectorEmployee_upcall_GetPosition(SwigcptrEmployee) string
-func (swig_p *_swig_DirectorEmployee) GetPosition() string {
- if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceEmployeeGetPosition); swig_ok {
- return swig_g.GetPosition()
- }
- return _swig_wrap__swig_DirectorEmployee_upcall_GetPosition(swig_p.SwigcptrEmployee)
-}
-
-func DirectorEmployeeGetPosition(p Employee) string {
- return _swig_wrap__swig_DirectorEmployee_upcall_GetPosition(p.(*_swig_DirectorEmployee).SwigcptrEmployee)
-}
-
-func Swig_DirectorEmployee_callback_getPosition(p *_swig_DirectorEmployee) (swig_result string) {
- return p.GetPosition()
-}
-
-func _swig_wrap_DeleteDirectorEmployee(uintptr)
-
-func DeleteDirectorEmployee(arg1 Employee) {
- _swig_wrap_DeleteDirectorEmployee(arg1.Swigcptr())
-}
-
-func Swiggo_DeleteDirector_Employee(p *_swig_DirectorEmployee) {
- p.SwigcptrEmployee = 0
-}
-
-type SwigcptrEmployee uintptr
-
-func (p SwigcptrEmployee) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrEmployee) SwigIsEmployee() {
-}
-
-func (p SwigcptrEmployee) DirectorInterface() interface{} {
- return nil
-}
-
-func _swig_wrap_new_Employee(string) SwigcptrEmployee
-
-func NewEmployee(arg1 string) Employee {
- return _swig_wrap_new_Employee(arg1)
-}
-
-func _swig_wrap_Employee_getTitle(SwigcptrEmployee) string
-
-func (arg1 SwigcptrEmployee) GetTitle() string {
- return _swig_wrap_Employee_getTitle(arg1)
-}
-
-func _swig_wrap_Employee_getName(SwigcptrEmployee) string
-
-func (arg1 SwigcptrEmployee) GetName() string {
- return _swig_wrap_Employee_getName(arg1)
-}
-
-func _swig_wrap_Employee_getPosition(SwigcptrEmployee) string
-
-func (arg1 SwigcptrEmployee) GetPosition() string {
- return _swig_wrap_Employee_getPosition(arg1)
-}
-
-func _swig_wrap_delete_Employee(uintptr)
-
-func DeleteEmployee(arg1 Employee) {
- _swig_wrap_delete_Employee(arg1.Swigcptr())
-}
-
-type Employee interface {
- Swigcptr() uintptr
- SwigIsEmployee()
- DirectorInterface() interface{}
- GetTitle() string
- GetName() string
- GetPosition() string
-}
-
-type _swig_DirectorManager struct {
- SwigcptrManager
- v interface{}
-}
-
-func (p *_swig_DirectorManager) Swigcptr() uintptr {
- return p.SwigcptrManager.Swigcptr()
-}
-
-func (p *_swig_DirectorManager) SwigIsManager() {
-}
-
-func (p *_swig_DirectorManager) DirectorInterface() interface{} {
- return p.v
-}
-
-func _swig_NewDirectorManagerManager(*_swig_DirectorManager, string) SwigcptrManager
-
-func NewDirectorManager(v interface{}, arg1 string) Manager {
- p := &_swig_DirectorManager{0, v}
- p.SwigcptrManager = _swig_NewDirectorManagerManager(p, arg1)
- return p
-}
-
-type _swig_DirectorInterfaceManagerGetTitle interface {
- GetTitle() string
-}
-
-func _swig_wrap__swig_DirectorManager_upcall_GetTitle(SwigcptrManager) string
-func (swig_p *_swig_DirectorManager) GetTitle() string {
- if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceManagerGetTitle); swig_ok {
- return swig_g.GetTitle()
- }
- return _swig_wrap__swig_DirectorManager_upcall_GetTitle(swig_p.SwigcptrManager)
-}
-
-func DirectorManagerGetTitle(p Manager) string {
- return _swig_wrap__swig_DirectorManager_upcall_GetTitle(p.(*_swig_DirectorManager).SwigcptrManager)
-}
-
-func Swig_DirectorManager_callback_getTitle(p *_swig_DirectorManager) (swig_result string) {
- return p.GetTitle()
-}
-
-type _swig_DirectorInterfaceManagerGetName interface {
- GetName() string
-}
-
-func _swig_wrap__swig_DirectorManager_upcall_GetName(SwigcptrManager) string
-func (swig_p *_swig_DirectorManager) GetName() string {
- if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceManagerGetName); swig_ok {
- return swig_g.GetName()
- }
- return _swig_wrap__swig_DirectorManager_upcall_GetName(swig_p.SwigcptrManager)
-}
-
-func DirectorManagerGetName(p Manager) string {
- return _swig_wrap__swig_DirectorManager_upcall_GetName(p.(*_swig_DirectorManager).SwigcptrManager)
-}
-
-func Swig_DirectorManager_callback_getName(p *_swig_DirectorManager) (swig_result string) {
- return p.GetName()
-}
-
-type _swig_DirectorInterfaceManagerGetPosition interface {
- GetPosition() string
-}
-
-func _swig_wrap__swig_DirectorManager_upcall_GetPosition(SwigcptrManager) string
-func (swig_p *_swig_DirectorManager) GetPosition() string {
- if swig_g, swig_ok := swig_p.v.(_swig_DirectorInterfaceManagerGetPosition); swig_ok {
- return swig_g.GetPosition()
- }
- return _swig_wrap__swig_DirectorManager_upcall_GetPosition(swig_p.SwigcptrManager)
-}
-
-func DirectorManagerGetPosition(p Manager) string {
- return _swig_wrap__swig_DirectorManager_upcall_GetPosition(p.(*_swig_DirectorManager).SwigcptrManager)
-}
-
-func Swig_DirectorManager_callback_getPosition(p *_swig_DirectorManager) (swig_result string) {
- return p.GetPosition()
-}
-
-func _swig_wrap_DeleteDirectorManager(uintptr)
-
-func DeleteDirectorManager(arg1 Manager) {
- _swig_wrap_DeleteDirectorManager(arg1.Swigcptr())
-}
-
-func Swiggo_DeleteDirector_Manager(p *_swig_DirectorManager) {
- p.SwigcptrManager = 0
-}
-
-type SwigcptrManager uintptr
-
-func (p SwigcptrManager) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrManager) SwigIsManager() {
-}
-
-func (p SwigcptrManager) DirectorInterface() interface{} {
- return nil
-}
-
-func _swig_wrap_new_Manager(string) SwigcptrManager
-
-func NewManager(arg1 string) Manager {
- return _swig_wrap_new_Manager(arg1)
-}
-
-func _swig_wrap_Manager_getPosition(SwigcptrManager) string
-
-func (arg1 SwigcptrManager) GetPosition() string {
- return _swig_wrap_Manager_getPosition(arg1)
-}
-
-func _swig_wrap_delete_Manager(uintptr)
-
-func DeleteManager(arg1 Manager) {
- _swig_wrap_delete_Manager(arg1.Swigcptr())
-}
-
-func _swig_wrap_Manager_getTitle(SwigcptrManager) string
-
-func (_swig_base SwigcptrManager) GetTitle() string {
- return _swig_wrap_Manager_getTitle(_swig_base)
-}
-
-func _swig_wrap_Manager_getName(SwigcptrManager) string
-
-func (_swig_base SwigcptrManager) GetName() string {
- return _swig_wrap_Manager_getName(_swig_base)
-}
-
-func (p SwigcptrManager) SwigIsEmployee() {
-}
-
-func (p SwigcptrManager) SwigGetEmployee() Employee {
- return SwigcptrEmployee(p.Swigcptr())
-}
-
-type Manager interface {
- Swigcptr() uintptr
- SwigIsManager()
- DirectorInterface() interface{}
- GetPosition() string
- GetTitle() string
- GetName() string
- SwigIsEmployee()
- SwigGetEmployee() Employee
-}
-
-type SwigcptrEmployeeList uintptr
-
-func (p SwigcptrEmployeeList) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrEmployeeList) SwigIsEmployeeList() {
-}
-
-func _swig_wrap_new_EmployeeList() SwigcptrEmployeeList
-
-func NewEmployeeList() EmployeeList {
- return _swig_wrap_new_EmployeeList()
-}
-
-func _swig_wrap_EmployeeList_addEmployee(SwigcptrEmployeeList, uintptr)
-
-func (arg1 SwigcptrEmployeeList) AddEmployee(arg2 Employee) {
- _swig_wrap_EmployeeList_addEmployee(arg1, arg2.Swigcptr())
-}
-
-func _swig_wrap_EmployeeList_get_item(SwigcptrEmployeeList, int) SwigcptrEmployee
-
-func (arg1 SwigcptrEmployeeList) Get_item(arg2 int) Employee {
- return _swig_wrap_EmployeeList_get_item(arg1, arg2)
-}
-
-func _swig_wrap_delete_EmployeeList(uintptr)
-
-func DeleteEmployeeList(arg1 EmployeeList) {
- _swig_wrap_delete_EmployeeList(arg1.Swigcptr())
-}
-
-type EmployeeList interface {
- Swigcptr() uintptr
- SwigIsEmployeeList()
- AddEmployee(arg2 Employee)
- Get_item(arg2 int) Employee
-}
-
-
-type SwigcptrSwigDirector_Manager uintptr
-type SwigDirector_Manager interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrSwigDirector_Manager) Swigcptr() uintptr {
- return uintptr(p)
-}
-
-type SwigcptrSwigDirector_Employee uintptr
-type SwigDirector_Employee interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrSwigDirector_Employee) Swigcptr() uintptr {
- return uintptr(p)
-}
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/funcptr/example.go b/Examples/go/funcptr/example.go
deleted file mode 100644
index b059bae8d..000000000
--- a/Examples/go/funcptr/example.go
+++ /dev/null
@@ -1,54 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-func Do_op(int, int, _swig_fnptr) int
-func _swig_getADD() _swig_fnptr
-var ADD _swig_fnptr = _swig_getADD()
-func _swig_getSUB() _swig_fnptr
-var SUB _swig_fnptr = _swig_getSUB()
-func _swig_getMUL() _swig_fnptr
-var MUL _swig_fnptr = _swig_getMUL()
-func _swig_wrap_funcvar_set(_swig_fnptr)
-
-func SetFuncvar(arg1 _swig_fnptr) {
- _swig_wrap_funcvar_set(arg1)
-}
-
-func GetFuncvar() _swig_fnptr
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/multimap/example.go b/Examples/go/multimap/example.go
deleted file mode 100644
index 59ed9eaad..000000000
--- a/Examples/go/multimap/example.go
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-func Gcd(int, int) int
-func Gcdmain([]string) int
-func Count(string, byte) int
-func _swig_wrap_capitalize([]string)
-
-func Capitalize(arg1 []string) {
- _swig_wrap_capitalize(arg1)
-}
-
-func _swig_wrap_circle(float64, float64)
-
-func Circle(arg1 float64, arg2 float64) {
- _swig_wrap_circle(arg1, arg2)
-}
-
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/pointer/example.go b/Examples/go/pointer/example.go
deleted file mode 100644
index 567c41c32..000000000
--- a/Examples/go/pointer/example.go
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-func _swig_wrap_add(*int, *int, *int)
-
-func Add(arg1 *int, arg2 *int, arg3 *int) {
- _swig_wrap_add(arg1, arg2, arg3)
-}
-
-func New_intp() *int
-func Copy_intp(int) *int
-func _swig_wrap_delete_intp(*int)
-
-func Delete_intp(arg1 *int) {
- _swig_wrap_delete_intp(arg1)
-}
-
-func _swig_wrap_intp_assign(*int, int)
-
-func Intp_assign(arg1 *int, arg2 int) {
- _swig_wrap_intp_assign(arg1, arg2)
-}
-
-func Intp_value(*int) int
-func _swig_wrap_sub(int, int, []int)
-
-func Sub(arg1 int, arg2 int, arg3 []int) {
- _swig_wrap_sub(arg1, arg2, arg3)
-}
-
-func Divide(int, int, []int) int
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/reference/example.go b/Examples/go/reference/example.go
deleted file mode 100644
index fb98f8a18..000000000
--- a/Examples/go/reference/example.go
+++ /dev/null
@@ -1,126 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-type SwigcptrVector uintptr
-
-func (p SwigcptrVector) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrVector) SwigIsVector() {
-}
-
-func _swig_wrap_new_Vector(float64, float64, float64) SwigcptrVector
-
-func NewVector(arg1 float64, arg2 float64, arg3 float64) Vector {
- return _swig_wrap_new_Vector(arg1, arg2, arg3)
-}
-
-func _swig_wrap_delete_Vector(uintptr)
-
-func DeleteVector(arg1 Vector) {
- _swig_wrap_delete_Vector(arg1.Swigcptr())
-}
-
-func _swig_wrap_Vector_print(SwigcptrVector) string
-
-func (arg1 SwigcptrVector) Print() string {
- return _swig_wrap_Vector_print(arg1)
-}
-
-type Vector interface {
- Swigcptr() uintptr
- SwigIsVector()
- Print() string
-}
-
-func _swig_wrap_addv(uintptr, uintptr) SwigcptrVector
-
-func Addv(arg1 Vector, arg2 Vector) Vector {
- return _swig_wrap_addv(arg1.Swigcptr(), arg2.Swigcptr())
-}
-
-type SwigcptrVectorArray uintptr
-
-func (p SwigcptrVectorArray) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrVectorArray) SwigIsVectorArray() {
-}
-
-func _swig_wrap_new_VectorArray(int) SwigcptrVectorArray
-
-func NewVectorArray(arg1 int) VectorArray {
- return _swig_wrap_new_VectorArray(arg1)
-}
-
-func _swig_wrap_delete_VectorArray(uintptr)
-
-func DeleteVectorArray(arg1 VectorArray) {
- _swig_wrap_delete_VectorArray(arg1.Swigcptr())
-}
-
-func _swig_wrap_VectorArray_size(SwigcptrVectorArray) int
-
-func (arg1 SwigcptrVectorArray) Size() int {
- return _swig_wrap_VectorArray_size(arg1)
-}
-
-func _swig_wrap_VectorArray_get(SwigcptrVectorArray, int) SwigcptrVector
-
-func (arg1 SwigcptrVectorArray) Get(arg2 int) Vector {
- return _swig_wrap_VectorArray_get(arg1, arg2)
-}
-
-func _swig_wrap_VectorArray_set(SwigcptrVectorArray, int, uintptr)
-
-func (arg1 SwigcptrVectorArray) Set(arg2 int, arg3 Vector) {
- _swig_wrap_VectorArray_set(arg1, arg2, arg3.Swigcptr())
-}
-
-type VectorArray interface {
- Swigcptr() uintptr
- SwigIsVectorArray()
- Size() int
- Get(arg2 int) Vector
- Set(arg2 int, arg3 Vector)
-}
-
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/simple/example.go b/Examples/go/simple/example.go
deleted file mode 100644
index df0e70564..000000000
--- a/Examples/go/simple/example.go
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-func Gcd(int, int) int
-func _swig_wrap_Foo_set(float64)
-
-func SetFoo(arg1 float64) {
- _swig_wrap_Foo_set(arg1)
-}
-
-func GetFoo() float64
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/template/example.go b/Examples/go/template/example.go
deleted file mode 100644
index 671b5c2ba..000000000
--- a/Examples/go/template/example.go
+++ /dev/null
@@ -1,150 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-func Maxint(int, int) int
-func Maxdouble(float64, float64) float64
-type SwigcptrVecint uintptr
-
-func (p SwigcptrVecint) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrVecint) SwigIsVecint() {
-}
-
-func _swig_wrap_new_vecint(int) SwigcptrVecint
-
-func NewVecint(arg1 int) Vecint {
- return _swig_wrap_new_vecint(arg1)
-}
-
-func _swig_wrap_vecint_get(SwigcptrVecint, int) *int
-
-func (arg1 SwigcptrVecint) Get(arg2 int) *int {
- return _swig_wrap_vecint_get(arg1, arg2)
-}
-
-func _swig_wrap_vecint_set(SwigcptrVecint, int, *int)
-
-func (arg1 SwigcptrVecint) Set(arg2 int, arg3 *int) {
- _swig_wrap_vecint_set(arg1, arg2, arg3)
-}
-
-func _swig_wrap_vecint_getitem(SwigcptrVecint, int) int
-
-func (arg1 SwigcptrVecint) Getitem(arg2 int) int {
- return _swig_wrap_vecint_getitem(arg1, arg2)
-}
-
-func _swig_wrap_vecint_setitem(SwigcptrVecint, int, int)
-
-func (arg1 SwigcptrVecint) Setitem(arg2 int, arg3 int) {
- _swig_wrap_vecint_setitem(arg1, arg2, arg3)
-}
-
-func _swig_wrap_delete_vecint(uintptr)
-
-func DeleteVecint(arg1 Vecint) {
- _swig_wrap_delete_vecint(arg1.Swigcptr())
-}
-
-type Vecint interface {
- Swigcptr() uintptr
- SwigIsVecint()
- Get(arg2 int) *int
- Set(arg2 int, arg3 *int)
- Getitem(arg2 int) int
- Setitem(arg2 int, arg3 int)
-}
-
-type SwigcptrVecdouble uintptr
-
-func (p SwigcptrVecdouble) Swigcptr() uintptr {
- return (uintptr)(p)
-}
-
-func (p SwigcptrVecdouble) SwigIsVecdouble() {
-}
-
-func _swig_wrap_new_vecdouble(int) SwigcptrVecdouble
-
-func NewVecdouble(arg1 int) Vecdouble {
- return _swig_wrap_new_vecdouble(arg1)
-}
-
-func _swig_wrap_vecdouble_get(SwigcptrVecdouble, int) *float64
-
-func (arg1 SwigcptrVecdouble) Get(arg2 int) *float64 {
- return _swig_wrap_vecdouble_get(arg1, arg2)
-}
-
-func _swig_wrap_vecdouble_set(SwigcptrVecdouble, int, *float64)
-
-func (arg1 SwigcptrVecdouble) Set(arg2 int, arg3 *float64) {
- _swig_wrap_vecdouble_set(arg1, arg2, arg3)
-}
-
-func _swig_wrap_vecdouble_getitem(SwigcptrVecdouble, int) float64
-
-func (arg1 SwigcptrVecdouble) Getitem(arg2 int) float64 {
- return _swig_wrap_vecdouble_getitem(arg1, arg2)
-}
-
-func _swig_wrap_vecdouble_setitem(SwigcptrVecdouble, int, float64)
-
-func (arg1 SwigcptrVecdouble) Setitem(arg2 int, arg3 float64) {
- _swig_wrap_vecdouble_setitem(arg1, arg2, arg3)
-}
-
-func _swig_wrap_delete_vecdouble(uintptr)
-
-func DeleteVecdouble(arg1 Vecdouble) {
- _swig_wrap_delete_vecdouble(arg1.Swigcptr())
-}
-
-type Vecdouble interface {
- Swigcptr() uintptr
- SwigIsVecdouble()
- Get(arg2 int) *float64
- Set(arg2 int, arg3 *float64)
- Getitem(arg2 int) float64
- Setitem(arg2 int, arg3 float64)
-}
-
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/go/variables/example.go b/Examples/go/variables/example.go
deleted file mode 100644
index f4f299b73..000000000
--- a/Examples/go/variables/example.go
+++ /dev/null
@@ -1,198 +0,0 @@
-/* ----------------------------------------------------------------------------
- * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 2.0.1
- *
- * This file is not intended to be easily readable and contains a number of
- * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
- * ----------------------------------------------------------------------------- */
-
-package example
-
-
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-
-
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-
-func _swig_wrap_ivar_set(int)
-
-func SetIvar(arg1 int) {
- _swig_wrap_ivar_set(arg1)
-}
-
-func GetIvar() int
-func _swig_wrap_svar_set(int16)
-
-func SetSvar(arg1 int16) {
- _swig_wrap_svar_set(arg1)
-}
-
-func GetSvar() int16
-func _swig_wrap_lvar_set(int32)
-
-func SetLvar(arg1 int32) {
- _swig_wrap_lvar_set(arg1)
-}
-
-func GetLvar() int32
-func _swig_wrap_uivar_set(uint)
-
-func SetUivar(arg1 uint) {
- _swig_wrap_uivar_set(arg1)
-}
-
-func GetUivar() uint
-func _swig_wrap_usvar_set(uint16)
-
-func SetUsvar(arg1 uint16) {
- _swig_wrap_usvar_set(arg1)
-}
-
-func GetUsvar() uint16
-func _swig_wrap_ulvar_set(uint32)
-
-func SetUlvar(arg1 uint32) {
- _swig_wrap_ulvar_set(arg1)
-}
-
-func GetUlvar() uint32
-func _swig_wrap_scvar_set(int8)
-
-func SetScvar(arg1 int8) {
- _swig_wrap_scvar_set(arg1)
-}
-
-func GetScvar() int8
-func _swig_wrap_ucvar_set(byte)
-
-func SetUcvar(arg1 byte) {
- _swig_wrap_ucvar_set(arg1)
-}
-
-func GetUcvar() byte
-func _swig_wrap_cvar_set(byte)
-
-func SetCvar(arg1 byte) {
- _swig_wrap_cvar_set(arg1)
-}
-
-func GetCvar() byte
-func _swig_wrap_fvar_set(float32)
-
-func SetFvar(arg1 float32) {
- _swig_wrap_fvar_set(arg1)
-}
-
-func GetFvar() float32
-func _swig_wrap_dvar_set(float64)
-
-func SetDvar(arg1 float64) {
- _swig_wrap_dvar_set(arg1)
-}
-
-func GetDvar() float64
-func _swig_wrap_strvar_set(string)
-
-func SetStrvar(arg1 string) {
- _swig_wrap_strvar_set(arg1)
-}
-
-func GetStrvar() string
-func GetCstrvar() string
-func _swig_wrap_iptrvar_set(*int)
-
-func SetIptrvar(arg1 *int) {
- _swig_wrap_iptrvar_set(arg1)
-}
-
-func GetIptrvar() *int
-func _swig_wrap_name_set(string)
-
-func SetName(arg1 string) {
- _swig_wrap_name_set(arg1)
-}
-
-func GetName() string
-func _swig_wrap_ptptr_set(uintptr)
-
-func SetPtptr(arg1 Point) {
- _swig_wrap_ptptr_set(arg1.Swigcptr())
-}
-
-func _swig_wrap_ptptr_get() SwigcptrPoint
-
-func GetPtptr() Point {
- return _swig_wrap_ptptr_get()
-}
-
-func _swig_wrap_pt_set(uintptr)
-
-func SetPt(arg1 Point) {
- _swig_wrap_pt_set(arg1.Swigcptr())
-}
-
-func _swig_wrap_pt_get() SwigcptrPoint
-
-func GetPt() Point {
- return _swig_wrap_pt_get()
-}
-
-func GetStatus() int
-func GetPath() string
-func _swig_wrap_print_vars()
-
-func Print_vars() {
- _swig_wrap_print_vars()
-}
-
-func New_int(int) *int
-func _swig_wrap_new_Point(int, int) SwigcptrPoint
-
-func New_Point(arg1 int, arg2 int) Point {
- return _swig_wrap_new_Point(arg1, arg2)
-}
-
-func _swig_wrap_Point_print(uintptr) string
-
-func Point_print(arg1 Point) string {
- return _swig_wrap_Point_print(arg1.Swigcptr())
-}
-
-func _swig_wrap_pt_print()
-
-func Pt_print() {
- _swig_wrap_pt_print()
-}
-
-
-type SwigcptrPoint uintptr
-type Point interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrPoint) Swigcptr() uintptr {
- return uintptr(p)
-}
-
-type SwigcptrVoid uintptr
-type Void interface {
- Swigcptr() uintptr;
-}
-func (p SwigcptrVoid) Swigcptr() uintptr {
- return uintptr(p)
-}
-
diff --git a/Examples/ocaml/argout_ref/example.i b/Examples/ocaml/argout_ref/example.i
index a0be05f24..5ea6777fb 100644
--- a/Examples/ocaml/argout_ref/example.i
+++ b/Examples/ocaml/argout_ref/example.i
@@ -1,4 +1,8 @@
/* File : example.i */
%module example
+%{
+extern "C" void factor(int &x, int &y);
+%}
+
extern "C" void factor(int &x, int &y);
diff --git a/Examples/ocaml/shapes/example.c b/Examples/ocaml/shapes/example.c
index bf0fff937..26c1b8098 100644
--- a/Examples/ocaml/shapes/example.c
+++ b/Examples/ocaml/shapes/example.c
@@ -46,3 +46,5 @@ void draw_depth_map( volume *v, int div_x, int div_y ) {
}
double volume::depth( double x, double y ) { return 0.0; }
+
+volume::~volume() { }
diff --git a/Examples/ocaml/shapes/example.h b/Examples/ocaml/shapes/example.h
index 4b1644494..68cb6ee3e 100644
--- a/Examples/ocaml/shapes/example.h
+++ b/Examples/ocaml/shapes/example.h
@@ -9,7 +9,8 @@ public:
class volume {
public:
- virtual double depth( double x, double y );
+ virtual double depth( double x, double y );
+ virtual ~volume();
};
extern void draw_shape_coverage( shape *s, int div_x, int div_y );
diff --git a/Examples/ocaml/std_string/README b/Examples/ocaml/std_string/README
index 566553083..ccebecbaf 100644
--- a/Examples/ocaml/std_string/README
+++ b/Examples/ocaml/std_string/README
@@ -1,3 +1,9 @@
+--- New ---
+
+It's not possible to access std::(w)string at the moment as it breaks other string examples.
+
+--- Old ---
+
This example shows how to use both std::string and std::wstring in Ocaml,
and also demonstrates that one might use this to make a locale-obedient
Ocaml program.
diff --git a/Examples/ocaml/strings_test/example.h b/Examples/ocaml/strings_test/example.h
index 3417981f0..959404b5d 100644
--- a/Examples/ocaml/strings_test/example.h
+++ b/Examples/ocaml/strings_test/example.h
@@ -1,14 +1,18 @@
/* -*- mode: c++ -*- */
/* File : example.h -- Tests all string typemaps */
+#include <sys/time.h>
+#include <time.h>
+
void takes_std_string( std::string in ) {
cout << "takes_std_string( \"" << in << "\" );" << endl;
}
std::string gives_std_string() {
- time_t t;
-
- return std::string( asctime( localtime( &t ) ) );
+ struct timeval tv;
+
+ gettimeofday(&tv, NULL);
+ return std::string( asctime( localtime( &tv.tv_sec ) ) );
}
void takes_char_ptr( char *p ) {
@@ -24,10 +28,10 @@ void takes_and_gives_std_string( std::string &inout ) {
inout.insert( inout.end(), ']' );
}
-void takes_and_gives_char_ptr( char *&ptr ) {
- char *pout = strchr( ptr, '.' );
- if( pout ) ptr = pout + 1;
- else ptr = "foo";
+void takes_and_gives_char_ptr( char *&inout ) {
+ char *pout = strchr( inout, '.' );
+ if( pout ) inout = pout + 1;
+ else inout = "foo";
}
/*
diff --git a/Examples/php/cpointer/runme.php b/Examples/php/cpointer/runme.php
index 48f0ad631..22e8a681a 100644
--- a/Examples/php/cpointer/runme.php
+++ b/Examples/php/cpointer/runme.php
@@ -6,40 +6,42 @@
print "Testing the pointer library\n";
- $a = new_intp();
- $b = new_intp();
- $c = new_intp();
- intp_assign($a,37);
- intp_assign($b,42);
+ $a = example::new_intp();
+ $b = example::new_intp();
+ $c = example::new_intp();
+ example::intp_assign($a,37);
+ example::intp_assign($b,42);
print " a = $a\n";
print " b = $b\n";
print " c = $c\n";
# Call the add() function wuth some pointers
- add($a,$b,$c);
+ example::add($a,$b,$c);
# Now get the result
- $r = intp_value($c);
+ $r = example::intp_value($c);
print " 37 + 42 = $r\n";
# Clean up the pointers
- delete_intp($a);
- delete_intp($b);
- delete_intp($c);
+ example::delete_intp($a);
+ example::delete_intp($b);
+ example::delete_intp($c);
# Now try the typemap library
# This should be much easier. Now how it is no longer
# necessary to manufacture pointers.
print "Trying the typemap library\n";
- $r = sub(37,42);
+ $r = example::sub(37,42);
print " 37 - 42 = $r\n";
# Now try the version with multiple return values
# print "Testing multiple return values\n";
- # ($q,$r) = divide(42,37);
+ # $a = example::divide(42,37);
+ # $q = $a[0]
+ # $r = $a[1]
# print " 42/37 = $q remainder $r\n";
?>
diff --git a/Examples/php/overloading/runme.php b/Examples/php/overloading/runme.php
index 01044445f..56d515138 100644
--- a/Examples/php/overloading/runme.php
+++ b/Examples/php/overloading/runme.php
@@ -35,11 +35,10 @@ print " Square = (" . $s->x . "," . $s->y . ")\n";
# ----- Call some methods -----
-print "\nHere are some properties of the shapes:\n";
+print "\nCall some overloaded methods:\n";
foreach (array(1, 2.1, "quick brown fox", $c, $s) as $o) {
- print " ".get_class($o)." \$o\n";
- print " overloaded = " . overloaded($o) . "\n";
- }
+ print " overloaded = " . overloaded($o) . "\n";
+}
# Need to unset($o) or else we hang on to a reference to the Square object.
unset($o);
diff --git a/Examples/test-suite/abstract_virtual.i b/Examples/test-suite/abstract_virtual.i
index 2e4d105b1..d8372c936 100644
--- a/Examples/test-suite/abstract_virtual.i
+++ b/Examples/test-suite/abstract_virtual.i
@@ -2,10 +2,12 @@
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) D; /* C#, D, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, D, Java, PHP multiple inheritance */
%inline %{
#if defined(_MSC_VER)
diff --git a/Examples/test-suite/char_binary.i b/Examples/test-suite/char_binary.i
new file mode 100644
index 000000000..778792946
--- /dev/null
+++ b/Examples/test-suite/char_binary.i
@@ -0,0 +1,29 @@
+/*
+A test case for testing non null terminated char pointers.
+*/
+
+%module char_binary
+
+%apply (char *STRING, size_t LENGTH) { (const char *str, size_t len) }
+
+%inline %{
+struct Test {
+ size_t strlen(const char *str, size_t len) {
+ return len;
+ }
+};
+
+typedef char namet[5];
+namet var_namet;
+
+typedef char* pchar;
+pchar var_pchar;
+%}
+
+// Remove string handling typemaps and treat as pointer
+%typemap(freearg) SWIGTYPE * ""
+%apply SWIGTYPE * { char * }
+
+%include "carrays.i"
+%array_functions(char, pchar);
+
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index c1952543f..5f3012091 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -154,6 +154,7 @@ CPP_TEST_CASES += \
derived_nested \
destructor_reprotected \
director_abstract \
+ director_alternating \
director_basic \
director_classes \
director_classic \
@@ -166,6 +167,7 @@ CPP_TEST_CASES += \
director_finalizer \
director_frob \
director_ignore \
+ director_keywords \
director_namespace_clash \
director_nested \
director_overload \
@@ -228,9 +230,11 @@ CPP_TEST_CASES += \
li_cpointer \
li_stdint \
li_typemaps \
+ li_typemaps_apply \
li_windows \
long_long_apply \
memberin_extend \
+ member_funcptr_galore \
member_pointer \
member_template \
minherit \
@@ -283,7 +287,10 @@ CPP_TEST_CASES += \
rename3 \
rename4 \
rename_scope \
+ rename_simple \
rename_strip_encoder \
+ rename_pcre_encoder \
+ rename_pcre_enum \
restrict_cplusplus \
return_const_value \
return_value_scope \
@@ -292,6 +299,7 @@ CPP_TEST_CASES += \
sizet \
smart_pointer_const \
smart_pointer_const2 \
+ smart_pointer_const_overload \
smart_pointer_extend \
smart_pointer_member \
smart_pointer_multi \
@@ -315,11 +323,11 @@ CPP_TEST_CASES += \
struct_initialization_cpp \
struct_value \
symbol_clash \
- template \
template_arg_replace \
template_arg_scope \
template_arg_typename \
template_array_numeric \
+ template_basic \
template_base_template \
template_classes \
template_const_ref \
@@ -393,6 +401,7 @@ CPP_TEST_CASES += \
typedef_scope \
typedef_sizet \
typedef_struct \
+ typemap_arrays \
typemap_delete \
typemap_global_scope \
typemap_namespace \
@@ -463,7 +472,7 @@ C_TEST_CASES += \
extern_declaration \
funcptr \
function_typedef \
- immutable \
+ immutable_values \
inctest \
integers \
keyword_rename \
@@ -484,6 +493,9 @@ C_TEST_CASES += \
overload_extendc \
preproc \
preproc_constants_c \
+ preproc_defined \
+ preproc_include \
+ preproc_line_file \
ret_by_value \
simple_array \
sizeof_pointer \
@@ -507,6 +519,7 @@ MULTI_CPP_TEST_CASES += \
# Custom tests - tests with additional commandline options
wallkw.cpptest: SWIGOPT += -Wallkw
+preproc_include.ctest: SWIGOPT += -includeall
NOT_BROKEN_TEST_CASES = $(CPP_TEST_CASES:=.cpptest) \
diff --git a/Examples/test-suite/constant_pointers.i b/Examples/test-suite/constant_pointers.i
index 7d46cdb31..388970c4d 100644
--- a/Examples/test-suite/constant_pointers.i
+++ b/Examples/test-suite/constant_pointers.i
@@ -5,7 +5,8 @@ This testcase primarily test constant pointers, eg int* const. Only a getter is
%module constant_pointers
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
-%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'Foo' due to Go name ('Foo') conflict with 'foo' */
+%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG); /* Setting a pointer/reference variable may leak memory. */
+
%inline %{
@@ -50,7 +51,7 @@ public:
private:
MemberVariablesTest& operator=(const MemberVariablesTest&);
};
-void foo(const int *const i) {}
+void foofunction(const int *const i) {}
typedef int *typedef1, typedef2, *const typedef3;
int int1, int2=2, *int3, *const int4 = &GlobalInt;
diff --git a/Examples/test-suite/contract.i b/Examples/test-suite/contract.i
index b979ef19e..0ad7e8e7c 100644
--- a/Examples/test-suite/contract.i
+++ b/Examples/test-suite/contract.i
@@ -3,12 +3,17 @@
%warnfilter(SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) C; /* Ruby, C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) C; /* Ruby, C#, D, Java, PHP multiple inheritance */
#ifdef SWIGCSHARP
%ignore B::bar; // otherwise get a warning: `C.bar' no suitable methods found to override
#endif
+#ifdef SWIGD
+%ignore B::bar; // Prevents getting an error that C.bar does not override any function because multiple inheritance is not supported.
+#endif
+
%contract test_preassert(int a, int b) {
require:
a > 0;
diff --git a/Examples/test-suite/csharp/Makefile.in b/Examples/test-suite/csharp/Makefile.in
index 5f50095a1..18f10c567 100644
--- a/Examples/test-suite/csharp/Makefile.in
+++ b/Examples/test-suite/csharp/Makefile.in
@@ -8,8 +8,8 @@ INTERPRETER = @CSHARPCILINTERPRETER@
CSHARPPATHSEPARATOR = "@CSHARPPATHSEPARATOR@"
CSHARPCYGPATH_W = @CSHARPCYGPATH_W@
srcdir = @srcdir@
-top_srcdir = @top_srcdir@/..
-top_builddir = @top_builddir@/..
+top_srcdir = ../@top_srcdir@
+top_builddir = ../@top_builddir@
CPP_TEST_CASES = \
csharp_attributes \
@@ -64,12 +64,13 @@ setup = \
# Compiles C# files then runs the testcase. A testcase is only run if
# a file is found which has _runme.cs appended after the testcase name.
# Note C# uses LD_LIBRARY_PATH under Unix, PATH under Cygwin/Windows and SHLIB_PATH on HPUX.
+# DYLD_FALLBACK_LIBRARY_PATH is cleared for MacOSX.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
- env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \
+ env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" DYLD_FALLBACK_LIBRARY_PATH= $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \
else \
cd $* && \
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
diff --git a/Examples/test-suite/csharp/csharp_prepost_runme.cs b/Examples/test-suite/csharp/csharp_prepost_runme.cs
index d0bacdaba..f76dae38e 100644
--- a/Examples/test-suite/csharp/csharp_prepost_runme.cs
+++ b/Examples/test-suite/csharp/csharp_prepost_runme.cs
@@ -55,6 +55,43 @@ public class csharp_prepost_runme {
throw new Exception("Expecting CustomInt attribute");
}
}
+ // Dates
+ {
+ // pre post typemap attributes example
+ System.DateTime dateIn = new System.DateTime(2011, 4, 13);
+ System.DateTime dateOut = new System.DateTime();
+
+ // Note in calls below, dateIn remains unchanged and dateOut
+ // is set to a new value by the C++ call
+ csharp_prepostNamespace.Action action = new csharp_prepostNamespace.Action(dateIn, out dateOut);
+ if (dateOut != dateIn)
+ throw new Exception("dates wrong");
+
+ dateIn = new System.DateTime(2012, 7, 14);
+ action.doSomething(dateIn, out dateOut);
+ if (dateOut != dateIn)
+ throw new Exception("dates wrong");
+
+ System.DateTime refDate = new System.DateTime(1999, 12, 31);
+ if (csharp_prepost.ImportantDate != refDate)
+ throw new Exception("dates wrong");
+
+ refDate = new System.DateTime(1999, 12, 31);
+ csharp_prepost.ImportantDate = refDate;
+ System.DateTime importantDate = csharp_prepost.ImportantDate;
+ if (importantDate != refDate)
+ throw new Exception("dates wrong");
+
+ System.DateTime christmasEve = new System.DateTime(2000, 12, 24);
+ csharp_prepost.addYears(ref christmasEve, 10);
+ if (christmasEve != new System.DateTime(2010, 12, 24))
+ throw new Exception("dates wrong");
+
+ Person person = new Person();
+ person.Birthday = christmasEve;
+ if (person.Birthday != christmasEve)
+ throw new Exception("dates wrong");
+ }
}
private static void Assert(double d1, double d2) {
if (d1 != d2)
diff --git a/Examples/test-suite/csharp/director_alternating_runme.cs b/Examples/test-suite/csharp/director_alternating_runme.cs
new file mode 100644
index 000000000..19365217a
--- /dev/null
+++ b/Examples/test-suite/csharp/director_alternating_runme.cs
@@ -0,0 +1,11 @@
+
+using System;
+using director_alternatingNamespace;
+
+public class director_alternating_runme {
+ public static void Main() {
+ if (director_alternating.getBar().id() != director_alternating.idFromGetBar())
+ throw new Exception("idFromGetBar failed");
+ }
+}
+
diff --git a/Examples/test-suite/csharp/director_protected_runme.cs b/Examples/test-suite/csharp/director_protected_runme.cs
index ee4697b0e..b44c3b7e9 100644
--- a/Examples/test-suite/csharp/director_protected_runme.cs
+++ b/Examples/test-suite/csharp/director_protected_runme.cs
@@ -16,6 +16,7 @@ public class runme
Foo f = b.create();
FooBar fb = new FooBar();
FooBar2 fb2 = new FooBar2();
+ FooBar3 fb3 = new FooBar3();
String s;
s = fb.used();
@@ -37,6 +38,21 @@ public class runme
s = fb.pong();
if ( s != ("Bar::pong();Foo::pong();FooBar::ping();"))
throw new Exception("bad FooBar::pong");
+
+// if (fb3.cheer() != "FooBar3::cheer();")
+// throw new Exception("bad fb3::cheer");
+
+ if (fb2.callping() != "FooBar2::ping();")
+ throw new Exception("bad fb2.callping");
+
+ if (fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();")
+ throw new Exception("bad fb2.callcheer");
+
+ if (fb3.callping() != "Bar::ping();")
+ throw new Exception("bad fb3.callping");
+
+ if (fb3.callcheer() != "FooBar3::cheer();")
+ throw new Exception("bad fb3.callcheer");
}
}
@@ -69,4 +85,16 @@ class FooBar2 : Bar
}
}
+class FooBar3 : Bar
+{
+ public FooBar3() : base()
+ {
+ }
+
+ protected override String cheer()
+ {
+ return "FooBar3::cheer();";
+ }
+}
+
}
diff --git a/Examples/test-suite/csharp/pointer_reference_runme.cs b/Examples/test-suite/csharp/pointer_reference_runme.cs
index d00555199..2b9f526af 100644
--- a/Examples/test-suite/csharp/pointer_reference_runme.cs
+++ b/Examples/test-suite/csharp/pointer_reference_runme.cs
@@ -12,6 +12,9 @@ public class pointer_reference_runme {
Struct ss = new Struct(20);
pointer_reference.set(ss);
if (Struct.instance.value != 20) throw new Exception("set test failed");
+
+ if (pointer_reference.overloading(1) != 111) throw new Exception("overload test 1 failed");
+ if (pointer_reference.overloading(ss) != 222) throw new Exception("overload test 2 failed");
}
}
diff --git a/Examples/test-suite/csharp/rename_pcre_encoder_runme.cs b/Examples/test-suite/csharp/rename_pcre_encoder_runme.cs
new file mode 100644
index 000000000..f6289e7e2
--- /dev/null
+++ b/Examples/test-suite/csharp/rename_pcre_encoder_runme.cs
@@ -0,0 +1,12 @@
+using System;
+using rename_pcre_encoderNamespace;
+
+public class runme {
+ static void Main() {
+ SomeWidget w = new SomeWidget();
+ w.putBorderWidth(17);
+ if ( w.getBorderWidth() != 17 )
+ throw new Exception(String.Format("Border with should be 17, not {0}",
+ w.getBorderWidth()));
+ }
+}
diff --git a/Examples/test-suite/csharp/rename_pcre_enum_runme.cs b/Examples/test-suite/csharp/rename_pcre_enum_runme.cs
new file mode 100644
index 000000000..0143eda33
--- /dev/null
+++ b/Examples/test-suite/csharp/rename_pcre_enum_runme.cs
@@ -0,0 +1,24 @@
+using System;
+using rename_pcre_enumNamespace;
+
+public class runme {
+ static void Main() {
+ Foo foo = Foo.First;
+ if ( foo == Foo.Second )
+ throw new Exception("Enum values should be different");
+
+ // Check that Foo_Max enum element was ignored.
+ int numFooEnumElements = Enum.GetValues(typeof(Foo)).Length;
+ if ( numFooEnumElements != 2 )
+ throw new Exception(String.Format("Enum should have 2 elements, not {0}",
+ numFooEnumElements));
+
+ BoundaryCondition bc = BoundaryCondition.MaxMax;
+ if ( (int)bc != 2 )
+ throw new Exception("Wrong enum value");
+
+ Colour c = Colour.red;
+ if ( c == Colour.blue )
+ throw new Exception("Enum values should be different");
+ }
+}
diff --git a/Examples/test-suite/csharp/rename_simple_runme.cs b/Examples/test-suite/csharp/rename_simple_runme.cs
new file mode 100644
index 000000000..edf05ad24
--- /dev/null
+++ b/Examples/test-suite/csharp/rename_simple_runme.cs
@@ -0,0 +1,30 @@
+
+using System;
+using rename_simpleNamespace;
+
+public class rename_simple_runme {
+
+ public static void Main() {
+ NewStruct s = new NewStruct();
+ check(111, s.NewInstanceVariable, "NewInstanceVariable");
+ check(222, s.NewInstanceMethod(), "NewInstanceMethod");
+ check(333, NewStruct.NewStaticMethod(), "NewStaticMethod");
+ check(444, NewStruct.NewStaticVariable, "NewStaticVariable");
+ check(555, rename_simple.NewFunction(), "NewFunction");
+ check(666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
+
+ s.NewInstanceVariable = 1111;
+ NewStruct.NewStaticVariable = 4444;
+ rename_simple.NewGlobalVariable = 6666;
+
+ check(1111, s.NewInstanceVariable, "NewInstanceVariable");
+ check(4444, NewStruct.NewStaticVariable, "NewStaticVariable");
+ check(6666, rename_simple.NewGlobalVariable, "NewGlobalVariable");
+ }
+
+ public static void check(int expected, int actual, string msg) {
+ if (expected != actual)
+ throw new Exception("Failed: Expected: " + expected + " actual: " + actual + " " + msg);
+ }
+}
+
diff --git a/Examples/test-suite/csharp_attributes.i b/Examples/test-suite/csharp_attributes.i
index bca595d9a..f679d8c08 100644
--- a/Examples/test-suite/csharp_attributes.i
+++ b/Examples/test-suite/csharp_attributes.i
@@ -56,7 +56,7 @@ double MoreStations::WestonSuperMare = 0.0;
%inline %{
struct YetMoreStations {
- virtual int Slough(int x) {}
+ virtual int Slough(int x) { return x; }
virtual ~YetMoreStations() {}
};
%}
diff --git a/Examples/test-suite/csharp_prepost.i b/Examples/test-suite/csharp_prepost.i
index 817f5b9b9..31e6ec753 100644
--- a/Examples/test-suite/csharp_prepost.i
+++ b/Examples/test-suite/csharp_prepost.i
@@ -79,7 +79,7 @@ struct PrePost2 {
// Check attributes in the typemaps
%typemap(cstype, inattributes="[CustomInt]") int val "int"
-%typemap(csin, pre=" int tmp_$csinput = $csinput * 100;") int "tmp_$csinput"
+%typemap(csin, pre=" int tmp_$csinput = $csinput * 100;") int val "tmp_$csinput"
%typemap(imtype, out="IntPtr/*overridden*/", outattributes="[CustomIntPtr]") CsinAttributes * "HandleRef/*overridden*/"
%inline %{
@@ -188,5 +188,8 @@ void subtractYears(CDate *pDate, int years) {
%inline %{
CDate ImportantDate = CDate(1999, 12, 31);
+struct Person {
+ CDate Birthday;
+};
%}
diff --git a/Examples/test-suite/d/Makefile.in b/Examples/test-suite/d/Makefile.in
new file mode 100644
index 000000000..0f5bf8cbb
--- /dev/null
+++ b/Examples/test-suite/d/Makefile.in
@@ -0,0 +1,81 @@
+#######################################################################
+# Makefile for D test-suite
+#######################################################################
+
+LANGUAGE = d
+srcdir = @srcdir@
+top_srcdir = ../@top_srcdir@
+top_builddir = ../@top_builddir@
+
+ifeq (2,$(D_VERSION))
+ VERSIONSUFFIX = .2
+else
+ VERSIONSUFFIX = .1
+endif
+
+TESTSUFFIX = _runme$(VERSIONSUFFIX).d
+
+CPP_TEST_CASES = \
+ d_exception_name \
+ d_nativepointers \
+ exception_partial_info
+
+include $(srcdir)/../common.mk
+
+# Override some variables from common.mk:
+
+TARGETSUFFIX = _wrap
+
+SWIGOPT+=-splitproxy -package $*
+
+# Rules for the different types of tests
+%.cpptest:
+ $(setup)
+ +(cd $*$(VERSIONSUFFIX) && $(swig_and_compile_cpp))
+ +$(run_testcase)
+
+%.ctest:
+ $(setup)
+ +(cd $*$(VERSIONSUFFIX) && $(swig_and_compile_c))
+ +$(run_testcase)
+
+%.multicpptest:
+ $(setup)
+ +(cd $*$(VERSIONSUFFIX) && $(swig_and_compile_multi_cpp))
+ +$(run_testcase)
+
+# Makes a directory for the testcase if it does not exist
+setup = \
+ if [ -f $(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) ]; then \
+ echo "$(ACTION)ing testcase $* (with run test) under $(LANGUAGE)" ; \
+ else \
+ echo "$(ACTION)ing testcase $* under $(LANGUAGE)" ; \
+ fi; \
+ if [ ! -d $*$(VERSIONSUFFIX) ]; then \
+ mkdir $*$(VERSIONSUFFIX); \
+ fi; \
+ if [ ! -d $*$(VERSIONSUFFIX)/$* ]; then \
+ mkdir $*$(VERSIONSUFFIX)/$*; \
+ fi
+
+# Compiles D files then runs the testcase. A testcase is only run if
+# a file is found which has _runme.d appended after the testcase name.
+run_testcase = \
+ if [ -f $(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) ]; then \
+ cd $*$(VERSIONSUFFIX) && \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
+ DFLAGS='-of$*_runme' \
+ DSRCS='../$(srcdir)/$(TESTPREFIX)$*$(TESTSUFFIX) $*/*.d' d_compile && \
+ env LD_LIBRARY_PATH=".:$$LD_LIBRARY_PATH" $(RUNTOOL) ./$*_runme; \
+ else \
+ cd $*$(VERSIONSUFFIX) && \
+ $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
+ DFLAGS='-c' \
+ DSRCS='$*/*.d' d_compile && cd .. ; \
+ fi
+
+# Clean: remove testcase directories
+%.clean:
+ @if [ -d $*$(VERSIONSUFFIX) ]; then \
+ rm -rf $*$(VERSIONSUFFIX); \
+ fi
diff --git a/Examples/test-suite/d/README b/Examples/test-suite/d/README
new file mode 100644
index 000000000..bb5372882
--- /dev/null
+++ b/Examples/test-suite/d/README
@@ -0,0 +1,7 @@
+D language module testsuite
+---------------------------
+
+Please see ../README for the common readme file.
+
+By default the D1 version is built, set D_VERSION=2 (in the environment or at
+the make command line) to run it for D2 instead.
diff --git a/Examples/test-suite/d/aggregate_runme.1.d b/Examples/test-suite/d/aggregate_runme.1.d
new file mode 100644
index 000000000..a00d34c25
--- /dev/null
+++ b/Examples/test-suite/d/aggregate_runme.1.d
@@ -0,0 +1,25 @@
+module aggregate_runme;
+
+import aggregate.aggregate;
+
+void main() {
+ // Confirm that move() returns correct results under normal use.
+ int result = move(UP);
+ if (result != UP) throw new Exception("UP failed");
+
+ result = move(DOWN);
+ if (result != DOWN) throw new Exception("DOWN failed");
+
+ result = move(LEFT);
+ if (result != LEFT) throw new Exception("LEFT failed");
+
+ result = move(RIGHT);
+ if (result != RIGHT) throw new Exception("RIGHT failed");
+
+ // Confirm that move() raises an exception when the contract is violated.
+ try {
+ move(0);
+ throw new Exception("0 test failed");
+ }
+ catch (Exception e) {}
+}
diff --git a/Examples/test-suite/d/aggregate_runme.2.d b/Examples/test-suite/d/aggregate_runme.2.d
new file mode 100644
index 000000000..a00d34c25
--- /dev/null
+++ b/Examples/test-suite/d/aggregate_runme.2.d
@@ -0,0 +1,25 @@
+module aggregate_runme;
+
+import aggregate.aggregate;
+
+void main() {
+ // Confirm that move() returns correct results under normal use.
+ int result = move(UP);
+ if (result != UP) throw new Exception("UP failed");
+
+ result = move(DOWN);
+ if (result != DOWN) throw new Exception("DOWN failed");
+
+ result = move(LEFT);
+ if (result != LEFT) throw new Exception("LEFT failed");
+
+ result = move(RIGHT);
+ if (result != RIGHT) throw new Exception("RIGHT failed");
+
+ // Confirm that move() raises an exception when the contract is violated.
+ try {
+ move(0);
+ throw new Exception("0 test failed");
+ }
+ catch (Exception e) {}
+}
diff --git a/Examples/test-suite/d/allprotected_runme.1.d b/Examples/test-suite/d/allprotected_runme.1.d
new file mode 100644
index 000000000..82a180e66
--- /dev/null
+++ b/Examples/test-suite/d/allprotected_runme.1.d
@@ -0,0 +1,65 @@
+module allprotected_runme;
+
+import allprotected.Klass;
+import allprotected.ProtectedBase;
+
+void main() {
+ auto mpb = new MyProtectedBase("MyProtectedBase");
+ mpb.accessProtected();
+}
+
+class MyProtectedBase : ProtectedBase {
+public:
+ this(char[] name) {
+ super(name);
+ }
+
+ void accessProtected() {
+ char[] s = virtualMethod();
+ if (s != "ProtectedBase")
+ throw new Exception("Failed");
+
+ Klass k = instanceMethod(new Klass("xyz"));
+ if (k.getName() != "xyz")
+ throw new Exception("Failed");
+
+ k = instanceOverloaded(new Klass("xyz"));
+ if (k.getName() != "xyz")
+ throw new Exception("Failed");
+
+ k = instanceOverloaded(new Klass("xyz"), "abc");
+ if (k.getName() != "abc")
+ throw new Exception("Failed");
+
+ k = staticMethod(new Klass("abc"));
+ if (k.getName() != "abc")
+ throw new Exception("Failed");
+
+ k = staticOverloaded(new Klass("xyz"));
+ if (k.getName() != "xyz")
+ throw new Exception("Failed");
+
+ k = staticOverloaded(new Klass("xyz"), "abc");
+ if (k.getName() != "abc")
+ throw new Exception("Failed");
+
+ instanceMemberVariable = 30;
+ int i = instanceMemberVariable;
+ if (i != 30)
+ throw new Exception("Failed");
+
+ staticMemberVariable = 40;
+ i = staticMemberVariable;
+ if (i != 40)
+ throw new Exception("Failed");
+
+ i = staticConstMemberVariable;
+ if (i != 20)
+ throw new Exception("Failed");
+
+ anEnum = ProtectedBase.AnEnum.EnumVal1;
+ ProtectedBase.AnEnum ae = anEnum;
+ if (ae != ProtectedBase.AnEnum.EnumVal1)
+ throw new Exception("Failed");
+ }
+}
diff --git a/Examples/test-suite/d/allprotected_runme.2.d b/Examples/test-suite/d/allprotected_runme.2.d
new file mode 100644
index 000000000..799230291
--- /dev/null
+++ b/Examples/test-suite/d/allprotected_runme.2.d
@@ -0,0 +1,65 @@
+module allprotected_runme;
+
+import allprotected.Klass;
+import allprotected.ProtectedBase;
+
+void main() {
+ auto mpb = new MyProtectedBase("MyProtectedBase");
+ mpb.accessProtected();
+}
+
+class MyProtectedBase : ProtectedBase {
+public:
+ this(string name) {
+ super(name);
+ }
+
+ void accessProtected() {
+ string s = virtualMethod();
+ if (s != "ProtectedBase")
+ throw new Exception("Failed");
+
+ Klass k = instanceMethod(new Klass("xyz"));
+ if (k.getName() != "xyz")
+ throw new Exception("Failed");
+
+ k = instanceOverloaded(new Klass("xyz"));
+ if (k.getName() != "xyz")
+ throw new Exception("Failed");
+
+ k = instanceOverloaded(new Klass("xyz"), "abc");
+ if (k.getName() != "abc")
+ throw new Exception("Failed");
+
+ k = staticMethod(new Klass("abc"));
+ if (k.getName() != "abc")
+ throw new Exception("Failed");
+
+ k = staticOverloaded(new Klass("xyz"));
+ if (k.getName() != "xyz")
+ throw new Exception("Failed");
+
+ k = staticOverloaded(new Klass("xyz"), "abc");
+ if (k.getName() != "abc")
+ throw new Exception("Failed");
+
+ instanceMemberVariable = 30;
+ int i = instanceMemberVariable;
+ if (i != 30)
+ throw new Exception("Failed");
+
+ staticMemberVariable = 40;
+ i = staticMemberVariable;
+ if (i != 40)
+ throw new Exception("Failed");
+
+ i = staticConstMemberVariable;
+ if (i != 20)
+ throw new Exception("Failed");
+
+ anEnum = ProtectedBase.AnEnum.EnumVal1;
+ ProtectedBase.AnEnum ae = anEnum;
+ if (ae != ProtectedBase.AnEnum.EnumVal1)
+ throw new Exception("Failed");
+ }
+}
diff --git a/Examples/test-suite/d/apply_strings_runme.1.d b/Examples/test-suite/d/apply_strings_runme.1.d
new file mode 100644
index 000000000..960caa4ca
--- /dev/null
+++ b/Examples/test-suite/d/apply_strings_runme.1.d
@@ -0,0 +1,12 @@
+module apply_strings_runme;
+
+import apply_strings.apply_strings;
+
+const char[] TEST_MESSAGE = "A message from target language to the C++ world and back again.";
+
+void main() {
+ if (UCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("UCharFunction failed");
+ if (SCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("SCharFunction failed");
+ auto pChar = CharFunction(null);
+ if (pChar !is null) throw new Exception("CharFunction failed");
+}
diff --git a/Examples/test-suite/d/apply_strings_runme.2.d b/Examples/test-suite/d/apply_strings_runme.2.d
new file mode 100644
index 000000000..86183f8a3
--- /dev/null
+++ b/Examples/test-suite/d/apply_strings_runme.2.d
@@ -0,0 +1,12 @@
+module apply_strings_runme;
+
+import apply_strings.apply_strings;
+
+enum string TEST_MESSAGE = "A message from target language to the C++ world and back again.";
+
+void main() {
+ if (UCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("UCharFunction failed");
+ if (SCharFunction(TEST_MESSAGE) != TEST_MESSAGE) throw new Exception("SCharFunction failed");
+ auto pChar = CharFunction(null);
+ if (pChar !is null) throw new Exception("CharFunction failed");
+}
diff --git a/Examples/test-suite/d/bools_runme.1.d b/Examples/test-suite/d/bools_runme.1.d
new file mode 100644
index 000000000..f501b0762
--- /dev/null
+++ b/Examples/test-suite/d/bools_runme.1.d
@@ -0,0 +1,20 @@
+/// This is the bool runtime testcase. It checks that the C++ bool type works.
+module bools_runme;
+
+import bools.bools;
+
+void main() {
+ bool t = true;
+ bool f = false;
+
+ check_bo(f);
+ check_bo(t);
+}
+
+void check_bo(bool input) {
+ for (int i = 0; i < 1000; ++i) {
+ if (bo(input) != input) {
+ throw new Exception("Runtime test check_bo failed.");
+ }
+ }
+}
diff --git a/Examples/test-suite/d/bools_runme.2.d b/Examples/test-suite/d/bools_runme.2.d
new file mode 100644
index 000000000..f501b0762
--- /dev/null
+++ b/Examples/test-suite/d/bools_runme.2.d
@@ -0,0 +1,20 @@
+/// This is the bool runtime testcase. It checks that the C++ bool type works.
+module bools_runme;
+
+import bools.bools;
+
+void main() {
+ bool t = true;
+ bool f = false;
+
+ check_bo(f);
+ check_bo(t);
+}
+
+void check_bo(bool input) {
+ for (int i = 0; i < 1000; ++i) {
+ if (bo(input) != input) {
+ throw new Exception("Runtime test check_bo failed.");
+ }
+ }
+}
diff --git a/Examples/test-suite/d/catches_runme.1.d b/Examples/test-suite/d/catches_runme.1.d
new file mode 100644
index 000000000..55b18132d
--- /dev/null
+++ b/Examples/test-suite/d/catches_runme.1.d
@@ -0,0 +1,33 @@
+module catches_runme;
+
+import catches.catches;
+
+void main() {
+ test({ test_catches(1); }, "C++ int exception thrown, value: 1");
+ test({ test_catches(2); }, "two");
+ test({ test_catches(3); }, "C++ ThreeException const & exception thrown");
+
+ test({ test_exception_specification(1); }, "C++ int exception thrown, value: 1");
+ test({ test_exception_specification(2); }, "unknown exception");
+ test({ test_exception_specification(3); }, "unknown exception");
+
+ test({ test_catches_all(1); }, "unknown exception");
+}
+
+void test(void delegate() command, char[] expectedMessage) {
+ bool didntThrow;
+ try {
+ command();
+ didntThrow = true;
+ } catch (Exception e) {
+ if (e.msg != expectedMessage) {
+ throw new Exception("Failed to propagate C++ exception. Expected '" ~
+ expectedMessage ~ "', but received '" ~ e.msg ~ "'.");
+ }
+ }
+
+ if (didntThrow) {
+ throw new Exception("Failed to propagate C++ exception. Expected '" ~
+ expectedMessage ~ "', but no exception was thrown.");
+ }
+}
diff --git a/Examples/test-suite/d/catches_runme.2.d b/Examples/test-suite/d/catches_runme.2.d
new file mode 100644
index 000000000..508558485
--- /dev/null
+++ b/Examples/test-suite/d/catches_runme.2.d
@@ -0,0 +1,33 @@
+module catches_runme;
+
+import catches.catches;
+
+void main() {
+ test({ test_catches(1); }, "C++ int exception thrown, value: 1");
+ test({ test_catches(2); }, "two");
+ test({ test_catches(3); }, "C++ ThreeException const & exception thrown");
+
+ test({ test_exception_specification(1); }, "C++ int exception thrown, value: 1");
+ test({ test_exception_specification(2); }, "unknown exception");
+ test({ test_exception_specification(3); }, "unknown exception");
+
+ test({ test_catches_all(1); }, "unknown exception");
+}
+
+void test(void delegate() command, string expectedMessage) {
+ bool didntThrow;
+ try {
+ command();
+ didntThrow = true;
+ } catch (Exception e) {
+ if (e.msg != expectedMessage) {
+ throw new Exception("Failed to propagate C++ exception. Expected '" ~
+ expectedMessage ~ "', but received '" ~ e.msg ~ "'.");
+ }
+ }
+
+ if (didntThrow) {
+ throw new Exception("Failed to propagate C++ exception. Expected '" ~
+ expectedMessage ~ "', but no exception was thrown.");
+ }
+}
diff --git a/Examples/test-suite/d/char_strings_runme.1.d b/Examples/test-suite/d/char_strings_runme.1.d
new file mode 100644
index 000000000..cde6fe0f7
--- /dev/null
+++ b/Examples/test-suite/d/char_strings_runme.1.d
@@ -0,0 +1,151 @@
+module char_strings_runme;
+
+import tango.text.convert.Integer;
+import char_strings.char_strings;
+
+const char[] CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible.";
+const char[] OTHERLAND_MSG = "Little message from the safe world.";
+
+void main() {
+ const uint count = 10000;
+ uint i = 0;
+
+ // get functions
+ for (i=0; i<count; i++) {
+ char[] str = GetCharHeapString();
+ if (str != CPLUSPLUS_MSG)
+ throw new Exception("Test char get 1 failed, iteration " ~ toString(i));
+ DeleteCharHeapString();
+ }
+
+ for (i=0; i<count; i++) {
+ char[] str = GetConstCharProgramCodeString();
+ if (str != CPLUSPLUS_MSG)
+ throw new Exception("Test char get 2 failed, iteration " ~ toString(i));
+ DeleteCharHeapString();
+ }
+
+ for (i=0; i<count; i++) {
+ char[] str = GetCharStaticString();
+ if (str != CPLUSPLUS_MSG)
+ throw new Exception("Test char get 3 failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ char[] str = GetCharStaticStringFixed();
+ if (str != CPLUSPLUS_MSG)
+ throw new Exception("Test char get 4 failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ char[] str = GetConstCharStaticStringFixed();
+ if (str != CPLUSPLUS_MSG)
+ throw new Exception("Test char get 5 failed, iteration " ~ toString(i));
+ }
+
+ // set functions
+ for (i=0; i<count; i++) {
+ if (!SetCharHeapString(OTHERLAND_MSG ~ toString(i), i))
+ throw new Exception("Test char set 1 failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ if (!SetCharStaticString(OTHERLAND_MSG ~ toString(i), i))
+ throw new Exception("Test char set 2 failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ if (!SetCharArrayStaticString(OTHERLAND_MSG ~ toString(i), i))
+ throw new Exception("Test char set 3 failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ if (!SetConstCharHeapString(OTHERLAND_MSG ~ toString(i), i))
+ throw new Exception("Test char set 4 failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ if (!SetConstCharStaticString(OTHERLAND_MSG ~ toString(i), i))
+ throw new Exception("Test char set 5 failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ if (!SetConstCharArrayStaticString(OTHERLAND_MSG ~ toString(i), i))
+ throw new Exception("Test char set 6 failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ if (!SetCharConstStaticString(OTHERLAND_MSG ~ toString(i), i))
+ throw new Exception("Test char set 7 failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ if (!SetConstCharConstStaticString(OTHERLAND_MSG ~ toString(i), i))
+ throw new Exception("Test char set 8 failed, iteration " ~ toString(i));
+ }
+
+ // get set function
+ for (i=0; i<count*10; i++) {
+ char[] ping = OTHERLAND_MSG ~ toString(i);
+ char[] pong = CharPingPong(ping);
+ if (ping != pong)
+ throw new Exception("Test PingPong 1 failed.\nExpected:" ~ ping ~ "\nReceived:" ~ pong);
+ }
+
+ // variables
+ for (i=0; i<count; i++) {
+ global_char = OTHERLAND_MSG ~ toString(i);
+ if (global_char != OTHERLAND_MSG ~ toString(i))
+ throw new Exception("Test variables 1 failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ global_char_array1 = OTHERLAND_MSG ~ toString(i);
+ if (global_char_array1 != OTHERLAND_MSG ~ toString(i))
+ throw new Exception("Test variables 2 failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ global_char_array2 = OTHERLAND_MSG ~ toString(i);
+ if (global_char_array2 != OTHERLAND_MSG ~ toString(i))
+ throw new Exception("Test variables 3 failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ if (global_const_char != CPLUSPLUS_MSG)
+ throw new Exception("Test variables 4 failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ if (global_const_char_array1 != CPLUSPLUS_MSG)
+ throw new Exception("Test variables 5 failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ if (global_const_char_array2 != CPLUSPLUS_MSG)
+ throw new Exception("Test variables 6 failed, iteration " ~ toString(i));
+ }
+
+ // char *& tests
+ for (i=0; i<count; i++) {
+ char[] str = GetCharPointerRef();
+ if (str != CPLUSPLUS_MSG)
+ throw new Exception("Test char pointer ref get failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ if (!SetCharPointerRef(OTHERLAND_MSG ~ toString(i), i))
+ throw new Exception("Test char pointer ref set failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ char[] str = GetConstCharPointerRef();
+ if (str != CPLUSPLUS_MSG)
+ throw new Exception("Test const char pointer ref get failed, iteration " ~ toString(i));
+ }
+
+ for (i=0; i<count; i++) {
+ if (!SetConstCharPointerRef(OTHERLAND_MSG ~ toString(i), i))
+ throw new Exception("Test const char pointer ref set failed, iteration " ~ toString(i));
+ }
+}
diff --git a/Examples/test-suite/d/char_strings_runme.2.d b/Examples/test-suite/d/char_strings_runme.2.d
new file mode 100644
index 000000000..5fe28e995
--- /dev/null
+++ b/Examples/test-suite/d/char_strings_runme.2.d
@@ -0,0 +1,123 @@
+module char_strings_runme;
+
+import std.conv;
+import std.exception;
+import std.range;
+import char_strings.char_strings;
+
+enum CPLUSPLUS_MSG = "A message from the deep dark world of C++, where anything is possible.";
+enum OTHERLAND_MSG = "Little message from the safe world.";
+enum TEST_RANGE = iota(0, 10000);
+
+void main() {
+ // get functions
+ foreach (i; TEST_RANGE) {
+ enforce(GetCharHeapString() == CPLUSPLUS_MSG, "Test char get 1 failed, iteration " ~ to!string(i));
+ DeleteCharHeapString();
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(GetConstCharProgramCodeString() == CPLUSPLUS_MSG, "Test char get 2 failed, iteration " ~ to!string(i));
+ DeleteCharHeapString();
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(GetCharStaticString() == CPLUSPLUS_MSG, "Test char get 3 failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(GetCharStaticStringFixed() == CPLUSPLUS_MSG, "Test char get 4 failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(GetConstCharStaticStringFixed() == CPLUSPLUS_MSG, "Test char get 5 failed, iteration " ~ to!string(i));
+ }
+
+ // set functions
+ foreach (i; TEST_RANGE) {
+ enforce(SetCharHeapString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 1 failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(SetCharStaticString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 2 failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(SetCharArrayStaticString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 3 failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(SetConstCharHeapString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 4 failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(SetConstCharStaticString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 5 failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(SetConstCharArrayStaticString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 6 failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(SetCharConstStaticString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 7 failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(SetConstCharConstStaticString(OTHERLAND_MSG ~ to!string(i), i), "Test char set 8 failed, iteration " ~ to!string(i));
+ }
+
+ // get set function
+ foreach (i; TEST_RANGE) {
+ string ping = OTHERLAND_MSG ~ to!string(i);
+ string pong = CharPingPong(ping);
+ enforce(ping == pong, "Test PingPong 1 failed.\nExpected:" ~ ping ~ "\nReceived:" ~ pong);
+ }
+
+ // variables
+ foreach (i; TEST_RANGE) {
+ const msg = OTHERLAND_MSG ~ to!string(i);
+ global_char = msg;
+ enforce(global_char == msg, "Test variables 1 failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ const msg = OTHERLAND_MSG ~ to!string(i);
+ global_char_array1 = msg;
+ enforce(global_char_array1 == msg, "Test variables 2 failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ const msg = OTHERLAND_MSG ~ to!string(i);
+ global_char_array2 = msg;
+ enforce(global_char_array2 == msg, "Test variables 2 failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(global_const_char == CPLUSPLUS_MSG, "Test variables 4 failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(global_const_char_array1 == CPLUSPLUS_MSG, "Test variables 5 failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(global_const_char_array2 == CPLUSPLUS_MSG, "Test variables 6 failed, iteration " ~ to!string(i));
+ }
+
+ // char *& tests
+ foreach (i; TEST_RANGE) {
+ enforce(GetCharPointerRef() == CPLUSPLUS_MSG, "Test char pointer ref get failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(SetCharPointerRef(OTHERLAND_MSG ~ to!string(i), i), "Test char pointer ref set failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(GetConstCharPointerRef() == CPLUSPLUS_MSG, "Test const char pointer ref get failed, iteration " ~ to!string(i));
+ }
+
+ foreach (i; TEST_RANGE) {
+ enforce(SetConstCharPointerRef(OTHERLAND_MSG ~ to!string(i), i), "Test const char pointer ref set failed, iteration " ~ to!string(i));
+ }
+}
diff --git a/Examples/test-suite/d/constover_runme.1.d b/Examples/test-suite/d/constover_runme.1.d
new file mode 100644
index 000000000..ead67319e
--- /dev/null
+++ b/Examples/test-suite/d/constover_runme.1.d
@@ -0,0 +1,31 @@
+module constover_runme;
+
+import constover.constover;
+import constover.Foo;
+
+void main() {
+ char[] p = test("test");
+ if (p != "test")
+ throw new Exception("test failed!");
+
+ p = test_pconst("test");
+ if (p != "test_pconst")
+ throw new Exception("test_pconst failed!");
+
+ auto f = new Foo();
+ p = f.test("test");
+ if (p != "test")
+ throw new Exception("member-test failed!");
+
+ p = f.test_pconst("test");
+ if (p != "test_pconst")
+ throw new Exception("member-test_pconst failed!");
+
+ p = f.test_constm("test");
+ if (p != "test_constmethod")
+ throw new Exception("member-test_constm failed!");
+
+ p = f.test_pconstm("test");
+ if (p != "test_pconstmethod")
+ throw new Exception("member-test_pconstm failed!");
+}
diff --git a/Examples/test-suite/d/constover_runme.2.d b/Examples/test-suite/d/constover_runme.2.d
new file mode 100644
index 000000000..68f7f207a
--- /dev/null
+++ b/Examples/test-suite/d/constover_runme.2.d
@@ -0,0 +1,16 @@
+module constover_runme;
+
+import std.exception;
+import constover.constover;
+import constover.Foo;
+
+void main() {
+ enforce(test("test") == "test", "test failed!");
+ enforce(test_pconst("test") == "test_pconst", "test_pconst failed!");
+
+ auto f = new Foo();
+ enforce(f.test("test") == "test", "member-test failed!");
+ enforce(f.test_pconst("test") == "test_pconst", "member-test_pconst failed!");
+ enforce(f.test_constm("test") == "test_constmethod", "member-test_constm failed!");
+ enforce(f.test_pconstm("test") == "test_pconstmethod", "member-test_pconstm failed!");
+}
diff --git a/Examples/test-suite/d/d_nativepointers_runme.1.d b/Examples/test-suite/d/d_nativepointers_runme.1.d
new file mode 100644
index 000000000..797c057d3
--- /dev/null
+++ b/Examples/test-suite/d/d_nativepointers_runme.1.d
@@ -0,0 +1,36 @@
+module d_nativepointers_runnme;
+
+import d_nativepointers.d_nativepointers;
+import d_nativepointers.SomeClass;
+import d_nativepointers.SWIGTYPE_p_OpaqueClass;
+import d_nativepointers.SWIGTYPE_p_p_SomeClass;
+import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void;
+
+void main() {
+ check!(a, int*);
+ check!(b, float**);
+ check!(c, char***);
+ check!(d, SomeClass);
+ check!(e, SWIGTYPE_p_p_SomeClass);
+ check!(f, SWIGTYPE_p_OpaqueClass);
+ check!(g, void function(int**, char***));
+ check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
+
+ {
+ static assert(is(int* function(int*) == typeof(&refA)));
+ int v = 2;
+ assert(*refA(&v) == 2);
+ }
+
+ {
+ static assert(is(float** function(float**) == typeof(&refB)));
+ float v = 1.0;
+ float* p = &v;
+ assert(**refB(&p) == 1.0);
+ }
+}
+
+void check(alias F, T)() {
+ static assert(is(T function(T) == typeof(&F)));
+ assert(F(null) is null);
+}
diff --git a/Examples/test-suite/d/d_nativepointers_runme.2.d b/Examples/test-suite/d/d_nativepointers_runme.2.d
new file mode 100644
index 000000000..797c057d3
--- /dev/null
+++ b/Examples/test-suite/d/d_nativepointers_runme.2.d
@@ -0,0 +1,36 @@
+module d_nativepointers_runnme;
+
+import d_nativepointers.d_nativepointers;
+import d_nativepointers.SomeClass;
+import d_nativepointers.SWIGTYPE_p_OpaqueClass;
+import d_nativepointers.SWIGTYPE_p_p_SomeClass;
+import d_nativepointers.SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void;
+
+void main() {
+ check!(a, int*);
+ check!(b, float**);
+ check!(c, char***);
+ check!(d, SomeClass);
+ check!(e, SWIGTYPE_p_p_SomeClass);
+ check!(f, SWIGTYPE_p_OpaqueClass);
+ check!(g, void function(int**, char***));
+ check!(h, SWIGTYPE_p_p_f_p_p_int_p_SomeClass__void);
+
+ {
+ static assert(is(int* function(int*) == typeof(&refA)));
+ int v = 2;
+ assert(*refA(&v) == 2);
+ }
+
+ {
+ static assert(is(float** function(float**) == typeof(&refB)));
+ float v = 1.0;
+ float* p = &v;
+ assert(**refB(&p) == 1.0);
+ }
+}
+
+void check(alias F, T)() {
+ static assert(is(T function(T) == typeof(&F)));
+ assert(F(null) is null);
+}
diff --git a/Examples/test-suite/d/default_args_runme.1.d b/Examples/test-suite/d/default_args_runme.1.d
new file mode 100644
index 000000000..0ad63b7c2
--- /dev/null
+++ b/Examples/test-suite/d/default_args_runme.1.d
@@ -0,0 +1,127 @@
+module default_args_runme;
+
+import default_args.default_args;
+import default_args.ConstMethods;
+import default_args.EnumClass;
+import default_args.Except;
+import default_args.Foo;
+import default_args.Klass;
+import default_args.Statics;
+import default_args.Tricky;
+
+void main() {
+ if (anonymous() != 7771)
+ throw new Exception("anonymous (1) failed");
+ if (anonymous(1234) != 1234)
+ throw new Exception("anonymous (2) failed");
+
+ if (booltest() != true)
+ throw new Exception("booltest (1) failed");
+ if (booltest(true) != true)
+ throw new Exception("booltest (2) failed");
+ if (booltest(false) != false)
+ throw new Exception("booltest (3) failed");
+
+ auto ec = new EnumClass();
+ if (ec.blah() != true)
+ throw new Exception("EnumClass failed");
+
+ if (casts1() != null)
+ throw new Exception("casts1 failed");
+
+ if (casts2() != "Hello")
+ throw new Exception("casts2 failed");
+
+ if (casts1("Ciao") != "Ciao")
+ throw new Exception("casts1 not default failed");
+
+ if (chartest1() != 'x')
+ throw new Exception("chartest1 failed");
+
+ if (chartest2() != '\0')
+ throw new Exception("chartest2 failed");
+
+ if (chartest1('y') != 'y')
+ throw new Exception("chartest1 not default failed");
+
+ if (chartest1('y') != 'y')
+ throw new Exception("chartest1 not default failed");
+
+ if (reftest1() != 42)
+ throw new Exception("reftest1 failed");
+
+ if (reftest1(400) != 400)
+ throw new Exception("reftest1 not default failed");
+
+ if (reftest2() != "hello")
+ throw new Exception("reftest2 failed");
+
+ // rename
+ auto foo = new Foo();
+ foo.newname();
+ foo.newname(10);
+ foo.renamed3arg(10, 10.0);
+ foo.renamed2arg(10);
+ foo.renamed1arg();
+
+ // exception specifications
+ testException( { exceptionspec(); }, "exceptionspec 1" );
+ testException( { exceptionspec(-1); }, "exceptionspec 2" );
+ testException( { exceptionspec(100); }, "exceptionspec 3" );
+
+ auto ex = new Except(false);
+ testException( { ex.exspec(); }, "exspec 1" );
+ testException( { ex.exspec(-1); }, "exspec 2" );
+ testException( { ex.exspec(100); }, "exspec 3" );
+ testException( { ex = new Except(true); }, "Except constructor 1" );
+ testException( { ex = new Except(true, -2); }, "Except constructor 2" );
+
+ // Default parameters in static class methods
+ if (Statics.staticmethod() != 10+20+30)
+ throw new Exception("staticmethod 1 failed");
+ if (Statics.staticmethod(100) != 100+20+30)
+ throw new Exception("staticmethod 2 failed");
+ if (Statics.staticmethod(100,200,300) != 100+200+300)
+ throw new Exception("staticmethod 3 failed");
+
+
+ auto tricky = new Tricky();
+ if (tricky.privatedefault() != 200)
+ throw new Exception("privatedefault failed");
+ if (tricky.protectedint() != 2000)
+ throw new Exception("protectedint failed");
+ if (tricky.protecteddouble() != 987.654)
+ throw new Exception("protecteddouble failed");
+ if (tricky.functiondefault() != 500)
+ throw new Exception("functiondefault failed");
+ if (tricky.contrived() != 'X')
+ throw new Exception("contrived failed");
+
+ if (constructorcall().val != -1)
+ throw new Exception("constructorcall test 1 failed");
+
+ if (constructorcall(new Klass(2222)).val != 2222)
+ throw new Exception("constructorcall test 2 failed");
+
+ if (constructorcall(new Klass()).val != -1)
+ throw new Exception("constructorcall test 3 failed");
+
+ // const methods
+ auto cm = new ConstMethods();
+ if (cm.coo() != 20)
+ throw new Exception("coo test 1 failed");
+ if (cm.coo(1.0) != 20)
+ throw new Exception("coo test 2 failed");
+}
+
+void testException(void delegate() command, char[] testName) {
+ bool didntThrow;
+ try {
+ command();
+ didntThrow = true;
+ } catch (Exception e) {}
+
+ if (didntThrow) {
+ throw new Exception(testName ~ " failed");
+ }
+}
diff --git a/Examples/test-suite/d/default_args_runme.2.d b/Examples/test-suite/d/default_args_runme.2.d
new file mode 100644
index 000000000..15688aec8
--- /dev/null
+++ b/Examples/test-suite/d/default_args_runme.2.d
@@ -0,0 +1,84 @@
+module default_args_runme;
+
+import std.exception;
+import default_args.default_args;
+import default_args.ConstMethods;
+import default_args.EnumClass;
+import default_args.Except;
+import default_args.Foo;
+import default_args.Klass;
+import default_args.Statics;
+import default_args.Tricky;
+
+void main() {
+ enforce(anonymous() == 7771, "anonymous (1) failed");
+ enforce(anonymous(1234) == 1234,"anonymous (2) failed");
+ enforce(booltest() == true, "booltest (1) failed");
+ enforce(booltest(true) == true, "booltest (2) failed");
+ enforce(booltest(false) == false, "booltest (3) failed");
+ enforce((new EnumClass()).blah() == true, "EnumClass failed");
+ enforce(casts1() == null, "casts1 failed");
+ enforce(casts2() == "Hello", "casts2 failed");
+ enforce(casts1("Ciao") == "Ciao", "casts1 not default failed");
+ enforce(chartest1() == 'x', "chartest1 failed");
+ enforce(chartest2() == '\0', "chartest2 failed");
+ enforce(chartest1('y') == 'y', "chartest1 not default failed");
+ enforce(chartest1('y') == 'y', "chartest1 not default failed");
+ enforce(reftest1() == 42, "reftest1 failed");
+ enforce(reftest1(400) == 400, "reftest1 not default failed");
+ enforce(reftest2() == "hello", "reftest2 failed");
+
+ // rename
+ auto foo = new Foo();
+ foo.newname();
+ foo.newname(10);
+ foo.renamed3arg(10, 10.0);
+ foo.renamed2arg(10);
+ foo.renamed1arg();
+
+ // exception specifications
+ enforceThrows( (){ exceptionspec(); }, "exceptionspec 1" );
+ enforceThrows( (){ exceptionspec(-1); }, "exceptionspec 2" );
+ enforceThrows( (){ exceptionspec(100); }, "exceptionspec 3" );
+
+ auto ex = new Except(false);
+ enforceThrows( (){ ex.exspec(); }, "exspec 1" );
+ enforceThrows( (){ ex.exspec(-1); }, "exspec 2" );
+ enforceThrows( (){ ex.exspec(100); }, "exspec 3" );
+ enforceThrows( (){ ex = new Except(true); }, "Except constructor 1" );
+ enforceThrows( (){ ex = new Except(true, -2); }, "Except constructor 2" );
+
+ // Default parameters in static class methods
+ enforce(Statics.staticmethod() == 10+20+30, "staticmethod 1 failed");
+ enforce(Statics.staticmethod(100) == 100+20+30, "staticmethod 2 failed");
+ enforce(Statics.staticmethod(100,200,300) == 100+200+300, "staticmethod 3 failed");
+
+ auto tricky = new Tricky();
+ enforce(tricky.privatedefault() == 200, "privatedefault failed");
+ enforce(tricky.protectedint() == 2000, "protectedint failed");
+ enforce(tricky.protecteddouble() == 987.654, "protecteddouble failed");
+ enforce(tricky.functiondefault() == 500, "functiondefault failed");
+ enforce(tricky.contrived() == 'X', "contrived failed");
+
+ enforce(constructorcall().val == -1, "constructorcall test 1 failed");
+ enforce(constructorcall(new Klass(2222)).val == 2222, "constructorcall test 2 failed");
+ enforce(constructorcall(new Klass()).val == -1, "constructorcall test 3 failed");
+
+ // const methods
+ const cm = new ConstMethods();
+ enforce(cm.coo() == 20, "coo test 1 failed");
+ enforce(cm.coo(1.0) == 20, "coo test 2 failed");
+}
+
+private void enforceThrows(void delegate() dg, string errorMessage) {
+ bool hasThrown;
+ try {
+ dg();
+ } catch (Exception) {
+ hasThrown = true;
+ } finally {
+ if (!hasThrown) {
+ throw new Exception(errorMessage);
+ }
+ }
+}
diff --git a/Examples/test-suite/d/default_constructor_runme.1.d b/Examples/test-suite/d/default_constructor_runme.1.d
new file mode 100644
index 000000000..3640218ae
--- /dev/null
+++ b/Examples/test-suite/d/default_constructor_runme.1.d
@@ -0,0 +1,30 @@
+module default_constructor_runme;
+
+import default_constructor.FFF;
+import default_constructor.G;
+
+void main() {
+ // Protected destructor test.
+ try {
+ {
+ scope g = new G();
+ }
+ throw new Exception("Protected destructor exception should have been thrown");
+ } catch (Exception e) {
+ if (e.msg != "C++ destructor does not have public access") {
+ throw e;
+ }
+ }
+
+ // Private destructor test.
+ try {
+ {
+ scope f = new FFF();
+ }
+ throw new Exception("Private destructor exception should have been thrown");
+ } catch (Exception e) {
+ if (e.msg != "C++ destructor does not have public access") {
+ throw e;
+ }
+ }
+}
diff --git a/Examples/test-suite/d/default_constructor_runme.2.d b/Examples/test-suite/d/default_constructor_runme.2.d
new file mode 100644
index 000000000..22f5bffd2
--- /dev/null
+++ b/Examples/test-suite/d/default_constructor_runme.2.d
@@ -0,0 +1,25 @@
+module default_constructor_runme;
+
+import default_constructor.FFF;
+import default_constructor.G;
+
+void main() {
+ // D2 does not support something akin to D1/Tango dispose() for deterministic
+ // destruction yet.
+
+ // enforceThrows((){ scope g = new G(); }, "Protected destructor exception should have been thrown");
+ // enforceThrows((){ scope f = new FFF(); }, "Private destructor exception should have been thrown");
+}
+
+private void enforceThrows(void delegate() dg, string errorMessage) {
+ bool hasThrown;
+ try {
+ dg();
+ } catch (Exception) {
+ hasThrown = true;
+ } finally {
+ if (!hasThrown) {
+ throw new Exception(errorMessage);
+ }
+ }
+}
diff --git a/Examples/test-suite/d/director_alternating_runme.1.d b/Examples/test-suite/d/director_alternating_runme.1.d
new file mode 100644
index 000000000..27bd262fd
--- /dev/null
+++ b/Examples/test-suite/d/director_alternating_runme.1.d
@@ -0,0 +1,7 @@
+module director_alternating_runme;
+
+import director_alternating.director_alternating;
+
+void main() {
+ assert(getBar().id() == idFromGetBar());
+}
diff --git a/Examples/test-suite/d/director_alternating_runme.2.d b/Examples/test-suite/d/director_alternating_runme.2.d
new file mode 100644
index 000000000..27bd262fd
--- /dev/null
+++ b/Examples/test-suite/d/director_alternating_runme.2.d
@@ -0,0 +1,7 @@
+module director_alternating_runme;
+
+import director_alternating.director_alternating;
+
+void main() {
+ assert(getBar().id() == idFromGetBar());
+}
diff --git a/Examples/test-suite/d/director_basic_runme.1.d b/Examples/test-suite/d/director_basic_runme.1.d
new file mode 100644
index 000000000..58a54835e
--- /dev/null
+++ b/Examples/test-suite/d/director_basic_runme.1.d
@@ -0,0 +1,59 @@
+module director_basic_runme;
+
+import director_basic.A1;
+import director_basic.Bar;
+import director_basic.Foo;
+import director_basic.MyClass;
+
+void main() {
+ auto a = new director_basic_MyFoo();
+ if (a.ping() != "director_basic_MyFoo::ping()") {
+ throw new Exception("a.ping()");
+ }
+ if (a.pong() != "Foo::pong();director_basic_MyFoo::ping()") {
+ throw new Exception("a.pong()");
+ }
+
+ auto b = new Foo();
+ if (b.ping() != "Foo::ping()") {
+ throw new Exception("b.ping()");
+ }
+ if (b.pong() != "Foo::pong();Foo::ping()") {
+ throw new Exception("b.pong()");
+ }
+
+ {
+ scope a1 = new A1(1, false);
+ }
+
+ {
+ auto my = new MyOverriddenClass();
+
+ my.expectNull = true;
+ if (MyClass.call_pmethod(my, null) !is null)
+ throw new Exception("null pointer conversion problem");
+
+ auto myBar = new Bar();
+ my.expectNull = false;
+ auto myNewBar = MyClass.call_pmethod(my, myBar);
+ if (myNewBar is null)
+ throw new Exception("non-null pointer conversion problem");
+ myNewBar.x = 10;
+ }
+}
+
+class director_basic_MyFoo : Foo {
+ public override char[] ping() {
+ return "director_basic_MyFoo::ping()";
+ }
+}
+
+class MyOverriddenClass : MyClass {
+ public bool expectNull = false;
+ public bool nonNullReceived = false;
+ public override Bar pmethod(Bar b) {
+ if (expectNull && (b !is null))
+ throw new Exception("null not received as expected");
+ return b;
+ }
+}
diff --git a/Examples/test-suite/d/director_basic_runme.2.d b/Examples/test-suite/d/director_basic_runme.2.d
new file mode 100644
index 000000000..877fcbc47
--- /dev/null
+++ b/Examples/test-suite/d/director_basic_runme.2.d
@@ -0,0 +1,46 @@
+module director_basic_runme;
+
+import std.exception;
+import director_basic.A1;
+import director_basic.Bar;
+import director_basic.Foo;
+import director_basic.MyClass;
+
+void main() {
+ auto a = new director_basic_MyFoo();
+ enforce(a.ping() == "director_basic_MyFoo::ping()", "a.ping()");
+ enforce(a.pong() == "Foo::pong();director_basic_MyFoo::ping()", "a.pong()");
+
+ auto b = new Foo();
+ enforce(b.ping() == "Foo::ping()", "b.ping()");
+ enforce(b.pong() == "Foo::pong();Foo::ping()", "b.pong()");
+
+ {
+ scope a1 = new A1(1, false);
+ }
+
+ auto my = new MyOverriddenClass();
+ my.expectNull = true;
+ enforce(MyClass.call_pmethod(my, null) is null, "null pointer conversion problem");
+ auto myBar = new Bar();
+ my.expectNull = false;
+ auto myNewBar = MyClass.call_pmethod(my, myBar);
+ enforce(myNewBar !is null, "non-null pointer conversion problem");
+ myNewBar.x = 10;
+}
+
+class director_basic_MyFoo : Foo {
+ public override string ping() {
+ return "director_basic_MyFoo::ping()";
+ }
+}
+
+class MyOverriddenClass : MyClass {
+ public bool expectNull = false;
+ public bool nonNullReceived = false;
+ public override Bar pmethod(Bar b) {
+ if (expectNull && (b !is null))
+ throw new Exception("null not received as expected");
+ return b;
+ }
+}
diff --git a/Examples/test-suite/d/director_classes_runme.1.d b/Examples/test-suite/d/director_classes_runme.1.d
new file mode 100644
index 000000000..9c34db82a
--- /dev/null
+++ b/Examples/test-suite/d/director_classes_runme.1.d
@@ -0,0 +1,168 @@
+/**
+ * This test demonstrates director classes when the types are classes. Shown are
+ * virtual function calls which use classes passed by
+ * - Value
+ * - Reference
+ * - Pointer
+ * as both parameters and return values
+ *
+ * The test also demonstrates directors used with:
+ * - method overloading
+ * - default parameters
+ *
+ * Note: Methods with default parameters that call up from C++ cannot call the
+ * overloaded D methods, see DefaultParms method.
+
+ * Expected output if PrintDebug enabled:
+ * ------------ Start ------------
+ * Base - Val(444.555)
+ * Base - Ref(444.555)
+ * Base - Ptr(444.555)
+ * Base - FullyOverloaded(int 10)
+ * Base - FullyOverloaded(bool 1)
+ * Base - SemiOverloaded(int -678)
+ * Base - SemiOverloaded(bool 1)
+ * Base - DefaultParms(10, 2.2)
+ * Base - DefaultParms(10, 1.1)
+ * --------------------------------
+ * Derived - Val(444.555)
+ * Derived - Ref(444.555)
+ * Derived - Ptr(444.555)
+ * Derived - FullyOverloaded(int 10)
+ * Derived - FullyOverloaded(bool 1)
+ * Derived - SemiOverloaded(int -678)
+ * Base - SemiOverloaded(bool 1)
+ * Derived - DefaultParms(10, 2.2)
+ * Derived - DefaultParms(10, 1.1)
+ * --------------------------------
+ * DDerived - Val(444.555)
+ * DDerived - Ref(444.555)
+ * DDerived - Ptr(444.555)
+ * DDerived - FullyOverloaded(int 10)
+ * DDerived - FullyOverloaded(bool True)
+ * DDerived - SemiOverloaded(-678)
+ * Base - SemiOverloaded(bool 1)
+ * DDerived - DefaultParms(10, 2.2)
+ * DDerived - DefaultParms(10, 1.1)
+ * ------------ Finish ------------
+ */
+module director_classes_runme;
+
+import tango.io.Stdout;
+import tango.text.Util;
+import director_classes.director_classes;
+import director_classes.Caller;
+import director_classes.Base;
+import director_classes.Derived;
+import director_classes.DoubleHolder;
+
+void main() {
+ if (PrintDebug) Stdout.formatln("------------ Start ------------ ");
+
+ auto myCaller = new Caller();
+
+ // Test C++ base class.
+ {
+ scope myBase = new Base(100.0);
+ makeCalls(myCaller, myBase);
+ }
+
+ if (PrintDebug) Stdout.formatln("--------------------------------");
+
+ // Test vanilla C++ wrapped derived class.
+ {
+ scope myBase = new Derived(200.0);
+ makeCalls(myCaller, myBase);
+ }
+
+ if (PrintDebug) Stdout.formatln("--------------------------------");
+
+ // Test director / D derived class.
+ {
+ scope myBase = new DDerived(300.0);
+ makeCalls(myCaller, myBase);
+ }
+
+ if (PrintDebug) Stdout.formatln("------------ Finish ------------ ");
+}
+
+void makeCalls(Caller myCaller, Base myBase) {
+ char[] myBaseType = myBase.classinfo.name.split(".")[$-1];
+ myCaller.set(myBase);
+
+ DoubleHolder dh = new DoubleHolder(444.555);
+
+ // Class pointer, reference and pass by value tests
+ if (myCaller.ValCall(dh).val != dh.val) throw new Exception("[1] failed");
+ if (myCaller.RefCall(dh).val != dh.val) throw new Exception("[2] failed");
+ if (myCaller.PtrCall(dh).val != dh.val) throw new Exception("[3] failed");
+
+ // Fully overloaded method test (all methods in base class are overloaded)
+ if (myCaller.FullyOverloadedCall(10) != myBaseType ~ "::FullyOverloaded(int)") throw new Exception("[4] failed");
+ if (myCaller.FullyOverloadedCall(true) != myBaseType ~ "::FullyOverloaded(bool)") throw new Exception("[5] failed");
+
+ // Semi overloaded method test (some methods in base class are overloaded)
+ if (myCaller.SemiOverloadedCall(-678) != myBaseType ~ "::SemiOverloaded(int)") throw new Exception("[6] failed");
+ if (myCaller.SemiOverloadedCall(true) != "Base" ~ "::SemiOverloaded(bool)") throw new Exception("[7] failed");
+
+ // Default parameters methods test
+ if (myCaller.DefaultParmsCall(10, 2.2) != myBaseType ~ "::DefaultParms(int, double)") throw new Exception("[8] failed");
+ if (myBase.classinfo == DDerived.classinfo) { // special handling for D derived classes, there is no way to do this any other way
+ if (myCaller.DefaultParmsCall(10) != myBaseType ~ "::DefaultParms(int, double)") throw new Exception("[9] failed");
+ } else {
+ if (myCaller.DefaultParmsCall(10) != myBaseType ~ "::DefaultParms(int)") throw new Exception("[10] failed");
+ }
+
+ myCaller.reset();
+}
+
+public class DDerived : Base {
+ public this(double dd) {
+ super(dd);
+ }
+
+ public override DoubleHolder Val(DoubleHolder x) {
+ if (PrintDebug) Stdout.formatln("DDerived - Val({0:d3})", x.val);
+ return x;
+ }
+
+ public override DoubleHolder Ref(DoubleHolder x) {
+ if (PrintDebug) Stdout.formatln("DDerived - Ref({0:d3})", x.val);
+ return x;
+ }
+
+ public override DoubleHolder Ptr(DoubleHolder x) {
+ if (PrintDebug) Stdout.formatln("DDerived - Ptr({0:d3})", x.val);
+ return x;
+ }
+
+ public override char[] FullyOverloaded(int x) {
+ if (PrintDebug) Stdout.formatln("DDerived - FullyOverloaded(int {0})", x);
+ return "DDerived::FullyOverloaded(int)";
+ }
+
+ public override char[] FullyOverloaded(bool x) {
+ if (PrintDebug) Stdout.formatln("DDerived - FullyOverloaded(bool {0})", x);
+ return "DDerived::FullyOverloaded(bool)";
+ }
+
+ public override char[] SemiOverloaded(int x) {
+ char[] ret = "DDerived::SemiOverloaded(int)";
+ if (PrintDebug) Stdout.formatln("DDerived - SemiOverloaded({0})", x);
+ return ret;
+ }
+ alias Base.SemiOverloaded SemiOverloaded; // Alias in SemiOverloaded(bool x).
+
+ public override char[] DefaultParms(int x, double y) {
+ char[] ret = "DDerived::DefaultParms(int, double)";
+ if (PrintDebug) Stdout.formatln("DDerived - DefaultParms({0}, {1:d1})", x, y);
+ return ret;
+ }
+ // This method will never be called from C++ code because the two-parameter
+ // DefaultParams() has a default value for the second parameter there. It is
+ // only here to ensure consistent behavior for calls from C++ and D code.
+ public override char[] DefaultParms(int x) {
+ if (PrintDebug) Stdout.formatln("DDerived - DefaultParms({0})", x);
+ return DefaultParms(x, 1.1/*use C++ default here*/);
+ }
+}
diff --git a/Examples/test-suite/d/director_classes_runme.2.d b/Examples/test-suite/d/director_classes_runme.2.d
new file mode 100644
index 000000000..98e27b3cd
--- /dev/null
+++ b/Examples/test-suite/d/director_classes_runme.2.d
@@ -0,0 +1,169 @@
+/**
+ * This test demonstrates director classes when the types are classes. Shown are
+ * virtual function calls which use classes passed by
+ * - Value
+ * - Reference
+ * - Pointer
+ * as both parameters and return values
+ *
+ * The test also demonstrates directors used with:
+ * - method overloading
+ * - default parameters
+ *
+ * Note: Methods with default parameters that call up from C++ cannot call the
+ * overloaded D methods, see DefaultParms method.
+
+ * Expected output if PrintDebug enabled:
+ * ------------ Start ------------
+ * Base - Val(444.555)
+ * Base - Ref(444.555)
+ * Base - Ptr(444.555)
+ * Base - FullyOverloaded(int 10)
+ * Base - FullyOverloaded(bool 1)
+ * Base - SemiOverloaded(int -678)
+ * Base - SemiOverloaded(bool 1)
+ * Base - DefaultParms(10, 2.2)
+ * Base - DefaultParms(10, 1.1)
+ * --------------------------------
+ * Derived - Val(444.555)
+ * Derived - Ref(444.555)
+ * Derived - Ptr(444.555)
+ * Derived - FullyOverloaded(int 10)
+ * Derived - FullyOverloaded(bool 1)
+ * Derived - SemiOverloaded(int -678)
+ * Base - SemiOverloaded(bool 1)
+ * Derived - DefaultParms(10, 2.2)
+ * Derived - DefaultParms(10, 1.1)
+ * --------------------------------
+ * DDerived - Val(444.555)
+ * DDerived - Ref(444.555)
+ * DDerived - Ptr(444.555)
+ * DDerived - FullyOverloaded(int 10)
+ * DDerived - FullyOverloaded(bool true)
+ * DDerived - SemiOverloaded(-678)
+ * Base - SemiOverloaded(bool 1)
+ * DDerived - DefaultParms(10, 2.2)
+ * DDerived - DefaultParms(10, 1.1)
+ * ------------ Finish ------------
+ */
+module director_classes_runme;
+
+import std.exception;
+import std.stdio;
+import std.string;
+import director_classes.director_classes;
+import director_classes.Caller;
+import director_classes.Base;
+import director_classes.Derived;
+import director_classes.DoubleHolder;
+
+void main() {
+ if (PrintDebug) writeln("------------ Start ------------ ");
+
+ auto myCaller = new Caller();
+
+ // Test C++ base class.
+ {
+ scope myBase = new Base(100.0);
+ makeCalls(myCaller, myBase);
+ }
+
+ if (PrintDebug) writeln("--------------------------------");
+
+ // Test vanilla C++ wrapped derived class.
+ {
+ scope myBase = new Derived(200.0);
+ makeCalls(myCaller, myBase);
+ }
+
+ if (PrintDebug) writeln("--------------------------------");
+
+ // Test director / D derived class.
+ {
+ scope myBase = new DDerived(300.0);
+ makeCalls(myCaller, myBase);
+ }
+
+ if (PrintDebug) writeln("------------ Finish ------------ ");
+}
+
+void makeCalls(Caller myCaller, Base myBase) {
+ string myBaseType = myBase.classinfo.name.split(".")[$-1];
+ myCaller.set(myBase);
+
+ DoubleHolder dh = new DoubleHolder(444.555);
+
+ // Class pointer, reference and pass by value tests
+ enforce(myCaller.ValCall(dh).val == dh.val, "[1] failed");
+ enforce(myCaller.RefCall(dh).val == dh.val, "[2] failed");
+ enforce(myCaller.PtrCall(dh).val == dh.val, "[3] failed");
+
+ // Fully overloaded method test (all methods in base class are overloaded)
+ enforce(myCaller.FullyOverloadedCall(10) == myBaseType ~ "::FullyOverloaded(int)", "[4] failed");
+ enforce(myCaller.FullyOverloadedCall(true) == myBaseType ~ "::FullyOverloaded(bool)", "[5] failed");
+
+ // Semi overloaded method test (some methods in base class are overloaded)
+ enforce(myCaller.SemiOverloadedCall(-678) == myBaseType ~ "::SemiOverloaded(int)", "[6] failed");
+ enforce(myCaller.SemiOverloadedCall(true) == "Base" ~ "::SemiOverloaded(bool)", "[7] failed");
+
+ // Default parameters methods test
+ enforce(myCaller.DefaultParmsCall(10, 2.2) == myBaseType ~ "::DefaultParms(int, double)", "[8] failed");
+ if (myBase.classinfo == DDerived.classinfo) { // special handling for D derived classes, there is no other way to do this
+ enforce(myCaller.DefaultParmsCall(10) == myBaseType ~ "::DefaultParms(int, double)", "[9] failed");
+ } else {
+ enforce(myCaller.DefaultParmsCall(10) == myBaseType ~ "::DefaultParms(int)", "[10] failed");
+ }
+
+ myCaller.reset();
+}
+
+public class DDerived : Base {
+ public this(double dd) {
+ super(dd);
+ }
+
+ public override DoubleHolder Val(DoubleHolder x) {
+ if (PrintDebug) writefln("DDerived - Val(%s)", x.val);
+ return x;
+ }
+
+ public override DoubleHolder Ref(DoubleHolder x) {
+ if (PrintDebug) writefln("DDerived - Ref(%s)", x.val);
+ return x;
+ }
+
+ public override DoubleHolder Ptr(DoubleHolder x) {
+ if (PrintDebug) writefln("DDerived - Ptr(%s)", x.val);
+ return x;
+ }
+
+ public override string FullyOverloaded(int x) {
+ if (PrintDebug) writefln("DDerived - FullyOverloaded(int %s)", x);
+ return "DDerived::FullyOverloaded(int)";
+ }
+
+ public override string FullyOverloaded(bool x) {
+ if (PrintDebug) writefln("DDerived - FullyOverloaded(bool %s)", x);
+ return "DDerived::FullyOverloaded(bool)";
+ }
+
+ public override string SemiOverloaded(int x) {
+ string ret = "DDerived::SemiOverloaded(int)";
+ if (PrintDebug) writefln("DDerived - SemiOverloaded(%s)", x);
+ return ret;
+ }
+ alias Base.SemiOverloaded SemiOverloaded; // Alias in SemiOverloaded(bool x).
+
+ public override string DefaultParms(int x, double y) {
+ string ret = "DDerived::DefaultParms(int, double)";
+ if (PrintDebug) writefln("DDerived - DefaultParms(%s, %s)", x, y);
+ return ret;
+ }
+ // This method will never be called from C++ code because the two-parameter
+ // DefaultParams() has a default value for the second parameter there. It is
+ // only here to ensure consistent behavior for calls from C++ and D code.
+ public override string DefaultParms(int x) {
+ if (PrintDebug) writefln("DDerived - DefaultParms(%s)", x);
+ return DefaultParms(x, 1.1/*use C++ default here*/);
+ }
+}
diff --git a/Examples/test-suite/d/director_classic_runme.1.d b/Examples/test-suite/d/director_classic_runme.1.d
new file mode 100644
index 000000000..33be80618
--- /dev/null
+++ b/Examples/test-suite/d/director_classic_runme.1.d
@@ -0,0 +1,207 @@
+module director_classic_runme;
+
+import tango.io.Stdout;
+import director_classic.Caller;
+import director_classic.Person;
+import director_classic.Child;
+import director_classic.GrandChild;
+import director_classic.OrphanPerson;
+import director_classic.OrphanChild;
+
+const bool TRACE = false;
+
+void main() {
+ {
+ scope person = new Person();
+ check(person, "Person");
+ }
+ {
+ scope person = new Child();
+ check(person, "Child");
+ }
+ {
+ scope person = new GrandChild();
+ check(person, "GrandChild");
+ }
+ {
+ scope person = new TargetLangPerson();
+ check(person, "TargetLangPerson");
+ }
+ {
+ scope person = new TargetLangChild();
+ check(person, "TargetLangChild");
+ }
+ {
+ scope person = new TargetLangGrandChild();
+ check(person, "TargetLangGrandChild");
+ }
+
+ // Semis - don't override id() in target language
+ {
+ scope person = new TargetLangSemiPerson();
+ check(person, "Person");
+ }
+ {
+ scope person = new TargetLangSemiChild();
+ check(person, "Child");
+ }
+ {
+ scope person = new TargetLangSemiGrandChild();
+ check(person, "GrandChild");
+ }
+
+ // Orphans - don't override id() in C++
+ {
+ scope person = new OrphanPerson();
+ check(person, "Person");
+ }
+ {
+ scope person = new OrphanChild();
+ check(person, "Child");
+ }
+ {
+ scope person = new TargetLangOrphanPerson();
+ check(person, "TargetLangOrphanPerson");
+ }
+ {
+ scope person = new TargetLangOrphanChild();
+ check(person, "TargetLangOrphanChild");
+ }
+
+ // Duals - id() makes an upcall to the base id()
+ {
+ scope person = new TargetLangDualPerson();
+ check(person, "TargetLangDualPerson + Person");
+ }
+ {
+ scope person = new TargetLangDualChild();
+ check(person, "TargetLangDualChild + Child");
+ }
+ {
+ scope person = new TargetLangDualGrandChild();
+ check(person, "TargetLangDualGrandChild + GrandChild");
+ }
+
+ // Mix Orphans and Duals
+ {
+ scope person = new TargetLangDualOrphanPerson();
+ check(person, "TargetLangDualOrphanPerson + Person");
+ }
+ {
+ scope person = new TargetLangDualOrphanChild();
+ check(person, "TargetLangDualOrphanChild + Child");
+ }
+}
+
+void check(Person person, char[] expected) {
+ char[] ret;
+ // Normal D polymorphic call.
+ ret = person.id();
+ if (TRACE)
+ Stdout(ret).newline;
+ if (ret != expected)
+ throw new Exception("Failed. Received: " ~ ret ~ " Expected: " ~ expected);
+
+ // Polymorphic call from C++.
+ Caller caller = new Caller();
+ caller.setCallback(person);
+ ret = caller.call();
+ if (TRACE)
+ Stdout(ret).newline;
+ if (ret != expected)
+ throw new Exception("Failed. Received: " ~ ret ~ " Expected: " ~ expected);
+
+ // Polymorphic call of object created in D and passed to C++ and back again.
+ Person baseclass = caller.baseClass();
+ ret = baseclass.id();
+ if (TRACE)
+ Stdout(ret).newline;
+ if (ret != expected)
+ throw new Exception("Failed. Received: " ~ ret ~ " Expected: " ~ expected);
+
+ caller.resetCallback();
+ if (TRACE)
+ Stdout("----------------------------------------").newline;
+}
+
+
+// »Full« target language persons.
+class TargetLangPerson : Person {
+ public override char[] id() {
+ return "TargetLangPerson";
+ }
+}
+
+class TargetLangChild : Child {
+ public override char[] id() {
+ return "TargetLangChild";
+ }
+}
+
+class TargetLangGrandChild : GrandChild {
+ public override char[] id() {
+ return "TargetLangGrandChild";
+ }
+}
+
+
+// Semis - don't override id() in target language
+class TargetLangSemiPerson : Person {
+ // No id() override
+}
+
+class TargetLangSemiChild : Child {
+ // No id() override
+}
+
+class TargetLangSemiGrandChild : GrandChild {
+ // No id() override
+}
+
+
+// Orphans - don't override id() in C++
+class TargetLangOrphanPerson : OrphanPerson {
+ public override char[] id() {
+ return "TargetLangOrphanPerson";
+ }
+}
+
+class TargetLangOrphanChild : OrphanChild {
+ public override char[] id() {
+ return "TargetLangOrphanChild";
+ }
+}
+
+
+// Duals - id() makes an upcall to the base id()
+class TargetLangDualPerson : Person {
+ public override char[] id() {
+ return "TargetLangDualPerson + " ~ super.id();
+ }
+}
+
+class TargetLangDualChild : Child {
+ public override char[] id() {
+ return "TargetLangDualChild + " ~ super.id();
+ }
+}
+
+class TargetLangDualGrandChild : GrandChild {
+ public override char[] id() {
+ return "TargetLangDualGrandChild + " ~ super.id();
+ }
+}
+
+
+// Mix Orphans and Duals
+class TargetLangDualOrphanPerson : OrphanPerson {
+ public override char[] id() {
+ return "TargetLangDualOrphanPerson + " ~ super.id();
+ }
+}
+
+class TargetLangDualOrphanChild : OrphanChild {
+ public override char[] id() {
+ return "TargetLangDualOrphanChild + " ~ super.id();
+ }
+}
diff --git a/Examples/test-suite/d/director_classic_runme.2.d b/Examples/test-suite/d/director_classic_runme.2.d
new file mode 100644
index 000000000..c50781b07
--- /dev/null
+++ b/Examples/test-suite/d/director_classic_runme.2.d
@@ -0,0 +1,202 @@
+module director_classic_runme;
+
+import std.exception;
+import std.stdio;
+import director_classic.Caller;
+import director_classic.Person;
+import director_classic.Child;
+import director_classic.GrandChild;
+import director_classic.OrphanPerson;
+import director_classic.OrphanChild;
+
+enum TRACE = false;
+
+void main() {
+ {
+ scope person = new Person();
+ check(person, "Person");
+ }
+ {
+ scope person = new Child();
+ check(person, "Child");
+ }
+ {
+ scope person = new GrandChild();
+ check(person, "GrandChild");
+ }
+ {
+ scope person = new TargetLangPerson();
+ check(person, "TargetLangPerson");
+ }
+ {
+ scope person = new TargetLangChild();
+ check(person, "TargetLangChild");
+ }
+ {
+ scope person = new TargetLangGrandChild();
+ check(person, "TargetLangGrandChild");
+ }
+
+ // Semis - don't override id() in target language
+ {
+ scope person = new TargetLangSemiPerson();
+ check(person, "Person");
+ }
+ {
+ scope person = new TargetLangSemiChild();
+ check(person, "Child");
+ }
+ {
+ scope person = new TargetLangSemiGrandChild();
+ check(person, "GrandChild");
+ }
+
+ // Orphans - don't override id() in C++
+ {
+ scope person = new OrphanPerson();
+ check(person, "Person");
+ }
+ {
+ scope person = new OrphanChild();
+ check(person, "Child");
+ }
+ {
+ scope person = new TargetLangOrphanPerson();
+ check(person, "TargetLangOrphanPerson");
+ }
+ {
+ scope person = new TargetLangOrphanChild();
+ check(person, "TargetLangOrphanChild");
+ }
+
+ // Duals - id() makes an upcall to the base id()
+ {
+ scope person = new TargetLangDualPerson();
+ check(person, "TargetLangDualPerson + Person");
+ }
+ {
+ scope person = new TargetLangDualChild();
+ check(person, "TargetLangDualChild + Child");
+ }
+ {
+ scope person = new TargetLangDualGrandChild();
+ check(person, "TargetLangDualGrandChild + GrandChild");
+ }
+
+ // Mix Orphans and Duals
+ {
+ scope person = new TargetLangDualOrphanPerson();
+ check(person, "TargetLangDualOrphanPerson + Person");
+ }
+ {
+ scope person = new TargetLangDualOrphanChild();
+ check(person, "TargetLangDualOrphanChild + Child");
+ }
+}
+
+void check(Person person, string expected) {
+ string ret;
+ // Normal D polymorphic call.
+ ret = person.id();
+ if (TRACE) writeln(ret);
+ enforce(ret == expected, "Failed. Received: " ~ ret ~ " Expected: " ~ expected);
+
+ // Polymorphic call from C++.
+ auto caller = new Caller();
+ caller.setCallback(person);
+ ret = caller.call();
+ if (TRACE) writeln(ret);
+ enforce(ret == expected, "Failed. Received: " ~ ret ~ " Expected: " ~ expected);
+
+ // Polymorphic call of object created in D and passed to C++ and back again.
+ Person baseclass = caller.baseClass();
+ ret = baseclass.id();
+ if (TRACE) writeln(ret);
+ enforce(ret == expected, "Failed. Received: " ~ ret ~ " Expected: " ~ expected);
+
+ caller.resetCallback();
+ if (TRACE)
+ writeln("----------------------------------------");
+}
+
+
+// »Full« target language persons.
+class TargetLangPerson : Person {
+ public override string id() {
+ return "TargetLangPerson";
+ }
+}
+
+class TargetLangChild : Child {
+ public override string id() {
+ return "TargetLangChild";
+ }
+}
+
+class TargetLangGrandChild : GrandChild {
+ public override string id() {
+ return "TargetLangGrandChild";
+ }
+}
+
+
+// Semis - don't override id() in target language
+class TargetLangSemiPerson : Person {
+ // No id() override
+}
+
+class TargetLangSemiChild : Child {
+ // No id() override
+}
+
+class TargetLangSemiGrandChild : GrandChild {
+ // No id() override
+}
+
+
+// Orphans - don't override id() in C++
+class TargetLangOrphanPerson : OrphanPerson {
+ public override string id() {
+ return "TargetLangOrphanPerson";
+ }
+}
+
+class TargetLangOrphanChild : OrphanChild {
+ public override string id() {
+ return "TargetLangOrphanChild";
+ }
+}
+
+
+// Duals - id() makes an upcall to the base id()
+class TargetLangDualPerson : Person {
+ public override string id() {
+ return "TargetLangDualPerson + " ~ super.id();
+ }
+}
+
+class TargetLangDualChild : Child {
+ public override string id() {
+ return "TargetLangDualChild + " ~ super.id();
+ }
+}
+
+class TargetLangDualGrandChild : GrandChild {
+ public override string id() {
+ return "TargetLangDualGrandChild + " ~ super.id();
+ }
+}
+
+
+// Mix Orphans and Duals
+class TargetLangDualOrphanPerson : OrphanPerson {
+ public override string id() {
+ return "TargetLangDualOrphanPerson + " ~ super.id();
+ }
+}
+
+class TargetLangDualOrphanChild : OrphanChild {
+ public override string id() {
+ return "TargetLangDualOrphanChild + " ~ super.id();
+ }
+}
diff --git a/Examples/test-suite/d/director_ignore_runme.1.d b/Examples/test-suite/d/director_ignore_runme.1.d
new file mode 100644
index 000000000..797d2fddf
--- /dev/null
+++ b/Examples/test-suite/d/director_ignore_runme.1.d
@@ -0,0 +1,39 @@
+module director_ignore_runme;
+
+import director_ignore.DIgnores;
+import director_ignore.DAbstractIgnores;
+
+void main() {
+ // Just check the classes can be instantiated and other methods work as expected
+ auto a = new DIgnoresDerived();
+ if (a.Triple(5) != 15)
+ throw new Exception("Triple failed");
+
+ auto b = new DAbstractIgnoresDerived();
+ if (b.Quadruple(5) != 20)
+ throw new Exception("Quadruple failed");
+}
+
+class DIgnoresDerived : DIgnores {
+public:
+ // These will give a warning if the %ignore is not working
+ int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; }
+ int OverloadedMethod(int n, int xoffset) { return 0; }
+ int OverloadedMethod(int n) { return 0; }
+
+ int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; }
+ int OverloadedProtectedMethod(int n, int xoffset) { return 0; }
+ int OverloadedProtectedMethod(int n) { return 0; }
+}
+
+class DAbstractIgnoresDerived : DAbstractIgnores {
+public:
+ // These will give a warning if the %ignore is not working
+ int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; }
+ int OverloadedMethod(int n, int xoffset) { return 0; }
+ int OverloadedMethod(int n) { return 0; }
+
+ int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; }
+ int OverloadedProtectedMethod(int n, int xoffset) { return 0; }
+ int OverloadedProtectedMethod(int n) { return 0; }
+}
diff --git a/Examples/test-suite/d/director_ignore_runme.2.d b/Examples/test-suite/d/director_ignore_runme.2.d
new file mode 100644
index 000000000..b3e29b48d
--- /dev/null
+++ b/Examples/test-suite/d/director_ignore_runme.2.d
@@ -0,0 +1,38 @@
+module director_ignore_runme;
+
+import std.exception;
+import director_ignore.DIgnores;
+import director_ignore.DAbstractIgnores;
+
+void main() {
+ // Just check the classes can be instantiated and other methods work as expected
+ auto a = new DIgnoresDerived();
+ enforce(a.Triple(5) == 15, "Triple failed");
+
+ auto b = new DAbstractIgnoresDerived();
+ enforce(b.Quadruple(5) == 20, "Quadruple failed");
+}
+
+class DIgnoresDerived : DIgnores {
+public:
+ // These will give a warning if the %ignore is not working
+ int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; }
+ int OverloadedMethod(int n, int xoffset) { return 0; }
+ int OverloadedMethod(int n) { return 0; }
+
+ int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; }
+ int OverloadedProtectedMethod(int n, int xoffset) { return 0; }
+ int OverloadedProtectedMethod(int n) { return 0; }
+}
+
+class DAbstractIgnoresDerived : DAbstractIgnores {
+public:
+ // These will give a warning if the %ignore is not working
+ int OverloadedMethod(int n, int xoffset, int yoffset) { return 0; }
+ int OverloadedMethod(int n, int xoffset) { return 0; }
+ int OverloadedMethod(int n) { return 0; }
+
+ int OverloadedProtectedMethod(int n, int xoffset, int yoffset) { return 0; }
+ int OverloadedProtectedMethod(int n, int xoffset) { return 0; }
+ int OverloadedProtectedMethod(int n) { return 0; }
+}
diff --git a/Examples/test-suite/d/director_primitives_runme.1.d b/Examples/test-suite/d/director_primitives_runme.1.d
new file mode 100644
index 000000000..f19e86f59
--- /dev/null
+++ b/Examples/test-suite/d/director_primitives_runme.1.d
@@ -0,0 +1,122 @@
+/**
+ * This test program shows a D class DDerived inheriting from Base.
+ *
+ * Three types of classes are created and the virtual methods called to
+ * demonstrate:
+ * - Wide variety of primitive types
+ * - Calling methods with zero, one or more parameters
+ * - Director methods that are not overridden in D
+ * - Director classes that are not overridden at all in D, i.e. non-director
+ * behaviour is as expected for director classes
+ * - Inheritance hierarchy using director methods
+ * - Return types working as well as parameters
+ *
+ * The Caller class is a tester class which calls the virtual functions from C++.
+ */
+module director_primitives_runme;
+
+import tango.io.Stdout;
+import director_primitives.director_primitives;
+import director_primitives.Base;
+import director_primitives.Caller;
+import director_primitives.Derived;
+import director_primitives.HShadowMode;
+
+void main() {
+ PrintDebug = false;
+ if (PrintDebug) Stdout("------------ Start ------------ ").newline;
+
+ Caller myCaller = new Caller();
+
+ // Test C++ base class.
+ {
+ scope myBase = new Base(100.0);
+ makeCalls(myCaller, myBase);
+ }
+
+ if (PrintDebug) Stdout("--------------------------------").newline;
+
+ // Test vanilla C++ wrapped derived class.
+ {
+ scope Base myBase = new Derived(100.0);
+ makeCalls(myCaller, myBase);
+ }
+
+ if (PrintDebug) Stdout("--------------------------------").newline;
+
+ // Test director/D derived class.
+ {
+ scope Base myBase = new DDerived(300.0);
+ makeCalls(myCaller, myBase);
+ }
+
+ if (PrintDebug) Stdout("------------ Finish ------------ ").newline;
+}
+
+void makeCalls(Caller myCaller, Base myBase) {
+ myCaller.set(myBase);
+
+ myCaller.NoParmsMethodCall();
+ if (myCaller.BoolMethodCall(true) != true) throw new Exception("failed");
+ if (myCaller.BoolMethodCall(false) != false) throw new Exception("failed");
+ if (myCaller.IntMethodCall(-123) != -123) throw new Exception("failed");
+ if (myCaller.UIntMethodCall(123) != 123) throw new Exception("failed");
+ if (myCaller.FloatMethodCall(-123.456f) != -123.456f) throw new Exception("failed");
+ if (myCaller.CharPtrMethodCall("test string") != "test string") throw new Exception("failed");
+ if (myCaller.ConstCharPtrMethodCall("another string") != "another string") throw new Exception("failed");
+ if (myCaller.EnumMethodCall(HShadowMode.HShadowHard) != HShadowMode.HShadowHard) throw new Exception("failed");
+ myCaller.ManyParmsMethodCall(true, -123, 123, 123.456f, "test string", "another string", HShadowMode.HShadowHard);
+ myCaller.NotOverriddenMethodCall();
+
+ myCaller.reset();
+}
+
+class DDerived : Base {
+public:
+ this(double dd) {
+ super(dd);
+ }
+
+ override void NoParmsMethod() {
+ if (PrintDebug) Stdout("DDerived - NoParmsMethod()").newline;
+ }
+
+ override bool BoolMethod(bool x) {
+ if (PrintDebug) Stdout.formatln("DDerived - BoolMethod({0})", x);
+ return x;
+ }
+
+ override int IntMethod(int x) {
+ if (PrintDebug) Stdout.formatln("DDerived - IntMethod({0})", x);
+ return x;
+ }
+
+ override uint UIntMethod(uint x) {
+ if (PrintDebug) Stdout.formatln("DDerived - UIntMethod({0})", x);
+ return x;
+ }
+
+ override float FloatMethod(float x) {
+ if (PrintDebug) Stdout.formatln("DDerived - FloatMethod({0})", x);
+ return x;
+ }
+
+ override char[] CharPtrMethod(char[] x) {
+ if (PrintDebug) Stdout.formatln("DDerived - CharPtrMethod({0})", x);
+ return x;
+ }
+
+ override char[] ConstCharPtrMethod(char[] x) {
+ if (PrintDebug) Stdout.formatln("DDerived - ConstCharPtrMethod({0})", x);
+ return x;
+ }
+
+ override HShadowMode EnumMethod(HShadowMode x) {
+ if (PrintDebug) Stdout.formatln("DDerived - EnumMethod({0})", x);
+ return x;
+ }
+
+ override void ManyParmsMethod(bool b, int i, uint u, float f, char[] c, char[] cc, HShadowMode h) {
+ if (PrintDebug) Stdout.formatln("DDerived - ManyParmsMethod({0}, {1}, {2}, {3:d3}, {4}, {5}, {6})", b, i, u, f, c, cc, h);
+ }
+}
diff --git a/Examples/test-suite/d/director_primitives_runme.2.d b/Examples/test-suite/d/director_primitives_runme.2.d
new file mode 100644
index 000000000..e0e307330
--- /dev/null
+++ b/Examples/test-suite/d/director_primitives_runme.2.d
@@ -0,0 +1,123 @@
+/**
+ * This test program shows a D class DDerived inheriting from Base.
+ *
+ * Three types of classes are created and the virtual methods called to
+ * demonstrate:
+ * - Wide variety of primitive types
+ * - Calling methods with zero, one or more parameters
+ * - Director methods that are not overridden in D
+ * - Director classes that are not overridden at all in D, i.e. non-director
+ * behaviour is as expected for director classes
+ * - Inheritance hierarchy using director methods
+ * - Return types working as well as parameters
+ *
+ * The Caller class is a tester class which calls the virtual functions from C++.
+ */
+module director_primitives_runme;
+
+import std.exception;
+import std.stdio;
+import director_primitives.director_primitives;
+import director_primitives.Base;
+import director_primitives.Caller;
+import director_primitives.Derived;
+import director_primitives.HShadowMode;
+
+void main() {
+ PrintDebug = false;
+ if (PrintDebug) writeln("------------ Start ------------ ");
+
+ auto myCaller = new Caller();
+
+ // Test C++ base class.
+ {
+ scope myBase = new Base(100.0);
+ makeCalls(myCaller, myBase);
+ }
+
+ if (PrintDebug) writeln("--------------------------------");
+
+ // Test vanilla C++ wrapped derived class.
+ {
+ scope Base myBase = new Derived(100.0);
+ makeCalls(myCaller, myBase);
+ }
+
+ if (PrintDebug) writeln("--------------------------------");
+
+ // Test director/D derived class.
+ {
+ scope Base myBase = new DDerived(300.0);
+ makeCalls(myCaller, myBase);
+ }
+
+ if (PrintDebug) writeln("------------ Finish ------------ ");
+}
+
+void makeCalls(Caller myCaller, Base myBase) {
+ myCaller.set(myBase);
+
+ myCaller.NoParmsMethodCall();
+ enforce(myCaller.BoolMethodCall(true) == true, "failed");
+ enforce(myCaller.BoolMethodCall(false) == false, "failed");
+ enforce(myCaller.IntMethodCall(-123) == -123, "failed");
+ enforce(myCaller.UIntMethodCall(123) == 123, "failed");
+ enforce(myCaller.FloatMethodCall(-123.456f) == -123.456f, "failed");
+ enforce(myCaller.CharPtrMethodCall("test string") == "test string", "failed");
+ enforce(myCaller.ConstCharPtrMethodCall("another string") == "another string", "failed");
+ enforce(myCaller.EnumMethodCall(HShadowMode.HShadowHard) == HShadowMode.HShadowHard, "failed");
+ myCaller.ManyParmsMethodCall(true, -123, 123, 123.456f, "test string", "another string", HShadowMode.HShadowHard);
+ myCaller.NotOverriddenMethodCall();
+
+ myCaller.reset();
+}
+
+class DDerived : Base {
+public:
+ this(double dd) {
+ super(dd);
+ }
+
+ override void NoParmsMethod() {
+ if (PrintDebug) writeln("DDerived - NoParmsMethod()");
+ }
+
+ override bool BoolMethod(bool x) {
+ if (PrintDebug) writefln("DDerived - BoolMethod(%s)", x);
+ return x;
+ }
+
+ override int IntMethod(int x) {
+ if (PrintDebug) writefln("DDerived - IntMethod(%s)", x);
+ return x;
+ }
+
+ override uint UIntMethod(uint x) {
+ if (PrintDebug) writefln("DDerived - UIntMethod(%s)", x);
+ return x;
+ }
+
+ override float FloatMethod(float x) {
+ if (PrintDebug) writefln("DDerived - FloatMethod(%s)", x);
+ return x;
+ }
+
+ override string CharPtrMethod(string x) {
+ if (PrintDebug) writefln("DDerived - CharPtrMethod(%s)", x);
+ return x;
+ }
+
+ override string ConstCharPtrMethod(string x) {
+ if (PrintDebug) writefln("DDerived - ConstCharPtrMethod(%s)", x);
+ return x;
+ }
+
+ override HShadowMode EnumMethod(HShadowMode x) {
+ if (PrintDebug) writefln("DDerived - EnumMethod(%s)", x);
+ return x;
+ }
+
+ override void ManyParmsMethod(bool b, int i, uint u, float f, string c, string cc, HShadowMode h) {
+ if (PrintDebug) writefln("DDerived - ManyParmsMethod(%s, %s, %s, %s, %s, %s, %s)", b, i, u, f, c, cc, h);
+ }
+}
diff --git a/Examples/test-suite/d/director_protected_runme.1.d b/Examples/test-suite/d/director_protected_runme.1.d
new file mode 100644
index 000000000..81447b73b
--- /dev/null
+++ b/Examples/test-suite/d/director_protected_runme.1.d
@@ -0,0 +1,50 @@
+module director_protected_runme;
+
+import director_protected.Foo;
+import director_protected.Bar;
+
+void main() {
+ Bar b = new Bar();
+ Foo f = b.create();
+ auto fb = new FooBar();
+ auto fb2 = new FooBar2();
+
+ char[] s;
+ s = fb.used();
+ if ( s != ("Foo::pang();Bar::pong();Foo::pong();FooBar::ping();"))
+ throw new Exception("bad FooBar::used" ~ " - " ~ s);
+
+ s = fb2.used();
+ if ( s != ("FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();"))
+ throw new Exception("bad FooBar2::used");
+
+ s = b.pong();
+ if ( s != ("Bar::pong();Foo::pong();Bar::ping();"))
+ throw new Exception("bad Bar::pong");
+
+ s = f.pong();
+ if ( s != ("Bar::pong();Foo::pong();Bar::ping();"))
+ throw new Exception("bad Foo::pong");
+
+ s = fb.pong();
+ if ( s != ("Bar::pong();Foo::pong();FooBar::ping();"))
+ throw new Exception("bad FooBar::pong");
+}
+
+class FooBar : Bar {
+protected:
+ override char[] ping() {
+ return "FooBar::ping();";
+ }
+}
+
+class FooBar2 : Bar{
+protected:
+ override char[] ping() {
+ return "FooBar2::ping();";
+ }
+
+ override char[] pang() {
+ return "FooBar2::pang();";
+ }
+}
diff --git a/Examples/test-suite/d/director_protected_runme.2.d b/Examples/test-suite/d/director_protected_runme.2.d
new file mode 100644
index 000000000..9beeecd23
--- /dev/null
+++ b/Examples/test-suite/d/director_protected_runme.2.d
@@ -0,0 +1,36 @@
+module director_protected_runme;
+
+import std.exception;
+import director_protected.Foo;
+import director_protected.Bar;
+
+void main() {
+ Bar b = new Bar();
+ Foo f = b.create();
+ auto fb = new FooBar();
+ scope fb2 = new FooBar2();
+
+ enforce(fb.used() == "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::used" ~ " - " ~ fb.used());
+ enforce(fb2.used() == "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad FooBar2::used");
+ enforce(b.pong() == "Bar::pong();Foo::pong();Bar::ping();", "bad Bar::pong");
+ enforce(f.pong() == "Bar::pong();Foo::pong();Bar::ping();", "bad Foo::pong");
+ enforce(fb.pong() == "Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::pong");
+}
+
+class FooBar : Bar {
+protected:
+ override string ping() {
+ return "FooBar::ping();";
+ }
+}
+
+class FooBar2 : Bar {
+protected:
+ override string ping() {
+ return "FooBar2::ping();";
+ }
+
+ override string pang() {
+ return "FooBar2::pang();";
+ }
+}
diff --git a/Examples/test-suite/d/director_string_runme.1.d b/Examples/test-suite/d/director_string_runme.1.d
new file mode 100644
index 000000000..4e750791a
--- /dev/null
+++ b/Examples/test-suite/d/director_string_runme.1.d
@@ -0,0 +1,46 @@
+module director_string_runme;
+
+import Integer = tango.text.convert.Integer;
+import director_string.A;
+
+void main() {
+ char[] s;
+
+ auto c = new director_string_A("hi");
+ for (int i=0; i<3; ++i) {
+ s = c.call_get(i);
+ if (s != Integer.toString(i)) throw new Exception("director_string_A.get(" ~ Integer.toString(i) ~ ") failed. Got:" ~ s);
+ }
+
+ auto b = new director_string_B("hello");
+
+ s = b.call_get_first();
+ if (s != "director_string_B.get_first") throw new Exception("call_get_first() failed");
+
+ s = b.call_get(0);
+ if (s != "director_string_B.get: hello") throw new Exception("get(0) failed");
+}
+
+class director_string_B : A {
+public:
+ this(char[] first) {
+ super(first);
+ }
+ override char[] get_first() {
+ return "director_string_B.get_first";
+ }
+
+ override char[] get(int n) {
+ return "director_string_B.get: " ~ super.get(n);
+ }
+}
+
+class director_string_A : A {
+public:
+ this(char[] first) {
+ super(first);
+ }
+ override char[] get(int n) {
+ return Integer.toString(n);
+ }
+}
diff --git a/Examples/test-suite/d/director_string_runme.2.d b/Examples/test-suite/d/director_string_runme.2.d
new file mode 100644
index 000000000..950a34072
--- /dev/null
+++ b/Examples/test-suite/d/director_string_runme.2.d
@@ -0,0 +1,42 @@
+module director_string_runme;
+
+import std.conv;
+import std.exception;
+import director_string.A;
+
+void main() {
+ auto c = new director_string_A("hi");
+ for (int i=0; i<3; ++i) {
+ auto s = c.call_get(i);
+ auto expected = to!string(i);
+ enforce(s == expected, "director_string_A.get(" ~ expected ~ ") failed. Got:" ~ s);
+ }
+
+ auto b = new director_string_B("hello");
+ enforce(b.call_get_first() == "director_string_B.get_first", "call_get_first() failed");
+ enforce(b.call_get(0) == "director_string_B.get: hello", "get(0) failed");
+}
+
+class director_string_B : A {
+public:
+ this(string first) {
+ super(first);
+ }
+ override string get_first() const {
+ return "director_string_B.get_first";
+ }
+
+ override string get(int n) const {
+ return "director_string_B.get: " ~ super.get(n);
+ }
+}
+
+class director_string_A : A {
+public:
+ this(string first) {
+ super(first);
+ }
+ override string get(int n) const {
+ return to!string(n);
+ }
+}
diff --git a/Examples/test-suite/d/enum_thorough_runme.1.d b/Examples/test-suite/d/enum_thorough_runme.1.d
new file mode 100644
index 000000000..b76bfdd93
--- /dev/null
+++ b/Examples/test-suite/d/enum_thorough_runme.1.d
@@ -0,0 +1,424 @@
+module enum_thorough_runme;
+
+import enum_thorough.enum_thorough;
+import enum_thorough.AnonStruct;
+import enum_thorough.colour;
+import enum_thorough.FirStruct;
+import enum_thorough.HairStruct;
+import enum_thorough.IgnoreTest;
+import enum_thorough.Instances;
+import enum_thorough.namedanon;
+import enum_thorough.namedanonspace;
+import enum_thorough.newname;
+import enum_thorough.NewNameStruct;
+import enum_thorough.repeat;
+import enum_thorough.SpeedClass;
+import enum_thorough.TClassInt;
+import enum_thorough.TemplateClassInt;
+import enum_thorough.TreesClass;
+import enum_thorough.twonames;
+import enum_thorough.TwoNamesStruct;
+
+void main() {
+ {
+ // Anonymous enums
+ int i = AnonEnum1;
+ if (ReallyAnInteger != 200) throw new Exception("Test Anon 1 failed");
+ i += AnonSpaceEnum1;
+ i += AnonStruct.AnonStructEnum1;
+ }
+ {
+ auto red = colour.red;
+ colourTest1(red);
+ colourTest2(red);
+ colourTest3(red);
+ colourTest4(red);
+ myColour = red;
+ }
+ {
+ auto s = new SpeedClass();
+ auto speed = SpeedClass.speed.slow;
+ if (s.speedTest1(speed) != speed) throw new Exception("speedTest 1 failed");
+ if (s.speedTest2(speed) != speed) throw new Exception("speedTest 2 failed");
+ if (s.speedTest3(speed) != speed) throw new Exception("speedTest 3 failed");
+ if (s.speedTest4(speed) != speed) throw new Exception("speedTest 4 failed");
+ if (s.speedTest5(speed) != speed) throw new Exception("speedTest 5 failed");
+ if (s.speedTest6(speed) != speed) throw new Exception("speedTest 6 failed");
+ if (s.speedTest7(speed) != speed) throw new Exception("speedTest 7 failed");
+ if (s.speedTest8(speed) != speed) throw new Exception("speedTest 8 failed");
+
+ if (speedTest1(speed) != speed) throw new Exception("speedTest Global 1 failed");
+ if (speedTest2(speed) != speed) throw new Exception("speedTest Global 2 failed");
+ if (speedTest3(speed) != speed) throw new Exception("speedTest Global 3 failed");
+ if (speedTest4(speed) != speed) throw new Exception("speedTest Global 4 failed");
+ if (speedTest5(speed) != speed) throw new Exception("speedTest Global 5 failed");
+ }
+ {
+ auto s = new SpeedClass();
+ auto slow = SpeedClass.speed.slow;
+ auto lightning = SpeedClass.speed.lightning;
+
+ if (s.mySpeedtd1 != slow) throw new Exception("mySpeedtd1 1 failed");
+ if (cast(int)s.mySpeedtd1 != 10) throw new Exception("mySpeedtd1 2 failed");
+
+ s.mySpeedtd1 = lightning;
+ if (s.mySpeedtd1 != lightning) throw new Exception("mySpeedtd1 3 failed");
+ if (cast(int)s.mySpeedtd1 != 31) throw new Exception("mySpeedtd1 4 failed");
+ }
+ {
+ if (namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new Exception("namedanonTest 1 failed");
+ }
+ {
+ auto val = twonames.TwoNames2;
+ if (twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed");
+ if (twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed");
+ if (twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed");
+ }
+ {
+ auto t = new TwoNamesStruct();
+ auto val = TwoNamesStruct.twonames.TwoNamesStruct1;
+ if (t.twonamesTest1(val) != val) throw new Exception("twonamesTest 1 failed");
+ if (t.twonamesTest2(val) != val) throw new Exception("twonamesTest 2 failed");
+ if (t.twonamesTest3(val) != val) throw new Exception("twonamesTest 3 failed");
+ }
+ {
+ auto val = namedanonspace.NamedAnonSpace2;
+ if (namedanonspaceTest1(val) != val) throw new Exception("namedanonspaceTest 1 failed");
+ if (namedanonspaceTest2(val) != val) throw new Exception("namedanonspaceTest 2 failed");
+ if (namedanonspaceTest3(val) != val) throw new Exception("namedanonspaceTest 3 failed");
+ if (namedanonspaceTest4(val) != val) throw new Exception("namedanonspaceTest 4 failed");
+ }
+ {
+ auto t = new TemplateClassInt();
+ auto galileo = TemplateClassInt.scientists.galileo;
+ if (t.scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest 1 failed");
+ if (t.scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest 2 failed");
+ if (t.scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest 3 failed");
+ if (t.scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest 4 failed");
+ if (t.scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest 5 failed");
+ if (t.scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest 6 failed");
+ if (t.scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest 7 failed");
+ if (t.scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest 8 failed");
+ if (t.scientistsTest9(galileo) != galileo) throw new Exception("scientistsTest 9 failed");
+// if (t.scientistsTestA(galileo) != galileo) throw new Exception("scientistsTest A failed");
+ if (t.scientistsTestB(galileo) != galileo) throw new Exception("scientistsTest B failed");
+// if (t.scientistsTestC(galileo) != galileo) throw new Exception("scientistsTest C failed");
+ if (t.scientistsTestD(galileo) != galileo) throw new Exception("scientistsTest D failed");
+ if (t.scientistsTestE(galileo) != galileo) throw new Exception("scientistsTest E failed");
+ if (t.scientistsTestF(galileo) != galileo) throw new Exception("scientistsTest F failed");
+ if (t.scientistsTestG(galileo) != galileo) throw new Exception("scientistsTest G failed");
+ if (t.scientistsTestH(galileo) != galileo) throw new Exception("scientistsTest H failed");
+ if (t.scientistsTestI(galileo) != galileo) throw new Exception("scientistsTest I failed");
+ if (t.scientistsTestJ(galileo) != galileo) throw new Exception("scientistsTest J failed");
+
+ if (scientistsTest1(galileo) != galileo) throw new Exception("scientistsTest Global 1 failed");
+ if (scientistsTest2(galileo) != galileo) throw new Exception("scientistsTest Global 2 failed");
+ if (scientistsTest3(galileo) != galileo) throw new Exception("scientistsTest Global 3 failed");
+ if (scientistsTest4(galileo) != galileo) throw new Exception("scientistsTest Global 4 failed");
+ if (scientistsTest5(galileo) != galileo) throw new Exception("scientistsTest Global 5 failed");
+ if (scientistsTest6(galileo) != galileo) throw new Exception("scientistsTest Global 6 failed");
+ if (scientistsTest7(galileo) != galileo) throw new Exception("scientistsTest Global 7 failed");
+ if (scientistsTest8(galileo) != galileo) throw new Exception("scientistsTest Global 8 failed");
+ }
+ {
+ auto t = new TClassInt();
+ auto bell = TClassInt.scientists.bell;
+ auto galileo = TemplateClassInt.scientists.galileo;
+ if (t.scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest 1 failed");
+ if (t.scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest 2 failed");
+ if (t.scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest 3 failed");
+ if (t.scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest 4 failed");
+ if (t.scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest 5 failed");
+ if (t.scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest 6 failed");
+ if (t.scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest 7 failed");
+ if (t.scientistsNameTest8(bell) != bell) throw new Exception("scientistsNameTest 8 failed");
+ if (t.scientistsNameTest9(bell) != bell) throw new Exception("scientistsNameTest 9 failed");
+// if (t.scientistsNameTestA(bell) != bell) throw new Exception("scientistsNameTest A failed");
+ if (t.scientistsNameTestB(bell) != bell) throw new Exception("scientistsNameTest B failed");
+// if (t.scientistsNameTestC(bell) != bell) throw new Exception("scientistsNameTest C failed");
+ if (t.scientistsNameTestD(bell) != bell) throw new Exception("scientistsNameTest D failed");
+ if (t.scientistsNameTestE(bell) != bell) throw new Exception("scientistsNameTest E failed");
+ if (t.scientistsNameTestF(bell) != bell) throw new Exception("scientistsNameTest F failed");
+ if (t.scientistsNameTestG(bell) != bell) throw new Exception("scientistsNameTest G failed");
+ if (t.scientistsNameTestH(bell) != bell) throw new Exception("scientistsNameTest H failed");
+ if (t.scientistsNameTestI(bell) != bell) throw new Exception("scientistsNameTest I failed");
+
+ if (t.scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest 1 failed");
+ if (t.scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest 2 failed");
+ if (t.scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest 3 failed");
+ if (t.scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest 4 failed");
+ if (t.scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest 5 failed");
+ if (t.scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest 6 failed");
+ if (t.scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest 7 failed");
+
+ if (t.scientistsOtherTest1(galileo) != galileo) throw new Exception("scientistsOtherTest 1 failed");
+ if (t.scientistsOtherTest2(galileo) != galileo) throw new Exception("scientistsOtherTest 2 failed");
+ if (t.scientistsOtherTest3(galileo) != galileo) throw new Exception("scientistsOtherTest 3 failed");
+ if (t.scientistsOtherTest4(galileo) != galileo) throw new Exception("scientistsOtherTest 4 failed");
+ if (t.scientistsOtherTest5(galileo) != galileo) throw new Exception("scientistsOtherTest 5 failed");
+ if (t.scientistsOtherTest6(galileo) != galileo) throw new Exception("scientistsOtherTest 6 failed");
+ if (t.scientistsOtherTest7(galileo) != galileo) throw new Exception("scientistsOtherTest 7 failed");
+
+ if (scientistsNameTest1(bell) != bell) throw new Exception("scientistsNameTest Global 1 failed");
+ if (scientistsNameTest2(bell) != bell) throw new Exception("scientistsNameTest Global 2 failed");
+ if (scientistsNameTest3(bell) != bell) throw new Exception("scientistsNameTest Global 3 failed");
+ if (scientistsNameTest4(bell) != bell) throw new Exception("scientistsNameTest Global 4 failed");
+ if (scientistsNameTest5(bell) != bell) throw new Exception("scientistsNameTest Global 5 failed");
+ if (scientistsNameTest6(bell) != bell) throw new Exception("scientistsNameTest Global 6 failed");
+ if (scientistsNameTest7(bell) != bell) throw new Exception("scientistsNameTest Global 7 failed");
+
+ if (scientistsNameSpaceTest1(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 1 failed");
+ if (scientistsNameSpaceTest2(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 2 failed");
+ if (scientistsNameSpaceTest3(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 3 failed");
+ if (scientistsNameSpaceTest4(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 4 failed");
+ if (scientistsNameSpaceTest5(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 5 failed");
+ if (scientistsNameSpaceTest6(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 6 failed");
+ if (scientistsNameSpaceTest7(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 7 failed");
+
+ if (scientistsNameSpaceTest8(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 8 failed");
+ if (scientistsNameSpaceTest9(bell) != bell) throw new Exception("scientistsNameSpaceTest Global 9 failed");
+ if (scientistsNameSpaceTestA(bell) != bell) throw new Exception("scientistsNameSpaceTest Global A failed");
+ if (scientistsNameSpaceTestB(bell) != bell) throw new Exception("scientistsNameSpaceTest Global B failed");
+ if (scientistsNameSpaceTestC(bell) != bell) throw new Exception("scientistsNameSpaceTest Global C failed");
+ if (scientistsNameSpaceTestD(bell) != bell) throw new Exception("scientistsNameSpaceTest Global D failed");
+ if (scientistsNameSpaceTestE(bell) != bell) throw new Exception("scientistsNameSpaceTest Global E failed");
+
+ if (scientistsNameSpaceTestF(bell) != bell) throw new Exception("scientistsNameSpaceTest Global F failed");
+ if (scientistsNameSpaceTestG(bell) != bell) throw new Exception("scientistsNameSpaceTest Global G failed");
+ if (scientistsNameSpaceTestH(bell) != bell) throw new Exception("scientistsNameSpaceTest Global H failed");
+ if (scientistsNameSpaceTestI(bell) != bell) throw new Exception("scientistsNameSpaceTest Global I failed");
+ if (scientistsNameSpaceTestJ(bell) != bell) throw new Exception("scientistsNameSpaceTest Global J failed");
+ if (scientistsNameSpaceTestK(bell) != bell) throw new Exception("scientistsNameSpaceTest Global K failed");
+ if (scientistsNameSpaceTestL(bell) != bell) throw new Exception("scientistsNameSpaceTest Global L failed");
+ }
+ {
+ auto val = newname.argh;
+ if (renameTest1(val) != val) throw new Exception("renameTest Global 1 failed");
+ if (renameTest2(val) != val) throw new Exception("renameTest Global 2 failed");
+ }
+ {
+ auto n = new NewNameStruct();
+ if (n.renameTest1(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest 1 failed");
+ if (n.renameTest2(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest 2 failed");
+ if (n.renameTest3(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new Exception("renameTest 3 failed");
+ if (n.renameTest4(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest 4 failed");
+ if (n.renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest 5 failed");
+ if (n.renameTest6(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new Exception("renameTest 6 failed");
+ }
+ {
+ if (renameTest3(NewNameStruct.enumeration.bang) != NewNameStruct.enumeration.bang) throw new Exception("renameTest Global 3 failed");
+ if (renameTest4(NewNameStruct.simplerenamed.simple1) != NewNameStruct.simplerenamed.simple1) throw new Exception("renameTest Global 4 failed");
+ if (renameTest5(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest Global 5 failed");
+ if (renameTest6(NewNameStruct.doublenamerenamed.doublename1) != NewNameStruct.doublenamerenamed.doublename1) throw new Exception("renameTest Global 6 failed");
+ if (renameTest7(NewNameStruct.singlenamerenamed.singlename1) != NewNameStruct.singlenamerenamed.singlename1) throw new Exception("renameTest Global 7 failed");
+ }
+ {
+ auto t = new TreesClass();
+ auto pine = TreesClass.trees.pine;
+
+ if (t.treesTest1(pine) != pine) throw new Exception("treesTest 1 failed");
+ if (t.treesTest2(pine) != pine) throw new Exception("treesTest 2 failed");
+ if (t.treesTest3(pine) != pine) throw new Exception("treesTest 3 failed");
+ if (t.treesTest4(pine) != pine) throw new Exception("treesTest 4 failed");
+ if (t.treesTest5(pine) != pine) throw new Exception("treesTest 5 failed");
+ if (t.treesTest6(pine) != pine) throw new Exception("treesTest 6 failed");
+ if (t.treesTest7(pine) != pine) throw new Exception("treesTest 7 failed");
+ if (t.treesTest8(pine) != pine) throw new Exception("treesTest 8 failed");
+ if (t.treesTest9(pine) != pine) throw new Exception("treesTest 9 failed");
+ if (t.treesTestA(pine) != pine) throw new Exception("treesTest A failed");
+ if (t.treesTestB(pine) != pine) throw new Exception("treesTest B failed");
+ if (t.treesTestC(pine) != pine) throw new Exception("treesTest C failed");
+ if (t.treesTestD(pine) != pine) throw new Exception("treesTest D failed");
+ if (t.treesTestE(pine) != pine) throw new Exception("treesTest E failed");
+ if (t.treesTestF(pine) != pine) throw new Exception("treesTest F failed");
+ if (t.treesTestG(pine) != pine) throw new Exception("treesTest G failed");
+ if (t.treesTestH(pine) != pine) throw new Exception("treesTest H failed");
+ if (t.treesTestI(pine) != pine) throw new Exception("treesTest I failed");
+ if (t.treesTestJ(pine) != pine) throw new Exception("treesTest J failed");
+ if (t.treesTestK(pine) != pine) throw new Exception("treesTest K failed");
+ if (t.treesTestL(pine) != pine) throw new Exception("treesTest L failed");
+ if (t.treesTestM(pine) != pine) throw new Exception("treesTest M failed");
+ if (t.treesTestN(pine) != pine) throw new Exception("treesTest N failed");
+ if (t.treesTestO(pine) != pine) throw new Exception("treesTest O failed");
+
+ if (treesTest1(pine) != pine) throw new Exception("treesTest Global 1 failed");
+ if (treesTest2(pine) != pine) throw new Exception("treesTest Global 2 failed");
+ if (treesTest3(pine) != pine) throw new Exception("treesTest Global 3 failed");
+ if (treesTest4(pine) != pine) throw new Exception("treesTest Global 4 failed");
+ if (treesTest5(pine) != pine) throw new Exception("treesTest Global 5 failed");
+ if (treesTest6(pine) != pine) throw new Exception("treesTest Global 6 failed");
+ if (treesTest7(pine) != pine) throw new Exception("treesTest Global 7 failed");
+ if (treesTest8(pine) != pine) throw new Exception("treesTest Global 8 failed");
+ if (treesTest9(pine) != pine) throw new Exception("treesTest Global 9 failed");
+ if (treesTestA(pine) != pine) throw new Exception("treesTest Global A failed");
+ if (treesTestB(pine) != pine) throw new Exception("treesTest Global B failed");
+ if (treesTestC(pine) != pine) throw new Exception("treesTest Global C failed");
+ if (treesTestD(pine) != pine) throw new Exception("treesTest Global D failed");
+ if (treesTestE(pine) != pine) throw new Exception("treesTest Global E failed");
+ if (treesTestF(pine) != pine) throw new Exception("treesTest Global F failed");
+ if (treesTestG(pine) != pine) throw new Exception("treesTest Global G failed");
+ if (treesTestH(pine) != pine) throw new Exception("treesTest Global H failed");
+ if (treesTestI(pine) != pine) throw new Exception("treesTest Global I failed");
+ if (treesTestJ(pine) != pine) throw new Exception("treesTest Global J failed");
+ if (treesTestK(pine) != pine) throw new Exception("treesTest Global K failed");
+ if (treesTestL(pine) != pine) throw new Exception("treesTest Global L failed");
+ if (treesTestM(pine) != pine) throw new Exception("treesTest Global M failed");
+// if (treesTestN(pine) != pine) throw new Exception("treesTest Global N failed");
+ if (treesTestO(pine) != pine) throw new Exception("treesTest Global O failed");
+ if (treesTestP(pine) != pine) throw new Exception("treesTest Global P failed");
+ if (treesTestQ(pine) != pine) throw new Exception("treesTest Global Q failed");
+ if (treesTestR(pine) != pine) throw new Exception("treesTest Global R failed");
+ }
+ {
+ auto h = new HairStruct();
+ auto ginger = HairStruct.hair.ginger;
+
+ if (h.hairTest1(ginger) != ginger) throw new Exception("hairTest 1 failed");
+ if (h.hairTest2(ginger) != ginger) throw new Exception("hairTest 2 failed");
+ if (h.hairTest3(ginger) != ginger) throw new Exception("hairTest 3 failed");
+ if (h.hairTest4(ginger) != ginger) throw new Exception("hairTest 4 failed");
+ if (h.hairTest5(ginger) != ginger) throw new Exception("hairTest 5 failed");
+ if (h.hairTest6(ginger) != ginger) throw new Exception("hairTest 6 failed");
+ if (h.hairTest7(ginger) != ginger) throw new Exception("hairTest 7 failed");
+ if (h.hairTest8(ginger) != ginger) throw new Exception("hairTest 8 failed");
+ if (h.hairTest9(ginger) != ginger) throw new Exception("hairTest 9 failed");
+ if (h.hairTestA(ginger) != ginger) throw new Exception("hairTest A failed");
+ if (h.hairTestB(ginger) != ginger) throw new Exception("hairTest B failed");
+
+ auto red = colour.red;
+ if (h.colourTest1(red) != red) throw new Exception("colourTest HairStruct 1 failed");
+ if (h.colourTest2(red) != red) throw new Exception("colourTest HairStruct 2 failed");
+ if (h.namedanonTest1(namedanon.NamedAnon2) != namedanon.NamedAnon2) throw new Exception("namedanonTest HairStruct 1 failed");
+ if (h.namedanonspaceTest1(namedanonspace.NamedAnonSpace2) != namedanonspace.NamedAnonSpace2) throw new Exception("namedanonspaceTest HairStruct 1 failed");
+
+ auto fir = TreesClass.trees.fir;
+ if (h.treesGlobalTest1(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 1 failed");
+ if (h.treesGlobalTest2(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 2 failed");
+ if (h.treesGlobalTest3(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 3 failed");
+ if (h.treesGlobalTest4(fir) != fir) throw new Exception("treesGlobalTest1 HairStruct 4 failed");
+ }
+ {
+ auto blonde = HairStruct.hair.blonde;
+ if (hairTest1(blonde) != blonde) throw new Exception("hairTest Global 1 failed");
+ if (hairTest2(blonde) != blonde) throw new Exception("hairTest Global 2 failed");
+ if (hairTest3(blonde) != blonde) throw new Exception("hairTest Global 3 failed");
+ if (hairTest4(blonde) != blonde) throw new Exception("hairTest Global 4 failed");
+ if (hairTest5(blonde) != blonde) throw new Exception("hairTest Global 5 failed");
+ if (hairTest6(blonde) != blonde) throw new Exception("hairTest Global 6 failed");
+ if (hairTest7(blonde) != blonde) throw new Exception("hairTest Global 7 failed");
+ if (hairTest8(blonde) != blonde) throw new Exception("hairTest Global 8 failed");
+ if (hairTest9(blonde) != blonde) throw new Exception("hairTest Global 9 failed");
+ if (hairTestA(blonde) != blonde) throw new Exception("hairTest Global A failed");
+ if (hairTestB(blonde) != blonde) throw new Exception("hairTest Global B failed");
+ if (hairTestC(blonde) != blonde) throw new Exception("hairTest Global C failed");
+
+ if (hairTestA1(blonde) != blonde) throw new Exception("hairTest Global A1 failed");
+ if (hairTestA2(blonde) != blonde) throw new Exception("hairTest Global A2 failed");
+ if (hairTestA3(blonde) != blonde) throw new Exception("hairTest Global A3 failed");
+ if (hairTestA4(blonde) != blonde) throw new Exception("hairTest Global A4 failed");
+ if (hairTestA5(blonde) != blonde) throw new Exception("hairTest Global A5 failed");
+ if (hairTestA6(blonde) != blonde) throw new Exception("hairTest Global A6 failed");
+ if (hairTestA7(blonde) != blonde) throw new Exception("hairTest Global A7 failed");
+ if (hairTestA8(blonde) != blonde) throw new Exception("hairTest Global A8 failed");
+ if (hairTestA9(blonde) != blonde) throw new Exception("hairTest Global A9 failed");
+ if (hairTestAA(blonde) != blonde) throw new Exception("hairTest Global AA failed");
+ if (hairTestAB(blonde) != blonde) throw new Exception("hairTest Global AB failed");
+ if (hairTestAC(blonde) != blonde) throw new Exception("hairTest Global AC failed");
+
+ if (hairTestB1(blonde) != blonde) throw new Exception("hairTest Global B1 failed");
+ if (hairTestB2(blonde) != blonde) throw new Exception("hairTest Global B2 failed");
+ if (hairTestB3(blonde) != blonde) throw new Exception("hairTest Global B3 failed");
+ if (hairTestB4(blonde) != blonde) throw new Exception("hairTest Global B4 failed");
+ if (hairTestB5(blonde) != blonde) throw new Exception("hairTest Global B5 failed");
+ if (hairTestB6(blonde) != blonde) throw new Exception("hairTest Global B6 failed");
+ if (hairTestB7(blonde) != blonde) throw new Exception("hairTest Global B7 failed");
+ if (hairTestB8(blonde) != blonde) throw new Exception("hairTest Global B8 failed");
+ if (hairTestB9(blonde) != blonde) throw new Exception("hairTest Global B9 failed");
+ if (hairTestBA(blonde) != blonde) throw new Exception("hairTest Global BA failed");
+ if (hairTestBB(blonde) != blonde) throw new Exception("hairTest Global BB failed");
+ if (hairTestBC(blonde) != blonde) throw new Exception("hairTest Global BC failed");
+
+ if (hairTestC1(blonde) != blonde) throw new Exception("hairTest Global C1 failed");
+ if (hairTestC2(blonde) != blonde) throw new Exception("hairTest Global C2 failed");
+ if (hairTestC3(blonde) != blonde) throw new Exception("hairTest Global C3 failed");
+ if (hairTestC4(blonde) != blonde) throw new Exception("hairTest Global C4 failed");
+ if (hairTestC5(blonde) != blonde) throw new Exception("hairTest Global C5 failed");
+ if (hairTestC6(blonde) != blonde) throw new Exception("hairTest Global C6 failed");
+ if (hairTestC7(blonde) != blonde) throw new Exception("hairTest Global C7 failed");
+ if (hairTestC8(blonde) != blonde) throw new Exception("hairTest Global C8 failed");
+ if (hairTestC9(blonde) != blonde) throw new Exception("hairTest Global C9 failed");
+ if (hairTestCA(blonde) != blonde) throw new Exception("hairTest Global CA failed");
+ if (hairTestCB(blonde) != blonde) throw new Exception("hairTest Global CB failed");
+ if (hairTestCC(blonde) != blonde) throw new Exception("hairTest Global CC failed");
+ }
+ {
+ auto f = new FirStruct();
+ auto blonde = HairStruct.hair.blonde;
+
+ if (f.hairTestFir1(blonde) != blonde) throw new Exception("hairTestFir 1 failed");
+ if (f.hairTestFir2(blonde) != blonde) throw new Exception("hairTestFir 2 failed");
+ if (f.hairTestFir3(blonde) != blonde) throw new Exception("hairTestFir 3 failed");
+ if (f.hairTestFir4(blonde) != blonde) throw new Exception("hairTestFir 4 failed");
+ if (f.hairTestFir5(blonde) != blonde) throw new Exception("hairTestFir 5 failed");
+ if (f.hairTestFir6(blonde) != blonde) throw new Exception("hairTestFir 6 failed");
+ if (f.hairTestFir7(blonde) != blonde) throw new Exception("hairTestFir 7 failed");
+ if (f.hairTestFir8(blonde) != blonde) throw new Exception("hairTestFir 8 failed");
+ if (f.hairTestFir9(blonde) != blonde) throw new Exception("hairTestFir 9 failed");
+ if (f.hairTestFirA(blonde) != blonde) throw new Exception("hairTestFir A failed");
+ }
+ {
+ GlobalInstance = globalinstance2;
+ if (GlobalInstance != globalinstance2) throw new Exception("GlobalInstance 1 failed");
+
+ auto i = new Instances();
+ i.MemberInstance = Instances.memberinstance3;
+ if (i.MemberInstance != Instances.memberinstance3) throw new Exception("MemberInstance 1 failed");
+ }
+ // ignore enum item tests start
+ {
+ if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero) != 0) throw new Exception("ignoreATest 0 failed");
+ if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_three) != 3) throw new Exception("ignoreATest 3 failed");
+ if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten) != 10) throw new Exception("ignoreATest 10 failed");
+ if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven) != 11) throw new Exception("ignoreATest 11 failed");
+ if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen) != 13) throw new Exception("ignoreATest 13 failed");
+ if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen) != 14) throw new Exception("ignoreATest 14 failed");
+ if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty) != 20) throw new Exception("ignoreATest 20 failed");
+ if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty) != 30) throw new Exception("ignoreATest 30 failed");
+ if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two) != 32) throw new Exception("ignoreATest 32 failed");
+ if (cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three) != 33) throw new Exception("ignoreATest 33 failed");
+ }
+ {
+ if (cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven) != 11) throw new Exception("ignoreBTest 11 failed");
+ if (cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve) != 12) throw new Exception("ignoreBTest 12 failed");
+ if (cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one) != 31) throw new Exception("ignoreBTest 31 failed");
+ if (cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two) != 32) throw new Exception("ignoreBTest 32 failed");
+ if (cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one) != 41) throw new Exception("ignoreBTest 41 failed");
+ if (cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two) != 42) throw new Exception("ignoreBTest 42 failed");
+ }
+ {
+ if (cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten) != 10) throw new Exception("ignoreCTest 10 failed");
+ if (cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve) != 12) throw new Exception("ignoreCTest 12 failed");
+ if (cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty) != 30) throw new Exception("ignoreCTest 30 failed");
+ if (cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two) != 32) throw new Exception("ignoreCTest 32 failed");
+ if (cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty) != 40) throw new Exception("ignoreCTest 40 failed");
+ if (cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two) != 42) throw new Exception("ignoreCTest 42 failed");
+ }
+ {
+ if (cast(int)ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one) != 21) throw new Exception("ignoreDTest 21 failed");
+ if (cast(int)ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two) != 22) throw new Exception("ignoreDTest 22 failed");
+ }
+ {
+ if (cast(int)ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero) != 0) throw new Exception("ignoreETest 0 failed");
+ if (cast(int)ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one) != 21) throw new Exception("ignoreETest 21 failed");
+ if (cast(int)ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two) != 22) throw new Exception("ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
+ {
+ if (cast(int)repeatTest(repeat.one) != 1) throw new Exception("repeatTest 1 failed");
+ if (cast(int)repeatTest(repeat.initial) != 1) throw new Exception("repeatTest 2 failed");
+ if (cast(int)repeatTest(repeat.two) != 2) throw new Exception("repeatTest 3 failed");
+ if (cast(int)repeatTest(repeat.three) != 3) throw new Exception("repeatTest 4 failed");
+ if (cast(int)repeatTest(repeat.llast) != 3) throw new Exception("repeatTest 5 failed");
+ if (cast(int)repeatTest(repeat.end) != 3) throw new Exception("repeatTest 6 failed");
+ }
+}
diff --git a/Examples/test-suite/d/enum_thorough_runme.2.d b/Examples/test-suite/d/enum_thorough_runme.2.d
new file mode 100644
index 000000000..d8b2a2ad9
--- /dev/null
+++ b/Examples/test-suite/d/enum_thorough_runme.2.d
@@ -0,0 +1,425 @@
+module enum_thorough_runme;
+
+import std.exception;
+import enum_thorough.enum_thorough;
+import enum_thorough.AnonStruct;
+import enum_thorough.colour;
+import enum_thorough.FirStruct;
+import enum_thorough.HairStruct;
+import enum_thorough.IgnoreTest;
+import enum_thorough.Instances;
+import enum_thorough.namedanon;
+import enum_thorough.namedanonspace;
+import enum_thorough.newname;
+import enum_thorough.NewNameStruct;
+import enum_thorough.repeat;
+import enum_thorough.SpeedClass;
+import enum_thorough.TClassInt;
+import enum_thorough.TemplateClassInt;
+import enum_thorough.TreesClass;
+import enum_thorough.twonames;
+import enum_thorough.TwoNamesStruct;
+
+void main() {
+ {
+ // Anonymous enums
+ int i = AnonEnum1;
+ enforce(ReallyAnInteger == 200, "Test Anon 1 failed");
+ i += AnonSpaceEnum1;
+ i += AnonStruct.AnonStructEnum1;
+ }
+ {
+ auto red = colour.red;
+ colourTest1(red);
+ colourTest2(red);
+ colourTest3(red);
+ colourTest4(red);
+ myColour = red;
+ }
+ {
+ auto s = new SpeedClass();
+ auto speed = SpeedClass.speed.slow;
+ enforce(s.speedTest1(speed) == speed, "speedTest 1 failed");
+ enforce(s.speedTest2(speed) == speed, "speedTest 2 failed");
+ enforce(s.speedTest3(speed) == speed, "speedTest 3 failed");
+ enforce(s.speedTest4(speed) == speed, "speedTest 4 failed");
+ enforce(s.speedTest5(speed) == speed, "speedTest 5 failed");
+ enforce(s.speedTest6(speed) == speed, "speedTest 6 failed");
+ enforce(s.speedTest7(speed) == speed, "speedTest 7 failed");
+ enforce(s.speedTest8(speed) == speed, "speedTest 8 failed");
+
+ enforce(speedTest1(speed) == speed, "speedTest Global 1 failed");
+ enforce(speedTest2(speed) == speed, "speedTest Global 2 failed");
+ enforce(speedTest3(speed) == speed, "speedTest Global 3 failed");
+ enforce(speedTest4(speed) == speed, "speedTest Global 4 failed");
+ enforce(speedTest5(speed) == speed, "speedTest Global 5 failed");
+ }
+ {
+ auto s = new SpeedClass();
+ auto slow = SpeedClass.speed.slow;
+ auto lightning = SpeedClass.speed.lightning;
+
+ enforce(s.mySpeedtd1 == slow, "mySpeedtd1 1 failed");
+ enforce(cast(int)s.mySpeedtd1 == 10, "mySpeedtd1 2 failed");
+
+ s.mySpeedtd1 = lightning;
+ enforce(s.mySpeedtd1 == lightning, "mySpeedtd1 3 failed");
+ enforce(cast(int)s.mySpeedtd1 == 31, "mySpeedtd1 4 failed");
+ }
+ {
+ enforce(namedanonTest1(namedanon.NamedAnon2) == namedanon.NamedAnon2, "namedanonTest 1 failed");
+ }
+ {
+ auto val = twonames.TwoNames2;
+ enforce(twonamesTest1(val) == val, "twonamesTest 1 failed");
+ enforce(twonamesTest2(val) == val, "twonamesTest 2 failed");
+ enforce(twonamesTest3(val) == val, "twonamesTest 3 failed");
+ }
+ {
+ auto t = new TwoNamesStruct();
+ auto val = TwoNamesStruct.twonames.TwoNamesStruct1;
+ enforce(t.twonamesTest1(val) == val, "twonamesTest 1 failed");
+ enforce(t.twonamesTest2(val) == val, "twonamesTest 2 failed");
+ enforce(t.twonamesTest3(val) == val, "twonamesTest 3 failed");
+ }
+ {
+ auto val = namedanonspace.NamedAnonSpace2;
+ enforce(namedanonspaceTest1(val) == val, "namedanonspaceTest 1 failed");
+ enforce(namedanonspaceTest2(val) == val, "namedanonspaceTest 2 failed");
+ enforce(namedanonspaceTest3(val) == val, "namedanonspaceTest 3 failed");
+ enforce(namedanonspaceTest4(val) == val, "namedanonspaceTest 4 failed");
+ }
+ {
+ auto t = new TemplateClassInt();
+ auto galileo = TemplateClassInt.scientists.galileo;
+ enforce(t.scientistsTest1(galileo) == galileo, "scientistsTest 1 failed");
+ enforce(t.scientistsTest2(galileo) == galileo, "scientistsTest 2 failed");
+ enforce(t.scientistsTest3(galileo) == galileo, "scientistsTest 3 failed");
+ enforce(t.scientistsTest4(galileo) == galileo, "scientistsTest 4 failed");
+ enforce(t.scientistsTest5(galileo) == galileo, "scientistsTest 5 failed");
+ enforce(t.scientistsTest6(galileo) == galileo, "scientistsTest 6 failed");
+ enforce(t.scientistsTest7(galileo) == galileo, "scientistsTest 7 failed");
+ enforce(t.scientistsTest8(galileo) == galileo, "scientistsTest 8 failed");
+ enforce(t.scientistsTest9(galileo) == galileo, "scientistsTest 9 failed");
+// enforce(t.scientistsTestA(galileo) == galileo, "scientistsTest A failed");
+ enforce(t.scientistsTestB(galileo) == galileo, "scientistsTest B failed");
+// enforce(t.scientistsTestC(galileo) == galileo, "scientistsTest C failed");
+ enforce(t.scientistsTestD(galileo) == galileo, "scientistsTest D failed");
+ enforce(t.scientistsTestE(galileo) == galileo, "scientistsTest E failed");
+ enforce(t.scientistsTestF(galileo) == galileo, "scientistsTest F failed");
+ enforce(t.scientistsTestG(galileo) == galileo, "scientistsTest G failed");
+ enforce(t.scientistsTestH(galileo) == galileo, "scientistsTest H failed");
+ enforce(t.scientistsTestI(galileo) == galileo, "scientistsTest I failed");
+ enforce(t.scientistsTestJ(galileo) == galileo, "scientistsTest J failed");
+
+ enforce(scientistsTest1(galileo) == galileo, "scientistsTest Global 1 failed");
+ enforce(scientistsTest2(galileo) == galileo, "scientistsTest Global 2 failed");
+ enforce(scientistsTest3(galileo) == galileo, "scientistsTest Global 3 failed");
+ enforce(scientistsTest4(galileo) == galileo, "scientistsTest Global 4 failed");
+ enforce(scientistsTest5(galileo) == galileo, "scientistsTest Global 5 failed");
+ enforce(scientistsTest6(galileo) == galileo, "scientistsTest Global 6 failed");
+ enforce(scientistsTest7(galileo) == galileo, "scientistsTest Global 7 failed");
+ enforce(scientistsTest8(galileo) == galileo, "scientistsTest Global 8 failed");
+ }
+ {
+ auto t = new TClassInt();
+ auto bell = TClassInt.scientists.bell;
+ auto galileo = TemplateClassInt.scientists.galileo;
+ enforce(t.scientistsNameTest1(bell) == bell, "scientistsNameTest 1 failed");
+ enforce(t.scientistsNameTest2(bell) == bell, "scientistsNameTest 2 failed");
+ enforce(t.scientistsNameTest3(bell) == bell, "scientistsNameTest 3 failed");
+ enforce(t.scientistsNameTest4(bell) == bell, "scientistsNameTest 4 failed");
+ enforce(t.scientistsNameTest5(bell) == bell, "scientistsNameTest 5 failed");
+ enforce(t.scientistsNameTest6(bell) == bell, "scientistsNameTest 6 failed");
+ enforce(t.scientistsNameTest7(bell) == bell, "scientistsNameTest 7 failed");
+ enforce(t.scientistsNameTest8(bell) == bell, "scientistsNameTest 8 failed");
+ enforce(t.scientistsNameTest9(bell) == bell, "scientistsNameTest 9 failed");
+// enforce(t.scientistsNameTestA(bell) == bell, "scientistsNameTest A failed");
+ enforce(t.scientistsNameTestB(bell) == bell, "scientistsNameTest B failed");
+// enforce(t.scientistsNameTestC(bell) == bell, "scientistsNameTest C failed");
+ enforce(t.scientistsNameTestD(bell) == bell, "scientistsNameTest D failed");
+ enforce(t.scientistsNameTestE(bell) == bell, "scientistsNameTest E failed");
+ enforce(t.scientistsNameTestF(bell) == bell, "scientistsNameTest F failed");
+ enforce(t.scientistsNameTestG(bell) == bell, "scientistsNameTest G failed");
+ enforce(t.scientistsNameTestH(bell) == bell, "scientistsNameTest H failed");
+ enforce(t.scientistsNameTestI(bell) == bell, "scientistsNameTest I failed");
+
+ enforce(t.scientistsNameSpaceTest1(bell) == bell, "scientistsNameSpaceTest 1 failed");
+ enforce(t.scientistsNameSpaceTest2(bell) == bell, "scientistsNameSpaceTest 2 failed");
+ enforce(t.scientistsNameSpaceTest3(bell) == bell, "scientistsNameSpaceTest 3 failed");
+ enforce(t.scientistsNameSpaceTest4(bell) == bell, "scientistsNameSpaceTest 4 failed");
+ enforce(t.scientistsNameSpaceTest5(bell) == bell, "scientistsNameSpaceTest 5 failed");
+ enforce(t.scientistsNameSpaceTest6(bell) == bell, "scientistsNameSpaceTest 6 failed");
+ enforce(t.scientistsNameSpaceTest7(bell) == bell, "scientistsNameSpaceTest 7 failed");
+
+ enforce(t.scientistsOtherTest1(galileo) == galileo, "scientistsOtherTest 1 failed");
+ enforce(t.scientistsOtherTest2(galileo) == galileo, "scientistsOtherTest 2 failed");
+ enforce(t.scientistsOtherTest3(galileo) == galileo, "scientistsOtherTest 3 failed");
+ enforce(t.scientistsOtherTest4(galileo) == galileo, "scientistsOtherTest 4 failed");
+ enforce(t.scientistsOtherTest5(galileo) == galileo, "scientistsOtherTest 5 failed");
+ enforce(t.scientistsOtherTest6(galileo) == galileo, "scientistsOtherTest 6 failed");
+ enforce(t.scientistsOtherTest7(galileo) == galileo, "scientistsOtherTest 7 failed");
+
+ enforce(scientistsNameTest1(bell) == bell, "scientistsNameTest Global 1 failed");
+ enforce(scientistsNameTest2(bell) == bell, "scientistsNameTest Global 2 failed");
+ enforce(scientistsNameTest3(bell) == bell, "scientistsNameTest Global 3 failed");
+ enforce(scientistsNameTest4(bell) == bell, "scientistsNameTest Global 4 failed");
+ enforce(scientistsNameTest5(bell) == bell, "scientistsNameTest Global 5 failed");
+ enforce(scientistsNameTest6(bell) == bell, "scientistsNameTest Global 6 failed");
+ enforce(scientistsNameTest7(bell) == bell, "scientistsNameTest Global 7 failed");
+
+ enforce(scientistsNameSpaceTest1(bell) == bell, "scientistsNameSpaceTest Global 1 failed");
+ enforce(scientistsNameSpaceTest2(bell) == bell, "scientistsNameSpaceTest Global 2 failed");
+ enforce(scientistsNameSpaceTest3(bell) == bell, "scientistsNameSpaceTest Global 3 failed");
+ enforce(scientistsNameSpaceTest4(bell) == bell, "scientistsNameSpaceTest Global 4 failed");
+ enforce(scientistsNameSpaceTest5(bell) == bell, "scientistsNameSpaceTest Global 5 failed");
+ enforce(scientistsNameSpaceTest6(bell) == bell, "scientistsNameSpaceTest Global 6 failed");
+ enforce(scientistsNameSpaceTest7(bell) == bell, "scientistsNameSpaceTest Global 7 failed");
+
+ enforce(scientistsNameSpaceTest8(bell) == bell, "scientistsNameSpaceTest Global 8 failed");
+ enforce(scientistsNameSpaceTest9(bell) == bell, "scientistsNameSpaceTest Global 9 failed");
+ enforce(scientistsNameSpaceTestA(bell) == bell, "scientistsNameSpaceTest Global A failed");
+ enforce(scientistsNameSpaceTestB(bell) == bell, "scientistsNameSpaceTest Global B failed");
+ enforce(scientistsNameSpaceTestC(bell) == bell, "scientistsNameSpaceTest Global C failed");
+ enforce(scientistsNameSpaceTestD(bell) == bell, "scientistsNameSpaceTest Global D failed");
+ enforce(scientistsNameSpaceTestE(bell) == bell, "scientistsNameSpaceTest Global E failed");
+
+ enforce(scientistsNameSpaceTestF(bell) == bell, "scientistsNameSpaceTest Global F failed");
+ enforce(scientistsNameSpaceTestG(bell) == bell, "scientistsNameSpaceTest Global G failed");
+ enforce(scientistsNameSpaceTestH(bell) == bell, "scientistsNameSpaceTest Global H failed");
+ enforce(scientistsNameSpaceTestI(bell) == bell, "scientistsNameSpaceTest Global I failed");
+ enforce(scientistsNameSpaceTestJ(bell) == bell, "scientistsNameSpaceTest Global J failed");
+ enforce(scientistsNameSpaceTestK(bell) == bell, "scientistsNameSpaceTest Global K failed");
+ enforce(scientistsNameSpaceTestL(bell) == bell, "scientistsNameSpaceTest Global L failed");
+ }
+ {
+ auto val = newname.argh;
+ enforce(renameTest1(val) == val, "renameTest Global 1 failed");
+ enforce(renameTest2(val) == val, "renameTest Global 2 failed");
+ }
+ {
+ auto n = new NewNameStruct();
+ enforce(n.renameTest1(NewNameStruct.enumeration.bang) == NewNameStruct.enumeration.bang, "renameTest 1 failed");
+ enforce(n.renameTest2(NewNameStruct.enumeration.bang) == NewNameStruct.enumeration.bang, "renameTest 2 failed");
+ enforce(n.renameTest3(NewNameStruct.simplerenamed.simple1) == NewNameStruct.simplerenamed.simple1, "renameTest 3 failed");
+ enforce(n.renameTest4(NewNameStruct.doublenamerenamed.doublename1) == NewNameStruct.doublenamerenamed.doublename1, "renameTest 4 failed");
+ enforce(n.renameTest5(NewNameStruct.doublenamerenamed.doublename1) == NewNameStruct.doublenamerenamed.doublename1, "renameTest 5 failed");
+ enforce(n.renameTest6(NewNameStruct.singlenamerenamed.singlename1) == NewNameStruct.singlenamerenamed.singlename1, "renameTest 6 failed");
+ }
+ {
+ enforce(renameTest3(NewNameStruct.enumeration.bang) == NewNameStruct.enumeration.bang, "renameTest Global 3 failed");
+ enforce(renameTest4(NewNameStruct.simplerenamed.simple1) == NewNameStruct.simplerenamed.simple1, "renameTest Global 4 failed");
+ enforce(renameTest5(NewNameStruct.doublenamerenamed.doublename1) == NewNameStruct.doublenamerenamed.doublename1, "renameTest Global 5 failed");
+ enforce(renameTest6(NewNameStruct.doublenamerenamed.doublename1) == NewNameStruct.doublenamerenamed.doublename1, "renameTest Global 6 failed");
+ enforce(renameTest7(NewNameStruct.singlenamerenamed.singlename1) == NewNameStruct.singlenamerenamed.singlename1, "renameTest Global 7 failed");
+ }
+ {
+ auto t = new TreesClass();
+ auto pine = TreesClass.trees.pine;
+
+ enforce(t.treesTest1(pine) == pine, "treesTest 1 failed");
+ enforce(t.treesTest2(pine) == pine, "treesTest 2 failed");
+ enforce(t.treesTest3(pine) == pine, "treesTest 3 failed");
+ enforce(t.treesTest4(pine) == pine, "treesTest 4 failed");
+ enforce(t.treesTest5(pine) == pine, "treesTest 5 failed");
+ enforce(t.treesTest6(pine) == pine, "treesTest 6 failed");
+ enforce(t.treesTest7(pine) == pine, "treesTest 7 failed");
+ enforce(t.treesTest8(pine) == pine, "treesTest 8 failed");
+ enforce(t.treesTest9(pine) == pine, "treesTest 9 failed");
+ enforce(t.treesTestA(pine) == pine, "treesTest A failed");
+ enforce(t.treesTestB(pine) == pine, "treesTest B failed");
+ enforce(t.treesTestC(pine) == pine, "treesTest C failed");
+ enforce(t.treesTestD(pine) == pine, "treesTest D failed");
+ enforce(t.treesTestE(pine) == pine, "treesTest E failed");
+ enforce(t.treesTestF(pine) == pine, "treesTest F failed");
+ enforce(t.treesTestG(pine) == pine, "treesTest G failed");
+ enforce(t.treesTestH(pine) == pine, "treesTest H failed");
+ enforce(t.treesTestI(pine) == pine, "treesTest I failed");
+ enforce(t.treesTestJ(pine) == pine, "treesTest J failed");
+ enforce(t.treesTestK(pine) == pine, "treesTest K failed");
+ enforce(t.treesTestL(pine) == pine, "treesTest L failed");
+ enforce(t.treesTestM(pine) == pine, "treesTest M failed");
+ enforce(t.treesTestN(pine) == pine, "treesTest N failed");
+ enforce(t.treesTestO(pine) == pine, "treesTest O failed");
+
+ enforce(treesTest1(pine) == pine, "treesTest Global 1 failed");
+ enforce(treesTest2(pine) == pine, "treesTest Global 2 failed");
+ enforce(treesTest3(pine) == pine, "treesTest Global 3 failed");
+ enforce(treesTest4(pine) == pine, "treesTest Global 4 failed");
+ enforce(treesTest5(pine) == pine, "treesTest Global 5 failed");
+ enforce(treesTest6(pine) == pine, "treesTest Global 6 failed");
+ enforce(treesTest7(pine) == pine, "treesTest Global 7 failed");
+ enforce(treesTest8(pine) == pine, "treesTest Global 8 failed");
+ enforce(treesTest9(pine) == pine, "treesTest Global 9 failed");
+ enforce(treesTestA(pine) == pine, "treesTest Global A failed");
+ enforce(treesTestB(pine) == pine, "treesTest Global B failed");
+ enforce(treesTestC(pine) == pine, "treesTest Global C failed");
+ enforce(treesTestD(pine) == pine, "treesTest Global D failed");
+ enforce(treesTestE(pine) == pine, "treesTest Global E failed");
+ enforce(treesTestF(pine) == pine, "treesTest Global F failed");
+ enforce(treesTestG(pine) == pine, "treesTest Global G failed");
+ enforce(treesTestH(pine) == pine, "treesTest Global H failed");
+ enforce(treesTestI(pine) == pine, "treesTest Global I failed");
+ enforce(treesTestJ(pine) == pine, "treesTest Global J failed");
+ enforce(treesTestK(pine) == pine, "treesTest Global K failed");
+ enforce(treesTestL(pine) == pine, "treesTest Global L failed");
+ enforce(treesTestM(pine) == pine, "treesTest Global M failed");
+// enforce(treesTestN(pine) == pine, "treesTest Global N failed");
+ enforce(treesTestO(pine) == pine, "treesTest Global O failed");
+ enforce(treesTestP(pine) == pine, "treesTest Global P failed");
+ enforce(treesTestQ(pine) == pine, "treesTest Global Q failed");
+ enforce(treesTestR(pine) == pine, "treesTest Global R failed");
+ }
+ {
+ auto h = new HairStruct();
+ auto ginger = HairStruct.hair.ginger;
+
+ enforce(h.hairTest1(ginger) == ginger, "hairTest 1 failed");
+ enforce(h.hairTest2(ginger) == ginger, "hairTest 2 failed");
+ enforce(h.hairTest3(ginger) == ginger, "hairTest 3 failed");
+ enforce(h.hairTest4(ginger) == ginger, "hairTest 4 failed");
+ enforce(h.hairTest5(ginger) == ginger, "hairTest 5 failed");
+ enforce(h.hairTest6(ginger) == ginger, "hairTest 6 failed");
+ enforce(h.hairTest7(ginger) == ginger, "hairTest 7 failed");
+ enforce(h.hairTest8(ginger) == ginger, "hairTest 8 failed");
+ enforce(h.hairTest9(ginger) == ginger, "hairTest 9 failed");
+ enforce(h.hairTestA(ginger) == ginger, "hairTest A failed");
+ enforce(h.hairTestB(ginger) == ginger, "hairTest B failed");
+
+ auto red = colour.red;
+ enforce(h.colourTest1(red) == red, "colourTest HairStruct 1 failed");
+ enforce(h.colourTest2(red) == red, "colourTest HairStruct 2 failed");
+ enforce(h.namedanonTest1(namedanon.NamedAnon2) == namedanon.NamedAnon2, "namedanonTest HairStruct 1 failed");
+ enforce(h.namedanonspaceTest1(namedanonspace.NamedAnonSpace2) == namedanonspace.NamedAnonSpace2, "namedanonspaceTest HairStruct 1 failed");
+
+ auto fir = TreesClass.trees.fir;
+ enforce(h.treesGlobalTest1(fir) == fir, "treesGlobalTest1 HairStruct 1 failed");
+ enforce(h.treesGlobalTest2(fir) == fir, "treesGlobalTest1 HairStruct 2 failed");
+ enforce(h.treesGlobalTest3(fir) == fir, "treesGlobalTest1 HairStruct 3 failed");
+ enforce(h.treesGlobalTest4(fir) == fir, "treesGlobalTest1 HairStruct 4 failed");
+ }
+ {
+ auto blonde = HairStruct.hair.blonde;
+ enforce(hairTest1(blonde) == blonde, "hairTest Global 1 failed");
+ enforce(hairTest2(blonde) == blonde, "hairTest Global 2 failed");
+ enforce(hairTest3(blonde) == blonde, "hairTest Global 3 failed");
+ enforce(hairTest4(blonde) == blonde, "hairTest Global 4 failed");
+ enforce(hairTest5(blonde) == blonde, "hairTest Global 5 failed");
+ enforce(hairTest6(blonde) == blonde, "hairTest Global 6 failed");
+ enforce(hairTest7(blonde) == blonde, "hairTest Global 7 failed");
+ enforce(hairTest8(blonde) == blonde, "hairTest Global 8 failed");
+ enforce(hairTest9(blonde) == blonde, "hairTest Global 9 failed");
+ enforce(hairTestA(blonde) == blonde, "hairTest Global A failed");
+ enforce(hairTestB(blonde) == blonde, "hairTest Global B failed");
+ enforce(hairTestC(blonde) == blonde, "hairTest Global C failed");
+
+ enforce(hairTestA1(blonde) == blonde, "hairTest Global A1 failed");
+ enforce(hairTestA2(blonde) == blonde, "hairTest Global A2 failed");
+ enforce(hairTestA3(blonde) == blonde, "hairTest Global A3 failed");
+ enforce(hairTestA4(blonde) == blonde, "hairTest Global A4 failed");
+ enforce(hairTestA5(blonde) == blonde, "hairTest Global A5 failed");
+ enforce(hairTestA6(blonde) == blonde, "hairTest Global A6 failed");
+ enforce(hairTestA7(blonde) == blonde, "hairTest Global A7 failed");
+ enforce(hairTestA8(blonde) == blonde, "hairTest Global A8 failed");
+ enforce(hairTestA9(blonde) == blonde, "hairTest Global A9 failed");
+ enforce(hairTestAA(blonde) == blonde, "hairTest Global AA failed");
+ enforce(hairTestAB(blonde) == blonde, "hairTest Global AB failed");
+ enforce(hairTestAC(blonde) == blonde, "hairTest Global AC failed");
+
+ enforce(hairTestB1(blonde) == blonde, "hairTest Global B1 failed");
+ enforce(hairTestB2(blonde) == blonde, "hairTest Global B2 failed");
+ enforce(hairTestB3(blonde) == blonde, "hairTest Global B3 failed");
+ enforce(hairTestB4(blonde) == blonde, "hairTest Global B4 failed");
+ enforce(hairTestB5(blonde) == blonde, "hairTest Global B5 failed");
+ enforce(hairTestB6(blonde) == blonde, "hairTest Global B6 failed");
+ enforce(hairTestB7(blonde) == blonde, "hairTest Global B7 failed");
+ enforce(hairTestB8(blonde) == blonde, "hairTest Global B8 failed");
+ enforce(hairTestB9(blonde) == blonde, "hairTest Global B9 failed");
+ enforce(hairTestBA(blonde) == blonde, "hairTest Global BA failed");
+ enforce(hairTestBB(blonde) == blonde, "hairTest Global BB failed");
+ enforce(hairTestBC(blonde) == blonde, "hairTest Global BC failed");
+
+ enforce(hairTestC1(blonde) == blonde, "hairTest Global C1 failed");
+ enforce(hairTestC2(blonde) == blonde, "hairTest Global C2 failed");
+ enforce(hairTestC3(blonde) == blonde, "hairTest Global C3 failed");
+ enforce(hairTestC4(blonde) == blonde, "hairTest Global C4 failed");
+ enforce(hairTestC5(blonde) == blonde, "hairTest Global C5 failed");
+ enforce(hairTestC6(blonde) == blonde, "hairTest Global C6 failed");
+ enforce(hairTestC7(blonde) == blonde, "hairTest Global C7 failed");
+ enforce(hairTestC8(blonde) == blonde, "hairTest Global C8 failed");
+ enforce(hairTestC9(blonde) == blonde, "hairTest Global C9 failed");
+ enforce(hairTestCA(blonde) == blonde, "hairTest Global CA failed");
+ enforce(hairTestCB(blonde) == blonde, "hairTest Global CB failed");
+ enforce(hairTestCC(blonde) == blonde, "hairTest Global CC failed");
+ }
+ {
+ auto f = new FirStruct();
+ auto blonde = HairStruct.hair.blonde;
+
+ enforce(f.hairTestFir1(blonde) == blonde, "hairTestFir 1 failed");
+ enforce(f.hairTestFir2(blonde) == blonde, "hairTestFir 2 failed");
+ enforce(f.hairTestFir3(blonde) == blonde, "hairTestFir 3 failed");
+ enforce(f.hairTestFir4(blonde) == blonde, "hairTestFir 4 failed");
+ enforce(f.hairTestFir5(blonde) == blonde, "hairTestFir 5 failed");
+ enforce(f.hairTestFir6(blonde) == blonde, "hairTestFir 6 failed");
+ enforce(f.hairTestFir7(blonde) == blonde, "hairTestFir 7 failed");
+ enforce(f.hairTestFir8(blonde) == blonde, "hairTestFir 8 failed");
+ enforce(f.hairTestFir9(blonde) == blonde, "hairTestFir 9 failed");
+ enforce(f.hairTestFirA(blonde) == blonde, "hairTestFir A failed");
+ }
+ {
+ GlobalInstance = globalinstance2;
+ enforce(GlobalInstance == globalinstance2, "GlobalInstance 1 failed");
+
+ auto i = new Instances();
+ i.MemberInstance = Instances.memberinstance3;
+ enforce(i.MemberInstance == Instances.memberinstance3, "MemberInstance 1 failed");
+ }
+ // ignore enum item tests start
+ {
+ enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_zero) == 0, "ignoreATest 0 failed");
+ enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_three) == 3, "ignoreATest 3 failed");
+ enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_ten) == 10, "ignoreATest 10 failed");
+ enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_eleven) == 11, "ignoreATest 11 failed");
+ enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirteen) == 13, "ignoreATest 13 failed");
+ enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_fourteen) == 14, "ignoreATest 14 failed");
+ enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_twenty) == 20, "ignoreATest 20 failed");
+ enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty) == 30, "ignoreATest 30 failed");
+ enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_two) == 32, "ignoreATest 32 failed");
+ enforce(cast(int)ignoreATest(IgnoreTest.IgnoreA.ignoreA_thirty_three) == 33, "ignoreATest 33 failed");
+ }
+ {
+ enforce(cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_eleven) == 11, "ignoreBTest 11 failed");
+ enforce(cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_twelve) == 12, "ignoreBTest 12 failed");
+ enforce(cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_one) == 31, "ignoreBTest 31 failed");
+ enforce(cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_thirty_two) == 32, "ignoreBTest 32 failed");
+ enforce(cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_one) == 41, "ignoreBTest 41 failed");
+ enforce(cast(int)ignoreBTest(IgnoreTest.IgnoreB.ignoreB_forty_two) == 42, "ignoreBTest 42 failed");
+ }
+ {
+ enforce(cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_ten), "ignoreCTest 10 failed");
+ enforce(cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_twelve) == 12, "ignoreCTest 12 failed");
+ enforce(cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty) == 30, "ignoreCTest 30 failed");
+ enforce(cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_thirty_two) == 32, "ignoreCTest 32 failed");
+ enforce(cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty) == 40, "ignoreCTest 40 failed");
+ enforce(cast(int)ignoreCTest(IgnoreTest.IgnoreC.ignoreC_forty_two) == 42, "ignoreCTest 42 failed");
+ }
+ {
+ enforce(cast(int)ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_one) == 21, "ignoreDTest 21 failed");
+ enforce(cast(int)ignoreDTest(IgnoreTest.IgnoreD.ignoreD_twenty_two) == 22, "ignoreDTest 22 failed");
+ }
+ {
+ enforce(cast(int)ignoreETest(IgnoreTest.IgnoreE.ignoreE_zero) == 0, "ignoreETest 0 failed");
+ enforce(cast(int)ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_one) == 21, "ignoreETest 21 failed");
+ enforce(cast(int)ignoreETest(IgnoreTest.IgnoreE.ignoreE_twenty_two) == 22, "ignoreETest 22 failed");
+ }
+ // ignore enum item tests end
+ {
+ enforce(cast(int)repeatTest(repeat.one) == 1, "repeatTest 1 failed");
+ enforce(cast(int)repeatTest(repeat.initial) == 1, "repeatTest 2 failed");
+ enforce(cast(int)repeatTest(repeat.two) == 2, "repeatTest 3 failed");
+ enforce(cast(int)repeatTest(repeat.three) == 3, "repeatTest 4 failed");
+ enforce(cast(int)repeatTest(repeat.llast) == 3, "repeatTest 5 failed");
+ enforce(cast(int)repeatTest(repeat.end) == 3, "repeatTest 6 failed");
+ }
+}
diff --git a/Examples/test-suite/d/inherit_target_language_runme.1.d b/Examples/test-suite/d/inherit_target_language_runme.1.d
new file mode 100644
index 000000000..8a13caca4
--- /dev/null
+++ b/Examples/test-suite/d/inherit_target_language_runme.1.d
@@ -0,0 +1,29 @@
+module inherit_target_language_runme;
+
+import inherit_target_language.BaseX;
+import inherit_target_language.Derived1;
+import inherit_target_language.Derived2;
+import inherit_target_language.DerivedX;
+import inherit_target_language.MultipleDerived1;
+import inherit_target_language.MultipleDerived2;
+import inherit_target_language.MultipleDerived3;
+import inherit_target_language.MultipleDerived4;
+
+void main() {
+ (new Derived1()).targetLanguageBaseMethod();
+ (new Derived2()).targetLanguageBaseMethod();
+
+ (new MultipleDerived1()).targetLanguageBaseMethod();
+ (new MultipleDerived2()).targetLanguageBaseMethod();
+ (new MultipleDerived3()).f();
+ (new MultipleDerived4()).g();
+
+ auto baseX = new BaseX();
+ baseX.basex();
+ baseX.targetLanguageBase2Method();
+
+ auto derivedX = new DerivedX();
+ derivedX.basex();
+ derivedX.derivedx();
+ derivedX.targetLanguageBase2Method();
+}
diff --git a/Examples/test-suite/d/inherit_target_language_runme.2.d b/Examples/test-suite/d/inherit_target_language_runme.2.d
new file mode 100644
index 000000000..8a13caca4
--- /dev/null
+++ b/Examples/test-suite/d/inherit_target_language_runme.2.d
@@ -0,0 +1,29 @@
+module inherit_target_language_runme;
+
+import inherit_target_language.BaseX;
+import inherit_target_language.Derived1;
+import inherit_target_language.Derived2;
+import inherit_target_language.DerivedX;
+import inherit_target_language.MultipleDerived1;
+import inherit_target_language.MultipleDerived2;
+import inherit_target_language.MultipleDerived3;
+import inherit_target_language.MultipleDerived4;
+
+void main() {
+ (new Derived1()).targetLanguageBaseMethod();
+ (new Derived2()).targetLanguageBaseMethod();
+
+ (new MultipleDerived1()).targetLanguageBaseMethod();
+ (new MultipleDerived2()).targetLanguageBaseMethod();
+ (new MultipleDerived3()).f();
+ (new MultipleDerived4()).g();
+
+ auto baseX = new BaseX();
+ baseX.basex();
+ baseX.targetLanguageBase2Method();
+
+ auto derivedX = new DerivedX();
+ derivedX.basex();
+ derivedX.derivedx();
+ derivedX.targetLanguageBase2Method();
+}
diff --git a/Examples/test-suite/d/li_attribute_runme.1.d b/Examples/test-suite/d/li_attribute_runme.1.d
new file mode 100644
index 000000000..ada3ed8d8
--- /dev/null
+++ b/Examples/test-suite/d/li_attribute_runme.1.d
@@ -0,0 +1,75 @@
+module li_attribute_runme;
+
+import li_attribute.A;
+import li_attribute.B;
+import li_attribute.MyClass;
+import li_attribute.MyClassVal;
+import li_attribute.MyStringyClass;
+import li_attribute.MyFoo;
+import li_attribute.Param_i;
+
+void main() {
+ auto aa = new A(1,2,3);
+
+ if (aa.a != 1)
+ throw new Exception("error");
+ aa.a = 3;
+ if (aa.a != 3)
+ throw new Exception("error");
+
+ if (aa.b != 2)
+ throw new Exception("error");
+ aa.b = 5;
+ if (aa.b != 5)
+ throw new Exception("error");
+
+ if (aa.d != aa.b)
+ throw new Exception("error");
+
+ if (aa.c != 3)
+ throw new Exception("error");
+
+ auto pi = new Param_i(7);
+ if (pi.value != 7)
+ throw new Exception("error");
+
+ pi.value=3;
+ if (pi.value != 3)
+ throw new Exception("error");
+
+ auto b = new B(aa);
+ if (b.a.c != 3)
+ throw new Exception("error");
+
+ // class/struct attribute with get/set methods using return/pass by reference
+ auto myFoo = new MyFoo();
+ myFoo.x = 8;
+ auto myClass = new MyClass();
+ myClass.Foo = myFoo;
+ if (myClass.Foo.x != 8)
+ throw new Exception("error");
+
+ // class/struct attribute with get/set methods using return/pass by value
+ auto myClassVal = new MyClassVal();
+ if (myClassVal.ReadWriteFoo.x != -1)
+ throw new Exception("error");
+ if (myClassVal.ReadOnlyFoo.x != -1)
+ throw new Exception("error");
+ myClassVal.ReadWriteFoo = myFoo;
+ if (myClassVal.ReadWriteFoo.x != 8)
+ throw new Exception("error");
+ if (myClassVal.ReadOnlyFoo.x != 8)
+ throw new Exception("error");
+
+ // string attribute with get/set methods using return/pass by value
+ auto myStringClass = new MyStringyClass("initial string");
+ if (myStringClass.ReadWriteString != "initial string")
+ throw new Exception("error");
+ if (myStringClass.ReadOnlyString != "initial string")
+ throw new Exception("error");
+ myStringClass.ReadWriteString = "changed string";
+ if (myStringClass.ReadWriteString != "changed string")
+ throw new Exception("error");
+ if (myStringClass.ReadOnlyString != "changed string")
+ throw new Exception("error");
+}
diff --git a/Examples/test-suite/d/li_attribute_runme.2.d b/Examples/test-suite/d/li_attribute_runme.2.d
new file mode 100644
index 000000000..4e0ea58ff
--- /dev/null
+++ b/Examples/test-suite/d/li_attribute_runme.2.d
@@ -0,0 +1,58 @@
+module li_attribute_runme;
+
+import std.exception;
+import li_attribute.A;
+import li_attribute.B;
+import li_attribute.MyClass;
+import li_attribute.MyClassVal;
+import li_attribute.MyStringyClass;
+import li_attribute.MyFoo;
+import li_attribute.Param_i;
+
+void main() {
+ auto aa = new A(1,2,3);
+
+ enforce(aa.a == 1);
+ aa.a = 3;
+ enforce(aa.a == 3);
+
+ enforce(aa.b == 2);
+ aa.b = 5;
+ enforce(aa.b == 5);
+
+ enforce(aa.d == aa.b);
+
+ enforce(aa.c == 3);
+
+ auto pi = new Param_i(7);
+ enforce(pi.value == 7);
+
+ pi.value=3;
+ enforce(pi.value == 3);
+
+ auto b = new B(aa);
+ enforce(b.a.c == 3);
+
+ // class/struct attribute with get/set methods using return/pass by reference
+ auto myFoo = new MyFoo();
+ myFoo.x = 8;
+ auto myClass = new MyClass();
+ myClass.Foo = myFoo;
+ enforce(myClass.Foo.x == 8);
+
+ // class/struct attribute with get/set methods using return/pass by value
+ auto myClassVal = new MyClassVal();
+ enforce(myClassVal.ReadWriteFoo.x == -1);
+ enforce(myClassVal.ReadOnlyFoo.x == -1);
+ myClassVal.ReadWriteFoo = myFoo;
+ enforce(myClassVal.ReadWriteFoo.x == 8);
+ enforce(myClassVal.ReadOnlyFoo.x == 8);
+
+ // string attribute with get/set methods using return/pass by value
+ auto myStringClass = new MyStringyClass("initial string");
+ enforce(myStringClass.ReadWriteString == "initial string");
+ enforce(myStringClass.ReadOnlyString == "initial string");
+ myStringClass.ReadWriteString = "changed string";
+ enforce(myStringClass.ReadWriteString == "changed string");
+ enforce(myStringClass.ReadOnlyString == "changed string");
+}
diff --git a/Examples/test-suite/d/li_boost_shared_ptr_bits_runme.1.d b/Examples/test-suite/d/li_boost_shared_ptr_bits_runme.1.d
new file mode 100644
index 000000000..098570b95
--- /dev/null
+++ b/Examples/test-suite/d/li_boost_shared_ptr_bits_runme.1.d
@@ -0,0 +1,21 @@
+module li_boost_shared_ptr_runme_bits;
+
+import li_boost_shared_ptr_bits.li_boost_shared_ptr_bits;
+import li_boost_shared_ptr_bits.HiddenDestructor;
+import li_boost_shared_ptr_bits.IntHolder;
+import li_boost_shared_ptr_bits.VectorIntHolder;
+
+void main() {
+ auto v = new VectorIntHolder();
+ v ~= new IntHolder(11);
+ v ~= new IntHolder(22);
+ v ~= new IntHolder(33);
+
+ if (sum(v) != 66) {
+ throw new Exception("sum is wrong");
+ }
+
+ {
+ scope hidden = HiddenDestructor.create();
+ }
+}
diff --git a/Examples/test-suite/d/li_boost_shared_ptr_bits_runme.2.d b/Examples/test-suite/d/li_boost_shared_ptr_bits_runme.2.d
new file mode 100644
index 000000000..4891b7673
--- /dev/null
+++ b/Examples/test-suite/d/li_boost_shared_ptr_bits_runme.2.d
@@ -0,0 +1,19 @@
+module li_boost_shared_ptr_runme_bits;
+
+import std.exception;
+import li_boost_shared_ptr_bits.li_boost_shared_ptr_bits;
+import li_boost_shared_ptr_bits.HiddenDestructor;
+import li_boost_shared_ptr_bits.IntHolder;
+import li_boost_shared_ptr_bits.VectorIntHolder;
+
+void main() {
+ auto v = new VectorIntHolder();
+ v ~= new IntHolder(11);
+ v ~= new IntHolder(22);
+ v ~= new IntHolder(33);
+ enforce(sum(v) == 66, "sum is wrong");
+
+ {
+ scope hidden = HiddenDestructor.create();
+ }
+}
diff --git a/Examples/test-suite/d/li_boost_shared_ptr_runme.1.d b/Examples/test-suite/d/li_boost_shared_ptr_runme.1.d
new file mode 100644
index 000000000..ed55cd302
--- /dev/null
+++ b/Examples/test-suite/d/li_boost_shared_ptr_runme.1.d
@@ -0,0 +1,604 @@
+module li_boost_shared_ptr_runme;
+
+import tango.io.Stdout;
+import tango.core.Exception;
+import tango.core.Memory;
+import tango.core.Thread;
+import tango.text.convert.Integer;
+import li_boost_shared_ptr.li_boost_shared_ptr;
+import li_boost_shared_ptr.Klass;
+import li_boost_shared_ptr.KlassDerived;
+import li_boost_shared_ptr.Klass3rdDerived;
+import li_boost_shared_ptr.MemberVariables;
+import li_boost_shared_ptr.PairIntDouble;
+
+// Debugging flag
+const bool TRACE = false;
+
+void main() {
+ if (TRACE)
+ Stdout("---> STARTED <---").newline;
+
+ debug_shared=TRACE;
+
+ // Change loop count to run for a long time to monitor memory
+ const int LOOP_COUNT = 1; // 50000;
+ for (int i = 0; i < LOOP_COUNT; ++i) {
+ runTest();
+ GC.collect();
+ }
+
+ if (TRACE)
+ Stdout("---> NEARLY FINISHED <---").newline;
+
+ // Try to get the GC to collect everything not referenced anymore.
+ int countdown = 100;
+ while (--countdown) {
+ GC.collect();
+ if (Klass.getTotal_count() == 1)
+ break;
+ Thread.sleep(0.01);
+ }
+
+ // A single remaining instance expected: the global variable (GlobalValue).
+ if (Klass.getTotal_count() != 1)
+ throw new Exception("Klass.total_count=" ~ toString(Klass.getTotal_count()));
+
+ // A single remaining instance expected: the global variable (GlobalSmartValue).
+ int wrapper_count = shared_ptr_wrapper_count();
+ if (wrapper_count != NOT_COUNTING)
+ if (wrapper_count != 1)
+ throw new Exception("shared_ptr wrapper count=" ~ toString(wrapper_count));
+
+ if (TRACE)
+ Stdout("---> FINISHED <---").newline;
+}
+
+void runTest() {
+ // simple shared_ptr usage - created in C++
+ {
+ auto k = new Klass("me oh my");
+ char[] val = k.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ }
+
+ // simple shared_ptr usage - not created in C++
+ {
+ auto k = factorycreate();
+ char[] val = k.getValue();
+ verifyValue("factorycreate", val);
+ verifyCount(1, k);
+ }
+
+ // pass by shared_ptr
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointertest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointerpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointerreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointerpointerreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr
+ {
+ auto k = new Klass("me oh my");
+ auto kret = constsmartpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr pointer
+ {
+ auto k = new Klass("me oh my");
+ auto kret = constsmartpointerpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = constsmartpointerreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by value
+ {
+ auto k = new Klass("me oh my");
+ auto kret = valuetest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my valuetest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer
+ {
+ auto k = new Klass("me oh my");
+ auto kret = pointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my pointertest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = reftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my reftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = pointerreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my pointerreftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // null tests
+ {
+ Klass k = null;
+
+ // TODO: add in const versions too
+ if (smartpointertest(k) !is null)
+ throw new Exception("return was not null");
+
+ if (smartpointerpointertest(k) !is null)
+ throw new Exception("return was not null");
+
+ if (smartpointerreftest(k) !is null)
+ throw new Exception("return was not null");
+
+ if (smartpointerpointerreftest(k) !is null)
+ throw new Exception("return was not null");
+
+ if (nullsmartpointerpointertest(null) != "null pointer")
+ throw new Exception("not null smartpointer pointer");
+
+ try { valuetest(k); throw new Exception("Failed to catch null pointer"); } catch (IllegalArgumentException) {}
+
+ if (pointertest(k) !is null)
+ throw new Exception("return was not null");
+
+ try { reftest(k); throw new Exception("Failed to catch null pointer"); } catch (IllegalArgumentException) {}
+ }
+
+ // $owner
+ {
+ auto k = pointerownertest();
+ char[] val = k.getValue();
+ verifyValue("pointerownertest", val);
+ verifyCount(1, k);
+ }
+ {
+ auto k = smartpointerpointerownertest();
+ char[] val = k.getValue();
+ verifyValue("smartpointerpointerownertest", val);
+ verifyCount(1, k);
+ }
+
+ ////////////////////////////////// Derived classes ////////////////////////////////////////
+ // derived pass by shared_ptr
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrtest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrtest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr pointer
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointertest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr ref
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrreftest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr pointer ref
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrpointerreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by pointer
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my derivedpointertest-Derived", val);
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ verifyCount(2, kret);
+ }
+ // derived pass by ref
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my derivedreftest-Derived", val);
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ verifyCount(2, kret);
+ }
+
+ ////////////////////////////////// Derived and base class mixed ////////////////////////////////////////
+ // pass by shared_ptr (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointertest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr pointer (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointerpointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr reference (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointerreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr pointer reference (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointerpointerreftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by value (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = valuetest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my valuetest", val); // note slicing
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = pointertest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my pointertest-Derived", val);
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // pass by ref (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = reftest(k);
+ char[] val = kret.getValue();
+ verifyValue("me oh my reftest-Derived", val);
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // 3rd derived class
+ {
+ auto k = new Klass3rdDerived("me oh my");
+ char[] val = k.getValue();
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values
+ val = test3rdupcast(k);
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k);
+ }
+
+ ////////////////////////////////// Member variables ////////////////////////////////////////
+ // smart pointer by value
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("smart member value");
+ m.SmartMemberValue = k;
+ char[] val = k.getValue();
+ verifyValue("smart member value", val);
+ verifyCount(2, k);
+
+ auto kmember = m.SmartMemberValue;
+ val = kmember.getValue();
+ verifyValue("smart member value", val);
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+
+ delete m;
+
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+ }
+ // smart pointer by pointer
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("smart member pointer");
+ m.SmartMemberPointer = k;
+ char[] val = k.getValue();
+ verifyValue("smart member pointer", val);
+ verifyCount(1, k);
+
+ auto kmember = m.SmartMemberPointer;
+ val = kmember.getValue();
+ verifyValue("smart member pointer", val);
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+
+ delete m;
+
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+ }
+ // smart pointer by reference
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("smart member reference");
+ m.SmartMemberReference = k;
+ char[] val = k.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(2, k);
+
+ auto kmember = m.SmartMemberReference;
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+
+ // The C++ reference refers to SmartMemberValue...
+ auto kmemberVal = m.SmartMemberValue;
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(4, kmemberVal);
+ verifyCount(4, kmember);
+ verifyCount(4, k);
+
+ delete m;
+
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+ }
+ // plain by value
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("plain member value");
+ m.MemberValue = k;
+ char[] val = k.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, k);
+
+ auto kmember = m.MemberValue;
+ val = kmember.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ delete m;
+
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ // plain by pointer
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("plain member pointer");
+ m.MemberPointer = k;
+ char[] val = k.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, k);
+
+ auto kmember = m.MemberPointer;
+ val = kmember.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ delete m;
+
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ // plain by reference
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("plain member reference");
+ m.MemberReference = k;
+ char[] val = k.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, k);
+
+ auto kmember = m.MemberReference;
+ val = kmember.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ delete m;
+
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+
+ // null member variables
+ {
+ auto m = new MemberVariables();
+
+ // shared_ptr by value
+ auto k = m.SmartMemberValue;
+ if (k !is null)
+ throw new Exception("expected null");
+ m.SmartMemberValue = null;
+ k = m.SmartMemberValue;
+ if (k !is null)
+ throw new Exception("expected null");
+ verifyCount(0, k);
+
+ // plain by value
+ try { m.MemberValue = null; throw new Exception("Failed to catch null pointer"); } catch (IllegalArgumentException) {}
+ }
+
+ ////////////////////////////////// Global variables ////////////////////////////////////////
+ // smart pointer
+ {
+ auto kglobal = GlobalSmartValue;
+ if (kglobal !is null)
+ throw new Exception("expected null");
+
+ auto k = new Klass("smart global value");
+ GlobalSmartValue = k;
+ verifyCount(2, k);
+
+ kglobal = GlobalSmartValue;
+ char[] val = kglobal.getValue();
+ verifyValue("smart global value", val);
+ verifyCount(3, kglobal);
+ verifyCount(3, k);
+ verifyValue("smart global value", GlobalSmartValue.getValue());
+ GlobalSmartValue = null;
+ }
+ // plain value
+ {
+ Klass kglobal;
+
+ auto k = new Klass("global value");
+ GlobalValue = k;
+ verifyCount(1, k);
+
+ kglobal = GlobalValue;
+ char[] val = kglobal.getValue();
+ verifyValue("global value", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ verifyValue("global value", GlobalValue.getValue());
+
+ try { GlobalValue = null; throw new Exception("Failed to catch null pointer"); } catch (IllegalArgumentException) {}
+ }
+ // plain pointer
+ {
+ auto kglobal = GlobalPointer;
+ if (kglobal !is null)
+ throw new Exception("expected null");
+
+ auto k = new Klass("global pointer");
+ GlobalPointer = k;
+ verifyCount(1, k);
+
+ kglobal = GlobalPointer;
+ char[] val = kglobal.getValue();
+ verifyValue("global pointer", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ GlobalPointer = null;
+ }
+ // plain reference
+ {
+ Klass kglobal;
+
+ auto k = new Klass("global reference");
+ GlobalReference = k;
+ verifyCount(1, k);
+
+ kglobal = GlobalReference;
+ char[] val = kglobal.getValue();
+ verifyValue("global reference", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+
+ try { GlobalReference = null; throw new Exception("Failed to catch null pointer"); } catch (IllegalArgumentException) {}
+ }
+
+ ////////////////////////////////// Templates ////////////////////////////////////////
+ {
+ PairIntDouble pid = new PairIntDouble(10, 20.2);
+ if (pid.baseVal1 != 20 || pid.baseVal2 != 40.4)
+ throw new Exception("Base values wrong");
+ if (pid.val1 != 10 || pid.val2 != 20.2)
+ throw new Exception("Derived Values wrong");
+ }
+}
+
+private void verifyValue(char[] expected, char[] got) {
+ if (expected != got)
+ throw new Exception("verify value failed. Expected: " ~ expected ~ " Got: " ~ got);
+}
+
+private void verifyCount(int expected, Klass k) {
+ // We deliberately call the use_count(Klass) overload also for objects which
+ // are instances of a subclass of Klass (due to static dispatch); things still
+ // have to work.
+ int got = use_count(k);
+ if (expected != got)
+ throw new Exception("verify use_count failed. Expected: " ~ toString(expected) ~ " Got: " ~ toString(got));
+}
diff --git a/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d b/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d
new file mode 100644
index 000000000..773ae74d5
--- /dev/null
+++ b/Examples/test-suite/d/li_boost_shared_ptr_runme.2.d
@@ -0,0 +1,602 @@
+module li_boost_shared_ptr_runme;
+
+import core.memory;
+import core.thread;
+import std.conv;
+import std.exception;
+import std.stdio;
+import li_boost_shared_ptr.li_boost_shared_ptr;
+import li_boost_shared_ptr.Klass;
+import li_boost_shared_ptr.KlassDerived;
+import li_boost_shared_ptr.Klass3rdDerived;
+import li_boost_shared_ptr.MemberVariables;
+import li_boost_shared_ptr.PairIntDouble;
+
+// Debugging flag
+enum TRACE = false;
+
+void main() {
+ if (TRACE)
+ writeln("---> STARTED <---");
+
+ debug_shared = TRACE;
+
+ // Change loop count to run for a long time to monitor memory
+ enum LOOP_COUNT = 1; // 50000;
+ for (int i = 0; i < LOOP_COUNT; ++i) {
+ runTest();
+ GC.collect();
+ }
+
+ if (TRACE)
+ writeln("---> NEARLY FINISHED <---");
+
+ // Try to get the GC to collect everything not referenced anymore.
+ int countdown = 100;
+ while (--countdown) {
+ GC.collect();
+ if (Klass.getTotal_count() == 1)
+ break;
+ Thread.sleep(100);
+ }
+
+ // A single remaining instance expected: the global variable (GlobalValue).
+ if (Klass.getTotal_count() != 1)
+ throw new Exception("Klass.total_count=" ~ to!string(Klass.getTotal_count()));
+
+ // A single remaining instance expected: the global variable (GlobalSmartValue).
+ int wrapper_count = shared_ptr_wrapper_count();
+ if (wrapper_count != NOT_COUNTING)
+ if (wrapper_count != 1)
+ throw new Exception("shared_ptr wrapper count=" ~ to!string(wrapper_count));
+
+ if (TRACE)
+ writeln("---> FINISHED <---");
+}
+
+void runTest() {
+ // simple shared_ptr usage - created in C++
+ {
+ auto k = new Klass("me oh my");
+ string val = k.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(1, k);
+ }
+
+ // simple shared_ptr usage - not created in C++
+ {
+ auto k = factorycreate();
+ string val = k.getValue();
+ verifyValue("factorycreate", val);
+ verifyCount(1, k);
+ }
+
+ // pass by shared_ptr
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointertest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointerpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointerreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by shared_ptr pointer reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = smartpointerpointerreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr
+ {
+ auto k = new Klass("me oh my");
+ auto kret = constsmartpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr pointer
+ {
+ auto k = new Klass("me oh my");
+ auto kret = constsmartpointerpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // const pass by shared_ptr reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = constsmartpointerreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my", val);
+ verifyCount(2, k);
+ verifyCount(2, kret);
+ }
+
+ // pass by value
+ {
+ auto k = new Klass("me oh my");
+ auto kret = valuetest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my valuetest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer
+ {
+ auto k = new Klass("me oh my");
+ auto kret = pointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my pointertest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = reftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my reftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer reference
+ {
+ auto k = new Klass("me oh my");
+ auto kret = pointerreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my pointerreftest", val);
+ verifyCount(1, k);
+ verifyCount(1, kret);
+ }
+
+ // null tests
+ {
+ Klass k = null;
+
+ // TODO: add in const versions too
+ enforce(smartpointertest(k) is null, "return was not null");
+ enforce(smartpointerpointertest(k) is null, "return was not null");
+ enforce(smartpointerreftest(k) is null, "return was not null");
+ enforce(smartpointerpointerreftest(k) is null, "return was not null");
+ enforce(nullsmartpointerpointertest(null) == "null pointer",
+ "not null smartpointer pointer");
+
+ enforceThrows( (){ valuetest(k); }, "Failed to catch null pointer");
+ enforce(pointertest(k) is null, "return was not null");
+ enforceThrows( (){ reftest(k); }, "Failed to catch null pointer");
+ }
+
+ // $owner
+ {
+ auto k = pointerownertest();
+ string val = k.getValue();
+ verifyValue("pointerownertest", val);
+ verifyCount(1, k);
+ }
+ {
+ auto k = smartpointerpointerownertest();
+ string val = k.getValue();
+ verifyValue("smartpointerpointerownertest", val);
+ verifyCount(1, k);
+ }
+
+ ////////////////////////////////// Derived classes ////////////////////////////////////////
+ // derived pass by shared_ptr
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrtest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrtest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr pointer
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointertest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr ref
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrreftest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by shared_ptr pointer ref
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedsmartptrpointerreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val);
+ verifyCount(4, k); // includes two extra references for upcasts in the proxy classes
+ verifyCount(4, kret);
+ }
+ // derived pass by pointer
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my derivedpointertest-Derived", val);
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ verifyCount(2, kret);
+ }
+ // derived pass by ref
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = derivedreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my derivedreftest-Derived", val);
+ verifyCount(2, k); // includes an extra reference for the upcast in the proxy class
+ verifyCount(2, kret);
+ }
+
+ ////////////////////////////////// Derived and base class mixed ////////////////////////////////////////
+ // pass by shared_ptr (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointertest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr pointer (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointerpointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointerpointertest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr reference (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointerreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointerreftest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by shared_ptr pointer reference (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = smartpointerpointerreftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my smartpointerpointerreftest-Derived", val);
+ verifyCount(3, k); // an extra reference for the upcast in the proxy class
+ verifyCount(3, kret);
+ }
+
+ // pass by value (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = valuetest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my valuetest", val); // note slicing
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // pass by pointer (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = pointertest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my pointertest-Derived", val);
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // pass by ref (mixed)
+ {
+ auto k = new KlassDerived("me oh my");
+ auto kret = reftest(k);
+ string val = kret.getValue();
+ verifyValue("me oh my reftest-Derived", val);
+ verifyCount(2, k); // an extra reference for the upcast in the proxy class
+ verifyCount(1, kret);
+ }
+
+ // 3rd derived class
+ {
+ auto k = new Klass3rdDerived("me oh my");
+ string val = k.getValue();
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k); // 3 classes in inheritance chain == 3 swigCPtr values
+ val = test3rdupcast(k);
+ verifyValue("me oh my-3rdDerived", val);
+ verifyCount(3, k);
+ }
+
+ ////////////////////////////////// Member variables ////////////////////////////////////////
+ // smart pointer by value
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("smart member value");
+ m.SmartMemberValue = k;
+ string val = k.getValue();
+ verifyValue("smart member value", val);
+ verifyCount(2, k);
+
+ auto kmember = m.SmartMemberValue;
+ val = kmember.getValue();
+ verifyValue("smart member value", val);
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+
+ delete m;
+
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+ }
+ // smart pointer by pointer
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("smart member pointer");
+ m.SmartMemberPointer = k;
+ string val = k.getValue();
+ verifyValue("smart member pointer", val);
+ verifyCount(1, k);
+
+ auto kmember = m.SmartMemberPointer;
+ val = kmember.getValue();
+ verifyValue("smart member pointer", val);
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+
+ delete m;
+
+ verifyCount(2, kmember);
+ verifyCount(2, k);
+ }
+ // smart pointer by reference
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("smart member reference");
+ m.SmartMemberReference = k;
+ string val = k.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(2, k);
+
+ auto kmember = m.SmartMemberReference;
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+
+ // The C++ reference refers to SmartMemberValue...
+ auto kmemberVal = m.SmartMemberValue;
+ val = kmember.getValue();
+ verifyValue("smart member reference", val);
+ verifyCount(4, kmemberVal);
+ verifyCount(4, kmember);
+ verifyCount(4, k);
+
+ delete m;
+
+ verifyCount(3, kmember);
+ verifyCount(3, k);
+ }
+ // plain by value
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("plain member value");
+ m.MemberValue = k;
+ string val = k.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, k);
+
+ auto kmember = m.MemberValue;
+ val = kmember.getValue();
+ verifyValue("plain member value", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ delete m;
+
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ // plain by pointer
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("plain member pointer");
+ m.MemberPointer = k;
+ string val = k.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, k);
+
+ auto kmember = m.MemberPointer;
+ val = kmember.getValue();
+ verifyValue("plain member pointer", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ delete m;
+
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+ // plain by reference
+ {
+ auto m = new MemberVariables();
+ auto k = new Klass("plain member reference");
+ m.MemberReference = k;
+ string val = k.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, k);
+
+ auto kmember = m.MemberReference;
+ val = kmember.getValue();
+ verifyValue("plain member reference", val);
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+
+ delete m;
+
+ verifyCount(1, kmember);
+ verifyCount(1, k);
+ }
+
+ // null member variables
+ {
+ auto m = new MemberVariables();
+
+ // shared_ptr by value
+ auto k = m.SmartMemberValue;
+ if (k !is null)
+ throw new Exception("expected null");
+ m.SmartMemberValue = null;
+ k = m.SmartMemberValue;
+ if (k !is null)
+ throw new Exception("expected null");
+ verifyCount(0, k);
+
+ // plain by value
+ enforceThrows( (){ m.MemberValue = null; }, "Failed to catch null pointer");
+ }
+
+ ////////////////////////////////// Global variables ////////////////////////////////////////
+ // smart pointer
+ {
+ auto kglobal = GlobalSmartValue;
+ enforce(kglobal is null, "expected null");
+
+ auto k = new Klass("smart global value");
+ GlobalSmartValue = k;
+ verifyCount(2, k);
+
+ kglobal = GlobalSmartValue;
+ string val = kglobal.getValue();
+ verifyValue("smart global value", val);
+ verifyCount(3, kglobal);
+ verifyCount(3, k);
+ verifyValue("smart global value", GlobalSmartValue.getValue());
+ GlobalSmartValue = null;
+ }
+ // plain value
+ {
+ Klass kglobal;
+
+ auto k = new Klass("global value");
+ GlobalValue = k;
+ verifyCount(1, k);
+
+ kglobal = GlobalValue;
+ string val = kglobal.getValue();
+ verifyValue("global value", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ verifyValue("global value", GlobalValue.getValue());
+
+ enforceThrows((){ GlobalValue = null; }, "Failed to catch null pointer");
+ }
+ // plain pointer
+ {
+ auto kglobal = GlobalPointer;
+ enforce(kglobal is null, "expected null");
+
+ auto k = new Klass("global pointer");
+ GlobalPointer = k;
+ verifyCount(1, k);
+
+ kglobal = GlobalPointer;
+ string val = kglobal.getValue();
+ verifyValue("global pointer", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+ GlobalPointer = null;
+ }
+ // plain reference
+ {
+ Klass kglobal;
+
+ auto k = new Klass("global reference");
+ GlobalReference = k;
+ verifyCount(1, k);
+
+ kglobal = GlobalReference;
+ string val = kglobal.getValue();
+ verifyValue("global reference", val);
+ verifyCount(1, kglobal);
+ verifyCount(1, k);
+
+ enforceThrows((){ GlobalReference = null; }, "Failed to catch null pointer");
+ }
+
+ ////////////////////////////////// Templates ////////////////////////////////////////
+ {
+ auto pid = new PairIntDouble(10, 20.2);
+ enforce(pid.baseVal1 == 20 && pid.baseVal2== 40.4, "Base values wrong");
+ enforce(pid.val1 == 10 && pid.val2 == 20.2, "Derived Values wrong");
+ }
+}
+
+private void verifyValue(string expected, string got) {
+ if (expected != got)
+ throw new Exception("verify value failed. Expected: " ~ expected ~ " Got: " ~ got);
+}
+
+private void verifyCount(int expected, Klass k) {
+ // We deliberately call the use_count(Klass) overload also for objects which
+ // are instances of a subclass of Klass (due to static dispatch); things still
+ // have to work.
+ int got = use_count(k);
+ if (expected != got)
+ throw new Exception("verify use_count failed. Expected: " ~ to!string(expected) ~ " Got: " ~ to!string(got));
+}
+
+private void enforceThrows(void delegate() dg, string errorMessage) {
+ bool hasThrown;
+ try {
+ dg();
+ } catch (Exception) {
+ hasThrown = true;
+ } finally {
+ if (!hasThrown) {
+ throw new Exception(errorMessage);
+ }
+ }
+}
diff --git a/Examples/test-suite/d/li_std_except_runme.1.d b/Examples/test-suite/d/li_std_except_runme.1.d
new file mode 100644
index 000000000..39f3bb202
--- /dev/null
+++ b/Examples/test-suite/d/li_std_except_runme.1.d
@@ -0,0 +1,40 @@
+module li_std_except_runme;
+
+import tango.core.Exception;
+import tango.io.Console;
+import li_std_except.Test;
+
+void main() {
+ with (new Test()) {
+ mixin(test("Exception", "throw_bad_exception"));
+ mixin(test("Exception", "throw_domain_error"));
+ mixin(test("Exception", "throw_exception"));
+ mixin(test("IllegalArgumentException", "throw_invalid_argument"));
+ mixin(test("NoSuchElementException", "throw_length_error"));
+ mixin(test("Exception", "throw_logic_error"));
+ mixin(test("NoSuchElementException", "throw_out_of_range"));
+ mixin(test("Exception", "throw_overflow_error"));
+ mixin(test("Exception", "throw_range_error"));
+ mixin(test("Exception", "throw_runtime_error"));
+ mixin(test("Exception", "throw_underflow_error"));
+ }
+}
+
+char[] test(char[] e, char[] f) {
+ return "if (!works!(" ~ e ~ ")(&" ~ f ~ ")) {\n" ~
+ "throw new Exception(\"" ~ f ~ " failed\");\n" ~
+ "}";
+}
+
+bool works(alias E, F)(F f) {
+ try {
+ try {
+ f();
+ } catch(E) {
+ return true;
+ }
+ } catch(Exception e) {
+ Cerr( "Received wrong exception: " ~ e.classinfo.name ).newline;
+ }
+ return false;
+}
diff --git a/Examples/test-suite/d/li_std_except_runme.2.d b/Examples/test-suite/d/li_std_except_runme.2.d
new file mode 100644
index 000000000..f2b4b672c
--- /dev/null
+++ b/Examples/test-suite/d/li_std_except_runme.2.d
@@ -0,0 +1,34 @@
+module li_std_except_runme;
+
+import std.exception;
+import std.stdio;
+import li_std_except.Test;
+
+void main() {
+ with (new Test()) {
+ enforce(works!(Exception)(&throw_bad_exception));
+ enforce(works!(Exception)(&throw_domain_error));
+ enforce(works!(Exception)(&throw_exception));
+ enforce(works!(Exception)(&throw_invalid_argument));
+ enforce(works!(Exception)(&throw_length_error));
+ enforce(works!(Exception)(&throw_logic_error));
+ enforce(works!(Exception)(&throw_out_of_range));
+ enforce(works!(Exception)(&throw_overflow_error));
+ enforce(works!(Exception)(&throw_range_error));
+ enforce(works!(Exception)(&throw_runtime_error));
+ enforce(works!(Exception)(&throw_underflow_error));
+ }
+}
+
+bool works(alias E, F)(F f) {
+ try {
+ try {
+ f();
+ } catch(E) {
+ return true;
+ }
+ } catch(Exception e) {
+ writefln( "Received wrong exception: %s", e.classinfo.name );
+ }
+ return false;
+}
diff --git a/Examples/test-suite/d/li_std_string_runme.1.d b/Examples/test-suite/d/li_std_string_runme.1.d
new file mode 100644
index 000000000..b5bbb51c0
--- /dev/null
+++ b/Examples/test-suite/d/li_std_string_runme.1.d
@@ -0,0 +1,97 @@
+module li_std_string_runme;
+
+import tango.core.Exception;
+import li_std_string.li_std_string;
+import li_std_string.Structure;
+import li_std_string.SWIGTYPE_p_std__string;
+
+
+void main() {
+ // Checking expected use of %typemap(in) std::string {}
+ test_value("Fee");
+
+ // Checking expected result of %typemap(out) std::string {}
+ if (test_value("Fi") != "Fi")
+ throw new Exception("Test 1 failed");
+
+ // Verify type-checking for %typemap(in) std::string {}
+ try {
+ test_value(null);
+ throw new Exception("Test 2 failed");
+ } catch (IllegalArgumentException) {
+ }
+
+ // Checking expected use of %typemap(in) const std::string & {}
+ test_const_reference("Fo");
+
+ // Checking expected result of %typemap(out) const std::string& {}
+ if (test_const_reference("Fum") != "Fum")
+ throw new Exception("Test 3 failed");
+
+ // Verify type-checking for %typemap(in) const std::string & {}
+ try {
+ test_const_reference(null);
+ throw new Exception("Test 4 failed");
+ } catch (IllegalArgumentException) {
+ }
+
+ // Input and output typemaps for pointers and non-const references to
+ // std::string are *not* supported; the following tests confirm
+ // that none of these cases are slipping through.
+
+ SWIGTYPE_p_std__string stringPtr = null;
+
+ stringPtr = test_pointer_out();
+ test_pointer(stringPtr);
+
+ stringPtr = test_const_pointer_out();
+ test_const_pointer(stringPtr);
+
+ stringPtr = test_reference_out();
+ test_reference(stringPtr);
+
+ // Check throw exception specification
+ try {
+ test_throw();
+ throw new Exception("test 5 failed!");
+ } catch (Exception e) {
+ if (e.msg != "test_throw message")
+ throw new Exception("Test 5 string check: " ~ e.msg);
+ }
+ try {
+ test_const_reference_throw();
+ throw new Exception("test 6 failed!");
+ } catch (Exception e) {
+ if (e.msg != "test_const_reference_throw message")
+ throw new Exception("Test 6 string check: " ~ e.msg);
+ }
+
+ // Global variables.
+ const char[] s = "initial string";
+ if (GlobalString2 != "global string 2")
+ throw new Exception("GlobalString2 test 1");
+ GlobalString2 = s;
+ if (GlobalString2 != s)
+ throw new Exception("GlobalString2 test 2");
+ if (ConstGlobalString != "const global string")
+ throw new Exception("ConstGlobalString test");
+
+ // Member variables.
+ auto myStructure = new Structure();
+ if (myStructure.MemberString2 != "member string 2")
+ throw new Exception("MemberString2 test 1");
+ myStructure.MemberString2 = s;
+ if (myStructure.MemberString2 != s)
+ throw new Exception("MemberString2 test 2");
+ if (myStructure.ConstMemberString != "const member string")
+ throw new Exception("ConstMemberString test");
+
+ // Static member variables.
+ if (Structure.StaticMemberString2 != "static member string 2")
+ throw new Exception("StaticMemberString2 test 1");
+ Structure.StaticMemberString2 = s;
+ if (Structure.StaticMemberString2 != s)
+ throw new Exception("StaticMemberString2 test 2");
+ if (Structure.ConstStaticMemberString != "const static member string")
+ throw new Exception("ConstStaticMemberString test");
+}
diff --git a/Examples/test-suite/d/li_std_string_runme.2.d b/Examples/test-suite/d/li_std_string_runme.2.d
new file mode 100644
index 000000000..395c2f7ff
--- /dev/null
+++ b/Examples/test-suite/d/li_std_string_runme.2.d
@@ -0,0 +1,86 @@
+module li_std_string_runme;
+
+import std.exception;
+import li_std_string.li_std_string;
+import li_std_string.Structure;
+import li_std_string.SWIGTYPE_p_std__string;
+
+void main() {
+ // Checking expected use of %typemap(in) std::string {}
+ test_value("Fee");
+
+ // Checking expected result of %typemap(out) std::string {}
+ enforce(test_value("Fi") == "Fi", "Test 1 failed");
+
+ // Verify type-checking for %typemap(in) std::string {}
+ enforceThrows( (){ test_value(null); }, "Test 2 failed.");
+
+ // Checking expected use of %typemap(in) const std::string & {}
+ test_const_reference("Fo");
+
+ // Checking expected result of %typemap(out) const std::string& {}
+ enforce(test_const_reference("Fum") == "Fum", "Test 3 failed");
+
+ // Verify type-checking for %typemap(in) const std::string & {}
+ enforceThrows( (){ test_const_reference(null); }, "Test 4 failed.");
+
+ // Input and output typemaps for pointers and non-const references to
+ // std::string are *not* supported; the following tests confirm
+ // that none of these cases are slipping through.
+
+ SWIGTYPE_p_std__string stringPtr = null;
+
+ stringPtr = test_pointer_out();
+ test_pointer(stringPtr);
+
+ stringPtr = test_const_pointer_out();
+ test_const_pointer(stringPtr);
+
+ stringPtr = test_reference_out();
+ test_reference(stringPtr);
+
+ // Check throw exception specification
+ try {
+ test_throw();
+ throw new Exception("test 5 failed!");
+ } catch (Exception e) {
+ enforce(e.msg == "test_throw message", "Test 5 string check: " ~ e.msg);
+ }
+ try {
+ test_const_reference_throw();
+ throw new Exception("test 6 failed!");
+ } catch (Exception e) {
+ enforce(e.msg == "test_const_reference_throw message", "Test 6 string check: " ~ e.msg);
+ }
+
+ // Global variables.
+ const string s = "initial string";
+ enforce(GlobalString2 == "global string 2", "GlobalString2 test 1");
+ GlobalString2 = s;
+ enforce(GlobalString2 == s, "GlobalString2 test 2");
+ enforce(ConstGlobalString == "const global string", "ConstGlobalString test");
+
+ // Member variables.
+ auto myStructure = new Structure();
+ enforce(myStructure.MemberString2 == "member string 2", "MemberString2 test 1");
+ myStructure.MemberString2 = s;
+ enforce(myStructure.MemberString2 == s, "MemberString2 test 2");
+ enforce(myStructure.ConstMemberString == "const member string", "ConstMemberString test");
+
+ // Static member variables.
+ enforce(Structure.StaticMemberString2 == "static member string 2", "StaticMemberString2 test 1");
+ Structure.StaticMemberString2 = s;
+ enforce(Structure.StaticMemberString2 == s, "StaticMemberString2 test 2");
+ enforce(Structure.ConstStaticMemberString == "const static member string", "ConstStaticMemberString test");
+}
+
+private void enforceThrows(void delegate() dg, string errorMessage) {
+ bool hasThrown;
+ try {
+ dg();
+ } catch (Exception) {
+ hasThrown = true;
+ } finally {
+ enforce(hasThrown, errorMessage);
+ }
+}
diff --git a/Examples/test-suite/d/li_std_vector_runme.1.d b/Examples/test-suite/d/li_std_vector_runme.1.d
new file mode 100644
index 000000000..895fb450f
--- /dev/null
+++ b/Examples/test-suite/d/li_std_vector_runme.1.d
@@ -0,0 +1,219 @@
+module li_std_vector_runme;
+
+import tango.core.Exception;
+import tango.io.Stdout;
+import Integer = tango.text.convert.Integer;
+import li_std_vector.li_std_vector;
+import li_std_vector.DoubleVector;
+import li_std_vector.IntVector;
+import li_std_vector.IntPtrVector;
+import li_std_vector.IntConstPtrVector;
+import li_std_vector.RealVector;
+import li_std_vector.Struct;
+import li_std_vector.StructVector;
+import li_std_vector.StructPtrVector;
+import li_std_vector.StructConstPtrVector;
+
+const size_t SIZE = 20;
+
+void main() {
+ // Basic functionality tests.
+ {
+ auto vector = new IntVector();
+ for (size_t i = 0; i < SIZE; ++i) {
+ vector ~= i * 10;
+ }
+
+ if (vector.length != SIZE) {
+ throw new Exception("length test failed.");
+ }
+
+ vector[0] = 200;
+ if (vector[0] != 200) {
+ throw new Exception("indexing test failed");
+ }
+ vector[0] = 0 * 10;
+
+ try {
+ vector[vector.length] = 777;
+ throw new Exception("out of range test failed");
+ } catch (NoSuchElementException) {
+ }
+
+ foreach (i, value; vector) {
+ if (value != (i * 10)) {
+ throw new Exception("foreach test failed, i: " ~ Integer.toString(i));
+ }
+ }
+
+ vector.clear();
+ if (vector.size != 0) {
+ throw new Exception("clear test failed");
+ }
+ }
+
+ // Slice tests.
+ {
+ auto dVector = new DoubleVector();
+ for (size_t i = 0; i < SIZE; ++i) {
+ dVector ~= i * 10.1f;
+ }
+
+ double[] dArray = dVector[];
+ foreach (i, value; dArray) {
+ if (dVector[i] != value) {
+ throw new Exception("slice test 1 failed, i: " ~ Integer.toString(i));
+ }
+ }
+
+
+ auto sVector = new StructVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ sVector ~= new Struct(i / 10.0);
+ }
+
+ Struct[] array = sVector[];
+
+ for (size_t i = 0; i < SIZE; i++) {
+ // Make sure that a shallow copy has been made.
+ void* aPtr = Struct.swigGetCPtr(array[i]);
+ void* vPtr = Struct.swigGetCPtr(sVector[i]);
+ if (aPtr != vPtr) {
+ throw new Exception("slice test 2 failed, i: " ~
+ Integer.toString(i));
+ }
+ }
+ }
+
+ // remove() tests.
+ {
+ auto iVector = new IntVector();
+ for (int i = 0; i < SIZE; i++) {
+ iVector ~= i;
+ }
+
+ iVector.remove(iVector.length - 1);
+ iVector.remove(SIZE / 2);
+ iVector.remove(0);
+
+ try {
+ iVector.remove(iVector.size);
+ throw new Exception("remove test failed");
+ } catch (NoSuchElementException) {
+ }
+ }
+
+ // Capacity tests.
+ {
+ auto dv = new DoubleVector(10);
+ if ((dv.capacity != 10) || (dv.length != 0)) {
+ throw new Exception("constructor setting capacity test failed");
+ }
+
+ // TODO: Is this really required (and spec'ed) behavior?
+ dv.capacity = 20;
+ if (dv.capacity != 20) {
+ throw new Exception("capacity test 1 failed");
+ }
+
+ dv ~= 1.11;
+ try {
+ dv.capacity = dv.length - 1;
+ throw new Exception("capacity test 2 failed");
+ } catch (IllegalArgumentException) {
+ }
+ }
+
+ // Test the methods being wrapped.
+ {
+ auto iv = new IntVector();
+ for (int i=0; i<4; i++) {
+ iv ~= i;
+ }
+
+ double x = average(iv);
+ x += average(new IntVector([1, 2, 3, 4]));
+ RealVector rv = half(new RealVector([10.0f, 10.5f, 11.0f, 11.5f]));
+
+ auto dv = new DoubleVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ dv ~= i / 2.0;
+ }
+ halve_in_place(dv);
+
+ RealVector v0 = vecreal(new RealVector());
+ float flo = 123.456f;
+ v0 ~= flo;
+ flo = v0[0];
+
+ IntVector v1 = vecintptr(new IntVector());
+ IntPtrVector v2 = vecintptr(new IntPtrVector());
+ IntConstPtrVector v3 = vecintconstptr(new IntConstPtrVector());
+
+ v1 ~= 123;
+ v2.clear();
+ v3.clear();
+
+ StructVector v4 = vecstruct(new StructVector());
+ StructPtrVector v5 = vecstructptr(new StructPtrVector());
+ StructConstPtrVector v6 = vecstructconstptr(new StructConstPtrVector());
+
+ v4 ~= new Struct(123);
+ v5 ~= new Struct(123);
+ v6 ~= new Struct(123);
+ }
+
+ // Test vectors of pointers.
+ {
+ auto vector = new StructPtrVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ vector ~= new Struct(i / 10.0);
+ }
+
+ Struct[] array = vector[];
+
+ for (size_t i = 0; i < SIZE; i++) {
+ // Make sure that a shallow copy has been made.
+ void* aPtr = Struct.swigGetCPtr(array[i]);
+ void* vPtr = Struct.swigGetCPtr(vector[i]);
+ if (aPtr != vPtr) {
+ throw new Exception("StructPtrVector test 1 failed, i: " ~
+ Integer.toString(i));
+ }
+ }
+ }
+
+ // Test vectors of const pointers.
+ {
+ auto vector = new StructConstPtrVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ vector ~= new Struct(i / 10.0);
+ }
+
+ Struct[] array = vector[];
+
+ for (size_t i = 0; i < SIZE; i++) {
+ // Make sure that a shallow copy has been made.
+ void* aPtr = Struct.swigGetCPtr(array[i]);
+ void* vPtr = Struct.swigGetCPtr(vector[i]);
+ if (aPtr != vPtr) {
+ throw new Exception("StructConstPtrVector test 1 failed, i: " ~
+ Integer.toString(i));
+ }
+ }
+ }
+
+ // Test vectors destroyed via dispose().
+ {
+ {
+ scope vector = new StructVector();
+ vector ~= new Struct(0.0);
+ vector ~= new Struct(11.1);
+ }
+ {
+ scope vector = new DoubleVector();
+ vector ~= 0.0;
+ vector ~= 11.1;
+ }
+ }
+}
diff --git a/Examples/test-suite/d/li_std_vector_runme.2.d b/Examples/test-suite/d/li_std_vector_runme.2.d
new file mode 100644
index 000000000..7860ad6fc
--- /dev/null
+++ b/Examples/test-suite/d/li_std_vector_runme.2.d
@@ -0,0 +1,207 @@
+module li_std_vector_runme;
+
+import std.algorithm;
+import std.array;
+import std.conv;
+import std.exception;
+import std.stdio;
+import li_std_vector.li_std_vector;
+import li_std_vector.DoubleVector;
+import li_std_vector.IntVector;
+import li_std_vector.IntPtrVector;
+import li_std_vector.IntConstPtrVector;
+import li_std_vector.RealVector;
+import li_std_vector.Struct;
+import li_std_vector.StructVector;
+import li_std_vector.StructPtrVector;
+import li_std_vector.StructConstPtrVector;
+
+const size_t SIZE = 20;
+
+void main() {
+ // Basic functionality tests.
+ {
+ auto vector = new IntVector();
+ for (size_t i = 0; i < SIZE; ++i) {
+ vector ~= i * 10;
+ }
+
+ enforce(vector.length == SIZE, "length test failed.");
+
+ vector[0] = 200;
+ enforce(vector[0] == 200, "indexing test failed");
+ vector[0] = 0 * 10;
+
+ enforceThrows((){ vector[vector.length] = 777; }, "out of range test failed" );
+
+ foreach (i, value; vector) {
+ enforce(value == (i * 10), "foreach test failed, i: " ~ to!string(i));
+ }
+
+ enforce(canFind!`a == 0 * 10`(vector[]), "canFind test 1 failed");
+ enforce(canFind!`a == 10 * 10`(vector[]), "canFind test 2 failed");
+ enforce(canFind!`a == 19 * 10`(vector[]), "canFind test 3 failed");
+ enforce(!canFind!`a == 20 * 10`(vector[]), "canFind test 4 failed");
+
+ foreach (i, _; vector) {
+ enforce(indexOf(vector[], i * 10) == i, "indexOf test failed, i: " ~ to!string(i));
+ }
+
+ enforce(indexOf(vector[], 42) == -1, "non-existant item indexOf test failed");
+
+ vector.clear();
+ enforce(vector.length == 0, "clear test failed");
+ }
+
+ // To array conversion tests.
+ {
+ auto dVector = new DoubleVector();
+ for (size_t i = 0; i < SIZE; ++i) {
+ dVector ~= i * 10.1f;
+ }
+
+ double[] dArray = array(dVector[]);
+ foreach (i, value; dArray) {
+ enforce(dVector[i] == value, "slice test 1 failed, i: " ~ to!string(i));
+ }
+
+
+ auto sVector = new StructVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ sVector ~= new Struct(i / 10.0);
+ }
+
+ Struct[] sArray = array(sVector[]);
+
+ for (size_t i = 0; i < SIZE; i++) {
+ // Make sure that a shallow copy has been made.
+ void* aPtr = Struct.swigGetCPtr(sArray[i]);
+ void* vPtr = Struct.swigGetCPtr(sVector[i]);
+ enforce(aPtr == vPtr, "slice test 2 failed, i: " ~ to!string(i));
+ }
+ }
+
+ // remove() tests.
+ {
+ auto iVector = new IntVector();
+ for (int i = 0; i < SIZE; i++) {
+ iVector ~= i;
+ }
+
+ iVector.remove(iVector.length - 1);
+ iVector.remove(SIZE / 2);
+ iVector.remove(0);
+
+ enforceThrows((){ iVector.remove(iVector.length); }, "remove test failed");
+ }
+
+ // Capacity tests.
+ {
+ auto dv = new DoubleVector(10);
+ enforce(dv.capacity == 10, "constructor setting capacity test failed (1)");
+ enforce(dv.length == 0, "constructor setting capacity test failed (1)");
+
+ dv.reserve(20);
+ enforce(dv.capacity == 20, "capacity test failed");
+ }
+
+ // Test the methods being wrapped.
+ {
+ auto iv = new IntVector();
+ for (int i=0; i<4; i++) {
+ iv ~= i;
+ }
+
+ double x = average(iv);
+ x += average(new IntVector([1, 2, 3, 4]));
+ RealVector rv = half(new RealVector([10.0f, 10.5f, 11.0f, 11.5f]));
+
+ auto dv = new DoubleVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ dv ~= i / 2.0;
+ }
+ halve_in_place(dv);
+
+ RealVector v0 = vecreal(new RealVector());
+ float flo = 123.456f;
+ v0 ~= flo;
+ flo = v0[0];
+
+ IntVector v1 = vecintptr(new IntVector());
+ IntPtrVector v2 = vecintptr(new IntPtrVector());
+ IntConstPtrVector v3 = vecintconstptr(new IntConstPtrVector());
+
+ v1 ~= 123;
+ v2.clear();
+ v3.clear();
+
+ StructVector v4 = vecstruct(new StructVector());
+ StructPtrVector v5 = vecstructptr(new StructPtrVector());
+ StructConstPtrVector v6 = vecstructconstptr(new StructConstPtrVector());
+
+ v4 ~= new Struct(123);
+ v5 ~= new Struct(123);
+ v6 ~= new Struct(123);
+ }
+
+ // Test vectors of pointers.
+ {
+ auto vector = new StructPtrVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ vector ~= new Struct(i / 10.0);
+ }
+
+ Struct[] array = array(vector[]);
+
+ for (size_t i = 0; i < SIZE; i++) {
+ // Make sure that a shallow copy has been made.
+ void* aPtr = Struct.swigGetCPtr(array[i]);
+ void* vPtr = Struct.swigGetCPtr(vector[i]);
+ enforce(aPtr == vPtr, "StructConstPtrVector test 1 failed, i: " ~ to!string(i));
+ }
+ }
+
+ // Test vectors of const pointers.
+ {
+ auto vector = new StructConstPtrVector();
+ for (size_t i = 0; i < SIZE; i++) {
+ vector ~= new Struct(i / 10.0);
+ }
+
+ Struct[] array = array(vector[]);
+
+ for (size_t i = 0; i < SIZE; i++) {
+ // Make sure that a shallow copy has been made.
+ void* aPtr = Struct.swigGetCPtr(array[i]);
+ void* vPtr = Struct.swigGetCPtr(vector[i]);
+ enforce(aPtr == vPtr, "StructConstPtrVector test 1 failed, i: " ~ to!string(i));
+ }
+ }
+
+ // Test vectors destroyed via scope.
+ {
+ {
+ scope vector = new StructVector();
+ vector ~= new Struct(0.0);
+ vector ~= new Struct(11.1);
+ }
+ {
+ scope vector = new DoubleVector();
+ vector ~= 0.0;
+ vector ~= 11.1;
+ }
+ }
+}
+
+private void enforceThrows(void delegate() dg, string errorMessage) {
+ bool hasThrown;
+ try {
+ dg();
+ } catch (Exception) {
+ hasThrown = true;
+ } finally {
+ if (!hasThrown) {
+ throw new Exception(errorMessage);
+ }
+ }
+}
diff --git a/Examples/test-suite/d/li_typemaps_runme.1.d b/Examples/test-suite/d/li_typemaps_runme.1.d
new file mode 100644
index 000000000..e37b12bc2
--- /dev/null
+++ b/Examples/test-suite/d/li_typemaps_runme.1.d
@@ -0,0 +1,94 @@
+/// Tests correct handling of a few INPUT/OUTPUT/INOUT-typemapped functions.
+module li_typemaps_runme;
+
+import li_typemaps.li_typemaps;
+
+void main() {
+ // Check double INPUT typemaps
+ if (in_double(22.22) != 22.22) raiseError("in_double");
+ if (inr_double(22.22) != 22.22) raiseError("inr_double");
+
+ // Check double OUTPUT typemaps
+ {
+ double var = 44.44;
+ out_double(22.22, var);
+ if (var != 22.22) raiseError("out_double");
+ }
+ {
+ double var = 44.44;
+ outr_double(22.22, var);
+ if (var != 22.22) raiseError("outr_double");
+ }
+
+ // Check double INOUT typemaps
+ {
+ double var = 44.44;
+ inout_double(var);
+ if (var != 44.44) raiseError("inout_double");
+ }
+ {
+ double var = 44.44;
+ inoutr_double(var);
+ if (var != 44.44) raiseError("inoutr_double");
+ }
+
+ // Check unsigned long long INPUT typemaps
+ if (in_ulonglong(20) != 20) raiseError("in_ulonglong");
+ if (inr_ulonglong(20) != 20) raiseError("inr_ulonglong");
+
+ // Check unsigned long long OUTPUT typemaps
+ {
+ ulong var = 40;
+ out_ulonglong(20, var);
+ if (var != 20) raiseError("out_ulonglong");
+ }
+ {
+ ulong var = 40;
+ outr_ulonglong(20, var);
+ if (var != 20) raiseError("outr_ulonglong");
+ }
+
+ // Check unsigned long long INOUT typemaps
+ {
+ ulong var = 40;
+ inout_ulonglong(var);
+ if (var != 40) raiseError("inout_ulonglong");
+ }
+ {
+ ulong var = 40;
+ inoutr_ulonglong(var);
+ if (var != 40) raiseError("inoutr_ulonglong");
+ }
+
+ // Check unsigned bool INPUT typemaps
+ if (in_bool(false) != false) raiseError("in_bool");
+ if (inr_bool(false) != false) raiseError("inr_bool");
+
+ // Check unsigned bool OUTPUT typemaps
+ {
+ bool var = false;
+ out_bool(true, var);
+ if (var != true) raiseError("out_bool");
+ }
+ {
+ bool var = false;
+ outr_bool(true, var);
+ if (var != true) raiseError("outr_bool");
+ }
+
+ // Check unsigned bool INOUT typemaps
+ {
+ bool var = false;
+ inout_bool(var);
+ if (var != false) raiseError("inout_bool");
+ }
+ {
+ bool var = false;
+ inoutr_bool(var);
+ if (var != false) raiseError("inoutr_bool");
+ }
+}
+
+void raiseError(char[] funcName) {
+ throw new Exception("Test FAILED for function " ~ funcName);
+}
diff --git a/Examples/test-suite/d/li_typemaps_runme.2.d b/Examples/test-suite/d/li_typemaps_runme.2.d
new file mode 100644
index 000000000..de515b0ff
--- /dev/null
+++ b/Examples/test-suite/d/li_typemaps_runme.2.d
@@ -0,0 +1,91 @@
+/// Tests correct handling of a few INPUT/OUTPUT/INOUT-typemapped functions.
+module li_typemaps_runme;
+
+import std.exception;
+import li_typemaps.li_typemaps;
+
+void main() {
+ // Check double INPUT typemaps
+ enforce(in_double(22.22) == 22.22, "in_double");
+ enforce(inr_double(22.22) == 22.22, "inr_double");
+
+ // Check double OUTPUT typemaps
+ {
+ double var = 44.44;
+ out_double(22.22, var);
+ enforce(var == 22.22, "out_double");
+ }
+ {
+ double var = 44.44;
+ outr_double(22.22, var);
+ enforce(var == 22.22, "outr_double");
+ }
+
+ // Check double INOUT typemaps
+ {
+ double var = 44.44;
+ inout_double(var);
+ enforce(var == 44.44, "inout_double");
+ }
+ {
+ double var = 44.44;
+ inoutr_double(var);
+ enforce(var == 44.44, "inoutr_double");
+ }
+
+ // Check unsigned long long INPUT typemaps
+ enforce(in_ulonglong(20) == 20, "in_ulonglong");
+ enforce(inr_ulonglong(20) == 20, "inr_ulonglong");
+
+ // Check unsigned long long OUTPUT typemaps
+ {
+ ulong var = 40;
+ out_ulonglong(20, var);
+ enforce(var == 20, "out_ulonglong");
+ }
+ {
+ ulong var = 40;
+ outr_ulonglong(20, var);
+ enforce(var == 20, "outr_ulonglong");
+ }
+
+ // Check unsigned long long INOUT typemaps
+ {
+ ulong var = 40;
+ inout_ulonglong(var);
+ enforce(var == 40, "inout_ulonglong");
+ }
+ {
+ ulong var = 40;
+ inoutr_ulonglong(var);
+ enforce(var == 40, "inoutr_ulonglong");
+ }
+
+ // Check unsigned bool INPUT typemaps
+ enforce(in_bool(false) == false, "in_bool");
+ enforce(inr_bool(false) == false, "inr_bool");
+
+ // Check unsigned bool OUTPUT typemaps
+ {
+ bool var = false;
+ out_bool(true, var);
+ enforce(var == true, "out_bool");
+ }
+ {
+ bool var = false;
+ outr_bool(true, var);
+ enforce(var == true, "outr_bool");
+ }
+
+ // Check unsigned bool INOUT typemaps
+ {
+ bool var = false;
+ inout_bool(var);
+ enforce(var == false, "inout_bool");
+ }
+ {
+ bool var = false;
+ inoutr_bool(var);
+ enforce(var == false, "inoutr_bool");
+ }
+}
diff --git a/Examples/test-suite/d/long_long_runme.1.d b/Examples/test-suite/d/long_long_runme.1.d
new file mode 100644
index 000000000..a6d5448bc
--- /dev/null
+++ b/Examples/test-suite/d/long_long_runme.1.d
@@ -0,0 +1,35 @@
+// Checks if the long long and unsigned long long types work.
+module long_long_runme;
+
+import Integer = tango.text.convert.Integer;
+import long_long.long_long;
+
+void main() {
+ check_ll(0L);
+ check_ll(0x7FFFFFFFFFFFFFFFL);
+ check_ll(-10L);
+
+ check_ull(0u);
+ check_ull(127u);
+ check_ull(128u);
+ check_ull(9223372036854775807u); //0x7FFFFFFFFFFFFFFFL
+ check_ull(18446744073709551615u); //0xFFFFFFFFFFFFFFFFL
+}
+
+void check_ll(long value) {
+ ll = value;
+ long value_check = ll;
+ if (value != value_check) {
+ throw new Exception("Runtime test using long long failed: expected: " ~
+ Integer.toString(value) ~ ", got: " ~ Integer.toString(value_check));
+ }
+}
+
+void check_ull(ulong value) {
+ ull = value;
+ ulong value_check = ull;
+ if (value != value_check) {
+ throw new Exception( "Runtime test using unsigned long long failed: expected: " ~
+ Integer.toString(value) ~ ", ll_check=" ~ Integer.toString(value_check));
+ }
+}
diff --git a/Examples/test-suite/d/long_long_runme.2.d b/Examples/test-suite/d/long_long_runme.2.d
new file mode 100644
index 000000000..a082171b4
--- /dev/null
+++ b/Examples/test-suite/d/long_long_runme.2.d
@@ -0,0 +1,32 @@
+// Checks if the long long and unsigned long long types work.
+module long_long_runme;
+
+import std.conv;
+import std.exception;
+import long_long.long_long;
+
+void main() {
+ check_ll(0L);
+ check_ll(0x7FFFFFFFFFFFFFFFL);
+ check_ll(-10L);
+
+ check_ull(0u);
+ check_ull(127u);
+ check_ull(128u);
+ check_ull(9223372036854775807u); //0x7FFFFFFFFFFFFFFFL
+ check_ull(18446744073709551615u); //0xFFFFFFFFFFFFFFFFL
+}
+
+void check_ll(long value) {
+ ll = value;
+ long value_check = ll;
+ enforce(value == value_check, "Runtime test using long long failed: expected: " ~
+ to!string(value) ~ ", got: " ~ to!string(value_check));
+}
+
+void check_ull(ulong value) {
+ ull = value;
+ ulong value_check = ull;
+ enforce(value == value_check, "Runtime test using unsigned long long failed: expected: " ~
+ to!string(value) ~ ", ll_check=" ~ to!string(value_check));
+}
diff --git a/Examples/test-suite/d/member_pointer_runme.1.d b/Examples/test-suite/d/member_pointer_runme.1.d
new file mode 100644
index 000000000..c1f8d33b8
--- /dev/null
+++ b/Examples/test-suite/d/member_pointer_runme.1.d
@@ -0,0 +1,43 @@
+module member_pointer_runme;
+
+import Float = tango.text.convert.Float;
+import member_pointer.member_pointer;
+import member_pointer.Square;
+import member_pointer.SWIGTYPE_m_Shape__f_void__double;
+
+void main() {
+ auto s = new Square(10);
+
+ // Do some calculations
+ auto area_pt = areapt();
+ auto perim_pt = perimeterpt();
+ check("Square area ", 100.0, do_op(s, area_pt));
+ check("Square perim", 40.0, do_op(s, perim_pt));
+
+ SWIGTYPE_m_Shape__f_void__double memberPtr = null;
+ memberPtr = areavar;
+ memberPtr = perimetervar;
+
+ // Try the variables
+ check("Square area ", 100.0, do_op(s, areavar));
+ check("Square perim", 40.0, do_op(s, perimetervar));
+
+ // Modify one of the variables
+ areavar = perim_pt;
+ check("Square perimeter", 40.0, do_op(s,areavar));
+
+ // Try the constants
+ memberPtr = AREAPT;
+ memberPtr = PERIMPT;
+ memberPtr = NULLPT;
+
+ check("Square area", 100.0, do_op(s, AREAPT));
+ check("Square perim", 40.0, do_op(s, PERIMPT));
+}
+
+void check(char[] what, double expected, double actual) {
+ if (expected != actual) {
+ throw new Exception("Failed: " ~ what ~ ": expected "
+ ~ Float.toString(expected) ~ ", but got " ~ Float.toString(actual));
+ }
+}
diff --git a/Examples/test-suite/d/member_pointer_runme.2.d b/Examples/test-suite/d/member_pointer_runme.2.d
new file mode 100644
index 000000000..a5c293cd0
--- /dev/null
+++ b/Examples/test-suite/d/member_pointer_runme.2.d
@@ -0,0 +1,42 @@
+module member_pointer_runme;
+
+import std.conv;
+import std.exception;
+import member_pointer.member_pointer;
+import member_pointer.Square;
+import member_pointer.SWIGTYPE_m_Shape__f_void__double;
+
+void main() {
+ auto s = new Square(10);
+
+ // Do some calculations
+ auto area_pt = areapt();
+ auto perim_pt = perimeterpt();
+ check("Square area", 100.0, do_op(s, area_pt));
+ check("Square perim", 40.0, do_op(s, perim_pt));
+
+ SWIGTYPE_m_Shape__f_void__double memberPtr = null;
+ memberPtr = areavar;
+ memberPtr = perimetervar;
+
+ // Try the variables
+ check("Square area", 100.0, do_op(s, areavar));
+ check("Square perim", 40.0, do_op(s, perimetervar));
+
+ // Modify one of the variables
+ areavar = perim_pt;
+ check("Square perimeter", 40.0, do_op(s,areavar));
+
+ // Try the constants
+ memberPtr = AREAPT;
+ memberPtr = PERIMPT;
+ memberPtr = NULLPT;
+
+ check("Square area", 100.0, do_op(s, AREAPT));
+ check("Square perim", 40.0, do_op(s, PERIMPT));
+}
+
+void check(string what, double expected, double actual) {
+ enforce(expected == actual, "Failed: " ~ what ~ ": expected " ~
+ to!string(expected) ~ ", but got " ~ to!string(actual));
+}
diff --git a/Examples/test-suite/d/operator_overload_runme.1.d b/Examples/test-suite/d/operator_overload_runme.1.d
new file mode 100644
index 000000000..18a24b91f
--- /dev/null
+++ b/Examples/test-suite/d/operator_overload_runme.1.d
@@ -0,0 +1,89 @@
+module operator_overload_runme;
+
+import operator_overload.Op;
+
+void main() {
+ // Invoke the C++ sanity check first.
+ Op.sanity_check();
+
+ auto a = new Op();
+ auto b = new Op(5);
+ auto c = b;
+ auto d = new Op(2);
+ auto dd = d;
+
+ // test equality
+ assert(a != b);
+ assert(b == c);
+ assert(a != d);
+ assert(d == dd);
+
+ // test <
+ assert(a < b);
+ assert(a <= b);
+ assert(b <= c);
+ assert(b >= c);
+ assert(b > d);
+ assert(b >= d);
+
+ // test +=
+ auto e = new Op(3);
+ e += d;
+ assert(e == b);
+ e -= c;
+ assert(e == a);
+ e = new Op(1);
+ e *= b;
+ assert(e == c);
+ e /= d;
+ assert(e == d);
+ e %= c;
+ assert(e == d);
+
+ // test +
+ auto f = new Op(1);
+ auto g = new Op(1);
+ assert(f + g == new Op(2));
+ assert(f - g == new Op(0));
+ assert(f * g == new Op(1));
+ assert(f / g == new Op(1));
+ assert(f % g == new Op(0));
+
+ // test unary operators
+ assert(-a == a);
+ assert(-b == new Op(-5));
+ // The unary ! operator is not overloadable in D1.
+
+ // test []
+ auto h = new Op(3);
+ assert(h[0]==3);
+ assert(h[1]==0);
+ // Generation of opIndexAssign is not supported yet.
+
+ // test ()
+ auto i = new Op(3);
+ assert(i()==3);
+ assert(i(1)==4);
+ assert(i(1,2)==6);
+
+ // test ++ and --
+ auto j = new Op(100);
+ int original = j.i;
+ {
+ Op newOp = j++;
+ int newInt = original++;
+ assert(j.i == original);
+ assert(newOp.i == newInt);
+ }
+ {
+ Op newOp = j--;
+ int newInt = original--;
+ assert(j.i == original);
+ assert(newOp.i == newInt);
+ }
+ // Prefix increment/decrement operators are lowered to (foo +=/-= 1) in D1,
+ // but the test case does not define an integer overload for operator +=
+ // respectively -=.
+
+ // Implicit casting is not overloadable in D1.
+} \ No newline at end of file
diff --git a/Examples/test-suite/d/operator_overload_runme.2.d b/Examples/test-suite/d/operator_overload_runme.2.d
new file mode 100644
index 000000000..2ff61cd56
--- /dev/null
+++ b/Examples/test-suite/d/operator_overload_runme.2.d
@@ -0,0 +1,91 @@
+module operator_overload_runme;
+
+import operator_overload.Op;
+
+void main() {
+ // Invoke the C++ sanity check first.
+ Op.sanity_check();
+
+ auto a = new Op();
+ auto b = new Op(5);
+ auto c = b;
+ auto d = new Op(2);
+ auto dd = d;
+
+ // test equality
+ assert(a != b);
+ assert(b == c);
+ assert(a != d);
+ assert(d == dd);
+
+ // test <
+ assert(a < b);
+ assert(a <= b);
+ assert(b <= c);
+ assert(b >= c);
+ assert(b > d);
+ assert(b >= d);
+
+ // test +=
+ auto e = new Op(3);
+ e += d;
+ assert(e == b);
+ e -= c;
+ assert(e == a);
+ e = new Op(1);
+ e *= b;
+ assert(e == c);
+ e /= d;
+ assert(e == d);
+ e %= c;
+ assert(e == d);
+
+ // test +
+ auto f = new Op(1);
+ auto g = new Op(1);
+ assert(f + g == new Op(2));
+ assert(f - g == new Op(0));
+ assert(f * g == new Op(1));
+ assert(f / g == new Op(1));
+ assert(f % g == new Op(0));
+
+ // test unary operators
+ assert(-a == a);
+ assert(-b == new Op(-5));
+
+ // Unfortunaly, there is no way to override conversion to boolean for
+ // classes in D, opCast!("bool") is only used for structs.
+
+ // test []
+ auto h = new Op(3);
+ assert(h[0]==3);
+ assert(h[1]==0);
+ // Generation of opIndexAssign is not supported yet.
+
+ // test ()
+ auto i = new Op(3);
+ assert(i()==3);
+ assert(i(1)==4);
+ assert(i(1,2)==6);
+
+ // test ++ and --
+ auto j = new Op(100);
+ int original = j.i;
+ // The prefix increment/decrement operators are not directly overloadable in
+ // D2, and because the proxy classes are reference types, the lowering
+ // yields the same value as the postfix operators.
+ {
+ Op newOp = ++j;
+ int newInt = ++original;
+ assert(j.i == original);
+ assert(newOp.i == newInt);
+ }
+ {
+ Op newOp = --j;
+ int newInt = --original;
+ assert(j.i == original);
+ assert(newOp.i == newInt);
+ }
+
+ // Implicit casting via alias this is not supported yet.
+} \ No newline at end of file
diff --git a/Examples/test-suite/d/overload_complicated_runme.1.d b/Examples/test-suite/d/overload_complicated_runme.1.d
new file mode 100644
index 000000000..03d1bf1e6
--- /dev/null
+++ b/Examples/test-suite/d/overload_complicated_runme.1.d
@@ -0,0 +1,50 @@
+module overload_complicated_runme;
+
+import overload_complicated;
+
+void main() {
+ SWIGTYPE_p_int pInt = null;
+
+ // Check the correct constructors are available
+ Pop p = new Pop(pInt);
+
+ p = new Pop(pInt, false);
+
+ // Check overloaded in const only and pointers/references which target languages cannot disambiguate
+ if (p.hip(false) != 701)
+ throw new Exception("Test 1 failed");
+
+ if (p.hip(pInt) != 702)
+ throw new Exception("Test 2 failed");
+
+ // Reverse the order for the above
+ if (p.hop(pInt) != 805)
+ throw new Exception("Test 3 failed");
+
+ if (p.hop(false) != 801)
+ throw new Exception("Test 4 failed");
+
+ // Few more variations and order shuffled
+ if (p.pop(false) != 901)
+ throw new Exception("Test 5 failed");
+
+ if (p.pop(pInt) != 902)
+ throw new Exception("Test 6 failed");
+
+ if (p.pop() != 905)
+ throw new Exception("Test 7 failed");
+
+ // Overload on const only
+ if (p.bop(pInt) != 1001)
+ throw new Exception("Test 8 failed");
+
+ if (p.bip(pInt) != 2001)
+ throw new Exception("Test 9 failed");
+
+ // Globals
+ if (muzak(false) != 3001)
+ throw new Exception("Test 10 failed");
+
+ if (muzak(pInt) != 3002)
+ throw new Exception("Test 11 failed");
+}
diff --git a/Examples/test-suite/d/overload_complicated_runme.2.d b/Examples/test-suite/d/overload_complicated_runme.2.d
new file mode 100644
index 000000000..9d03ec5e6
--- /dev/null
+++ b/Examples/test-suite/d/overload_complicated_runme.2.d
@@ -0,0 +1,34 @@
+module overload_complicated_runme;
+
+import std.exception;
+import overload_complicated.overload_complicated;
+import overload_complicated.Pop;
+
+void main() {
+ int* pInt = new int;
+
+ // Check the correct constructors are available
+ auto p = new Pop(pInt);
+ p = new Pop(pInt, false);
+
+ // Check overloaded in const only and pointers/references which target languages cannot disambiguate
+ enforce(p.hip(false) == 701, "Test 1 failed");
+ enforce(p.hip(pInt) == 702, "Test 2 failed");
+
+ // Reverse the order for the above
+ enforce(p.hop(pInt) == 805, "Test 3 failed");
+ enforce(p.hop(false) == 801, "Test 4 failed");
+
+ // Few more variations and order shuffled
+ enforce(p.pop(false) == 901, "Test 5 failed");
+ enforce(p.pop(pInt) == 902, "Test 6 failed");
+ enforce(p.pop() == 905, "Test 7 failed");
+
+ // Overload on const only
+ enforce(p.bop(pInt) == 1001, "Test 8 failed");
+ enforce(p.bip(pInt) == 2001, "Test 9 failed");
+
+ // Globals
+ enforce(muzak(false) == 3001, "Test 10 failed");
+ enforce(muzak(pInt) == 3002, "Test 11 failed");
+}
diff --git a/Examples/test-suite/d/overload_template_runme.1.d b/Examples/test-suite/d/overload_template_runme.1.d
new file mode 100644
index 000000000..a1fe8012f
--- /dev/null
+++ b/Examples/test-suite/d/overload_template_runme.1.d
@@ -0,0 +1,146 @@
+module overload_template_runme;
+
+import overload_template.overload_template;
+import overload_template.Klass;
+
+void main() {
+ int f = foo();
+
+ f += maximum(3,4);
+ double b = maximum(3.4,5.2);
+ b++; // warning suppression
+
+ // mix 1
+ if (mix1("hi") != 101)
+ throw new Exception ("mix1(const char*)");
+
+ if (mix1(1.0, 1.0) != 102)
+ throw new Exception ("mix1(double, const double &)");
+
+ if (mix1(1.0) != 103)
+ throw new Exception ("mix1(double)");
+
+ // mix 2
+ if (mix2("hi") != 101)
+ throw new Exception ("mix2(const char*)");
+
+ if (mix2(1.0, 1.0) != 102)
+ throw new Exception ("mix2(double, const double &)");
+
+ if (mix2(1.0) != 103)
+ throw new Exception ("mix2(double)");
+
+ // mix 3
+ if (mix3("hi") != 101)
+ throw new Exception ("mix3(const char*)");
+
+ if (mix3(1.0, 1.0) != 102)
+ throw new Exception ("mix3(double, const double &)");
+
+ if (mix3(1.0) != 103)
+ throw new Exception ("mix3(double)");
+
+ // Combination 1
+ if (overtparams1(100) != 10)
+ throw new Exception ("overtparams1(int)");
+
+ if (overtparams1(100.0, 100) != 20)
+ throw new Exception ("overtparams1(double, int)");
+
+ // Combination 2
+ if (overtparams2(100.0, 100) != 40)
+ throw new Exception ("overtparams2(double, int)");
+
+ // Combination 3
+ if (overloaded() != 60)
+ throw new Exception ("overloaded()");
+
+ if (overloaded(100.0, 100) != 70)
+ throw new Exception ("overloaded(double, int)");
+
+ // Combination 4
+ if (overloadedagain("hello") != 80)
+ throw new Exception ("overloadedagain(const char *)");
+
+ if (overloadedagain() != 90)
+ throw new Exception ("overloadedagain(double)");
+
+ // specializations
+ if (specialization(10) != 202)
+ throw new Exception ("specialization(int)");
+
+ if (specialization(10.0) != 203)
+ throw new Exception ("specialization(double)");
+
+ if (specialization(10, 10) != 204)
+ throw new Exception ("specialization(int, int)");
+
+ if (specialization(10.0, 10.0) != 205)
+ throw new Exception ("specialization(double, double)");
+
+ if (specialization("hi", "hi") != 201)
+ throw new Exception ("specialization(const char *, const char *)");
+
+ // simple specialization
+ xyz();
+ xyz_int();
+ xyz_double();
+
+ // a bit of everything
+ if (overload("hi") != 0)
+ throw new Exception ("overload()");
+
+ if (overload(1) != 10)
+ throw new Exception ("overload(int t)");
+
+ if (overload(1, 1) != 20)
+ throw new Exception ("overload(int t, const int &)");
+
+ if (overload(1, "hello") != 30)
+ throw new Exception ("overload(int t, const char *)");
+
+ auto k = new Klass();
+ if (overload(k) != 10)
+ throw new Exception ("overload(Klass t)");
+
+ if (overload(k, k) != 20)
+ throw new Exception ("overload(Klass t, const Klass &)");
+
+ if (overload(k, "hello") != 30)
+ throw new Exception ("overload(Klass t, const char *)");
+
+ if (overload(10.0, "hi") != 40)
+ throw new Exception ("overload(double t, const char *)");
+
+ if (overload() != 50)
+ throw new Exception ("overload(const char *)");
+
+
+ // everything put in a namespace
+ if (nsoverload("hi") != 1000)
+ throw new Exception ("nsoverload()");
+
+ if (nsoverload(1) != 1010)
+ throw new Exception ("nsoverload(int t)");
+
+ if (nsoverload(1, 1) != 1020)
+ throw new Exception ("nsoverload(int t, const int &)");
+
+ if (nsoverload(1, "hello") != 1030)
+ throw new Exception ("nsoverload(int t, const char *)");
+
+ if (nsoverload(k) != 1010)
+ throw new Exception ("nsoverload(Klass t)");
+
+ if (nsoverload(k, k) != 1020)
+ throw new Exception ("nsoverload(Klass t, const Klass &)");
+
+ if (nsoverload(k, "hello") != 1030)
+ throw new Exception ("nsoverload(Klass t, const char *)");
+
+ if (nsoverload(10.0, "hi") != 1040)
+ throw new Exception ("nsoverload(double t, const char *)");
+
+ if (nsoverload() != 1050)
+ throw new Exception ("nsoverload(const char *)");
+}
diff --git a/Examples/test-suite/d/overload_template_runme.2.d b/Examples/test-suite/d/overload_template_runme.2.d
new file mode 100644
index 000000000..9fe6eb2cf
--- /dev/null
+++ b/Examples/test-suite/d/overload_template_runme.2.d
@@ -0,0 +1,80 @@
+module overload_template_runme;
+
+import std.exception;
+import overload_template.overload_template;
+import overload_template.Klass;
+
+void main() {
+ int f = foo();
+
+ f += maximum(3,4);
+ double b = maximum(3.4,5.2);
+ b++; // warning suppression
+
+ // mix 1
+ enforce(mix1("hi") == 101, "mix1(const char*)");
+ enforce(mix1(1.0, 1.0) == 102, "mix1(double, const double &)");
+ enforce(mix1(1.0) == 103, "mix1(double)");
+
+ // mix 2
+ enforce(mix2("hi") == 101, "mix2(const char*)");
+ enforce(mix2(1.0, 1.0) == 102, "mix2(double, const double &)");
+ enforce(mix2(1.0) == 103, "mix2(double)");
+
+ // mix 3
+ enforce(mix3("hi") == 101, "mix3(const char*)");
+ enforce(mix3(1.0, 1.0) == 102, "mix3(double, const double &)");
+ enforce(mix3(1.0) == 103, "mix3(double)");
+
+ // Combination 1
+ enforce(overtparams1(100) == 10, "overtparams1(int)");
+ enforce(overtparams1(100.0, 100) == 20, "overtparams1(double, int)");
+
+ // Combination 2
+ enforce(overtparams2(100.0, 100) == 40, "overtparams2(double, int)");
+
+ // Combination 3
+ enforce(overloaded() == 60, "overloaded()");
+ enforce(overloaded(100.0, 100) == 70, "overloaded(double, int)");
+
+ // Combination 4
+ enforce(overloadedagain("hello") == 80, "overloadedagain(const char *)");
+ enforce(overloadedagain() == 90, "overloadedagain(double)");
+
+ // specializations
+ enforce(specialization(10) == 202, "specialization(int)");
+ enforce(specialization(10.0) == 203, "specialization(double)");
+ enforce(specialization(10, 10) == 204, "specialization(int, int)");
+ enforce(specialization(10.0, 10.0) == 205, "specialization(double, double)");
+ enforce(specialization("hi", "hi") == 201, "specialization(const char *, const char *)");
+
+ // simple specialization
+ xyz();
+ xyz_int();
+ xyz_double();
+
+ // a bit of everything
+ enforce(overload("hi") == 0, "overload()");
+ enforce(overload(1) == 10, "overload(int t)");
+ enforce(overload(1, 1) == 20, "overload(int t, const int &)");
+ enforce(overload(1, "hello") == 30, "overload(int t, const char *)");
+
+ auto k = new Klass();
+ enforce(overload(k) == 10, "overload(Klass t)");
+ enforce(overload(k, k) == 20, "overload(Klass t, const Klass &)");
+ enforce(overload(k, "hello") == 30, "overload(Klass t, const char *)");
+ enforce(overload(10.0, "hi") == 40, "overload(double t, const char *)");
+ enforce(overload() == 50, "overload(const char *)");
+
+
+ // everything put in a namespace
+ enforce(nsoverload("hi") == 1000, "nsoverload()");
+ enforce(nsoverload(1) == 1010, "nsoverload(int t)");
+ enforce(nsoverload(1, 1) == 1020, "nsoverload(int t, const int &)");
+ enforce(nsoverload(1, "hello") == 1030, "nsoverload(int t, const char *)");
+ enforce(nsoverload(k) == 1010, "nsoverload(Klass t)");
+ enforce(nsoverload(k, k) == 1020, "nsoverload(Klass t, const Klass &)");
+ enforce(nsoverload(k, "hello") == 1030, "nsoverload(Klass t, const char *)");
+ enforce(nsoverload(10.0, "hi") == 1040, "nsoverload(double t, const char *)");
+ enforce(nsoverload() == 1050, "nsoverload(const char *)");
+}
diff --git a/Examples/test-suite/d/pointer_reference_runme.1.d b/Examples/test-suite/d/pointer_reference_runme.1.d
new file mode 100644
index 000000000..c593b939c
--- /dev/null
+++ b/Examples/test-suite/d/pointer_reference_runme.1.d
@@ -0,0 +1,13 @@
+module pointer_reference_runme;
+
+import pointer_reference.pointer_reference;
+import pointer_reference.Struct;
+
+void main() {
+ Struct s = get();
+ if (s.value != 10) throw new Exception("get test failed");
+
+ Struct ss = new Struct(20);
+ set(ss);
+ if (Struct.instance.value != 20) throw new Exception("set test failed");
+}
diff --git a/Examples/test-suite/d/pointer_reference_runme.2.d b/Examples/test-suite/d/pointer_reference_runme.2.d
new file mode 100644
index 000000000..8f287dfbd
--- /dev/null
+++ b/Examples/test-suite/d/pointer_reference_runme.2.d
@@ -0,0 +1,14 @@
+module pointer_reference_runme;
+
+import std.exception;
+import pointer_reference.pointer_reference;
+import pointer_reference.Struct;
+
+void main() {
+ Struct s = get();
+ enforce(s.value == 10, "get test failed");
+
+ auto ss = new Struct(20);
+ set(ss);
+ enforce(Struct.instance.value == 20, "set test failed");
+}
diff --git a/Examples/test-suite/d/preproc_constants_c_runme.1.d b/Examples/test-suite/d/preproc_constants_c_runme.1.d
new file mode 100644
index 000000000..f25bbfdee
--- /dev/null
+++ b/Examples/test-suite/d/preproc_constants_c_runme.1.d
@@ -0,0 +1,63 @@
+module preproc_constants_c_runme;
+
+import preproc_constants_c.preproc_constants_c;
+
+// Same as preproc_constants.i testcase, but bool types are int instead.
+void main() {
+ static assert(is(int == typeof(CONST_INT1())));
+ static assert(is(int == typeof(CONST_INT2())));
+ static assert(is(uint == typeof(CONST_UINT1())));
+ static assert(is(uint == typeof(CONST_UINT2())));
+ static assert(is(uint == typeof(CONST_UINT3())));
+ static assert(is(uint == typeof(CONST_UINT4())));
+ static assert(is(int == typeof(CONST_LONG1())));
+ static assert(is(int == typeof(CONST_LONG2())));
+ static assert(is(int == typeof(CONST_LONG3())));
+ static assert(is(int == typeof(CONST_LONG4())));
+ static assert(is(long == typeof(CONST_LLONG1())));
+ static assert(is(long == typeof(CONST_LLONG2())));
+ static assert(is(long == typeof(CONST_LLONG3())));
+ static assert(is(long == typeof(CONST_LLONG4())));
+ static assert(is(ulong == typeof(CONST_ULLONG1())));
+ static assert(is(ulong == typeof(CONST_ULLONG2())));
+ static assert(is(ulong == typeof(CONST_ULLONG3())));
+ static assert(is(ulong == typeof(CONST_ULLONG4())));
+ static assert(is(double == typeof(CONST_DOUBLE1())));
+ static assert(is(double == typeof(CONST_DOUBLE2())));
+ static assert(is(double == typeof(CONST_DOUBLE3())));
+ static assert(is(double == typeof(CONST_DOUBLE4())));
+ static assert(is(double == typeof(CONST_DOUBLE5())));
+ static assert(is(double == typeof(CONST_DOUBLE6())));
+ static assert(is(int == typeof(CONST_BOOL1())));
+ static assert(is(int == typeof(CONST_BOOL2())));
+ static assert(is(char == typeof(CONST_CHAR())));
+ static assert(is(char[] == typeof(CONST_STRING1())));
+ static assert(is(char[] == typeof(CONST_STRING2())));
+
+ static assert(is(int == typeof(INT_AND_BOOL())));
+// static assert(is(int == typeof(INT_AND_CHAR())));
+ static assert(is(int == typeof(INT_AND_INT())));
+ static assert(is(uint == typeof(INT_AND_UINT())));
+ static assert(is(int == typeof(INT_AND_LONG())));
+ static assert(is(uint == typeof(INT_AND_ULONG())));
+ static assert(is(long == typeof(INT_AND_LLONG())));
+ static assert(is(ulong == typeof(INT_AND_ULLONG())));
+ static assert(is(int == typeof(BOOL_AND_BOOL())));
+
+ static assert(is(int == typeof(EXPR_MULTIPLY())));
+ static assert(is(int == typeof(EXPR_DIVIDE())));
+ static assert(is(int == typeof(EXPR_PLUS())));
+ static assert(is(int == typeof(EXPR_MINUS())));
+ static assert(is(int == typeof(EXPR_LSHIFT())));
+ static assert(is(int == typeof(EXPR_RSHIFT())));
+ static assert(is(int == typeof(EXPR_LTE())));
+ static assert(is(int == typeof(EXPR_GTE())));
+ static assert(is(int == typeof(EXPR_INEQUALITY())));
+ static assert(is(int == typeof(EXPR_EQUALITY())));
+ static assert(is(int == typeof(EXPR_AND())));
+ static assert(is(int == typeof(EXPR_XOR())));
+ static assert(is(int == typeof(EXPR_OR())));
+ static assert(is(int == typeof(EXPR_LAND())));
+ static assert(is(int == typeof(EXPR_LOR())));
+ static assert(is(double == typeof(EXPR_CONDITIONAL())));
+}
diff --git a/Examples/test-suite/d/preproc_constants_c_runme.2.d b/Examples/test-suite/d/preproc_constants_c_runme.2.d
new file mode 100644
index 000000000..07d6ac53d
--- /dev/null
+++ b/Examples/test-suite/d/preproc_constants_c_runme.2.d
@@ -0,0 +1,63 @@
+module preproc_constants_c_runme;
+
+import preproc_constants_c.preproc_constants_c;
+
+// Same as preproc_constants.i testcase, but bool types are int instead.
+void main() {
+ static assert(is(int == typeof(CONST_INT1())));
+ static assert(is(int == typeof(CONST_INT2())));
+ static assert(is(uint == typeof(CONST_UINT1())));
+ static assert(is(uint == typeof(CONST_UINT2())));
+ static assert(is(uint == typeof(CONST_UINT3())));
+ static assert(is(uint == typeof(CONST_UINT4())));
+ static assert(is(int == typeof(CONST_LONG1())));
+ static assert(is(int == typeof(CONST_LONG2())));
+ static assert(is(int == typeof(CONST_LONG3())));
+ static assert(is(int == typeof(CONST_LONG4())));
+ static assert(is(long == typeof(CONST_LLONG1())));
+ static assert(is(long == typeof(CONST_LLONG2())));
+ static assert(is(long == typeof(CONST_LLONG3())));
+ static assert(is(long == typeof(CONST_LLONG4())));
+ static assert(is(ulong == typeof(CONST_ULLONG1())));
+ static assert(is(ulong == typeof(CONST_ULLONG2())));
+ static assert(is(ulong == typeof(CONST_ULLONG3())));
+ static assert(is(ulong == typeof(CONST_ULLONG4())));
+ static assert(is(double == typeof(CONST_DOUBLE1())));
+ static assert(is(double == typeof(CONST_DOUBLE2())));
+ static assert(is(double == typeof(CONST_DOUBLE3())));
+ static assert(is(double == typeof(CONST_DOUBLE4())));
+ static assert(is(double == typeof(CONST_DOUBLE5())));
+ static assert(is(double == typeof(CONST_DOUBLE6())));
+ static assert(is(int == typeof(CONST_BOOL1())));
+ static assert(is(int == typeof(CONST_BOOL2())));
+ static assert(is(char == typeof(CONST_CHAR())));
+ static assert(is(string == typeof(CONST_STRING1())));
+ static assert(is(string == typeof(CONST_STRING2())));
+
+ static assert(is(int == typeof(INT_AND_BOOL())));
+// static assert(is(int == typeof(INT_AND_CHAR())));
+ static assert(is(int == typeof(INT_AND_INT())));
+ static assert(is(uint == typeof(INT_AND_UINT())));
+ static assert(is(int == typeof(INT_AND_LONG())));
+ static assert(is(uint == typeof(INT_AND_ULONG())));
+ static assert(is(long == typeof(INT_AND_LLONG())));
+ static assert(is(ulong == typeof(INT_AND_ULLONG())));
+ static assert(is(int == typeof(BOOL_AND_BOOL())));
+
+ static assert(is(int == typeof(EXPR_MULTIPLY())));
+ static assert(is(int == typeof(EXPR_DIVIDE())));
+ static assert(is(int == typeof(EXPR_PLUS())));
+ static assert(is(int == typeof(EXPR_MINUS())));
+ static assert(is(int == typeof(EXPR_LSHIFT())));
+ static assert(is(int == typeof(EXPR_RSHIFT())));
+ static assert(is(int == typeof(EXPR_LTE())));
+ static assert(is(int == typeof(EXPR_GTE())));
+ static assert(is(int == typeof(EXPR_INEQUALITY())));
+ static assert(is(int == typeof(EXPR_EQUALITY())));
+ static assert(is(int == typeof(EXPR_AND())));
+ static assert(is(int == typeof(EXPR_XOR())));
+ static assert(is(int == typeof(EXPR_OR())));
+ static assert(is(int == typeof(EXPR_LAND())));
+ static assert(is(int == typeof(EXPR_LOR())));
+ static assert(is(double == typeof(EXPR_CONDITIONAL())));
+}
diff --git a/Examples/test-suite/d/preproc_constants_runme.1.d b/Examples/test-suite/d/preproc_constants_runme.1.d
new file mode 100644
index 000000000..a2aaa8fcd
--- /dev/null
+++ b/Examples/test-suite/d/preproc_constants_runme.1.d
@@ -0,0 +1,62 @@
+module preproc_constants_runme;
+
+import preproc_constants.preproc_constants;
+
+void main() {
+ static assert(is(int == typeof(CONST_INT1())));
+ static assert(is(int == typeof(CONST_INT2())));
+ static assert(is(uint == typeof(CONST_UINT1())));
+ static assert(is(uint == typeof(CONST_UINT2())));
+ static assert(is(uint == typeof(CONST_UINT3())));
+ static assert(is(uint == typeof(CONST_UINT4())));
+ static assert(is(int == typeof(CONST_LONG1())));
+ static assert(is(int == typeof(CONST_LONG2())));
+ static assert(is(int == typeof(CONST_LONG3())));
+ static assert(is(int == typeof(CONST_LONG4())));
+ static assert(is(long == typeof(CONST_LLONG1())));
+ static assert(is(long == typeof(CONST_LLONG2())));
+ static assert(is(long == typeof(CONST_LLONG3())));
+ static assert(is(long == typeof(CONST_LLONG4())));
+ static assert(is(ulong == typeof(CONST_ULLONG1())));
+ static assert(is(ulong == typeof(CONST_ULLONG2())));
+ static assert(is(ulong == typeof(CONST_ULLONG3())));
+ static assert(is(ulong == typeof(CONST_ULLONG4())));
+ static assert(is(double == typeof(CONST_DOUBLE1())));
+ static assert(is(double == typeof(CONST_DOUBLE2())));
+ static assert(is(double == typeof(CONST_DOUBLE3())));
+ static assert(is(double == typeof(CONST_DOUBLE4())));
+ static assert(is(double == typeof(CONST_DOUBLE5())));
+ static assert(is(double == typeof(CONST_DOUBLE6())));
+ static assert(is(bool == typeof(CONST_BOOL1())));
+ static assert(is(bool == typeof(CONST_BOOL2())));
+ static assert(is(char == typeof(CONST_CHAR())));
+ static assert(is(char[] == typeof(CONST_STRING1())));
+ static assert(is(char[] == typeof(CONST_STRING2())));
+
+ static assert(is(int == typeof(INT_AND_BOOL())));
+// static assert(is(int == typeof(INT_AND_CHAR())));
+ static assert(is(int == typeof(INT_AND_INT())));
+ static assert(is(uint == typeof(INT_AND_UINT())));
+ static assert(is(int == typeof(INT_AND_LONG())));
+ static assert(is(uint == typeof(INT_AND_ULONG())));
+ static assert(is(long == typeof(INT_AND_LLONG())));
+ static assert(is(ulong == typeof(INT_AND_ULLONG())));
+ static assert(is(int == typeof(BOOL_AND_BOOL())));
+
+ static assert(is(int == typeof(EXPR_MULTIPLY())));
+ static assert(is(int == typeof(EXPR_DIVIDE())));
+ static assert(is(int == typeof(EXPR_PLUS())));
+ static assert(is(int == typeof(EXPR_MINUS())));
+ static assert(is(int == typeof(EXPR_LSHIFT())));
+ static assert(is(int == typeof(EXPR_RSHIFT())));
+ static assert(is(bool == typeof(EXPR_LTE())));
+ static assert(is(bool == typeof(EXPR_GTE())));
+ static assert(is(bool == typeof(EXPR_INEQUALITY())));
+ static assert(is(bool == typeof(EXPR_EQUALITY())));
+ static assert(is(int == typeof(EXPR_AND())));
+ static assert(is(int == typeof(EXPR_XOR())));
+ static assert(is(int == typeof(EXPR_OR())));
+ static assert(is(bool == typeof(EXPR_LAND())));
+ static assert(is(bool == typeof(EXPR_LOR())));
+ static assert(is(double == typeof(EXPR_CONDITIONAL())));
+}
diff --git a/Examples/test-suite/d/preproc_constants_runme.2.d b/Examples/test-suite/d/preproc_constants_runme.2.d
new file mode 100644
index 000000000..e2eab2c46
--- /dev/null
+++ b/Examples/test-suite/d/preproc_constants_runme.2.d
@@ -0,0 +1,62 @@
+module preproc_constants_runme;
+
+import preproc_constants.preproc_constants;
+
+void main() {
+ static assert(is(int == typeof(CONST_INT1())));
+ static assert(is(int == typeof(CONST_INT2())));
+ static assert(is(uint == typeof(CONST_UINT1())));
+ static assert(is(uint == typeof(CONST_UINT2())));
+ static assert(is(uint == typeof(CONST_UINT3())));
+ static assert(is(uint == typeof(CONST_UINT4())));
+ static assert(is(int == typeof(CONST_LONG1())));
+ static assert(is(int == typeof(CONST_LONG2())));
+ static assert(is(int == typeof(CONST_LONG3())));
+ static assert(is(int == typeof(CONST_LONG4())));
+ static assert(is(long == typeof(CONST_LLONG1())));
+ static assert(is(long == typeof(CONST_LLONG2())));
+ static assert(is(long == typeof(CONST_LLONG3())));
+ static assert(is(long == typeof(CONST_LLONG4())));
+ static assert(is(ulong == typeof(CONST_ULLONG1())));
+ static assert(is(ulong == typeof(CONST_ULLONG2())));
+ static assert(is(ulong == typeof(CONST_ULLONG3())));
+ static assert(is(ulong == typeof(CONST_ULLONG4())));
+ static assert(is(double == typeof(CONST_DOUBLE1())));
+ static assert(is(double == typeof(CONST_DOUBLE2())));
+ static assert(is(double == typeof(CONST_DOUBLE3())));
+ static assert(is(double == typeof(CONST_DOUBLE4())));
+ static assert(is(double == typeof(CONST_DOUBLE5())));
+ static assert(is(double == typeof(CONST_DOUBLE6())));
+ static assert(is(bool == typeof(CONST_BOOL1())));
+ static assert(is(bool == typeof(CONST_BOOL2())));
+ static assert(is(char == typeof(CONST_CHAR())));
+ static assert(is(string == typeof(CONST_STRING1())));
+ static assert(is(string == typeof(CONST_STRING2())));
+
+ static assert(is(int == typeof(INT_AND_BOOL())));
+// static assert(is(int == typeof(INT_AND_CHAR())));
+ static assert(is(int == typeof(INT_AND_INT())));
+ static assert(is(uint == typeof(INT_AND_UINT())));
+ static assert(is(int == typeof(INT_AND_LONG())));
+ static assert(is(uint == typeof(INT_AND_ULONG())));
+ static assert(is(long == typeof(INT_AND_LLONG())));
+ static assert(is(ulong == typeof(INT_AND_ULLONG())));
+ static assert(is(int == typeof(BOOL_AND_BOOL())));
+
+ static assert(is(int == typeof(EXPR_MULTIPLY())));
+ static assert(is(int == typeof(EXPR_DIVIDE())));
+ static assert(is(int == typeof(EXPR_PLUS())));
+ static assert(is(int == typeof(EXPR_MINUS())));
+ static assert(is(int == typeof(EXPR_LSHIFT())));
+ static assert(is(int == typeof(EXPR_RSHIFT())));
+ static assert(is(bool == typeof(EXPR_LTE())));
+ static assert(is(bool == typeof(EXPR_GTE())));
+ static assert(is(bool == typeof(EXPR_INEQUALITY())));
+ static assert(is(bool == typeof(EXPR_EQUALITY())));
+ static assert(is(int == typeof(EXPR_AND())));
+ static assert(is(int == typeof(EXPR_XOR())));
+ static assert(is(int == typeof(EXPR_OR())));
+ static assert(is(bool == typeof(EXPR_LAND())));
+ static assert(is(bool == typeof(EXPR_LOR())));
+ static assert(is(double == typeof(EXPR_CONDITIONAL())));
+}
diff --git a/Examples/test-suite/d/sizet_runme.1.d b/Examples/test-suite/d/sizet_runme.1.d
new file mode 100644
index 000000000..ae42e20e5
--- /dev/null
+++ b/Examples/test-suite/d/sizet_runme.1.d
@@ -0,0 +1,15 @@
+module sizet_runme;
+
+import sizet.sizet;
+
+void main() {
+ size_t s = 2000;
+ s = test1(s+1);
+ s = test2(s+1);
+ s = test3(s+1);
+ s = test4(s+1);
+
+ if (s != 2004) {
+ throw new Exception("failed");
+ }
+}
diff --git a/Examples/test-suite/d/sizet_runme.2.d b/Examples/test-suite/d/sizet_runme.2.d
new file mode 100644
index 000000000..63eb03b21
--- /dev/null
+++ b/Examples/test-suite/d/sizet_runme.2.d
@@ -0,0 +1,14 @@
+module sizet_runme;
+
+import std.exception;
+import sizet.sizet;
+
+void main() {
+ size_t s = 2000;
+ s = test1(s+1);
+ s = test2(s+1);
+ s = test3(s+1);
+ s = test4(s+1);
+
+ enforce(s == 2004, "failed");
+}
diff --git a/Examples/test-suite/d/sneaky1_runme.1.d b/Examples/test-suite/d/sneaky1_runme.1.d
new file mode 100644
index 000000000..b293b4972
--- /dev/null
+++ b/Examples/test-suite/d/sneaky1_runme.1.d
@@ -0,0 +1,21 @@
+module sneaky1_runme;
+
+import sneaky1.sneaky1;
+
+void main() {
+ if (add(30, 2) != 32) {
+ throw new Exception("add test failed");
+ }
+
+ if (subtract(20, 2) != 18) {
+ throw new Exception("subtract test failed");
+ }
+
+ if (mul(20, 2) != 40) {
+ throw new Exception("mul test failed");
+ }
+
+ if (divide(20, 2) != 10) {
+ throw new Exception("div test failed");
+ }
+}
diff --git a/Examples/test-suite/d/sneaky1_runme.2.d b/Examples/test-suite/d/sneaky1_runme.2.d
new file mode 100644
index 000000000..84e51e74d
--- /dev/null
+++ b/Examples/test-suite/d/sneaky1_runme.2.d
@@ -0,0 +1,11 @@
+module sneaky1_runme;
+
+import std.exception;
+import sneaky1.sneaky1;
+
+void main() {
+ enforce(add(30, 2) == 32, "add test failed");
+ enforce(subtract(20, 2) == 18, "subtract test failed");
+ enforce(mul(20, 2) == 40, "mul test failed");
+ enforce(divide(20, 2) == 10, "div test failed");
+}
diff --git a/Examples/test-suite/d/special_variable_macros_runme.1.d b/Examples/test-suite/d/special_variable_macros_runme.1.d
new file mode 100644
index 000000000..12491eef5
--- /dev/null
+++ b/Examples/test-suite/d/special_variable_macros_runme.1.d
@@ -0,0 +1,39 @@
+module special_variable_macros_runme;
+
+import special_variable_macros.special_variable_macros;
+import special_variable_macros.Name;
+import special_variable_macros.NewName;
+import special_variable_macros.PairIntBool;
+
+void main() {
+ auto name = new Name();
+
+ if (testFred(name) != "none") {
+ throw new Exception("test failed");
+ }
+
+ if (testJack(name) != "$specialname") {
+ throw new Exception("test failed");
+ }
+
+ if (testJill(name) != "jilly") {
+ throw new Exception("test failed");
+ }
+
+ if (testMary(name) != "SWIGTYPE_p_NameWrap") {
+ throw new Exception("test failed");
+ }
+
+ if (testJim(name) != "multiname num") {
+ throw new Exception("test failed");
+ }
+
+ if (testJohn(new PairIntBool(10, false)) != 123) {
+ throw new Exception("test failed");
+ }
+
+ auto newName = NewName.factory("factoryname");
+ if (newName.getStoredName().getName() != "factoryname") {
+ throw new Exception("test failed");
+ }
+}
diff --git a/Examples/test-suite/d/special_variable_macros_runme.2.d b/Examples/test-suite/d/special_variable_macros_runme.2.d
new file mode 100644
index 000000000..128e5870f
--- /dev/null
+++ b/Examples/test-suite/d/special_variable_macros_runme.2.d
@@ -0,0 +1,21 @@
+module special_variable_macros_runme;
+
+import std.exception;
+import special_variable_macros.special_variable_macros;
+import special_variable_macros.Name;
+import special_variable_macros.NewName;
+import special_variable_macros.PairIntBool;
+
+void main() {
+ auto name = new Name();
+ enforce(testFred(name) == "none");
+ enforce(testJack(name) == "$specialname");
+ enforce(testJill(name) == "jilly");
+ enforce(testMary(name) == "SWIGTYPE_p_NameWrap");
+ enforce(testJim(name) == "multiname num");
+
+ enforce(testJohn(new PairIntBool(10, false)) == 123);
+
+ auto newName = NewName.factory("factoryname");
+ enforce(newName.getStoredName().getName() == "factoryname");
+}
diff --git a/Examples/test-suite/d/threads_runme.1.d b/Examples/test-suite/d/threads_runme.1.d
new file mode 100644
index 000000000..206875824
--- /dev/null
+++ b/Examples/test-suite/d/threads_runme.1.d
@@ -0,0 +1,70 @@
+module threads_runme;
+
+import tango.core.Thread;
+import tango.io.Console;
+import Integer = tango.text.convert.Integer;
+import threads.Kerfuffle;
+
+// Spawn 8 threads.
+const uint NUM_THREADS = 8;
+
+// Run test for a few seconds on a 1GHz machine.
+const uint WORKER_LOOP_PASSES = 30000;
+
+void main() {
+ auto kerf = new Kerfuffle();
+ TestThread[] threads;
+
+ // Invoke the threads.
+ for (uint i = 0; i < NUM_THREADS; i++) {
+ auto thread = new TestThread(kerf);
+ threads ~= thread;
+ thread.name = Integer.toString(i);
+ thread.start();
+ }
+
+ // Wait for the threads to finish.
+ foreach(thread; threads) {
+ thread.join();
+ }
+
+ // Check if any thread has failed.
+ foreach(thread; threads) {
+ if (thread.failed) throw new Exception("Test failed.");
+ }
+}
+
+class TestThread : Thread {
+public:
+ this(Kerfuffle kerf) {
+ super(&run);
+ m_kerf = kerf;
+ }
+
+ void run() {
+ failed = false;
+ try {
+ for (uint i = 0; i < WORKER_LOOP_PASSES; i++) {
+ char[] given = "This is the test char[] that should come back. A number: " ~ Integer.toString(i);
+ char[] received = m_kerf.StdString(given);
+ if (received != given) {
+ throw new Exception("StdString char[] does not match. Received: '" ~ received ~ "'. Expected: '" ~ given ~ "'.");
+ }
+ }
+ for (uint i = 0; i < WORKER_LOOP_PASSES; i++) {
+ char[] given = "This is the test char[] that should come back. A number: " ~ Integer.toString(i);
+ char[] received = m_kerf.CharString(given);
+ if (received != given) {
+ throw new Exception("StdString char[] does not match. Received: '" ~ received ~ "'. Expected: '" ~ given ~ "'.");
+ }
+ }
+ } catch (Exception e) {
+ Cerr("Test failed (thread " ~ name() ~ "): " ~ e.msg).newline;
+ failed = true;
+ }
+ }
+
+ bool failed;
+private:
+ Kerfuffle m_kerf;
+}
diff --git a/Examples/test-suite/d/threads_runme.2.d b/Examples/test-suite/d/threads_runme.2.d
new file mode 100644
index 000000000..3ac27a5a8
--- /dev/null
+++ b/Examples/test-suite/d/threads_runme.2.d
@@ -0,0 +1,55 @@
+module threads_runme;
+
+import core.thread;
+import std.conv;
+import std.exception;
+import std.range;
+import std.stdio;
+import threads.Kerfuffle;
+
+// Spawn 8 threads.
+enum THREADS = iota(0, 9);
+
+// Run test for a few seconds on a 1GHz machine.
+enum WORK_RANGE = iota(0, 30000);
+
+void main() {
+ auto kerf = new Kerfuffle();
+ TestThread[] threads;
+
+ // Invoke the threads.
+ foreach (i; THREADS) {
+ auto thread = new TestThread(kerf);
+ threads ~= thread;
+ thread.name = to!string(i);
+ thread.start();
+ }
+
+ // Wait for the threads to finish.
+ foreach (i, thread; threads) {
+ thread.join(true);
+ }
+}
+
+class TestThread : Thread {
+ this(Kerfuffle kerf) {
+ super(&run);
+ m_kerf = kerf;
+ }
+
+ void run() {
+ foreach (i; WORK_RANGE) {
+ string given = "This is the test string that should come back. A number: " ~ to!string(i);
+ string received = m_kerf.StdString(given);
+ enforce(received == given, "StdString string does not match. Received: '" ~ received ~ "'. Expected: '" ~ given ~ "'.");
+ }
+ foreach (i; WORK_RANGE) {
+ string given = "This is the test string that should come back. A number: " ~ to!string(i);
+ string received = m_kerf.CharString(given);
+ enforce(received == given, "CharString string does not match. Received: '" ~ received ~ "'. Expected: '" ~ given ~ "'.");
+ }
+ }
+
+private:
+ Kerfuffle m_kerf;
+}
diff --git a/Examples/test-suite/d/throw_exception_runme.1.d b/Examples/test-suite/d/throw_exception_runme.1.d
new file mode 100644
index 000000000..f2397a202
--- /dev/null
+++ b/Examples/test-suite/d/throw_exception_runme.1.d
@@ -0,0 +1,30 @@
+module throw_exception_runme;
+
+import throw_exception.Foo;
+
+void main() {
+ test!("test_int");
+ test!("test_msg");
+ test!("test_cls");
+ test!("test_cls_ptr");
+ test!("test_cls_ref");
+ test!("test_cls_td");
+ test!("test_cls_ptr_td");
+ test!("test_cls_ref_td");
+ test!("test_array");
+ test!("test_enum");
+}
+
+void test(char[] methodName)() {
+ auto foo = new Foo();
+
+ bool didntThrow;
+ try {
+ mixin("foo." ~ methodName ~ "();");
+ didntThrow = true;
+ } catch (Exception) {}
+
+ if (didntThrow) {
+ throw new Exception(methodName ~ " failed");
+ }
+}
diff --git a/Examples/test-suite/d/throw_exception_runme.2.d b/Examples/test-suite/d/throw_exception_runme.2.d
new file mode 100644
index 000000000..6fc82a93d
--- /dev/null
+++ b/Examples/test-suite/d/throw_exception_runme.2.d
@@ -0,0 +1,30 @@
+module throw_exception_runme;
+
+import throw_exception.Foo;
+
+void main() {
+ test!("test_int");
+ test!("test_msg");
+ test!("test_cls");
+ test!("test_cls_ptr");
+ test!("test_cls_ref");
+ test!("test_cls_td");
+ test!("test_cls_ptr_td");
+ test!("test_cls_ref_td");
+ test!("test_array");
+ test!("test_enum");
+}
+
+void test(string methodName)() {
+ auto foo = new Foo();
+
+ bool didntThrow;
+ try {
+ mixin("foo." ~ methodName ~ "();");
+ didntThrow = true;
+ } catch (Exception) {}
+
+ if (didntThrow) {
+ throw new Exception(methodName ~ " failed");
+ }
+}
diff --git a/Examples/test-suite/d/typemap_namespace_runme.1.d b/Examples/test-suite/d/typemap_namespace_runme.1.d
new file mode 100644
index 000000000..3a5ca1a9f
--- /dev/null
+++ b/Examples/test-suite/d/typemap_namespace_runme.1.d
@@ -0,0 +1,13 @@
+module typemap_namespace_runme;
+
+import typemap_namespace.typemap_namespace;
+
+void main() {
+ if (test1("hello") != "hello") {
+ throw new Exception("test1 failed");
+ }
+
+ if (test2("hello") != "hello") {
+ throw new Exception("test2 failed");
+ }
+}
diff --git a/Examples/test-suite/d/typemap_namespace_runme.2.d b/Examples/test-suite/d/typemap_namespace_runme.2.d
new file mode 100644
index 000000000..2281e403b
--- /dev/null
+++ b/Examples/test-suite/d/typemap_namespace_runme.2.d
@@ -0,0 +1,9 @@
+module typemap_namespace_runme;
+
+import std.exception;
+import typemap_namespace.typemap_namespace;
+
+void main() {
+ enforce(test1("hello") == "hello", "test1 failed");
+ enforce(test2("hello") == "hello", "test2 failed");
+}
diff --git a/Examples/test-suite/d/typemap_out_optimal_runme.1.d b/Examples/test-suite/d/typemap_out_optimal_runme.1.d
new file mode 100644
index 000000000..16aab3cff
--- /dev/null
+++ b/Examples/test-suite/d/typemap_out_optimal_runme.1.d
@@ -0,0 +1,9 @@
+module typemap_out_optimal_runme;
+
+import typemap_out_optimal.XX;
+
+void main() {
+ XX x;
+ XX.trace = false;
+ x = XX.create();
+}
diff --git a/Examples/test-suite/d/typemap_out_optimal_runme.2.d b/Examples/test-suite/d/typemap_out_optimal_runme.2.d
new file mode 100644
index 000000000..16aab3cff
--- /dev/null
+++ b/Examples/test-suite/d/typemap_out_optimal_runme.2.d
@@ -0,0 +1,9 @@
+module typemap_out_optimal_runme;
+
+import typemap_out_optimal.XX;
+
+void main() {
+ XX x;
+ XX.trace = false;
+ x = XX.create();
+}
diff --git a/Examples/test-suite/d/varargs_runme.1.d b/Examples/test-suite/d/varargs_runme.1.d
new file mode 100644
index 000000000..53f76d075
--- /dev/null
+++ b/Examples/test-suite/d/varargs_runme.1.d
@@ -0,0 +1,20 @@
+module varargs_runme;
+
+import varargs.varargs;
+import varargs.Foo;
+
+void main() {
+ if (test("Hello") != "Hello") {
+ throw new Exception("Test 1 failed");
+ }
+
+ auto f = new Foo("Greetings");
+
+ if (f.str != "Greetings") {
+ throw new Exception("Test 2 failed");
+ }
+
+ if (f.test("Hello") != "Hello") {
+ throw new Exception("Test 3 failed");
+ }
+}
diff --git a/Examples/test-suite/d/varargs_runme.2.d b/Examples/test-suite/d/varargs_runme.2.d
new file mode 100644
index 000000000..b2b5ceddc
--- /dev/null
+++ b/Examples/test-suite/d/varargs_runme.2.d
@@ -0,0 +1,13 @@
+module varargs_runme;
+
+import std.exception;
+import varargs.varargs;
+import varargs.Foo;
+
+void main() {
+ enforce(test("Hello") == "Hello", "Test 1 failed");
+
+ auto f = new Foo("Greetings");
+ enforce(f.str == "Greetings", "Test 2 failed");
+ enforce(f.test("Hello") == "Hello", "Test 3 failed");
+}
diff --git a/Examples/test-suite/d/virtual_poly_runme.1.d b/Examples/test-suite/d/virtual_poly_runme.1.d
new file mode 100644
index 000000000..fb2e7814d
--- /dev/null
+++ b/Examples/test-suite/d/virtual_poly_runme.1.d
@@ -0,0 +1,27 @@
+module virtual_poly_runme;
+
+import virtual_poly.NDouble;
+import virtual_poly.NInt;
+import virtual_poly.NNumber;
+
+void main() {
+ // D supports covariant (polymorphic) return types, so this should work like
+ // in C++.
+ auto d = new NDouble(3.5);
+ NDouble dc = d.copy();
+ if (d.get() != dc.get()) {
+ throw new Exception("Test 1 failed.");
+ }
+
+ auto i = new NInt(2);
+ NInt ic = i.copy();
+ if (i.get() != ic.get()) {
+ throw new Exception("Test 2 failed.");
+ }
+
+ NNumber n = d;
+ auto nd = cast(NDouble) n.copy();
+ if (nd.get() != d.get()) {
+ throw new Exception("Test 3 failed.");
+ }
+}
diff --git a/Examples/test-suite/d/virtual_poly_runme.2.d b/Examples/test-suite/d/virtual_poly_runme.2.d
new file mode 100644
index 000000000..f749ee236
--- /dev/null
+++ b/Examples/test-suite/d/virtual_poly_runme.2.d
@@ -0,0 +1,22 @@
+module virtual_poly_runme;
+
+import std.exception;
+import virtual_poly.NDouble;
+import virtual_poly.NInt;
+import virtual_poly.NNumber;
+
+void main() {
+ // D supports covariant (polymorphic) return types, so this should work like
+ // in C++.
+ auto d = new NDouble(3.5);
+ NDouble dc = d.copy();
+ enforce(d.get() == dc.get(), "Test 1 failed.");
+
+ auto i = new NInt(2);
+ NInt ic = i.copy();
+ enforce(i.get() == ic.get(), "Test 2 failed.");
+
+ NNumber n = d;
+ auto nd = cast(NDouble) n.copy();
+ enforce(nd.get() == d.get(), "Test 3 failed.");
+}
diff --git a/Examples/test-suite/d_exception_name.i b/Examples/test-suite/d_exception_name.i
new file mode 100644
index 000000000..23f338a73
--- /dev/null
+++ b/Examples/test-suite/d_exception_name.i
@@ -0,0 +1,15 @@
+// Tests if exception handling still works in the presence of a wrapped C++
+// class called »Exception«, which could shadow the built-in Exception class.
+%module d_exception_name
+
+%inline %{
+ class Exception {
+ Exception(int i) {}
+ };
+
+ class Foo {
+ ~Foo() {}
+ public:
+ void bar(Exception *e) {}
+ };
+%}
diff --git a/Examples/test-suite/d_nativepointers.i b/Examples/test-suite/d_nativepointers.i
new file mode 100644
index 000000000..fdf3f1669
--- /dev/null
+++ b/Examples/test-suite/d_nativepointers.i
@@ -0,0 +1,21 @@
+%module d_nativepointers;
+
+%inline %{
+ class SomeClass {
+ };
+ class OpaqueClass;
+ typedef void (*FuncA)(int **x, char ***y);
+ typedef void (*FuncB)(int **x, SomeClass *y);
+
+ int *a( int *value ){ return value; }
+ float **b( float **value ){ return value; }
+ char ***c( char ***value ){ return value; }
+ SomeClass *d( SomeClass *value ){ return value; }
+ SomeClass **e( SomeClass **value ){ return value; }
+ OpaqueClass *f( OpaqueClass *value ){ return value; }
+ FuncA g( FuncA value ){ return value; }
+ FuncB* h( FuncB* value ){ return value; }
+
+ int &refA( int &value ){ return value; }
+ float *&refB( float *&value ){ return value; }
+%}
diff --git a/Examples/test-suite/default_constructor.i b/Examples/test-suite/default_constructor.i
index ff22c7834..091adff20 100644
--- a/Examples/test-suite/default_constructor.i
+++ b/Examples/test-suite/default_constructor.i
@@ -5,11 +5,13 @@
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) EB; /* C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) EB; /* C#, D, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) AD; /* C#, D, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_LANG_FRIEND_IGNORE) F; /* friend function */
diff --git a/Examples/test-suite/director_alternating.i b/Examples/test-suite/director_alternating.i
new file mode 100644
index 000000000..6e3ef4f24
--- /dev/null
+++ b/Examples/test-suite/director_alternating.i
@@ -0,0 +1,36 @@
+// Checks if calls to a method being defined in the base class, not
+// overridden in the subclass, but again overridden in a class derived from
+// the first subclass are dispatched correctly.
+%module(directors="1") director_alternating;
+
+%feature("director") Foo;
+
+%inline %{
+struct Foo {
+ virtual ~Foo() {}
+ virtual int id() {
+ return 0;
+ }
+};
+
+struct Bar : Foo {};
+
+struct Baz : Bar {
+ virtual int id() {
+ return 2;
+ }
+};
+
+// Note that even though the return value is of type Bar*, it really points to
+// an instance of Baz (in which id() has been overridden).
+Bar *getBar() {
+ static Baz baz;
+ return &baz;
+}
+
+// idFromGetBar() obviously is equivalent to getBar()->id() in C++ – this
+// should be true from the target language as well.
+int idFromGetBar() {
+ return getBar()->id();
+}
+%}
diff --git a/Examples/test-suite/director_keywords.i b/Examples/test-suite/director_keywords.i
new file mode 100644
index 000000000..473786c00
--- /dev/null
+++ b/Examples/test-suite/director_keywords.i
@@ -0,0 +1,13 @@
+// Checks if collisions of argument names with target language keywords are
+// resolved properly when directors are used (currently only »abstract« for
+// C#, D and Java is checked).
+%module(directors="1") director_keywords
+
+%feature("director") Foo;
+
+%inline %{
+struct Foo {
+ virtual ~Foo() {}
+ virtual void bar(int abstract) {}
+};
+%}
diff --git a/Examples/test-suite/director_protected.i b/Examples/test-suite/director_protected.i
index fee45b4a6..0299b238d 100644
--- a/Examples/test-suite/director_protected.i
+++ b/Examples/test-suite/director_protected.i
@@ -53,6 +53,10 @@ protected:
virtual std::string used() {
return pang() + pong();
}
+
+ virtual std::string cheer() {
+ return pang() + pong();
+ }
};
class Bar : public Foo
@@ -63,6 +67,14 @@ public:
return new Bar();
}
+ std::string callping() {
+ return ping();
+ }
+
+ std::string callcheer() {
+ return cheer();
+ }
+
std::string pong() {
return "Bar::pong();" + Foo::pong();
}
@@ -75,6 +87,7 @@ protected:
std::string ping() {
return "Bar::ping();";
};
+ using Foo::cheer;
enum Hello {hola, chao};
diff --git a/Examples/test-suite/director_using.i b/Examples/test-suite/director_using.i
index 9001ffbb9..d86546e86 100644
--- a/Examples/test-suite/director_using.i
+++ b/Examples/test-suite/director_using.i
@@ -59,9 +59,22 @@
public:
virtual C get_value() const = 0;
using Bar::do_advance;
-
};
+
}
%template(FooBar_int) FooBar<int>;
+%inline %{
+ struct SomeBase {
+ virtual ~SomeBase() {}
+ virtual void method1() {}
+ virtual void method2() {}
+ };
+
+ struct PrivateDerived : SomeBase {
+ private:
+ virtual void method1() {}
+ using SomeBase::method2;
+ };
+%}
diff --git a/Examples/test-suite/dynamic_cast.i b/Examples/test-suite/dynamic_cast.i
index ccbaa5b47..392b3bfd1 100644
--- a/Examples/test-suite/dynamic_cast.i
+++ b/Examples/test-suite/dynamic_cast.i
@@ -1,7 +1,7 @@
/* File : example.i */
%module dynamic_cast
-#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO)
+#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) && !defined(SWIGD)
%apply SWIGTYPE *DYNAMIC { Foo * };
#endif
@@ -17,7 +17,7 @@ public:
};
%}
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGO)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGO) || defined(SWIGD)
%typemap(out) Foo *blah {
Bar *downcast = dynamic_cast<Bar *>($1);
*(Bar **)&$result = downcast;
@@ -37,6 +37,13 @@ public:
}
#endif
+#if defined(SWIGD)
+%typemap(dout, excode=SWIGEXCODE) Foo * {
+ Bar ret = new Bar($imcall, $owner);$excode
+ return ret;
+}
+#endif
+
#if defined(SWIGGO)
%insert(go_runtime) %{
func FooToBar(f Foo) Bar {
@@ -62,7 +69,7 @@ char *do_test(Bar *b) {
}
%}
-#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO)
+#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) && !defined(SWIGD)
// A general purpose function for dynamic casting of a Foo *
%{
static swig_type_info *
diff --git a/Examples/test-suite/enum_rename.i b/Examples/test-suite/enum_rename.i
index 455826f8b..0cab4d0d8 100644
--- a/Examples/test-suite/enum_rename.i
+++ b/Examples/test-suite/enum_rename.i
@@ -2,7 +2,7 @@
%warnfilter(SWIGWARN_PARSE_REDEFINED) S_May;
-// %rename with rxspencer can do the equivalent of these two renames, which was resulting in uncompileable code
+// %rename using regex can do the equivalent of these two renames, which was resulting in uncompileable code
%rename(May) M_May;
%rename(May) S_May;
diff --git a/Examples/test-suite/enums.i b/Examples/test-suite/enums.i
index 5632b5e97..14c6efbba 100644
--- a/Examples/test-suite/enums.i
+++ b/Examples/test-suite/enums.i
@@ -58,6 +58,11 @@ typedef struct _Foo {
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) _iFoo;
+#ifdef SWIGD
+/* Work around missing support for proper char quoting due to parser shortcomings. */
+%dconstvalue("'a'") _iFoo::Char;
+#endif
+
#ifndef __cplusplus
%inline %{
typedef struct _iFoo
diff --git a/Examples/test-suite/errors/cpp_inherit.i b/Examples/test-suite/errors/cpp_inherit.i
new file mode 100644
index 000000000..fdc77d1d5
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_inherit.i
@@ -0,0 +1,47 @@
+%module xxx
+
+%inline %{
+struct A5;
+int A6;
+template<typename T> struct A7
+{
+};
+template<typename T> struct A8
+{
+};
+
+struct A0
+:
+ public A1
+ ,
+ A2,
+ private A3
+ ,
+ private A4
+ ,
+ A5
+ ,
+ A6
+ ,
+ A7<int>
+ ,
+ protected A8<double>
+{
+};
+
+struct A1
+{
+};
+
+class B1 {};
+
+class B0 :
+ B1,
+ B2<int>
+{
+};
+
+struct Recursive : Recursive
+{
+};
+%}
diff --git a/Examples/test-suite/errors/cpp_macro_locator.i b/Examples/test-suite/errors/cpp_macro_locator.i
new file mode 100644
index 000000000..bd441a121
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_macro_locator.i
@@ -0,0 +1,103 @@
+%module xxx
+
+// Test the SWIG preprocessor locator effects on reporting line numbers in warnings when processing SWIG (multiline) macros
+
+// The ignored overloaded methods warnings should have the correct line number reporting
+// {} blocks are tested, where the preprocessor expands the macros
+
+%define CLASSMACRO(KLASS)
+class KLASS
+{
+public:
+ KLASS() {}
+ void methodX(int *) {}
+ void methodX(const int *) {}
+};
+%enddef
+
+%{
+#define CLASSMACRO(KLASS) \
+class KLASS \
+{ \
+public: \
+ KLASS() {} \
+ void methodX(int *) {} \
+ void methodX(const int *) {} \
+};
+%}
+
+%{
+#define VARIABLEMACRO(NAME) double NAME;
+struct Outer {
+ struct Inner {
+ VARIABLEMACRO(MyInnerVar)
+ };
+};
+void overload1(int *) {}
+void overload1(const int *) {}
+void overload2(int *) {}
+void overload2(const int *) {}
+void overload3(int *) {}
+void overload3(const int *) {}
+%}
+
+%define VARIABLEMACRO(NAME)
+double NAME;
+%enddef
+struct Outer {
+ struct Inner {
+ VARIABLEMACRO(MyInnerVar)
+ };
+};
+void overload1(int *) {}
+void overload1(const int *) {}
+
+%fragment("FragmentMethod", "header") {
+void fragmentMethod() {
+}
+VARIABLEMACRO(fragVar)
+}
+void overload2(int *) {}
+void overload2(const int *) {}
+
+%inline {
+CLASSMACRO(Klass1)
+}
+#warning inline warning message one
+void overload3(int *) {}
+void overload3(const int *) {}
+
+%{
+struct Classic {
+ Classic() {
+ VARIABLEMACRO(inconstructor)
+ }
+ double value;
+};
+void overload4(int *) {}
+void overload4(const int *) {}
+void overload5(int *) {}
+void overload5(const int *) {}
+%}
+
+struct Classic {
+ Classic() {
+ VARIABLEMACRO(inconstructor)
+ }
+ double value;
+};
+void overload4(int *) {}
+void overload4(const int *) {}
+
+%inline {
+void overloadinline1(int *) {}
+void overloadinline1(const int *) {}
+CLASSMACRO(Klass2)
+#warning an inline warning message 2
+void overloadinline2(int *) {}
+void overloadinline2(const int *) {}
+}
+void overload5(int *) {}
+void overload5(const int *) {}
+
+
diff --git a/Examples/test-suite/errors/cpp_recursive_typedef.i b/Examples/test-suite/errors/cpp_recursive_typedef.i
new file mode 100644
index 000000000..3d65a8817
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_recursive_typedef.i
@@ -0,0 +1,4 @@
+%module cpp_recursive_typedef
+
+typedef std::set<pds> pds;
+
diff --git a/Examples/test-suite/errors/cpp_shared_ptr.i b/Examples/test-suite/errors/cpp_shared_ptr.i
new file mode 100644
index 000000000..edbd0cf87
--- /dev/null
+++ b/Examples/test-suite/errors/cpp_shared_ptr.i
@@ -0,0 +1,29 @@
+%module cpp_shared_ptr
+
+%include <boost_shared_ptr.i>
+
+%shared_ptr(B);
+%shared_ptr(C);
+
+%inline %{
+ #include <stdio.h>
+ #include <boost/shared_ptr.hpp>
+
+ struct A {
+ virtual ~A() {}
+ };
+
+ struct B {
+ virtual ~B() {}
+ };
+
+ struct C : B, A {
+ virtual ~C() {}
+ };
+
+ struct D : C {
+ virtual ~D() {}
+ };
+%}
+
+
diff --git a/Examples/test-suite/errors/expected.log b/Examples/test-suite/errors/expected.log
new file mode 100644
index 000000000..f9210226d
--- /dev/null
+++ b/Examples/test-suite/errors/expected.log
@@ -0,0 +1,314 @@
+SWIG error and warning test. opts=
+-----------------------------------------------------------
+
+:::::::::::::::::::::::::::::::: c_bad_name.i :::::::::::::::::::::::::::::::::::
+c_bad_name.i:3: Warning 121: %name is deprecated. Use %rename instead.
+c_bad_name.i:3: Error: Missing argument to %name directive.
+
+:::::::::::::::::::::::::::::::: c_bad_native.i :::::::::::::::::::::::::::::::::::
+c_bad_native.i:3: Error: %native declaration 'foo' is not a function.
+
+:::::::::::::::::::::::::::::::: c_class.i :::::::::::::::::::::::::::::::::::
+c_class.i:3: Warning 301: class keyword used, but not in C++ mode.
+c_class.i:3: Warning 314: 'class' is a python keyword, renaming to '_class'
+
+:::::::::::::::::::::::::::::::: c_default_error.i :::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::: c_deprecated.i :::::::::::::::::::::::::::::::::::
+c_deprecated.i:3: Warning 102: %val directive deprecated (ignored).
+c_deprecated.i:3: Warning 103: %out directive deprecated (ignored).
+
+:::::::::::::::::::::::::::::::: c_empty_char.i :::::::::::::::::::::::::::::::::::
+c_empty_char.i:3: Error: Empty character constant
+0
+
+:::::::::::::::::::::::::::::::: c_enum_badvalue.i :::::::::::::::::::::::::::::::::::
+c_enum_badvalue.i:6: Error: Type error. Expecting an integral type
+
+:::::::::::::::::::::::::::::::: c_extra_rblock.i :::::::::::::::::::::::::::::::::::
+c_extra_rblock.i:5: Error: Syntax error in input(1).
+
+:::::::::::::::::::::::::::::::: c_extra_rbrace.i :::::::::::::::::::::::::::::::::::
+c_extra_rbrace.i:5: Error: Syntax error. Extraneous '}'
+
+:::::::::::::::::::::::::::::::: c_extra_unsigned.i :::::::::::::::::::::::::::::::::::
+c_extra_unsigned.i:3: Error: Extra unsigned specifier.
+c_extra_unsigned.i:4: Error: Extra signed specifier.
+c_extra_unsigned.i:5: Error: Extra signed specifier.
+
+:::::::::::::::::::::::::::::::: c_insert_missing.i :::::::::::::::::::::::::::::::::::
+c_insert_missing.i:3: Error: Couldn't find 'missing_file.i'.
+
+:::::::::::::::::::::::::::::::: c_long_short.i :::::::::::::::::::::::::::::::::::
+c_long_short.i:3: Error: Extra long specifier.
+c_long_short.i:4: Error: Extra short specifier.
+c_long_short.i:5: Error: Extra long specifier.
+c_long_short.i:6: Error: Extra short specifier.
+
+:::::::::::::::::::::::::::::::: c_missing_rbrace.i :::::::::::::::::::::::::::::::::::
+:168430090: Error: Missing '}'. Reached end of input.
+c_missing_rbrace.i:3: Error: Syntax error in input(1).
+
+:::::::::::::::::::::::::::::::: c_missing_semi.i :::::::::::::::::::::::::::::::::::
+c_missing_semi.i:3: Error: Syntax error in input(1).
+
+:::::::::::::::::::::::::::::::: c_redefine.i :::::::::::::::::::::::::::::::::::
+c_redefine.i:4: Warning 302: Identifier 'foo' redefined (ignored),
+c_redefine.i:3: Warning 302: previous definition of 'foo'.
+c_redefine.i:8: Warning 302: Identifier 'bar' redefined (ignored),
+c_redefine.i:6: Warning 302: previous definition of 'bar'.
+c_redefine.i:14: Warning 322: Redundant redeclaration of 'bar' (Renamed from 'spam'),
+c_redefine.i:6: Warning 322: previous declaration of 'bar'.
+
+:::::::::::::::::::::::::::::::: c_varargs.i :::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::: c_varargs_neg.i :::::::::::::::::::::::::::::::::::
+c_varargs_neg.i:3: Error: Argument count in %varargs must be positive.
+
+:::::::::::::::::::::::::::::::: nomodule.i :::::::::::::::::::::::::::::::::::
+No module name specified using %module or -module.
+
+:::::::::::::::::::::::::::::::: pp_badeval.i :::::::::::::::::::::::::::::::::::
+pp_badeval.i:4: Warning 202: Could not evaluate 'FOO==4+'
+pp_badeval.i:4: Warning 202: Error: 'Expected an expression'
+
+:::::::::::::::::::::::::::::::: pp_constant.i :::::::::::::::::::::::::::::::::::
+pp_constant.i:9: Warning 305: Bad constant value (ignored).
+pp_constant.i:15: Warning 305: Bad constant value (ignored).
+pp_constant.i:23: Warning 305: Bad constant value (ignored).
+pp_constant.i:29: Warning 305: Bad constant value (ignored).
+pp_constant.i:35: Warning 305: Bad constant value (ignored).
+pp_constant.i:42: Warning 305: Bad constant value (ignored).
+pp_constant.i:46: Warning 305: Bad constant value (ignored).
+pp_constant.i:49: Warning 305: Bad constant value (ignored).
+
+:::::::::::::::::::::::::::::::: pp_defined.i :::::::::::::::::::::::::::::::::::
+pp_defined.i:6: Error: No arguments given to defined()
+pp_defined.i:6: Warning 202: Could not evaluate 'defined'
+pp_defined.i:6: Warning 202: Error: 'Expected an expression'
+
+:::::::::::::::::::::::::::::::: pp_deprecated.i :::::::::::::::::::::::::::::::::::
+pp_deprecated.i:4: Warning 101: %extern is deprecated. Use %import instead.
+pp_deprecated.i:4: Error: Unable to find 'ext;'
+pp_deprecated.i:6: Warning 204: CPP #warning, Print this warning
+pp_deprecated.i:8: Error: CPP #error "This is an error". Use the -cpperraswarn option to continue swig processing.
+
+:::::::::::::::::::::::::::::::: pp_illegal_argument.i :::::::::::::::::::::::::::::::::::
+pp_illegal_argument.i:6: Error: Illegal macro argument name '..'
+pp_illegal_argument.i:10: Error: Illegal macro argument name '..'
+pp_illegal_argument.i:16: Error: Illegal character in macro argument name
+
+:::::::::::::::::::::::::::::::: pp_macro_args.i :::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::: pp_macro_badchar.i :::::::::::::::::::::::::::::::::::
+pp_macro_badchar.i:4: Error: Illegal character in macro argument name
+
+:::::::::::::::::::::::::::::::: pp_macro_defined_unterminated.i :::::::::::::::::::::::::::::::::::
+pp_macro_defined_unterminated.i:4: Error: Unterminated call to 'defined'
+
+:::::::::::::::::::::::::::::::: pp_macro_expansion.i :::::::::::::::::::::::::::::::::::
+pp_macro_expansion.i:9: Error: Macro 'MACRO2' expects 2 arguments
+
+:::::::::::::::::::::::::::::::: pp_macro_expansion_multiline.i :::::::::::::::::::::::::::::::::::
+pp_macro_expansion_multiline.i:13: Warning 509: Overloaded method foo(int const *) effectively ignored,
+pp_macro_expansion_multiline.i:12: Warning 509: as it is shadowed by foo(int *).
+pp_macro_expansion_multiline.i:31: Warning 509: Overloaded method bar(int const *) effectively ignored,
+pp_macro_expansion_multiline.i:30: Warning 509: as it is shadowed by bar(int *).
+
+:::::::::::::::::::::::::::::::: pp_macro_inline_unterminated.i :::::::::::::::::::::::::::::::::::
+pp_macro_inline_unterminated.i:9: Error: Unterminated call invoking macro 'foo'
+pp_macro_inline_unterminated.i:12: Error: Syntax error in input(3).
+
+:::::::::::::::::::::::::::::::: pp_macro_nargs.i :::::::::::::::::::::::::::::::::::
+pp_macro_nargs.i:7: Error: Macro 'foo' expects 2 arguments
+pp_macro_nargs.i:8: Error: Macro 'foo' expects 2 arguments
+pp_macro_nargs.i:10: Error: Macro 'bar' expects 1 argument
+pp_macro_nargs.i:11: Error: Macro 'spam' expects no arguments
+
+:::::::::::::::::::::::::::::::: pp_macro_redef.i :::::::::::::::::::::::::::::::::::
+pp_macro_redef.i:4: Error: Macro 'foo' redefined,
+pp_macro_redef.i:3: Error: previous definition of 'foo'.
+pp_macro_redef.i:7: Error: Macro 'foo' redefined,
+pp_macro_redef.i:3: Error: previous definition of 'foo'.
+
+:::::::::::::::::::::::::::::::: pp_macro_rparen.i :::::::::::::::::::::::::::::::::::
+pp_macro_rparen.i:3: Error: Missing ')' in macro parameters
+
+:::::::::::::::::::::::::::::::: pp_macro_unterminated.i :::::::::::::::::::::::::::::::::::
+pp_macro_unterminated.i:5: Error: Unterminated call invoking macro 'foo'
+
+:::::::::::::::::::::::::::::::: pp_misplaced_elif.i :::::::::::::::::::::::::::::::::::
+pp_misplaced_elif.i:4: Error: Misplaced #elif.
+pp_misplaced_elif.i:6: Error: Extraneous #endif.
+
+:::::::::::::::::::::::::::::::: pp_misplaced_else.i :::::::::::::::::::::::::::::::::::
+pp_misplaced_else.i:4: Error: Misplaced #else.
+pp_misplaced_else.i:6: Error: Extraneous #endif.
+
+:::::::::::::::::::::::::::::::: pp_missing_enddef.i :::::::::::::::::::::::::::::::::::
+pp_missing_enddef.i:EOF: Error: Missing %enddef for macro starting on line 3
+
+:::::::::::::::::::::::::::::::: pp_missing_endif.i :::::::::::::::::::::::::::::::::::
+pp_missing_endif.i:EOF: Error: Missing #endif for conditional starting on line 3
+
+:::::::::::::::::::::::::::::::: pp_missing_file.i :::::::::::::::::::::::::::::::::::
+pp_missing_file.i:3: Error: Unable to find 'missing_filename.i'
+
+:::::::::::::::::::::::::::::::: pp_missing_rblock.i :::::::::::::::::::::::::::::::::::
+pp_missing_rblock.i:EOF: Error: Unterminated %{ ... %} block starting on line 3
+
+:::::::::::::::::::::::::::::::: pp_pragma.i :::::::::::::::::::::::::::::::::::
+pp_pragma.i:4: Error: Unknown SWIG pragma: rubbish()
+
+:::::::::::::::::::::::::::::::: pp_unterm_char.i :::::::::::::::::::::::::::::::::::
+pp_unterm_char.i:EOF: Error: Unterminated character constant starting at line 4
+
+:::::::::::::::::::::::::::::::: pp_unterm_comment.i :::::::::::::::::::::::::::::::::::
+pp_unterm_comment.i:EOF: Error: Unterminated comment starting on line 3
+
+:::::::::::::::::::::::::::::::: pp_unterm_string.i :::::::::::::::::::::::::::::::::::
+pp_unterm_string.i:EOF: Error: Unterminated string constant starting at line 4
+
+:::::::::::::::::::::::::::::::: pp_variable_args.i :::::::::::::::::::::::::::::::::::
+pp_variable_args.i:6: Error: Variable length macro argument must be last parameter
+
+:::::::::::::::::::::::::::::::: swig_apply_nargs.i :::::::::::::::::::::::::::::::::::
+swig_apply_nargs.i:6: Error: Can't apply (char *str,int len) to (int x). Number of arguments don't match.
+
+:::::::::::::::::::::::::::::::: swig_identifier.i :::::::::::::::::::::::::::::::::::
+swig_identifier.i:5: Warning 503: Can't wrap 'foo bar' unless renamed to a valid identifier.
+
+:::::::::::::::::::::::::::::::: swig_insert_bad.i :::::::::::::::::::::::::::::::::::
+swig_insert_bad.i:5: Error: Unknown target 'foobar' for %insert directive.
+
+:::::::::::::::::::::::::::::::: swig_typemap_copy.i :::::::::::::::::::::::::::::::::::
+swig_typemap_copy.i:3: Error: Can't copy typemap (in) blah = int
+
+:::::::::::::::::::::::::::::::: swig_typemap_old.i :::::::::::::::::::::::::::::::::::
+swig_typemap_old.i:6: Warning 450: Deprecated typemap feature ($source/$target).
+swig_typemap_old.i:6: Warning 450: The use of $source and $target in a typemap declaration is deprecated.
+For typemaps related to argument input (in,ignore,default,arginit,check), replace
+$source by $input and $target by $1. For typemaps related to return values (out,
+argout,ret,except), replace $source by $1 and $target by $result. See the file
+Doc/Manual/Typemaps.html for complete details.
+
+:::::::::::::::::::::::::::::::: cpp_bad_extern.i :::::::::::::::::::::::::::::::::::
+cpp_bad_extern.i:5: Warning 313: Unrecognized extern type "INTERCAL".
+cpp_bad_extern.i:7: Warning 313: Unrecognized extern type "INTERCAL".
+
+:::::::::::::::::::::::::::::::: cpp_extend_redefine.i :::::::::::::::::::::::::::::::::::
+cpp_extend_redefine.i:9: Warning 302: Identifier 'bar' redefined by %extend (ignored),
+cpp_extend_redefine.i:5: Warning 302: %extend definition of 'bar'.
+cpp_extend_redefine.i:14: Warning 322: Redundant redeclaration of 'spam',
+cpp_extend_redefine.i:10: Warning 322: previous declaration of 'spam'.
+
+:::::::::::::::::::::::::::::::: cpp_extend_undefined.i :::::::::::::::::::::::::::::::::::
+cpp_extend_undefined.i:6: Warning 303: %extend defined for an undeclared class foo.
+
+:::::::::::::::::::::::::::::::: cpp_inline_namespace.i :::::::::::::::::::::::::::::::::::
+cpp_inline_namespace.i:4: Error: %inline directive inside a namespace is disallowed.
+
+:::::::::::::::::::::::::::::::: cpp_inherit.i :::::::::::::::::::::::::::::::::::
+cpp_inherit.i:18: Warning 309: private inheritance from base 'A3' (ignored).
+cpp_inherit.i:20: Warning 309: private inheritance from base 'A4' (ignored).
+cpp_inherit.i:28: Warning 309: protected inheritance from base 'A8< double >' (ignored).
+cpp_inherit.i:39: Warning 319: No access specifier given for base class 'B1' (ignored).
+cpp_inherit.i:40: Warning 319: No access specifier given for base class 'B2< int >' (ignored).
+cpp_inherit.i:15: Warning 401: Base class 'A1' undefined.
+cpp_inherit.i:33: Warning 401: 'A1' must be defined before it is used as a base class.
+cpp_inherit.i:17: Warning 401: Nothing known about base class 'A2'. Ignored.
+cpp_inherit.i:22: Warning 402: Base class 'A5' is incomplete.
+cpp_inherit.i:4: Warning 402: Only forward declaration 'A5' was found.
+cpp_inherit.i:24: Error: 'A6' is not a valid base class.
+cpp_inherit.i:5: Error: See definition of 'A6'.
+cpp_inherit.i:24: Warning 401: Nothing known about base class 'A6'. Ignored.
+cpp_inherit.i:26: Warning 401: Nothing known about base class 'A7< int >'. Ignored.
+cpp_inherit.i:26: Warning 401: Maybe you forgot to instantiate 'A7< int >' using %template.
+cpp_inherit.i:45: Warning 323: Recursive scope inheritance of 'Recursive'.
+
+:::::::::::::::::::::::::::::::: cpp_macro_locator.i :::::::::::::::::::::::::::::::::::
+cpp_macro_locator.i:66: Warning 204: CPP #warning, inline warning message one
+cpp_macro_locator.i:96: Warning 204: CPP #warning, an inline warning message 2
+cpp_macro_locator.i:50: Warning 325: Nested struct not currently supported (Inner ignored)
+cpp_macro_locator.i:53: Warning 509: Overloaded method overload1(int const *) effectively ignored,
+cpp_macro_locator.i:52: Warning 509: as it is shadowed by overload1(int *).
+cpp_macro_locator.i:61: Warning 509: Overloaded method overload2(int const *) effectively ignored,
+cpp_macro_locator.i:60: Warning 509: as it is shadowed by overload2(int *).
+cpp_macro_locator.i:64: Warning 509: Overloaded method Klass1::methodX(int const *) effectively ignored,
+cpp_macro_locator.i:64: Warning 509: as it is shadowed by Klass1::methodX(int *).
+cpp_macro_locator.i:68: Warning 509: Overloaded method overload3(int const *) effectively ignored,
+cpp_macro_locator.i:67: Warning 509: as it is shadowed by overload3(int *).
+cpp_macro_locator.i:90: Warning 509: Overloaded method overload4(int const *) effectively ignored,
+cpp_macro_locator.i:89: Warning 509: as it is shadowed by overload4(int *).
+cpp_macro_locator.i:94: Warning 509: Overloaded method overloadinline1(int const *) effectively ignored,
+cpp_macro_locator.i:93: Warning 509: as it is shadowed by overloadinline1(int *).
+cpp_macro_locator.i:95: Warning 509: Overloaded method Klass2::methodX(int const *) effectively ignored,
+cpp_macro_locator.i:95: Warning 509: as it is shadowed by Klass2::methodX(int *).
+cpp_macro_locator.i:98: Warning 509: Overloaded method overloadinline2(int const *) effectively ignored,
+cpp_macro_locator.i:97: Warning 509: as it is shadowed by overloadinline2(int *).
+cpp_macro_locator.i:101: Warning 509: Overloaded method overload5(int const *) effectively ignored,
+cpp_macro_locator.i:100: Warning 509: as it is shadowed by overload5(int *).
+
+:::::::::::::::::::::::::::::::: cpp_missing_rtemplate.i :::::::::::::::::::::::::::::::::::
+cpp_missing_rtemplate.i:4: Error: Syntax error in input(1).
+
+:::::::::::::::::::::::::::::::: cpp_namespace_alias.i :::::::::::::::::::::::::::::::::::
+cpp_namespace_alias.i:8: Warning 308: Namespace alias 'B' not allowed here. Assuming 'blah'
+
+:::::::::::::::::::::::::::::::: cpp_namespace_aliasnot.i :::::::::::::::::::::::::::::::::::
+cpp_namespace_aliasnot.i:4: Error: 'blah' is not a namespace
+
+:::::::::::::::::::::::::::::::: cpp_namespace_aliasundef.i :::::::::::::::::::::::::::::::::::
+cpp_namespace_aliasundef.i:3: Error: Unknown namespace 'blah'
+
+:::::::::::::::::::::::::::::::: cpp_nested.i :::::::::::::::::::::::::::::::::::
+cpp_nested.i:6: Warning 325: Nested class not currently supported (Bar ignored)
+cpp_nested.i:12: Warning 325: Nested class not currently supported (Grok ignored)
+
+:::::::::::::::::::::::::::::::: cpp_no_access.i :::::::::::::::::::::::::::::::::::
+cpp_no_access.i:3: Warning 319: No access specifier given for base class 'foo' (ignored).
+
+:::::::::::::::::::::::::::::::: cpp_nobase.i :::::::::::::::::::::::::::::::::::
+cpp_nobase.i:3: Warning 401: Nothing known about base class 'Bar'. Ignored.
+cpp_nobase.i:6: Warning 401: Nothing known about base class 'Bar< int >'. Ignored.
+cpp_nobase.i:6: Warning 401: Maybe you forgot to instantiate 'Bar< int >' using %template.
+
+:::::::::::::::::::::::::::::::: cpp_overload.i :::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::: cpp_private_defvalue.i :::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::: cpp_private_inherit.i :::::::::::::::::::::::::::::::::::
+cpp_private_inherit.i:6: Warning 309: private inheritance from base 'Foo' (ignored).
+cpp_private_inherit.i:9: Warning 309: protected inheritance from base 'Foo' (ignored).
+
+:::::::::::::::::::::::::::::::: cpp_recursive_typedef.i :::::::::::::::::::::::::::::::::::
+:1: Error: Recursive typedef detected resolving 'pds *' to 'std::set< pds > *' to 'std::set< std::set< pds > > *' and so on...
+
+:::::::::::::::::::::::::::::::: cpp_shared_ptr.i :::::::::::::::::::::::::::::::::::
+cpp_shared_ptr.i:20: Warning 520: Base class 'A' of 'C' is not similarly marked as a smart pointer.
+cpp_shared_ptr.i:24: Warning 520: Derived class 'D' of 'C' is not similarly marked as a smart pointer.
+cpp_shared_ptr.i:24: Warning 520: Derived class 'D' of 'B' is not similarly marked as a smart pointer.
+
+:::::::::::::::::::::::::::::::: cpp_template_argname.i :::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::: cpp_template_nargs.i :::::::::::::::::::::::::::::::::::
+cpp_template_nargs.i:5: Error: Template 'blah' undefined.
+cpp_template_nargs.i:6: Error: Template 'blah' undefined.
+
+:::::::::::::::::::::::::::::::: cpp_template_not.i :::::::::::::::::::::::::::::::::::
+cpp_template_not.i:5: Error: 'blah' is not defined as a template. (cdecl)
+
+:::::::::::::::::::::::::::::::: cpp_template_partial.i :::::::::::::::::::::::::::::::::::
+cpp_template_partial.i:3: Warning 317: Specialization of non-template 'vector'.
+
+:::::::::::::::::::::::::::::::: cpp_template_repeat.i :::::::::::::::::::::::::::::::::::
+
+:::::::::::::::::::::::::::::::: cpp_template_undef.i :::::::::::::::::::::::::::::::::::
+cpp_template_undef.i:3: Error: Template 'blah' undefined.
+
+:::::::::::::::::::::::::::::::: cpp_using_not.i :::::::::::::::::::::::::::::::::::
+cpp_using_not.i:4: Error: 'blah' is not a namespace.
+
+:::::::::::::::::::::::::::::::: cpp_using_undef.i :::::::::::::::::::::::::::::::::::
+cpp_using_undef.i:4: Error: Nothing known about namespace 'foo'
+cpp_using_undef.i:3: Warning 315: Nothing known about 'foo::bar'.
diff --git a/Examples/test-suite/errors/make.sh b/Examples/test-suite/errors/make.sh
index ae38ca879..474c79b2d 100755
--- a/Examples/test-suite/errors/make.sh
+++ b/Examples/test-suite/errors/make.sh
@@ -24,11 +24,18 @@ c_missing_semi
c_redefine
c_varargs
c_varargs_neg
-nomodule
+nomodule
pp_badeval
+pp_constant
pp_defined
+pp_deprecated
+pp_illegal_argument
pp_macro_args
pp_macro_badchar
+pp_macro_defined_unterminated
+pp_macro_expansion
+pp_macro_expansion_multiline
+pp_macro_inline_unterminated
pp_macro_nargs
pp_macro_redef
pp_macro_rparen
@@ -39,9 +46,11 @@ pp_missing_enddef
pp_missing_endif
pp_missing_file
pp_missing_rblock
+pp_pragma
pp_unterm_char
pp_unterm_comment
pp_unterm_string
+pp_variable_args
swig_apply_nargs
swig_identifier
swig_insert_bad
@@ -55,6 +64,8 @@ cpp_bad_extern
cpp_extend_redefine
cpp_extend_undefined
cpp_inline_namespace
+cpp_inherit
+cpp_macro_locator
cpp_missing_rtemplate
cpp_namespace_alias
cpp_namespace_aliasnot
@@ -65,6 +76,8 @@ cpp_nobase
cpp_overload
cpp_private_defvalue
cpp_private_inherit
+cpp_recursive_typedef
+cpp_shared_ptr
cpp_template_argname
cpp_template_nargs
cpp_template_not
@@ -87,14 +100,14 @@ for i in ${CFILES}; do
echo " Testing : ${i}.i";
echo "" >> ${LOGFILE};
echo ":::::::::::::::::::::::::::::::: ${i}.i :::::::::::::::::::::::::::::::::::" >> ${LOGFILE};
- ${SWIG} -Wall ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1
+ ${SWIG} -python -Wall ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1
done
for i in ${CPPFILES}; do
echo " Testing : ${i}.i";
echo "" >> ${LOGFILE}
echo ":::::::::::::::::::::::::::::::: ${i}.i :::::::::::::::::::::::::::::::::::" >> ${LOGFILE};
- ${SWIG} -Wall -c++ ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1
+ ${SWIG} -python -Wall -c++ ${SWIGOPT} ${i}.i >>${LOGFILE} 2>&1
done
echo ""
diff --git a/Examples/test-suite/errors/pp_constant.i b/Examples/test-suite/errors/pp_constant.i
new file mode 100644
index 000000000..2be108e83
--- /dev/null
+++ b/Examples/test-suite/errors/pp_constant.i
@@ -0,0 +1,50 @@
+%module xxx
+
+/* Test preprocessor comments and their effect on line number reporting on later errors */
+
+#define A1 1234
+#define A2 1234 /*C comment*/
+#define A3 1234
+
+%constant int aaa=;
+
+#define B1 1234
+#define B2 1234 //C++ comment
+#define B3 1234
+
+%constant int bbb=;
+
+#define C1 1234
+#define C2 1234 /*multiline
+C
+comment */
+#define C3 1234
+
+%constant int ccc=;
+
+#define D1 1234
+#define /*C Comment*/ D2 1234
+#define D3 1234
+
+%constant int ddd=;
+
+#define E1 1234
+#/*C comment*/define E2 1234
+#define E3 1234
+
+%constant int eee=;
+
+#define F1 1234
+#define F2 1234 \
+// C comment
+#define F3 1234
+
+%constant int fff=;
+
+// Test macro ending in /, that is not a C comment terminator
+#define G1 1234
+#define G2 1234 /
+#define G3 1234
+
+%constant int ggg=;
+
diff --git a/Examples/test-suite/errors/pp_deprecated.i b/Examples/test-suite/errors/pp_deprecated.i
new file mode 100644
index 000000000..68f81317b
--- /dev/null
+++ b/Examples/test-suite/errors/pp_deprecated.i
@@ -0,0 +1,9 @@
+%module xxx
+
+
+%extern ext;
+
+#warning Print this warning
+
+#error This is an error
+
diff --git a/Examples/test-suite/errors/pp_illegal_argument.i b/Examples/test-suite/errors/pp_illegal_argument.i
new file mode 100644
index 000000000..13ffa4559
--- /dev/null
+++ b/Examples/test-suite/errors/pp_illegal_argument.i
@@ -0,0 +1,20 @@
+%module xxx
+
+
+%define MISSING_DOT1(a,
+b,
+..)
+xxx
+%enddef
+
+%define MISSING_DOT2(..)
+xxx
+%enddef
+
+%define BAD_ARGNAME(
+a,
+b{c
+)
+xxx
+%enddef
+
diff --git a/Examples/test-suite/errors/pp_macro_defined_unterminated.i b/Examples/test-suite/errors/pp_macro_defined_unterminated.i
new file mode 100644
index 000000000..bc44d07c6
--- /dev/null
+++ b/Examples/test-suite/errors/pp_macro_defined_unterminated.i
@@ -0,0 +1,6 @@
+%module xxx
+
+
+#if defined(a
+#endif
+
diff --git a/Examples/test-suite/errors/pp_macro_expansion.i b/Examples/test-suite/errors/pp_macro_expansion.i
new file mode 100644
index 000000000..e23a0da01
--- /dev/null
+++ b/Examples/test-suite/errors/pp_macro_expansion.i
@@ -0,0 +1,10 @@
+%module xxx
+
+/* Test line number reporting for multiple macro expansions */
+
+#define MACRO2(a, b)
+
+#define MACRO1(NAME) MACRO2(NAME,2,3)
+
+MACRO1(abc)
+
diff --git a/Examples/test-suite/errors/pp_macro_expansion_multiline.i b/Examples/test-suite/errors/pp_macro_expansion_multiline.i
new file mode 100644
index 000000000..b0777de60
--- /dev/null
+++ b/Examples/test-suite/errors/pp_macro_expansion_multiline.i
@@ -0,0 +1,32 @@
+%module xxx
+// Testing macros split over multiple lines - ensure the warning message for the ignored functions contain the correct line numbering
+
+#define MYMACRO(NAME, A, B, C) void NAME(int A, int B, int C);
+
+MYMACRO(funk, x,
+y,
+
+z
+)
+
+void foo(int *);
+void foo(const int *);
+
+%define MYSWIGMACRO(A, B, C)
+MYMACRO(funk1,
+ AA,
+ BB,
+ CC)
+MYMACRO(funk2,
+ AA,
+ BB,
+ CC)
+%enddef
+
+MYSWIGMACRO(xx,
+ yy,
+ zz)
+
+void bar(int *);
+void bar(const int *);
+
diff --git a/Examples/test-suite/errors/pp_macro_inline_unterminated.i b/Examples/test-suite/errors/pp_macro_inline_unterminated.i
new file mode 100644
index 000000000..67de0942c
--- /dev/null
+++ b/Examples/test-suite/errors/pp_macro_inline_unterminated.i
@@ -0,0 +1,11 @@
+%module xxx
+
+%define foo(a,x)
+int ii;
+%enddef
+
+%inline %{
+struct Struct {
+foo(2,
+};
+%}
diff --git a/Examples/test-suite/errors/pp_pragma.i b/Examples/test-suite/errors/pp_pragma.i
new file mode 100644
index 000000000..8d928690c
--- /dev/null
+++ b/Examples/test-suite/errors/pp_pragma.i
@@ -0,0 +1,6 @@
+%module xxx
+
+
+#pragma SWIG rubbish()
+
+
diff --git a/Examples/test-suite/errors/pp_variable_args.i b/Examples/test-suite/errors/pp_variable_args.i
new file mode 100644
index 000000000..c5f72fff9
--- /dev/null
+++ b/Examples/test-suite/errors/pp_variable_args.i
@@ -0,0 +1,10 @@
+%module xxx
+
+
+%define VARARGS_WRONG(a,
+x,
+...,
+ b)
+xxx
+%enddef
+
diff --git a/Examples/test-suite/evil_diamond.i b/Examples/test-suite/evil_diamond.i
index 7b2e9152f..a8d48b30b 100644
--- a/Examples/test-suite/evil_diamond.i
+++ b/Examples/test-suite/evil_diamond.i
@@ -6,7 +6,8 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C#, D & Java, PHP multiple inheritance
%inline %{
diff --git a/Examples/test-suite/evil_diamond_ns.i b/Examples/test-suite/evil_diamond_ns.i
index 515044007..0227b31ee 100644
--- a/Examples/test-suite/evil_diamond_ns.i
+++ b/Examples/test-suite/evil_diamond_ns.i
@@ -6,7 +6,8 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) Blah::spam; // Ruby, wrong class name - C#, D & Java, PHP multiple inheritance
%inline %{
namespace Blah {
diff --git a/Examples/test-suite/evil_diamond_prop.i b/Examples/test-suite/evil_diamond_prop.i
index 804ea66b4..2dac6eab7 100644
--- a/Examples/test-suite/evil_diamond_prop.i
+++ b/Examples/test-suite/evil_diamond_prop.i
@@ -6,6 +6,7 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME,
SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) spam; // Ruby, wrong class name - C# & Java, PHP multiple inheritance
%inline %{
diff --git a/Examples/test-suite/exception_order.i b/Examples/test-suite/exception_order.i
index 45a87e0c5..4dd13858a 100644
--- a/Examples/test-suite/exception_order.i
+++ b/Examples/test-suite/exception_order.i
@@ -2,6 +2,14 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME);
+#if defined(SWIGGO) && defined(SWIGGO_GCCGO)
+%{
+#ifdef __GNUC__
+#include <cxxabi.h>
+#endif
+%}
+#endif
+
%include "exception.i"
%{
@@ -23,6 +31,18 @@
SWIG_exception_fail(SWIG_RuntimeError,"postcatch unknown");
}
}
+#elif defined(SWIGGO) && defined(SWIGGO_GCCGO)
+%exception %{
+ try {
+ $action
+#ifdef __GNUC__
+ } catch (__cxxabiv1::__foreign_exception&) {
+ throw;
+#endif
+ } catch(...) {
+ SWIG_exception(SWIG_RuntimeError,"postcatch unknown");
+ }
+%}
#else
%exception {
try {
diff --git a/Examples/test-suite/global_namespace.i b/Examples/test-suite/global_namespace.i
index 7b575614f..37195c76b 100644
--- a/Examples/test-suite/global_namespace.i
+++ b/Examples/test-suite/global_namespace.i
@@ -58,3 +58,25 @@ struct TheEnumMethods {
}
%}
+%inline %{
+Klass1 getKlass1A() { return ::Klass1(); }
+::Klass1 getKlass1B() { return ::Klass1(); }
+
+Klass2 getKlass2A() { return ::Klass2(); }
+::Klass2 getKlass2B() { return ::Klass2(); }
+
+Klass3 getKlass3A() { return ::Klass3(); }
+::Klass3 getKlass3B() { return ::Klass3(); }
+
+Klass4 getKlass4A() { return ::Klass4(); }
+::Klass4 getKlass4B() { return ::Klass4(); }
+
+Klass5 getKlass5A() { return ::Klass5(); }
+::Klass5 getKlass5B() { return ::Klass5(); }
+
+Klass6 getKlass6A() { return ::Klass6(); }
+::Klass6 getKlass6B() { return ::Klass6(); }
+
+Klass7 getKlass7A() { return ::Klass7(); }
+::Klass7 getKlass7B() { return ::Klass7(); }
+%}
diff --git a/Examples/test-suite/go/char_binary_runme.go b/Examples/test-suite/go/char_binary_runme.go
new file mode 100644
index 000000000..50f2e121d
--- /dev/null
+++ b/Examples/test-suite/go/char_binary_runme.go
@@ -0,0 +1,25 @@
+package main
+
+import . "./char_binary"
+
+func main() {
+ t := NewTest()
+ if t.Strlen("hile") != 4 {
+ print(t.Strlen("hile"))
+ panic("bad multi-arg typemap")
+ }
+
+ if t.Strlen("hil\000") != 4 {
+ panic("bad multi-arg typemap")
+ }
+
+ // creating a raw char*
+ pc := New_pchar(5)
+ Pchar_setitem(pc, 0, 'h')
+ Pchar_setitem(pc, 1, 'o')
+ Pchar_setitem(pc, 2, 'l')
+ Pchar_setitem(pc, 3, 'a')
+ Pchar_setitem(pc, 4, 0)
+
+ Delete_pchar(pc)
+}
diff --git a/Examples/test-suite/guilescm/ext_test_external.cxx b/Examples/test-suite/guilescm/ext_test_external.cxx
index 4b65f4953..713e5d2d0 100644
--- a/Examples/test-suite/guilescm/ext_test_external.cxx
+++ b/Examples/test-suite/guilescm/ext_test_external.cxx
@@ -10,7 +10,7 @@ SCM test_create()
newobj = new A();
type = SWIG_TypeQuery("A *");
- result = SWIG_NewPointerObj(result, type, 1);
+ result = SWIG_NewPointerObj(newobj, type, 1);
return result;
#undef FUNC_NAME
diff --git a/Examples/test-suite/immutable.i b/Examples/test-suite/immutable_values.i
index ff5081e9c..1c1978661 100644
--- a/Examples/test-suite/immutable.i
+++ b/Examples/test-suite/immutable_values.i
@@ -1,6 +1,6 @@
// test to make sure setters are not generated for constants
-%module immutable
+%module immutable_values
%immutable;
diff --git a/Examples/test-suite/import_nomodule.i b/Examples/test-suite/import_nomodule.i
index a1ba9ad7a..4fd5cbf65 100644
--- a/Examples/test-suite/import_nomodule.i
+++ b/Examples/test-suite/import_nomodule.i
@@ -8,16 +8,16 @@
%import "import_nomodule.h"
-#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP)
+#if !defined(SWIGJAVA) && !defined(SWIGRUBY) && !defined(SWIGCSHARP) && !defined(SWIGD)
/**
* The proxy class does not have Bar derived from Foo, yet an instance of Bar
* can successfully be passed to a proxy function taking a Foo pointer (for some
* language modules).
*
- * This violation of the type system is not possible in Java and C# due to static
- * type checking. It's also not (currently) possible in Ruby, but this may be
- * fixable (needs more investigation).
+ * This violation of the type system is not possible in Java, C# and D due to
+ * static type checking. It's also not (currently) possible in Ruby, but this may
+ * be fixable (needs more investigation).
*/
%newobject create_Foo;
diff --git a/Examples/test-suite/inherit_target_language.i b/Examples/test-suite/inherit_target_language.i
index 20fb93fda..88801f3f6 100644
--- a/Examples/test-suite/inherit_target_language.i
+++ b/Examples/test-suite/inherit_target_language.i
@@ -1,4 +1,4 @@
-// Test using a target language specified base class, primarily for Java/C# and possibly other single inheritance languages
+// Test using a target language specified base class, primarily for Java/C#/D and possibly other single inheritance languages
// Note the multiple inheritance warnings don't appear because of the two techniques used in here: typemaps and %ignore
@@ -6,6 +6,8 @@
#if defined(SWIGJAVA)
# define csbase javabase
+#elif defined(SWIGD)
+# define csbase dbase
#endif
%pragma(csharp) moduleimports=%{
@@ -20,6 +22,10 @@ class TargetLanguageBase { public void targetLanguageBaseMethod() {} };
class TargetLanguageBase2 { public void targetLanguageBase2Method() {} };
%}
+%pragma(d) globalproxyimports=%{
+private class TargetLanguageBase { public void targetLanguageBaseMethod() {} };
+private class TargetLanguageBase2 { public void targetLanguageBase2Method() {} };
+%}
%typemap(csbase) SWIGTYPE "TargetLanguageBase"
diff --git a/Examples/test-suite/java/Makefile.in b/Examples/test-suite/java/Makefile.in
index ba225f6e9..1ba888fc1 100644
--- a/Examples/test-suite/java/Makefile.in
+++ b/Examples/test-suite/java/Makefile.in
@@ -7,8 +7,8 @@ JAVA = java
JAVAC = javac
SCRIPTSUFFIX = _runme.java
srcdir = @srcdir@
-top_srcdir = @top_srcdir@/..
-top_builddir = @top_builddir@/..
+top_srcdir = ../@top_srcdir@
+top_builddir = ../@top_builddir@
C_TEST_CASES = \
java_lib_arrays \
diff --git a/Examples/test-suite/java/char_binary_runme.java b/Examples/test-suite/java/char_binary_runme.java
new file mode 100644
index 000000000..9227f8617
--- /dev/null
+++ b/Examples/test-suite/java/char_binary_runme.java
@@ -0,0 +1,24 @@
+import char_binary.*;
+
+public class char_binary_runme {
+
+ static {
+ try {
+ System.loadLibrary("char_binary");
+ } 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[]) {
+ Test t = new Test();
+ byte[] hile = "hile".getBytes();
+ byte[] hil0 = "hil\0".getBytes();
+ if (t.strlen(hile) != 4)
+ throw new RuntimeException("bad multi-arg typemap");
+
+ if (t.strlen(hil0) != 4)
+ throw new RuntimeException("bad multi-arg typemap");
+ }
+}
diff --git a/Examples/test-suite/java/director_protected_runme.java b/Examples/test-suite/java/director_protected_runme.java
index 464b4d4d9..63ac03502 100644
--- a/Examples/test-suite/java/director_protected_runme.java
+++ b/Examples/test-suite/java/director_protected_runme.java
@@ -19,6 +19,7 @@ public class director_protected_runme {
Foo f = b.create();
director_protected_FooBar fb = new director_protected_FooBar();
director_protected_FooBar2 fb2 = new director_protected_FooBar2();
+ director_protected_FooBar3 fb3 = new director_protected_FooBar3();
{
String s = fb.used();
@@ -60,11 +61,34 @@ public class director_protected_runme {
if ( !Modifier.isProtected(method.getModifiers()) )
throw new RuntimeException("Foo::ping should be protected" );
+ method = b.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null);
+ if ( !Modifier.isProtected(method.getModifiers()) )
+ throw new RuntimeException("Bar::cheer should be protected" );
+
+ method = f.getClass().getDeclaredMethod("cheer", (java.lang.Class[])null);
+ if ( !Modifier.isProtected(method.getModifiers()) )
+ throw new RuntimeException("Foo::cheer should be protected" );
+
} catch (NoSuchMethodException n) {
- throw new RuntimeException("NoSuchmethodException caught. Test failed.");
+ throw new RuntimeException(n);
} catch (SecurityException s) {
throw new RuntimeException("SecurityException caught. Test failed.");
}
+
+ if (!fb3.cheer().equals("director_protected_FooBar3::cheer();"))
+ throw new RuntimeException("bad fb3::cheer");
+
+ if (!fb2.callping().equals("director_protected_FooBar2::ping();"))
+ throw new RuntimeException("bad fb2.callping");
+
+ if (!fb2.callcheer().equals("director_protected_FooBar2::pang();Bar::pong();Foo::pong();director_protected_FooBar2::ping();"))
+ throw new RuntimeException("bad fb2.callcheer");
+
+ if (!fb3.callping().equals("Bar::ping();"))
+ throw new RuntimeException("bad fb3.callping");
+
+ if (!fb3.callcheer().equals("director_protected_FooBar3::cheer();"))
+ throw new RuntimeException("bad fb3.callcheer");
}
}
@@ -83,3 +107,9 @@ class director_protected_FooBar2 extends Bar {
}
}
+class director_protected_FooBar3 extends Bar {
+ public String cheer() {
+ return "director_protected_FooBar3::cheer();";
+ }
+}
+
diff --git a/Examples/test-suite/java/global_namespace_runme.java b/Examples/test-suite/java/global_namespace_runme.java
index faab7d4ba..205e149b0 100644
--- a/Examples/test-suite/java/global_namespace_runme.java
+++ b/Examples/test-suite/java/global_namespace_runme.java
@@ -13,8 +13,38 @@ public class global_namespace_runme {
public static void main(String argv[]) {
- KlassMethods.methodA(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
- KlassMethods.methodB(new Klass1(), new Klass2(), new Klass3(), new Klass4(), new Klass5(), new Klass6(), new Klass7());
+ Klass1 k1 = new Klass1();
+ Klass2 k2 = new Klass2();
+ Klass3 k3 = new Klass3();
+ Klass4 k4 = new Klass4();
+ Klass5 k5 = new Klass5();
+ Klass6 k6 = new Klass6();
+ Klass7 k7 = new Klass7();
+
+ KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7);
+ KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7);
+
+ k1 = global_namespace.getKlass1A();
+ k2 = global_namespace.getKlass2A();
+ k3 = global_namespace.getKlass3A();
+ k4 = global_namespace.getKlass4A();
+ k5 = global_namespace.getKlass5A();
+ k6 = global_namespace.getKlass6A();
+ k7 = global_namespace.getKlass7A();
+
+ KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7);
+ KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7);
+
+ k1 = global_namespace.getKlass1B();
+ k2 = global_namespace.getKlass2B();
+ k3 = global_namespace.getKlass3B();
+ k4 = global_namespace.getKlass4B();
+ k5 = global_namespace.getKlass5B();
+ k6 = global_namespace.getKlass6B();
+ k7 = global_namespace.getKlass7B();
+
+ KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7);
+ KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7);
XYZMethods.methodA(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
XYZMethods.methodB(new XYZ1(), new XYZ2(), new XYZ3(), new XYZ4(), new XYZ5(), new XYZ6(), new XYZ7());
diff --git a/Examples/test-suite/java/pointer_reference_runme.java b/Examples/test-suite/java/pointer_reference_runme.java
index e8bd6800e..284951611 100644
--- a/Examples/test-suite/java/pointer_reference_runme.java
+++ b/Examples/test-suite/java/pointer_reference_runme.java
@@ -19,5 +19,8 @@ public class pointer_reference_runme {
Struct ss = new Struct(20);
pointer_reference.set(ss);
if (Struct.getInstance().getValue() != 20) throw new RuntimeException("set test failed");
+
+ if (pointer_reference.overloading(1) != 111) throw new RuntimeException("overload test 1 failed");
+ if (pointer_reference.overloading(ss) != 222) throw new RuntimeException("overload test 2 failed");
}
}
diff --git a/Examples/test-suite/java/preproc_line_file_runme.java b/Examples/test-suite/java/preproc_line_file_runme.java
new file mode 100644
index 000000000..c29cef680
--- /dev/null
+++ b/Examples/test-suite/java/preproc_line_file_runme.java
@@ -0,0 +1,68 @@
+import preproc_line_file.*;
+
+public class preproc_line_file_runme {
+
+ static {
+ try {
+ System.loadLibrary("preproc_line_file");
+ } 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 String FILENAME_WINDOWS = "..\\..\\..\\..\\Examples\\test-suite\\preproc_line_file.i";
+ public static String FILENAME_UNIX = "../../../../Examples/test-suite/preproc_line_file.i";
+ public static void main(String argv[]) throws Throwable
+ {
+ int myline = preproc_line_file.MYLINE;
+ int myline_adjusted = preproc_line_file.MYLINE_ADJUSTED;
+ if (myline != 4)
+ throw new RuntimeException("preproc failure");
+ if (myline + 100 + 1 != myline_adjusted)
+ throw new RuntimeException("preproc failure");
+
+ String myfile = preproc_line_file.MYFILE;
+ String myfile_adjusted = preproc_line_file.MYFILE_ADJUSTED;
+ if (!(myfile.equals(FILENAME_UNIX) || myfile.equals(FILENAME_WINDOWS)))
+ throw new RuntimeException("preproc failure");
+
+ if (!(myfile_adjusted.equals(FILENAME_UNIX + ".bak") || myfile_adjusted.equals(FILENAME_WINDOWS + ".bak")))
+ throw new RuntimeException("preproc failure");
+
+ if (!preproc_line_file.MY_STRINGNUM_A.equals("my15"))
+ throw new RuntimeException("preproc failed MY_STRINGNUM_A");
+
+ if (!preproc_line_file.MY_STRINGNUM_B.equals("my16"))
+ throw new RuntimeException("preproc failed MY_STRINGNUM_B");
+
+ if (preproc_line_file.getThing27() != -1)
+ throw new RuntimeException("preproc failure");
+
+ if (preproc_line_file.getThing28() != -2)
+ throw new RuntimeException("preproc failure");
+
+ if (preproc_line_file.MYLINE2 != 30)
+ throw new RuntimeException("preproc failure");
+
+ if (SillyStruct.LINE_NUMBER != 52)
+ throw new RuntimeException("preproc failure");
+
+ if (SillyMacroClass.LINE_NUM != 56)
+ throw new RuntimeException("preproc failure");
+
+ if (SillyMultipleMacroStruct.LINE_NUM != 81)
+ throw new RuntimeException("preproc failure");
+
+ if (preproc_line_file.INLINE_LINE != 87)
+ throw new RuntimeException("preproc failure");
+
+ String inlineFile = preproc_line_file.INLINE_FILE;
+ if (!(inlineFile.equals(FILENAME_UNIX) || inlineFile.equals(FILENAME_WINDOWS)))
+ throw new RuntimeException("preproc failure");
+
+ if (Slash.LINE_NUM != 93)
+ throw new RuntimeException("preproc failure");
+
+ }
+}
diff --git a/Examples/test-suite/java/rename_pcre_encoder_runme.java b/Examples/test-suite/java/rename_pcre_encoder_runme.java
new file mode 100644
index 000000000..cb843338b
--- /dev/null
+++ b/Examples/test-suite/java/rename_pcre_encoder_runme.java
@@ -0,0 +1,14 @@
+import rename_pcre_encoder.*;
+
+public class rename_pcre_encoder_runme {
+ static { System.loadLibrary("rename_pcre_encoder"); }
+
+ public static void main(String argv[])
+ {
+ SomeWidget w = new SomeWidget();
+ w.putBorderWidth(17);
+ if ( w.getBorderWidth() != 17 )
+ throw new RuntimeException(String.format("Border with should be 17, not %d",
+ w.getBorderWidth()));
+ }
+}
diff --git a/Examples/test-suite/java/rename_pcre_enum_runme.java b/Examples/test-suite/java/rename_pcre_enum_runme.java
new file mode 100644
index 000000000..a8bfef46a
--- /dev/null
+++ b/Examples/test-suite/java/rename_pcre_enum_runme.java
@@ -0,0 +1,26 @@
+import rename_pcre_enum.*;
+
+public class rename_pcre_enum_runme {
+ static { System.loadLibrary("rename_pcre_enum"); }
+
+ public static void main(String argv[])
+ {
+ Foo foo = Foo.First;
+ if ( foo == Foo.Second )
+ throw new RuntimeException("Enum values should be different");
+
+ // Check that Foo_Max enum element was ignored.
+ int numFooEnumElements = Foo.values().length;
+ if ( numFooEnumElements != 2 )
+ throw new RuntimeException(String.format("Enum should have 2 elements, not %d",
+ numFooEnumElements));
+
+ BoundaryCondition bc = BoundaryCondition.MaxMax;
+ if ( bc.ordinal() != 2 )
+ throw new RuntimeException("Wrong enum value");
+
+ Colour c = Colour.red;
+ if ( c == Colour.blue )
+ throw new RuntimeException("Enum values should be different");
+ }
+}
diff --git a/Examples/test-suite/java/rname_runme.java b/Examples/test-suite/java/rname_runme.java
index 7f2ab2f75..dac0a1ecf 100644
--- a/Examples/test-suite/java/rname_runme.java
+++ b/Examples/test-suite/java/rname_runme.java
@@ -30,7 +30,7 @@ public class rname_runme {
throw new RuntimeException("base.newname");
RenamedDerived derived = new RenamedDerived();
- derived.func(base, base, base);
+ derived.Xfunc(base, base, base);
if (!derived.newname(10.0).equals("Derived"))
throw new RuntimeException("derived.newname");
}
diff --git a/Examples/test-suite/java/smart_pointer_const_overload_runme.java b/Examples/test-suite/java/smart_pointer_const_overload_runme.java
new file mode 100644
index 000000000..bb4ae2c8f
--- /dev/null
+++ b/Examples/test-suite/java/smart_pointer_const_overload_runme.java
@@ -0,0 +1,99 @@
+import smart_pointer_const_overload.*;
+
+public class smart_pointer_const_overload_runme {
+ static int CONST_ACCESS = 1;
+ static int MUTABLE_ACCESS = 2;
+
+ static {
+ System.loadLibrary("smart_pointer_const_overload");
+ }
+
+ public static void test(Bar b, Foo f) {
+ Assert(f.getX() == 0);
+
+ // Test member variable get
+ Assert(b.getX() == 0);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test member variable set
+ b.setX(1);
+ Assert(f.getX() == 1);
+ Assert(f.getAccess() == MUTABLE_ACCESS);
+
+ // Test const method
+ Assert(b.getx() == 1);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test mutable method
+ b.setx(2);
+
+ Assert(f.getX() == 2);
+ Assert(f.getAccess() == MUTABLE_ACCESS);
+
+ // Test extended const method
+ Assert(b.getx2() == 2);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test extended mutable method
+ b.setx2(3);
+
+ Assert(f.getX() == 3);
+ Assert(f.getAccess() == MUTABLE_ACCESS);
+
+ // Test static method
+ b.stat();
+
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test const member
+ f.setAccess(MUTABLE_ACCESS);
+
+ Assert(b.getY() == 0);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test get through mutable pointer to const member
+ f.setAccess(MUTABLE_ACCESS);
+
+ Assert(smart_pointer_const_overload.get_int(b.getYp()) == 0);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test get through const pointer to mutable member
+ f.setX(4);
+ f.setAccess(MUTABLE_ACCESS);
+
+ Assert(smart_pointer_const_overload.get_int(b.getXp()) == 4);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test set through const pointer to mutable member
+ f.setAccess(MUTABLE_ACCESS);
+ smart_pointer_const_overload.set_int(b.getXp(), 5);
+
+ Assert(f.getX() == 5);
+ Assert(f.getAccess() == CONST_ACCESS);
+
+ // Test set pointer to const member
+ b.setYp(smart_pointer_const_overload.new_int(6));
+
+ Assert(f.getY() == 0);
+ Assert(smart_pointer_const_overload.get_int(f.getYp()) == 6);
+ Assert(f.getAccess() == MUTABLE_ACCESS);
+
+ smart_pointer_const_overload.delete_int(f.getYp());
+ }
+
+ public static void main(String argv[]) {
+ Foo f = new Foo();
+ Bar b = new Bar(f);
+
+ //Foo f2 = new Foo();
+ //Bar b2 = new Bar2(f2);
+
+ test(b, f);
+ //test(b2, f2);
+ }
+
+ public static void Assert(boolean b) {
+ if (!b)
+ throw new RuntimeException("Assertion failed");
+ }
+}
diff --git a/Examples/test-suite/java/typemap_arrays_runme.java b/Examples/test-suite/java/typemap_arrays_runme.java
new file mode 100644
index 000000000..1ca062f78
--- /dev/null
+++ b/Examples/test-suite/java/typemap_arrays_runme.java
@@ -0,0 +1,19 @@
+import typemap_arrays.*;
+
+public class typemap_arrays_runme {
+
+ static {
+ try {
+ System.loadLibrary("typemap_arrays");
+ } 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 (typemap_arrays.sumA(null) != 60)
+ throw new RuntimeException("Sum is wrong");
+ }
+}
+
diff --git a/Examples/test-suite/java/wallkw_runme.java b/Examples/test-suite/java/wallkw_runme.java
index 028c2a32f..7695cda24 100644
--- a/Examples/test-suite/java/wallkw_runme.java
+++ b/Examples/test-suite/java/wallkw_runme.java
@@ -19,7 +19,9 @@ public class wallkw_runme {
throw new RuntimeException("delegate keyword fail");
if (!wallkw._pass().equals("pass"))
throw new RuntimeException("pass keyword fail");
- if (!wallkw.C_alias().equals("alias"))
+ if (!wallkw._alias().equals("alias"))
throw new RuntimeException("alias keyword fail");
+ if (!wallkw.C_rescue().equals("rescue"))
+ throw new RuntimeException("rescue keyword fail");
}
}
diff --git a/Examples/test-suite/li_boost_shared_ptr.i b/Examples/test-suite/li_boost_shared_ptr.i
index f92df23a9..3d474ec00 100644
--- a/Examples/test-suite/li_boost_shared_ptr.i
+++ b/Examples/test-suite/li_boost_shared_ptr.i
@@ -34,7 +34,7 @@
# define SWIG_SHARED_PTR_NAMESPACE SwigBoost
#endif
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD)
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif
@@ -45,6 +45,7 @@
%shared_ptr(Space::KlassDerived)
%shared_ptr(Space::Klass2ndDerived)
%shared_ptr(Space::Klass3rdDerived)
+%shared_ptr(IgnoredMultipleInheritBase) // IgnoredMultipleInheritBase not actually used in any wrapped functions, so this isn't entirely necessary and warning 520 could instead have been suppressed.
#endif
diff --git a/Examples/test-suite/li_boost_shared_ptr_bits.i b/Examples/test-suite/li_boost_shared_ptr_bits.i
index 610edb4b4..2232b6cf6 100644
--- a/Examples/test-suite/li_boost_shared_ptr_bits.i
+++ b/Examples/test-suite/li_boost_shared_ptr_bits.i
@@ -1,6 +1,6 @@
%module li_boost_shared_ptr_bits
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGPYTHON) || defined(SWIGD)
#define SHARED_PTR_WRAPPERS_IMPLEMENTED
#endif
diff --git a/Examples/test-suite/li_std_combinations.i b/Examples/test-suite/li_std_combinations.i
index 9acc8f23d..57f945bcd 100644
--- a/Examples/test-suite/li_std_combinations.i
+++ b/Examples/test-suite/li_std_combinations.i
@@ -14,7 +14,7 @@
%template(VectorVectorString) std::vector< std::vector<std::string> >;
%template(PairIntPairIntString) std::pair< int, std::pair<int, std::string> >;
-#if defined(SWIGCSHARP)
+#if defined(SWIGCSHARP) || defined(SWIGD)
// Checks macro containing a type with a comma
SWIG_STD_VECTOR_ENHANCED(std::pair< double, std::string >)
#endif
diff --git a/Examples/test-suite/li_typemaps_apply.i b/Examples/test-suite/li_typemaps_apply.i
new file mode 100644
index 000000000..ecb3f87b6
--- /dev/null
+++ b/Examples/test-suite/li_typemaps_apply.i
@@ -0,0 +1,46 @@
+%module li_typemaps_apply
+
+// Test %apply to global primitive type references/pointers to make sure the return types are still okay... mainly for the strongly typed languages.
+
+%include "typemaps.i"
+
+#if !defined(SWIGJAVA) // Needs asymmetric type marshalling support for this testcase to work
+
+%define TMAPS(PRIMTYPE, NAME)
+%apply PRIMTYPE *INPUT { PRIMTYPE * }
+%apply PRIMTYPE &INPUT { PRIMTYPE & }
+%inline %{
+PRIMTYPE *input_ptr_##NAME(PRIMTYPE *v) { static PRIMTYPE stat; stat = *v; return &stat; }
+PRIMTYPE &input_ref_##NAME(PRIMTYPE &v) { static PRIMTYPE stat; stat = v; return stat; }
+%}
+
+%apply PRIMTYPE *OUTPUT { PRIMTYPE * }
+%apply PRIMTYPE &OUTPUT { PRIMTYPE & }
+%inline %{
+PRIMTYPE *output_ptr_##NAME(PRIMTYPE x, PRIMTYPE *v) { static PRIMTYPE stat; stat = x; *v = x; return &stat; }
+PRIMTYPE &output_ref_##NAME(PRIMTYPE x, PRIMTYPE &v) { static PRIMTYPE stat; stat = x; v = x; return stat; }
+%}
+
+%apply PRIMTYPE *INOUT { PRIMTYPE * }
+%apply PRIMTYPE &INOUT { PRIMTYPE & }
+%inline %{
+PRIMTYPE *inout_ptr_##NAME(PRIMTYPE *v) { static PRIMTYPE stat; stat = *v; *v = *v; return &stat; }
+PRIMTYPE &inout_ref_##NAME(PRIMTYPE &v) { static PRIMTYPE stat; stat = v; v = v; return stat; }
+%}
+%enddef
+
+TMAPS(bool, bool)
+TMAPS(int, int)
+TMAPS(short, short)
+TMAPS(long, long)
+TMAPS(unsigned int, uint)
+TMAPS(unsigned short, ushort)
+TMAPS(unsigned long, ulong)
+TMAPS(unsigned char, uchar)
+TMAPS(signed char, schar)
+TMAPS(float, float)
+TMAPS(double, double)
+TMAPS(long long, longlong)
+TMAPS(unsigned long long, ulonglong)
+
+#endif
diff --git a/Examples/test-suite/lua/pointer_reference_runme.lua b/Examples/test-suite/lua/pointer_reference_runme.lua
index 959d5a2a3..428c76998 100644
--- a/Examples/test-suite/lua/pointer_reference_runme.lua
+++ b/Examples/test-suite/lua/pointer_reference_runme.lua
@@ -9,3 +9,5 @@ ss = pointer_reference.Struct(20);
pointer_reference.set(ss);
assert(pointer_reference.Struct_instance.value == 20)
+assert(pointer_reference.overloading(1) == 111)
+assert(pointer_reference.overloading(ss) == 222)
diff --git a/Examples/test-suite/member_funcptr_galore.i b/Examples/test-suite/member_funcptr_galore.i
new file mode 100644
index 000000000..cc626bfc4
--- /dev/null
+++ b/Examples/test-suite/member_funcptr_galore.i
@@ -0,0 +1,83 @@
+%module member_funcptr_galore
+
+%inline %{
+
+namespace FunkSpace {
+struct Funktions {
+ int addByValue(const int &a, int b) { return a+b; }
+ int * addByPointer(const int &a, int b) { static int val; val = a+b; return &val; }
+ int & addByReference(const int &a, int b) { static int val; val = a+b; return val; }
+};
+}
+
+template <typename T> struct Thing {};
+namespace Space {
+class Shape {
+public:
+ double x, y;
+ double *z;
+
+ void move(double dx, double dy);
+ virtual double area(Shape &ref, int & (FunkSpace::Funktions::*d)(const int &, int)) { return 0.0; }
+ virtual double abc(Thing<short> ts, Thing< const Space::Shape * > tda[]) { return 0.0; }
+};
+}
+
+extern double do_op(Space::Shape *s, double (Space::Shape::*m)(void));
+
+/* Functions that return member pointers */
+
+extern double (Space::Shape::*areapt())(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int));
+extern double (Space::Shape::*abcpt())(Thing<short>, Thing< const Space::Shape * > tda[]);
+
+/* Global variables that are member pointers */
+extern double (Space::Shape::*areavar)(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int));
+extern double (Space::Shape::*abcvar)(Thing<short>, Thing< const Space::Shape * >[]);
+
+%}
+
+%{
+void Space::Shape::move(double dx, double dy) {
+ x += dx;
+ y += dy;
+}
+
+double do_op(Space::Shape *s, double (Space::Shape::*m)(void)) {
+ return (s->*m)();
+}
+
+double (Space::Shape::*areapt(Space::Shape &ref, int & (FunkSpace::Funktions::*d)(const int &, int)))(Space::Shape &, int & (FunkSpace::Funktions::*d)(const int &, int)) {
+ return &Space::Shape::area;
+}
+
+double (Space::Shape::*abcpt())(Thing<short>, Thing< const Space::Shape * >[]) {
+ return &Space::Shape::abc;
+}
+
+/* Member pointer variables */
+double (Space::Shape::*areavar)(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int)) = &Space::Shape::area;
+double (Space::Shape::*abcvar)(Thing<short>, Thing< const Space::Shape * >[]) = &Space::Shape::abc;
+%}
+
+
+/* Some constants */
+%constant double (Space::Shape::*AREAPT)(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int)) = &Space::Shape::area;
+%constant double (Space::Shape::*PERIMPT)(Thing<short>, Thing< const Space::Shape * >[]) = &Space::Shape::abc;
+%constant double (Space::Shape::*NULLPT)(void) = 0;
+
+%inline %{
+
+int call1(int (FunkSpace::Funktions::*d)(const int &, int), int a, int b) { FunkSpace::Funktions f; return (f.*d)(a, b); }
+int call2(int * (FunkSpace::Funktions::*d)(const int &, int), int a, int b) { FunkSpace::Funktions f; return *(f.*d)(a, b); }
+int call3(int & (FunkSpace::Funktions::*d)(const int &, int), int a, int b) { FunkSpace::Funktions f; return (f.*d)(a, b); }
+%}
+
+%constant int (FunkSpace::Funktions::*ADD_BY_VALUE)(const int &, int) = &FunkSpace::Funktions::addByValue;
+%constant int * (FunkSpace::Funktions::*ADD_BY_POINTER)(const int &, int) = &FunkSpace::Funktions::addByPointer;
+%constant int & (FunkSpace::Funktions::*ADD_BY_REFERENCE)(const int &, int) = &FunkSpace::Funktions::addByReference;
+
+%inline %{
+// parameter that is a member pointer containing a function ptr, urgh :)
+int unreal1(double (Space::Shape::*memptr)(Space::Shape &, int & (FunkSpace::Funktions::*)(const int &, int))) { return 0; }
+int unreal2(double (Space::Shape::*memptr)(Thing<short>)) { return 0; }
+%}
diff --git a/Examples/test-suite/minherit2.i b/Examples/test-suite/minherit2.i
index 1bca4fc48..7d470d30e 100644
--- a/Examples/test-suite/minherit2.i
+++ b/Examples/test-suite/minherit2.i
@@ -1,16 +1,18 @@
%module minherit2
-// A multiple inheritance example, mainly for Java and C#.
-// The example shows how it is possible to turn C++ abstract base classes into Java/C# interface.
+// A multiple inheritance example, mainly for Java, C# and D.
+// The example shows how it is possible to turn C++ abstract base classes into
+// Java/C#/D interfaces.
// In the future, all this trouble might be more automated.
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
SWIGWARN_RUBY_MULTIPLE_INHERITANCE,
SWIGWARN_PHP_MULTIPLE_INHERITANCE) RemoteMpe;
-#if defined(SWIGJAVA) || defined(SWIGCSHARP)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
#if defined(SWIGCSHARP)
#define javaclassmodifiers csclassmodifiers
@@ -22,6 +24,21 @@
#define javabase csbase
#endif
+#if defined(SWIGD)
+#define javaclassmodifiers dclassmodifiers
+#define javabody dbody
+#define javafinalize ddestructor
+#define javadestruct ddispose
+#define javaout dout
+#define javainterfaces dinterfaces
+#define javabase dbase
+
+%typemap(dimports) RemoteMpe %{
+$importtype(IRemoteSyncIO)
+$importtype(IRemoteAsyncIO)
+%}
+#endif
+
// Modify multiple inherited base classes into inheriting interfaces
%typemap(javainterfaces) RemoteMpe "IRemoteSyncIO, IRemoteAsyncIO";
%typemap(javabase, replace="1") RemoteMpe "";
@@ -51,6 +68,12 @@
// Features are inherited by derived classes, so override this
%csmethodmodifiers RemoteMpe::syncmethod "public"
%csmethodmodifiers RemoteMpe::asyncmethod "public"
+#elif defined(SWIGD)
+%dmethodmodifiers IRemoteSyncIO::syncmethod "";
+%dmethodmodifiers IRemoteAsyncIO::asyncmethod "";
+// Features are inherited by derived classes, so override this
+%dmethodmodifiers RemoteMpe::syncmethod "public"
+%dmethodmodifiers RemoteMpe::asyncmethod "public"
#endif
#endif
diff --git a/Examples/test-suite/multiple_inheritance.i b/Examples/test-suite/multiple_inheritance.i
index 1fc68eef9..044345020 100644
--- a/Examples/test-suite/multiple_inheritance.i
+++ b/Examples/test-suite/multiple_inheritance.i
@@ -5,11 +5,13 @@ It tests basic multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; /* C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; /* C#, D, Java, PHP multiple inheritance */
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBarSpam; /* C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBarSpam; /* C#, D, Java, PHP multiple inheritance */
%inline %{
diff --git a/Examples/test-suite/namespace_class.i b/Examples/test-suite/namespace_class.i
index 7dc9139cd..aea5362d1 100644
--- a/Examples/test-suite/namespace_class.i
+++ b/Examples/test-suite/namespace_class.i
@@ -2,6 +2,10 @@
%warnfilter(SWIGWARN_PARSE_NAMED_NESTED_CLASS) Ala::Ola;
+#ifdef SWIGD
+%warnfilter(SWIGWARN_IGNORE_OPERATOR_LT);
+#endif
+
%inline %{
template<class T> void foobar(T t) {}
namespace test {
diff --git a/Examples/test-suite/octave/primitive_types_runme.m b/Examples/test-suite/octave/primitive_types_runme.m
deleted file mode 100644
index 568e3511e..000000000
--- a/Examples/test-suite/octave/primitive_types_runme.m
+++ /dev/null
@@ -1,402 +0,0 @@
-primitive_types
-
-var_init();
-
-# assigning globals calls
-cvar.var_bool = sct_bool;
-cvar.var_schar = sct_schar;
-cvar.var_uchar = sct_uchar;
-cvar.var_int = sct_int;
-cvar.var_uint = sct_uint;
-cvar.var_short = sct_short;
-cvar.var_ushort = sct_ushort;
-cvar.var_long = sct_long;
-cvar.var_ulong = sct_ulong;
-cvar.var_llong = sct_llong;
-cvar.var_ullong = sct_ullong;
-cvar.var_char = sct_char;
-cvar.var_pchar = sct_pchar;
-cvar.var_pcharc = sct_pcharc;
-cvar.var_pint = sct_pint;
-cvar.var_sizet = sct_sizet;
-cvar.var_hello = sct_hello;
-cvar.var_myint = sct_myint;
-cvar.var_namet = def_namet;
-cvar.var_parami = sct_parami;
-cvar.var_paramd = sct_paramd;
-cvar.var_paramc = sct_paramc;
-
-v_check();
-
-function octerror(name, val, cte)
- name, val, cte
- error
-endfunction
-
-if cvar.var_bool != cct_bool:
-octerror("bool", cvar.var_bool, cct_bool)
-endif
-if cvar.var_schar != cct_schar:
-octerror("schar", cvar.var_schar, cct_schar)
-endif
-if cvar.var_uchar != cct_uchar:
- octerror("uchar", cvar.var_uchar, cct_uchar)
-endif
-if cvar.var_int != cct_int:
- octerror("int", cvar.var_int, cct_int)
-endif
-if cvar.var_uint != cct_uint:
- octerror("uint", cvar.var_uint, cct_uint)
-endif
-if cvar.var_short != cct_short:
- octerror("short", cvar.var_short, cct_short)
-endif
-if cvar.var_ushort != cct_ushort:
- octerror("ushort", cvar.var_ushort, cct_ushort)
-endif
-if cvar.var_long != cct_long:
- octerror("long", cvar.var_long, cct_long)
-endif
-if cvar.var_ulong != cct_ulong:
- octerror("ulong", cvar.var_ulong, cct_ulong)
-endif
-if cvar.var_llong != cct_llong:
- octerror("llong", cvar.var_llong, cct_llong)
-endif
-if cvar.var_ullong != cct_ullong:
- octerror("ullong", cvar.var_ullong, cct_ullong)
-endif
-if cvar.var_char != cct_char:
- octerror("char", cvar.var_char, cct_char)
-endif
-if cvar.var_pchar != cct_pchar:
- octerror("pchar", cvar.var_pchar, cct_pchar)
-endif
-if cvar.var_pcharc != cct_pcharc:
- octerror("pchar", cvar.var_pcharc, cct_pcharc)
-endif
-if cvar.var_pint != cct_pint:
- octerror("pint", cvar.var_pint, cct_pint)
-endif
-if cvar.var_sizet != cct_sizet:
- octerror("sizet", cvar.var_sizet, cct_sizet)
-endif
-if cvar.var_hello != cct_hello:
- octerror("hello", cvar.var_hello, cct_hello)
-endif
-if cvar.var_myint != cct_myint:
- octerror("myint", cvar.var_myint, cct_myint)
-endif
-if cvar.var_namet != def_namet:
- octerror("name", cvar.var_namet, def_namet)
-endif
-
-
-function OctTest()
- self=subclass(TestDirector);
- self.ident=@(self,x) x;
-
- self.vval_bool=@(self, x) self.ident(x);
- self.vval_schar=@(self, x) self.ident(x);
- self.vval_uchar=@(self, x) self.ident(x);
- self.vval_int=@(self, x) self.ident(x);
- self.vval_uint=@(self, x) self.ident(x);
- self.vval_short=@(self, x) self.ident(x);
- self.vval_ushort=@(self, x) self.ident(x);
- self.vval_long=@(self, x) self.ident(x);
- self.vval_ulong=@(self, x) self.ident(x);
- self.vval_llong=@(self, x) self.ident(x);
- self.vval_ullong=@(self, x) self.ident(x);
- self.vval_float=@(self, x) self.ident(x);
- self.vval_double=@(self, x) self.ident(x);
- self.vval_char=@(self, x) self.ident(x);
- self.vval_pchar=@(self, x) self.ident(x);
- self.vval_pcharc=@(self, x) self.ident(x);
- self.vval_pint=@(self, x) self.ident(x);
- self.vval_sizet=@(self, x) self.ident(x);
- self.vval_hello=@(self, x) self.ident(x);
- self.vval_myint=@(self, x) self.ident(x);
-
- self.vref_bool=@(self, x) self.ident(x);
- self.vref_schar=@(self, x) self.ident(x);
- self.vref_uchar=@(self, x) self.ident(x);
- self.vref_int=@(self, x) self.ident(x);
- self.vref_uint=@(self, x) self.ident(x);
- self.vref_short=@(self, x) self.ident(x);
- self.vref_ushort=@(self, x) self.ident(x);
- self.vref_long=@(self, x) self.ident(x);
- self.vref_ulong=@(self, x) self.ident(x);
- self.vref_llong=@(self, x) self.ident(x);
- self.vref_ullong=@(self, x) self.ident(x);
- self.vref_float=@(self, x) self.ident(x);
- self.vref_double=@(self, x) self.ident(x);
- self.vref_char=@(self, x) self.ident(x);
- self.vref_pchar=@(self, x) self.ident(x);
- self.vref_pcharc=@(self, x) self.ident(x);
- self.vref_pint=@(self, x) self.ident(x);
- self.vref_sizet=@(self, x) self.ident(x);
- self.vref_hello=@(self, x) self.ident(x);
- self.vref_myint=@(self, x) self.ident(x);
-endfunction
-
-
-t = Test();
-p = OctTest();
-
-
-# internal call check
-if (t.c_check() != p.c_check())
- error, "bad director"
-endif
-
-p.var_bool = p.stc_bool;
-p.var_schar = p.stc_schar;
-p.var_uchar = p.stc_uchar;
-p.var_int = p.stc_int;
-p.var_uint = p.stc_uint;
-p.var_short = p.stc_short;
-p.var_ushort = p.stc_ushort;
-p.var_long = p.stc_long;
-p.var_ulong = p.stc_ulong;
-p.var_llong = p.stc_llong;
-p.var_ullong = p.stc_ullong;
-p.var_char = p.stc_char;
-p.var_pchar = sct_pchar;
-p.var_pcharc = sct_pcharc;
-p.var_pint = sct_pint;
-p.var_sizet = sct_sizet;
-p.var_hello = sct_hello;
-p.var_myint = sct_myint;
-p.var_namet = def_namet;
-p.var_parami = sct_parami;
-p.var_paramd = sct_paramd;
-p.var_paramc = sct_paramc;
-
-p.v_check();
-
-t.var_bool = t.stc_bool;
-t.var_schar = t.stc_schar;
-t.var_uchar = t.stc_uchar;
-t.var_int = t.stc_int;
-t.var_uint = t.stc_uint;
-t.var_short = t.stc_short;
-t.var_ushort = t.stc_ushort;
-t.var_long = t.stc_long;
-t.var_ulong = t.stc_ulong;
-t.var_llong = t.stc_llong;
-t.var_ullong = t.stc_ullong;
-t.var_char = t.stc_char;
-t.var_pchar = sct_pchar;
-t.var_pcharc = sct_pcharc;
-t.var_pint = sct_pint;
-t.var_sizet = sct_sizet;
-t.var_hello = sct_hello;
-t.var_myint = sct_myint;
-t.var_namet = def_namet;
-t.var_parami = sct_parami;
-t.var_paramd = sct_paramd;
-t.var_paramc = sct_paramc;
-
-t.v_check();
-
-# this value contains a '0' char!
-if (def_namet != 'ho\0la')
- error
-endif
-
-t.var_namet = def_namet;
-if (t.var_namet != def_namet)
- error
-endif
-
-t.var_namet = 'holac';
-
-if (t.var_namet != 'holac')
- error
-endif
-
-t.var_namet = 'hol';
-
-if (t.var_namet != 'hol')
- error
-endif
-
-if (t.strlen('hile') != 4)
- error
-endif
-
-if (t.strlen('hil\0') != 4)
- error
-endif
-
-cvar.var_char = '\0';
-if (cvar.var_char != '\0')
- error
-endif
-
-cvar.var_char = 0;
-if (cvar.var_char != '\0')
- error
-endif
-
-cvar.var_namet = '\0';
-if (cvar.var_namet != '')
- error
-endif
-
-cvar.var_namet = '';
-if (cvar.var_namet != '')
- error, "bad char empty case"
-endif
-
-cvar.var_pchar = None;
-if (cvar.var_pchar != None)
- error, "bad None case"
-endif
-
-cvar.var_pchar = '';
-if (cvar.var_pchar != '')
- error
-endif
-
-cvar.var_pcharc = None;
-if (cvar.var_pcharc != None)
- error
-endif
-
-cvar.var_pcharc = '';
-if (cvar.var_pcharc != '')
- error
-endif
-
-#
-# creating a raw char*
-#
-pc = new_pchar(5);
-pchar_setitem(pc, 0, 'h');
-pchar_setitem(pc, 1, 'o');
-pchar_setitem(pc, 2, 'l');
-pchar_setitem(pc, 3, 'a');
-pchar_setitem(pc, 4, 0);
-
-
-if (t.strlen(pc) != 4)
- error
-endif
-
-cvar.var_pchar = pc;
-if (cvar.var_pchar != "hola")
- error
-endif
-
-cvar.var_namet = pc;
-if (cvar.var_namet != "hola")
- error
-endif
-
-delete_pchar(pc);
-
-#
-# Now when things should fail
-#
-
-try
- error = 0;
- a = t.var_uchar;
- t.var_uchar = 10000;
- err = 1;
-catch
- if (a != t.var_uchar)
- err = 1;
- endif
-end_try_catch
-
-if (err)
- error
-endif
-
-try
- err = 0;
- a = t.var_char;
- t.var_char = '23';
- err = 1;
-catch
- if (a != t.var_char)
- error = 1
- endif
-end_try_catch
-if (err)
- error
-endif
-
-try
- err = 0
- a = t.var_uint
- t.var_uint = -1
- err = 1;
-catch
- if a != t.var_uint:
- err = 1;
- endif
-end_try_catch
-if (err)
- error
-endif
-
-#
-#
-try
- err = 0;
- a = t.var_namet;
- t.var_namet = '123456';
- err = 1;
-catch
- if (a != t.var_namet)
- err = 1;
- endif
-end_try_catch
-if (err)
- error
-endif
-
-#
-#
-#
-t2 = p.vtest(t);
-if (t.var_namet != t2.var_namet)
- error
-endif
-
-
-if (cvar.fixsize != 'ho\0la\0\0\0')
- error
-endif
-
-cvar.fixsize = 'ho';
-if (cvar.fixsize != 'ho\0\0\0\0\0\0')
- error
-endif
-
-
-f = Foo(3);
-f1 = fptr_val(f);
-f2 = fptr_ref(f);
-if (f1._a != f2._a)
- error
-endif
-
-v = char_foo(1,3);
-if (v !=3)
- error
-endif
-
-s = char_foo(1,"hello");
-if (s !="hello")
- error
-endif
-
-
-v = SetPos(1,3);
-if (v !=4)
- error
-endif
diff --git a/Examples/test-suite/samename_runme.m b/Examples/test-suite/octave/samename_runme.m
index a3864cfc8..a3864cfc8 100644
--- a/Examples/test-suite/samename_runme.m
+++ b/Examples/test-suite/octave/samename_runme.m
diff --git a/Examples/test-suite/operator_overload.i b/Examples/test-suite/operator_overload.i
index 80facff76..006662109 100644
--- a/Examples/test-suite/operator_overload.i
+++ b/Examples/test-suite/operator_overload.i
@@ -79,6 +79,12 @@ see bottom for a set of possible tests
%}
#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.
+%warnfilter(SWIGWARN_IGNORE_OPERATOR_PLUSPLUS, SWIGWARN_IGNORE_OPERATOR_MINUSMINUS);
+#endif
+
%rename(IntCast) operator int();
%rename(DoubleCast) operator double();
diff --git a/Examples/test-suite/operator_overload_break.i b/Examples/test-suite/operator_overload_break.i
index 9c6927bb0..f5f3c1a46 100644
--- a/Examples/test-suite/operator_overload_break.i
+++ b/Examples/test-suite/operator_overload_break.i
@@ -1,6 +1,6 @@
%module operator_overload_break
-#if defined(SWIGPYTHON)
+#if defined(SWIGPYTHON) || defined(SWIGD)
%warnfilter(SWIGWARN_IGNORE_OPERATOR_PLUSPLUS);
#endif
diff --git a/Examples/test-suite/operbool.i b/Examples/test-suite/operbool.i
index 793c0174e..ee8c889e9 100644
--- a/Examples/test-suite/operbool.i
+++ b/Examples/test-suite/operbool.i
@@ -1,6 +1,6 @@
%module operbool
-%rename(operbool) operator bool();
+%rename(operator_bool) operator bool();
%inline %{
class Test {
diff --git a/Examples/test-suite/perl5/char_binary_runme.pl b/Examples/test-suite/perl5/char_binary_runme.pl
new file mode 100755
index 000000000..4c50ee700
--- /dev/null
+++ b/Examples/test-suite/perl5/char_binary_runme.pl
@@ -0,0 +1,32 @@
+use strict;
+use warnings;
+use Test::More tests => 7;
+BEGIN { use_ok('char_binary') }
+require_ok('char_binary');
+
+my $t = char_binary::Test->new();
+
+is($t->strlen('hile'), 4, "string typemap");
+
+is($t->strlen("hil\0"), 4, "string typemap");
+
+#
+# creating a raw char*
+#
+my $pc = char_binary::new_pchar(5);
+char_binary::pchar_setitem($pc, 0, 'h');
+char_binary::pchar_setitem($pc, 1, 'o');
+char_binary::pchar_setitem($pc, 2, 'l');
+char_binary::pchar_setitem($pc, 3, 'a');
+char_binary::pchar_setitem($pc, 4, 0);
+
+
+is($t->strlen($pc), 4, "string typemap");
+
+$char_binary::var_pchar = $pc;
+is($char_binary::var_pchar, "hola", "pointer case");
+
+$char_binary::var_namet = $pc;
+is($char_binary::var_namet, "hola", "pointer case");
+
+char_binary::delete_pchar($pc);
diff --git a/Examples/test-suite/perl5/primitive_types_runme.pl b/Examples/test-suite/perl5/primitive_types_runme.pl
index 6d7b05d8d..31604ad06 100755
--- a/Examples/test-suite/perl5/primitive_types_runme.pl
+++ b/Examples/test-suite/perl5/primitive_types_runme.pl
@@ -1,6 +1,6 @@
use strict;
use warnings;
-use Test::More tests => 54;
+use Test::More tests => 51;
BEGIN { use_ok('primitive_types') }
require_ok('primitive_types');
@@ -179,11 +179,6 @@ $t->{var_namet} = 'hol';
is($t->{var_namet}, 'hol', "namet");
-is($t->strlen('hile'), 4, "string typemap");
-
-is($t->strlen("hil\0"), 4, "string typemap");
-
-
$primitive_types::var_char = "\0";
is($primitive_types::var_char, "\0", "char '0' case");
@@ -220,8 +215,6 @@ primitive_types::pchar_setitem($pc, 3, 'a');
primitive_types::pchar_setitem($pc, 4, 0);
-is($t->strlen($pc), 4, "string typemap");
-
$primitive_types::var_pchar = $pc;
is($primitive_types::var_pchar, "hola", "pointer case");
diff --git a/Examples/test-suite/php/director_protected_runme.php b/Examples/test-suite/php/director_protected_runme.php
index 73bcba1fd..9d47ef658 100644
--- a/Examples/test-suite/php/director_protected_runme.php
+++ b/Examples/test-suite/php/director_protected_runme.php
@@ -26,10 +26,17 @@ class FooBar2 extends Bar {
}
}
+class FooBar3 extends Bar {
+ function cheer() {
+ return "FooBar3::cheer();";
+ }
+}
+
$b = new Bar();
$f = $b->create();
$fb = new FooBar();
$fb2 = new FooBar2();
+$fb3 = new FooBar3();
check::equal($fb->used(), "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::used");
@@ -42,7 +49,7 @@ check::equal($f->pong(), "Bar::pong();Foo::pong();Bar::ping();", "bad Foo::pong"
check::equal($fb->pong(), "Bar::pong();Foo::pong();FooBar::ping();", "bad FooBar::pong");
$method = new ReflectionMethod('Bar', 'ping');
-check::equal($method->isProtected(), true, "Boo::ping should be protected");
+check::equal($method->isProtected(), true, "Foo::ping should be protected");
$method = new ReflectionMethod('Foo', 'ping');
check::equal($method->isProtected(), true, "Foo::ping should be protected");
@@ -50,5 +57,17 @@ check::equal($method->isProtected(), true, "Foo::ping should be protected");
$method = new ReflectionMethod('FooBar', 'pang');
check::equal($method->isProtected(), true, "FooBar::pang should be protected");
+$method = new ReflectionMethod('Bar', 'cheer');
+check::equal($method->isProtected(), true, "Bar::cheer should be protected");
+
+$method = new ReflectionMethod('Foo', 'cheer');
+check::equal($method->isProtected(), true, "Foo::cheer should be protected");
+
+check::equal($fb3->cheer(), "FooBar3::cheer();", "bad fb3::pong");
+check::equal($fb2->callping(), "FooBar2::ping();", "bad fb2::callping");
+check::equal($fb2->callcheer(), "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();", "bad fb2::callcheer");
+check::equal($fb3->callping(), "Bar::ping();", "bad fb3::callping");
+check::equal($fb3->callcheer(), "FooBar3::cheer();", "bad fb3::callcheer");
+
check::done();
?>
diff --git a/Examples/test-suite/php/pointer_reference_runme.php b/Examples/test-suite/php/pointer_reference_runme.php
index 782760a37..52946177e 100644
--- a/Examples/test-suite/php/pointer_reference_runme.php
+++ b/Examples/test-suite/php/pointer_reference_runme.php
@@ -11,5 +11,8 @@ pointer_reference::set($ss);
$i = Struct::instance();
check::equal($i->value, 20, "pointer_reference::set() failed");
+check::equal(pointer_reference::overloading(1), 111, "overload test 1 failed");
+check::equal(pointer_reference::overloading($ss), 222, "overload test 2 failed");
+
check::done();
?>
diff --git a/Examples/test-suite/pointer_reference.i b/Examples/test-suite/pointer_reference.i
index c57a32374..b9e126fd4 100644
--- a/Examples/test-suite/pointer_reference.i
+++ b/Examples/test-suite/pointer_reference.i
@@ -35,6 +35,12 @@ void set(Struct *const& s) {
Struct *const& get() {
return Struct::pInstance;
}
+int overloading(int i) {
+ return 111;
+}
+int overloading(Struct *const& s) {
+ return 222;
+}
%}
%{
diff --git a/Examples/test-suite/preproc_defined.i b/Examples/test-suite/preproc_defined.i
new file mode 100644
index 000000000..2fa2f9856
--- /dev/null
+++ b/Examples/test-suite/preproc_defined.i
@@ -0,0 +1,108 @@
+%module preproc_defined
+
+// Check 'defined' passes through the preprocessor without being processed like '#if defined(ABC)' would be (SF bug #1940536)
+
+%define DEFINED_MACRO
+%{
+ int defined(int b) {
+ return b > 10;
+ }
+ int vvv = -1;
+ void fn(int val) {
+ if (defined(val))
+ vvv = 1;
+ else
+ vvv = 0;
+ }
+%}
+%enddef
+
+DEFINED_MACRO
+
+%{
+int checking(void) {
+ fn(11);
+ int okay = (vvv == 1);
+ fn(9);
+ okay = okay && (vvv == 0);
+ return okay; /* should be 1 */
+}
+%}
+
+%inline %{
+int call_checking(void) {
+ return checking();
+}
+%}
+
+/*****************************************************************************/
+/* Check #if/#elif defined() macro expansions
+ Also checks #if/#elif defined() works correctly within macros... this is not
+ standard C, but is now relied on in the SWIG library. */
+/*****************************************************************************/
+
+#define AAA
+#define BBB
+#define CCC
+
+#if defined(AAA)\
+&& defined(BBB) \
+&& defined(CCC)
+%{
+void thing(int i) {}
+void stuff(int i) {}
+struct Defined {
+ int defined;
+};
+void bumpf(int i) {}
+%}
+#else
+#endif
+
+%define ANOTHER_MACRO(TYPE)
+
+#if defined(AAA) && defined(BBB) && defined(CCC)
+void thing(TYPE) {}
+#else
+void thing_not(TYPE) {}
+#endif
+
+#if defined(AAA) &&\
+ defined(BBB) \\
+&& defined(CCC)
+void stuff(TYPE) {}
+#else
+void stuff_not(TYPE);
+#endif
+
+#if defined(0)
+void defined_not(TYPE);
+#elif defined(AAA) && defined( BBB ) && defined(CCC)
+struct Defined {
+ int defined;
+};
+#else
+void defined_not(TYPE);
+#endif
+
+#if !( defined(AAA) \
+ defined(BBB) \\
+&& defined(CCC) )
+void bumpf_not(TYPE);
+#else
+void bumpf(TYPE) {}
+#endif
+
+%enddef
+
+ANOTHER_MACRO(int)
+
+%{
+void another_macro_checking(void) {
+ struct Defined d;
+ d.defined = 10;
+ thing(10);
+ stuff(10);
+ bumpf(10);
+}
+%}
diff --git a/Examples/test-suite/preproc_include.i b/Examples/test-suite/preproc_include.i
new file mode 100644
index 000000000..c6b08b5fd
--- /dev/null
+++ b/Examples/test-suite/preproc_include.i
@@ -0,0 +1,18 @@
+%module preproc_include
+
+%{
+#include "preproc_include_a.h"
+#include "preproc_include_b.h"
+int multiply10(int a) { return a*10; }
+int multiply20(int a) { return a*20; }
+int multiply30(int a) { return a*30; }
+%}
+
+#define INCLUDE_B preproc_include_b.h
+#define FILE_INCLUDE(FNAME) #FNAME
+
+%include FILE_INCLUDE(preproc_include_a.h)
+
+// Note that this test uses -includeall, so including preproc_include_b.h also includes preproc_include_c.h
+%include INCLUDE_B
+
diff --git a/Examples/test-suite/preproc_include_a.h b/Examples/test-suite/preproc_include_a.h
new file mode 100644
index 000000000..b6b55d90d
--- /dev/null
+++ b/Examples/test-suite/preproc_include_a.h
@@ -0,0 +1,3 @@
+
+int multiply10(int a);
+
diff --git a/Examples/test-suite/preproc_include_b.h b/Examples/test-suite/preproc_include_b.h
new file mode 100644
index 000000000..b7cfd530e
--- /dev/null
+++ b/Examples/test-suite/preproc_include_b.h
@@ -0,0 +1,7 @@
+
+int multiply20(int a);
+
+#define PREPROC_INCLUDE_C "preproc_include_c.h"
+
+#include PREPROC_INCLUDE_C
+
diff --git a/Examples/test-suite/preproc_include_c.h b/Examples/test-suite/preproc_include_c.h
new file mode 100644
index 000000000..18f9084a4
--- /dev/null
+++ b/Examples/test-suite/preproc_include_c.h
@@ -0,0 +1,3 @@
+
+int multiply30(int a);
+
diff --git a/Examples/test-suite/preproc_line_file.i b/Examples/test-suite/preproc_line_file.i
new file mode 100644
index 000000000..b221b7728
--- /dev/null
+++ b/Examples/test-suite/preproc_line_file.i
@@ -0,0 +1,95 @@
+%module preproc_line_file
+
+// 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 MYFILE __FILE__
+#define MYFILE_ADJUSTED __FILE__ ".bak"
+
+
+#define STRINGNUM_HELP(a,b) #a#b
+#define STRINGNUM(a,b) STRINGNUM_HELP(a,b)
+#define STRINGNUM_UNIQUE(a) STRINGNUM(a,__LINE__)
+
+#define MY_STRINGNUM_A STRINGNUM_UNIQUE(my)
+#define MY_STRINGNUM_B STRINGNUM_UNIQUE(my)
+
+
+#define NUMBER_HELP(a,b) a##b
+#define NUMBER(a,b) NUMBER_HELP(a,b)
+#define NUMBER_UNIQUE(a) NUMBER(a,__LINE__)
+
+%{
+const int thing27 = -1;
+const int thing28 = -2;
+%}
+const int NUMBER_UNIQUE(thing) = -1; /* resolves to thing27 */
+const int NUMBER_UNIQUE(thing) = -2; /* resolves to thing28 */
+
+#define MYLINE2 __LINE__
+
+#if defined (SWIGJAVA)
+%javaconst(1);
+#elif defined(SWIGCSHARP)
+%csconst(1);
+#elif defined(SWIGD)
+%dmanifestconst;
+#else
+%ignore LINE_NUMBER;
+%ignore LINE_NUM;
+/* spare space */
+#endif
+
+%{
+struct SillyStruct {
+ int num;
+ /* static const int line_num = __LINE__; */
+};
+%}
+struct SillyStruct {
+ int num;
+ static const int LINE_NUMBER = __LINE__; /* This is a C test case, but we can still use a C++ feature to wrap a constant to test __LINE__ here */
+};
+
+#define SILLY_CLASS struct SillyMacroClass { int num; static const int LINE_NUM = __LINE__; };
+SILLY_CLASS
+
+%{
+#define SILLY_CLASS struct SillyMacroClass { int num; };
+SILLY_CLASS
+%}
+
+
+%inline %{
+#ifdef SWIG
+%define BODY
+ int num;
+ static const int LINE_NUM = __LINE__;
+%enddef
+%define KLASS(NAME)
+struct NAME {
+ BODY
+};
+%enddef
+#else
+#define KLASS(NAME) \
+struct NAME { \
+ int num; \
+};
+#endif
+KLASS(SillyMultipleMacroStruct)
+%}
+
+%inline %{
+
+#define INLINE_FILE __FILE__
+#define INLINE_LINE __LINE__
+%}
+
+#define MACRO_END_WITH_SLASH ABCD/
+
+%inline %{
+KLASS(Slash)
+%}
+
diff --git a/Examples/test-suite/primitive_types.i b/Examples/test-suite/primitive_types.i
index e00108b93..f912bd77c 100644
--- a/Examples/test-suite/primitive_types.i
+++ b/Examples/test-suite/primitive_types.i
@@ -355,8 +355,6 @@ macro(size_t, pfx, sizet)
%enddef
-%apply (char *STRING, int LENGTH) { (const char *str, size_t len) }
-
%inline {
struct Foo
{
@@ -464,15 +462,8 @@ macro(size_t, pfx, sizet)
%test_prim_types_ovr(ovr_decl, ovr)
- size_t strlen(const char *str, size_t len)
- {
- return len;
- }
-
static const double stc_double;
static const double stc_float;
-
-
};
struct TestDirector
diff --git a/Examples/test-suite/pure_virtual.i b/Examples/test-suite/pure_virtual.i
index 5bda283cf..9e345e2a4 100644
--- a/Examples/test-suite/pure_virtual.i
+++ b/Examples/test-suite/pure_virtual.i
@@ -9,7 +9,8 @@
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) E; /* C#, D, Java, PHP multiple inheritance */
%nodefaultctor C;
%nodefaultdtor C;
@@ -65,7 +66,7 @@ public:
%}
/* Fill in method from AA. This class should be constructable */
-#ifdef SWIGCSHARP
+#if defined(SWIGCSHARP) || defined(SWIGD)
%ignore F::method2(); // Work around for lack of multiple inheritance support - base AA is ignored.
#endif
diff --git a/Examples/test-suite/python/Makefile.in b/Examples/test-suite/python/Makefile.in
index 4938ddc27..a05542b70 100644
--- a/Examples/test-suite/python/Makefile.in
+++ b/Examples/test-suite/python/Makefile.in
@@ -117,7 +117,7 @@ VALGRIND_OPT += --suppressions=pythonswig.supp
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.py (or _runme3.py for Python 3) appended after the testcase name.
-run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
+run_python = env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH PYTHONPATH=.:$(srcdir):$$PYTHONPATH $(RUNTOOL) $(PYTHON) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)
py2_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY2SCRIPTSUFFIX)
py3_runme = $(srcdir)/$(SCRIPTPREFIX)$*$(PY3SCRIPTSUFFIX)
diff --git a/Examples/test-suite/python/char_binary_runme.py b/Examples/test-suite/python/char_binary_runme.py
new file mode 100644
index 000000000..b6d9c81c8
--- /dev/null
+++ b/Examples/test-suite/python/char_binary_runme.py
@@ -0,0 +1,36 @@
+from char_binary import *
+
+t = Test()
+if t.strlen('hile') != 4:
+ print t.strlen('hile')
+ raise RuntimeError, "bad multi-arg typemap"
+
+if t.strlen('hil\0') != 4:
+ raise RuntimeError, "bad multi-arg typemap"
+
+#
+# creating a raw char*
+#
+pc = new_pchar(5)
+pchar_setitem(pc, 0, 'h')
+pchar_setitem(pc, 1, 'o')
+pchar_setitem(pc, 2, 'l')
+pchar_setitem(pc, 3, 'a')
+pchar_setitem(pc, 4, 0)
+
+
+if t.strlen(pc) != 4:
+ raise RuntimeError, "bad multi-arg typemap"
+
+cvar.var_pchar = pc
+if cvar.var_pchar != "hola":
+ print cvar.var_pchar
+ raise RuntimeError, "bad pointer case"
+
+cvar.var_namet = pc
+#if cvar.var_namet != "hola\0":
+if cvar.var_namet != "hola":
+ raise RuntimeError, "bad pointer case"
+
+delete_pchar(pc)
+
diff --git a/Examples/test-suite/python/director_alternating_runme.py b/Examples/test-suite/python/director_alternating_runme.py
new file mode 100644
index 000000000..a92ae1c5c
--- /dev/null
+++ b/Examples/test-suite/python/director_alternating_runme.py
@@ -0,0 +1,5 @@
+from director_alternating import *
+
+id = getBar().id()
+if id != idFromGetBar():
+ raise RuntimeError, "Got wrong id: " + str(id)
diff --git a/Examples/test-suite/python/director_protected_runme.py b/Examples/test-suite/python/director_protected_runme.py
index 9d565a1b4..fd3c868a1 100644
--- a/Examples/test-suite/python/director_protected_runme.py
+++ b/Examples/test-suite/python/director_protected_runme.py
@@ -12,11 +12,16 @@ class FooBar2(Bar):
def pang(self):
return "FooBar2::pang();"
+class FooBar3(Bar):
+ def cheer(self):
+ return "FooBar3::cheer();"
+
b = Bar()
f = b.create()
fb = FooBar()
fb2 = FooBar2()
+fb3 = FooBar3()
try:
@@ -66,7 +71,7 @@ try:
except:
pass
if not protected:
- raise RuntimeError,"Boo::ping is protected"
+ raise RuntimeError,"Foo::ping is protected"
protected=1
try:
@@ -86,3 +91,39 @@ except:
pass
if not protected:
raise RuntimeError,"FooBar::pang is protected"
+
+
+protected=1
+try:
+ b.cheer()
+ protected=0
+except:
+ pass
+if not protected:
+ raise RuntimeError,"Bar::cheer is protected"
+
+protected=1
+try:
+ f.cheer()
+ protected=0
+except:
+ pass
+if not protected:
+ raise RuntimeError,"Foo::cheer is protected"
+
+if fb3.cheer() != "FooBar3::cheer();":
+ raise RuntimeError, "bad fb3::cheer"
+
+if fb2.callping() != "FooBar2::ping();":
+ raise RuntimeError, "bad fb2.callping"
+
+if fb2.callcheer() != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();":
+ raise RuntimeError, "bad fb2.callcheer"
+
+if fb3.callping() != "Bar::ping();":
+ raise RuntimeError, "bad fb3.callping"
+
+if fb3.callcheer() != "FooBar3::cheer();":
+ raise RuntimeError, "bad fb3.callcheer"
+
+
diff --git a/Examples/test-suite/python/global_namespace_runme.py b/Examples/test-suite/python/global_namespace_runme.py
new file mode 100644
index 000000000..b64e75ca1
--- /dev/null
+++ b/Examples/test-suite/python/global_namespace_runme.py
@@ -0,0 +1,40 @@
+from global_namespace import *
+
+k1 = Klass1()
+k2 = Klass2()
+k3 = Klass3()
+k4 = Klass4()
+k5 = Klass5()
+k6 = Klass6()
+k7 = Klass7()
+
+KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
+
+k1 = getKlass1A()
+k2 = getKlass2A()
+k3 = getKlass3A()
+k4 = getKlass4A()
+k5 = getKlass5A()
+k6 = getKlass6A()
+k7 = getKlass7A()
+
+KlassMethods.methodA(k1, k2, k3, k4, k5, k6, k7)
+KlassMethods.methodB(k1, k2, k3, k4, k5, k6, k7)
+
+k1 = getKlass1B()
+k2 = getKlass2B()
+k3 = getKlass3B()
+k4 = getKlass4B()
+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)
diff --git a/Examples/test-suite/python/pointer_reference_runme.py b/Examples/test-suite/python/pointer_reference_runme.py
new file mode 100644
index 000000000..e1a1a1f4b
--- /dev/null
+++ b/Examples/test-suite/python/pointer_reference_runme.py
@@ -0,0 +1,16 @@
+import pointer_reference
+
+s = pointer_reference.get()
+if s.value != 10:
+ raise RuntimeError, "get test failed"
+
+ss = pointer_reference.Struct(20)
+pointer_reference.set(ss)
+if pointer_reference.cvar.Struct_instance.value != 20:
+ raise RuntimeError, "set test failed"
+
+if pointer_reference.overloading(1) != 111:
+ raise RuntimeError, "overload test 1 failed"
+
+if pointer_reference.overloading(ss) != 222:
+ raise RuntimeError, "overload test 2 failed"
diff --git a/Examples/test-suite/python/preproc_defined_runme.py b/Examples/test-suite/python/preproc_defined_runme.py
new file mode 100644
index 000000000..9a295533a
--- /dev/null
+++ b/Examples/test-suite/python/preproc_defined_runme.py
@@ -0,0 +1,11 @@
+import preproc_defined
+
+if preproc_defined.call_checking() != 1:
+ raise RuntimeError
+
+d = preproc_defined.Defined()
+d.defined = 10
+
+preproc_defined.thing(10)
+preproc_defined.stuff(10)
+preproc_defined.bumpf(10)
diff --git a/Examples/test-suite/python/preproc_include_runme.py b/Examples/test-suite/python/preproc_include_runme.py
new file mode 100644
index 000000000..e15606581
--- /dev/null
+++ b/Examples/test-suite/python/preproc_include_runme.py
@@ -0,0 +1,11 @@
+import preproc_include
+
+if preproc_include.multiply10(10) != 100:
+ raise RuntimeError
+
+if preproc_include.multiply20(10) != 200:
+ raise RuntimeError
+
+if preproc_include.multiply30(10) != 300:
+ raise RuntimeError
+
diff --git a/Examples/test-suite/python/primitive_types_runme.py b/Examples/test-suite/python/primitive_types_runme.py
index 02cc21763..2495cd60d 100644
--- a/Examples/test-suite/python/primitive_types_runme.py
+++ b/Examples/test-suite/python/primitive_types_runme.py
@@ -188,14 +188,6 @@ if t.var_namet != 'hol':
raise RuntimeError
-if t.strlen('hile') != 4:
- print t.strlen('hile')
- raise RuntimeError, "bad string typemap"
-
-if t.strlen('hil\0') != 4:
- raise RuntimeError, "bad string typemap"
-
-
cvar.var_char = '\0'
if cvar.var_char != '\0':
raise RuntimeError, "bad char '0' case"
@@ -244,9 +236,6 @@ pchar_setitem(pc, 3, 'a')
pchar_setitem(pc, 4, 0)
-if t.strlen(pc) != 4:
- raise RuntimeError, "bad string typemap"
-
cvar.var_pchar = pc
if cvar.var_pchar != "hola":
print cvar.var_pchar
diff --git a/Examples/test-suite/python/rename_pcre_encoder_runme.py b/Examples/test-suite/python/rename_pcre_encoder_runme.py
new file mode 100644
index 000000000..1186703a0
--- /dev/null
+++ b/Examples/test-suite/python/rename_pcre_encoder_runme.py
@@ -0,0 +1,13 @@
+from rename_pcre_encoder import *
+
+s = SomeWidget()
+s.putBorderWidth(3)
+if s.getBorderWidth() != 3:
+ raise RuntimeError("Border should be 3, not %d" % (s.getBorderWidth(),))
+
+s.putSize(4, 5)
+a = AnotherWidget()
+a.DoSomething()
+
+evt = wxEVTSomeEvent()
+t = xUnchangedName()
diff --git a/Examples/test-suite/python/smart_pointer_const_overload_runme.py b/Examples/test-suite/python/smart_pointer_const_overload_runme.py
new file mode 100644
index 000000000..f1be315a5
--- /dev/null
+++ b/Examples/test-suite/python/smart_pointer_const_overload_runme.py
@@ -0,0 +1,123 @@
+from smart_pointer_const_overload import *
+
+CONST_ACCESS = 1
+MUTABLE_ACCESS = 2
+
+def test(b, f):
+ if f.x != 0:
+ raise RuntimeError
+
+ # Test member variable get
+ if b.x != 0:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test member variable set
+ b.x = 1
+
+ if f.x != 1:
+ raise RuntimeError
+
+ if f.access != MUTABLE_ACCESS:
+ raise RuntimeError
+
+ # Test const method
+ if b.getx() != 1:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test mutable method
+ b.setx(2)
+
+ if f.x != 2:
+ raise RuntimeError
+
+ if f.access != MUTABLE_ACCESS:
+ raise RuntimeError
+
+ # Test extended const method
+ if b.getx2() != 2:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test extended mutable method
+ b.setx2(3)
+
+ if f.x != 3:
+ raise RuntimeError
+
+ if f.access != MUTABLE_ACCESS:
+ raise RuntimeError
+
+ # Test static method
+ b.stat()
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test const member
+ f.access = MUTABLE_ACCESS
+
+ if b.y != 0:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test get through mutable pointer to const member
+ f.access = MUTABLE_ACCESS
+
+ if get_int(b.yp) != 0:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test get through const pointer to mutable member
+ f.x = 4
+ f.access = MUTABLE_ACCESS
+
+ if get_int(b.xp) != 4:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test set through const pointer to mutable member
+ f.access = MUTABLE_ACCESS
+ set_int(b.xp, 5)
+
+ if f.x != 5:
+ raise RuntimeError
+
+ if f.access != CONST_ACCESS:
+ raise RuntimeError
+
+ # Test set pointer to const member
+ b.yp = new_int(6)
+
+ if f.y != 0:
+ raise RuntimeError
+
+ if get_int(f.yp) != 6:
+ raise RuntimeError
+
+ if f.access != MUTABLE_ACCESS:
+ raise RuntimeError
+
+ delete_int(f.yp);
+
+f = Foo()
+b = Bar(f)
+
+f2 = Foo()
+b2 = Bar2(f2)
+
+test(b, f)
+test(b2, f2)
diff --git a/Examples/test-suite/python/typemap_arrays_runme.py b/Examples/test-suite/python/typemap_arrays_runme.py
new file mode 100644
index 000000000..c23222c63
--- /dev/null
+++ b/Examples/test-suite/python/typemap_arrays_runme.py
@@ -0,0 +1,5 @@
+from typemap_arrays import *
+
+if sumA(None) != 60:
+ raise RuntimeError, "Sum is wrong"
+
diff --git a/Examples/test-suite/r/rename_simple_runme.R b/Examples/test-suite/r/rename_simple_runme.R
new file mode 100644
index 000000000..b25aeb844
--- /dev/null
+++ b/Examples/test-suite/r/rename_simple_runme.R
@@ -0,0 +1,20 @@
+source("unittest.R")
+dyn.load(paste("rename_simple", .Platform$dynlib.ext, sep=""))
+source("rename_simple.R")
+cacheMetaData(1)
+
+s <- NewStruct();
+unittest(111, s$NewInstanceVariable)
+unittest(222, s$NewInstanceMethod())
+unittest(333, NewStruct_NewStaticMethod())
+unittest(444, NewStruct_NewStaticVariable())
+unittest(555, NewFunction())
+unittest(666, NewGlobalVariable())
+
+s$NewInstanceVariable <- 1111
+NewStruct_NewStaticVariable(4444)
+NewGlobalVariable(6666)
+
+unittest(1111, s$NewInstanceVariable)
+unittest(4444, NewStruct_NewStaticVariable())
+unittest(6666, NewGlobalVariable())
diff --git a/Examples/test-suite/r/unittest.R b/Examples/test-suite/r/unittest.R
index 81c590a3f..0633c7715 100644
--- a/Examples/test-suite/r/unittest.R
+++ b/Examples/test-suite/r/unittest.R
@@ -1,9 +1,17 @@
unittest <- function (x,y) {
-if (x==y) print("PASS")
-else print("FAIL")
+ if (x==y) {
+ print("PASS")
+ } else {
+ print("FAIL")
+ stop("Test failed")
+ }
}
unittesttol <- function(x,y,z) {
-if (abs(x-y) < z) print("PASS")
-else print("FAIL")
-} \ No newline at end of file
+ if (abs(x-y) < z) {
+ print("PASS")
+ } else {
+ print("FAIL")
+ stop("Test failed")
+ }
+}
diff --git a/Examples/test-suite/rename_camel.i b/Examples/test-suite/rename_camel.i
index 54f06f967..970bb9215 100644
--- a/Examples/test-suite/rename_camel.i
+++ b/Examples/test-suite/rename_camel.i
@@ -33,7 +33,7 @@
%rename(awk_cmd) "";
-%rename("%(title)s",rxsmatch$parentNode$type="enum .*") "";
+%rename("%(title)s",regexmatch$parentNode$type="enum .*") "";
%inline
{
@@ -59,7 +59,7 @@
}
-%rename("%(lowercase)s",sourcefmt="%(rxspencer:[GSL_(.*)][@1])s",%$isfunction) "";
+%rename("%(lowercase)s",sourcefmt="%(regex:/GSL_(.*)/\\1/)s",%$isfunction) "";
%inline {
void GSL_Hello() {}
}
diff --git a/Examples/test-suite/rename_pcre_encoder.i b/Examples/test-suite/rename_pcre_encoder.i
new file mode 100644
index 000000000..66f30c7bc
--- /dev/null
+++ b/Examples/test-suite/rename_pcre_encoder.i
@@ -0,0 +1,31 @@
+%module rename_pcre_encoder
+
+// strip the wx prefix from all identifiers except those starting with wxEVT
+%rename("%(regex:/wx(?!EVT)(.*)/\\1/)s") "";
+
+// Replace "Set" and "Get" prefixes with "put" and "get" respectively.
+%rename("%(regex:/^Set(.*)/put\\1/)s", %$isfunction) "";
+%rename("%(regex:/^Get(.*)/get\\1/)s", %$isfunction) "";
+
+%inline %{
+
+struct wxSomeWidget {
+ void SetBorderWidth(int width) { m_width = width; }
+ int GetBorderWidth() const { return m_width; }
+
+ void SetSize(int, int) {}
+
+ int m_width;
+};
+
+struct wxAnotherWidget {
+ void DoSomething() {}
+};
+
+class wxEVTSomeEvent {
+};
+
+class xUnchangedName {
+};
+
+%}
diff --git a/Examples/test-suite/rename_pcre_enum.i b/Examples/test-suite/rename_pcre_enum.i
new file mode 100644
index 000000000..1bb7c1b8b
--- /dev/null
+++ b/Examples/test-suite/rename_pcre_enum.i
@@ -0,0 +1,49 @@
+%module rename_pcre_enum
+
+// This file is needed for proper enum support in C#/Java backends
+#if defined(SWIGCSHARP) || defined(SWIGJAVA)
+%include "enums.swg"
+#endif
+
+// Apply a rule for renaming the enum elements to avoid the common prefixes
+// redundant in C#/Java
+%rename("%(regex:/([A-Z][a-z]+)+_(.*)/\\2/)s",%$isenumitem) "";
+
+// Also don't export special end of enum markers which are often used in C++
+// code to just have a symbolic name for the number of enum elements but are
+// not needed in target language.
+%rename("$ignore", regexmatch$name="([A-Z][a-z]+)+_Max$",%$isenumitem) "";
+
+// Test another way of doing the same thing with regextarget:
+%rename("$ignore", %$isenumitem, regextarget=1) "([A-Z][a-z]+)+_Internal$";
+
+// Apply this renaming rule to all enum elements that don't contain more than
+// one capital letter.
+%rename("%(lower)s", notregexmatch$name="[A-Z]\\w*[A-Z]", %$isenumitem) "";
+
+%inline %{
+
+// Foo_Internal and Foo_Max won't be exported.
+enum Foo {
+ Foo_Internal = -1,
+ Foo_First,
+ Foo_Second,
+ Foo_Max
+};
+
+// All elements of this enum will be exported because they do not match the
+// excluding regex.
+enum BoundaryCondition {
+ BoundaryCondition_MinMax,
+ BoundaryCondition_MaxMin,
+ BoundaryCondition_MaxMax
+};
+
+// The elements of this enum will have lower-case names.
+enum Colour {
+ Red,
+ Blue,
+ Green
+};
+
+%}
diff --git a/Examples/test-suite/rename_simple.i b/Examples/test-suite/rename_simple.i
new file mode 100644
index 000000000..feba53fa1
--- /dev/null
+++ b/Examples/test-suite/rename_simple.i
@@ -0,0 +1,24 @@
+%module rename_simple
+
+%rename(NewStruct) OldStruct;
+%rename(NewVariable) OldVariable;
+%rename(NewInstanceMethod) OldInstanceMethod;
+%rename(NewInstanceVariable) OldInstanceVariable;
+%rename(NewStaticMethod) OldStaticMethod;
+%rename(NewStaticVariable) OldStaticVariable;
+%rename(NewFunction) OldFunction;
+%rename(NewGlobalVariable) OldGlobalVariable;
+
+%inline %{
+struct OldStruct {
+ OldStruct() : OldInstanceVariable(111) {}
+ int OldInstanceVariable;
+ int OldInstanceMethod() { return 222; }
+ static int OldStaticVariable;
+ static int OldStaticMethod() { return 333; }
+};
+int OldStruct::OldStaticVariable = 444;
+
+int OldFunction() { return 555; }
+int OldGlobalVariable = 666;
+%}
diff --git a/Examples/test-suite/restrict_cplusplus.i b/Examples/test-suite/restrict_cplusplus.i
index 4e4bfc277..62abffa52 100644
--- a/Examples/test-suite/restrict_cplusplus.i
+++ b/Examples/test-suite/restrict_cplusplus.i
@@ -1,7 +1,15 @@
%module restrict_cplusplus
-%inline %{
+%{
+// For PHP 5.3 / gcc-4.4
+#ifdef restrict
+#undef restrict
+#endif
struct Foo {
int restrict;
};
%}
+
+struct Foo {
+ int restrict;
+};
diff --git a/Examples/test-suite/return_const_value.i b/Examples/test-suite/return_const_value.i
index 473878521..6be5760c1 100644
--- a/Examples/test-suite/return_const_value.i
+++ b/Examples/test-suite/return_const_value.i
@@ -42,6 +42,7 @@ public:
_ptr = f._ptr;
_own = f._own;
f._own = 0;
+ return *this;
}
~Foo_ptr() {
diff --git a/Examples/test-suite/rname.i b/Examples/test-suite/rname.i
index 31b99833d..09d6e3e3b 100644
--- a/Examples/test-suite/rname.i
+++ b/Examples/test-suite/rname.i
@@ -15,19 +15,14 @@
%rename(foo_u) *::foo(unsigned);
/* Rename classes in a class hierarchy */
-%rename (RenamedBase) Base;
-%rename (RenamedDerived) Derived;
+%rename (RenamedBase) Space::Base;
+%rename (RenamedDerived) Space::Derived;
/* Rename base class method applies to derived classes too */#
-%rename (newname) Base::oldname(double d) const;
+%rename (newname) Space::Base::oldname(double d) const;
/* Rename derived class method only */
-#ifndef SWIGGO
-%rename (func) Derived::fn(Base baseValue, Base* basePtr, Base& baseRef);
-#else
-/* func is a keyword in Go. */
-%rename (Xfunc) Derived::fn(Base baseValue, Base* basePtr, Base& baseRef);
-#endif
+%rename (Xfunc) Space::Derived::fn(Base baseValue, Base* basePtr, Base& baseRef);
%inline %{
class Bar {
@@ -43,20 +38,22 @@ char *foo(double) { return (char *) "foo-double"; }
char *foo(short) { return (char *) "foo-short"; }
char *foo(unsigned) { return (char *) "foo-unsigned"; }
+namespace Space {
class Base {
public:
Base(){};
virtual ~Base(){};
void fn(Base baseValue, Base* basePtr, Base& baseRef){}
- virtual const char * oldname(double d) const { return (char*) "Base"; }
+ virtual const char * oldname(double d) const { return "Base"; }
};
class Derived : public Base {
public:
Derived(){}
~Derived(){}
void fn(Base baseValue, Base* basePtr, Base& baseRef){}
- virtual const char * oldname(double d) const { return (char*) "Derived"; }
+ virtual const char * oldname(double d) const { return "Derived"; }
};
+}
%}
diff --git a/Examples/test-suite/samename.i b/Examples/test-suite/samename.i
index 819cb4abd..cc03995bc 100644
--- a/Examples/test-suite/samename.i
+++ b/Examples/test-suite/samename.i
@@ -1,6 +1,6 @@
%module samename
-#if !(defined(SWIGCSHARP) || defined(SWIGJAVA))
+#if !(defined(SWIGCSHARP) || defined(SWIGJAVA) || defined(SWIGD))
class samename {
public:
void do_something() {
diff --git a/Examples/test-suite/smart_pointer_const_overload.i b/Examples/test-suite/smart_pointer_const_overload.i
new file mode 100644
index 000000000..e3b000b52
--- /dev/null
+++ b/Examples/test-suite/smart_pointer_const_overload.i
@@ -0,0 +1,74 @@
+%module smart_pointer_const_overload
+
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) Bar::operator->; // Overloaded method Bar::operator ->() ignored
+%warnfilter(SWIGWARN_LANG_OVERLOAD_IGNORED) Bar2::operator->; // Overloaded method Bar2::operator ->() ignored
+
+%inline %{
+int CONST_ACCESS = 1;
+int MUTABLE_ACCESS = 2;
+
+int *new_int(int ivalue) {
+ int *i = (int *) malloc(sizeof(ivalue));
+ *i = ivalue;
+ return i;
+}
+
+int get_int(int *i) {
+ return *i;
+}
+
+void set_int(int *i, int ivalue) {
+ *i = ivalue;
+}
+
+void delete_int(int *i) {
+ free(i);
+}
+
+struct Foo {
+ int x;
+ int * const xp;
+ const int y;
+ const int *yp;
+ int access;
+ 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() {}
+};
+%}
+
+%extend Foo {
+ int getx2() const { return self->x; }
+ void setx2(int x_) { self->x = x_; }
+};
+
+%inline %{
+class Bar {
+ Foo *f;
+public:
+ Bar(Foo *f) : f(f) { }
+ const Foo *operator->() const {
+ f->access = CONST_ACCESS;
+ return f;
+ }
+ Foo *operator->() {
+ f->access = MUTABLE_ACCESS;
+ return f;
+ }
+};
+
+class Bar2 {
+ Foo *f;
+public:
+ Bar2(Foo *f) : f(f) { }
+ Foo *operator->() {
+ f->access = MUTABLE_ACCESS;
+ return f;
+ }
+ const Foo *operator->() const {
+ f->access = CONST_ACCESS;
+ return f;
+ }
+};
+%}
diff --git a/Examples/test-suite/smart_pointer_templatemethods.i b/Examples/test-suite/smart_pointer_templatemethods.i
index 7baa6386a..f79bbcc9d 100644
--- a/Examples/test-suite/smart_pointer_templatemethods.i
+++ b/Examples/test-suite/smart_pointer_templatemethods.i
@@ -1,4 +1,3 @@
-
%module smart_pointer_templatemethods
%inline %{
@@ -29,21 +28,21 @@ public:
void DisposeObjekt (void) {}
};
-class Object
+class Objct
{
public:
- Object () {}
- virtual ~Object () {}
+ Objct () {}
+ virtual ~Objct () {}
template <typename T> Ptr<T> QueryInterface (InterfaceId iid) const { return Ptr<T>(); }
- void DisposeObject (void) {}
+ void DisposeObjct (void) {}
};
#ifdef SWIG
-%template(PtrObject) Ptr<Object>;
+%template(PtrObjct) Ptr<Objct>;
%template(PtrInt) Ptr<int>;
%template(ObjektInt) Objekt<int>;
%template(PtrObjektInt) Ptr<Objekt<int> >;
-%template(QueryInterfaceObject) Object::QueryInterface<Object>;
+%template(QueryInterfaceObjct) Objct::QueryInterface<Objct>;
#endif
}; // namespace
diff --git a/Examples/test-suite/special_variable_macros.i b/Examples/test-suite/special_variable_macros.i
index c168b4747..1ad673b41 100644
--- a/Examples/test-suite/special_variable_macros.i
+++ b/Examples/test-suite/special_variable_macros.i
@@ -165,6 +165,20 @@ namespace Space {
return new $typemap(jstype, Space::RenameMe)( new $typemap(jstype, Name)(s) );
}
%}
+#elif defined(SWIGD)
+#if (SWIG_D_VERSION == 1)
+%typemap(dcode) Space::RenameMe %{
+ public static NewName factory(char[] s) {
+ return new $typemap(dtype, Space::RenameMe)( new $typemap(dtype, Name)(s) );
+ }
+%}
+#else
+%typemap(dcode) Space::RenameMe %{
+ public static NewName factory(string s) {
+ return new $typemap(dtype, Space::RenameMe)( new $typemap(dtype, Name)(s) );
+ }
+%}
+#endif
#endif
%rename(NewName) Space::RenameMe;
diff --git a/Examples/test-suite/static_const_member.i b/Examples/test-suite/static_const_member.i
index 3db60b4c2..a8d119b81 100644
--- a/Examples/test-suite/static_const_member.i
+++ b/Examples/test-suite/static_const_member.i
@@ -11,6 +11,9 @@
#elif SWIGCSHARP
%csconst(1) EN;
%csconst(1) CHARTEST;
+#elif SWIGD
+%dmanifestconst EN;
+%dmanifestconst CHARTEST;
#endif
%inline %{
diff --git a/Examples/test-suite/template.i b/Examples/test-suite/template_basic.i
index d2c7a91ed..570392bf6 100644
--- a/Examples/test-suite/template.i
+++ b/Examples/test-suite/template_basic.i
@@ -1,5 +1,5 @@
-/* File : example.i */
-%module "template"
+/* File: template_basic.i */
+%module "template_basic"
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<int>; /* Ruby, wrong class name */
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) vector<double>; /* Ruby, wrong class name */
@@ -31,7 +31,7 @@ template<class T> class vector {
void set(int index, T &val) {
v[index] = val;
}
- // This really doesn't do anything except test const handling
+ // This really doesn't do anything except test const handling
void testconst(const T x) { }
};
diff --git a/Examples/test-suite/template_enum.i b/Examples/test-suite/template_enum.i
index 0d6fbf5b9..f36d5dc40 100644
--- a/Examples/test-suite/template_enum.i
+++ b/Examples/test-suite/template_enum.i
@@ -13,6 +13,10 @@ public:
%template(foo_i) foo<int>;
%template(foo_d) foo<double>;
+#ifdef SWIGD
+// Workaround for the D module which uses the literal value in the generated wrapper code.
+%dconstvalue("3") Manta::ColorSpace<Manta::RGBTraits>::NumComponents;
+#endif
%inline {
diff --git a/Examples/test-suite/template_inherit_abstract.i b/Examples/test-suite/template_inherit_abstract.i
index 2f83433a5..87c921eab 100644
--- a/Examples/test-suite/template_inherit_abstract.i
+++ b/Examples/test-suite/template_inherit_abstract.i
@@ -4,7 +4,8 @@
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) oss::Module; /* C#, Java, PHP multiple inheritance */
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) oss::Module; /* C#, D, Java, PHP multiple inheritance */
%inline %{
@@ -56,7 +57,7 @@ namespace oss
%inline %{
namespace oss
{
-#if defined(SWIG) && defined(SWIGCSHARP)
+#if defined(SWIG) && (defined(SWIGCSHARP) || defined(SWIGD))
%ignore HModule<B>::get(); // Work around for lack of multiple inheritance support - base ModuleBase is ignored.
#endif
struct test : HModule<B>
diff --git a/Examples/test-suite/threads_exception.i b/Examples/test-suite/threads_exception.i
index 9f275bd6a..9f275bd6a 100755..100644
--- a/Examples/test-suite/threads_exception.i
+++ b/Examples/test-suite/threads_exception.i
diff --git a/Examples/test-suite/typemap_arrays.i b/Examples/test-suite/typemap_arrays.i
new file mode 100644
index 000000000..dd7994405
--- /dev/null
+++ b/Examples/test-suite/typemap_arrays.i
@@ -0,0 +1,30 @@
+%module typemap_arrays
+
+// Test that previously non-working array typemaps special variables are working
+
+%typemap(in) SWIGTYPE[ANY] {
+ _should_not_be_used_and_will_not_compile_
+}
+
+// Check $basemangle expands to _p_int and $basetype expands to int *
+%typemap(in) int *nums[3] (int *temp[3]) {
+ $basetype var1$basemangle = new int(10);
+ $basetype var2$basemangle = new int(20);
+ $basetype var3$basemangle = new int(30);
+ temp[0] = var1_p_int;
+ temp[1] = var2_p_int;
+ temp[2] = var3_p_int;
+ $1 = temp;
+}
+
+%inline %{
+int sumA(int *nums[3]) {
+ int sum = 0;
+ for (int i=0; i<3; ++i) {
+ int *p = nums[i];
+ if (p)
+ sum += *p;
+ }
+ return sum;
+}
+%}
diff --git a/Examples/test-suite/typemap_namespace.i b/Examples/test-suite/typemap_namespace.i
index 6614e0372..1fd7ce718 100644
--- a/Examples/test-suite/typemap_namespace.i
+++ b/Examples/test-suite/typemap_namespace.i
@@ -29,8 +29,15 @@ namespace Foo {
#ifdef SWIGGO
%typemap(gotype) Str1 * = char *;
#endif
+#ifdef SWIGD
+ %typemap(ctype) Str1 * = char *;
+ %typemap(imtype) Str1 * = char *;
+ %typemap(dtype) Str1 * = char *;
+ %typemap(din) Str1 * = char *;
+ %typemap(dout) Str1 * = char *;
+#endif
%typemap(in) Str1 * = char *;
-#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGMZSCHEME) || defined(SWIGOCAML) || defined(SWIGGO))
+#if !(defined(SWIGCSHARP) || defined(SWIGLUA) || defined(SWIGPHP) || defined(SWIGMZSCHEME) || defined(SWIGOCAML) || defined(SWIGGO) || defined(SWIGD))
%typemap(freearg) Str1 * = char *;
#endif
%typemap(typecheck) Str1 * = char *;
diff --git a/Examples/test-suite/typemap_out_optimal.i b/Examples/test-suite/typemap_out_optimal.i
index 23cd2ad3f..d707ed2d5 100644
--- a/Examples/test-suite/typemap_out_optimal.i
+++ b/Examples/test-suite/typemap_out_optimal.i
@@ -2,7 +2,7 @@
%module typemap_out_optimal
// Just the following languages tested
-#if defined (SWIGCSHARP)
+#if defined (SWIGCSHARP) || defined (SWIGD)
%typemap(out, optimal="1") SWIGTYPE %{
$result = new $1_ltype((const $1_ltype &)$1);
%}
@@ -18,6 +18,10 @@
%ignore XX::operator=;
+#ifdef SWIGD
+%rename(trace) XX::debug;
+#endif
+
%inline %{
#include <iostream>
using namespace std;
diff --git a/Examples/test-suite/typemap_subst.i b/Examples/test-suite/typemap_subst.i
index 1b1f8a3f4..91ac62020 100644
--- a/Examples/test-suite/typemap_subst.i
+++ b/Examples/test-suite/typemap_subst.i
@@ -61,8 +61,8 @@
$1 = ($ltype) temp;
}
-/* Java, C# and Go modules don't use SWIG's runtime type system */
-#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO)
+/* Java, C#, Go and D modules don't use SWIG's runtime type system */
+#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO) && !defined(SWIGD)
%inline %{
void foo(const struct xyzzy **TEST) {}
%}
diff --git a/Examples/test-suite/using_composition.i b/Examples/test-suite/using_composition.i
index bd0f712b5..052412b5f 100644
--- a/Examples/test-suite/using_composition.i
+++ b/Examples/test-suite/using_composition.i
@@ -2,13 +2,16 @@
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, Java, PHP multiple inheritance
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, D, Java, PHP multiple inheritance
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar2; // C#, Java, PHP multiple inheritance
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar2; // C#, D, Java, PHP multiple inheritance
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar3; // C#, Java, PHP multiple inheritance
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar3; // C#, D, Java, PHP multiple inheritance
#ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) blah;
#endif
diff --git a/Examples/test-suite/using_extend.i b/Examples/test-suite/using_extend.i
index e14cc28e8..c52f65c23 100644
--- a/Examples/test-suite/using_extend.i
+++ b/Examples/test-suite/using_extend.i
@@ -2,7 +2,8 @@
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, Java, PHP multiple inheritance
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) FooBar; // C#, D, Java, PHP multiple inheritance
#ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings
%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) blah;
#endif
diff --git a/Examples/test-suite/using_namespace.i b/Examples/test-suite/using_namespace.i
index ce02e9a87..1119b46f7 100644
--- a/Examples/test-suite/using_namespace.i
+++ b/Examples/test-suite/using_namespace.i
@@ -5,7 +5,8 @@
%warnfilter(SWIGWARN_JAVA_MULTIPLE_INHERITANCE,
SWIGWARN_CSHARP_MULTIPLE_INHERITANCE,
- SWIGWARN_PHP_MULTIPLE_INHERITANCE) Hi<hello::Hello, hi::hi0>; // C#, Java, PHP multiple inheritance
+ SWIGWARN_D_MULTIPLE_INHERITANCE,
+ SWIGWARN_PHP_MULTIPLE_INHERITANCE) Hi<hello::Hello, hi::hi0>; // C#, D, Java, PHP multiple inheritance
%inline %{
namespace hello
diff --git a/Examples/test-suite/using_protected.i b/Examples/test-suite/using_protected.i
index 23adfdbba..402a7c8da 100644
--- a/Examples/test-suite/using_protected.i
+++ b/Examples/test-suite/using_protected.i
@@ -3,14 +3,23 @@
%inline %{
class Foo {
protected:
- int x;
- int blah(int xx) { return xx; }
+ int x;
+ int blah(int xx) { return xx; }
+ virtual int vmethod(int xx) { return xx; }
};
class FooBar : public Foo {
public:
- using Foo::blah;
- using Foo::x;
+ using Foo::blah;
+ using Foo::x;
+ using Foo::vmethod;
+};
+
+class FooBaz : public Foo {
+protected:
+ using Foo::blah;
+ using Foo::x;
+ using Foo::vmethod;
};
%}
diff --git a/Examples/test-suite/varargs.i b/Examples/test-suite/varargs.i
index 41e4903f0..c7931fed2 100644
--- a/Examples/test-suite/varargs.i
+++ b/Examples/test-suite/varargs.i
@@ -1,4 +1,5 @@
-// Tests SWIG's *default* handling of varargs. The default behavior is to simply ignore the varargs.
+// Tests SWIG's *default* handling of varargs (function varargs, not preprocessor varargs).
+// The default behavior is to simply ignore the varargs.
%module varargs
%varargs(int mode = 0) test_def;
diff --git a/Examples/test-suite/wallkw.i b/Examples/test-suite/wallkw.i
index 0ac383bcd..1a5866088 100644
--- a/Examples/test-suite/wallkw.i
+++ b/Examples/test-suite/wallkw.i
@@ -5,12 +5,14 @@
%warnfilter(SWIGWARN_PARSE_KEYWORD) clone; // 'clone' is a php keyword, renamed as 'c_clone'
%warnfilter(SWIGWARN_PARSE_KEYWORD) delegate; // 'delegate' is a C# keyword, renaming to '_delegate'
%warnfilter(SWIGWARN_PARSE_KEYWORD) pass; // 'pass' is a python keyword, renaming to '_pass'
-%warnfilter(SWIGWARN_PARSE_KEYWORD) alias; // 'alias' is a ruby keyword, renaming to 'C_alias'
+%warnfilter(SWIGWARN_PARSE_KEYWORD) alias; // 'alias' is a D keyword, renaming to '_alias'
+%warnfilter(SWIGWARN_PARSE_KEYWORD) rescue; // 'rescue' is a ruby keyword, renaming to 'C_rescue'
%inline %{
const char * clone() { return "clone"; }
const char * delegate() { return "delegate"; }
const char * pass() { return "pass"; }
const char * alias() { return "alias"; }
+const char * rescue() { return "rescue"; }
%}
diff --git a/Examples/test-suite/wrapmacro.i b/Examples/test-suite/wrapmacro.i
index bd5e48b15..4d2cd67be 100644
--- a/Examples/test-suite/wrapmacro.i
+++ b/Examples/test-suite/wrapmacro.i
@@ -1,7 +1,7 @@
%module wrapmacro
#ifdef SWIGLUA // lua only has one numeric type, so some overloads shadow each other creating warnings
-%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) SWIGMACRO_max;
+%warnfilter(SWIGWARN_LANG_OVERLOAD_SHADOW) SWIGMACRO_maximum;
#endif
/* Testing technique for wrapping macros */
diff --git a/Lib/allkw.swg b/Lib/allkw.swg
index fb76ff287..2e0dad6cf 100644
--- a/Lib/allkw.swg
+++ b/Lib/allkw.swg
@@ -18,6 +18,7 @@
%include <chicken/chickenkw.swg>
%include <csharp/csharpkw.swg>
+%include <d/dkw.swg>
%include <java/javakw.swg>
%include <php/phpkw.swg>
%include <pike/pikekw.swg>
diff --git a/Lib/chicken/chicken.swg b/Lib/chicken/chicken.swg
index 112780499..525c1a64c 100644
--- a/Lib/chicken/chicken.swg
+++ b/Lib/chicken/chicken.swg
@@ -538,7 +538,7 @@ $result = C_SCHEME_UNDEFINED;
* String & length
* ------------------------------------------------------------ */
-%typemap(in) (char *STRING, int LENGTH) {
+%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
if ($input == C_SCHEME_FALSE) {
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Cannot use a null/#f string for a char*, int arguments");
}
diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i
index 2db6ddf5b..a4bf02397 100644
--- a/Lib/csharp/std_map.i
+++ b/Lib/csharp/std_map.i
@@ -67,12 +67,13 @@
public System.Collections.Generic.ICollection<$typemap(cstype, K)> Keys {
get {
System.Collections.Generic.ICollection<$typemap(cstype, K)> keys = new System.Collections.Generic.List<$typemap(cstype, K)>();
- IntPtr iter = create_iterator_begin();
- try {
- while (true) {
+ int size = this.Count;
+ if (size > 0) {
+ IntPtr iter = create_iterator_begin();
+ for (int i = 0; i < size; i++) {
keys.Add(get_next_key(iter));
}
- } catch (ArgumentOutOfRangeException) {
+ destroy_iterator(iter);
}
return keys;
}
@@ -258,7 +259,7 @@
return false;
}
- // create_iterator_begin() and get_next_key() work together to provide a collection of keys to C#
+ // create_iterator_begin(), get_next_key() and destroy_iterator work together to provide a collection of keys to C#
%apply void *VOID_INT_PTR { std::map< K, T >::iterator *create_iterator_begin }
%apply void *VOID_INT_PTR { std::map< K, T >::iterator *swigiterator }
@@ -266,15 +267,15 @@
return new std::map< K, T >::iterator($self->begin());
}
- const key_type& get_next_key(std::map< K, T >::iterator *swigiterator) throw (std::out_of_range) {
+ const key_type& get_next_key(std::map< K, T >::iterator *swigiterator) {
std::map< K, T >::iterator iter = *swigiterator;
- if (iter == $self->end()) {
- delete swigiterator;
- throw std::out_of_range("no more map elements");
- }
- (*swigiterator)++;
+ swigiterator++;
return (*iter).first;
}
+
+ void destroy_iterator(std::map< K, T >::iterator *swigiterator) {
+ delete swigiterator;
+ }
}
@@ -285,6 +286,7 @@
%csmethodmodifiers std::map::setitem "private"
%csmethodmodifiers std::map::create_iterator_begin "private"
%csmethodmodifiers std::map::get_next_key "private"
+%csmethodmodifiers std::map::destroy_iterator "private"
// Default implementation
namespace std {
diff --git a/Lib/csharp/typemaps.i b/Lib/csharp/typemaps.i
index d50e5c46d..7bca83c12 100644
--- a/Lib/csharp/typemaps.i
+++ b/Lib/csharp/typemaps.i
@@ -51,13 +51,12 @@ or you can use the %apply directive :
In C# you could then use it like this:
double answer = modulename.fadd(10.0, 20.0);
-
*/
%define INPUT_TYPEMAP(TYPE, CTYPE, CSTYPE)
-%typemap(ctype) TYPE *INPUT, TYPE &INPUT "CTYPE"
-%typemap(imtype) TYPE *INPUT, TYPE &INPUT "CSTYPE"
-%typemap(cstype) TYPE *INPUT, TYPE &INPUT "CSTYPE"
+%typemap(ctype, out="void *") TYPE *INPUT, TYPE &INPUT "CTYPE"
+%typemap(imtype, out="IntPtr") TYPE *INPUT, TYPE &INPUT "CSTYPE"
+%typemap(cstype, out="$csclassname") TYPE *INPUT, TYPE &INPUT "CSTYPE"
%typemap(csin) TYPE *INPUT, TYPE &INPUT "$csinput"
%typemap(csdirectorin) TYPE *INPUT, TYPE &INPUT "$iminput"
%typemap(csdirectorout) TYPE *INPUT, TYPE &INPUT "$cscall"
@@ -143,18 +142,16 @@ value returned in the second output parameter. In C# you would use it like this:
double dptr;
double fraction = modulename.modf(5, out dptr);
-
*/
%define OUTPUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE)
-%typemap(ctype) TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *"
-%typemap(imtype) TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
-%typemap(cstype) TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
+%typemap(ctype, out="void *") TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *"
+%typemap(imtype, out="IntPtr") TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
+%typemap(cstype, out="$csclassname") TYPE *OUTPUT, TYPE &OUTPUT "out CSTYPE"
%typemap(csin) TYPE *OUTPUT, TYPE &OUTPUT "out $csinput"
%typemap(csdirectorin) TYPE *OUTPUT, TYPE &OUTPUT "$iminput"
%typemap(csdirectorout) TYPE *OUTPUT, TYPE &OUTPUT "$cscall"
-
%typemap(in) TYPE *OUTPUT, TYPE &OUTPUT
%{ $1 = ($1_ltype)$input; %}
@@ -250,9 +247,9 @@ of the function return value.
*/
%define INOUT_TYPEMAP(TYPE, CTYPE, CSTYPE, TYPECHECKPRECEDENCE)
-%typemap(ctype) TYPE *INOUT, TYPE &INOUT "CTYPE *"
-%typemap(imtype) TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
-%typemap(cstype) TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
+%typemap(ctype, out="void *") TYPE *INOUT, TYPE &INOUT "CTYPE *"
+%typemap(imtype, out="IntPtr") TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
+%typemap(cstype, out="$csclassname") TYPE *INOUT, TYPE &INOUT "ref CSTYPE"
%typemap(csin) TYPE *INOUT, TYPE &INOUT "ref $csinput"
%typemap(csdirectorin) TYPE *INOUT, TYPE &INOUT "$iminput"
%typemap(csdirectorout) TYPE *INOUT, TYPE &INOUT "$cscall"
diff --git a/Lib/csharp/wchar.i b/Lib/csharp/wchar.i
index f02c09a53..1d95edded 100644
--- a/Lib/csharp/wchar.i
+++ b/Lib/csharp/wchar.i
@@ -1,102 +1,102 @@
-/* -----------------------------------------------------------------------------
- * wchar.i
- *
- * Typemaps for the wchar_t type
- * These are mapped to a C# String and are passed around by value.
- *
- * Support code for wide strings can be turned off by defining SWIG_CSHARP_NO_WSTRING_HELPER
- *
- * ----------------------------------------------------------------------------- */
-
-#if !defined(SWIG_CSHARP_NO_WSTRING_HELPER)
-#if !defined(SWIG_CSHARP_WSTRING_HELPER_)
-#define SWIG_CSHARP_WSTRING_HELPER_
-%insert(runtime) %{
-/* Callback for returning strings to C# without leaking memory */
-typedef void * (SWIGSTDCALL* SWIG_CSharpWStringHelperCallback)(const wchar_t *);
-static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL;
-%}
-
-%pragma(csharp) imclasscode=%{
- protected class SWIGWStringHelper {
-
- public delegate string SWIGWStringDelegate(IntPtr message);
- static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString);
-
- [DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")]
- public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringDelegate);
-
- static string CreateWString([MarshalAs(UnmanagedType.LPWStr)]IntPtr cString) {
- return System.Runtime.InteropServices.Marshal.PtrToStringUni(cString);
- }
-
- static SWIGWStringHelper() {
- SWIGRegisterWStringCallback_$module(wstringDelegate);
- }
- }
-
- static protected SWIGWStringHelper swigWStringHelper = new SWIGWStringHelper();
-%}
-
-%insert(runtime) %{
-#ifdef __cplusplus
-extern "C"
-#endif
-SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStringHelperCallback callback) {
- SWIG_csharp_wstring_callback = callback;
-}
-%}
-#endif // SWIG_CSHARP_WSTRING_HELPER_
-#endif // SWIG_CSHARP_NO_WSTRING_HELPER
-
-
-// wchar_t
-%typemap(ctype) wchar_t "wchar_t"
-%typemap(imtype) wchar_t "char"
-%typemap(cstype) wchar_t "char"
-
-%typemap(csin) wchar_t "$csinput"
-%typemap(csout, excode=SWIGEXCODE) wchar_t {
- char ret = $imcall;$excode
- return ret;
- }
-%typemap(csvarin, excode=SWIGEXCODE2) wchar_t %{
- set {
- $imcall;$excode
- } %}
-%typemap(csvarout, excode=SWIGEXCODE2) wchar_t %{
- get {
- char ret = $imcall;$excode
- return ret;
- } %}
-
-%typemap(in) wchar_t %{ $1 = ($1_ltype)$input; %}
-%typemap(out) wchar_t %{ $result = (wchar_t)$1; %}
-
-%typemap(typecheck) wchar_t = char;
-
-// wchar_t *
-%typemap(ctype) wchar_t * "wchar_t *"
-%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]", out="IntPtr" ) wchar_t * "string"
-%typemap(cstype) wchar_t * "string"
-
-%typemap(csin) wchar_t * "$csinput"
-%typemap(csout, excode=SWIGEXCODE) wchar_t * {
- string ret = System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode
- return ret;
- }
-%typemap(csvarin, excode=SWIGEXCODE2) wchar_t * %{
- set {
- $imcall;$excode
- } %}
-%typemap(csvarout, excode=SWIGEXCODE2) wchar_t * %{
- get {
- string ret = $imcall;$excode
- return ret;
- } %}
-
-%typemap(in) wchar_t * %{ $1 = ($1_ltype)$input; %}
-%typemap(out) wchar_t * %{ $result = (wchar_t *)$1; %}
-
-%typemap(typecheck) wchar_t * = char *;
-
+/* -----------------------------------------------------------------------------
+ * wchar.i
+ *
+ * Typemaps for the wchar_t type
+ * These are mapped to a C# String and are passed around by value.
+ *
+ * Support code for wide strings can be turned off by defining SWIG_CSHARP_NO_WSTRING_HELPER
+ *
+ * ----------------------------------------------------------------------------- */
+
+#if !defined(SWIG_CSHARP_NO_WSTRING_HELPER)
+#if !defined(SWIG_CSHARP_WSTRING_HELPER_)
+#define SWIG_CSHARP_WSTRING_HELPER_
+%insert(runtime) %{
+/* Callback for returning strings to C# without leaking memory */
+typedef void * (SWIGSTDCALL* SWIG_CSharpWStringHelperCallback)(const wchar_t *);
+static SWIG_CSharpWStringHelperCallback SWIG_csharp_wstring_callback = NULL;
+%}
+
+%pragma(csharp) imclasscode=%{
+ protected class SWIGWStringHelper {
+
+ public delegate string SWIGWStringDelegate(IntPtr message);
+ static SWIGWStringDelegate wstringDelegate = new SWIGWStringDelegate(CreateWString);
+
+ [DllImport("$dllimport", EntryPoint="SWIGRegisterWStringCallback_$module")]
+ public static extern void SWIGRegisterWStringCallback_$module(SWIGWStringDelegate wstringDelegate);
+
+ static string CreateWString([MarshalAs(UnmanagedType.LPWStr)]IntPtr cString) {
+ return System.Runtime.InteropServices.Marshal.PtrToStringUni(cString);
+ }
+
+ static SWIGWStringHelper() {
+ SWIGRegisterWStringCallback_$module(wstringDelegate);
+ }
+ }
+
+ static protected SWIGWStringHelper swigWStringHelper = new SWIGWStringHelper();
+%}
+
+%insert(runtime) %{
+#ifdef __cplusplus
+extern "C"
+#endif
+SWIGEXPORT void SWIGSTDCALL SWIGRegisterWStringCallback_$module(SWIG_CSharpWStringHelperCallback callback) {
+ SWIG_csharp_wstring_callback = callback;
+}
+%}
+#endif // SWIG_CSHARP_WSTRING_HELPER_
+#endif // SWIG_CSHARP_NO_WSTRING_HELPER
+
+
+// wchar_t
+%typemap(ctype) wchar_t "wchar_t"
+%typemap(imtype) wchar_t "char"
+%typemap(cstype) wchar_t "char"
+
+%typemap(csin) wchar_t "$csinput"
+%typemap(csout, excode=SWIGEXCODE) wchar_t {
+ char ret = $imcall;$excode
+ return ret;
+ }
+%typemap(csvarin, excode=SWIGEXCODE2) wchar_t %{
+ set {
+ $imcall;$excode
+ } %}
+%typemap(csvarout, excode=SWIGEXCODE2) wchar_t %{
+ get {
+ char ret = $imcall;$excode
+ return ret;
+ } %}
+
+%typemap(in) wchar_t %{ $1 = ($1_ltype)$input; %}
+%typemap(out) wchar_t %{ $result = (wchar_t)$1; %}
+
+%typemap(typecheck) wchar_t = char;
+
+// wchar_t *
+%typemap(ctype) wchar_t * "wchar_t *"
+%typemap(imtype, inattributes="[MarshalAs(UnmanagedType.LPWStr)]", out="IntPtr" ) wchar_t * "string"
+%typemap(cstype) wchar_t * "string"
+
+%typemap(csin) wchar_t * "$csinput"
+%typemap(csout, excode=SWIGEXCODE) wchar_t * {
+ string ret = System.Runtime.InteropServices.Marshal.PtrToStringUni($imcall);$excode
+ return ret;
+ }
+%typemap(csvarin, excode=SWIGEXCODE2) wchar_t * %{
+ set {
+ $imcall;$excode
+ } %}
+%typemap(csvarout, excode=SWIGEXCODE2) wchar_t * %{
+ get {
+ string ret = $imcall;$excode
+ return ret;
+ } %}
+
+%typemap(in) wchar_t * %{ $1 = ($1_ltype)$input; %}
+%typemap(out) wchar_t * %{ $result = (wchar_t *)$1; %}
+
+%typemap(typecheck) wchar_t * = char *;
+
diff --git a/Lib/d/boost_shared_ptr.i b/Lib/d/boost_shared_ptr.i
new file mode 100644
index 000000000..37ce26d00
--- /dev/null
+++ b/Lib/d/boost_shared_ptr.i
@@ -0,0 +1,201 @@
+%include <shared_ptr.i>
+
+%define SWIG_SHARED_PTR_TYPEMAPS(CONST, TYPE...)
+
+%naturalvar TYPE;
+%naturalvar SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+
+// destructor mods
+%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;"
+
+
+// plain value
+%typemap(in, canthrow=1) CONST TYPE ($&1_type argp = 0) %{
+ argp = ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0;
+ if (!argp) {
+ SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Attempt to dereference null $1_type");
+ return $null;
+ }
+ $1 = *argp; %}
+%typemap(out) CONST TYPE
+%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(new $1_ltype(($1_ltype &)$1)); %}
+
+// plain pointer
+%typemap(in, canthrow=1) CONST TYPE * (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *smartarg = 0) %{
+ smartarg = (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input;
+ $1 = (TYPE *)(smartarg ? smartarg->get() : 0); %}
+%typemap(out, fragment="SWIG_null_deleter") CONST TYPE * %{
+ $result = $1 ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner) : 0;
+%}
+
+// plain reference
+%typemap(in, canthrow=1) CONST TYPE & %{
+ $1 = ($1_ltype)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0);
+ if (!$1) {
+ SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type reference is null");
+ return $null;
+ } %}
+%typemap(out, fragment="SWIG_null_deleter") CONST TYPE &
+%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >($1 SWIG_NO_NULL_DELETER_$owner); %}
+
+// plain pointer by reference
+%typemap(in) TYPE *CONST& ($*1_ltype temp = 0)
+%{ temp = (TYPE *)(((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input) ? ((SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *)$input)->get() : 0);
+ $1 = &temp; %}
+%typemap(out, fragment="SWIG_null_deleter") TYPE *CONST&
+%{ $result = new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(*$1 SWIG_NO_NULL_DELETER_$owner); %}
+
+// shared_ptr by value
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >
+%{ if ($input) $1 = *($&1_ltype)$input; %}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >
+%{ $result = $1 ? new $1_ltype($1) : 0; %}
+
+// shared_ptr by reference
+%typemap(in, canthrow=1) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & ($*1_ltype tempnull)
+%{ $1 = $input ? ($1_ltype)$input : &tempnull; %}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > &
+%{ $result = *$1 ? new $*1_ltype(*$1) : 0; %}
+
+// shared_ptr by pointer
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * ($*1_ltype tempnull)
+%{ $1 = $input ? ($1_ltype)$input : &tempnull; %}
+%typemap(out, fragment="SWIG_null_deleter") SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *
+%{ $result = ($1 && *$1) ? new $*1_ltype(*($1_ltype)$1) : 0;
+ if ($owner) delete $1; %}
+
+// shared_ptr by pointer reference
+%typemap(in) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& (SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > tempnull, $*1_ltype temp = 0)
+%{ temp = $input ? *($1_ltype)&$input : &tempnull;
+ $1 = &temp; %}
+%typemap(out) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *&
+%{ *($1_ltype)&$result = (*$1 && **$1) ? new SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >(**$1) : 0; %}
+
+// 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"
+%}
+
+
+%typemap (ctype) 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 > *& "void *"
+%typemap (imtype) 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 > *& "void*"
+%typemap (dtype) 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 > *& "$typemap(dtype, TYPE)"
+
+%typemap(din) 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 > *& "$typemap(dtype, TYPE).swigGetCPtr($dinput)"
+
+%typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > {
+ void* cPtr = $imcall;
+ auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode
+ return ret;
+}
+%typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > & {
+ void* cPtr = $imcall;
+ auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode
+ return ret;
+}
+%typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > * {
+ void* cPtr = $imcall;
+ auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode
+ return ret;
+}
+%typemap(dout, excode=SWIGEXCODE) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE > *& {
+ void* cPtr = $imcall;
+ auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode
+ return ret;
+}
+
+
+%typemap(dout, excode=SWIGEXCODE) CONST TYPE {
+ auto ret = new $typemap(dtype, TYPE)($imcall, true);$excode
+ return ret;
+}
+%typemap(dout, excode=SWIGEXCODE) CONST TYPE & {
+ auto ret = new $typemap(dtype, TYPE)($imcall, true);$excode
+ return ret;
+}
+%typemap(dout, excode=SWIGEXCODE) CONST TYPE * {
+ void* cPtr = $imcall;
+ auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode
+ return ret;
+}
+%typemap(dout, excode=SWIGEXCODE) TYPE *CONST& {
+ void* cPtr = $imcall;
+ auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode
+ return ret;
+}
+
+// For shared pointers, both the derived and the base class have to »own« their
+// pointer; otherwise the reference count is not decreased properly on destruction.
+%typemap(dbody) SWIGTYPE %{
+private void* swigCPtr;
+private bool swigCMemOwn;
+
+public this(void* cObject, bool ownCObject) {
+ swigCPtr = cObject;
+ swigCMemOwn = ownCObject;
+}
+
+public static void* swigGetCPtr($dclassname obj) {
+ return (obj is null) ? null : obj.swigCPtr;
+}
+%}
+
+%typemap(dbody_derived) SWIGTYPE %{
+private void* swigCPtr;
+private bool swigCMemOwn;
+
+public this(void* cObject, bool ownCObject) {
+ super($imdmodule.$dclassnameSmartPtrUpcast(cObject), ownCObject);
+ swigCPtr = cObject;
+ swigCMemOwn = ownCObject;
+}
+
+public static void* swigGetCPtr($dclassname obj) {
+ return (obj is null) ? null : obj.swigCPtr;
+}
+%}
+
+%typemap(ddispose, methodname="dispose", methodmodifiers="public") TYPE {
+ synchronized(this) {
+ if (swigCPtr !is null) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ $imcall;
+ }
+ swigCPtr = null;
+ }
+ }
+}
+
+%typemap(ddispose_derived, methodname="dispose", methodmodifiers="public") TYPE {
+ synchronized(this) {
+ if (swigCPtr !is null) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ $imcall;
+ }
+ swigCPtr = null;
+ super.dispose();
+ }
+ }
+}
+
+%template() SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >;
+%enddef
diff --git a/Lib/d/carrays.i b/Lib/d/carrays.i
new file mode 100644
index 000000000..9893d09e5
--- /dev/null
+++ b/Lib/d/carrays.i
@@ -0,0 +1,111 @@
+/* -----------------------------------------------------------------------------
+ * carrays.i
+ *
+ * D-specific version of ../carrays.i.
+ * ----------------------------------------------------------------------------- */
+
+/* -----------------------------------------------------------------------------
+ * %array_functions(TYPE,NAME)
+ *
+ * Generates functions for creating and accessing elements of a C array
+ * (as pointers). Creates the following functions:
+ *
+ * TYPE *new_NAME(int nelements)
+ * void delete_NAME(TYPE *);
+ * TYPE NAME_getitem(TYPE *, int index);
+ * void NAME_setitem(TYPE *, int index, TYPE value);
+ *
+ * ----------------------------------------------------------------------------- */
+
+%define %array_functions(TYPE,NAME)
+%{
+static TYPE *new_##NAME(int nelements) { %}
+#ifdef __cplusplus
+%{ return new TYPE[nelements]; %}
+#else
+%{ return (TYPE *) calloc(nelements,sizeof(TYPE)); %}
+#endif
+%{}
+
+static void delete_##NAME(TYPE *ary) { %}
+#ifdef __cplusplus
+%{ delete [] ary; %}
+#else
+%{ free(ary); %}
+#endif
+%{}
+
+static TYPE NAME##_getitem(TYPE *ary, int index) {
+ return ary[index];
+}
+static void NAME##_setitem(TYPE *ary, int index, TYPE value) {
+ ary[index] = value;
+}
+%}
+
+TYPE *new_##NAME(int nelements);
+void delete_##NAME(TYPE *ary);
+TYPE NAME##_getitem(TYPE *ary, int index);
+void NAME##_setitem(TYPE *ary, int index, TYPE value);
+
+%enddef
+
+
+/* -----------------------------------------------------------------------------
+ * %array_class(TYPE,NAME)
+ *
+ * Generates a class wrapper around a C array. The class has the following
+ * interface:
+ *
+ * struct NAME {
+ * NAME(int nelements);
+ * ~NAME();
+ * TYPE getitem(int index);
+ * void setitem(int index, TYPE value);
+ * TYPE * ptr();
+ * static NAME *frompointer(TYPE *t);
+ * }
+ *
+ * ----------------------------------------------------------------------------- */
+
+%define %array_class(TYPE,NAME)
+%{
+typedef TYPE NAME;
+%}
+
+typedef struct NAME {} NAME;
+
+%extend NAME {
+#ifdef __cplusplus
+ NAME(int nelements) {
+ return new TYPE[nelements];
+ }
+ ~NAME() {
+ delete [] self;
+ }
+#else
+ NAME(int nelements) {
+ return (TYPE *) calloc(nelements,sizeof(TYPE));
+ }
+ ~NAME() {
+ free(self);
+ }
+#endif
+
+ TYPE getitem(int index) {
+ return self[index];
+ }
+ void setitem(int index, TYPE value) {
+ self[index] = value;
+ }
+ TYPE * ptr() {
+ return self;
+ }
+ static NAME *frompointer(TYPE *t) {
+ return (NAME *) t;
+ }
+};
+
+%types(NAME = TYPE);
+
+%enddef
diff --git a/Lib/d/cpointer.i b/Lib/d/cpointer.i
new file mode 100644
index 000000000..75e610f67
--- /dev/null
+++ b/Lib/d/cpointer.i
@@ -0,0 +1,171 @@
+/* -----------------------------------------------------------------------------
+ * cpointer.i
+ *
+ * D-specific version of ../cpointer.i.
+ * ----------------------------------------------------------------------------- */
+
+/* -----------------------------------------------------------------------------
+ * %pointer_class(type,name)
+ *
+ * Places a simple proxy around a simple type like 'int', 'float', or whatever.
+ * The proxy provides this interface:
+ *
+ * class type {
+ * public:
+ * type();
+ * ~type();
+ * type value();
+ * void assign(type value);
+ * };
+ *
+ * Example:
+ *
+ * %pointer_class(int, intp);
+ *
+ * int add(int *x, int *y) { return *x + *y; }
+ *
+ * In python (with proxies)
+ *
+ * >>> a = intp()
+ * >>> a.assign(10)
+ * >>> a.value()
+ * 10
+ * >>> b = intp()
+ * >>> b.assign(20)
+ * >>> print add(a,b)
+ * 30
+ *
+ * As a general rule, this macro should not be used on class/structures that
+ * are already defined in the interface.
+ * ----------------------------------------------------------------------------- */
+
+
+%define %pointer_class(TYPE, NAME)
+%{
+typedef TYPE NAME;
+%}
+
+typedef struct {
+} NAME;
+
+%extend NAME {
+#ifdef __cplusplus
+NAME() {
+ return new TYPE();
+}
+~NAME() {
+ if (self) delete self;
+}
+#else
+NAME() {
+ return (TYPE *) calloc(1,sizeof(TYPE));
+}
+~NAME() {
+ if (self) free(self);
+}
+#endif
+}
+
+%extend NAME {
+
+void assign(TYPE value) {
+ *self = value;
+}
+TYPE value() {
+ return *self;
+}
+TYPE * ptr() {
+ return self;
+}
+static NAME * frompointer(TYPE *t) {
+ return (NAME *) t;
+}
+
+}
+
+%types(NAME = TYPE);
+
+%enddef
+
+/* -----------------------------------------------------------------------------
+ * %pointer_functions(type,name)
+ *
+ * Create functions for allocating/deallocating pointers. This can be used
+ * if you don't want to create a proxy class or if the pointer is complex.
+ *
+ * %pointer_functions(int, intp)
+ *
+ * int add(int *x, int *y) { return *x + *y; }
+ *
+ * In python (with proxies)
+ *
+ * >>> a = copy_intp(10)
+ * >>> intp_value(a)
+ * 10
+ * >>> b = new_intp()
+ * >>> intp_assign(b,20)
+ * >>> print add(a,b)
+ * 30
+ * >>> delete_intp(a)
+ * >>> delete_intp(b)
+ *
+ * ----------------------------------------------------------------------------- */
+
+%define %pointer_functions(TYPE,NAME)
+%{
+static TYPE *new_##NAME() { %}
+#ifdef __cplusplus
+%{ return new TYPE(); %}
+#else
+%{ return (TYPE *) calloc(1,sizeof(TYPE)); %}
+#endif
+%{}
+
+static TYPE *copy_##NAME(TYPE value) { %}
+#ifdef __cplusplus
+%{ return new TYPE(value); %}
+#else
+%{ TYPE *self = (TYPE *) calloc(1,sizeof(TYPE));
+ *self = value;
+ return self; %}
+#endif
+%{}
+
+static void delete_##NAME(TYPE *self) { %}
+#ifdef __cplusplus
+%{ if (self) delete self; %}
+#else
+%{ if (self) free(self); %}
+#endif
+%{}
+
+static void NAME ##_assign(TYPE *self, TYPE value) {
+ *self = value;
+}
+
+static TYPE NAME ##_value(TYPE *self) {
+ return *self;
+}
+%}
+
+TYPE *new_##NAME();
+TYPE *copy_##NAME(TYPE value);
+void delete_##NAME(TYPE *self);
+void NAME##_assign(TYPE *self, TYPE value);
+TYPE NAME##_value(TYPE *self);
+
+%enddef
+
+/* -----------------------------------------------------------------------------
+ * %pointer_cast(type1,type2,name)
+ *
+ * Generates a pointer casting function.
+ * ----------------------------------------------------------------------------- */
+
+%define %pointer_cast(TYPE1,TYPE2,NAME)
+%inline %{
+TYPE2 NAME(TYPE1 x) {
+ return (TYPE2) x;
+}
+%}
+%enddef
diff --git a/Lib/d/d.swg b/Lib/d/d.swg
new file mode 100644
index 000000000..f5bb4596c
--- /dev/null
+++ b/Lib/d/d.swg
@@ -0,0 +1,46 @@
+/* -----------------------------------------------------------------------------
+ * d.swg
+ *
+ * Main library file for the D language module. See the D chapter in the SWIG
+ * manual for explanation on the typemaps, pragmas, etc. used.
+ * ----------------------------------------------------------------------------- */
+
+// Typemaps for exception handling.
+%include <dexception.swg>
+
+// Typemaps for primitive types.
+%include <dprimitives.swg>
+
+// Typemaps for non-primitive types (C/C++ classes and structs).
+%include <dswigtype.swg>
+
+// Typemaps for enumeration types.
+%include <denums.swg>
+
+// Typemaps for member function pointers.
+%include <dmemberfunctionpointers.swg>
+
+// Typemaps for wrapping pointers to/arrays of C chars as D strings.
+%include <dstrings.swg>
+
+// Typemaps for handling void function return types and empty parameter lists.
+%include <dvoid.swg>
+
+// Typemaps containing D code used when generating D proxy classes.
+%include <dclassgen.swg>
+
+// Mapping of C++ operator overloading methods to D.
+%include <doperators.swg>
+
+// Helper code string and exception handling.
+%include <dhead.swg>
+
+// Wrapper loader code for dynamically linking the C wrapper library from the D
+// wrapper module.
+%include <wrapperloader.swg>
+
+// List of all reserved D keywords.
+%include <dkw.swg>
+
+// D-specific directives.
+%include <ddirectives.swg>
diff --git a/Lib/d/dclassgen.swg b/Lib/d/dclassgen.swg
new file mode 100644
index 000000000..467621f4a
--- /dev/null
+++ b/Lib/d/dclassgen.swg
@@ -0,0 +1,142 @@
+/* -----------------------------------------------------------------------------
+ * dclassgen.swg
+ *
+ * Typemaps containing D code used when generating D proxy classes.
+ * ----------------------------------------------------------------------------- */
+
+%typemap(dbase) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(dclassmodifiers) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) "class"
+%typemap(dcode) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(dimports) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(dinterfaces) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+%typemap(dinterfaces_derived) SWIGTYPE, SWIGTYPE *, SWIGTYPE &, SWIGTYPE [], SWIGTYPE (CLASS::*) ""
+
+// See <denums.swg>.
+%typemap(dclassmodifiers) enum SWIGTYPE "enum"
+%typemap(dcode) enum SWIGTYPE ""
+
+
+/*
+ * Proxy classes.
+ */
+
+%typemap(dconstructor, excode=SWIGEXCODE,directorconnect="\n swigDirectorConnect();") SWIGTYPE {
+ this($imcall, true);$excode$directorconnect
+}
+
+%typemap(ddestructor) SWIGTYPE %{
+~this() {
+ dispose();
+}
+%}
+
+// We do not use »override« attribute for generated dispose() methods to stay
+// somewhat compatible to Phobos and older Tango versions where Object.dispose()
+// does not exist.
+%typemap(ddispose, methodname="dispose", methodmodifiers="public") SWIGTYPE {
+ synchronized(this) {
+ if (swigCPtr !is null) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ $imcall;
+ }
+ swigCPtr = null;
+ }
+ }
+}
+
+%typemap(ddispose_derived, methodname="dispose", methodmodifiers="public") SWIGTYPE {
+ synchronized(this) {
+ if (swigCPtr !is null) {
+ if (swigCMemOwn) {
+ swigCMemOwn = false;
+ $imcall;
+ }
+ swigCPtr = null;
+ super.dispose();
+ }
+ }
+}
+
+
+// Unfortunately, the »package« visibility attribute does not work in D when the
+// module in question is in the root package (happens if no -package is specified
+// at the SWIG command line), so we are stuck with public visibility for
+// swigGetCPtr().
+%typemap(dbody) SWIGTYPE %{
+private void* swigCPtr;
+protected bool swigCMemOwn;
+
+public this(void* cObject, bool ownCObject) {
+ swigCPtr = cObject;
+ swigCMemOwn = ownCObject;
+}
+
+public static void* swigGetCPtr($dclassname obj) {
+ return (obj is null) ? null : obj.swigCPtr;
+}
+
+mixin $imdmodule.SwigOperatorDefinitions;
+%}
+
+
+%typemap(dbody_derived) SWIGTYPE %{
+private void* swigCPtr;
+
+public this(void* cObject, bool ownCObject) {
+ super($imdmodule.$dclassnameUpcast(cObject), ownCObject);
+ swigCPtr = cObject;
+}
+
+public static void* swigGetCPtr($dclassname obj) {
+ return (obj is null) ? null : obj.swigCPtr;
+}
+
+mixin $imdmodule.SwigOperatorDefinitions;
+%}
+
+
+/*
+ * Type wrapper classes.
+ */
+
+%typemap(dbody) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] %{
+private void* swigCPtr;
+
+public this(void* cObject, bool futureUse) {
+ swigCPtr = cObject;
+}
+
+protected this() {
+ swigCPtr = null;
+}
+
+public static void* swigGetCPtr($dclassname obj) {
+ return (obj is null) ? null : obj.swigCPtr;
+}
+
+mixin $imdmodule.SwigOperatorDefinitions;
+%}
+
+
+/*
+ * Member function pointer wrapper classes (see <dmemberfunctionpointers.swg>).
+ */
+
+%typemap(dbody) SWIGTYPE (CLASS::*) %{
+private char* swigCPtr;
+
+public this(char* cMemberPtr, bool futureUse) {
+ swigCPtr = cMemberPtr;
+}
+
+protected this() {
+ swigCPtr = null;
+}
+
+package static char* swigGetCMemberPtr($dclassname obj) {
+ return (obj is null) ? null : obj.swigCPtr;
+}
+
+mixin $imdmodule.SwigOperatorDefinitions;
+%}
diff --git a/Lib/d/ddirectives.swg b/Lib/d/ddirectives.swg
new file mode 100644
index 000000000..6972a0c18
--- /dev/null
+++ b/Lib/d/ddirectives.swg
@@ -0,0 +1,10 @@
+/* -----------------------------------------------------------------------------
+ * ddirectives.swg
+ *
+ * D-specifiv directives.
+ * ----------------------------------------------------------------------------- */
+
+#define %dmanifestconst %feature("d:manifestconst")
+#define %dconstvalue(value) %feature("d:constvalue",value)
+#define %dmethodmodifiers %feature("d:methodmodifiers")
+#define %dnothrowexception %feature("except")
diff --git a/Lib/d/denums.swg b/Lib/d/denums.swg
new file mode 100644
index 000000000..a216527b2
--- /dev/null
+++ b/Lib/d/denums.swg
@@ -0,0 +1,60 @@
+/* -----------------------------------------------------------------------------
+ * denums.swg
+ *
+ * Typemaps for enumerations.
+ * ----------------------------------------------------------------------------- */
+
+
+/*
+ * Typemaps for enumeration types.
+ */
+
+%typemap(ctype) enum SWIGTYPE "int"
+%typemap(imtype) enum SWIGTYPE "int"
+%typemap(dtype, cprimitive="1") enum SWIGTYPE "$dclassname"
+
+%typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE ""
+
+%typemap(in) enum SWIGTYPE %{ $1 = ($1_ltype)$input; %}
+%typemap(out) enum SWIGTYPE %{ $result = $1; %}
+
+%typemap(directorout) enum SWIGTYPE %{ $result = ($1_ltype)$input; %}
+%typemap(directorin) enum SWIGTYPE "$input = $1;"
+%typemap(ddirectorin) enum SWIGTYPE "cast($dclassname)$winput"
+%typemap(ddirectorout) enum SWIGTYPE "cast(int)$dcall"
+
+%typemap(din) enum SWIGTYPE "cast(int)$dinput"
+%typemap(dout, excode=SWIGEXCODE) enum SWIGTYPE {
+ $dclassname ret = cast($dclassname)$imcall;$excode
+ return ret;
+}
+
+
+/*
+ * Typemaps for (const) references to enumeration types.
+ */
+
+%typemap(ctype) const enum SWIGTYPE & "int"
+%typemap(imtype) const enum SWIGTYPE & "int"
+%typemap(dtype) const enum SWIGTYPE & "$*dclassname"
+
+%typecheck(SWIG_TYPECHECK_POINTER) const enum SWIGTYPE & ""
+
+%typemap(in) const enum SWIGTYPE & ($*1_ltype temp)
+%{ temp = ($*1_ltype)$input;
+ $1 = &temp; %}
+%typemap(out) const enum SWIGTYPE & %{ $result = *$1; %}
+
+%typemap(directorin) const enum SWIGTYPE & "$input = $1_name;"
+%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const enum SWIGTYPE &
+%{ static $*1_ltype temp = ($*1_ltype)$input;
+ $result = &temp; %}
+
+%typemap(ddirectorin) const enum SWIGTYPE & "cast($*dclassname)$winput"
+%typemap(ddirectorout) const enum SWIGTYPE & "cast(int)$dcall"
+
+%typemap(din) const enum SWIGTYPE & "cast(int)$dinput"
+%typemap(dout, excode=SWIGEXCODE) const enum SWIGTYPE & {
+ $*dclassname ret = cast($*dclassname)$imcall;$excode
+ return ret;
+}
diff --git a/Lib/d/dexception.swg b/Lib/d/dexception.swg
new file mode 100644
index 000000000..1aadbaada
--- /dev/null
+++ b/Lib/d/dexception.swg
@@ -0,0 +1,30 @@
+/* -----------------------------------------------------------------------------
+ * dexception.swg
+ *
+ * Typemaps used for propagating C++ exceptions to D.
+ * ----------------------------------------------------------------------------- */
+
+// Code which is inserted into the dout typemaps and class constructors via
+// excode if exceptions can be thrown.
+%define SWIGEXCODE "\n if ($imdmodule.SwigPendingException.isPending) throw $imdmodule.SwigPendingException.retrieve();" %enddef
+
+%typemap(throws, canthrow=1) int,
+ long,
+ short,
+ unsigned int,
+ unsigned long,
+ unsigned short
+%{ char error_msg[256];
+ sprintf(error_msg, "C++ $1_type exception thrown, value: %d", $1);
+ SWIG_DSetPendingException(SWIG_DException, error_msg);
+ return $null; %}
+
+%typemap(throws, canthrow=1) SWIGTYPE, SWIGTYPE &, SWIGTYPE *, SWIGTYPE [ANY],
+ enum SWIGTYPE, const enum SWIGTYPE &
+%{ (void)$1;
+ SWIG_DSetPendingException(SWIG_DException, "C++ $1_type exception thrown");
+ return $null; %}
+
+%typemap(throws, canthrow=1) char *
+%{ SWIG_DSetPendingException(SWIG_DException, $1);
+ return $null; %}
diff --git a/Lib/d/dhead.swg b/Lib/d/dhead.swg
new file mode 100644
index 000000000..4326b7f8c
--- /dev/null
+++ b/Lib/d/dhead.swg
@@ -0,0 +1,310 @@
+/* -----------------------------------------------------------------------------
+ * dhead.swg
+ *
+ * Support code for exceptions if the SWIG_D_NO_EXCEPTION_HELPER is not defined
+ * Support code for strings if the SWIG_D_NO_STRING_HELPER is not defined
+ * ----------------------------------------------------------------------------- */
+
+%insert(runtime) %{
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+%}
+
+
+#if !defined(SWIG_D_NO_EXCEPTION_HELPER)
+%insert(runtime) %{
+// Support for throwing D exceptions from C/C++.
+typedef enum {
+ SWIG_DException = 0,
+ SWIG_DIllegalArgumentException,
+ SWIG_DIllegalElementException,
+ SWIG_DIOException,
+ SWIG_DNoSuchElementException,
+} SWIG_DExceptionCodes;
+
+typedef void (* SWIG_DExceptionCallback_t)(const char *);
+
+typedef struct {
+ SWIG_DExceptionCodes code;
+ SWIG_DExceptionCallback_t callback;
+} SWIG_DException_t;
+
+static SWIG_DException_t SWIG_d_exceptions[] = {
+ { SWIG_DException, NULL },
+ { SWIG_DIllegalArgumentException, NULL },
+ { SWIG_DIllegalElementException, NULL },
+ { SWIG_DIOException, NULL },
+ { SWIG_DNoSuchElementException, NULL }
+};
+
+static void SWIGUNUSED SWIG_DSetPendingException(SWIG_DExceptionCodes code, const char *msg) {
+ if ((size_t)code < sizeof(SWIG_d_exceptions)/sizeof(SWIG_DException_t)) {
+ SWIG_d_exceptions[code].callback(msg);
+ } else {
+ SWIG_d_exceptions[SWIG_DException].callback(msg);
+ }
+}
+
+#ifdef __cplusplus
+extern "C"
+#endif
+SWIGEXPORT void SWIGRegisterExceptionCallbacks_$module(
+ SWIG_DExceptionCallback_t exceptionCallback,
+ SWIG_DExceptionCallback_t illegalArgumentCallback,
+ SWIG_DExceptionCallback_t illegalElementCallback,
+ SWIG_DExceptionCallback_t ioCallback,
+ SWIG_DExceptionCallback_t noSuchElementCallback) {
+ SWIG_d_exceptions[SWIG_DException].callback = exceptionCallback;
+ SWIG_d_exceptions[SWIG_DIllegalArgumentException].callback = illegalArgumentCallback;
+ SWIG_d_exceptions[SWIG_DIllegalElementException].callback = illegalElementCallback;
+ SWIG_d_exceptions[SWIG_DIOException].callback = ioCallback;
+ SWIG_d_exceptions[SWIG_DNoSuchElementException].callback = noSuchElementCallback;
+}
+%}
+
+#if (SWIG_D_VERSION == 1)
+%pragma(d) imdmoduleimports=%{
+// Exception throwing support currently requires Tango, but there is no reason
+// why it could not support Phobos.
+static import tango.core.Exception;
+static import tango.core.Thread;
+static import tango.stdc.stringz;
+%}
+
+%pragma(d) imdmodulecode=%{
+private class SwigExceptionHelper {
+ static this() {
+ swigRegisterExceptionCallbacks(
+ &setException,
+ &setIllegalArgumentException,
+ &setIllegalElementException,
+ &setIOException,
+ &setNoSuchElementException);
+ }
+
+ static void setException(char* message) {
+ auto exception = new object.Exception(tango.stdc.stringz.fromStringz(message).dup);
+ exception.next = SwigPendingException.retrieve();
+ SwigPendingException.set(exception);
+ }
+
+ static void setIllegalArgumentException(char* message) {
+ auto exception = new tango.core.Exception.IllegalArgumentException(tango.stdc.stringz.fromStringz(message).dup);
+ exception.next = SwigPendingException.retrieve();
+ SwigPendingException.set(exception);
+ }
+
+ static void setIllegalElementException(char* message) {
+ auto exception = new tango.core.Exception.IllegalElementException(tango.stdc.stringz.fromStringz(message).dup);
+ exception.next = SwigPendingException.retrieve();
+ SwigPendingException.set(exception);
+ }
+
+ static void setIOException(char* message) {
+ auto exception = new tango.core.Exception.IOException(tango.stdc.stringz.fromStringz(message).dup);
+ exception.next = SwigPendingException.retrieve();
+ SwigPendingException.set(exception);
+ }
+
+ static void setNoSuchElementException(char* message) {
+ auto exception = new tango.core.Exception.NoSuchElementException(tango.stdc.stringz.fromStringz(message).dup);
+ exception.next = SwigPendingException.retrieve();
+ SwigPendingException.set(exception);
+ }
+}
+
+package class SwigPendingException {
+public:
+ static this() {
+ m_sPendingCount = 0;
+ m_sPendingException = new ThreadLocalData(null);
+ }
+
+ static bool isPending() {
+ bool pending = false;
+ if (m_sPendingCount > 0) {
+ if (m_sPendingException.val !is null) {
+ pending = true;
+ }
+ }
+ return pending;
+ }
+
+ static void set(object.Exception e) {
+ if (m_sPendingException.val !is null) {
+ throw new object.Exception("FATAL: An earlier pending exception from C/C++ code " ~
+ "was missed and thus not thrown (" ~ m_sPendingException.val.classinfo.name ~
+ ": " ~ m_sPendingException.val.msg ~ ")!", e);
+ }
+
+ m_sPendingException.val = e;
+ synchronized {
+ ++m_sPendingCount;
+ }
+ }
+
+ static object.Exception retrieve() {
+ object.Exception e = null;
+ if (m_sPendingCount > 0) {
+ if (m_sPendingException.val !is null) {
+ e = m_sPendingException.val;
+ m_sPendingException.val = null;
+ synchronized {
+ --m_sPendingCount;
+ }
+ }
+ }
+ return e;
+ }
+
+private:
+ // The pending exception counter is stored thread-global.
+ static int m_sPendingCount;
+
+ // The reference to the pending exception (if any) is stored thread-local.
+ alias tango.core.Thread.ThreadLocal!(object.Exception) ThreadLocalData;
+ static ThreadLocalData m_sPendingException;
+}
+alias void function(char* message) SwigExceptionCallback;
+%}
+#else
+%pragma(d) imdmoduleimports=%{
+static import std.conv;
+%}
+
+%pragma(d) imdmodulecode=%{
+private class SwigExceptionHelper {
+ static this() {
+ // The D1/Tango version maps C++ exceptions to multiple exception types.
+ swigRegisterExceptionCallbacks(
+ &setException,
+ &setException,
+ &setException,
+ &setException,
+ &setException
+ );
+ }
+
+ static void setException(char* message) {
+ auto exception = new object.Exception(std.conv.to!string(message).idup);
+ exception.next = SwigPendingException.retrieve();
+ SwigPendingException.set(exception);
+ }
+}
+
+package struct SwigPendingException {
+public:
+ static this() {
+ m_sPendingCount = 0;
+ m_sPendingException = null;
+ }
+
+ static bool isPending() {
+ bool pending = false;
+ if (m_sPendingCount > 0) {
+ if (m_sPendingException !is null) {
+ pending = true;
+ }
+ }
+ return pending;
+ }
+
+ static void set(object.Exception e) {
+ if (m_sPendingException !is null) {
+ throw new object.Exception("FATAL: An earlier pending exception from C/C++ code " ~
+ "was missed and thus not thrown (" ~ m_sPendingException.classinfo.name ~
+ ": " ~ m_sPendingException.msg ~ ")!", e);
+ }
+
+ m_sPendingException = e;
+ synchronized {
+ ++m_sPendingCount;
+ }
+ }
+
+ static object.Exception retrieve() {
+ object.Exception e = null;
+ if (m_sPendingCount > 0) {
+ if (m_sPendingException !is null) {
+ e = m_sPendingException;
+ m_sPendingException = null;
+ synchronized {
+ --m_sPendingCount;
+ }
+ }
+ }
+ return e;
+ }
+
+private:
+ // The pending exception counter is stored thread-global.
+ static shared int m_sPendingCount;
+
+ // The reference to the pending exception (if any) is stored thread-local.
+ static object.Exception m_sPendingException;
+}
+alias void function(const char* message) SwigExceptionCallback;
+%}
+#endif
+// Callback registering function in wrapperloader.swg.
+#endif // SWIG_D_NO_EXCEPTION_HELPER
+
+#if !defined(SWIG_D_NO_STRING_HELPER)
+%insert(runtime) %{
+// Callback for returning strings to D without leaking memory.
+typedef char * (* SWIG_DStringHelperCallback)(const char *);
+static SWIG_DStringHelperCallback SWIG_d_string_callback = NULL;
+
+#ifdef __cplusplus
+extern "C"
+#endif
+SWIGEXPORT void SWIGRegisterStringCallback_$module(SWIG_DStringHelperCallback callback) {
+ SWIG_d_string_callback = callback;
+}
+%}
+
+#if (SWIG_D_VERSION == 1)
+%pragma(d) imdmoduleimports = "static import tango.stdc.stringz;";
+
+%pragma(d) imdmodulecode = %{
+private class SwigStringHelper {
+ static this() {
+ swigRegisterStringCallback(&createString);
+ }
+
+ static char* createString(char* cString) {
+ // We are effectively dup'ing the string here.
+ return tango.stdc.stringz.toStringz(tango.stdc.stringz.fromStringz(cString));
+ }
+}
+alias char* function(char* cString) SwigStringCallback;
+%}
+#else
+%pragma(d) imdmoduleimports = %{
+static import std.conv;
+static import std.string;
+%}
+
+%pragma(d) imdmodulecode = %{
+private class SwigStringHelper {
+ static this() {
+ swigRegisterStringCallback(&createString);
+ }
+
+ static const(char)* createString(const(char*) cString) {
+ // We are effectively dup'ing the string here.
+ // TODO: Is this also correct for D2/Phobos?
+ return std.string.toStringz(std.conv.to!string(cString));
+ }
+}
+alias const(char)* function(const(char*) cString) SwigStringCallback;
+%}
+#endif
+// Callback registering function in wrapperloader.swg.
+#endif // SWIG_D_NO_STRING_HELPER
+
+%insert(runtime) %{
+/* Contract support. */
+#define SWIG_contract_assert(nullreturn, expr, msg) if (!(expr)) {SWIG_DSetPendingException(SWIG_DException, msg); return nullreturn; } else
+%}
diff --git a/Lib/d/director.swg b/Lib/d/director.swg
new file mode 100644
index 000000000..9692e03c1
--- /dev/null
+++ b/Lib/d/director.swg
@@ -0,0 +1,46 @@
+/* -----------------------------------------------------------------------------
+ * director.swg
+ *
+ * This file contains support for director classes so that D proxy
+ * methods can be called from C++.
+ * ----------------------------------------------------------------------------- */
+
+#ifdef __cplusplus
+
+#if defined(DEBUG_DIRECTOR_OWNED)
+#include <iostream>
+#endif
+#include <string>
+
+namespace Swig {
+ // Director base class – not used in D directors.
+ class Director {
+ };
+
+ // Base class for director exceptions.
+ class DirectorException {
+ protected:
+ std::string swig_msg;
+
+ public:
+ DirectorException(const char* msg) : swig_msg(msg) {
+ }
+ DirectorException(const std::string &msg) : swig_msg(msg) {
+ }
+ const std::string& what() const {
+ return swig_msg;
+ }
+ virtual ~DirectorException() {
+ }
+ };
+
+ // Exception which is thrown when attempting to call a pure virtual method
+ // from D code thorugh the director layer.
+ class DirectorPureVirtualException : public Swig::DirectorException {
+ public:
+ DirectorPureVirtualException(const char* msg) : DirectorException(std::string("Attempted to invoke pure virtual method ") + msg) {
+ }
+ };
+}
+
+#endif /* __cplusplus */
diff --git a/Lib/d/dkw.swg b/Lib/d/dkw.swg
new file mode 100644
index 000000000..5091f02cc
--- /dev/null
+++ b/Lib/d/dkw.swg
@@ -0,0 +1,126 @@
+#ifndef D_DKW_SWG_
+#define D_DKW_SWG_
+
+/* Warnings for D keywords */
+#define DKEYWORD(x) %keywordwarn("'" `x` "' is a D keyword, renaming to '_" `x` "'",rename="_%s") `x`
+
+// Source: http://www.digitalmars.com/d/{1.0,2.0}/lex.html and
+DKEYWORD(Object);
+DKEYWORD(__FILE__);
+DKEYWORD(__LINE__);
+DKEYWORD(__gshared);
+DKEYWORD(__thread);
+DKEYWORD(__traits);
+DKEYWORD(abstract);
+DKEYWORD(alias);
+DKEYWORD(align);
+DKEYWORD(asm);
+DKEYWORD(assert);
+DKEYWORD(auto);
+DKEYWORD(body);
+DKEYWORD(bool);
+DKEYWORD(break);
+DKEYWORD(byte);
+DKEYWORD(case);
+DKEYWORD(cast);
+DKEYWORD(catch);
+DKEYWORD(cdouble);
+DKEYWORD(cent);
+DKEYWORD(cfloat);
+DKEYWORD(char);
+DKEYWORD(class);
+DKEYWORD(const);
+DKEYWORD(continue);
+DKEYWORD(creal);
+DKEYWORD(dchar);
+DKEYWORD(debug);
+DKEYWORD(default);
+DKEYWORD(delegate);
+DKEYWORD(delete);
+DKEYWORD(deprecated);
+DKEYWORD(do);
+DKEYWORD(double);
+DKEYWORD(dstring);
+DKEYWORD(else);
+DKEYWORD(enum);
+DKEYWORD(export);
+DKEYWORD(extern);
+DKEYWORD(false);
+DKEYWORD(final);
+DKEYWORD(finally);
+DKEYWORD(float);
+DKEYWORD(for);
+DKEYWORD(foreach);
+DKEYWORD(foreach_reverse);
+DKEYWORD(function);
+DKEYWORD(goto);
+DKEYWORD(idouble);
+DKEYWORD(if);
+DKEYWORD(ifloat);
+DKEYWORD(immutable);
+DKEYWORD(import);
+DKEYWORD(in);
+DKEYWORD(inout);
+DKEYWORD(int);
+DKEYWORD(interface);
+DKEYWORD(invariant);
+DKEYWORD(ireal);
+DKEYWORD(is);
+DKEYWORD(lazy);
+DKEYWORD(long);
+DKEYWORD(macro);
+DKEYWORD(mixin);
+DKEYWORD(module);
+DKEYWORD(new);
+DKEYWORD(nothrow);
+DKEYWORD(null);
+DKEYWORD(out);
+DKEYWORD(override);
+DKEYWORD(package);
+DKEYWORD(pragma);
+DKEYWORD(private);
+DKEYWORD(protected);
+DKEYWORD(public);
+DKEYWORD(pure);
+DKEYWORD(real);
+DKEYWORD(ref);
+DKEYWORD(return);
+DKEYWORD(scope);
+DKEYWORD(shared);
+DKEYWORD(short);
+DKEYWORD(static);
+DKEYWORD(string);
+DKEYWORD(struct);
+DKEYWORD(super);
+DKEYWORD(switch);
+DKEYWORD(synchronized);
+DKEYWORD(template);
+DKEYWORD(this);
+DKEYWORD(throw);
+DKEYWORD(true);
+DKEYWORD(try);
+DKEYWORD(typedef);
+DKEYWORD(typeid);
+DKEYWORD(typeof);
+DKEYWORD(ubyte);
+DKEYWORD(ucent);
+DKEYWORD(uint);
+DKEYWORD(ulong);
+DKEYWORD(union);
+DKEYWORD(unittest);
+DKEYWORD(ushort);
+DKEYWORD(version);
+DKEYWORD(void);
+DKEYWORD(volatile);
+DKEYWORD(wchar);
+DKEYWORD(while);
+DKEYWORD(with);
+DKEYWORD(wstring);
+
+// Not really a keyword, but dispose() methods are generated in proxy classes
+// and it's a special method name for D1/Tango.
+DKEYWORD(dispose);
+
+#undef DKEYWORD
+
+#endif //D_DKW_SWG_
diff --git a/Lib/d/dmemberfunctionpointers.swg b/Lib/d/dmemberfunctionpointers.swg
new file mode 100644
index 000000000..c33ff3840
--- /dev/null
+++ b/Lib/d/dmemberfunctionpointers.swg
@@ -0,0 +1,92 @@
+/* -----------------------------------------------------------------------------
+ * dmemberfunctionpointers.swg
+ *
+ * Typemaps for member function pointers.
+ * ----------------------------------------------------------------------------- */
+
+
+%typemap(ctype) SWIGTYPE (CLASS::*) "char *"
+%typemap(imtype) SWIGTYPE (CLASS::*) "char*"
+%typemap(dtype) SWIGTYPE (CLASS::*) "$dclassname"
+
+%typecheck(SWIG_TYPECHECK_POINTER)
+ SWIGTYPE (CLASS::*)
+ ""
+
+
+/*
+ * Conversion generation typemaps.
+ */
+
+%typemap(in, fragment="SWIG_UnPackData") SWIGTYPE (CLASS::*) %{
+ SWIG_UnpackData($input, (void *)&$1, sizeof($1));
+%}
+%typemap(out, fragment="SWIG_PackData") SWIGTYPE (CLASS::*) %{
+ char buf[128];
+ char *data = SWIG_PackData(buf, (void *)&$1, sizeof($1));
+ *data = '\0';
+ $result = SWIG_d_string_callback(buf);
+%}
+
+%typemap(directorin) SWIGTYPE (CLASS::*) "$input = (void *) $1;"
+%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE (CLASS::*)
+ "$result = ($1_ltype)$input;"
+
+%typemap(ddirectorin) SWIGTYPE (CLASS::*)
+ "($winput is null) ? null : new $dclassname($winput, false)"
+%typemap(ddirectorout) SWIGTYPE (CLASS::*) "$dclassname.swigGetCPtr($dcall)"
+
+%typemap(din) SWIGTYPE (CLASS::*) "$dclassname.swigGetCMemberPtr($dinput)"
+%typemap(dout, excode=SWIGEXCODE) SWIGTYPE (CLASS::*) {
+ char* cMemberPtr = $imcall;
+ $dclassname ret = (cMemberPtr is null) ? null : new $dclassname(cMemberPtr, $owner);$excode
+ return ret;
+}
+
+
+/*
+ * Helper functions to pack/unpack arbitrary binary data (member function
+ * pointers in this case) into a string.
+ */
+
+%fragment("SWIG_PackData", "header") {
+/* Pack binary data into a string */
+SWIGINTERN char * SWIG_PackData(char *c, void *ptr, size_t sz) {
+ static const char hex[17] = "0123456789abcdef";
+ register const unsigned char *u = (unsigned char *) ptr;
+ register const unsigned char *eu = u + sz;
+ for (; u != eu; ++u) {
+ register unsigned char uu = *u;
+ *(c++) = hex[(uu & 0xf0) >> 4];
+ *(c++) = hex[uu & 0xf];
+ }
+ return c;
+}
+}
+
+%fragment("SWIG_UnPackData", "header") {
+/* Unpack binary data from a string */
+SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
+ register unsigned char *u = (unsigned char *) ptr;
+ register const unsigned char *eu = u + sz;
+ for (; u != eu; ++u) {
+ register char d = *(c++);
+ register unsigned char uu;
+ if ((d >= '0') && (d <= '9'))
+ uu = ((d - '0') << 4);
+ else if ((d >= 'a') && (d <= 'f'))
+ uu = ((d - ('a'-10)) << 4);
+ else
+ return (char *) 0;
+ d = *(c++);
+ if ((d >= '0') && (d <= '9'))
+ uu |= (d - '0');
+ else if ((d >= 'a') && (d <= 'f'))
+ uu |= (d - ('a'-10));
+ else
+ return (char *) 0;
+ *u = uu;
+ }
+ return c;
+}
+}
diff --git a/Lib/d/doperators.swg b/Lib/d/doperators.swg
new file mode 100644
index 000000000..0cb63533c
--- /dev/null
+++ b/Lib/d/doperators.swg
@@ -0,0 +1,259 @@
+/* -----------------------------------------------------------------------------
+ * doperators.swg
+ *
+ * Mapping of C++ operator overloading methods to D.
+ * ----------------------------------------------------------------------------- */
+
+#if (SWIG_D_VERSION == 1)
+
+%pragma(d) imdmodulecode=%{
+template SwigOperatorDefinitions() {
+ public override int opEquals(Object o) {
+ if (auto rhs = cast(typeof(this))o) {
+ if (swigCPtr == rhs.swigCPtr) return 1;
+ static if (is(typeof(swigOpEquals(rhs)))) {
+ return swigOpEquals(rhs) ? 1 : 0;
+ } else {
+ return 0;
+ }
+ }
+ return super.opEquals(o);
+ }
+%}
+// opEquals is emitted in pure C mode as well to define two proxy classes
+// pointing to the same struct as equal.
+
+#ifdef __cplusplus
+%rename(opPos) *::operator+();
+%rename(opPos) *::operator+() const;
+%rename(opNeg) *::operator-();
+%rename(opNeg) *::operator-() const;
+%rename(opCom) *::operator~();
+%rename(opCom) *::operator~() const;
+
+%rename(opAdd) *::operator+;
+%rename(opAddAssign) *::operator+=;
+%rename(opSub) *::operator-;
+%rename(opSubAssign) *::operator-=;
+%rename(opMul) *::operator*;
+%rename(opMulAssign) *::operator*=;
+%rename(opDiv) *::operator/;
+%rename(opDivAssign) *::operator/=;
+%rename(opMod) *::operator%;
+%rename(opModAssign) *::operator%=;
+%rename(opAnd) *::operator&;
+%rename(opAndAssign) *::operator&=;
+%rename(opOr) *::operator|;
+%rename(opOrAssign) *::operator|=;
+%rename(opXor) *::operator^;
+%rename(opXorAssign) *::operator^=;
+%rename(opShl) *::operator<<;
+%rename(opShlAssign) *::operator<<=;
+%rename(opShr) *::operator>>;
+%rename(opShrAssign) *::operator>>=;
+
+%rename(opIndex) *::operator[](unsigned) const;
+// opIndexAssign is not currently generated, it needs more extensive support
+// mechanisms.
+
+%rename(opCall) *::operator();
+
+// !a is not overrideable in D1.
+%ignoreoperator(LNOT) operator!;
+
+// opCmp is used in D.
+%rename(swigOpEquals) *::operator==;
+%rename(swigOpLt) *::operator<;
+%rename(swigOpLtEquals) *::operator<=;
+%rename(swigOpGt) *::operator>;
+%rename(swigOpGtEquals) *::operator>=;
+
+// a != b is rewritten as !a.opEquals(b) in D.
+%ignoreoperator(NOTEQUAL) operator!=;
+
+// The logic operators are not overrideable in D.
+%ignoreoperator(LAND) operator&&;
+%ignoreoperator(LOR) operator||;
+
+// ++/--a is rewritten as a +/-= 1 in D1,so ignore the prefix operators.
+%ignoreoperator(PLUSPLUS) *::operator++();
+%ignoreoperator(MINUSMINUS) *::operator--();
+%rename(swigOpInc) *::operator++(int);
+%rename(swigOpDec) *::operator--(int);
+
+// The C++ assignment operator does not translate well to D where the proxy
+// classes have reference semantics.
+%ignoreoperator(EQ) operator=;
+
+%pragma(d) imdmodulecode=%{
+ public override int opCmp(Object o) {
+ static if (is(typeof(swigOpLt(typeof(this).init) &&
+ swigOpEquals(typeof(this).init)))) {
+ if (auto rhs = cast(typeof(this))o) {
+ if (swigOpLt(rhs)) {
+ return -1;
+ } else if (swigOpEquals(rhs)) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+ }
+ return super.opCmp(o);
+ }
+
+ public typeof(this) opPostInc(T = int)(T unused = 0) {
+ static assert(
+ is(typeof(swigOpInc(int.init))),
+ "opPostInc called on " ~ typeof(this).stringof ~ ", but no postfix " ~
+ "increment operator exists in the corresponding C++ class."
+ );
+ return swigOpInc(int.init);
+ }
+
+ public typeof(this) opPostDec(T = int)(T unused = 0) {
+ static assert(
+ is(typeof(swigOpDec(int.init))),
+ "opPostInc called on " ~ typeof(this).stringof ~ ", but no postfix " ~
+ "decrement operator exists in the corresponding C++ class."
+ );
+ return swigOpDec(int.init);
+ }
+%}
+#endif
+
+%pragma(d) imdmodulecode=%{
+}
+%}
+
+#else
+%pragma(d) imdmodulecode=%{
+mixin template SwigOperatorDefinitions() {
+ public override bool opEquals(Object o) {
+ if (auto rhs = cast(typeof(this))o) {
+ if (swigCPtr == rhs.swigCPtr) return true;
+ static if (is(typeof(swigOpEquals(rhs)))) {
+ return swigOpEquals(rhs);
+ } else {
+ return false;
+ }
+ }
+ return super.opEquals(o);
+ }
+%}
+// opEquals is emitted in pure C mode as well to define two proxy classes
+// pointing to the same struct as equal.
+
+#ifdef __cplusplus
+%rename(swigOpPos) *::operator+();
+%rename(swigOpPos) *::operator+() const;
+%rename(swigOpNeg) *::operator-();
+%rename(swigOpNeg) *::operator-() const;
+%rename(swigOpCom) *::operator~();
+%rename(swigOpCom) *::operator~() const;
+%rename(swigOpInc) *::operator++();
+%rename(swigOpDec) *::operator--();
+%ignoreoperator(PLUSPLUS) *::operator++(int);
+%ignoreoperator(MINUSMINUS) *::operator--(int);
+// The postfix increment/decrement operators are ignored because they are
+// rewritten to (auto t = e, ++e, t) in D2. The unary * operator (used for
+// pointer dereferencing in C/C++) isn't mapped to opUnary("*") by default,
+// despite this would be possible in D2 – the difference in member access
+// semantics would only lead to confusion in most cases.
+
+%rename(swigOpAdd) *::operator+;
+%rename(swigOpSub) *::operator-;
+%rename(swigOpMul) *::operator*;
+%rename(swigOpDiv) *::operator/;
+%rename(swigOpMod) *::operator%;
+%rename(swigOpAnd) *::operator&;
+%rename(swigOpOr) *::operator|;
+%rename(swigOpXor) *::operator^;
+%rename(swigOpShl) *::operator<<;
+%rename(swigOpShr) *::operator>>;
+
+%rename(swigOpAddAssign) *::operator+=;
+%rename(swigOpSubAssign) *::operator-=;
+%rename(swigOpMulAssign) *::operator*=;
+%rename(swigOpDivAssign) *::operator/=;
+%rename(swigOpModAssign) *::operator%=;
+%rename(swigOpAndAssign) *::operator&=;
+%rename(swigOpOrAssign) *::operator|=;
+%rename(swigOpXorAssign) *::operator^=;
+%rename(swigOpShlAssign) *::operator<<=;
+%rename(swigOpShrAssign) *::operator>>=;
+
+%rename(opIndex) *::operator[];
+// opIndexAssign is not currently generated, it needs more extensive support
+// mechanisms.
+
+%rename(opCall) *::operator();
+
+%rename(swigOpEquals) *::operator==;
+%rename(swigOpLt) *::operator<;
+%rename(swigOpLtEquals) *::operator<=;
+%rename(swigOpGt) *::operator>;
+%rename(swigOpGtEquals) *::operator>=;
+
+// a != b is rewritten as !a.opEquals(b) in D.
+%ignoreoperator(NOTEQUAL) operator!=;
+
+// The logic operators are not overrideable in D.
+%ignoreoperator(LAND) operator&&;
+%ignoreoperator(LOR) operator||;
+
+// The C++ assignment operator does not translate well to D where the proxy
+// classes have reference semantics.
+%ignoreoperator(EQ) operator=;
+
+%pragma(d) imdmodulecode=%{
+ public override int opCmp(Object o) {
+ static if (__traits(compiles, swigOpLt(typeof(this).init) &&
+ swigOpEquals(typeof(this).init))) {
+ if (auto rhs = cast(typeof(this))o) {
+ if (swigOpLt(rhs)) {
+ return -1;
+ } else if (swigOpEquals(rhs)) {
+ return 0;
+ } else {
+ return 1;
+ }
+ }
+ }
+ return super.opCmp(o);
+ }
+
+ private template swigOpBinary(string operator, string name) {
+ enum swigOpBinary = `public void opOpAssign(string op, T)(T rhs) if (op == "` ~ operator ~
+ `" && __traits(compiles, swigOp` ~ name ~ `Assign(rhs))) { swigOp` ~ name ~ `Assign(rhs);}` ~
+ `public auto opBinary(string op, T)(T rhs) if (op == "` ~ operator ~
+ `" && __traits(compiles, swigOp` ~ name ~ `(rhs))) { return swigOp` ~ name ~ `(rhs);}`;
+ }
+ mixin(swigOpBinary!("+", "Add"));
+ mixin(swigOpBinary!("-", "Sub"));
+ mixin(swigOpBinary!("*", "Mul"));
+ mixin(swigOpBinary!("/", "Div"));
+ mixin(swigOpBinary!("%", "Mod"));
+ mixin(swigOpBinary!("&", "And"));
+ mixin(swigOpBinary!("|", "Or"));
+ mixin(swigOpBinary!("^", "Xor"));
+ mixin(swigOpBinary!("<<", "Shl"));
+ mixin(swigOpBinary!(">>", "Shr"));
+
+ private template swigOpUnary(string operator, string name) {
+ enum swigOpUnary = `public auto opUnary(string op)() if (op == "` ~ operator ~
+ `" && __traits(compiles, swigOp` ~ name ~ `())) { return swigOp` ~ name ~ `();}`;
+ }
+ mixin(swigOpUnary!("+", "Pos"));
+ mixin(swigOpUnary!("-", "Neg"));
+ mixin(swigOpUnary!("~", "Com"));
+ mixin(swigOpUnary!("++", "Inc"));
+ mixin(swigOpUnary!("--", "Dec"));
+%}
+#endif
+
+%pragma(d) imdmodulecode=%{
+}
+%}
+
+#endif
diff --git a/Lib/d/dprimitives.swg b/Lib/d/dprimitives.swg
new file mode 100644
index 000000000..53a4b89da
--- /dev/null
+++ b/Lib/d/dprimitives.swg
@@ -0,0 +1,158 @@
+/* -----------------------------------------------------------------------------
+ * dprimitves.swg
+ *
+ * Typemaps for primitive types.
+ * ----------------------------------------------------------------------------- */
+
+/*
+ * The SWIG_D_PRIMITIVE macro is used to define the typemaps for the primitive
+ * types, because are more or less the same for all of them. The few special
+ * cases are handeled below.
+ */
+%define SWIG_D_PRIMITIVE(TYPE, DTYPE)
+%typemap(ctype) TYPE, const TYPE & "TYPE"
+%typemap(imtype) TYPE, const TYPE & "DTYPE"
+%typemap(dtype, cprimitive="1") TYPE, const TYPE & "DTYPE"
+
+%typemap(in) TYPE "$1 = ($1_ltype)$input;"
+%typemap(out) TYPE "$result = $1;"
+%typemap(directorin) TYPE "$input = $1;"
+%typemap(directorout) TYPE "$result = ($1_ltype)$input;"
+%typemap(ddirectorin) TYPE "$winput"
+%typemap(ddirectorout) TYPE "$dcall"
+
+%typemap(in) const TYPE & ($*1_ltype temp)
+%{ temp = ($*1_ltype)$input;
+ $1 = &temp; %}
+%typemap(out) const TYPE & "$result = *$1;"
+%typemap(directorin) const TYPE & "$input = $1_name;"
+%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const TYPE &
+%{ static $*1_ltype temp;
+ temp = ($*1_ltype)$input;
+ $result = &temp; %}
+%typemap(ddirectorin) const TYPE & "$winput"
+%typemap(ddirectorout) const TYPE & "$dcall"
+
+%typemap(din) TYPE, const TYPE & "$dinput"
+%typemap(dout, excode=SWIGEXCODE) TYPE, const TYPE & {
+ auto ret = $imcall;$excode
+ return ret;
+}
+%enddef
+
+
+SWIG_D_PRIMITIVE(bool, bool)
+SWIG_D_PRIMITIVE(char, char)
+SWIG_D_PRIMITIVE(signed char, byte)
+SWIG_D_PRIMITIVE(unsigned char, ubyte)
+SWIG_D_PRIMITIVE(short, short)
+SWIG_D_PRIMITIVE(unsigned short, ushort)
+SWIG_D_PRIMITIVE(int, int)
+SWIG_D_PRIMITIVE(unsigned int, uint)
+SWIG_D_PRIMITIVE(long, int)
+SWIG_D_PRIMITIVE(unsigned long, uint)
+SWIG_D_PRIMITIVE(size_t, size_t)
+SWIG_D_PRIMITIVE(long long, long)
+SWIG_D_PRIMITIVE(unsigned long long, ulong)
+SWIG_D_PRIMITIVE(float, float)
+SWIG_D_PRIMITIVE(double, double)
+
+
+// The C++ boolean type needs some special casing since it is not part of the
+// C standard and is thus represented as unsigned int in the C wrapper layer.
+%typemap(ctype) bool, const bool & "unsigned int"
+%typemap(imtype) bool, const bool & "uint"
+
+%typemap(in) bool "$1 = $input ? true : false;"
+%typemap(in) const bool & ($*1_ltype temp)
+%{ temp = $input ? true : false;
+ $1 = &temp; %}
+
+%typemap(directorout) bool
+ "$result = $input ? true : false;"
+%typemap(directorout,warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const bool &
+%{ static $*1_ltype temp;
+ temp = $input ? true : false;
+ $result = &temp; %}
+
+%typemap(ddirectorin) bool "($winput ? true : false)"
+
+%typemap(dout, excode=SWIGEXCODE) bool, const bool & {
+ bool ret = $imcall ? true : false;$excode
+ return ret;
+}
+
+
+// Judging from the history of the C# module, the explicit casts are needed for
+// certain versions of VC++.
+%typemap(out) unsigned long "$result = (unsigned long)$1;"
+%typemap(out) const unsigned long & "$result = (unsigned long)*$1;"
+
+
+/*
+ * Typecheck typemaps.
+ */
+
+%typecheck(SWIG_TYPECHECK_BOOL)
+ bool,
+ const bool &
+ ""
+
+%typecheck(SWIG_TYPECHECK_CHAR)
+ char,
+ const char &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT8)
+ signed char,
+ const signed char &
+ ""
+
+%typecheck(SWIG_TYPECHECK_UINT8)
+ unsigned char,
+ const unsigned char &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT16)
+ short,
+ const short &
+ ""
+
+%typecheck(SWIG_TYPECHECK_UINT16)
+ unsigned short,
+ const unsigned short &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT32)
+ int,
+ long,
+ const int &,
+ const long &
+ ""
+
+%typecheck(SWIG_TYPECHECK_UINT32)
+ unsigned int,
+ unsigned long,
+ const unsigned int &,
+ const unsigned long &
+ ""
+
+%typecheck(SWIG_TYPECHECK_INT64)
+ long long,
+ const long long &
+ ""
+
+%typecheck(SWIG_TYPECHECK_UINT64)
+ unsigned long long,
+ const unsigned long long &
+ ""
+
+%typecheck(SWIG_TYPECHECK_FLOAT)
+ float,
+ const float &
+ ""
+
+%typecheck(SWIG_TYPECHECK_DOUBLE)
+ double,
+ const double &
+ ""
diff --git a/Lib/d/dstrings.swg b/Lib/d/dstrings.swg
new file mode 100644
index 000000000..02895c153
--- /dev/null
+++ b/Lib/d/dstrings.swg
@@ -0,0 +1,80 @@
+/* -----------------------------------------------------------------------------
+ * dstrings.swg
+ *
+ * Typemaps for wrapping pointers to/arrays of C chars as D strings.
+ * ----------------------------------------------------------------------------- */
+
+%define SWIGD_STRING_TYPEMAPS(DW_STRING_TYPE, DP_STRING_TYPE, FROM_STRINGZ, TO_STRINGZ)
+%typemap(ctype) char *, char *&, char[ANY], char[] "char *"
+%typemap(imtype) char *, char *&, char[ANY], char[] #DW_STRING_TYPE
+%typemap(dtype) char *, char *&, char[ANY], char[] #DP_STRING_TYPE
+
+
+/*
+ * char* typemaps.
+ */
+
+%typemap(in) char * %{ $1 = ($1_ltype)$input; %}
+%typemap(out) char * %{ $result = SWIG_d_string_callback((const char *)$1); %}
+%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) char * %{ $result = ($1_ltype)$input; %}
+%typemap(directorin) char * %{ $input = SWIG_d_string_callback((const char *)$1); %}
+%typemap(ddirectorin) char * "FROM_STRINGZ($winput)"
+%typemap(ddirectorout) char * "TO_STRINGZ($dcall)"
+
+
+/*
+ * char*& typemaps.
+ */
+
+%typemap(in) char *& ($*1_ltype temp = 0) %{
+ temp = ($*1_ltype)$input;
+ $1 = &temp;
+%}
+%typemap(out) char *& %{ if ($1) $result = SWIG_d_string_callback((const char *)*$1); %}
+
+
+/*
+ * char array typemaps.
+ */
+
+%typemap(in) char[ANY], char[] %{ $1 = ($1_ltype)$input; %}
+%typemap(out) char[ANY], char[] %{ $result = SWIG_d_string_callback((const char *)$1); %}
+
+%typemap(directorout) char[ANY], char[] %{ $result = ($1_ltype)$input; %}
+%typemap(directorin) char[ANY], char[] %{ $input = SWIG_d_string_callback((const char *)$1); %}
+
+%typemap(ddirectorin) char[ANY], char[] "$winput"
+%typemap(ddirectorout) char[ANY], char[] "$dcall"
+
+
+%typemap(din) char *, char *&, char[ANY], char[] "($dinput ? TO_STRINGZ($dinput) : null)"
+%typemap(dout, excode=SWIGEXCODE) char *, char *&, char[ANY], char[] {
+ DP_STRING_TYPE ret = FROM_STRINGZ ## ($imcall);$excode
+ return ret;
+}
+
+%typecheck(SWIG_TYPECHECK_STRING)
+ char *,
+ char *&,
+ char[ANY],
+ char[]
+ ""
+%enddef
+
+
+// We need to have the \0-terminated string conversion functions available in
+// the D proxy modules.
+#if (SWIG_D_VERSION == 1)
+// Could be easily extended to support Phobos as well.
+SWIGD_STRING_TYPEMAPS(char*, char[], tango.stdc.stringz.fromStringz, tango.stdc.stringz.toStringz)
+
+%pragma(d) globalproxyimports = "static import tango.stdc.stringz;";
+#else
+SWIGD_STRING_TYPEMAPS(const(char)*, string, std.conv.to!string, std.string.toStringz)
+
+%pragma(d) globalproxyimports = %{
+static import std.conv;
+static import std.string;
+%}
+#endif
+#undef SWIGD_STRING_TYPEMAPS
diff --git a/Lib/d/dswigtype.swg b/Lib/d/dswigtype.swg
new file mode 100644
index 000000000..41336dc91
--- /dev/null
+++ b/Lib/d/dswigtype.swg
@@ -0,0 +1,184 @@
+/* -----------------------------------------------------------------------------
+ * dswigtype.swg
+ *
+ * Typemaps for non-primitive types (C/C++ classes and structs).
+ * ----------------------------------------------------------------------------- */
+
+%typemap(ctype) SWIGTYPE "void *"
+%typemap(imtype) SWIGTYPE "void*"
+%typemap(dtype) SWIGTYPE "$&dclassname"
+
+%typemap(ctype) SWIGTYPE [] "void *"
+%typemap(imtype) SWIGTYPE [] "void*"
+%typemap(dtype) SWIGTYPE [] "$dclassname"
+
+%typemap(ctype) SWIGTYPE * "void *"
+%typemap(imtype) SWIGTYPE * "void*"
+%typemap(dtype, nativepointer="$dtype") SWIGTYPE * "$dclassname"
+
+%typemap(ctype) SWIGTYPE & "void *"
+%typemap(imtype) SWIGTYPE & "void*"
+%typemap(dtype, nativepointer="$dtype") SWIGTYPE & "$dclassname"
+
+%typemap(ctype) SWIGTYPE *const& "void *"
+%typemap(imtype) SWIGTYPE *const& "void*"
+%typemap(dtype) SWIGTYPE *const& "$*dclassname"
+
+%typecheck(SWIG_TYPECHECK_POINTER)
+ SWIGTYPE,
+ SWIGTYPE *,
+ SWIGTYPE &,
+ SWIGTYPE [],
+ SWIGTYPE *const&
+ ""
+
+
+/*
+ * By-value conversion typemaps (parameter is converted to a pointer).
+ */
+
+%typemap(in, canthrow=1) SWIGTYPE ($&1_type argp)
+%{ argp = ($&1_ltype)$input;
+ if (!argp) {
+ SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Attempt to dereference null $1_type");
+ return $null;
+ }
+ $1 = *argp; %}
+
+%typemap(out) SWIGTYPE
+#ifdef __cplusplus
+%{ $result = new $1_ltype((const $1_ltype &)$1); %}
+#else
+{
+ $&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype));
+ memmove($1ptr, &$1, sizeof($1_type));
+ $result = $1ptr;
+}
+#endif
+
+%typemap(directorin) SWIGTYPE
+ "$input = (void *)&$1;"
+%typemap(directorout) SWIGTYPE
+%{ if (!$input) {
+ SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Unexpected null return for type $1_type");
+ return $null;
+ }
+ $result = *($&1_ltype)$input; %}
+
+%typemap(ddirectorin) SWIGTYPE "new $&dclassname($winput, false)"
+%typemap(ddirectorout) SWIGTYPE "$&dclassname.swigGetCPtr($dcall)"
+
+%typemap(din) SWIGTYPE "$&dclassname.swigGetCPtr($dinput)"
+%typemap(dout, excode=SWIGEXCODE) SWIGTYPE {
+ $&dclassname ret = new $&dclassname($imcall, true);$excode
+ return ret;
+}
+
+
+/*
+ * Pointer conversion typemaps.
+ */
+
+%typemap(in) SWIGTYPE * "$1 = ($1_ltype)$input;"
+%typemap(out) SWIGTYPE * "$result = (void *)$1;"
+
+%typemap(directorin) SWIGTYPE *
+ "$input = (void *) $1;"
+%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *
+ "$result = ($1_ltype)$input;"
+
+%typemap(ddirectorin,
+ nativepointer="cast($dtype)$winput"
+) SWIGTYPE * "($winput is null) ? null : new $dclassname($winput, false)"
+
+%typemap(ddirectorout,
+ nativepointer="cast(void*)$dcall"
+) SWIGTYPE * "$dclassname.swigGetCPtr($dcall)"
+
+%typemap(din,
+ nativepointer="cast(void*)$dinput"
+) SWIGTYPE * "$dclassname.swigGetCPtr($dinput)"
+
+%typemap(dout, excode=SWIGEXCODE,
+ nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}"
+) SWIGTYPE * {
+ void* cPtr = $imcall;
+ $dclassname ret = (cPtr is null) ? null : new $dclassname(cPtr, $owner);$excode
+ return ret;
+}
+
+// Use the same typemaps for const pointers.
+%apply SWIGTYPE * { SWIGTYPE *const }
+
+
+/*
+ * Reference conversion typemaps.
+ */
+
+%typemap(in, canthrow=1) SWIGTYPE & %{ $1 = ($1_ltype)$input;
+ if (!$1) {
+ SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type type is null");
+ return $null;
+ } %}
+%typemap(out) SWIGTYPE & "$result = (void *)$1;"
+
+%typemap(directorin) SWIGTYPE &
+ "$input = ($1_ltype) &$1;"
+%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE &
+%{ if (!$input) {
+ SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Unexpected null return for type $1_type");
+ return $null;
+ }
+ $result = ($1_ltype)$input; %}
+
+%typemap(ddirectorin,
+ nativepointer="cast($dtype)$winput"
+) SWIGTYPE & "new $dclassname($winput, false)"
+%typemap(ddirectorout,
+ nativepointer="cast(void*)$dcall"
+) SWIGTYPE & "$dclassname.swigGetCPtr($dcall)"
+
+%typemap(din,
+ nativepointer="cast(void*)$dinput"
+) SWIGTYPE & "$dclassname.swigGetCPtr($dinput)"
+%typemap(dout, excode=SWIGEXCODE,
+ nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}") SWIGTYPE & {
+ $dclassname ret = new $dclassname($imcall, $owner);$excode
+ return ret;
+}
+
+
+/*
+ * Array conversion typemaps.
+ */
+
+%typemap(in) SWIGTYPE [] %{ $1 = ($1_ltype)$input; %}
+%typemap(out) SWIGTYPE [] %{ $result = $1; %}
+
+%typemap(din) SWIGTYPE [] "$dclassname.swigGetCPtr($dinput)"
+%typemap(dout, excode=SWIGEXCODE) SWIGTYPE [] {
+ void* cPtr = $imcall;
+ $dclassname ret = (cPtr is null) ? null : new $dclassname(cPtr, $owner);$excode
+ return ret;
+}
+
+// Treat references to arrays like like references to a single element.
+%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
+
+
+/*
+ * Pointer reference conversion typemaps.
+ */
+
+%typemap(in) SWIGTYPE *const& ($*1_ltype temp = 0)
+%{ temp = ($*1_ltype)$input;
+ $1 = ($1_ltype)&temp; %}
+%typemap(out) SWIGTYPE *const&
+%{ $result = (void *)*$1; %}
+
+%typemap(din) SWIGTYPE *const& "$*dclassname.swigGetCPtr($dinput)"
+%typemap(dout, excode=SWIGEXCODE) SWIGTYPE *const& {
+ void* cPtr = $imcall;
+ $*dclassname ret = (cPtr is null) ? null : new $*dclassname(cPtr, $owner);$excode
+ return ret;
+}
diff --git a/Lib/d/dvoid.swg b/Lib/d/dvoid.swg
new file mode 100644
index 000000000..805f1e71e
--- /dev/null
+++ b/Lib/d/dvoid.swg
@@ -0,0 +1,18 @@
+/* -----------------------------------------------------------------------------
+ * dvoid.swg
+ *
+ * Typemaps for handling void function return types and empty parameter lists.
+ * ----------------------------------------------------------------------------- */
+
+%typemap(ctype) void "void"
+%typemap(imtype) void "void"
+%typemap(dtype, cprimitive="1") void "void"
+
+%typemap(out, null="") void ""
+%typemap(ddirectorin) void "$winput"
+%typemap(ddirectorout) void "$dcall"
+%typemap(directorin) void ""
+
+%typemap(dout, excode=SWIGEXCODE) void {
+ $imcall;$excode
+}
diff --git a/Lib/d/std_common.i b/Lib/d/std_common.i
new file mode 100644
index 000000000..cee11e8ca
--- /dev/null
+++ b/Lib/d/std_common.i
@@ -0,0 +1,5 @@
+%include <std_except.i>
+
+%apply size_t { std::size_t };
+%apply const size_t& { const std::size_t& };
+
diff --git a/Lib/d/std_deque.i b/Lib/d/std_deque.i
new file mode 100644
index 000000000..cb98f6c2f
--- /dev/null
+++ b/Lib/d/std_deque.i
@@ -0,0 +1 @@
+%include <std/_std_deque.i>
diff --git a/Lib/d/std_except.i b/Lib/d/std_except.i
new file mode 100644
index 000000000..2b557e5fc
--- /dev/null
+++ b/Lib/d/std_except.i
@@ -0,0 +1,30 @@
+/* -----------------------------------------------------------------------------
+ * std_except.i
+ *
+ * Typemaps used by the STL wrappers that throw exceptions. These typemaps are
+ * used when methods are declared with an STL exception specification, such as
+ * size_t at() const throw (std::out_of_range);
+ * ----------------------------------------------------------------------------- */
+
+%{
+#include <stdexcept>
+%}
+
+namespace std
+{
+ %ignore exception;
+ struct exception {};
+}
+
+%typemap(throws, canthrow=1) std::bad_exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
+%typemap(throws, canthrow=1) std::domain_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
+%typemap(throws, canthrow=1) std::exception "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
+%typemap(throws, canthrow=1) std::invalid_argument "SWIG_DSetPendingException(SWIG_DIllegalArgumentException, $1.what());\n return $null;"
+%typemap(throws, canthrow=1) std::length_error "SWIG_DSetPendingException(SWIG_DNoSuchElementException, $1.what());\n return $null;"
+%typemap(throws, canthrow=1) std::logic_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
+%typemap(throws, canthrow=1) std::out_of_range "SWIG_DSetPendingException(SWIG_DNoSuchElementException, $1.what());\n return $null;"
+%typemap(throws, canthrow=1) std::overflow_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
+%typemap(throws, canthrow=1) std::range_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
+%typemap(throws, canthrow=1) std::runtime_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
+%typemap(throws, canthrow=1) std::underflow_error "SWIG_DSetPendingException(SWIG_DException, $1.what());\n return $null;"
+
diff --git a/Lib/d/std_map.i b/Lib/d/std_map.i
new file mode 100644
index 000000000..0e8574b8a
--- /dev/null
+++ b/Lib/d/std_map.i
@@ -0,0 +1,59 @@
+/* -----------------------------------------------------------------------------
+ * std_map.i
+ *
+ * SWIG typemaps for std::map
+ * ----------------------------------------------------------------------------- */
+
+%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:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef K key_type;
+ typedef T mapped_type;
+ 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();
+ }
+ }
+ };
+}
diff --git a/Lib/d/std_pair.i b/Lib/d/std_pair.i
new file mode 100644
index 000000000..0712ad762
--- /dev/null
+++ b/Lib/d/std_pair.i
@@ -0,0 +1,34 @@
+/* -----------------------------------------------------------------------------
+ * std_pair.i
+ *
+ * SWIG 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 t, U u);
+ 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/d/std_shared_ptr.i b/Lib/d/std_shared_ptr.i
new file mode 100644
index 000000000..df873679c
--- /dev/null
+++ b/Lib/d/std_shared_ptr.i
@@ -0,0 +1,2 @@
+#define SWIG_SHARED_PTR_NAMESPACE std
+%include <boost_shared_ptr.i>
diff --git a/Lib/d/std_string.i b/Lib/d/std_string.i
new file mode 100644
index 000000000..7a4accf18
--- /dev/null
+++ b/Lib/d/std_string.i
@@ -0,0 +1,98 @@
+/* -----------------------------------------------------------------------------
+ * std_string.i
+ *
+ * Typemaps for std::string and const std::string&
+ * These are mapped to a D char[] and are passed around by value.
+ *
+ * To use non-const std::string references, use the following %apply. Note
+ * that they are passed by value.
+ * %apply const std::string & {std::string &};
+ * ----------------------------------------------------------------------------- */
+
+%{
+#include <string>
+%}
+
+namespace std {
+
+%naturalvar string;
+
+class string;
+
+%define SWIGD_STD_STRING_TYPEMAPS(DW_STRING_TYPE, DP_STRING_TYPE, FROM_STRINGZ, TO_STRINGZ)
+// string
+%typemap(ctype) string, const string & "char *"
+%typemap(imtype) string, const string & #DW_STRING_TYPE
+%typemap(dtype) string, const string & #DP_STRING_TYPE
+
+%typemap(in, canthrow=1) string, const string &
+%{ if (!$input) {
+ SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string");
+ return $null;
+ }
+ $1.assign($input); %}
+%typemap(in, canthrow=1) const string &
+%{ if (!$input) {
+ SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string");
+ return $null;
+ }
+ std::string $1_str($input);
+ $1 = &$1_str; %}
+
+%typemap(out) string %{ $result = SWIG_d_string_callback($1.c_str()); %}
+%typemap(out) const string & %{ $result = SWIG_d_string_callback($1->c_str()); %}
+
+%typemap(din) string, const string & "($dinput ? TO_STRINGZ($dinput) : null)"
+%typemap(dout, excode=SWIGEXCODE) string, const string & {
+ DP_STRING_TYPE ret = FROM_STRINGZ($imcall);$excode
+ return ret;
+}
+
+%typemap(directorin) string, const string & %{ $input = SWIG_d_string_callback($1.c_str()); %}
+
+%typemap(directorout, canthrow=1) string
+%{ if (!$input) {
+ SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string");
+ return $null;
+ }
+ $result.assign($input); %}
+
+%typemap(directorout, canthrow=1, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) const string &
+%{ if (!$input) {
+ SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "null string");
+ return $null;
+ }
+ /* possible thread/reentrant code problem */
+ static std::string $1_str;
+ $1_str = $input;
+ $result = &$1_str; %}
+
+%typemap(ddirectorin) string, const string & "FROM_STRINGZ($winput)"
+%typemap(ddirectorout) string, const string & "TO_STRINGZ($dcall)"
+
+%typemap(throws, canthrow=1) string, const string &
+%{ SWIG_DSetPendingException(SWIG_DException, $1.c_str());
+ return $null; %}
+
+%typemap(typecheck) string, const string & = char *;
+%enddef
+
+// We need to have the \0-terminated string conversion functions available in
+// the D proxy modules.
+#if (SWIG_D_VERSION == 1)
+// Could be easily extended to support Phobos as well.
+SWIGD_STD_STRING_TYPEMAPS(char*, char[], tango.stdc.stringz.fromStringz, tango.stdc.stringz.toStringz)
+
+%pragma(d) globalproxyimports = "static import tango.stdc.stringz;";
+#else
+SWIGD_STD_STRING_TYPEMAPS(const(char)*, string, std.conv.to!string, std.string.toStringz)
+
+%pragma(d) globalproxyimports = %{
+static import std.conv;
+static import std.string;
+%}
+#endif
+
+#undef SWIGD_STD_STRING_TYPEMAPS
+
+} // namespace std
diff --git a/Lib/d/std_vector.i b/Lib/d/std_vector.i
new file mode 100644
index 000000000..b7d4e223f
--- /dev/null
+++ b/Lib/d/std_vector.i
@@ -0,0 +1,591 @@
+/* -----------------------------------------------------------------------------
+ * std_vector.i
+ *
+ * SWIG typemaps for std::vector<T>, D implementation.
+ *
+ * The D wrapper is made to loosely resemble a tango.util.container.more.Vector
+ * and to provide built-in array-like access.
+ *
+ * If T does define an operator==, then use the SWIG_STD_VECTOR_ENHANCED
+ * macro to obtain enhanced functionality (none yet), for example:
+ *
+ * SWIG_STD_VECTOR_ENHANCED(SomeNamespace::Klass)
+ * %template(VectKlass) std::vector<SomeNamespace::Klass>;
+ *
+ * Warning: heavy macro usage in this file. Use swig -E to get a sane view on
+ * the real file contents!
+ * ----------------------------------------------------------------------------- */
+
+// Warning: Use the typemaps here in the expectation that the macros they are in will change name.
+
+%include <std_common.i>
+
+// MACRO for use within the std::vector class body
+%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CONST_REFERENCE, CTYPE...)
+#if (SWIG_D_VERSION == 1)
+%typemap(dimports) std::vector< CTYPE > "static import tango.core.Exception;"
+%typemap(dcode) std::vector< CTYPE > %{
+public this($typemap(dtype, CTYPE)[] values) {
+ this();
+ append(values);
+}
+
+alias push_back add;
+alias push_back push;
+alias push_back opCatAssign;
+alias size length;
+alias opSlice slice;
+
+public $typemap(dtype, CTYPE) opIndexAssign($typemap(dtype, CTYPE) value, size_t index) {
+ if (index >= size()) {
+ throw new tango.core.Exception.NoSuchElementException("Tried to assign to element out of vector bounds.");
+ }
+ setElement(index, value);
+ return value;
+}
+
+public $typemap(dtype, CTYPE) opIndex(size_t index) {
+ if (index >= size()) {
+ throw new tango.core.Exception.NoSuchElementException("Tried to read from element out of vector bounds.");
+ }
+ return getElement(index);
+}
+
+public void append($typemap(dtype, CTYPE)[] value...) {
+ foreach (v; value) {
+ add(v);
+ }
+}
+
+public $typemap(dtype, CTYPE)[] opSlice() {
+ $typemap(dtype, CTYPE)[] array = new $typemap(dtype, CTYPE)[size()];
+ foreach (i, ref value; array) {
+ value = getElement(i);
+ }
+ return array;
+}
+
+public int opApply(int delegate(ref $typemap(dtype, CTYPE) value) dg) {
+ int result;
+
+ size_t currentSize = size();
+ for (size_t i = 0; i < currentSize; ++i) {
+ auto value = getElement(i);
+ result = dg(value);
+ setElement(i, value);
+ }
+ return result;
+}
+
+public int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) {
+ int result;
+
+ size_t currentSize = size();
+ for (size_t i = 0; i < currentSize; ++i) {
+ auto value = getElement(i);
+
+ // Workaround for http://d.puremagic.com/issues/show_bug.cgi?id=2443.
+ auto index = i;
+
+ result = dg(index, value);
+ setElement(i, value);
+ }
+ return result;
+}
+
+public void capacity(size_t value) {
+ if (value < size()) {
+ throw new tango.core.Exception.IllegalArgumentException("Tried to make the capacity of a vector smaller than its size.");
+ }
+
+ reserve(value);
+}
+%}
+
+ public:
+ typedef size_t size_type;
+ typedef CTYPE value_type;
+ typedef CONST_REFERENCE const_reference;
+ void clear();
+ void push_back(CTYPE const& x);
+ size_type size() const;
+ size_type capacity() const;
+ void reserve(size_type n) throw (std::length_error);
+ vector();
+ vector(const vector &other);
+ %extend {
+ vector(size_type capacity) throw (std::length_error) {
+ std::vector< CTYPE >* pv = 0;
+ pv = new std::vector< CTYPE >();
+
+ // Might throw std::length_error.
+ pv->reserve(capacity);
+
+ return pv;
+ }
+
+ size_type unused() const {
+ return $self->capacity() - $self->size();
+ }
+
+ const_reference remove() throw (std::out_of_range) {
+ if ($self->empty()) {
+ throw std::out_of_range("Tried to remove last element from empty vector.");
+ }
+
+ std::vector< CTYPE >::const_reference value = $self->back();
+ $self->pop_back();
+ return value;
+ }
+
+ const_reference remove(size_type index) throw (std::out_of_range) {
+ if (index >= $self->size()) {
+ throw std::out_of_range("Tried to remove element with invalid index.");
+ }
+
+ std::vector< CTYPE >::iterator it = $self->begin() + index;
+ std::vector< CTYPE >::const_reference value = *it;
+ $self->erase(it);
+ return value;
+ }
+ }
+
+ // Wrappers for setting/getting items with the possibly thrown exception
+ // specified (important for SWIG wrapper generation).
+ %extend {
+ const_reference getElement(size_type index) throw (std::out_of_range) {
+ if ((index < 0) || ($self->size() <= index)) {
+ throw std::out_of_range("Tried to get value of element with invalid index.");
+ }
+ return (*$self)[index];
+ }
+ }
+
+ // Use CTYPE const& instead of const_reference to work around SWIG code
+ // generation issue when using const pointers as vector elements (like
+ // std::vector< const int* >).
+ %extend {
+ void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) {
+ if ((index < 0) || ($self->size() <= index)) {
+ throw std::out_of_range("Tried to set value of element with invalid index.");
+ }
+ (*$self)[index] = val;
+ }
+ }
+
+%dmethodmodifiers std::vector::getElement "private"
+%dmethodmodifiers std::vector::setElement "private"
+%dmethodmodifiers std::vector::reserve "private"
+
+#else
+
+%typemap(dimports) std::vector< CTYPE > %{
+static import std.algorithm;
+static import std.exception;
+static import std.range;
+static import std.traits;
+%}
+%typemap(dcode) std::vector< CTYPE > %{
+alias size_t KeyType;
+alias $typemap(dtype, CTYPE) ValueType;
+
+this(ValueType[] values...) {
+ this();
+ reserve(values.length);
+ foreach (e; values) {
+ this ~= e;
+ }
+}
+
+struct Range {
+ private $typemap(dtype, std::vector< CTYPE >) _outer;
+ private size_t _a, _b;
+
+ this($typemap(dtype, std::vector< CTYPE >) data, size_t a, size_t b) {
+ _outer = data;
+ _a = a;
+ _b = b;
+ }
+
+ @property bool empty() const {
+ assert((cast($typemap(dtype, std::vector< CTYPE >))_outer).length >= _b);
+ return _a >= _b;
+ }
+
+ @property Range save() {
+ return this;
+ }
+
+ @property ValueType front() {
+ std.exception.enforce(!empty);
+ return _outer[_a];
+ }
+
+ @property void front(ValueType value) {
+ std.exception.enforce(!empty);
+ _outer[_a] = std.algorithm.move(value);
+ }
+
+ void popFront() {
+ std.exception.enforce(!empty);
+ ++_a;
+ }
+
+ void opIndexAssign(ValueType value, size_t i) {
+ i += _a;
+ std.exception.enforce(i < _b && _b <= _outer.length);
+ _outer[i] = value;
+ }
+
+ void opIndexOpAssign(string op)(ValueType value, size_t i) {
+ std.exception.enforce(_outer && _a + i < _b && _b <= _outer.length);
+ auto element = _outer[i];
+ mixin("element "~op~"= value;");
+ _outer[i] = element;
+ }
+}
+
+// TODO: dup?
+
+Range opSlice() {
+ return Range(this, 0, length);
+}
+
+Range opSlice(size_t a, size_t b) {
+ std.exception.enforce(a <= b && b <= length);
+ return Range(this, a, b);
+}
+
+size_t opDollar() const {
+ return length;
+}
+
+@property ValueType front() {
+ std.exception.enforce(!empty);
+ return getElement(0);
+}
+
+@property void front(ValueType value) {
+ std.exception.enforce(!empty);
+ setElement(0, value);
+}
+
+@property ValueType back() {
+ std.exception.enforce(!empty);
+ return getElement(length - 1);
+}
+
+@property void back(ValueType value) {
+ std.exception.enforce(!empty);
+ setElement(length - 1, value);
+}
+
+ValueType opIndex(size_t i) {
+ return getElement(i);
+}
+
+void opIndexAssign(ValueType value, size_t i) {
+ setElement(i, value);
+}
+
+void opIndexOpAssign(string op)(ValueType value, size_t i) {
+ auto element = this[i];
+ mixin("element "~op~"= value;");
+ this[i] = element;
+}
+
+ValueType[] opBinary(string op, Stuff)(Stuff stuff) if (op == "~") {
+ ValueType[] result;
+ result ~= this[];
+ assert(result.length == length);
+ result ~= stuff[];
+ return result;
+}
+
+void opOpAssign(string op, Stuff)(Stuff stuff) if (op == "~") {
+ static if (is(typeof(insertBack(stuff)))) {
+ insertBack(stuff);
+ } else if (is(typeof(insertBack(stuff[])))) {
+ insertBack(stuff[]);
+ } else {
+ static assert(false, "Cannot append " ~ Stuff.stringof ~ " to " ~ typeof(this).stringof);
+ }
+}
+
+alias size length;
+
+alias remove removeAny;
+alias removeAny stableRemoveAny;
+
+size_t insertBack(Stuff)(Stuff stuff)
+if (std.traits.isImplicitlyConvertible!(Stuff, ValueType)){
+ push_back(stuff);
+ return 1;
+}
+size_t insertBack(Stuff)(Stuff stuff)
+if (std.range.isInputRange!Stuff &&
+ std.traits.isImplicitlyConvertible!(std.range.ElementType!Stuff, ValueType)) {
+ size_t itemCount;
+ foreach(item; stuff) {
+ insertBack(item);
+ ++itemCount;
+ }
+ return itemCount;
+}
+alias insertBack insert;
+
+alias pop_back removeBack;
+alias pop_back stableRemoveBack;
+
+size_t insertBefore(Stuff)(Range r, Stuff stuff)
+if (std.traits.isImplicitlyConvertible!(Stuff, ValueType)) {
+ std.exception.enforce(r._outer.swigCPtr == swigCPtr && r._a < length);
+ insertAt(r._a, stuff);
+ return 1;
+}
+
+size_t insertBefore(Stuff)(Range r, Stuff stuff)
+if (std.range.isInputRange!Stuff && std.traits.isImplicitlyConvertible!(ElementType!Stuff, ValueType)) {
+ std.exception.enforce(r._outer.swigCPtr == swigCPtr && r._a <= length);
+
+ size_t insertCount;
+ foreach(i, item; stuff) {
+ insertAt(r._a + i, item);
+ ++insertCount;
+ }
+
+ return insertCount;
+}
+
+size_t insertAfter(Stuff)(Range r, Stuff stuff) {
+ // TODO: optimize
+ immutable offset = r._a + r.length;
+ std.exception.enforce(offset <= length);
+ auto result = insertBack(stuff);
+ std.algorithm.bringToFront(this[offset .. length - result],
+ this[length - result .. length]);
+ return result;
+}
+
+size_t replace(Stuff)(Range r, Stuff stuff)
+if (std.range.isInputRange!Stuff &&
+ std.traits.isImplicitlyConvertible!(ElementType!Stuff, ValueType)) {
+ immutable offset = r._a;
+ std.exception.enforce(offset <= length);
+ size_t result;
+ for (; !stuff.empty; stuff.popFront()) {
+ if (r.empty) {
+ // append the rest
+ return result + insertBack(stuff);
+ }
+ r.front = stuff.front;
+ r.popFront();
+ ++result;
+ }
+ // Remove remaining stuff in r
+ remove(r);
+ return result;
+}
+
+size_t replace(Stuff)(Range r, Stuff stuff)
+if (std.traits.isImplicitlyConvertible!(Stuff, ValueType))
+{
+ if (r.empty)
+ {
+ insertBefore(r, stuff);
+ }
+ else
+ {
+ r.front = stuff;
+ r.popFront();
+ remove(r);
+ }
+ return 1;
+}
+
+Range linearRemove(Range r) {
+ std.exception.enforce(r._a <= r._b && r._b <= length);
+ immutable tailLength = length - r._b;
+ linearRemove(r._a, r._b);
+ return this[length - tailLength .. length];
+}
+alias remove stableLinearRemove;
+
+int opApply(int delegate(ref $typemap(dtype, CTYPE) value) dg) {
+ int result;
+
+ size_t currentSize = size();
+ for (size_t i = 0; i < currentSize; ++i) {
+ auto value = getElement(i);
+ result = dg(value);
+ setElement(i, value);
+ }
+ return result;
+}
+
+int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) {
+ int result;
+
+ size_t currentSize = size();
+ for (size_t i = 0; i < currentSize; ++i) {
+ auto value = getElement(i);
+
+ // Workaround for http://d.puremagic.com/issues/show_bug.cgi?id=2443.
+ auto index = i;
+
+ result = dg(index, value);
+ setElement(i, value);
+ }
+ return result;
+}
+%}
+
+ public:
+ typedef size_t size_type;
+ typedef CTYPE value_type;
+ typedef CONST_REFERENCE const_reference;
+ bool empty() const;
+ void clear();
+ void push_back(CTYPE const& x);
+ void pop_back();
+ size_type size() const;
+ size_type capacity() const;
+ void reserve(size_type n) throw (std::length_error);
+ vector();
+ vector(const vector &other);
+ %extend {
+ vector(size_type capacity) throw (std::length_error) {
+ std::vector< CTYPE >* pv = 0;
+ pv = new std::vector< CTYPE >();
+
+ // Might throw std::length_error.
+ pv->reserve(capacity);
+
+ return pv;
+ }
+
+ const_reference remove() throw (std::out_of_range) {
+ if ($self->empty()) {
+ throw std::out_of_range("Tried to remove last element from empty vector.");
+ }
+
+ std::vector< CTYPE >::const_reference value = $self->back();
+ $self->pop_back();
+ return value;
+ }
+
+ const_reference remove(size_type index) throw (std::out_of_range) {
+ if (index >= $self->size()) {
+ throw std::out_of_range("Tried to remove element with invalid index.");
+ }
+
+ std::vector< CTYPE >::iterator it = $self->begin() + index;
+ std::vector< CTYPE >::const_reference value = *it;
+ $self->erase(it);
+ return value;
+ }
+
+ void removeBack(size_type how_many) throw (std::out_of_range) {
+ std::vector< CTYPE >::iterator end = $self->end();
+ std::vector< CTYPE >::iterator start = end - how_many;
+ $self->erase(start, end);
+ }
+
+ void linearRemove(size_type start_index, size_type end_index) throw (std::out_of_range) {
+ std::vector< CTYPE >::iterator start = $self->begin() + start_index;
+ std::vector< CTYPE >::iterator end = $self->begin() + end_index;
+ $self->erase(start, end);
+ }
+
+ void insertAt(size_type index, CTYPE const& x) throw (std::out_of_range) {
+ std::vector< CTYPE >::iterator it = $self->begin() + index;
+ $self->insert(it, x);
+ }
+ }
+
+ // Wrappers for setting/getting items with the possibly thrown exception
+ // specified (important for SWIG wrapper generation).
+ %extend {
+ const_reference getElement(size_type index) throw (std::out_of_range) {
+ if ((index < 0) || ($self->size() <= index)) {
+ throw std::out_of_range("Tried to get value of element with invalid index.");
+ }
+ return (*$self)[index];
+ }
+ }
+ // Use CTYPE const& instead of const_reference to work around SWIG code
+ // generation issue when using const pointers as vector elements (like
+ // std::vector< const int* >).
+ %extend {
+ void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) {
+ if ((index < 0) || ($self->size() <= index)) {
+ throw std::out_of_range("Tried to set value of element with invalid index.");
+ }
+ (*$self)[index] = val;
+ }
+ }
+
+%dmethodmodifiers std::vector::getElement "private"
+%dmethodmodifiers std::vector::setElement "private"
+#endif
+%enddef
+
+// Extra methods added to the collection class if operator== is defined for the class being wrapped
+// The class will then implement IList<>, which adds extra functionality
+%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...)
+ %extend {
+ }
+%enddef
+
+// For vararg handling in macros, from swigmacros.swg
+#define %arg(X...) X
+
+// Macros for std::vector class specializations/enhancements
+%define SWIG_STD_VECTOR_ENHANCED(CTYPE...)
+namespace std {
+ template<> class vector<CTYPE > {
+ SWIG_STD_VECTOR_MINIMUM_INTERNAL(%arg(CTYPE const&), %arg(CTYPE))
+ SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE)
+ };
+}
+%enddef
+
+%{
+#include <vector>
+#include <stdexcept>
+%}
+
+namespace std {
+ // primary (unspecialized) class template for std::vector
+ // does not require operator== to be defined
+ template<class T> class vector {
+ SWIG_STD_VECTOR_MINIMUM_INTERNAL(T const&, T)
+ };
+ // specializations for pointers
+ template<class T> class vector<T *> {
+ SWIG_STD_VECTOR_MINIMUM_INTERNAL(T *const&, T *)
+ SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *)
+ };
+ // bool is a bit different in the C++ standard - const_reference in particular
+ template<> class vector<bool> {
+ SWIG_STD_VECTOR_MINIMUM_INTERNAL(bool, bool)
+ SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(bool)
+ };
+}
+
+// template specializations for std::vector
+// these provide extra collections methods as operator== is defined
+SWIG_STD_VECTOR_ENHANCED(char)
+SWIG_STD_VECTOR_ENHANCED(signed char)
+SWIG_STD_VECTOR_ENHANCED(unsigned char)
+SWIG_STD_VECTOR_ENHANCED(short)
+SWIG_STD_VECTOR_ENHANCED(unsigned short)
+SWIG_STD_VECTOR_ENHANCED(int)
+SWIG_STD_VECTOR_ENHANCED(unsigned int)
+SWIG_STD_VECTOR_ENHANCED(long)
+SWIG_STD_VECTOR_ENHANCED(unsigned long)
+SWIG_STD_VECTOR_ENHANCED(long long)
+SWIG_STD_VECTOR_ENHANCED(unsigned long long)
+SWIG_STD_VECTOR_ENHANCED(float)
+SWIG_STD_VECTOR_ENHANCED(double)
+SWIG_STD_VECTOR_ENHANCED(std::string) // also requires a %include <std_string.i>
diff --git a/Lib/d/stl.i b/Lib/d/stl.i
new file mode 100644
index 000000000..9d2e91eee
--- /dev/null
+++ b/Lib/d/stl.i
@@ -0,0 +1,12 @@
+/* -----------------------------------------------------------------------------
+ * stl.i
+ *
+ * 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/d/typemaps.i b/Lib/d/typemaps.i
new file mode 100644
index 000000000..21cd848af
--- /dev/null
+++ b/Lib/d/typemaps.i
@@ -0,0 +1,298 @@
+/* -----------------------------------------------------------------------------
+ * typemaps.i
+ *
+ * Pointer and reference handling typemap library
+ *
+ * These mappings provide support for input/output arguments and common
+ * uses for C/C++ pointers and C++ references.
+ * ----------------------------------------------------------------------------- */
+
+/*
+INPUT typemaps
+--------------
+
+These typemaps are used for pointer/reference parameters that are input only
+and are mapped to a D input parameter.
+
+The following typemaps can be applied to turn a pointer or reference into a simple
+input value. That is, instead of passing a pointer or reference to an object,
+you would use a real value instead.
+
+ bool *INPUT, bool &INPUT
+ signed char *INPUT, signed char &INPUT
+ unsigned char *INPUT, unsigned char &INPUT
+ short *INPUT, short &INPUT
+ unsigned short *INPUT, unsigned short &INPUT
+ int *INPUT, int &INPUT
+ unsigned int *INPUT, unsigned int &INPUT
+ long *INPUT, long &INPUT
+ unsigned long *INPUT, unsigned long &INPUT
+ long long *INPUT, long long &INPUT
+ unsigned long long *INPUT, unsigned long long &INPUT
+ float *INPUT, float &INPUT
+ double *INPUT, double &INPUT
+
+To use these, suppose you had a C function like this :
+
+ double fadd(double *a, double *b) {
+ return *a+*b;
+ }
+
+You could wrap it with SWIG as follows :
+
+ %include <typemaps.i>
+ double fadd(double *INPUT, double *INPUT);
+
+or you can use the %apply directive :
+
+ %include <typemaps.i>
+ %apply double *INPUT { double *a, double *b };
+ double fadd(double *a, double *b);
+
+In D you could then use it like this:
+ double answer = fadd(10.0, 20.0);
+*/
+
+%define INPUT_TYPEMAP(TYPE, CTYPE, DTYPE)
+%typemap(ctype, out="void *") TYPE *INPUT, TYPE &INPUT "CTYPE"
+%typemap(imtype, out="void*") TYPE *INPUT, TYPE &INPUT "DTYPE"
+%typemap(dtype, out="DTYPE*") TYPE *INPUT, TYPE &INPUT "DTYPE"
+%typemap(din) TYPE *INPUT, TYPE &INPUT "$dinput"
+%typemap(ddirectorin) TYPE *INPUT, TYPE &INPUT "$winput"
+%typemap(ddirectorout) TYPE *INPUT, TYPE &INPUT "$dcall"
+
+%typemap(in) TYPE *INPUT, TYPE &INPUT
+%{ $1 = ($1_ltype)&$input; %}
+
+%typemap(directorout) TYPE *INPUT, TYPE &INPUT
+%{ $result = ($1_ltype)&$input; %}
+
+%typemap(directorin) TYPE &INPUT
+%{ $input = (CTYPE *)$1; %}
+
+%typemap(directorin) TYPE *INPUT
+%{ $input = (CTYPE *)$1; %}
+
+%typemap(typecheck) TYPE *INPUT = TYPE;
+%typemap(typecheck) TYPE &INPUT = TYPE;
+%enddef
+
+INPUT_TYPEMAP(bool, unsigned int, bool)
+//INPUT_TYPEMAP(char, char, char) // Why was this commented out?
+INPUT_TYPEMAP(signed char, signed char, byte)
+INPUT_TYPEMAP(unsigned char, unsigned char, ubyte)
+INPUT_TYPEMAP(short, short, short)
+INPUT_TYPEMAP(unsigned short, unsigned short, ushort)
+INPUT_TYPEMAP(int, int, int)
+INPUT_TYPEMAP(unsigned int, unsigned int, uint)
+INPUT_TYPEMAP(long, long, int)
+INPUT_TYPEMAP(unsigned long, unsigned long, uint)
+INPUT_TYPEMAP(long long, long long, long)
+INPUT_TYPEMAP(unsigned long long, unsigned long long, ulong)
+INPUT_TYPEMAP(float, float, float)
+INPUT_TYPEMAP(double, double, double)
+
+INPUT_TYPEMAP(enum SWIGTYPE, unsigned int, int)
+%typemap(dtype) enum SWIGTYPE *INPUT, enum SWIGTYPE &INPUT "$*dclassname"
+
+#undef INPUT_TYPEMAP
+
+
+/*
+OUTPUT typemaps
+---------------
+
+These typemaps are used for pointer/reference parameters that are output only and
+are mapped to a D output parameter.
+
+The following typemaps can be applied to turn a pointer or reference into an
+"output" value. When calling a function, no input value would be given for
+a parameter, but an output value would be returned. In D, the 'out' keyword is
+used when passing the parameter to a function that takes an output parameter.
+
+ bool *OUTPUT, bool &OUTPUT
+ signed char *OUTPUT, signed char &OUTPUT
+ unsigned char *OUTPUT, unsigned char &OUTPUT
+ short *OUTPUT, short &OUTPUT
+ unsigned short *OUTPUT, unsigned short &OUTPUT
+ int *OUTPUT, int &OUTPUT
+ unsigned int *OUTPUT, unsigned int &OUTPUT
+ long *OUTPUT, long &OUTPUT
+ unsigned long *OUTPUT, unsigned long &OUTPUT
+ long long *OUTPUT, long long &OUTPUT
+ unsigned long long *OUTPUT, unsigned long long &OUTPUT
+ float *OUTPUT, float &OUTPUT
+ double *OUTPUT, double &OUTPUT
+
+For example, suppose you were trying to wrap the modf() function in the
+C math library which splits x into integral and fractional parts (and
+returns the integer part in one of its parameters):
+
+ double modf(double x, double *ip);
+
+You could wrap it with SWIG as follows :
+
+ %include <typemaps.i>
+ double modf(double x, double *OUTPUT);
+
+or you can use the %apply directive :
+
+ %include <typemaps.i>
+ %apply double *OUTPUT { double *ip };
+ double modf(double x, double *ip);
+
+The D output of the function would be the function return value and the
+value returned in the second output parameter. In D you would use it like this:
+
+ double dptr;
+ double fraction = modf(5, dptr);
+*/
+
+%define OUTPUT_TYPEMAP(TYPE, CTYPE, DTYPE, TYPECHECKPRECEDENCE)
+%typemap(ctype, out="void *") TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *"
+%typemap(imtype, out="void*") TYPE *OUTPUT, TYPE &OUTPUT "out DTYPE"
+%typemap(dtype, out="DTYPE*") TYPE *OUTPUT, TYPE &OUTPUT "out DTYPE"
+%typemap(din) TYPE *OUTPUT, TYPE &OUTPUT "$dinput"
+%typemap(ddirectorin) TYPE *OUTPUT, TYPE &OUTPUT "$winput"
+%typemap(ddirectorout) TYPE *OUTPUT, TYPE &OUTPUT "$dcall"
+
+
+%typemap(in) TYPE *OUTPUT, TYPE &OUTPUT
+%{ $1 = ($1_ltype)$input; %}
+
+%typemap(directorout,warning="Need to provide TYPE *OUTPUT directorout typemap") TYPE *OUTPUT, TYPE &OUTPUT {
+}
+
+%typemap(directorin) TYPE &OUTPUT
+%{ $input = &$1; %}
+
+%typemap(directorin,warning="Need to provide TYPE *OUTPUT directorin typemap, TYPE array length is unknown") TYPE *OUTPUT
+{
+}
+
+
+%typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *OUTPUT, TYPE &OUTPUT ""
+%enddef
+
+OUTPUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR)
+//OUTPUT_TYPEMAP(char, char, char, CHAR_PTR) // Why was this commented out?
+OUTPUT_TYPEMAP(signed char, signed char, byte, INT8_PTR)
+OUTPUT_TYPEMAP(unsigned char, unsigned char, ubyte, UINT8_PTR)
+OUTPUT_TYPEMAP(short, short, short, INT16_PTR)
+OUTPUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR)
+OUTPUT_TYPEMAP(int, int, int, INT32_PTR)
+OUTPUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR)
+OUTPUT_TYPEMAP(long, long, int, INT32_PTR)
+OUTPUT_TYPEMAP(unsigned long, unsigned long, uint, UINT32_PTR)
+OUTPUT_TYPEMAP(long long, long long, long, INT64_PTR)
+OUTPUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR)
+OUTPUT_TYPEMAP(float, float, float, FLOAT_PTR)
+OUTPUT_TYPEMAP(double, double, double, DOUBLE_PTR)
+
+OUTPUT_TYPEMAP(enum SWIGTYPE, unsigned int, int, INT32_PTR)
+%typemap(dtype) enum SWIGTYPE *OUTPUT, enum SWIGTYPE &OUTPUT "out $*dclassname"
+
+#undef OUTPUT_TYPEMAP
+
+%typemap(in) bool *OUTPUT, bool &OUTPUT
+%{ *$input = 0;
+ $1 = ($1_ltype)$input; %}
+
+
+/*
+INOUT typemaps
+--------------
+
+These typemaps are for pointer/reference parameters that are both input and
+output and are mapped to a D reference parameter.
+
+The following typemaps can be applied to turn a pointer or reference into a
+reference parameters, that is the parameter is both an input and an output.
+In D, the 'ref' keyword is used for reference parameters.
+
+ bool *INOUT, bool &INOUT
+ signed char *INOUT, signed char &INOUT
+ unsigned char *INOUT, unsigned char &INOUT
+ short *INOUT, short &INOUT
+ unsigned short *INOUT, unsigned short &INOUT
+ int *INOUT, int &INOUT
+ unsigned int *INOUT, unsigned int &INOUT
+ long *INOUT, long &INOUT
+ unsigned long *INOUT, unsigned long &INOUT
+ long long *INOUT, long long &INOUT
+ unsigned long long *INOUT, unsigned long long &INOUT
+ float *INOUT, float &INOUT
+ double *INOUT, double &INOUT
+
+For example, suppose you were trying to wrap the following function :
+
+ void neg(double *x) {
+ *x = -(*x);
+ }
+
+You could wrap it with SWIG as follows :
+
+ %include <typemaps.i>
+ void neg(double *INOUT);
+
+or you can use the %apply directive :
+
+ %include <typemaps.i>
+ %apply double *INOUT { double *x };
+ void neg(double *x);
+
+The D output of the function would be the new value returned by the
+reference parameter. In D you would use it like this:
+
+
+ double x = 5.0;
+ neg(x);
+
+The implementation of the OUTPUT and INOUT typemaps is different to the scripting
+languages in that the scripting languages will return the output value as part
+of the function return value.
+*/
+
+%define INOUT_TYPEMAP(TYPE, CTYPE, DTYPE, TYPECHECKPRECEDENCE)
+%typemap(ctype, out="void *") TYPE *INOUT, TYPE &INOUT "CTYPE *"
+%typemap(imtype, out="void*") TYPE *INOUT, TYPE &INOUT "ref DTYPE"
+%typemap(dtype, out="DTYPE*") TYPE *INOUT, TYPE &INOUT "ref DTYPE"
+%typemap(din) TYPE *INOUT, TYPE &INOUT "$dinput"
+%typemap(ddirectorin) TYPE *INOUT, TYPE &INOUT "$winput"
+%typemap(ddirectorout) TYPE *INOUT, TYPE &INOUT "$dcall"
+
+%typemap(in) TYPE *INOUT, TYPE &INOUT
+%{ $1 = ($1_ltype)$input; %}
+
+%typemap(directorout,warning="Need to provide TYPE *INOUT directorout typemap") TYPE *INOUT, TYPE &INOUT {
+}
+
+%typemap(directorin) TYPE &INOUT
+%{ $input = &$1; %}
+
+%typemap(directorin,warning="Need to provide TYPE *INOUT directorin typemap, TYPE array length is unknown") TYPE *INOUT, TYPE &INOUT
+{
+}
+
+%typecheck(SWIG_TYPECHECK_##TYPECHECKPRECEDENCE) TYPE *INOUT, TYPE &INOUT ""
+%enddef
+
+INOUT_TYPEMAP(bool, unsigned int, bool, BOOL_PTR)
+//INOUT_TYPEMAP(char, char, char, CHAR_PTR)
+INOUT_TYPEMAP(signed char, signed char, byte, INT8_PTR)
+INOUT_TYPEMAP(unsigned char, unsigned char, ubyte, UINT8_PTR)
+INOUT_TYPEMAP(short, short, short, INT16_PTR)
+INOUT_TYPEMAP(unsigned short, unsigned short, ushort, UINT16_PTR)
+INOUT_TYPEMAP(int, int, int, INT32_PTR)
+INOUT_TYPEMAP(unsigned int, unsigned int, uint, UINT32_PTR)
+INOUT_TYPEMAP(long, long, int, INT32_PTR)
+INOUT_TYPEMAP(unsigned long, unsigned long, uint, UINT32_PTR)
+INOUT_TYPEMAP(long long, long long, long, INT64_PTR)
+INOUT_TYPEMAP(unsigned long long, unsigned long long, ulong, UINT64_PTR)
+INOUT_TYPEMAP(float, float, float, FLOAT_PTR)
+INOUT_TYPEMAP(double, double, double, DOUBLE_PTR)
+
+INOUT_TYPEMAP(enum SWIGTYPE, unsigned int, int, INT32_PTR)
+%typemap(dtype) enum SWIGTYPE *INOUT, enum SWIGTYPE &INOUT "ref $*dclassname"
+
+#undef INOUT_TYPEMAP
diff --git a/Lib/d/wrapperloader.swg b/Lib/d/wrapperloader.swg
new file mode 100644
index 000000000..428af7b60
--- /dev/null
+++ b/Lib/d/wrapperloader.swg
@@ -0,0 +1,308 @@
+/* -----------------------------------------------------------------------------
+ * wrapperloader.swg
+ *
+ * Support code for dynamically linking the C wrapper library from the D
+ * wrapper module.
+ *
+ * The loading code was adapted from the Derelict project and is used with
+ * permission from Michael Parker, the original author.
+ * ----------------------------------------------------------------------------- */
+
+%pragma(d) wrapperloadercode = %{
+private {
+ version(linux) {
+ version = Nix;
+ } else version(darwin) {
+ version = Nix;
+ } else version(OSX) {
+ version = Nix;
+ } else version(FreeBSD) {
+ version = Nix;
+ version = freebsd;
+ } else version(freebsd) {
+ version = Nix;
+ } else version(Unix) {
+ version = Nix;
+ } else version(Posix) {
+ version = Nix;
+ }
+
+ version(Tango) {
+ static import tango.stdc.string;
+ static import tango.stdc.stringz;
+
+ version (PhobosCompatibility) {
+ } else {
+ alias char[] string;
+ alias wchar[] wstring;
+ alias dchar[] dstring;
+ }
+ } else {
+ version(D_Version2) {
+ static import std.conv;
+ }
+ static import std.string;
+ static import std.c.string;
+ }
+
+ version(D_Version2) {
+ mixin("alias const(char)* CCPTR;");
+ } else {
+ alias char* CCPTR;
+ }
+
+ CCPTR swigToCString(string str) {
+ version(Tango) {
+ return tango.stdc.stringz.toStringz(str);
+ } else {
+ return std.string.toStringz(str);
+ }
+ }
+
+ string swigToDString(CCPTR cstr) {
+ version(Tango) {
+ return tango.stdc.stringz.fromStringz(cstr);
+ } else {
+ version(D_Version2) {
+ mixin("return std.conv.to!string(cstr);");
+ } else {
+ return std.c.string.toString(cstr);
+ }
+ }
+ }
+}
+
+class SwigSwigSharedLibLoadException : Exception {
+ this(in string[] libNames, in string[] reasons) {
+ string msg = "Failed to load one or more shared libraries:";
+ foreach(i, n; libNames) {
+ msg ~= "\n\t" ~ n ~ " - ";
+ if(i < reasons.length)
+ msg ~= reasons[i];
+ else
+ msg ~= "Unknown";
+ }
+ super(msg);
+ }
+}
+
+class SwigSymbolLoadException : Exception {
+ this(string SwigSharedLibName, string symbolName) {
+ super("Failed to load symbol " ~ symbolName ~ " from shared library " ~ SwigSharedLibName);
+ _symbolName = symbolName;
+ }
+
+ string symbolName() {
+ return _symbolName;
+ }
+
+private:
+ string _symbolName;
+}
+
+private {
+ version(Nix) {
+ version(freebsd) {
+ // the dl* functions are in libc on FreeBSD
+ }
+ else {
+ pragma(lib, "dl");
+ }
+
+ version(Tango) {
+ import tango.sys.Common;
+ } else version(linux) {
+ import std.c.linux.linux;
+ } else {
+ extern(C) {
+ const RTLD_NOW = 2;
+
+ void *dlopen(CCPTR file, int mode);
+ int dlclose(void* handle);
+ void *dlsym(void* handle, CCPTR name);
+ CCPTR dlerror();
+ }
+ }
+
+ alias void* SwigSharedLibHandle;
+
+ SwigSharedLibHandle swigLoadSharedLib(string libName) {
+ return dlopen(swigToCString(libName), RTLD_NOW);
+ }
+
+ void swigUnloadSharedLib(SwigSharedLibHandle hlib) {
+ dlclose(hlib);
+ }
+
+ void* swigGetSymbol(SwigSharedLibHandle hlib, string symbolName) {
+ return dlsym(hlib, swigToCString(symbolName));
+ }
+
+ string swigGetErrorStr() {
+ CCPTR err = dlerror();
+ if (err is null) {
+ return "Unknown Error";
+ }
+ return swigToDString(err);
+ }
+ } else version(Windows) {
+ alias ushort WORD;
+ alias uint DWORD;
+ alias CCPTR LPCSTR;
+ alias void* HMODULE;
+ alias void* HLOCAL;
+ alias int function() FARPROC;
+ struct VA_LIST {}
+
+ extern (Windows) {
+ HMODULE LoadLibraryA(LPCSTR);
+ FARPROC GetProcAddress(HMODULE, LPCSTR);
+ void FreeLibrary(HMODULE);
+ DWORD GetLastError();
+ DWORD FormatMessageA(DWORD, in void*, DWORD, DWORD, LPCSTR, DWORD, VA_LIST*);
+ HLOCAL LocalFree(HLOCAL);
+ }
+
+ DWORD MAKELANGID(WORD p, WORD s) {
+ return (((cast(WORD)s) << 10) | cast(WORD)p);
+ }
+
+ enum {
+ LANG_NEUTRAL = 0,
+ SUBLANG_DEFAULT = 1,
+ FORMAT_MESSAGE_ALLOCATE_BUFFER = 256,
+ FORMAT_MESSAGE_IGNORE_INSERTS = 512,
+ FORMAT_MESSAGE_FROM_SYSTEM = 4096
+ }
+
+ alias HMODULE SwigSharedLibHandle;
+
+ SwigSharedLibHandle swigLoadSharedLib(string libName) {
+ return LoadLibraryA(swigToCString(libName));
+ }
+
+ void swigUnloadSharedLib(SwigSharedLibHandle hlib) {
+ FreeLibrary(hlib);
+ }
+
+ void* swigGetSymbol(SwigSharedLibHandle hlib, string symbolName) {
+ return GetProcAddress(hlib, swigToCString(symbolName));
+ }
+
+ string swigGetErrorStr() {
+ DWORD errcode = GetLastError();
+
+ LPCSTR msgBuf;
+ DWORD i = FormatMessageA(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ null,
+ errcode,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ cast(LPCSTR)&msgBuf,
+ 0,
+ null);
+
+ string text = swigToDString(msgBuf);
+ LocalFree(cast(HLOCAL)msgBuf);
+
+ if (i >= 2) {
+ i -= 2;
+ }
+ return text[0 .. i];
+ }
+ } else {
+ static assert(0, "Operating system not supported by the wrapper loading code.");
+ }
+
+ final class SwigSharedLib {
+ void load(string[] names) {
+ if (_hlib !is null) return;
+
+ string[] failedLibs;
+ string[] reasons;
+
+ foreach(n; names) {
+ _hlib = swigLoadSharedLib(n);
+ if (_hlib is null) {
+ failedLibs ~= n;
+ reasons ~= swigGetErrorStr();
+ continue;
+ }
+ _name = n;
+ break;
+ }
+
+ if (_hlib is null) {
+ throw new SwigSwigSharedLibLoadException(failedLibs, reasons);
+ }
+ }
+
+ void* loadSymbol(string symbolName, bool doThrow = true) {
+ void* sym = swigGetSymbol(_hlib, symbolName);
+ if(doThrow && (sym is null)) {
+ throw new SwigSymbolLoadException(_name, symbolName);
+ }
+ return sym;
+ }
+
+ void unload() {
+ if(_hlib !is null) {
+ swigUnloadSharedLib(_hlib);
+ _hlib = null;
+ }
+ }
+
+ private:
+ string _name;
+ SwigSharedLibHandle _hlib;
+ }
+}
+
+static this() {
+ string[] possibleFileNames;
+ version (Posix) {
+ version (OSX) {
+ possibleFileNames ~= ["lib$wraplibrary.dylib", "lib$wraplibrary.bundle"];
+ }
+ possibleFileNames ~= ["lib$wraplibrary.so"];
+ } else version (Windows) {
+ possibleFileNames ~= ["$wraplibrary.dll", "lib$wraplibrary.so"];
+ } else {
+ static assert(false, "Operating system not supported by the wrapper loading code.");
+ }
+
+ auto library = new SwigSharedLib;
+ library.load(possibleFileNames);
+
+ string bindCode(string functionPointer, string symbol) {
+ return functionPointer ~ " = cast(typeof(" ~ functionPointer ~
+ "))library.loadSymbol(`" ~ symbol ~ "`);";
+ }
+
+ //#if !defined(SWIG_D_NO_EXCEPTION_HELPER)
+ mixin(bindCode("swigRegisterExceptionCallbacks", "SWIGRegisterExceptionCallbacks_$module"));
+ //#endif // SWIG_D_NO_EXCEPTION_HELPER
+ //#if !defined(SWIG_D_NO_STRING_HELPER)
+ mixin(bindCode("swigRegisterStringCallback", "SWIGRegisterStringCallback_$module"));
+ //#endif // SWIG_D_NO_STRING_HELPER
+ $wrapperloaderbindcode
+}
+
+//#if !defined(SWIG_D_NO_EXCEPTION_HELPER)
+extern(C) void function(
+ SwigExceptionCallback exceptionCallback,
+ SwigExceptionCallback illegalArgumentCallback,
+ SwigExceptionCallback illegalElementCallback,
+ SwigExceptionCallback ioCallback,
+ SwigExceptionCallback noSuchElementCallback) swigRegisterExceptionCallbacks;
+//#endif // SWIG_D_NO_EXCEPTION_HELPER
+
+//#if !defined(SWIG_D_NO_STRING_HELPER)
+extern(C) void function(SwigStringCallback callback) swigRegisterStringCallback;
+//#endif // SWIG_D_NO_STRING_HELPER
+%}
+
+%pragma(d) wrapperloaderbindcommand = %{
+ mixin(bindCode("$function", "$symbol"));%}
diff --git a/Lib/exception.i b/Lib/exception.i
index 2bc86b458..8d8df33dd 100644
--- a/Lib/exception.i
+++ b/Lib/exception.i
@@ -209,6 +209,40 @@ SWIGINTERN void SWIG_CSharpException(int code, const char *msg) {
#endif // SWIGLUA
+#ifdef SWIGD
+%{
+SWIGINTERN void SWIG_DThrowException(int code, const char *msg) {
+ SWIG_DExceptionCodes exception_code;
+ switch(code) {
+ case SWIG_IndexError:
+ exception_code = SWIG_DNoSuchElementException;
+ break;
+ case SWIG_IOError:
+ exception_code = SWIG_DIOException;
+ break;
+ case SWIG_ValueError:
+ exception_code = SWIG_DIllegalArgumentException;
+ break;
+ case SWIG_DivisionByZero:
+ case SWIG_MemoryError:
+ case SWIG_OverflowError:
+ case SWIG_RuntimeError:
+ case SWIG_TypeError:
+ case SWIG_SyntaxError:
+ case SWIG_SystemError:
+ case SWIG_UnknownError:
+ default:
+ exception_code = SWIG_DException;
+ break;
+ }
+ SWIG_DSetPendingException(exception_code, msg);
+}
+%}
+
+#define SWIG_exception(code, msg)\
+{ SWIG_DThrowException(code, msg); return $null; }
+#endif // SWIGD
+
#ifdef __cplusplus
/*
You can use the SWIG_CATCH_STDEXCEPT macro with the %exception
@@ -259,7 +293,7 @@ SWIGINTERN void SWIG_CSharpException(int code, const char *msg) {
/* rethrow the unknown exception */
-#ifdef SWIGCSHARP
+#if defined(SWIGCSHARP) || defined(SWIGD)
%typemap(throws,noblock=1, canthrow=1) (...) {
SWIG_exception(SWIG_RuntimeError,"unknown exception");
}
diff --git a/Lib/go/cdata.i b/Lib/go/cdata.i
index decf297c1..0dac6420c 100644
--- a/Lib/go/cdata.i
+++ b/Lib/go/cdata.i
@@ -12,83 +12,12 @@ typedef struct SWIGCDATA {
%}
%typemap(gotype) SWIGCDATA %{ []byte %}
-%typemap(out) SWIGCDATA (swigcdata argp) {
- argp = _swig_makegobyteslice($1.data, $1.len);
- $result.data = (char*)argp.data;
- $result.len = (int)argp.len;
-}
-
-/* The makegobyteslice function. */
-
-%insert(runtime) %{
-typedef struct {
- char *data;
- int len;
-} swigcdata;
-
-%}
-
-#ifndef SWIGGO_GCCGO
-%insert(runtime) %{
-extern
-#ifdef __cplusplus
-"C"
-#endif
-void _swig_gc_makegobyteslice(void *, int);
-static swigcdata _swig_makegobyteslice(const char *data, int len) {
- struct {
- const char *data;
- int len;
- swigcdata ret;
- } a;
- a.data = data;
- a.len = len;
- crosscall2(_swig_gc_makegobyteslice, &a, (int) sizeof a);
- return a.ret;
-}
-%}
-
-%insert(gc_header) %{
-typedef struct {
- byte *data;
- int32 len;
-} swigcdata;
-extern void ·_swig_internal_makegobyteslice(void);
-#pragma dynexport _swig_gc_makegobyteslice _swig_gc_makegobyteslice
-void _swig_gc_makegobyteslice(void *a, int32 n) {
- cgocallback(·_swig_internal_makegobyteslice, a, n);
-}
-void ·_swig_allocategobyteslice(byte *data, int32 len, swigcdata ret) {
- ret.data = mal(len);
- mcpy(ret.data, data, len);
- ret.len = len;
- FLUSH(&ret);
-}
+%typemap(out) SWIGCDATA %{
+ $result.data = (char*)_swig_goallocate($1.len);
+ memcpy($result.data, $1.data, $1.len);
+ $result.len = (int)$1.len;
%}
-%insert(go_header) %{
-type swigcdata struct { data *byte; len int }
-func _swig_allocategobyteslice(*byte, int) swigcdata
-func _swig_internal_makegobyteslice(data *byte, len int) swigcdata {
- return _swig_allocategobyteslice(data, len)
-}
-%}
-
-#else
-
-%insert(runtime) %{
-static swigcdata _swig_makegobyteslice(const char *data, int len) {
- swigcdata ret;
- ret.data = (char*)__go_alloc(len);
- memcpy(ret.data, data, len);
- ret.len = (int)len;
- return ret;
-}
-
-%}
-
-#endif
-
/* -----------------------------------------------------------------------------
* %cdata(TYPE [, NAME])
*
diff --git a/Lib/go/go.swg b/Lib/go/go.swg
index 648e112e1..587d219be 100644
--- a/Lib/go/go.swg
+++ b/Lib/go/go.swg
@@ -157,8 +157,8 @@
const float &,
const double &
%{
- $result = ($1_ltype)_swig_allocate(sizeof($*1_ltype));
- *$result = *($1_ltype)$input;
+ $result = ($1_ltype)_swig_goallocate(sizeof($*1_ltype));
+ *$result = *($1_ltype)&$input;
%}
/* The size_t type. */
@@ -192,7 +192,7 @@
%typemap(directorout) const size_t &
%{
- $result = ($1_ltype)_swig_allocate(sizeof($*1_ltype));
+ $result = ($1_ltype)_swig_goallocate(sizeof($*1_ltype));
*$result = *($1_ltype)$input;
%}
@@ -206,7 +206,7 @@
%typemap(out) SWIGTYPE (CLASS::*)
%{
- $result = _swig_allocate(sizeof($1_ltype));
+ $result = _swig_goallocate(sizeof($1_ltype));
*($&1_ltype)$result = $1;
%}
@@ -215,7 +215,7 @@
%typemap(directorout) SWIGTYPE (CLASS::*)
%{
- $result = _swig_allocate(sizeof($1_ltype));
+ $result = _swig_goallocate(sizeof($1_ltype));
*($&1_ltype)$result = $input;
%}
@@ -254,14 +254,6 @@
%typemap(out) SWIGTYPE *const&
%{ *($1_ltype)&$result = *$1; %}
-/* Function pointers are translated by the code in go.cxx into
- _swig_fnptr. Member pointers are translated to _swig_memberptr. */
-
-%insert(go_header) %{
-type _swig_fnptr *byte
-type _swig_memberptr *byte
-%}
-
/* References. */
/* Converting a C++ reference to Go has to be handled in the C++
@@ -341,6 +333,28 @@ type _swig_memberptr *byte
unsigned char *, unsigned char *&, unsigned char[ANY], unsigned char[]
%{ $result = ($1_ltype)$input.p; %}
+/* String & length */
+
+%typemap(gotype) (char *STRING, size_t LENGTH) "string"
+
+%typemap(in) (char *STRING, size_t LENGTH)
+%{
+ $1 = ($1_ltype)$input.p;
+ $2 = ($2_ltype)$input.n;
+%}
+
+%typemap(out) (char *STRING, size_t LENGTH)
+%{ $result = _swig_makegostring((char*)$1, (size_t)$2); %}
+
+%typemap(directorin) (char *STRING, size_t LENGTH)
+%{ $input = _swig_makegostring((char*)$1_name, $2_name); %}
+
+%typemap(directorout) (char *STRING, size_t LENGTH)
+%{
+ $1 = ($1_ltype)$input.p;
+ $2 = ($2_ltype)$input.n;
+%}
+
/* Enums. We can't do the right thing for enums in typemap(gotype) so
we deliberately don't define them. The right thing would be to
capitalize the name. This is instead done in go.cxx. */
@@ -508,6 +522,7 @@ type _swig_memberptr *byte
SWIGTYPE [],
SWIGTYPE (CLASS::*)
""
+
/* Go keywords. */
%include <gokw.swg>
diff --git a/Lib/go/goruntime.swg b/Lib/go/goruntime.swg
index 057f81d01..6aeeab730 100644
--- a/Lib/go/goruntime.swg
+++ b/Lib/go/goruntime.swg
@@ -30,57 +30,32 @@ swiggo_size_assert(swiggo_long_long, 8)
swiggo_size_assert(float, 4)
swiggo_size_assert(double, 8)
-extern
#ifdef __cplusplus
-"C"
+extern "C" {
#endif
-void crosscall2(void (*fn)(void *, int), void *, int);
-
-extern
+extern void crosscall2(void (*fn)(void *, int), void *, int);
+extern void _cgo_allocate(void *, int);
+extern void _cgo_panic(void *, int);
#ifdef __cplusplus
-"C"
+}
#endif
-void _swig_gc_allocate(void *, int);
-static void *_swig_allocate(int len) {
+
+static void *_swig_goallocate(size_t len) {
struct {
- int len;
+ size_t len;
void *ret;
} a;
a.len = len;
- crosscall2(_swig_gc_allocate, &a, (int) sizeof a);
+ crosscall2(_cgo_allocate, &a, (int) sizeof a);
return a.ret;
}
-extern
-#ifdef __cplusplus
-"C"
-#endif
-void _swig_gc_makegostring(void *, int);
-static _gostring_ _swig_makegostring(const char *p, size_t l) {
- struct {
- const char *p;
- int l;
- _gostring_ ret;
- } a;
- a.p = p;
- a.l = l;
- crosscall2(_swig_gc_makegostring, &a, (int) sizeof a);
- return a.ret;
-}
-
-extern
-#ifdef __cplusplus
-"C"
-#endif
-void _swig_gc_gopanic(void *, int);
static void _swig_gopanic(const char *p) {
struct {
const char *p;
- int l;
} a;
a.p = p;
- a.l = strlen(p);
- crosscall2(_swig_gc_gopanic, &a, (int) sizeof a);
+ crosscall2(_cgo_panic, &a, (int) sizeof a);
}
%}
@@ -91,10 +66,6 @@ static void _swig_gopanic(const char *p) {
#include "runtime.h"
#include "cgocall.h"
-#pragma dynimport initcgo initcgo "libcgo.so"
-#pragma dynimport libcgo_thread_start libcgo_thread_start "libcgo.so"
-#pragma dynimport libcgo_set_scheduler libcgo_set_scheduler "libcgo.so"
-
#ifdef _64BIT
#define SWIG_PARM_SIZE 8
#else
@@ -102,97 +73,56 @@ static void _swig_gopanic(const char *p) {
#endif
%}
-/* 6g/8g C boilerplate that is only needed once in a program. This
- only gets added to the file if nothing is imported. */
-%insert(gc_once) %{
-
-extern void ·_swig_internal_allocate(void);
-#pragma dynexport _swig_gc_allocate _swig_gc_allocate
-void _swig_gc_allocate(void *a, int32 n) {
- cgocallback(·_swig_internal_allocate, a, n);
-}
-
-void ·_swig_allocatememory(int32 len, byte *ret) {
- ret = mal(len);
- FLUSH(&ret);
-}
-
-extern void ·_swig_internal_makegostring(void);
-#pragma dynexport _swig_gc_makegostring _swig_gc_makegostring
-void _swig_gc_makegostring(void *a, int32 n) {
- cgocallback(·_swig_internal_makegostring, a, n);
-}
-
-void ·_swig_allocatestring(byte *p, int32 l, String ret) {
- ret.str = mal(l+1);
- mcpy(ret.str, p, l);
- ret.len = l;
- FLUSH(&ret);
-}
-
-extern void ·_swig_internal_gopanic(void);
-#pragma dynexport _swig_gc_gopanic _swig_gc_gopanic
-void _swig_gc_gopanic(void *a, int32 n) {
- cgocallback(·_swig_internal_gopanic, a, n);
-}
-
-%}
-
-/* Go code that is only needed once in a program. This is only added
- to the file if nothing is imported. */
-%insert(go_once) %{
-func _swig_allocatememory(int) *byte
-func _swig_internal_allocate(len int) *byte {
- return _swig_allocatememory(len)
-}
-
-func _swig_allocatestring(*byte, int) string
-func _swig_internal_makegostring(p *byte, l int) string {
- return _swig_allocatestring(p, l)
-}
-
-func _swig_internal_gopanic(p *byte, l int) {
- panic(_swig_allocatestring(p, l))
-}
-%}
-
#else
/* Boilerplate for C/C++ code when using gccgo. */
%insert(runtime) %{
#define SWIGGO_GCCGO
-extern
#ifdef __cplusplus
-"C"
+extern "C" {
#endif
-void *__go_alloc (size_t);
-
-static void *_swig_allocate(int len) {
- return __go_alloc(len);
+extern void *_cgo_allocate(size_t);
+extern void _cgo_panic(const char *);
+#ifdef __cplusplus
}
+#endif
+
+#define _swig_goallocate _cgo_allocate
+#define _swig_gopanic _cgo_panic
+
+%}
+
+#endif
+
+%insert(runtime) %{
static _gostring_ _swig_makegostring(const char *p, size_t l) {
_gostring_ ret;
- ret.p = (char*)__go_alloc(l);
+ ret.p = (char*)_swig_goallocate(l + 1);
memcpy(ret.p, p, l);
ret.n = l;
return ret;
}
-extern
-#ifdef __cplusplus
-"C"
-#endif
-void __go_panic_msg(const char *);
-#define _swig_gopanic __go_panic_msg
+#define SWIG_contract_assert(expr, msg) \
+ if (!(expr)) { _swig_gopanic(msg); } else
+%}
+
+#ifndef SWIGGO_GCCGO
+
+%insert(go_header) %{
+
+import _ "runtime/cgo"
%}
#endif
-%insert(runtime) %{
-#define SWIG_contract_assert(expr, msg) \
- if (!(expr)) { _swig_gopanic(msg); } else
-%}
+/* Function pointers are translated by the code in go.cxx into
+ _swig_fnptr. Member pointers are translated to _swig_memberptr. */
+%insert(go_header) %{
+type _swig_fnptr *byte
+type _swig_memberptr *byte
+%}
diff --git a/Lib/guile/typemaps.i b/Lib/guile/typemaps.i
index c194d4bc9..c31f1463f 100644
--- a/Lib/guile/typemaps.i
+++ b/Lib/guile/typemaps.i
@@ -348,7 +348,7 @@ typedef unsigned long SCM;
* String & length
* ------------------------------------------------------------ */
-%typemap(in) (char *STRING, int LENGTH) {
+%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
size_t temp;
$1 = ($1_ltype) gh_scm2newstr($input, &temp);
$2 = ($2_ltype) temp;
diff --git a/Lib/java/java.swg b/Lib/java/java.swg
index 44e1337bc..159aafb17 100644
--- a/Lib/java/java.swg
+++ b/Lib/java/java.swg
@@ -1290,6 +1290,21 @@ SWIG_PROXY_CONSTRUCTOR(true, true, SWIGTYPE)
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }
+/* String & length */
+%typemap(jni) (char *STRING, size_t LENGTH) "jbyteArray"
+%typemap(jtype) (char *STRING, size_t LENGTH) "byte[]"
+%typemap(jstype) (char *STRING, size_t LENGTH) "byte[]"
+%typemap(javain) (char *STRING, size_t LENGTH) "$javainput"
+%typemap(freearg) (char *STRING, size_t LENGTH) ""
+%typemap(in) (char *STRING, size_t LENGTH) {
+ $1 = (char *) JCALL2(GetByteArrayElements, jenv, $input, 0);
+ $2 = (size_t) JCALL1(GetArrayLength, jenv, $input);
+}
+%typemap(argout) (char *STRING, size_t LENGTH) {
+ JCALL3(ReleaseByteArrayElements, jenv, $input, (jbyte *)$1, 0);
+}
+%apply (char *STRING, size_t LENGTH) { (char *STRING, int LENGTH) }
+
/* java keywords */
%include <javakw.swg>
diff --git a/Lib/ocaml/std_string.i b/Lib/ocaml/std_string.i
index e75e95304..5b6966dec 100644
--- a/Lib/ocaml/std_string.i
+++ b/Lib/ocaml/std_string.i
@@ -11,141 +11,91 @@
// However, I think I'll wait until someone asks for it...
// ------------------------------------------------------------------------
-%include <exception.i>
-
%{
#include <string>
#include <vector>
- using std::string;
- using std::vector;
%}
-
+
+%include <exception.i>
%include <std_vector.i>
-%naturalvar std::string;
-%naturalvar std::wstring;
-
namespace std {
- template <class charT> class basic_string {
- public:
- typedef charT *pointer;
- typedef charT &reference;
- typedef const charT &const_reference;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- basic_string();
- basic_string( charT *str );
- size_t size();
- charT operator []( int pos ) const;
- charT *c_str() const;
- basic_string<charT> &operator = ( const basic_string &ws );
- basic_string<charT> &operator = ( const charT *str );
- basic_string<charT> &append( const basic_string<charT> &other );
- basic_string<charT> &append( const charT *str );
- void push_back( charT c );
- void clear();
- void reserve( size_type t );
- void resize( size_type n, charT c = charT() );
- int compare( const basic_string<charT> &other ) const;
- int compare( const charT *str ) const;
- basic_string<charT> &insert( size_type pos,
- const basic_string<charT> &str );
- size_type find( const basic_string<charT> &other, int pos = 0 ) const;
- size_type find( charT c, int pos = 0 ) const;
- %extend {
- bool operator == ( const basic_string<charT> &other ) const {
- return self->compare( other ) == 0;
- }
- bool operator != ( const basic_string<charT> &other ) const {
- return self->compare( other ) != 0;
- }
- bool operator < ( const basic_string<charT> &other ) const {
- return self->compare( other ) == -1;
- }
- bool operator > ( const basic_string<charT> &other ) const {
- return self->compare( other ) == 1;
- }
- bool operator <= ( const basic_string<charT> &other ) const {
- return self->compare( other ) != 1;
- }
- bool operator >= ( const basic_string<charT> &other ) const {
- return self->compare( other ) != -1;
- }
- }
- };
-
- %template(string) basic_string<char>;
- %template(wstring) basic_string<wchar_t>;
- typedef basic_string<char> string;
- typedef basic_string<wchar_t> wstring;
-
- /* Overloading check */
- %typemap(in) string {
- if (caml_ptr_check($input))
- $1.assign((char *)caml_ptr_val($input,0),
- caml_string_len($input));
- else
- SWIG_exception(SWIG_TypeError, "string expected");
- }
- %typemap(in) const string & (std::string temp) {
- if (caml_ptr_check($input)) {
- temp.assign((char *)caml_ptr_val($input,0),
- caml_string_len($input));
- $1 = &temp;
- } else {
- SWIG_exception(SWIG_TypeError, "string expected");
- }
- }
+%naturalvar string;
+%naturalvar wstring;
+
+class string;
+class wstring;
+
+/* Overloading check */
+%typemap(in) string {
+ /* %typemap(in) string */
+ if (caml_ptr_check($input))
+ $1.assign((char *)caml_ptr_val($input,0), caml_string_len($input));
+ else
+ SWIG_exception(SWIG_TypeError, "string expected");
+}
- %typemap(in) string & (std::string temp) {
- if (caml_ptr_check($input)) {
- temp.assign((char *)caml_ptr_val($input,0),
- caml_string_len($input));
- $1 = &temp;
- } else {
- SWIG_exception(SWIG_TypeError, "string expected");
- }
- }
+%typemap(in) const string & (std::string temp) {
+ /* %typemap(in) const string & */
+ if (caml_ptr_check($input)) {
+ temp.assign((char *)caml_ptr_val($input,0), caml_string_len($input));
+ $1 = &temp;
+ } else {
+ SWIG_exception(SWIG_TypeError, "string expected");
+ }
+}
- %typemap(in) string * (std::string *temp) {
- if (caml_ptr_check($input)) {
- temp = new std::string((char *)caml_ptr_val($input,0),
- caml_string_len($input));
- $1 = temp;
- } else {
- SWIG_exception(SWIG_TypeError, "string expected");
- }
- }
+%typemap(in) string & (std::string temp) {
+ /* %typemap(in) string & */
+ if (caml_ptr_check($input)) {
+ temp.assign((char *)caml_ptr_val($input,0), caml_string_len($input));
+ $1 = &temp;
+ } else {
+ SWIG_exception(SWIG_TypeError, "string expected");
+ }
+}
- %typemap(free) string * (std::string *temp) {
- delete temp;
- }
+%typemap(in) string * (std::string *temp) {
+ /* %typemap(in) string * */
+ if (caml_ptr_check($input)) {
+ temp = new std::string((char *)caml_ptr_val($input,0), caml_string_len($input));
+ $1 = temp;
+ } else {
+ SWIG_exception(SWIG_TypeError, "string expected");
+ }
+}
- %typemap(argout) string & {
- caml_list_append(swig_result,caml_val_string_len((*$1).c_str(),
- (*$1).size()));
- }
+%typemap(free) string * (std::string *temp) {
+ delete temp;
+}
- %typemap(directorout) string {
- $result.assign((char *)caml_ptr_val($input,0),
- caml_string_len($input));
- }
+%typemap(argout) string & {
+ /* %typemap(argout) string & */
+ swig_result = caml_list_append(swig_result,caml_val_string_len((*$1).c_str(), (*$1).size()));
+}
- %typemap(out) string {
- $result = caml_val_string_len($1.c_str(),$1.size());
- }
+%typemap(directorout) string {
+ /* %typemap(directorout) string */
+ $result.assign((char *)caml_ptr_val($input,0), caml_string_len($input));
+}
+
+%typemap(out) string {
+ /* %typemap(out) string */
+ $result = caml_val_string_len($1.c_str(),$1.size());
+}
- %typemap(out) string * {
+%typemap(out) string * {
+ /* %typemap(out) string * */
$result = caml_val_string_len((*$1).c_str(),(*$1).size());
- }
+}
}
#ifdef ENABLE_CHARPTR_ARRAY
-char **c_charptr_array( const std::vector <string > &str_v );
+char **c_charptr_array( const std::vector <std::string > &str_v );
%{
- SWIGEXT char **c_charptr_array( const std::vector <string > &str_v ) {
+ SWIGEXT char **c_charptr_array( const std::vector <std::string > &str_v ) {
char **out = new char *[str_v.size() + 1];
out[str_v.size()] = 0;
for( int i = 0; i < str_v.size(); i++ ) {
@@ -157,7 +107,7 @@ char **c_charptr_array( const std::vector <string > &str_v );
#endif
#ifdef ENABLE_STRING_VECTOR
-%template (StringVector) std::vector<string >;
+%template (StringVector) std::vector<std::string >;
%insert(ml) %{
(* Some STL convenience items *)
diff --git a/Lib/ocaml/swigp4.ml.in b/Lib/ocaml/swigp4.ml.in
index 0387c0a47..2f6074a9e 100644
--- a/Lib/ocaml/swigp4.ml.in
+++ b/Lib/ocaml/swigp4.ml.in
@@ -1,118 +1,135 @@
-open Pcaml ;;
+open Camlp4
+
+module Id : Sig.Id =
+struct
+ let name = "swigp4"
+ let version = "0.1"
+end
+
+module Make (Syntax : Sig.Camlp4Syntax) =
+struct
+ open Sig
+ include Syntax
-let lap x y = x :: y
-let c_ify e @OCAMLLOC@ =
- match e with
- <:expr< $int:_$ >> -> <:expr< (C_int $e$) >>
- | <:expr< $str:_$ >> -> <:expr< (C_string $e$) >>
- | <:expr< $chr:_$ >> -> <:expr< (C_char $e$) >>
- | <:expr< $flo:_$ >> -> <:expr< (C_double $e$) >>
- | <:expr< True >> -> <:expr< (C_bool $e$) >>
- | <:expr< False >> -> <:expr< (C_bool $e$) >>
- | _ -> <:expr< $e$ >>
-let mk_list args @OCAMLLOC@ f =
- let rec mk_list_inner args @OCAMLLOC@ f =
- match args with
- [] -> <:expr< [] >>
- | x :: xs ->
- (let @OCAMLLOC@ = MLast.loc_of_expr x in
- <:expr< [ ($f x @OCAMLLOC@$) ] @ ($mk_list_inner xs @OCAMLLOC@ f$) >>) in
- match args with
- [] -> <:expr< (Obj.magic C_void) >>
- | [ a ] -> <:expr< (Obj.magic $f a @OCAMLLOC@$) >>
- | _ -> <:expr< (Obj.magic (C_list ($mk_list_inner args @OCAMLLOC@ f$))) >>
+ let _loc = Loc.ghost
+ let lap x y = x :: y
+ let c_ify e loc =
+ match e with
+ <:expr< $int:_$ >> -> <:expr< (C_int $e$) >>
+ | <:expr< $str:_$ >> -> <:expr< (C_string $e$) >>
+ | <:expr< $chr:_$ >> -> <:expr< (C_char $e$) >>
+ | <:expr< $flo:_$ >> -> <:expr< (C_double $e$) >>
+ | <:expr< True >> -> <:expr< (C_bool $e$) >>
+ | <:expr< False >> -> <:expr< (C_bool $e$) >>
+ | _ -> <:expr< $e$ >>
+ let mk_list args loc f =
+ let rec mk_list_inner args loc f =
+ match args with
+ [] -> <:expr< [] >>
+ | x :: xs ->
+ (let loc = Ast.loc_of_expr x in
+ <:expr< [ ($f x _loc$) ] @ ($mk_list_inner xs loc f$) >>) in
+ match args with
+ [] -> <:expr< (Obj.magic C_void) >>
+ | [ a ] -> <:expr< (Obj.magic $f a _loc$) >>
+ | _ -> <:expr< (Obj.magic (C_list ($mk_list_inner args loc f$))) >> ;;
+
+ EXTEND Gram
+ GLOBAL: expr;
-EXTEND
- expr:
- [ [ e1 = expr ; "'" ; "[" ; e2 = expr ; "]" ->
- <:expr< (invoke $e1$) "[]" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "->" ; l = LIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
- <:expr< (invoke $e1$) $str:l$ ($mk_list args @OCAMLLOC@ c_ify$) >>
- | e1 = expr ; "->" ; u = UIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
- <:expr< (invoke $e1$) $str:u$ ($mk_list args @OCAMLLOC@ c_ify$) >>
- | e1 = expr ; "->" ; s = expr LEVEL "simple" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
- <:expr< (invoke $e1$) $s$ ($mk_list args @OCAMLLOC@ c_ify$) >>
- | e1 = expr ; "'" ; "." ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
- <:expr< (invoke $e1$) "()" ($mk_list args @OCAMLLOC@ c_ify$) >>
- | e1 = expr ; "'" ; "->" ; l = LIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
- <:expr< (invoke ((invoke $e1$) "->" C_void)) $str:l$ ($mk_list args @OCAMLLOC@ c_ify$) >>
- | e1 = expr ; "'" ; "->" ; u = UIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
- <:expr< (invoke ((invoke $e1$) "->" C_void)) $str:u$ ($mk_list args @OCAMLLOC@ c_ify$) >>
- | e1 = expr ; "'" ; "->" ; s = expr LEVEL "simple" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
- <:expr< (invoke ((invoke $e1$) "->" C_void)) $s$ ($mk_list args @OCAMLLOC@ c_ify$) >>
- | e1 = expr ; "'" ; "++" ->
- <:expr< (invoke $e1$) "++" C_void >>
- | e1 = expr ; "'" ; "--" ->
- <:expr< (invoke $e1$) "--" C_void >>
- | e1 = expr ; "'" ; "-" ; e2 = expr ->
- <:expr< (invoke $e1$) "-" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "+" ; e2 = expr -> <:expr< (invoke $e1$) "+" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "*" ; e2 = expr -> <:expr< (invoke $e1$) "*" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | "'" ; "&" ; e1 = expr ->
- <:expr< (invoke $e1$) "&" C_void >>
- | "'" ; "!" ; e1 = expr ->
- <:expr< (invoke $e1$) "!" C_void >>
- | "'" ; "~" ; e1 = expr ->
- <:expr< (invoke $e1$) "~" C_void >>
- | e1 = expr ; "'" ; "/" ; e2 = expr ->
- <:expr< (invoke $e1$) "/" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "%" ; e2 = expr ->
- <:expr< (invoke $e1$) "%" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "lsl" ; e2 = expr ->
- <:expr< (invoke $e1$) ("<" ^ "<") (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "lsr" ; e2 = expr ->
- <:expr< (invoke $e1$) (">" ^ ">") (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "<" ; e2 = expr ->
- <:expr< (invoke $e1$) "<" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "<=" ; e2 = expr ->
- <:expr< (invoke $e1$) "<=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; ">" ; e2 = expr ->
- <:expr< (invoke $e1$) ">" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; ">=" ; e2 = expr ->
- <:expr< (invoke $e1$) ">=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "==" ; e2 = expr ->
- <:expr< (invoke $e1$) "==" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "!=" ; e2 = expr ->
- <:expr< (invoke $e1$) "!=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "&" ; e2 = expr ->
- <:expr< (invoke $e1$) "&" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "^" ; e2 = expr ->
- <:expr< (invoke $e1$) "^" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "|" ; e2 = expr ->
- <:expr< (invoke $e1$) "|" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "&&" ; e2 = expr ->
- <:expr< (invoke $e1$) "&&" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "||" ; e2 = expr ->
- <:expr< (invoke $e1$) "||" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "=" ; e2 = expr ->
- <:expr< (invoke $e1$) "=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "+=" ; e2 = expr ->
- <:expr< (invoke $e1$) "+=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "-=" ; e2 = expr ->
- <:expr< (invoke $e1$) "-=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "*=" ; e2 = expr ->
- <:expr< (invoke $e1$) "*=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "/=" ; e2 = expr ->
- <:expr< (invoke $e1$) "/=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "%=" ; e2 = expr ->
- <:expr< (invoke $e1$) "%=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "lsl" ; "=" ; e2 = expr ->
- <:expr< (invoke $e1$) ("<" ^ "<=") (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "lsr" ; "=" ; e2 = expr ->
- <:expr< (invoke $e1$) (">" ^ ">=") (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "&=" ; e2 = expr ->
- <:expr< (invoke $e1$) "&=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "^=" ; e2 = expr ->
- <:expr< (invoke $e1$) "^=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | e1 = expr ; "'" ; "|=" ; e2 = expr ->
- <:expr< (invoke $e1$) "|=" (C_list [ $c_ify e2 @OCAMLLOC@$ ]) >>
- | "'" ; e = expr -> c_ify e @OCAMLLOC@
- | c = expr ; "as" ; id = LIDENT -> <:expr< $lid:"get_" ^ id$ $c$ >>
- | c = expr ; "to" ; id = LIDENT -> <:expr< $uid:"C_" ^ id$ $c$ >>
- | "`" ; "`" ; l = LIDENT -> <:expr< C_enum `$lid:l$ >>
- | "`" ; "`" ; u = UIDENT -> <:expr< C_enum `$uid:u$ >>
- | f = expr ; "'" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
- <:expr< $f$ ($mk_list args @OCAMLLOC@ c_ify$) >>
- ] ] ;
-END ;;
-
+ expr: LEVEL "top"
+ [ [ e1 = expr ; "'" ; "[" ; e2 = expr ; "]" ->
+ <:expr< (invoke $e1$) "[]" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "->" ; l = LIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
+ <:expr< (invoke $e1$) $str:l$ ($mk_list args _loc c_ify$) >>
+ | e1 = expr ; "->" ; u = UIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
+ <:expr< (invoke $e1$) $str:u$ ($mk_list args _loc c_ify$) >>
+ | e1 = expr ; "->" ; s = expr LEVEL "simple" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
+ <:expr< (invoke $e1$) $s$ ($mk_list args _loc c_ify$) >>
+ | e1 = expr ; "'" ; "." ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
+ <:expr< (invoke $e1$) "()" ($mk_list args _loc c_ify$) >>
+ | e1 = expr ; "'" ; "->" ; l = LIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
+ <:expr< (invoke ((invoke $e1$) "->" C_void)) $str:l$ ($mk_list args _loc c_ify$) >>
+ | e1 = expr ; "'" ; "->" ; u = UIDENT ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
+ <:expr< (invoke ((invoke $e1$) "->" C_void)) $str:u$ ($mk_list args _loc c_ify$) >>
+ | e1 = expr ; "'" ; "->" ; s = expr LEVEL "simple" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
+ <:expr< (invoke ((invoke $e1$) "->" C_void)) $s$ ($mk_list args _loc c_ify$) >>
+ | e1 = expr ; "'" ; "++" ->
+ <:expr< (invoke $e1$) "++" C_void >>
+ | e1 = expr ; "'" ; "--" ->
+ <:expr< (invoke $e1$) "--" C_void >>
+ | e1 = expr ; "'" ; "-" ; e2 = expr ->
+ <:expr< (invoke $e1$) "-" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "+" ; e2 = expr -> <:expr< (invoke $e1$) "+" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "*" ; e2 = expr -> <:expr< (invoke $e1$) "*" (C_list [ $c_ify e2 _loc$ ]) >>
+ | "'" ; "&" ; e1 = expr ->
+ <:expr< (invoke $e1$) "&" C_void >>
+ | "'" ; "!" ; e1 = expr ->
+ <:expr< (invoke $e1$) "!" C_void >>
+ | "'" ; "~" ; e1 = expr ->
+ <:expr< (invoke $e1$) "~" C_void >>
+ | e1 = expr ; "'" ; "/" ; e2 = expr ->
+ <:expr< (invoke $e1$) "/" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "%" ; e2 = expr ->
+ <:expr< (invoke $e1$) "%" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "lsl" ; e2 = expr ->
+ <:expr< (invoke $e1$) ("<" ^ "<") (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "lsr" ; e2 = expr ->
+ <:expr< (invoke $e1$) (">" ^ ">") (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "<" ; e2 = expr ->
+ <:expr< (invoke $e1$) "<" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "<=" ; e2 = expr ->
+ <:expr< (invoke $e1$) "<=" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; ">" ; e2 = expr ->
+ <:expr< (invoke $e1$) ">" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; ">=" ; e2 = expr ->
+ <:expr< (invoke $e1$) ">=" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "==" ; e2 = expr ->
+ <:expr< (invoke $e1$) "==" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "!=" ; e2 = expr ->
+ <:expr< (invoke $e1$) "!=" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "&" ; e2 = expr ->
+ <:expr< (invoke $e1$) "&" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "^" ; e2 = expr ->
+ <:expr< (invoke $e1$) "^" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "|" ; e2 = expr ->
+ <:expr< (invoke $e1$) "|" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "&&" ; e2 = expr ->
+ <:expr< (invoke $e1$) "&&" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "||" ; e2 = expr ->
+ <:expr< (invoke $e1$) "||" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "=" ; e2 = expr ->
+ <:expr< (invoke $e1$) "=" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "+=" ; e2 = expr ->
+ <:expr< (invoke $e1$) "+=" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "-=" ; e2 = expr ->
+ <:expr< (invoke $e1$) "-=" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "*=" ; e2 = expr ->
+ <:expr< (invoke $e1$) "*=" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "/=" ; e2 = expr ->
+ <:expr< (invoke $e1$) "/=" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "%=" ; e2 = expr ->
+ <:expr< (invoke $e1$) "%=" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "lsl" ; "=" ; e2 = expr ->
+ <:expr< (invoke $e1$) ("<" ^ "<=") (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "lsr" ; "=" ; e2 = expr ->
+ <:expr< (invoke $e1$) (">" ^ ">=") (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "&=" ; e2 = expr ->
+ <:expr< (invoke $e1$) "&=" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "^=" ; e2 = expr ->
+ <:expr< (invoke $e1$) "^=" (C_list [ $c_ify e2 _loc$ ]) >>
+ | e1 = expr ; "'" ; "|=" ; e2 = expr ->
+ <:expr< (invoke $e1$) "|=" (C_list [ $c_ify e2 _loc$ ]) >>
+ | "'" ; e = expr -> c_ify e _loc
+ | c = expr ; "as" ; id = LIDENT -> <:expr< $lid:"get_" ^ id$ $c$ >>
+ | c = expr ; "to" ; id = LIDENT -> <:expr< $uid:"C_" ^ id$ $c$ >>
+ | "`" ; "`" ; l = LIDENT -> <:expr< C_enum `$lid:l$ >>
+ | "`" ; "`" ; u = UIDENT -> <:expr< C_enum `$uid:u$ >>
+ | f = expr ; "'" ; "(" ; args = LIST0 (expr LEVEL "simple") SEP "," ; ")" ->
+ <:expr< $f$ ($mk_list args _loc c_ify$) >>
+ ] ] ;
+ END ;;
+
+end
+
+module M = Register.OCamlSyntaxExtension(Id)(Make)
diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i
index e5458a3e2..cada7b957 100644
--- a/Lib/ocaml/typemaps.i
+++ b/Lib/ocaml/typemaps.i
@@ -82,6 +82,17 @@
}
}
+%typemap(in) char *& (char *temp) {
+ /* %typemap(in) char *& */
+ temp = (char*)caml_val_ptr($1,$descriptor);
+ $1 = &temp;
+}
+
+%typemap(argout) char *& {
+ /* %typemap(argout) char *& */
+ swig_result = caml_list_append(swig_result,caml_val_string_len(*$1, strlen(*$1)));
+}
+
#else
%typemap(in) SWIGTYPE {
diff --git a/Lib/octave/octcontainer.swg b/Lib/octave/octcontainer.swg
index 6613fcfff..4f14ccef1 100644
--- a/Lib/octave/octcontainer.swg
+++ b/Lib/octave/octcontainer.swg
@@ -4,8 +4,7 @@
* Octave cell <-> C++ container wrapper
*
* This wrapper, and its iterator, allows a general use (and reuse) of
- * the the mapping between C++ and Octave, thanks to the C++
- * templates.
+ * the mapping between C++ and Octave, 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
diff --git a/Lib/perl5/perlprimtypes.swg b/Lib/perl5/perlprimtypes.swg
index ae7bb3886..86a78c5bf 100644
--- a/Lib/perl5/perlprimtypes.swg
+++ b/Lib/perl5/perlprimtypes.swg
@@ -311,7 +311,9 @@ SWIG_AsVal_dec(double)(SV *obj, double *val)
const char *nptr = SvPV_nolen(obj);
if (nptr) {
char *endptr;
- double v = strtod(nptr, &endptr);
+ double v;
+ errno = 0;
+ v = strtod(nptr, &endptr);
if (errno == ERANGE) {
errno = 0;
return SWIG_OverflowError;
diff --git a/Lib/php/php.swg b/Lib/php/php.swg
index f4cc8d2b2..b1866137d 100644
--- a/Lib/php/php.swg
+++ b/Lib/php/php.swg
@@ -76,8 +76,7 @@
$1 = ($1_ltype) Z_STRVAL_PP($input);
}
-%typemap(in) (char *STRING, int LENGTH)
-{
+%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
convert_to_string_ex($input);
$1 = ($1_ltype) Z_STRVAL_PP($input);
$2 = ($2_ltype) Z_STRLEN_PP($input);
@@ -415,17 +414,17 @@
%php_typecheck(unsigned int,SWIG_TYPECHECK_UINT32,IS_LONG)
%php_typecheck(short,SWIG_TYPECHECK_INT16,IS_LONG)
%php_typecheck(unsigned short,SWIG_TYPECHECK_UINT16,IS_LONG)
-%php_typecheck(long,SWIG_TYPECHECK_INT64,IS_LONG)
-%php_typecheck(unsigned long,SWIG_TYPECHECK_UINT64,IS_LONG)
+%php_typecheck(long,SWIG_TYPECHECK_INT32,IS_LONG)
+%php_typecheck(unsigned long,SWIG_TYPECHECK_UINT32,IS_LONG)
%php_typecheck(long long,SWIG_TYPECHECK_INT64,IS_LONG)
%php_typecheck(unsigned long long,SWIG_TYPECHECK_UINT64,IS_LONG)
%php_typecheck(signed char,SWIG_TYPECHECK_INT8,IS_LONG)
%php_typecheck(unsigned char,SWIG_TYPECHECK_UINT8,IS_LONG)
-%php_typecheck(size_t,SWIG_TYPECHECK_INT16,IS_LONG)
-%php_typecheck(enum SWIGTYPE,SWIG_TYPECHECK_INT8,IS_LONG)
+%php_typecheck(size_t,SWIG_TYPECHECK_SIZE,IS_LONG)
+%php_typecheck(enum SWIGTYPE,SWIG_TYPECHECK_INTEGER,IS_LONG)
%php_typecheck(bool,SWIG_TYPECHECK_BOOL,IS_BOOL)
%php_typecheck(float,SWIG_TYPECHECK_FLOAT,IS_DOUBLE)
-%php_typecheck(double,SWIG_TYPECHECK_BOOL,IS_DOUBLE)
+%php_typecheck(double,SWIG_TYPECHECK_DOUBLE,IS_DOUBLE)
%php_typecheck(char,SWIG_TYPECHECK_CHAR,IS_STRING)
%typemap(typecheck,precedence=SWIG_TYPECHECK_STRING) char *, char *&, char []
@@ -447,6 +446,12 @@
_v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $1_descriptor, 0) >= 0);
}
+%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *const&
+{
+ void *tmp;
+ _v = (SWIG_ConvertPtr(*$input, (void**)&tmp, $*1_descriptor, 0) >= 0);
+}
+
%typecheck(SWIG_TYPECHECK_VOIDPTR) void *
{
void *tmp;
diff --git a/Lib/pike/pike.swg b/Lib/pike/pike.swg
index 0cfec52b0..130af1346 100644
--- a/Lib/pike/pike.swg
+++ b/Lib/pike/pike.swg
@@ -185,7 +185,7 @@ extern "C" {
* String & length
* ------------------------------------------------------------ */
-%typemap(in, pikedesc="tStr") (char *STRING, int LENGTH) {
+%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
if ($input.type != T_STRING)
Pike_error("Bad argument: Expected a string.\n");
$1 = ($1_ltype) STR0($input.u.string);
diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg
index efca86cf1..40506e15b 100644
--- a/Lib/python/pycontainer.swg
+++ b/Lib/python/pycontainer.swg
@@ -4,8 +4,7 @@
* Python sequence <-> C++ container wrapper
*
* This wrapper, and its iterator, allows a general use (and reuse) of
- * the the mapping between C++ and Python, thanks to the C++
- * templates.
+ * the mapping between C++ and Python, 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
diff --git a/Lib/python/pyrun.swg b/Lib/python/pyrun.swg
index d46628551..5043e6ec0 100644
--- a/Lib/python/pyrun.swg
+++ b/Lib/python/pyrun.swg
@@ -979,10 +979,13 @@ _SWIG_This(void)
return SWIG_Python_str_FromChar("this");
}
+static PyObject *swig_this = NULL;
+
SWIGRUNTIME PyObject *
SWIG_This(void)
{
- static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
+ if (swig_this == NULL)
+ swig_this = _SWIG_This();
return swig_this;
}
@@ -1413,6 +1416,7 @@ SWIG_Python_DestroyModule(void *vptr)
}
}
Py_DECREF(SWIG_This());
+ swig_this = NULL;
}
SWIGRUNTIME void
diff --git a/Lib/ruby/rubycontainer.swg b/Lib/ruby/rubycontainer.swg
index fa4b619f9..f643e84b3 100644
--- a/Lib/ruby/rubycontainer.swg
+++ b/Lib/ruby/rubycontainer.swg
@@ -4,8 +4,7 @@
* Ruby sequence <-> C++ container wrapper
*
* This wrapper, and its iterator, allows a general use (and reuse) of
- * the the mapping between C++ and Ruby, thanks to the C++
- * templates.
+ * the mapping between C++ and Ruby, 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
diff --git a/Lib/ruby/rubyerrors.swg b/Lib/ruby/rubyerrors.swg
index e2564980f..434544bc9 100644
--- a/Lib/ruby/rubyerrors.swg
+++ b/Lib/ruby/rubyerrors.swg
@@ -9,7 +9,7 @@
/* Define custom exceptions for errors that do not map to existing Ruby
exceptions. Note this only works for C++ since a global cannot be
- initialized by a funtion in C. For C, fallback to rb_eRuntimeError.*/
+ initialized by a function in C. For C, fallback to rb_eRuntimeError.*/
SWIGINTERN VALUE
getNullReferenceError(void) {
diff --git a/Lib/ruby/timeval.i b/Lib/ruby/timeval.i
index 91b56916f..e7bc2d322 100644
--- a/Lib/ruby/timeval.i
+++ b/Lib/ruby/timeval.i
@@ -58,6 +58,11 @@ struct timeval rb_time_timeval(VALUE);
$1 = NUM2LONG(rb_funcall($input, rb_intern("tv_sec"), 0));
}
+%typemap(typecheck) time_t
+{
+ $1 = (NIL_P($input) || TYPE(rb_funcall($input, rb_intern("respond_to?"), 1, ID2SYM(rb_intern("tv_sec")))) == T_TRUE);
+}
+
%typemap(out) time_t
{
$result = rb_time_new($1, 0);
diff --git a/Lib/std_except.i b/Lib/std_except.i
index 769a68995..a4a7a85ac 100644
--- a/Lib/std_except.i
+++ b/Lib/std_except.i
@@ -19,7 +19,7 @@
* a new std_except.i file in the target library directory.
* ----------------------------------------------------------------------------- */
-#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGUILE) || defined(SWIGUTL)
+#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGUILE) || defined(SWIGUTL) || defined(SWIGD)
#error "This version of std_except.i should not be used"
#endif
diff --git a/Lib/swig.swg b/Lib/swig.swg
index ec903533c..e7c01823e 100644
--- a/Lib/swig.swg
+++ b/Lib/swig.swg
@@ -77,7 +77,7 @@
#define %clearoldnodefault %feature("oldnodefault","")
/* the %exception directive */
-#ifdef SWIGCSHARP
+#if defined(SWIGCSHARP) || defined(SWIGD)
#define %exception %feature("except", canthrow=1)
#else
#define %exception %feature("except")
@@ -95,7 +95,7 @@
to set/get variable methods. You don't need to use the
%allowexception directive when using %exceptionvar.
*/
-#ifdef SWIGCSHARP
+#if defined(SWIGCSHARP) || defined(SWIGD)
#define %exceptionvar %feature("exceptvar", canthrow=1)
#else
#define %exceptionvar %feature("exceptvar")
@@ -269,7 +269,6 @@ static int NAME(TYPE x) {
%define %$isaccess "match"="access" %enddef
%define %$isclass "match"="class","notmatch$template$templatetype"="class" %enddef
%define %$isextend "match"="extend" %enddef
-%define %$isextend "match"="extend" %enddef
%define %$isconstructor "match"="constructor" %enddef
%define %$isdestructor "match"="destructor" %enddef
%define %$isnamespace "match"="namespace" %enddef
diff --git a/Lib/typemaps/strings.swg b/Lib/typemaps/strings.swg
index 7c5f59ae2..0769fe221 100644
--- a/Lib/typemaps/strings.swg
+++ b/Lib/typemaps/strings.swg
@@ -577,8 +577,6 @@ SWIG_AsVal_dec(Char)(SWIG_Object obj, Char *val)
}
}
-%typemaps_asvalfromn(CharCode, Char);
-
%_typemap_string(StringCode,
Char,
SWIG_AsCharPtrAndSize,
diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg
index f57766962..bd113e278 100644
--- a/Lib/typemaps/swigtype.swg
+++ b/Lib/typemaps/swigtype.swg
@@ -301,7 +301,7 @@
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE *const& {
void *vptr = 0;
- int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
+ int res = SWIG_ConvertPtr($input, &vptr, $*descriptor, 0);
$1 = SWIG_CheckState(res);
}
diff --git a/Makefile.in b/Makefile.in
index 472656629..475e3b218 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -76,6 +76,7 @@ skip-cffi = test -n "@SKIP_CFFI@"
skip-uffi = test -n "@SKIP_UFFI@"
skip-r = test -n "@SKIP_R@"
skip-go = test -n "@SKIP_GO@"
+skip-d = test -n "@SKIP_D@"
# Additional dependencies for some tests
skip-gcj = test -n "@SKIP_GCJ@"
@@ -112,6 +113,7 @@ check-aliveness:
@$(skip-lua) || ./$(TARGET) -lua -help
@$(skip-r) || ./$(TARGET) -r -help
@$(skip-go) || ./$(TARGET) -go -help
+ @$(skip-d) || ./$(TARGET) -d -help
check-ccache:
test -z "$(ENABLE_CCACHE)" || (cd $(CCACHE) && $(MAKE) check)
@@ -138,7 +140,8 @@ check-examples: \
check-uffi-examples \
check-cffi-examples \
check-r-examples \
- check-go-examples
+ check-go-examples \
+ check-d-examples
tcl_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/tcl/check.list)
perl5_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/perl5/check.list)
@@ -160,7 +163,8 @@ clisp_examples :=
uffi_examples :=
cffi_examples :=
r_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/r/check.list)
-go_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/go/check.list)
+go_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/go/check.list)
+d_examples :=$(shell sed '/^\#/d' $(srcdir)/Examples/d/check.list)
# all examples
check-%-examples :
@@ -170,6 +174,8 @@ check-%-examples :
fi
@if $(skip-$*); then \
echo skipping $* $(ACTION); \
+ elif test -z "$($(strip $*_examples))"; then \
+ echo empty $* $(ACTION); \
else \
$(MAKE) -k -s $($*_examples:=.actionexample) LANGUAGE=$* ACTION=$(ACTION); \
fi
@@ -211,7 +217,8 @@ check-test-suite: \
check-cffi-test-suite \
check-chicken-test-suite \
check-r-test-suite \
- check-go-test-suite
+ check-go-test-suite \
+ check-d-test-suite
check-%-test-suite:
@if test -z "$(skip-$*)"; then \
@@ -263,7 +270,8 @@ all-test-suite: \
all-cffi-test-suite \
all-chicken-test-suite \
all-r-test-suite \
- all-go-test-suite
+ all-go-test-suite \
+ all-d-test-suite
all-%-test-suite:
@$(MAKE) -k -s check-$*-test-suite ACTION=all
@@ -291,7 +299,8 @@ broken-test-suite: \
broken-cffi-test-suite \
broken-chicken-test-suite \
broken-r-test-suite \
- broken-go-test-suite
+ broken-go-test-suite \
+ broken-d-test-suite
broken-%-test-suite:
@$(MAKE) -k -s check-$*-test-suite ACTION=broken
@@ -408,7 +417,7 @@ install-main:
@$(INSTALL_PROGRAM) $(TARGET) $(DESTDIR)$(BIN_DIR)/`echo $(TARGET_NOEXE) | sed '$(transform)'`@EXEEXT@
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 fortran
+ pike chicken csharp modula3 allegrocl clisp lua cffi uffi r go d fortran
lib-modules = std
diff --git a/README b/README
index 3c6ee27a0..2eb8ae339 100644
--- a/README
+++ b/README
@@ -1,6 +1,6 @@
SWIG (Simplified Wrapper and Interface Generator)
-Version: 2.0.1 (in progress)
+Version: 2.0.2 (in progress)
Tagline: SWIG is a compiler that integrates C and C++ with languages
including Perl, Python, Tcl, Ruby, PHP, Java, Ocaml, Lua,
@@ -57,6 +57,9 @@ You must use GNU `make' to build SWIG.
http://www.gnu.org/software/make/
+PCRE needs to be installed on your system to build SWIG. The configure
+script will provide instructions for obtaining PCRE if it cannot be found.
+
To build and install SWIG, simply type the following:
% ./configure
@@ -85,6 +88,10 @@ uses. Don't panic if you get 'not found' messages--SWIG does not need these
packages to compile or run. The configure script is actually looking for
these packages so that you can try out the SWIG examples contained
in the 'Examples' directory without having to hack Makefiles.
+Note that the --without-xxx options, where xxx is a target language, have
+minimal effect. All they do is reduce the amount of testing done with
+'make check'. The SWIG executable and library files installed cannot currently
+be configured with a subset of target languages.
Please see the Documentation section below on installing documentation as
none is installed by default.
@@ -135,6 +142,8 @@ incorrectly configured. It may also fail due to compiler issues such
as broken C++ compiler. Even if 'make -k check' fails, there is a
pretty good chance SWIG still works correctly---you will just have to
mess around with one of the examples and some makefiles to get it to work.
+Some tests may also fail due to missing dependency packages, eg PCRE
+or Boost, but this will require careful analysis of the configure output.
The testing suite executed by 'make -k check' is designed to stress-test
many parts of the implementation including obscure corner cases. If some
@@ -142,8 +151,8 @@ of these tests fail or generate warning messages, there is no reason for
alarm---the test may be related to some new SWIG feature or a difficult bug
that we're trying to resolve. Chances are that SWIG will work just fine
for you. Note that if you have more than one CPU/core, then you can use
-parallel make can be used to speed up the check as it does take quite some
-time to run, for example:
+parallel make to speed up the check as it does take quite some time to run,
+for example:
% make -j2 -k check
diff --git a/RELEASENOTES b/RELEASENOTES
index 5f41df04f..829cd4d03 100644
--- a/RELEASENOTES
+++ b/RELEASENOTES
@@ -5,6 +5,15 @@ and CHANGES files.
Release Notes
=============
+SWIG-2.0.1 summary:
+- Support for the Go language has been added.
+- New regular expression (regex) encoder for renaming symbols based on
+ the Perl Compatible Regular Expressions (PCRE) library.
+- Numerous fixes in reporting file and line numbers in error and warning
+ messages.
+- Various bug fixes and improvements in the C#, Lua, Perl, PHP, Ruby
+ and Python language modules.
+
SWIG-2.0.0 summary:
- License changes, see LICENSE file and http://www.swig.org/legal.html.
- Much better nested class/struct support.
diff --git a/Source/CParse/cscanner.c b/Source/CParse/cscanner.c
index f88841c09..bf684c4cc 100644
--- a/Source/CParse/cscanner.c
+++ b/Source/CParse/cscanner.c
@@ -45,8 +45,6 @@ static int num_brace = 0;
static int last_brace = 0;
static int last_id = 0;
static int rename_active = 0;
-static int expanding_macro = 0;
-static int follow_locators = 0;
/* -----------------------------------------------------------------------------
* Swig_cparse_cplusplus()
@@ -56,101 +54,6 @@ void Swig_cparse_cplusplus(int v) {
cparse_cplusplus = v;
}
-/* ----------------------------------------------------------------------
- * locator()
- *
- * Support for locator strings. These are strings of the form
- * @SWIG:filename,line,id@ emitted by the SWIG preprocessor. They
- * are primarily used for macro line number reporting
- * ---------------------------------------------------------------------- */
-
-typedef struct Locator {
- String *filename;
- int line_number;
- struct Locator *next;
-} Locator;
-
-static Locator *locs = 0;
-
-/* we just use the locator to mark when active/deactive the linecounting */
-
-static void scanner_locator(String *loc) {
- if (!follow_locators) {
- if (Equal(loc, "/*@SWIG@*/")) {
- /* End locator. */
- if (expanding_macro)
- --expanding_macro;
- } else {
- /* Begin locator. */
- ++expanding_macro;
- }
- /* Freeze line number processing in Scanner */
- Scanner_freeze_line(scan,expanding_macro);
- } else {
- int c;
- Locator *l;
- Seek(loc, 7, SEEK_SET);
- c = Getc(loc);
- if (c == '@') {
- /* Empty locator. We pop the last location off */
- if (locs) {
- Scanner_set_location(scan,locs->filename,locs->line_number);
- cparse_file = locs->filename;
- cparse_line = locs->line_number;
- l = locs->next;
- free(locs);
- locs = l;
- }
- return;
- }
-
- /* We're going to push a new location */
- l = (Locator *) malloc(sizeof(Locator));
- l->filename = cparse_file;
- l->line_number = cparse_line;
- l->next = locs;
- locs = l;
-
- /* Now, parse the new location out of the locator string */
- {
- String *fn = NewStringEmpty();
- /* Putc(c, fn); */
-
- while ((c = Getc(loc)) != EOF) {
- if ((c == '@') || (c == ','))
- break;
- Putc(c, fn);
- }
- cparse_file = Swig_copy_string(Char(fn));
- Clear(fn);
- cparse_line = 1;
- /* Get the line number */
- while ((c = Getc(loc)) != EOF) {
- if ((c == '@') || (c == ','))
- break;
- Putc(c, fn);
- }
- cparse_line = atoi(Char(fn));
- Clear(fn);
-
- /* Get the rest of it */
- while ((c = Getc(loc)) != EOF) {
- if (c == '@')
- break;
- Putc(c, fn);
- }
- /* Swig_diagnostic(cparse_file, cparse_line, "Scanner_set_location\n"); */
- Scanner_set_location(scan,cparse_file,cparse_line);
- Delete(fn);
- }
- }
-}
-
-void Swig_cparse_follow_locators(int v) {
- follow_locators = v;
-}
-
-
/* ----------------------------------------------------------------------------
* scanner_init()
*
@@ -432,7 +335,7 @@ static int yylook(void) {
String *cmt = Scanner_text(scan);
char *loc = Char(cmt);
if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) {
- scanner_locator(cmt);
+ Scanner_locator(scan, cmt);
}
}
break;
@@ -791,7 +694,7 @@ int yylex(void) {
if (strcmp(yytext, "typename") == 0)
return (TYPENAME);
if (strcmp(yytext, "template") == 0) {
- yylval.ivalue = cparse_line;
+ yylval.intvalue = cparse_line;
return (TEMPLATE);
}
if (strcmp(yytext, "delete") == 0) {
@@ -833,7 +736,7 @@ int yylex(void) {
return (SIZEOF);
if (strcmp(yytext, "typedef") == 0) {
- yylval.ivalue = 0;
+ yylval.intvalue = 0;
return (TYPEDEF);
}
@@ -875,7 +778,7 @@ int yylex(void) {
if (strcmp(yytext, "%constant") == 0)
return (CONSTANT);
if (strcmp(yytext, "%typedef") == 0) {
- yylval.ivalue = 1;
+ yylval.intvalue = 1;
return (TYPEDEF);
}
if (strcmp(yytext, "%native") == 0)
diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y
index 6e41fa565..d792021c6 100644
--- a/Source/CParse/parser.y
+++ b/Source/CParse/parser.y
@@ -1628,7 +1628,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
String *str;
Parm *p;
ParmList *pl;
- int ivalue;
+ int intvalue;
Node *node;
};
@@ -1639,7 +1639,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%token <loc> INCLUDE IMPORT INSERT
%token <str> CHARCONST
%token <dtype> NUM_INT NUM_FLOAT NUM_UNSIGNED NUM_LONG NUM_ULONG NUM_LONGLONG NUM_ULONGLONG NUM_BOOL
-%token <ivalue> TYPEDEF
+%token <intvalue> TYPEDEF
%token <type> TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_WCHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW TYPE_NON_ISO_INT8 TYPE_NON_ISO_INT16 TYPE_NON_ISO_INT32 TYPE_NON_ISO_INT64
%token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD
%token CONST_QUAL VOLATILE REGISTER STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET
@@ -1657,7 +1657,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%token QUESTIONMARK
%token TYPES PARMS
%token NONID DSTAR DCNOT
-%token <ivalue> TEMPLATE
+%token <intvalue> TEMPLATE
%token <str> OPERATOR
%token <str> COPERATOR
%token PARSETYPE PARSEPARM PARSEPARMS
@@ -1728,7 +1728,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
%type <id> string stringnum ;
%type <tparms> template_parms;
%type <dtype> cpp_end cpp_vend;
-%type <ivalue> rename_namewarn;
+%type <intvalue> rename_namewarn;
%type <ptype> type_specifier primitive_type_list ;
%type <node> fname stringtype;
%type <node> featattr;
@@ -2121,7 +2121,7 @@ include_directive: includetype options string LBRACKET {
} interface RBRACKET {
String *mname = 0;
$$ = $6;
- scanner_set_location($1.filename,$1.line);
+ scanner_set_location($1.filename,$1.line+1);
if (strcmp($1.type,"include") == 0) set_nodeType($$,"include");
if (strcmp($1.type,"import") == 0) {
mname = $2 ? Getattr($2,"module") : 0;
@@ -2176,15 +2176,14 @@ inline_directive : INLINE HBLOCK {
String *cpps;
if (Namespaceprefix) {
Swig_error(cparse_file, cparse_start_line, "%%inline directive inside a namespace is disallowed.\n");
-
$$ = 0;
} else {
$$ = new_node("insert");
Setattr($$,"code",$2);
/* Need to run through the preprocessor */
+ Seek($2,0,SEEK_SET);
Setline($2,cparse_start_line);
Setfile($2,cparse_file);
- Seek($2,0,SEEK_SET);
cpps = Preprocessor_parse($2);
start_inline(Char(cpps), cparse_start_line);
Delete($2);
@@ -4541,7 +4540,8 @@ cpp_protection_decl : PUBLIC COLON {
------------------------------------------------------------ */
cpp_nested : storage_class cpptype idcolon inherit LBRACE {
- cparse_start_line = cparse_line; skip_balanced('{','}');
+ cparse_start_line = cparse_line;
+ skip_balanced('{','}');
$<str>$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */
} cpp_opt_declarators {
$$ = 0;
@@ -4566,7 +4566,8 @@ cpp_nested : storage_class cpptype idcolon inherit LBRACE {
------------------------------------------------------------ */
| storage_class cpptype inherit LBRACE {
- cparse_start_line = cparse_line; skip_balanced('{','}');
+ cparse_start_line = cparse_line;
+ skip_balanced('{','}');
$<str>$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */
} cpp_opt_declarators {
$$ = 0;
@@ -5884,28 +5885,34 @@ base_list : base_specifier {
}
;
-base_specifier : opt_virtual idcolon {
+base_specifier : opt_virtual {
+ $<intvalue>$ = cparse_line;
+ } idcolon {
$$ = NewHash();
Setfile($$,cparse_file);
- Setline($$,cparse_line);
- Setattr($$,"name",$2);
+ Setline($$,$<intvalue>2);
+ Setattr($$,"name",$3);
+ Setfile($3,cparse_file);
+ Setline($3,$<intvalue>2);
if (last_cpptype && (Strcmp(last_cpptype,"struct") != 0)) {
Setattr($$,"access","private");
- Swig_warning(WARN_PARSE_NO_ACCESS,cparse_file,cparse_line,
- "No access specifier given for base class %s (ignored).\n",$2);
+ Swig_warning(WARN_PARSE_NO_ACCESS, Getfile($$), Getline($$), "No access specifier given for base class '%s' (ignored).\n", SwigType_namestr($3));
} else {
Setattr($$,"access","public");
}
}
- | opt_virtual access_specifier opt_virtual idcolon {
+ | opt_virtual access_specifier {
+ $<intvalue>$ = cparse_line;
+ } opt_virtual idcolon {
$$ = NewHash();
Setfile($$,cparse_file);
- Setline($$,cparse_line);
- Setattr($$,"name",$4);
+ Setline($$,$<intvalue>3);
+ Setattr($$,"name",$5);
+ Setfile($5,cparse_file);
+ Setline($5,$<intvalue>3);
Setattr($$,"access",$2);
if (Strcmp($2,"public") != 0) {
- Swig_warning(WARN_PARSE_PRIVATE_INHERIT, cparse_file,
- cparse_line,"%s inheritance ignored.\n", $2);
+ Swig_warning(WARN_PARSE_PRIVATE_INHERIT, Getfile($$), Getline($$), "%s inheritance from base '%s' (ignored).\n", $2, SwigType_namestr($5));
}
}
;
diff --git a/Source/DOH/base.c b/Source/DOH/base.c
index 36ceb7ae3..cfbd2bdc4 100644
--- a/Source/DOH/base.c
+++ b/Source/DOH/base.c
@@ -645,7 +645,7 @@ int DohRead(DOH *obj, void *buffer, int length) {
* DohWrite()
* ----------------------------------------------------------------------------- */
-int DohWrite(DOH *obj, void *buffer, int length) {
+int DohWrite(DOH *obj, const void *buffer, int length) {
DohBase *b = (DohBase *) obj;
DohObjInfo *objinfo;
if (DohCheck(obj)) {
diff --git a/Source/DOH/doh.h b/Source/DOH/doh.h
index bd692596d..cfa6d79b2 100644
--- a/Source/DOH/doh.h
+++ b/Source/DOH/doh.h
@@ -222,7 +222,7 @@ extern int DohDelslice(DOH *obj, int sindex, int eindex);
/* File methods */
-extern int DohWrite(DOHFile * obj, void *buffer, int length);
+extern int DohWrite(DOHFile * obj, const void *buffer, int length);
extern int DohRead(DOHFile * obj, void *buffer, int length);
extern int DohSeek(DOHFile * obj, long offset, int whence);
extern long DohTell(DOHFile * obj);
@@ -268,6 +268,8 @@ extern int DohIsSequence(const DOH *obj);
extern int DohIsString(const DOH *obj);
extern int DohIsFile(const DOH *obj);
+extern void DohSetMaxHashExpand(int count);
+extern int DohGetMaxHashExpand(void);
extern void DohSetmark(DOH *obj, int x);
extern int DohGetmark(DOH *obj);
@@ -276,9 +278,9 @@ extern int DohGetmark(DOH *obj);
* ----------------------------------------------------------------------------- */
extern DOHString *DohNewStringEmpty(void);
-extern DOHString *DohNewString(const DOH *c);
-extern DOHString *DohNewStringWithSize(const DOH *c, int len);
-extern DOHString *DohNewStringf(const DOH *fmt, ...);
+extern DOHString *DohNewString(const DOHString_or_char *c);
+extern DOHString *DohNewStringWithSize(const DOHString_or_char *c, int len);
+extern DOHString *DohNewStringf(const DOHString_or_char *fmt, ...);
extern int DohStrcmp(const DOHString_or_char *s1, const DOHString_or_char *s2);
extern int DohStrncmp(const DOHString_or_char *s1, const DOHString_or_char *s2, int n);
@@ -427,6 +429,8 @@ extern void DohMemoryDebug(void);
#define SplitLines DohSplitLines
#define Setmark DohSetmark
#define Getmark DohGetmark
+#define SetMaxHashExpand DohSetMaxHashExpand
+#define GetMaxHashExpand DohGetMaxHashExpand
#define None DohNone
#define Call DohCall
#define First DohFirst
diff --git a/Source/DOH/dohint.h b/Source/DOH/dohint.h
index 661bed075..9f5c06272 100644
--- a/Source/DOH/dohint.h
+++ b/Source/DOH/dohint.h
@@ -43,7 +43,7 @@ typedef struct {
/* File methods */
typedef struct {
int (*doh_read) (DOH *obj, void *buffer, int nbytes); /* Read bytes */
- int (*doh_write) (DOH *obj, void *buffer, int nbytes); /* Write bytes */
+ int (*doh_write) (DOH *obj, const void *buffer, int nbytes); /* Write bytes */
int (*doh_putc) (DOH *obj, int ch); /* Put character */
int (*doh_getc) (DOH *obj); /* Get character */
int (*doh_ungetc) (DOH *obj, int ch); /* Unget character */
@@ -54,7 +54,7 @@ typedef struct {
/* String methods */
typedef struct {
- int (*doh_replace) (DOH *obj, DOH *old, DOH *rep, int flags);
+ int (*doh_replace) (DOH *obj, const DOHString_or_char *old, const DOHString_or_char *rep, int flags);
void (*doh_chop) (DOH *obj);
} DohStringMethods;
diff --git a/Source/DOH/file.c b/Source/DOH/file.c
index a9ee332bf..11482fa7f 100644
--- a/Source/DOH/file.c
+++ b/Source/DOH/file.c
@@ -67,7 +67,7 @@ static int File_read(DOH *fo, void *buffer, int len) {
* File_write()
* ----------------------------------------------------------------------------- */
-static int File_write(DOH *fo, void *buffer, int len) {
+static int File_write(DOH *fo, const void *buffer, int len) {
DohFile *f = (DohFile *) ObjData(fo);
if (f->filep) {
int ret = (int) fwrite(buffer, 1, len, f->filep);
diff --git a/Source/DOH/hash.c b/Source/DOH/hash.c
index 87f8e3c40..241383327 100644
--- a/Source/DOH/hash.c
+++ b/Source/DOH/hash.c
@@ -42,6 +42,7 @@ typedef struct KeyValue {
} KeyValue;
static KeyValue *root = 0;
+static int max_expand = 1;
/* Find or create a key in the interned key table */
static DOH *find_key(DOH *doh_c) {
@@ -362,7 +363,7 @@ static DohIterator Hash_nextiter(DohIterator iter) {
}
/* -----------------------------------------------------------------------------
- * Hash_keys(DOH *)
+ * Hash_keys()
*
* Return a list of keys
* ----------------------------------------------------------------------------- */
@@ -379,6 +380,26 @@ static DOH *Hash_keys(DOH *so) {
}
/* -----------------------------------------------------------------------------
+ * DohSetMaxHashExpand()
+ *
+ * Controls how many Hash objects are displayed in full in Hash_str
+ * ----------------------------------------------------------------------------- */
+
+void DohSetMaxHashExpand(int count) {
+ max_expand = count;
+}
+
+/* -----------------------------------------------------------------------------
+ * DohGetMaxHashExpand()
+ *
+ * Returns how many Hash objects are displayed in full in Hash_str
+ * ----------------------------------------------------------------------------- */
+
+int DohGetMaxHashExpand(void) {
+ return max_expand;
+}
+
+/* -----------------------------------------------------------------------------
* Hash_str()
*
* Create a string representation of a hash table (mainly for debugging).
@@ -388,7 +409,8 @@ static DOH *Hash_str(DOH *ho) {
int i, j;
HashNode *n;
DOH *s;
- static int indent = 4;
+ static int expanded = 0;
+ static const char *tab = " ";
Hash *h = (Hash *) ObjData(ho);
s = NewStringEmpty();
@@ -396,22 +418,35 @@ static DOH *Hash_str(DOH *ho) {
Printf(s, "Hash(0x%x)", ho);
return s;
}
+ if (expanded >= max_expand) {
+ /* replace each hash attribute with a '.' */
+ Printf(s, "Hash(0x%x) {", ho);
+ for (i = 0; i < h->hashsize; i++) {
+ n = h->hashtable[i];
+ while (n) {
+ Putc('.', s);
+ n = n->next;
+ }
+ }
+ Putc('}', s);
+ return s;
+ }
ObjSetMark(ho, 1);
- Printf(s, "Hash {\n");
+ Printf(s, "Hash(0x%x) {\n", ho);
for (i = 0; i < h->hashsize; i++) {
n = h->hashtable[i];
while (n) {
- for (j = 0; j < indent; j++)
- Putc(' ', s);
- indent += 4;
+ for (j = 0; j < expanded + 1; j++)
+ Printf(s, tab);
+ expanded += 1;
Printf(s, "'%s' : %s, \n", n->key, n->object);
- indent -= 4;
+ expanded -= 1;
n = n->next;
}
}
- for (j = 0; j < (indent - 4); j++)
- Putc(' ', s);
- Printf(s, "}\n");
+ for (j = 0; j < expanded; j++)
+ Printf(s, tab);
+ Printf(s, "}");
ObjSetMark(ho, 0);
return s;
}
diff --git a/Source/DOH/list.c b/Source/DOH/list.c
index a08cadb5a..d5b532409 100644
--- a/Source/DOH/list.c
+++ b/Source/DOH/list.c
@@ -252,7 +252,7 @@ static DOH *List_str(DOH *lo) {
if ((i + 1) < l->nitems)
Printf(s, ", ");
}
- Printf(s, " ]\n");
+ Printf(s, " ]");
ObjSetMark(lo, 0);
return s;
}
diff --git a/Source/DOH/string.c b/Source/DOH/string.c
index 276ae6b96..ac770cea2 100644
--- a/Source/DOH/string.c
+++ b/Source/DOH/string.c
@@ -29,7 +29,7 @@ typedef struct String {
} String;
/* -----------------------------------------------------------------------------
- * void *String_data() - Return as a 'void *'
+ * String_data() - Return as a 'void *'
* ----------------------------------------------------------------------------- */
static void *String_data(DOH *so) {
@@ -44,7 +44,7 @@ static void *String_data(DOH *so) {
*/
/* -----------------------------------------------------------------------------
- * int String_dump() - Serialize a string onto out
+ * String_dump() - Serialize a string onto out
* ----------------------------------------------------------------------------- */
static int String_dump(DOH *so, DOH *out) {
@@ -105,7 +105,7 @@ static int String_len(DOH *so) {
/* -----------------------------------------------------------------------------
- * int String_cmp() - Compare two strings
+ * String_cmp() - Compare two strings
* ----------------------------------------------------------------------------- */
static int String_cmp(DOH *so1, DOH *so2) {
@@ -137,7 +137,7 @@ static int String_cmp(DOH *so1, DOH *so2) {
}
/* -----------------------------------------------------------------------------
- * int String_equal() - Say if two string are equal
+ * String_equal() - Say if two string are equal
* ----------------------------------------------------------------------------- */
static int String_equal(DOH *so1, DOH *so2) {
@@ -174,7 +174,7 @@ static int String_equal(DOH *so1, DOH *so2) {
}
/* -----------------------------------------------------------------------------
- * int String_hash() - Compute string hash value
+ * String_hash() - Compute string hash value
* ----------------------------------------------------------------------------- */
static int String_hash(DOH *so) {
@@ -203,10 +203,10 @@ static int String_hash(DOH *so) {
}
/* -----------------------------------------------------------------------------
- * DohString_append(String *s, const char *newstr) - Append to s
+ * DohString_append() - Append to s
* ----------------------------------------------------------------------------- */
-void DohString_append(DOH *so, DOH *str) {
+static void DohString_append(DOH *so, const DOHString_or_char *str) {
int oldlen, newlen, newmaxsize, l, sp;
char *tc;
String *s = (String *) ObjData(so);
@@ -251,7 +251,7 @@ void DohString_append(DOH *so, DOH *str) {
/* -----------------------------------------------------------------------------
- * void String_clear() - Clear a string
+ * String_clear() - Clear a string
* ----------------------------------------------------------------------------- */
static void String_clear(DOH *so) {
@@ -264,7 +264,7 @@ static void String_clear(DOH *so) {
}
/* -----------------------------------------------------------------------------
- * void String_insert() - Insert a string
+ * String_insert() - Insert a string
* ----------------------------------------------------------------------------- */
static int String_insert(DOH *so, int pos, DOH *str) {
@@ -320,7 +320,7 @@ static int String_insert(DOH *so, int pos, DOH *str) {
}
/* -----------------------------------------------------------------------------
- * int String_delitem() - Delete a character
+ * String_delitem() - Delete a character
* ----------------------------------------------------------------------------- */
static int String_delitem(DOH *so, int pos) {
@@ -346,7 +346,7 @@ static int String_delitem(DOH *so, int pos) {
}
/* -----------------------------------------------------------------------------
- * int String_delslice() - Delete a range
+ * String_delslice() - Delete a range
* ----------------------------------------------------------------------------- */
static int String_delslice(DOH *so, int sindex, int eindex) {
@@ -384,7 +384,7 @@ static int String_delslice(DOH *so, int sindex, int eindex) {
}
/* -----------------------------------------------------------------------------
- * DOH *String_str() - Returns a string (used by printing commands)
+ * String_str() - Returns a string (used by printing commands)
* ----------------------------------------------------------------------------- */
static DOH *String_str(DOH *so) {
@@ -394,7 +394,7 @@ static DOH *String_str(DOH *so) {
}
/* -----------------------------------------------------------------------------
- * int String_read() - Read data from a string
+ * String_read() - Read data from a string
* ----------------------------------------------------------------------------- */
static int String_read(DOH *so, void *buffer, int len) {
@@ -417,9 +417,9 @@ static int String_read(DOH *so, void *buffer, int len) {
}
/* -----------------------------------------------------------------------------
- * int String_write() - Write data to a string
+ * String_write() - Write data to a string
* ----------------------------------------------------------------------------- */
-static int String_write(DOH *so, void *buffer, int len) {
+static int String_write(DOH *so, const void *buffer, int len) {
int newlen;
String *s = (String *) ObjData(so);
s->hashkey = -1;
@@ -441,7 +441,7 @@ static int String_write(DOH *so, void *buffer, int len) {
}
/* -----------------------------------------------------------------------------
- * int String_seek() - Seek to a new position
+ * String_seek() - Seek to a new position
* ----------------------------------------------------------------------------- */
static int String_seek(DOH *so, long offset, int whence) {
@@ -498,7 +498,7 @@ static int String_seek(DOH *so, long offset, int whence) {
}
/* -----------------------------------------------------------------------------
- * long String_tell() - Return current position
+ * String_tell() - Return current position
* ----------------------------------------------------------------------------- */
static long String_tell(DOH *so) {
@@ -507,7 +507,7 @@ static long String_tell(DOH *so) {
}
/* -----------------------------------------------------------------------------
- * int String_putc()
+ * String_putc()
* ----------------------------------------------------------------------------- */
static int String_putc(DOH *so, int ch) {
@@ -538,7 +538,7 @@ static int String_putc(DOH *so, int ch) {
}
/* -----------------------------------------------------------------------------
- * int String_getc()
+ * String_getc()
* ----------------------------------------------------------------------------- */
static int String_getc(DOH *so) {
@@ -554,7 +554,7 @@ static int String_getc(DOH *so) {
}
/* -----------------------------------------------------------------------------
- * int String_ungetc()
+ * String_ungetc()
* ----------------------------------------------------------------------------- */
static int String_ungetc(DOH *so, int ch) {
@@ -569,12 +569,6 @@ static int String_ungetc(DOH *so, int ch) {
return ch;
}
-/* -----------------------------------------------------------------------------
- * replace_simple(String *str, char *token, char *rep, int flags, int count)
- *
- * Replaces count non-overlapping occurrences of token with rep in a string.
- * ----------------------------------------------------------------------------- */
-
static char *end_quote(char *s) {
char *qs;
char qc;
@@ -659,6 +653,12 @@ static char *match_identifier_end(char *base, char *s, char *token, int tokenlen
return 0;
}
+/* -----------------------------------------------------------------------------
+ * replace_simple()
+ *
+ * Replaces count non-overlapping occurrences of token with rep in a string.
+ * ----------------------------------------------------------------------------- */
+
static int replace_simple(String *str, char *token, char *rep, int flags, int count, char *(*match) (char *, char *, char *, int)) {
int tokenlen; /* Length of the token */
int replen; /* Length of the replacement */
@@ -885,10 +885,10 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co
}
/* -----------------------------------------------------------------------------
- * int String_replace()
+ * String_replace()
* ----------------------------------------------------------------------------- */
-static int String_replace(DOH *stro, DOH *token, DOH *rep, int flags) {
+static int String_replace(DOH *stro, const DOHString_or_char *token, const DOHString_or_char *rep, int flags) {
int count = -1;
String *str = (String *) ObjData(stro);
@@ -907,7 +907,7 @@ static int String_replace(DOH *stro, DOH *token, DOH *rep, int flags) {
}
/* -----------------------------------------------------------------------------
- * void String_chop(DOH *str)
+ * String_chop()
* ----------------------------------------------------------------------------- */
static void String_chop(DOH *so) {
@@ -1012,10 +1012,10 @@ DohObjInfo DohStringType = {
#define INIT_MAXSIZE 16
/* -----------------------------------------------------------------------------
- * NewString(const char *c) - Create a new string
+ * NewString() - Create a new string
* ----------------------------------------------------------------------------- */
-DOHString *DohNewString(const DOH *so) {
+DOHString *DohNewString(const DOHString_or_char *so) {
int l = 0, max;
String *str;
char *s;
@@ -1073,10 +1073,10 @@ DOHString *DohNewStringEmpty(void) {
}
/* -----------------------------------------------------------------------------
- * NewStringWithSize(const char *c, int len) - Create a new string
+ * NewStringWithSize() - Create a new string
* ----------------------------------------------------------------------------- */
-DOHString *DohNewStringWithSize(const DOH *so, int len) {
+DOHString *DohNewStringWithSize(const DOHString_or_char *so, int len) {
int l = 0, max;
String *str;
char *s;
@@ -1111,12 +1111,12 @@ DOHString *DohNewStringWithSize(const DOH *so, int len) {
}
/* -----------------------------------------------------------------------------
- * NewStringf(DOH *fmt, ...)
+ * NewStringf()
*
* Create a new string from a list of objects.
* ----------------------------------------------------------------------------- */
-DOHString *DohNewStringf(const DOH *fmt, ...) {
+DOHString *DohNewStringf(const DOHString_or_char *fmt, ...) {
va_list ap;
DOH *r;
va_start(ap, fmt);
diff --git a/Source/Include/swigwarn.h b/Source/Include/swigwarn.h
index 46f5b79a5..9c5c3be74 100644
--- a/Source/Include/swigwarn.h
+++ b/Source/Include/swigwarn.h
@@ -1,5 +1,5 @@
-/* -----------------------------------------------------------------------------
- * This file is part of SWIG, which is licensed as a whole under version 3
+/* -----------------------------------------------------------------------------
+ * 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
@@ -193,14 +193,37 @@
#define WARN_LANG_DIRECTOR_ABSTRACT 517
#define WARN_LANG_PORTABILITY_FILENAME 518
#define WARN_LANG_TEMPLATE_METHOD_IGNORE 519
+#define WARN_LANG_SMARTPTR_MISSING 520
/* -- Reserved (600-799) -- */
-/* -- Language module specific warnings (800 - 999) -- */
+/* -- Language module specific warnings (700 - 899) -- */
+
+/* Feel free to claim any number in this space that's not currently being used. Just make sure you
+ add an entry here */
+
+#define WARN_D_TYPEMAP_CTYPE_UNDEF 700
+#define WARN_D_TYPEMAP_IMTYPE_UNDEF 701
+#define WARN_D_TYPEMAP_DTYPE_UNDEF 702
+#define WARN_D_MULTIPLE_INHERITANCE 703
+#define WARN_D_TYPEMAP_CLASSMOD_UNDEF 704
+#define WARN_D_TYPEMAP_DBODY_UNDEF 705
+#define WARN_D_TYPEMAP_DOUT_UNDEF 706
+#define WARN_D_TYPEMAP_DIN_UNDEF 707
+#define WARN_D_TYPEMAP_DDIRECTORIN_UNDEF 708
+#define WARN_D_TYPEMAP_DCONSTRUCTOR_UNDEF 709
+#define WARN_D_EXCODE_MISSING 710
+#define WARN_D_CANTHROW_MISSING 711
+#define WARN_D_NO_DIRECTORCONNECT_ATTR 712
+#define WARN_D_NAME_COLLISION 713
+
+/* please leave 700-719 free for D */
#define WARN_RUBY_WRONG_NAME 801
#define WARN_RUBY_MULTIPLE_INHERITANCE 802
+/* please leave 800-809 free for Ruby */
+
#define WARN_JAVA_TYPEMAP_JNI_UNDEF 810
#define WARN_JAVA_TYPEMAP_JTYPE_UNDEF 811
#define WARN_JAVA_TYPEMAP_JSTYPE_UNDEF 812
@@ -262,7 +285,6 @@
/* please leave 890-899 free for Go */
-/* Feel free to claim any number in this space that's not currently being used. Just make sure you
- add an entry here */
+/* -- User defined warnings (900 - 999) -- */
#endif
diff --git a/Source/Makefile.am b/Source/Makefile.am
index b880a9543..0313dcade 100644
--- a/Source/Makefile.am
+++ b/Source/Makefile.am
@@ -42,6 +42,7 @@ eswig_SOURCES = CParse/cscanner.c \
Modules/clisp.cxx \
Modules/contract.cxx \
Modules/csharp.cxx \
+ Modules/d.cxx \
Modules/directors.cxx \
Modules/emit.cxx \
Modules/fortran.cxx \
diff --git a/Source/Modules/allocate.cxx b/Source/Modules/allocate.cxx
index 2e05fd190..110a92939 100644
--- a/Source/Modules/allocate.cxx
+++ b/Source/Modules/allocate.cxx
@@ -216,7 +216,7 @@ class Allocate:public Dispatcher {
if (!most_base_covariant_type) {
// Eliminate the derived virtual method.
- if (virtual_elimination_mode)
+ if (virtual_elimination_mode && !is_member_director(n))
if (both_have_public_access)
if (!is_non_public_base(inclass, b))
if (!Swig_symbol_isoverloaded(n)) {
@@ -824,9 +824,12 @@ Allocate():
int isconst = 0;
Delete(SwigType_pop(type));
if (SwigType_isconst(type)) {
- isconst = 1;
+ isconst = !Getattr(inclass, "allocate:smartpointermutable");
Setattr(inclass, "allocate:smartpointerconst", "1");
}
+ else {
+ Setattr(inclass, "allocate:smartpointermutable", "1");
+ }
List *methods = smart_pointer_methods(sc, 0, isconst);
Setattr(inclass, "allocate:smartpointer", methods);
Setattr(inclass, "allocate:smartpointerbase", base);
@@ -834,7 +837,6 @@ Allocate():
/* Hmmm. The return value is not a pointer. If the type is a value
or reference. We're going to chase it to see if another operator->()
can be found */
-
if ((SwigType_check_decl(type, "")) || (SwigType_check_decl(type, "r."))) {
Node *nn = Swig_symbol_clookup((char *) "operator ->", Getattr(sc, "symtab"));
if (nn) {
diff --git a/Source/Modules/clisp.cxx b/Source/Modules/clisp.cxx
index b1a6f5610..d26df36c2 100644
--- a/Source/Modules/clisp.cxx
+++ b/Source/Modules/clisp.cxx
@@ -293,16 +293,18 @@ int CLISP::classDeclaration(Node *n) {
}
String *temp = Copy(Getattr(c, "decl"));
- Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
- String *lisp_type = get_ffi_type(n, temp);
- Delete(temp);
+ if (temp) {
+ Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
+ String *lisp_type = get_ffi_type(n, temp);
+ Delete(temp);
- String *slot_name = Getattr(c, "sym:name");
- Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type);
+ String *slot_name = Getattr(c, "sym:name");
+ Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type);
- Append(entries, NewStringf("%s-%s", name, slot_name));
+ Append(entries, NewStringf("%s-%s", name, slot_name));
- Delete(lisp_type);
+ Delete(lisp_type);
+ }
}
Printf(f_cl, ")\n");
diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx
index 8ffd9768a..1444dbd87 100644
--- a/Source/Modules/csharp.cxx
+++ b/Source/Modules/csharp.cxx
@@ -1640,10 +1640,10 @@ public:
base = Next(base);
continue;
}
- String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
- String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0);
- Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, input_file, line_number,
- "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#.\n", proxyclassname, baseclassname);
+ String *proxyclassname = Getattr(n, "classtypeobj");
+ String *baseclassname = Getattr(base.item, "name");
+ Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
+ "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
base = Next(base);
}
}
@@ -1661,9 +1661,9 @@ public:
Delete(baseclass);
baseclass = NULL;
if (purebase_notderived)
- Swig_error(input_file, line_number, "The csbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
+ Swig_error(Getfile(n), Getline(n), "The csbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
} else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) {
- Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, input_file, line_number,
+ Swig_warning(WARN_CSHARP_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in C#. "
"Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
}
@@ -1704,10 +1704,10 @@ public:
}
if (tm && *Char(tm)) {
if (!destruct_methodname) {
- Swig_error(input_file, line_number, "No methodname attribute defined in csdestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
+ Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in csdestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
}
if (!destruct_methodmodifiers) {
- Swig_error(input_file, line_number,
+ Swig_error(Getfile(n), Getline(n),
"No methodmodifiers attribute defined in csdestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name);
}
}
@@ -2292,17 +2292,24 @@ public:
String *ex_imcall = Copy(imcall);
Replaceall(ex_imcall, "$imfuncname", ex_intermediary_function_name);
Replaceall(imcall, "$imfuncname", intermediary_function_name);
-
String *excode = NewString("");
- if (!Cmp(return_type, "void"))
- Printf(excode, "if (this.GetType() == typeof(%s)) %s; else %s", proxy_class_name, imcall, ex_imcall);
- else
- Printf(excode, "((this.GetType() == typeof(%s)) ? %s : %s)", proxy_class_name, imcall, ex_imcall);
+ Node *directorNode = Getattr(n, "directorNode");
+ if (directorNode) {
+ UpcallData *udata = Getattr(directorNode, "upcalldata");
+ String *methid = Getattr(udata, "class_methodidx");
- Clear(imcall);
- Printv(imcall, excode, NIL);
- Delete(ex_overloaded_name);
+ if (!Cmp(return_type, "void"))
+ Printf(excode, "if (SwigDerivedClassHasMethod(\"%s\", swigMethodTypes%s)) %s; else %s", proxy_function_name, methid, ex_imcall, imcall);
+ else
+ Printf(excode, "(SwigDerivedClassHasMethod(\"%s\", swigMethodTypes%s) ? %s : %s)", proxy_function_name, methid, ex_imcall, imcall);
+
+ Clear(imcall);
+ Printv(imcall, excode, NIL);
+ } else {
+ // probably an ignored method or nodirector
+ }
Delete(excode);
+ Delete(ex_overloaded_name);
} else {
Replaceall(imcall, "$imfuncname", intermediary_function_name);
}
@@ -2343,6 +2350,7 @@ public:
SwigType *pt = Getattr(p, "type");
if ((tm = Getattr(p, "tmap:csvarin"))) {
substituteClassname(pt, tm);
+ Replaceall(tm, "$csinput", "value");
Replaceall(tm, "$imcall", imcall);
excodeSubstitute(n, tm, "csvarin", p);
Printf(proxy_class_code, "%s", tm);
@@ -3472,7 +3480,6 @@ public:
String *callback_def = NewString("");
String *callback_code = NewString("");
String *imcall_args = NewString("");
- int gencomma = 0;
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
// Kludge Alert: functionWrapper sets sym:overload properly, but it
@@ -3616,14 +3623,14 @@ public:
Printf(w->code, "} else {\n");
/* Go through argument list, convert from native to Java */
- for (p = l; p; /* empty */ ) {
+ for (i = 0, p = l; p; ++i) {
/* Is this superfluous? */
while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
p = Getattr(p, "tmap:directorin:next");
}
SwigType *pt = Getattr(p, "type");
- String *ln = Copy(Getattr(p, "name"));
+ String *ln = makeParameterName(n, p, i, false);
String *c_param_type = NULL;
String *c_decl = NewString("");
String *arg = NewString("");
@@ -3631,7 +3638,7 @@ public:
Printf(arg, "j%s", ln);
/* And add to the upcall args */
- if (gencomma > 0)
+ if (i > 0)
Printf(jupcall_args, ", ");
Printf(jupcall_args, "%s", arg);
@@ -3641,17 +3648,13 @@ public:
if (ctypeout)
c_param_type = ctypeout;
- Parm *tp = NewParm(c_param_type, empty_str, n);
- String *desc_tm = NULL;
-
/* Add to local variables */
Printf(c_decl, "%s %s", c_param_type, arg);
if (!ignored_method)
Wrapper_add_localv(w, arg, c_decl, (!(SwigType_ispointer(pt) || SwigType_isreference(pt)) ? "" : "= 0"), NIL);
/* Add input marshalling code */
- if ((desc_tm = Swig_typemap_lookup("directorin", tp, "", 0))
- && (tm = Getattr(p, "tmap:directorin"))) {
+ if ((tm = Getattr(p, "tmap:directorin"))) {
Replaceall(tm, "$input", arg);
Replaceall(tm, "$owner", "0");
@@ -3663,7 +3666,7 @@ public:
Delete(tm);
/* Add C type to callback typedef */
- if (gencomma > 0)
+ if (i > 0)
Printf(callback_typedef_parms, ", ");
Printf(callback_typedef_parms, "%s", c_param_type);
@@ -3684,7 +3687,7 @@ public:
substituteClassname(pt, din);
Replaceall(din, "$iminput", ln);
- if (gencomma > 0) {
+ if (i > 0) {
Printf(delegate_parms, ", ");
Printf(proxy_method_types, ", ");
Printf(imcall_args, ", ");
@@ -3716,24 +3719,13 @@ public:
p = Getattr(p, "tmap:directorin:next");
- Delete(desc_tm);
} else {
- if (!desc_tm) {
- Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number,
- "No or improper directorin typemap defined for %s for use in %s::%s (skipping director method)\n",
- SwigType_str(c_param_type, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
- p = nextSibling(p);
- } else if (!tm) {
- Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number,
- "No or improper directorin typemap defined for argument %s for use in %s::%s (skipping director method)\n",
- SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
- p = nextSibling(p);
- }
-
+ Swig_warning(WARN_CSHARP_TYPEMAP_CSDIRECTORIN_UNDEF, input_file, line_number,
+ "No or improper directorin typemap defined for argument %s for use in %s::%s (skipping director method)\n",
+ SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
+ p = nextSibling(p);
output_director = false;
}
-
- Delete(tp);
} else {
Swig_warning(WARN_CSHARP_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s for use in %s::%s (skipping director method)\n",
SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
@@ -3741,7 +3733,7 @@ public:
p = nextSibling(p);
}
- gencomma++;
+ Delete(ln);
Delete(arg);
Delete(c_decl);
Delete(c_param_type);
@@ -3884,6 +3876,10 @@ public:
/* Emit the actual upcall through */
UpcallData *udata = addUpcallMethod(imclass_dmethod, symname, decl, overloaded_name);
String *methid = Getattr(udata, "class_methodidx");
+ Setattr(n, "upcalldata", udata);
+ /*
+ Printf(stdout, "setting upcalldata, nodeType: %s %s::%s %p\n", nodeType(n), classname, Getattr(n, "name"), n);
+ */
Printf(director_callback_typedefs, " typedef %s (SWIGSTDCALL* SWIG_Callback%s_t)(", c_ret_type, methid);
Printf(director_callback_typedefs, "%s);\n", callback_typedef_parms);
diff --git a/Source/Modules/d.cxx b/Source/Modules/d.cxx
new file mode 100644
index 000000000..cc1bd2365
--- /dev/null
+++ b/Source/Modules/d.cxx
@@ -0,0 +1,4351 @@
+/* -----------------------------------------------------------------------------
+ * 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.
+ *
+ * d.cxx
+ *
+ * D language module for SWIG.
+ * ----------------------------------------------------------------------------- */
+
+char cvsroot_d_cxx[] = "$Id$";
+
+#include "swigmod.h"
+#include "cparse.h"
+#include <ctype.h>
+
+// Hash type used for storing information about director callbacks for a class.
+typedef DOH UpcallData;
+
+class D : public Language {
+ static const char *usage;
+ const String *empty_string;
+ const String *public_string;
+ const String *protected_string;
+ const String *static_string;
+
+ /*
+ * Files and file sections containing C/C++ code.
+ */
+ File *f_begin;
+ File *f_runtime;
+ File *f_runtime_h;
+ File *f_header;
+ File *f_wrappers;
+ File *f_init;
+ File *f_directors;
+ File *f_directors_h;
+ List *filenames_list;
+
+ /*
+ * Command line-set modes of operation.
+ */
+ // Whether a single proxy D module is generated or classes and enums are
+ // written to their own files.
+ bool split_proxy_dmodule;
+
+ // The major D version targeted (currently 1 or 2).
+ unsigned short d_version;
+
+ /*
+ * State variables which indicate what is being wrapped at the moment.
+ * This is probably not the most elegant way of handling state, but it has
+ * proven to work in the C# and Java modules.
+ */
+ // Indicates if wrapping a native function.
+ bool native_function_flag;
+
+ // Indicates if wrapping a static functions or member variables
+ bool static_flag;
+
+ // Indicates if wrapping a nonstatic member variable
+ bool variable_wrapper_flag;
+
+ // Indicates if wrapping a member variable/enum/const.
+ bool wrapping_member_flag;
+
+ // Indicates if wrapping a global variable.
+ bool global_variable_flag;
+
+ // Name of a variable being wrapped.
+ String *variable_name;
+
+ /*
+ * Variables temporarily holding the generated C++ code.
+ */
+ // C++ code for the generated wrapper functions for casts up the C++
+ // for inheritance hierarchies.
+ String *upcasts_code;
+
+ // Function pointer typedefs for handling director callbacks on the C++ side.
+ String *director_callback_typedefs;
+
+ // Variables for storing the function pointers to the director callbacks on
+ // the C++ side.
+ String *director_callback_pointers;
+
+ /*
+ * Names of generated D entities.
+ */
+ // The name of the D module containing the interface to the C wrapper.
+ String *im_dmodule_name;
+
+ // The fully qualified name of the wrap D module (package name included).
+ String *im_dmodule_fq_name;
+
+ // The name of the proxy module which exposes the (SWIG) module contents as a
+ // D module.
+ String *proxy_dmodule_name;
+
+ // The fully qualified name of the proxy D module.
+ String *proxy_dmodule_fq_name;
+
+ // Optional: Package the D modules are placed in (set via the -package
+ // command line option).
+ String *package;
+
+ // The directory the generated D module files are written to. Is constructed
+ // from the package path if a target package is set, points to the general
+ // output directory otherwise.
+ String *dmodule_directory;
+
+ // The name of the library which contains the C wrapper (used when generating
+ // the dynamic library loader). Can be overridden via the -wrapperlibrary
+ // command line flag.
+ String *wrap_library_name;
+
+ /*
+ * Variables temporarily holding the generated D code.
+ */
+ // Import statements written to the intermediary D module header set via
+ // %pragma(d) imdmoduleimports.
+ String *im_dmodule_imports;
+
+ // The code for the intermediary D module body.
+ String *im_dmodule_code;
+
+ // Import statements for all proxy modules (the main proxy module and, if in
+ // split proxy module mode, the proxy class modules) from
+ // %pragma(d) globalproxyimports.
+ String *global_proxy_imports;
+
+ // Imports written to the proxy D module header from global_proxy_imports
+ // and, if in split proxy module mode, from D::requireDType().
+ String *proxy_dmodule_imports;
+
+ // The D code for proxy functions/classes which is written to the proxy D
+ // module. If not in split proxy mode, this contains the whole proxy code.
+ String *proxy_dmodule_code;
+
+ // The D code generated for the currently processed enum.
+ String *proxy_enum_code;
+
+ /*
+ * D data for the current proxy class.
+ */
+ // The name of the current proxy class.
+ String *proxy_class_name;
+
+ // The import directives for the current proxy class. They are written to the
+ // same D module the proxy class is written to.
+ String *proxy_class_imports;
+
+ // Code for enumerations nested in the current proxy class. Is emitted earlier
+ // than the rest of the body to work around forward referencing-issues.
+ String *proxy_class_enums_code;
+
+ // The generated D code making up the body of the current proxy class.
+ String *proxy_class_body_code;
+
+ // D code which is emitted right after the proxy class.
+ String *proxy_class_epilogue_code;
+
+ // The full code for the current proxy class, including the epilogue.
+ String* proxy_class_code;
+
+ // Contains a D call to the function wrapping C++ the destructor of the
+ // current class (if there is a public C++ destructor).
+ String *destructor_call;
+
+ // D code for the director callbacks generated for the current class.
+ String *director_dcallbacks_code;
+
+ /*
+ * Code for dynamically loading the wrapper library on the D side.
+ */
+ // D code which is inserted into the im D module if dynamic linking is used.
+ String *wrapper_loader_code;
+
+ // The D code to bind a function pointer to a library symbol.
+ String *wrapper_loader_bind_command;
+
+ // The cumulated binding commands binding all the functions declared in the
+ // intermediary D module to the C/C++ library symbols.
+ String *wrapper_loader_bind_code;
+
+ /*
+ * Director data.
+ */
+ List *dmethods_seq;
+ Hash *dmethods_table;
+ int n_dmethods;
+ int first_class_dmethod;
+ int curr_class_dmethod;
+
+ /*
+ * SWIG types data.
+ */
+ // Collects information about encountered types SWIG does not know about (e.g.
+ // incomplete types). This is used later to generate type wrapper proxy
+ // classes for the unknown types.
+ Hash *unknown_types;
+
+
+public:
+ /* ---------------------------------------------------------------------------
+ * D::D()
+ * --------------------------------------------------------------------------- */
+ D():empty_string(NewString("")),
+ public_string(NewString("public")),
+ protected_string(NewString("protected")),
+ f_begin(NULL),
+ f_runtime(NULL),
+ f_runtime_h(NULL),
+ f_header(NULL),
+ f_wrappers(NULL),
+ f_init(NULL),
+ f_directors(NULL),
+ f_directors_h(NULL),
+ filenames_list(NULL),
+ split_proxy_dmodule(false),
+ d_version(1),
+ native_function_flag(false),
+ static_flag(false),
+ variable_wrapper_flag(false),
+ wrapping_member_flag(false),
+ global_variable_flag(false),
+ variable_name(NULL),
+ upcasts_code(NULL),
+ director_callback_typedefs(NULL),
+ director_callback_pointers(NULL),
+ im_dmodule_name(NULL),
+ im_dmodule_fq_name(NULL),
+ proxy_dmodule_name(NULL),
+ proxy_dmodule_fq_name(NULL),
+ package(NULL),
+ dmodule_directory(NULL),
+ wrap_library_name(NULL),
+ im_dmodule_imports(NULL),
+ im_dmodule_code(NULL),
+ global_proxy_imports(NULL),
+ proxy_dmodule_imports(NULL),
+ proxy_dmodule_code(NULL),
+ proxy_enum_code(NULL),
+ proxy_class_name(NULL),
+ proxy_class_imports(NULL),
+ proxy_class_enums_code(NULL),
+ proxy_class_body_code(NULL),
+ proxy_class_epilogue_code(NULL),
+ proxy_class_code(NULL),
+ destructor_call(NULL),
+ director_dcallbacks_code(NULL),
+ wrapper_loader_code(NULL),
+ wrapper_loader_bind_command(NULL),
+ wrapper_loader_bind_code(NULL),
+ dmethods_seq(NULL),
+ dmethods_table(NULL),
+ n_dmethods(0),
+ unknown_types(NULL) {
+
+ // For now, multiple inheritance with directors is not possible. It should be
+ // easy to implement though.
+ director_multiple_inheritance = 0;
+ director_language = 1;
+
+ // Not used:
+ Delete(none_comparison);
+ none_comparison = NewString("");
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::main()
+ * --------------------------------------------------------------------------- */
+ virtual void main(int argc, char *argv[]) {
+ SWIG_library_directory("d");
+
+ // Look for certain command line options
+ for (int i = 1; i < argc; i++) {
+ if (argv[i]) {
+ if ((strcmp(argv[i], "-d2") == 0)) {
+ Swig_mark_arg(i);
+ d_version = 2;
+ } else if (strcmp(argv[i], "-wrapperlibrary") == 0) {
+ if (argv[i + 1]) {
+ wrap_library_name = NewString("");
+ Printf(wrap_library_name, argv[i + 1]);
+ Swig_mark_arg(i);
+ Swig_mark_arg(i + 1);
+ i++;
+ } else {
+ Swig_arg_error();
+ }
+ } else if (strcmp(argv[i], "-package") == 0) {
+ if (argv[i + 1]) {
+ package = NewString("");
+ Printf(package, argv[i + 1]);
+ Swig_mark_arg(i);
+ Swig_mark_arg(i + 1);
+ i++;
+ } else {
+ Swig_arg_error();
+ }
+ } else if ((strcmp(argv[i], "-splitproxy") == 0)) {
+ Swig_mark_arg(i);
+ split_proxy_dmodule = true;
+ } else if (strcmp(argv[i], "-help") == 0) {
+ Printf(stdout, "%s\n", usage);
+ }
+ }
+ }
+
+ // Add a symbol to the parser for conditional compilation
+ Preprocessor_define("SWIGD 1", 0);
+
+ // Also make the target D version available as preprocessor symbol for
+ // use in our library files.
+ String *version_define = NewStringf("SWIG_D_VERSION %u", d_version);
+ Preprocessor_define(version_define, 0);
+ Delete(version_define);
+
+ // Add typemap definitions
+ SWIG_typemap_lang("d");
+ SWIG_config_file("d.swg");
+
+ allow_overloading();
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::top()
+ * --------------------------------------------------------------------------- */
+ virtual int top(Node *n) {
+ // Get any options set in the module directive
+ Node *optionsnode = Getattr(Getattr(n, "module"), "options");
+
+ if (optionsnode) {
+ if (Getattr(optionsnode, "imdmodulename")) {
+ im_dmodule_name = Copy(Getattr(optionsnode, "imdmodulename"));
+ }
+
+ if (Getattr(optionsnode, "directors")) {
+ // Check if directors are enabled for this module. Note: This is a
+ // "master switch", if it is not set, not director code will be emitted
+ // at all. %feature("director") statements are also required to enable
+ // directors for individual classes or methods.
+ //
+ // Use the »directors« attributte of the %module directive to enable
+ // director generation (e.g. »%module(directors="1") modulename«).
+ allow_directors();
+ }
+
+ if (Getattr(optionsnode, "dirprot")) {
+ allow_dirprot();
+ }
+
+ allow_allprotected(GetFlag(optionsnode, "allprotected"));
+ }
+
+ /* Initialize all of the output files */
+ String *outfile = Getattr(n, "outfile");
+ String *outfile_h = Getattr(n, "outfile_h");
+
+ if (!outfile) {
+ Printf(stderr, "Unable to determine outfile\n");
+ SWIG_exit(EXIT_FAILURE);
+ }
+
+ f_begin = NewFile(outfile, "w", SWIG_output_files());
+ if (!f_begin) {
+ FileErrorDisplay(outfile);
+ SWIG_exit(EXIT_FAILURE);
+ }
+
+ if (directorsEnabled()) {
+ if (!outfile_h) {
+ Printf(stderr, "Unable to determine outfile_h\n");
+ SWIG_exit(EXIT_FAILURE);
+ }
+ f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
+ if (!f_runtime_h) {
+ FileErrorDisplay(outfile_h);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ }
+
+ f_runtime = NewString("");
+ f_init = NewString("");
+ f_header = NewString("");
+ f_wrappers = NewString("");
+ f_directors_h = NewString("");
+ f_directors = NewString("");
+
+ /* Register file targets with the SWIG file handler */
+ Swig_register_filebyname("header", f_header);
+ Swig_register_filebyname("wrapper", f_wrappers);
+ Swig_register_filebyname("begin", f_begin);
+ Swig_register_filebyname("runtime", f_runtime);
+ Swig_register_filebyname("init", f_init);
+ Swig_register_filebyname("director", f_directors);
+ Swig_register_filebyname("director_h", f_directors_h);
+
+ unknown_types = NewHash();
+ filenames_list = NewList();
+
+ // Make the package name and the resulting module output path.
+ if (package) {
+ // Append a dot so we can prepend the package variable directly to the
+ // module names in the rest of the code.
+ Printv(package, ".", NIL);
+ } else {
+ // Write the generated D modules to the »root« package by default.
+ package = NewString("");
+ }
+
+ dmodule_directory = Copy(SWIG_output_directory());
+ if (Len(package) > 0) {
+ String *package_directory = Copy(package);
+ Replaceall(package_directory, ".", SWIG_FILE_DELIMITER);
+ Printv(dmodule_directory, package_directory, NIL);
+ Delete(package_directory);
+ }
+
+ // Make the wrap and proxy D module names.
+ // The wrap module name can be set in the module directive.
+ if (!im_dmodule_name) {
+ im_dmodule_name = NewStringf("%s_im", Getattr(n, "name"));
+ }
+ im_dmodule_fq_name = NewStringf("%s%s", package, im_dmodule_name);
+ proxy_dmodule_name = Copy(Getattr(n, "name"));
+ proxy_dmodule_fq_name = NewStringf("%s%s", package, proxy_dmodule_name);
+
+ im_dmodule_code = NewString("");
+ proxy_class_imports = NewString("");
+ proxy_class_enums_code = NewString("");
+ proxy_class_body_code = NewString("");
+ proxy_class_epilogue_code = NewString("");
+ proxy_class_code = NewString("");
+ destructor_call = NewString("");
+ proxy_dmodule_code = NewString("");
+ proxy_dmodule_imports = NewString("");
+ im_dmodule_imports = NewString("");
+ upcasts_code = NewString("");
+ global_proxy_imports = NewString("");
+ wrapper_loader_code = NewString("");
+ wrapper_loader_bind_command = NewString("");
+ wrapper_loader_bind_code = NewString("");
+ dmethods_seq = NewList();
+ dmethods_table = NewHash();
+ n_dmethods = 0;
+
+ // By default, expect the dynamically loaded wrapper library to be named
+ // [lib]<module>_wrap[.so/.dll].
+ if (!wrap_library_name)
+ wrap_library_name = NewStringf("%s_wrap", Getattr(n, "name"));
+
+ Swig_banner(f_begin);
+
+ Printf(f_runtime, "\n");
+ Printf(f_runtime, "#define SWIGD\n");
+
+ if (directorsEnabled()) {
+ Printf(f_runtime, "#define SWIG_DIRECTORS\n");
+
+ /* Emit initial director header and director code: */
+ Swig_banner(f_directors_h);
+ Printf(f_directors_h, "\n");
+ Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", proxy_dmodule_name);
+ Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", proxy_dmodule_name);
+
+ Printf(f_directors, "\n\n");
+ Printf(f_directors, "/* ---------------------------------------------------\n");
+ Printf(f_directors, " * C++ director class methods\n");
+ Printf(f_directors, " * --------------------------------------------------- */\n\n");
+ if (outfile_h)
+ Printf(f_directors, "#include \"%s\"\n\n", Swig_file_filename(outfile_h));
+ }
+
+ Printf(f_runtime, "\n");
+
+ Swig_name_register("wrapper", "D_%f");
+
+ Printf(f_wrappers, "\n#ifdef __cplusplus\n");
+ Printf(f_wrappers, "extern \"C\" {\n");
+ Printf(f_wrappers, "#endif\n\n");
+
+ // Emit all the wrapper code.
+ Language::top(n);
+
+ if (directorsEnabled()) {
+ // Insert director runtime into the f_runtime file (before %header section).
+ Swig_insert_file("director.swg", f_runtime);
+ }
+
+ // Generate the wrap D module.
+ // TODO: Add support for »static« linking.
+ {
+ String *filen = NewStringf("%s%s.d", dmodule_directory, im_dmodule_name);
+ File *im_d_file = NewFile(filen, "w", SWIG_output_files());
+ if (!im_d_file) {
+ FileErrorDisplay(filen);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ Append(filenames_list, Copy(filen));
+ Delete(filen);
+ filen = NULL;
+
+ // Start writing out the intermediary class file.
+ emitBanner(im_d_file);
+
+ Printf(im_d_file, "module %s;\n", im_dmodule_fq_name);
+
+ Printv(im_d_file, im_dmodule_imports, "\n", NIL);
+
+ Replaceall(wrapper_loader_code, "$wraplibrary", wrap_library_name);
+ Replaceall(wrapper_loader_code, "$wrapperloaderbindcode", wrapper_loader_bind_code);
+ Replaceall(wrapper_loader_code, "$module", proxy_dmodule_name);
+ Printf(im_d_file, "%s\n", wrapper_loader_code);
+
+ // Add the wrapper function declarations.
+ replaceModuleVariables(im_dmodule_code);
+ Printv(im_d_file, im_dmodule_code, NIL);
+
+ Close(im_d_file);
+ }
+
+ // Generate the D proxy module for the wrapped module.
+ {
+ String *filen = NewStringf("%s%s.d", dmodule_directory, proxy_dmodule_name);
+ File *proxy_d_file = NewFile(filen, "w", SWIG_output_files());
+ if (!proxy_d_file) {
+ FileErrorDisplay(filen);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ Append(filenames_list, Copy(filen));
+ Delete(filen);
+ filen = NULL;
+
+ emitBanner(proxy_d_file);
+
+ Printf(proxy_d_file, "module %s;\n", proxy_dmodule_fq_name);
+ Printf(proxy_d_file, "\nstatic import %s;\n", im_dmodule_fq_name);
+ Printv(proxy_d_file, global_proxy_imports, NIL);
+ Printv(proxy_d_file, proxy_dmodule_imports, NIL);
+ Printv(proxy_d_file, "\n", NIL);
+
+ // Write a D type wrapper class for each SWIG type to the proxy module code.
+ for (Iterator swig_type = First(unknown_types); swig_type.key; swig_type = Next(swig_type)) {
+ writeTypeWrapperClass(swig_type.key, swig_type.item);
+ }
+
+ // Add the proxy functions (and classes, if they are not written to a
+ // seperate file).
+ replaceModuleVariables(proxy_dmodule_code);
+ Printv(proxy_d_file, proxy_dmodule_code, NIL);
+
+ Close(proxy_d_file);
+ }
+
+ if (upcasts_code)
+ Printv(f_wrappers, upcasts_code, NIL);
+
+ Printf(f_wrappers, "#ifdef __cplusplus\n");
+ Printf(f_wrappers, "}\n");
+ Printf(f_wrappers, "#endif\n");
+
+ // Check for overwriting file problems on filesystems that are case insensitive
+ Iterator it1;
+ Iterator it2;
+ for (it1 = First(filenames_list); it1.item; it1 = Next(it1)) {
+ String *item1_lower = Swig_string_lower(it1.item);
+ for (it2 = Next(it1); it2.item; it2 = Next(it2)) {
+ String *item2_lower = Swig_string_lower(it2.item);
+ if (it1.item && it2.item) {
+ if (Strcmp(item1_lower, item2_lower) == 0) {
+ Swig_warning(WARN_LANG_PORTABILITY_FILENAME, input_file, line_number,
+ "Portability warning: File %s will be overwritten by %s on case insensitive filesystems such as "
+ "Windows' FAT32 and NTFS unless the class/module name is renamed\n", it1.item, it2.item);
+ }
+ }
+ Delete(item2_lower);
+ }
+ Delete(item1_lower);
+ }
+
+ Delete(unknown_types);
+ unknown_types = NULL;
+ Delete(filenames_list);
+ filenames_list = NULL;
+ Delete(im_dmodule_name);
+ im_dmodule_name = NULL;
+ Delete(im_dmodule_fq_name);
+ im_dmodule_fq_name = NULL;
+ Delete(im_dmodule_code);
+ im_dmodule_code = NULL;
+ Delete(proxy_class_imports);
+ proxy_class_imports = NULL;
+ Delete(proxy_class_enums_code);
+ proxy_class_enums_code = NULL;
+ Delete(proxy_class_body_code);
+ proxy_class_body_code = NULL;
+ Delete(proxy_class_epilogue_code);
+ proxy_class_epilogue_code = NULL;
+ Delete(proxy_class_code);
+ proxy_class_code = NULL;
+ Delete(destructor_call);
+ destructor_call = NULL;
+ Delete(proxy_dmodule_name);
+ proxy_dmodule_name = NULL;
+ Delete(proxy_dmodule_fq_name);
+ proxy_dmodule_fq_name = NULL;
+ Delete(proxy_dmodule_code);
+ proxy_dmodule_code = NULL;
+ Delete(proxy_dmodule_imports);
+ proxy_dmodule_imports = NULL;
+ Delete(im_dmodule_imports);
+ im_dmodule_imports = NULL;
+ Delete(upcasts_code);
+ upcasts_code = NULL;
+ Delete(global_proxy_imports);
+ global_proxy_imports = NULL;
+ Delete(wrapper_loader_code);
+ wrapper_loader_code = NULL;
+ Delete(wrapper_loader_bind_code);
+ wrapper_loader_bind_code = NULL;
+ Delete(wrapper_loader_bind_command);
+ wrapper_loader_bind_command = NULL;
+ Delete(dmethods_seq);
+ dmethods_seq = NULL;
+ Delete(dmethods_table);
+ dmethods_table = NULL;
+ Delete(package);
+ package = NULL;
+ Delete(dmodule_directory);
+ dmodule_directory = NULL;
+ n_dmethods = 0;
+
+ // Merge all the generated C/C++ code and close the output files.
+ Dump(f_runtime, f_begin);
+ Dump(f_header, f_begin);
+
+ if (directorsEnabled()) {
+ Dump(f_directors, f_begin);
+ Dump(f_directors_h, f_runtime_h);
+
+ Printf(f_runtime_h, "\n");
+ Printf(f_runtime_h, "#endif\n");
+
+ Close(f_runtime_h);
+ Delete(f_runtime_h);
+ f_runtime_h = NULL;
+ Delete(f_directors);
+ f_directors = NULL;
+ Delete(f_directors_h);
+ f_directors_h = NULL;
+ }
+
+ Dump(f_wrappers, f_begin);
+ Wrapper_pretty_print(f_init, f_begin);
+ Delete(f_header);
+ Delete(f_wrappers);
+ Delete(f_init);
+ Close(f_begin);
+ Delete(f_runtime);
+ Delete(f_begin);
+
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::insertDirective()
+ * --------------------------------------------------------------------------- */
+ virtual int insertDirective(Node *n) {
+ String *code = Getattr(n, "code");
+ replaceModuleVariables(code);
+ return Language::insertDirective(n);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::pragmaDirective()
+ *
+ * Valid Pragmas:
+ * imdmodulecode - text (D code) is copied verbatim to the wrap module
+ * imdmoduleimports - import statements for the im D module
+ *
+ * proxydmodulecode - text (D code) is copied verbatim to the proxy module
+ * (the main proxy module if in split proxy mode).
+ * globalproxyimports - import statements inserted into _all_ proxy modules.
+ *
+ * wrapperloadercode - D code for loading the wrapper library (is copied to
+ * the im D module).
+ * wrapperloaderbindcommand - D code for binding a symbol from the wrapper
+ * library to the declaration in the im D module.
+ * --------------------------------------------------------------------------- */
+ virtual int pragmaDirective(Node *n) {
+ if (!ImportMode) {
+ String *lang = Getattr(n, "lang");
+ String *code = Getattr(n, "name");
+ String *value = Getattr(n, "value");
+
+ if (Strcmp(lang, "d") == 0) {
+ String *strvalue = NewString(value);
+ Replaceall(strvalue, "\\\"", "\"");
+
+ if (Strcmp(code, "imdmodulecode") == 0) {
+ Printf(im_dmodule_code, "%s\n", strvalue);
+ } else if (Strcmp(code, "imdmoduleimports") == 0) {
+ replaceImportTypeMacros(strvalue);
+ Chop(strvalue);
+ Printf(im_dmodule_imports, "%s\n", strvalue);
+ } else if (Strcmp(code, "proxydmodulecode") == 0) {
+ Printf(proxy_dmodule_code, "%s\n", strvalue);
+ } else if (Strcmp(code, "globalproxyimports") == 0) {
+ replaceImportTypeMacros(strvalue);
+ Chop(strvalue);
+ Printf(global_proxy_imports, "%s\n", strvalue);
+ } else if (Strcmp(code, "wrapperloadercode") == 0) {
+ Delete(wrapper_loader_code);
+ wrapper_loader_code = Copy(strvalue);
+ } else if (Strcmp(code, "wrapperloaderbindcommand") == 0) {
+ Delete(wrapper_loader_bind_command);
+ wrapper_loader_bind_command = Copy(strvalue);
+ } else {
+ Swig_error(input_file, line_number, "Unrecognized pragma.\n");
+ }
+ Delete(strvalue);
+ }
+ }
+ return Language::pragmaDirective(n);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::enumDeclaration()
+ *
+ * Wraps C/C++ enums as D enums.
+ * --------------------------------------------------------------------------- */
+ virtual int enumDeclaration(Node *n) {
+ if (ImportMode)
+ return SWIG_OK;
+
+ if (getCurrentClass() && (cplus_mode != PUBLIC))
+ return SWIG_NOWRAP;
+
+ proxy_enum_code = NewString("");
+ String *symname = Getattr(n, "sym:name");
+ String *typemap_lookup_type = Getattr(n, "name");
+
+ // Emit the enum declaration.
+ if (typemap_lookup_type) {
+ const String *enummodifiers = lookupCodeTypemap(n, "dclassmodifiers", typemap_lookup_type, WARN_D_TYPEMAP_CLASSMOD_UNDEF);
+ Printv(proxy_enum_code, "\n", enummodifiers, " ", symname, " {\n", NIL);
+ } else {
+ // Handle anonymous enums.
+ Printv(proxy_enum_code, "\nenum {\n", NIL);
+ }
+
+ // Emit each enum item.
+ Language::enumDeclaration(n);
+
+ if (!GetFlag(n, "nonempty")) {
+ // Do not wrap empty enums; the resulting D code would be illegal.
+ Delete(proxy_enum_code);
+ return SWIG_NOWRAP;
+ }
+
+ // Finish the enum.
+ if (typemap_lookup_type) {
+ Printv(proxy_enum_code,
+ lookupCodeTypemap(n, "dcode", typemap_lookup_type, WARN_NONE), // Extra D code
+ "\n}\n", NIL);
+ } else {
+ // Handle anonymous enums.
+ Printv(proxy_enum_code, "\n}\n", NIL);
+ }
+
+ Replaceall(proxy_enum_code, "$dclassname", symname);
+
+ const String* imports =
+ lookupCodeTypemap(n, "dimports", typemap_lookup_type, WARN_NONE);
+ String* imports_trimmed;
+ if (Len(imports) > 0) {
+ imports_trimmed = Copy(imports);
+ Chop(imports_trimmed);
+ replaceImportTypeMacros(imports_trimmed);
+ Printv(imports_trimmed, "\n", NIL);
+ } else {
+ imports_trimmed = NewString("");
+ }
+
+ if (is_wrapping_class()) {
+ // Enums defined within the C++ class are written into the proxy
+ // class.
+ Printv(proxy_class_imports, imports_trimmed, NIL);
+ Printv(proxy_class_enums_code, proxy_enum_code, NIL);
+ } else {
+ // Write non-anonymous enums to their own file if in split proxy module
+ // mode.
+ if (split_proxy_dmodule && typemap_lookup_type) {
+ assertClassNameValidity(proxy_class_name);
+
+ String *filename = NewStringf("%s%s.d", dmodule_directory, symname);
+ File *class_file = NewFile(filename, "w", SWIG_output_files());
+ if (!class_file) {
+ FileErrorDisplay(filename);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ Append(filenames_list, Copy(filename));
+ Delete(filename);
+
+ emitBanner(class_file);
+ Printf(class_file, "module %s%s;\n", package, symname);
+ Printv(class_file, imports_trimmed, NIL);
+
+ Printv(class_file, proxy_enum_code, NIL);
+
+ Close(class_file);
+ Delete(class_file);
+ } else {
+ Printv(proxy_dmodule_imports, imports, NIL);
+ Printv(proxy_dmodule_code, proxy_enum_code, NIL);
+ }
+ }
+
+ Delete(imports_trimmed);
+
+ Delete(proxy_enum_code);
+ proxy_enum_code = NULL;
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::enumvalueDeclaration()
+ * --------------------------------------------------------------------------- */
+ virtual int enumvalueDeclaration(Node *n) {
+ if (getCurrentClass() && (cplus_mode != PUBLIC))
+ return SWIG_NOWRAP;
+
+ Swig_require("enumvalueDeclaration", n, "*name", "?value", NIL);
+ String *value = Getattr(n, "value");
+ String *name = Getattr(n, "name");
+ Node *parent = parentNode(n);
+ String *tmpValue;
+
+ // Strange hack from parent method.
+ // RESEARCH: What is this doing?
+ if (value)
+ tmpValue = NewString(value);
+ else
+ tmpValue = NewString(name);
+ // Note that this is used in enumValue() amongst other places
+ Setattr(n, "value", tmpValue);
+
+ String *proxy_name = Getattr(n, "sym:name");
+
+ // Emit the enum item.
+ {
+ if (!GetFlag(n, "firstenumitem"))
+ Printf(proxy_enum_code, ",\n");
+
+ Printf(proxy_enum_code, " %s", proxy_name);
+
+ // Check for the %dconstvalue feature
+ String *value = Getattr(n, "feature:d:constvalue");
+
+ // Note that in D, enum values must be compile-time constants. Thus,
+ // %dmanifestconst(0) (getting the enum values at runtime) is not supported.
+ value = value ? value : Getattr(n, "enumvalue");
+ if (value) {
+ Printf(proxy_enum_code, " = %s", value);
+ }
+
+ // Keep track that the currently processed enum has at least one value.
+ SetFlag(parent, "nonempty");
+ }
+
+ Delete(tmpValue);
+ Swig_restore(n);
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::memberfunctionHandler()
+ * --------------------------------------------------------------------------- */
+ virtual int memberfunctionHandler(Node *n) {
+ Language::memberfunctionHandler(n);
+
+ String *overloaded_name = getOverloadedName(n);
+ String *intermediary_function_name =
+ Swig_name_member(NSPACE_TODO,proxy_class_name, overloaded_name);
+ Setattr(n, "imfuncname", intermediary_function_name);
+
+ String *proxy_func_name = Getattr(n, "sym:name");
+ Setattr(n, "proxyfuncname", proxy_func_name);
+ if (split_proxy_dmodule &&
+ Len(Getattr(n, "parms")) == 0 &&
+ Strncmp(proxy_func_name, package, Len(proxy_func_name)) == 0) {
+ // If we are in split proxy mode and the function is named like the
+ // target package, the D compiler is unable to resolve the ambiguity
+ // between the package name and an argument-less function call.
+ Swig_warning(WARN_D_NAME_COLLISION, input_file, line_number,
+ "%s::%s might collide with the package name, consider using %%rename to resolve the ambiguity.\n",
+ proxy_class_name, proxy_func_name);
+ }
+
+ writeProxyClassFunction(n);
+
+ Delete(overloaded_name);
+
+ // For each function, look if we have to alias in the parent class function
+ // for the overload resolution process to work as expected from C++
+ // (http://www.digitalmars.com/d/2.0/function.html#function-inheritance).
+ // For multiple overloads, only emit the alias directive once (for the
+ // last method, »sym:nextSibling« is null then).
+ // Smart pointer classes do not mirror the inheritance hierarchy of the
+ // underlying types, so aliasing the base class methods in is not required
+ // for them.
+ // DMD BUG: We have to emit the alias after the last function becasue
+ // taking a delegate in the overload checking code fails otherwise
+ // (http://d.puremagic.com/issues/show_bug.cgi?id=4860).
+ if (!Getattr(n, "sym:nextSibling") && !is_smart_pointer() &&
+ !areAllOverloadsOverridden(n)) {
+ String *name = Getattr(n, "sym:name");
+ Printf(proxy_class_body_code, "\nalias $dbaseclass.%s %s;\n", name, name);
+ }
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::staticmemberfunctionHandler()
+ * --------------------------------------------------------------------------- */
+ virtual int staticmemberfunctionHandler(Node *n) {
+ static_flag = true;
+
+ Language::staticmemberfunctionHandler(n);
+
+ String *overloaded_name = getOverloadedName(n);
+ String *intermediary_function_name =
+ Swig_name_member(NSPACE_TODO,proxy_class_name, overloaded_name);
+ Setattr(n, "proxyfuncname", Getattr(n, "sym:name"));
+ Setattr(n, "imfuncname", intermediary_function_name);
+ writeProxyClassFunction(n);
+ Delete(overloaded_name);
+
+ static_flag = false;
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::globalvariableHandler()
+ * --------------------------------------------------------------------------- */
+ virtual int globalvariableHandler(Node *n) {
+ variable_name = Getattr(n, "sym:name");
+ global_variable_flag = true;
+ int ret = Language::globalvariableHandler(n);
+ global_variable_flag = false;
+
+ return ret;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::membervariableHandler()
+ * --------------------------------------------------------------------------- */
+ virtual int membervariableHandler(Node *n) {
+ variable_name = Getattr(n, "sym:name");
+ wrapping_member_flag = true;
+ variable_wrapper_flag = true;
+ Language::membervariableHandler(n);
+ wrapping_member_flag = false;
+ variable_wrapper_flag = false;
+
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::staticmembervariableHandler()
+ * --------------------------------------------------------------------------- */
+ virtual int staticmembervariableHandler(Node *n) {
+ if (GetFlag(n, "feature:d:manifestconst") != 1) {
+ Delattr(n, "value");
+ }
+
+ variable_name = Getattr(n, "sym:name");
+ wrapping_member_flag = true;
+ static_flag = true;
+ Language::staticmembervariableHandler(n);
+ wrapping_member_flag = false;
+ static_flag = false;
+
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::memberconstantHandler()
+ * --------------------------------------------------------------------------- */
+ virtual int memberconstantHandler(Node *n) {
+ variable_name = Getattr(n, "sym:name");
+ wrapping_member_flag = true;
+ Language::memberconstantHandler(n);
+ wrapping_member_flag = false;
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::constructorHandler()
+ * --------------------------------------------------------------------------- */
+ virtual int constructorHandler(Node *n) {
+ Language::constructorHandler(n);
+
+ // Wrappers not wanted for some methods where the parameters cannot be overloaded in D.
+ if (Getattr(n, "overload:ignore")) {
+ return SWIG_OK;
+ }
+
+ ParmList *l = Getattr(n, "parms");
+ String *tm;
+ String *proxy_constructor_code = NewString("");
+ int i;
+
+ // Holds code for the constructor helper method generated only when the din
+ // typemap has code in the pre or post attributes.
+ String *helper_code = NewString("");
+ String *helper_args = NewString("");
+ String *pre_code = NewString("");
+ String *post_code = NewString("");
+ String *terminator_code = NewString("");
+ NewString("");
+
+ String *overloaded_name = getOverloadedName(n);
+ String *mangled_overname = Swig_name_construct(NSPACE_TODO,overloaded_name);
+ String *imcall = NewString("");
+
+ const String *methodmods = Getattr(n, "feature:d:methodmodifiers");
+ methodmods = methodmods ? methodmods : (is_public(n) ? public_string : protected_string);
+
+ // Typemaps were attached earlier to the node, get the return type of the
+ // call to the C++ constructor wrapper.
+ const String *wrapper_return_type = lookupDTypemap(n, "imtype", true);
+
+ String *imtypeout = Getattr(n, "tmap:imtype:out");
+ if (imtypeout) {
+ // The type in the imtype typemap's out attribute overrides the type in
+ // the typemap itself.
+ wrapper_return_type = imtypeout;
+ }
+
+ Printf(proxy_constructor_code, "\n%s this(", methodmods);
+ Printf(helper_code, "static private %s SwigConstruct%s(",
+ wrapper_return_type, proxy_class_name);
+
+ Printv(imcall, im_dmodule_fq_name, ".", mangled_overname, "(", NIL);
+
+ /* Attach the non-standard typemaps to the parameter list */
+ Swig_typemap_attach_parms("in", l, NULL);
+ Swig_typemap_attach_parms("dtype", l, NULL);
+ Swig_typemap_attach_parms("din", l, NULL);
+
+ emit_mark_varargs(l);
+
+ int gencomma = 0;
+
+ /* Output each parameter */
+ Parm *p = l;
+ for (i = 0; p; i++) {
+ if (checkAttribute(p, "varargs:ignore", "1")) {
+ // Skip ignored varargs.
+ p = nextSibling(p);
+ continue;
+ }
+
+ if (checkAttribute(p, "tmap:in:numinputs", "0")) {
+ // Skip ignored parameters.
+ p = Getattr(p, "tmap:in:next");
+ continue;
+ }
+
+ SwigType *pt = Getattr(p, "type");
+ String *param_type = NewString("");
+
+ // Get the D parameter type.
+ if ((tm = lookupDTypemap(p, "dtype", true))) {
+ const String *inattributes = Getattr(p, "tmap:dtype:inattributes");
+ Printf(param_type, "%s%s", inattributes ? inattributes : empty_string, tm);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number,
+ "No dtype typemap defined for %s\n", SwigType_str(pt, 0));
+ }
+
+ if (gencomma)
+ Printf(imcall, ", ");
+
+ String *arg = makeParameterName(n, p, i, false);
+ String *parmtype = 0;
+
+ // Get the D code to convert the parameter value to the type used in the
+ // intermediary D module.
+ if ((tm = lookupDTypemap(p, "din"))) {
+ Replaceall(tm, "$dinput", arg);
+ String *pre = Getattr(p, "tmap:din:pre");
+ if (pre) {
+ replaceClassname(pre, pt);
+ Replaceall(pre, "$dinput", arg);
+ if (Len(pre_code) > 0)
+ Printf(pre_code, "\n");
+ Printv(pre_code, pre, NIL);
+ }
+ String *post = Getattr(p, "tmap:din:post");
+ if (post) {
+ replaceClassname(post, pt);
+ Replaceall(post, "$dinput", arg);
+ if (Len(post_code) > 0)
+ Printf(post_code, "\n");
+ Printv(post_code, post, NIL);
+ }
+ String *terminator = Getattr(p, "tmap:din:terminator");
+ if (terminator) {
+ replaceClassname(terminator, pt);
+ Replaceall(terminator, "$dinput", arg);
+ if (Len(terminator_code) > 0)
+ Insert(terminator_code, 0, "\n");
+ Insert(terminator_code, 0, terminator);
+ }
+ parmtype = Getattr(p, "tmap:din:parmtype");
+ if (parmtype)
+ Replaceall(parmtype, "$dinput", arg);
+ Printv(imcall, tm, NIL);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_DIN_UNDEF, input_file, line_number,
+ "No din typemap defined for %s\n", SwigType_str(pt, 0));
+ }
+
+ /* Add parameter to proxy function */
+ if (gencomma) {
+ Printf(proxy_constructor_code, ", ");
+ Printf(helper_code, ", ");
+ Printf(helper_args, ", ");
+ }
+ Printf(proxy_constructor_code, "%s %s", param_type, arg);
+ Printf(helper_code, "%s %s", param_type, arg);
+ Printf(helper_args, "%s", parmtype ? parmtype : arg);
+ ++gencomma;
+
+ Delete(parmtype);
+ Delete(arg);
+ Delete(param_type);
+ p = Getattr(p, "tmap:in:next");
+ }
+
+ Printf(imcall, ")");
+
+ Printf(proxy_constructor_code, ")");
+ Printf(helper_code, ")");
+
+ // Insert the dconstructor typemap (replacing $directorconnect as needed).
+ Hash *attributes = NewHash();
+ String *construct_tm = Copy(lookupCodeTypemap(n, "dconstructor",
+ Getattr(n, "name"), WARN_D_TYPEMAP_DCONSTRUCTOR_UNDEF, attributes));
+ if (construct_tm) {
+ const bool use_director = (parentNode(n) && Swig_directorclass(n));
+ if (!use_director) {
+ Replaceall(construct_tm, "$directorconnect", "");
+ } else {
+ String *connect_attr = Getattr(attributes, "tmap:dconstructor:directorconnect");
+
+ if (connect_attr) {
+ Replaceall(construct_tm, "$directorconnect", connect_attr);
+ } else {
+ Swig_warning(WARN_D_NO_DIRECTORCONNECT_ATTR, input_file, line_number,
+ "\"directorconnect\" attribute missing in %s \"dconstructor\" typemap.\n",
+ Getattr(n, "name"));
+ Replaceall(construct_tm, "$directorconnect", "");
+ }
+ }
+
+ Printv(proxy_constructor_code, " ", construct_tm, NIL);
+ }
+
+ replaceExcode(n, proxy_constructor_code, "dconstructor", attributes);
+
+ bool is_pre_code = Len(pre_code) > 0;
+ bool is_post_code = Len(post_code) > 0;
+ bool is_terminator_code = Len(terminator_code) > 0;
+ if (is_pre_code || is_post_code || is_terminator_code) {
+ Printf(helper_code, " {\n");
+ if (is_pre_code) {
+ Printv(helper_code, pre_code, "\n", NIL);
+ }
+ if (is_post_code) {
+ Printf(helper_code, " try {\n");
+ Printv(helper_code, " return ", imcall, ";\n", NIL);
+ Printv(helper_code, " } finally {\n", post_code, "\n }", NIL);
+ } else {
+ Printv(helper_code, " return ", imcall, ";", NIL);
+ }
+ if (is_terminator_code) {
+ Printv(helper_code, "\n", terminator_code, NIL);
+ }
+ Printf(helper_code, "\n}\n");
+ String *helper_name = NewStringf("%s.SwigConstruct%s(%s)",
+ proxy_class_name, proxy_class_name, helper_args);
+ Replaceall(proxy_constructor_code, "$imcall", helper_name);
+ Delete(helper_name);
+ } else {
+ Replaceall(proxy_constructor_code, "$imcall", imcall);
+ }
+
+ Printv(proxy_class_body_code, proxy_constructor_code, "\n", NIL);
+
+ Delete(helper_args);
+ Delete(pre_code);
+ Delete(post_code);
+ Delete(terminator_code);
+ Delete(construct_tm);
+ Delete(attributes);
+ Delete(overloaded_name);
+ Delete(imcall);
+
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::destructorHandler()
+ * --------------------------------------------------------------------------- */
+ virtual int destructorHandler(Node *n) {
+ Language::destructorHandler(n);
+ String *symname = Getattr(n, "sym:name");
+ Printv(destructor_call, im_dmodule_fq_name, ".", Swig_name_destroy(NSPACE_TODO,symname), "(cast(void*)swigCPtr)", NIL);
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::classHandler()
+ * --------------------------------------------------------------------------- */
+ virtual int classHandler(Node *n) {
+ File *class_file = NULL;
+
+ proxy_class_name = Copy(Getattr(n, "sym:name"));
+
+ if (!addSymbol(proxy_class_name, n)) {
+ return SWIG_ERROR;
+ }
+
+ assertClassNameValidity(proxy_class_name);
+
+ if (split_proxy_dmodule) {
+ String *filename = NewStringf("%s%s.d", dmodule_directory, proxy_class_name);
+ class_file = NewFile(filename, "w", SWIG_output_files());
+ if (!class_file) {
+ FileErrorDisplay(filename);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ Append(filenames_list, Copy(filename));
+ Delete(filename);
+
+ emitBanner(class_file);
+ Printf(class_file, "module %s%s;\n", package, proxy_class_name);
+ Printf(class_file, "\nstatic import %s;\n", im_dmodule_fq_name);
+ }
+
+ Clear(proxy_class_imports);
+ Clear(proxy_class_enums_code);
+ Clear(proxy_class_body_code);
+ Clear(proxy_class_epilogue_code);
+ Clear(proxy_class_code);
+ Clear(destructor_call);
+
+
+ Language::classHandler(n);
+
+
+ writeProxyClassAndUpcasts(n);
+ writeDirectorConnectWrapper(n);
+
+ Replaceall(proxy_class_code, "$dclassname", proxy_class_name);
+
+ if (split_proxy_dmodule) {
+ Printv(class_file, global_proxy_imports, NIL);
+ Printv(class_file, proxy_class_imports, NIL);
+
+ replaceModuleVariables(proxy_class_code);
+ Printv(class_file, proxy_class_code, NIL);
+
+ Close(class_file);
+ Delete(class_file);
+ } else {
+ Printv(proxy_dmodule_imports, proxy_class_imports, NIL);
+ Printv(proxy_dmodule_code, proxy_class_code, NIL);
+ }
+
+ Delete(proxy_class_name);
+ proxy_class_name = NULL;
+
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::constantWrapper()
+ *
+ * Used for wrapping constants declared by #define or %constant and also for
+ * (primitive) static member constants initialised inline.
+ *
+ * If the %dmanifestconst feature is used, the C/C++ constant value is used to
+ * initialize a D »const«. If not, a »getter« method is generated which
+ * retrieves the value via a call to the C wrapper. However, if there is a
+ * %dconstvalue specified, it overrides all other settings.
+ * --------------------------------------------------------------------------- */
+ virtual int constantWrapper(Node *n) {
+ String *symname = Getattr(n, "sym:name");
+ if (!addSymbol(symname, n))
+ return SWIG_ERROR;
+
+ // The %dmanifestconst feature determines if a D manifest constant
+ // (const/enum) or a getter function is created.
+ if (GetFlag(n, "feature:d:manifestconst") != 1) {
+ // Default constant handling will work with any type of C constant. It
+ // generates a getter function (which is the same as a read only property
+ // in D) which retrieves the value via by calling the C wrapper.
+ // Note that this is only called for global constants, static member
+ // constants are already handeled in staticmemberfunctionHandler().
+
+ Swig_save("constantWrapper", n, "value", NIL);
+
+ // Add the stripped quotes back in.
+ String *old_value = Getattr(n, "value");
+ SwigType *t = Getattr(n, "type");
+ if (SwigType_type(t) == T_STRING) {
+ Setattr(n, "value", NewStringf("\"%s\"", old_value));
+ Delete(old_value);
+ } else if (SwigType_type(t) == T_CHAR) {
+ Setattr(n, "value", NewStringf("\'%s\'", old_value));
+ Delete(old_value);
+ }
+
+ int result = globalvariableHandler(n);
+
+ Swig_restore(n);
+ return result;
+ }
+
+ String *constants_code = NewString("");
+ SwigType *t = Getattr(n, "type");
+ ParmList *l = Getattr(n, "parms");
+
+ // Attach the non-standard typemaps to the parameter list.
+ Swig_typemap_attach_parms("dtype", l, NULL);
+
+ // Get D return type.
+ String *return_type = NewString("");
+ String *tm;
+ if ((tm = lookupDTypemap(n, "dtype"))) {
+ String *dtypeout = Getattr(n, "tmap:dtype:out");
+ if (dtypeout) {
+ // The type in the out attribute of the typemap overrides the type
+ // in the dtype typemap.
+ tm = dtypeout;
+ replaceClassname(tm, t);
+ }
+ Printf(return_type, "%s", tm);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number,
+ "No dtype typemap defined for %s\n", SwigType_str(t, 0));
+ }
+
+ const String *itemname = wrapping_member_flag ? variable_name : symname;
+
+ String *attributes = Getattr(n, "feature:d:methodmodifiers");
+ if (attributes) {
+ attributes = Copy(attributes);
+ } else {
+ attributes = Copy(is_public(n) ? public_string : protected_string);
+ }
+
+ if (d_version == 1) {
+ if (static_flag) {
+ Printv(attributes, " static", NIL);
+ }
+ Printf(constants_code, "\n%s const %s %s = ", attributes, return_type, itemname);
+ } else {
+ Printf(constants_code, "\n%s enum %s %s = ", attributes, return_type, itemname);
+ }
+ Delete(attributes);
+
+ // Retrive the override value set via %dconstvalue, if any.
+ String *override_value = Getattr(n, "feature:d:constvalue");
+ if (override_value) {
+ Printf(constants_code, "%s;\n", override_value);
+ } else {
+ // Just take the value from the C definition and hope it compiles in D.
+ String* value = Getattr(n, "wrappedasconstant") ?
+ Getattr(n, "staticmembervariableHandler:value") : Getattr(n, "value");
+
+ // Add the stripped quotes back in.
+ if (SwigType_type(t) == T_STRING) {
+ Printf(constants_code, "\"%s\";\n", value);
+ } else if (SwigType_type(t) == T_CHAR) {
+ Printf(constants_code, "\'%s\';\n", value);
+ } else {
+ Printf(constants_code, "%s;\n", value);
+ }
+ }
+
+ // Emit the generated code to appropriate place.
+ if (wrapping_member_flag) {
+ Printv(proxy_class_body_code, constants_code, NIL);
+ } else {
+ Printv(proxy_dmodule_code, constants_code, NIL);
+ }
+
+ // Cleanup.
+ Delete(return_type);
+ Delete(constants_code);
+
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::functionWrapper()
+ *
+ * Generates the C wrapper code for a function and the corresponding
+ * declaration in the wrap D module.
+ * --------------------------------------------------------------------------- */
+ virtual int functionWrapper(Node *n) {
+ String *symname = Getattr(n, "sym:name");
+ SwigType *t = Getattr(n, "type");
+ ParmList *l = Getattr(n, "parms");
+ String *tm;
+ Parm *p;
+ int i;
+ String *c_return_type = NewString("");
+ String *im_return_type = NewString("");
+ String *cleanup = NewString("");
+ String *outarg = NewString("");
+ String *body = NewString("");
+ int num_arguments = 0;
+ int num_required = 0;
+ bool is_void_return;
+ String *overloaded_name = getOverloadedName(n);
+
+ if (!Getattr(n, "sym:overloaded")) {
+ if (!addSymbol(Getattr(n, "sym:name"), n))
+ return SWIG_ERROR;
+ }
+
+ // A new wrapper function object
+ Wrapper *f = NewWrapper();
+
+ // Make a wrapper name for this function
+ String *wname = Swig_name_wrapper(overloaded_name);
+
+ /* Attach the non-standard typemaps to the parameter list. */
+ Swig_typemap_attach_parms("ctype", l, f);
+ Swig_typemap_attach_parms("imtype", l, f);
+
+ /* Get return types */
+ if ((tm = lookupDTypemap(n, "ctype"))) {
+ String *ctypeout = Getattr(n, "tmap:ctype:out");
+ if (ctypeout) {
+ // The type in the ctype typemap's out attribute overrides the type in
+ // the typemap itself.
+ tm = ctypeout;
+ }
+ Printf(c_return_type, "%s", tm);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_CTYPE_UNDEF, input_file, line_number,
+ "No ctype typemap defined for %s\n", SwigType_str(t, 0));
+ }
+
+ if ((tm = lookupDTypemap(n, "imtype"))) {
+ String *imtypeout = Getattr(n, "tmap:imtype:out");
+ if (imtypeout) {
+ // The type in the imtype typemap's out attribute overrides the type in
+ // the typemap itself.
+ tm = imtypeout;
+ }
+ Printf(im_return_type, "%s", tm);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_IMTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(t, 0));
+ }
+
+ is_void_return = (Cmp(c_return_type, "void") == 0);
+ if (!is_void_return)
+ Wrapper_add_localv(f, "jresult", c_return_type, "jresult", NIL);
+
+ Printv(f->def, " SWIGEXPORT ", c_return_type, " ", wname, "(", NIL);
+
+ // Emit all of the local variables for holding arguments.
+ emit_parameter_variables(l, f);
+
+ /* Attach the standard typemaps */
+ emit_attach_parmmaps(l, f);
+
+ // Parameter overloading
+ Setattr(n, "wrap:parms", l);
+ Setattr(n, "wrap:name", wname);
+
+ // Wrappers not wanted for some methods where the parameters cannot be overloaded in D
+ if (Getattr(n, "sym:overloaded")) {
+ // Emit warnings for the few cases that can't be overloaded in D and give up on generating wrapper
+ Swig_overload_check(n);
+ if (Getattr(n, "overload:ignore"))
+ return SWIG_OK;
+ }
+
+ // Collect the parameter list for the intermediary D module declaration of
+ // the generated wrapper function.
+ String *im_dmodule_parameters = NewString("(");
+
+ /* Get number of required and total arguments */
+ num_arguments = emit_num_arguments(l);
+ num_required = emit_num_required(l);
+ int gencomma = 0;
+
+ // Now walk the function parameter list and generate code to get arguments
+ for (i = 0, p = l; i < num_arguments; i++) {
+
+ while (checkAttribute(p, "tmap:in:numinputs", "0")) {
+ p = Getattr(p, "tmap:in:next");
+ }
+
+ SwigType *pt = Getattr(p, "type");
+ String *ln = Getattr(p, "lname");
+ String *im_param_type = NewString("");
+ String *c_param_type = NewString("");
+ String *arg = NewString("");
+
+ Printf(arg, "j%s", ln);
+
+ /* Get the ctype types of the parameter */
+ if ((tm = lookupDTypemap(p, "ctype", true))) {
+ Printv(c_param_type, tm, NIL);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_CTYPE_UNDEF, input_file, line_number, "No ctype typemap defined for %s\n", SwigType_str(pt, 0));
+ }
+
+ /* Get the intermediary class parameter types of the parameter */
+ if ((tm = lookupDTypemap(p, "imtype", true))) {
+ const String *inattributes = Getattr(p, "tmap:imtype:inattributes");
+ Printf(im_param_type, "%s%s", inattributes ? inattributes : empty_string, tm);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_IMTYPE_UNDEF, input_file, line_number, "No imtype typemap defined for %s\n", SwigType_str(pt, 0));
+ }
+
+ /* Add parameter to intermediary class method */
+ if (gencomma)
+ Printf(im_dmodule_parameters, ", ");
+ Printf(im_dmodule_parameters, "%s %s", im_param_type, arg);
+
+ // Add parameter to C function
+ Printv(f->def, gencomma ? ", " : "", c_param_type, " ", arg, NIL);
+
+ gencomma = 1;
+
+ // Get typemap for this argument
+ if ((tm = Getattr(p, "tmap:in"))) {
+ canThrow(n, "in", p);
+ Replaceall(tm, "$input", arg);
+ Setattr(p, "emit:input", arg);
+ Printf(f->code, "%s\n", tm);
+ p = Getattr(p, "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(pt, 0));
+ p = nextSibling(p);
+ }
+ Delete(im_param_type);
+ Delete(c_param_type);
+ Delete(arg);
+ }
+
+ /* Insert constraint checking code */
+ for (p = l; p;) {
+ if ((tm = Getattr(p, "tmap:check"))) {
+ canThrow(n, "check", p);
+ Replaceall(tm, "$input", Getattr(p, "emit:input"));
+ Printv(f->code, tm, "\n", NIL);
+ p = Getattr(p, "tmap:check:next");
+ } else {
+ p = nextSibling(p);
+ }
+ }
+
+ /* Insert cleanup code */
+ for (p = l; p;) {
+ if ((tm = Getattr(p, "tmap:freearg"))) {
+ canThrow(n, "freearg", p);
+ Replaceall(tm, "$input", Getattr(p, "emit:input"));
+ Printv(cleanup, tm, "\n", NIL);
+ p = Getattr(p, "tmap:freearg:next");
+ } else {
+ p = nextSibling(p);
+ }
+ }
+
+ /* Insert argument output code */
+ for (p = l; p;) {
+ if ((tm = Getattr(p, "tmap:argout"))) {
+ canThrow(n, "argout", p);
+ Replaceall(tm, "$result", "jresult");
+ Replaceall(tm, "$input", Getattr(p, "emit:input"));
+ Printv(outarg, tm, "\n", NIL);
+ p = Getattr(p, "tmap:argout:next");
+ } else {
+ p = nextSibling(p);
+ }
+ }
+
+ // Look for usage of throws typemap and the canthrow flag
+ ParmList *throw_parm_list = NULL;
+ if ((throw_parm_list = Getattr(n, "catchlist"))) {
+ Swig_typemap_attach_parms("throws", throw_parm_list, f);
+ for (p = throw_parm_list; p; p = nextSibling(p)) {
+ if ((tm = Getattr(p, "tmap:throws"))) {
+ canThrow(n, "throws", p);
+ }
+ }
+ }
+
+ 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("result = (%s) %s;", 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, "result", f, actioncode))) {
+ canThrow(n, "out", n);
+ Replaceall(tm, "$result", "jresult");
+
+ if (GetFlag(n, "feature:new"))
+ Replaceall(tm, "$owner", "1");
+ else
+ Replaceall(tm, "$owner", "0");
+
+ Printf(f->code, "%s", tm);
+ null_attribute = Getattr(n, "tmap:out:null");
+ if (Len(tm))
+ Printf(f->code, "\n");
+ } else {
+ Swig_warning(WARN_TYPEMAP_OUT_UNDEF, input_file, line_number, "Unable to use return type %s in function %s.\n", SwigType_str(t, 0), Getattr(n, "name"));
+ }
+ emit_return_variable(n, t, f);
+ }
+
+ /* Output argument output code */
+ Printv(f->code, outarg, NIL);
+
+ /* Output cleanup code */
+ Printv(f->code, cleanup, NIL);
+
+ /* Look to see if there is any newfree cleanup code */
+ if (GetFlag(n, "feature:new")) {
+ if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
+ canThrow(n, "newfree", n);
+ Printf(f->code, "%s\n", tm);
+ }
+ }
+
+ /* See if there is any return cleanup code */
+ if (!native_function_flag) {
+ if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
+ canThrow(n, "ret", n);
+ Printf(f->code, "%s\n", tm);
+ }
+ }
+
+ // Complete D im parameter list and emit the declaration/binding code.
+ Printv(im_dmodule_parameters, ")", NIL);
+ writeImDModuleFunction(overloaded_name, im_return_type,
+ im_dmodule_parameters, wname);
+ Delete(im_dmodule_parameters);
+
+ // Finish C function header.
+ Printf(f->def, ") {");
+
+ if (!is_void_return)
+ Printv(f->code, " return jresult;\n", NIL);
+ Printf(f->code, "}\n");
+
+ /* Substitute the cleanup code */
+ Replaceall(f->code, "$cleanup", cleanup);
+
+ /* Substitute the function name */
+ Replaceall(f->code, "$symname", symname);
+
+ /* Contract macro modification */
+ if (Replaceall(f->code, "SWIG_contract_assert(", "SWIG_contract_assert($null, ") > 0) {
+ Setattr(n, "d:canthrow", "1");
+ }
+
+ if (!null_attribute)
+ Replaceall(f->code, "$null", "0");
+ else
+ Replaceall(f->code, "$null", null_attribute);
+
+ /* Dump the function out */
+ if (!native_function_flag) {
+ Wrapper_print(f, f_wrappers);
+
+ // Handle %exception which sets the canthrow attribute.
+ if (Getattr(n, "feature:except:canthrow")) {
+ Setattr(n, "d:canthrow", "1");
+ }
+
+ // A very simple check (it is not foolproof) to assist typemap writers
+ // with setting the correct features when the want to throw D exceptions
+ // from C++ code. It checks for the common methods which set
+ // a pending D exception and issues a warning if one of them has been found
+ // in the typemap, but the »canthrow« attribute/feature is not set.
+ if (!Getattr(n, "d:canthrow")) {
+ if (Strstr(f->code, "SWIG_exception")) {
+ Swig_warning(WARN_D_CANTHROW_MISSING, input_file, line_number,
+ "C code contains a call to SWIG_exception and D code does not handle pending exceptions via the canthrow attribute.\n");
+ } else if (Strstr(f->code, "SWIG_DSetPendingException")) {
+ Swig_warning(WARN_D_CANTHROW_MISSING, input_file, line_number,
+ "C code contains a call to a SWIG_DSetPendingException method and D code does not handle pending exceptions via the canthrow attribute.\n");
+ }
+ }
+ }
+
+ // If we are not processing an enum or constant, and we were not generating
+ // a wrapper function which will be accessed via a proxy class, write a
+ // function to the proxy D module.
+ if (!is_wrapping_class()) {
+ writeProxyDModuleFunction(n);
+ }
+
+ // If we are processing a public member variable, write the property-style
+ // member function to the proxy class.
+ if (wrapping_member_flag) {
+ Setattr(n, "proxyfuncname", variable_name);
+ Setattr(n, "imfuncname", symname);
+
+ writeProxyClassFunction(n);
+ }
+
+ Delete(c_return_type);
+ Delete(im_return_type);
+ Delete(cleanup);
+ Delete(outarg);
+ Delete(body);
+ Delete(overloaded_name);
+ DelWrapper(f);
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::nativeWrapper()
+ * --------------------------------------------------------------------------- */
+ virtual int nativeWrapper(Node *n) {
+ String *wrapname = Getattr(n, "wrap:name");
+
+ if (!addSymbol(wrapname, n))
+ return SWIG_ERROR;
+
+ if (Getattr(n, "type")) {
+ Swig_save("nativeWrapper", n, "name", NIL);
+ Setattr(n, "name", wrapname);
+ native_function_flag = true;
+ functionWrapper(n);
+ Swig_restore(n);
+ native_function_flag = false;
+ } else {
+ Swig_error(input_file, line_number, "No return type for %%native method %s.\n", Getattr(n, "wrap:name"));
+ }
+
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::classDirector()
+ * --------------------------------------------------------------------------- */
+ virtual int classDirector(Node *n) {
+ proxy_class_name = NewString(Getattr(n, "sym:name"));
+
+ int success = Language::classDirector(n);
+
+ Delete(proxy_class_name);
+ proxy_class_name = NULL;
+
+ return success;
+ }
+
+
+ /* ---------------------------------------------------------------------------
+ * D::classDirectorInit()
+ * --------------------------------------------------------------------------- */
+ virtual int classDirectorInit(Node *n) {
+ Delete(director_ctor_code);
+ director_ctor_code = NewString("$director_new");
+
+ // Write C++ director class declaration, for example:
+ // class SwigDirector_myclass : public myclass, public Swig::Director {
+ String *classname = Swig_class_name(n);
+ String *directorname = NewStringf("SwigDirector_%s", classname);
+ String *declaration = Swig_class_declaration(n, directorname);
+ const String *base = Getattr(n, "classtype");
+
+ Printf(f_directors_h,
+ "%s : public %s, public Swig::Director {\n", declaration, base);
+ Printf(f_directors_h, "\npublic:\n");
+
+ Delete(declaration);
+ Delete(directorname);
+ Delete(classname);
+
+ // Stash for later.
+ Setattr(n, "director:ctor", NewString("Swig::Director()"));
+
+ // Keep track of the director methods for this class.
+ first_class_dmethod = curr_class_dmethod = n_dmethods;
+
+ director_callback_typedefs = NewString("");
+ director_callback_pointers = NewString("");
+ director_dcallbacks_code = NewString("");
+
+ return Language::classDirectorInit(n);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::classDirectorMethod()
+ *
+ * Emit a virtual director method to pass a method call on to the
+ * underlying D object.
+ * --------------------------------------------------------------------------- */
+ virtual int classDirectorMethod(Node *n, Node *parent, String *super) {
+ String *empty_str = NewString("");
+ String *classname = Getattr(parent, "sym:name");
+ String *c_classname = Getattr(parent, "name");
+ String *name = Getattr(n, "name");
+ String *symname = Getattr(n, "sym:name");
+ SwigType *type = Getattr(n, "type");
+ SwigType *returntype = Getattr(n, "returntype");
+ String *overloaded_name = getOverloadedName(n);
+ String *storage = Getattr(n, "storage");
+ String *value = Getattr(n, "value");
+ String *decl = Getattr(n, "decl");
+ String *declaration = NewString("");
+ String *tm;
+ Parm *p;
+ int i;
+ Wrapper *w = NewWrapper();
+ ParmList *l = Getattr(n, "parms");
+ bool is_void = !(Cmp(returntype, "void"));
+ String *qualified_return = NewString("");
+ bool pure_virtual = (!(Cmp(storage, "virtual")) && !(Cmp(value, "0")));
+ int status = SWIG_OK;
+ bool output_director = true;
+ String *dirclassname = getDirectorClassName(parent);
+ String *qualified_name = NewStringf("%s::%s", dirclassname, name);
+ SwigType *c_ret_type = NULL;
+ String *dcallback_call_args = NewString("");
+ String *imclass_dmethod;
+ String *callback_typedef_parms = NewString("");
+ String *delegate_parms = NewString("");
+ String *proxy_method_param_list = NewString("");
+ String *proxy_callback_return_type = NewString("");
+ String *callback_def = NewString("");
+ String *callback_code = NewString("");
+ String *imcall_args = NewString("");
+ bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
+
+ // Kludge Alert: functionWrapper sets sym:overload properly, but it
+ // isn't at this point, so we have to manufacture it ourselves. At least
+ // we're consistent with the sym:overload name in functionWrapper. (?? when
+ // does the overloaded method name get set?)
+
+ imclass_dmethod = NewStringf("SwigDirector_%s", Swig_name_member(NSPACE_TODO,classname, overloaded_name));
+
+ if (returntype) {
+ qualified_return = SwigType_rcaststr(returntype, "c_result");
+
+ if (!is_void && !ignored_method) {
+ if (!SwigType_isclass(returntype)) {
+ if (!(SwigType_ispointer(returntype) || SwigType_isreference(returntype))) {
+ String *construct_result = NewStringf("= SwigValueInit< %s >()", SwigType_lstr(returntype, 0));
+ Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), construct_result, NIL);
+ Delete(construct_result);
+ } else {
+ String *base_typename = SwigType_base(returntype);
+ String *resolved_typename = SwigType_typedef_resolve_all(base_typename);
+ Symtab *symtab = Getattr(n, "sym:symtab");
+ Node *typenode = Swig_symbol_clookup(resolved_typename, symtab);
+
+ if (SwigType_ispointer(returntype) || (typenode && Getattr(typenode, "abstract"))) {
+ /* initialize pointers to something sane. Same for abstract
+ classes when a reference is returned. */
+ Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= 0", NIL);
+ } else {
+ /* If returning a reference, initialize the pointer to a sane
+ default - if a D exception occurs, then the pointer returns
+ something other than a NULL-initialized reference. */
+ String *non_ref_type = Copy(returntype);
+
+ /* Remove reference and const qualifiers */
+ Replaceall(non_ref_type, "r.", "");
+ Replaceall(non_ref_type, "q(const).", "");
+ Wrapper_add_localv(w, "result_default", "static", SwigType_str(non_ref_type, "result_default"), "=", SwigType_str(non_ref_type, "()"), NIL);
+ Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), "= &result_default", NIL);
+
+ Delete(non_ref_type);
+ }
+
+ Delete(base_typename);
+ Delete(resolved_typename);
+ }
+ } else {
+ SwigType *vt;
+
+ vt = cplus_value_type(returntype);
+ if (!vt) {
+ Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), NIL);
+ } else {
+ Wrapper_add_localv(w, "c_result", SwigType_lstr(vt, "c_result"), NIL);
+ Delete(vt);
+ }
+ }
+ }
+
+ /* Create the intermediate class wrapper */
+ Parm *tp = NewParm(returntype, empty_str, n);
+
+ tm = lookupDTypemap(tp, "imtype");
+ if (tm) {
+ String *imtypeout = Getattr(tp, "tmap:imtype:out");
+ if (imtypeout) {
+ // The type in the imtype typemap's out attribute overrides the type
+ // in the typemap.
+ tm = imtypeout;
+ }
+ Printf(callback_def, "\nprivate extern(C) %s swigDirectorCallback_%s_%s(void* dObject", tm, classname, overloaded_name);
+ Printv(proxy_callback_return_type, tm, NIL);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_IMTYPE_UNDEF, input_file, line_number,
+ "No imtype typemap defined for %s\n", SwigType_str(returntype, 0));
+ }
+
+ Parm *retpm = NewParm(returntype, empty_str, n);
+
+ if ((c_ret_type = Swig_typemap_lookup("ctype", retpm, "", 0))) {
+ if (!is_void && !ignored_method) {
+ String *jretval_decl = NewStringf("%s jresult", c_ret_type);
+ Wrapper_add_localv(w, "jresult", jretval_decl, "= 0", NIL);
+ Delete(jretval_decl);
+ }
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_CTYPE_UNDEF, input_file, line_number,
+ "No ctype typemap defined for %s for use in %s::%s (skipping director method)\n",
+ SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
+ output_director = false;
+ }
+
+ Delete(retpm);
+ }
+
+ /* Go through argument list, attach lnames for arguments */
+ for (i = 0, p = l; p; p = nextSibling(p), ++i) {
+ String *arg = Getattr(p, "name");
+ String *lname = NewString("");
+
+ if (!arg && Cmp(Getattr(p, "type"), "void")) {
+ lname = NewStringf("arg%d", i);
+ Setattr(p, "name", lname);
+ } else
+ lname = arg;
+
+ Setattr(p, "lname", lname);
+ }
+
+ // Attach the standard typemaps.
+ Swig_typemap_attach_parms("out", l, 0);
+ Swig_typemap_attach_parms("ctype", l, 0);
+ Swig_typemap_attach_parms("imtype", l, 0);
+ Swig_typemap_attach_parms("dtype", l, 0);
+ Swig_typemap_attach_parms("directorin", l, 0);
+ Swig_typemap_attach_parms("ddirectorin", l, 0);
+
+ // Preamble code.
+ if (!ignored_method)
+ Printf(w->code, "if (!swig_callback_%s) {\n", overloaded_name);
+
+ if (!pure_virtual) {
+ String *super_call = Swig_method_call(super, l);
+ if (is_void) {
+ Printf(w->code, "%s;\n", super_call);
+ if (!ignored_method)
+ Printf(w->code, "return;\n");
+ } else {
+ Printf(w->code, "return %s;\n", super_call);
+ }
+ Delete(super_call);
+ } else {
+ Printf(w->code, " throw Swig::DirectorPureVirtualException(\"%s::%s\");\n", SwigType_namestr(c_classname), SwigType_namestr(name));
+ }
+
+ if (!ignored_method)
+ Printf(w->code, "} else {\n");
+
+ // Go through argument list.
+ for (i = 0, p = l; p; ++i) {
+ /* Is this superfluous? */
+ while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
+ p = Getattr(p, "tmap:directorin:next");
+ }
+
+ SwigType *pt = Getattr(p, "type");
+ String *ln = makeParameterName(n, p, i, false);
+ String *c_param_type = NULL;
+ String *c_decl = NewString("");
+ String *arg = NewString("");
+
+ Printf(arg, "j%s", ln);
+
+ // Add each parameter to the D callback invocation arguments.
+ Printf(dcallback_call_args, ", %s", arg);
+
+ /* Get parameter's intermediary C type */
+ if ((c_param_type = lookupDTypemap(p, "ctype", true))) {
+ String *ctypeout = Getattr(p, "tmap:ctype:out");
+ if (ctypeout) {
+ // The type in the ctype typemap's out attribute overrides the type
+ // in the typemap itself.
+ c_param_type = ctypeout;
+ }
+
+ /* Add to local variables */
+ Printf(c_decl, "%s %s", c_param_type, arg);
+ if (!ignored_method)
+ Wrapper_add_localv(w, arg, c_decl, (!(SwigType_ispointer(pt) || SwigType_isreference(pt)) ? "" : "= 0"), NIL);
+
+ /* Add input marshalling code */
+ if ((tm = Getattr(p, "tmap:directorin"))) {
+
+ Replaceall(tm, "$input", arg);
+ Replaceall(tm, "$owner", "0");
+
+ if (Len(tm))
+ if (!ignored_method)
+ Printf(w->code, "%s\n", tm);
+
+ Delete(tm);
+
+ // Add parameter type to the C typedef for the D callback function.
+ Printf(callback_typedef_parms, ", %s", c_param_type);
+
+ /* Add parameter to the intermediate class code if generating the
+ * intermediate's upcall code */
+ if ((tm = lookupDTypemap(p, "imtype", true))) {
+ String *imtypeout = Getattr(p, "tmap:imtype:out");
+ if (imtypeout) {
+ // The type in the imtype typemap's out attribute overrides the
+ // type in the typemap itself.
+ tm = imtypeout;
+ }
+ const String *im_directorinattributes = Getattr(p, "tmap:imtype:directorinattributes");
+
+ // TODO: Is this copy really needed?
+ String *din = Copy(lookupDTypemap(p, "ddirectorin", true));
+
+ if (din) {
+ Replaceall(din, "$winput", ln);
+
+ Printf(delegate_parms, ", ");
+ if (i > 0) {
+ Printf(proxy_method_param_list, ", ");
+ Printf(imcall_args, ", ");
+ }
+ Printf(delegate_parms, "%s%s %s", im_directorinattributes ? im_directorinattributes : empty_string, tm, ln);
+
+ if (Cmp(din, ln)) {
+ Printv(imcall_args, din, NIL);
+ } else {
+ Printv(imcall_args, ln, NIL);
+ }
+
+ Delete(din);
+
+ // Get the parameter type in the proxy D class (used later when
+ // generating the overload checking code for the directorConnect
+ // function).
+ if ((tm = lookupDTypemap(p, "dtype", true))) {
+ Printf(proxy_method_param_list, "%s", tm);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number,
+ "No dtype typemap defined for %s\n", SwigType_str(pt, 0));
+ }
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_DDIRECTORIN_UNDEF, input_file, line_number,
+ "No ddirectorin typemap defined for %s for use in %s::%s (skipping director method)\n",
+ SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
+ output_director = false;
+ }
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_IMTYPE_UNDEF, input_file, line_number,
+ "No imtype typemap defined for %s for use in %s::%s (skipping director method)\n",
+ SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
+ output_director = false;
+ }
+
+ p = Getattr(p, "tmap:directorin:next");
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_DDIRECTORIN_UNDEF, input_file, line_number,
+ "No or improper directorin typemap defined for argument %s for use in %s::%s (skipping director method)\n",
+ SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
+ p = nextSibling(p);
+ output_director = false;
+ }
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_CTYPE_UNDEF, input_file, line_number,
+ "No ctype typemap defined for %s for use in %s::%s (skipping director method)\n",
+ SwigType_str(pt, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
+ output_director = false;
+ p = nextSibling(p);
+ }
+
+ Delete(arg);
+ Delete(c_decl);
+ Delete(c_param_type);
+ Delete(ln);
+ }
+
+ /* header declaration, start wrapper definition */
+ String *target;
+ SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type;
+ target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
+ Printf(w->def, "%s", target);
+ Delete(qualified_name);
+ Delete(target);
+ target = Swig_method_decl(rtype, decl, name, l, 0, 1);
+ Printf(declaration, " virtual %s", target);
+ Delete(target);
+
+ // Add any exception specifications to the methods in the director class
+ ParmList *throw_parm_list = NULL;
+ if ((throw_parm_list = Getattr(n, "throws")) || Getattr(n, "throw")) {
+ int gencomma = 0;
+
+ Append(w->def, " throw(");
+ Append(declaration, " throw(");
+
+ if (throw_parm_list)
+ Swig_typemap_attach_parms("throws", throw_parm_list, 0);
+ for (p = throw_parm_list; p; p = nextSibling(p)) {
+ if ((tm = Getattr(p, "tmap:throws"))) {
+ if (gencomma++) {
+ Append(w->def, ", ");
+ Append(declaration, ", ");
+ }
+ Printf(w->def, "%s", SwigType_str(Getattr(p, "type"), 0));
+ Printf(declaration, "%s", SwigType_str(Getattr(p, "type"), 0));
+ }
+ }
+
+ Append(w->def, ")");
+ Append(declaration, ")");
+ }
+
+ Append(w->def, " {");
+ Append(declaration, ";\n");
+
+ // Finish the callback function declaraction.
+ Printf(callback_def, "%s)", delegate_parms);
+ Printf(callback_def, " {\n");
+
+ /* Emit the intermediate class's upcall to the actual class */
+
+ String *upcall = NewStringf("(cast(%s)dObject).%s(%s)", classname, symname, imcall_args);
+
+ if (!is_void) {
+ Parm *tp = NewParm(returntype, empty_str, n);
+
+ // RESEARCH: What happens if there is no ddirectorout typemap?
+ if ((tm = lookupDTypemap(tp, "ddirectorout"))) {
+ Replaceall(tm, "$dcall", upcall);
+
+ Printf(callback_code, " return %s;\n", tm);
+ }
+
+ Delete(tm);
+ Delete(tp);
+ } else {
+ Printf(callback_code, " %s;\n", upcall);
+ }
+
+ Printf(callback_code, "}\n");
+ Delete(upcall);
+
+ if (!ignored_method) {
+ if (!is_void)
+ Printf(w->code, "jresult = (%s) ", c_ret_type);
+
+ Printf(w->code, "swig_callback_%s(d_object%s);\n", overloaded_name, dcallback_call_args);
+
+ if (!is_void) {
+ String *jresult_str = NewString("jresult");
+ String *result_str = NewString("c_result");
+ Parm *tp = NewParm(returntype, result_str, n);
+
+ /* Copy jresult into c_result... */
+ // FIXME: lookupDTypemap?
+ if ((tm = Swig_typemap_lookup("directorout", tp, result_str, w))) {
+ Replaceall(tm, "$input", jresult_str);
+ Replaceall(tm, "$result", result_str);
+ Printf(w->code, "%s\n", tm);
+ } else {
+ Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
+ "Unable to use return type %s used in %s::%s (skipping director method)\n",
+ SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
+ output_director = false;
+ }
+
+ Delete(tp);
+ Delete(jresult_str);
+ Delete(result_str);
+ }
+
+ /* Terminate wrapper code */
+ Printf(w->code, "}\n");
+ if (!is_void)
+ Printf(w->code, "return %s;", qualified_return);
+ }
+
+ Printf(w->code, "}");
+
+ // We expose virtual protected methods via an extra public inline method which makes a straight call to the wrapped class' method
+ String *inline_extra_method = NewString("");
+ if (dirprot_mode() && !is_public(n) && !pure_virtual) {
+ Printv(inline_extra_method, declaration, NIL);
+ String *extra_method_name = NewStringf("%sSwigPublic", name);
+ Replaceall(inline_extra_method, name, extra_method_name);
+ Replaceall(inline_extra_method, ";\n", " {\n ");
+ if (!is_void)
+ Printf(inline_extra_method, "return ");
+ String *methodcall = Swig_method_call(super, l);
+ Printv(inline_extra_method, methodcall, ";\n }\n", NIL);
+ Delete(methodcall);
+ Delete(extra_method_name);
+ }
+
+ /* emit code */
+ if (status == SWIG_OK && output_director) {
+ if (!is_void) {
+ Replaceall(w->code, "$null", qualified_return);
+ } else {
+ Replaceall(w->code, "$null", "");
+ }
+ if (!ignored_method)
+ Printv(director_dcallbacks_code, callback_def, callback_code, NIL);
+ if (!Getattr(n, "defaultargs")) {
+ Wrapper_print(w, f_directors);
+ Printv(f_directors_h, declaration, NIL);
+ Printv(f_directors_h, inline_extra_method, NIL);
+ }
+ }
+
+ if (!ignored_method) {
+ // Register the upcall method so that the callback registering code can
+ // be written later.
+
+ // We cannot directly use n here because its »type« attribute does not
+ // the full return type any longer after Language::functionHandler has
+ // returned.
+ Parm *tp = NewParm(returntype, empty_str, n);
+ String *dp_return_type = lookupDTypemap(tp, "dtype");
+ if (dp_return_type) {
+ String *dtypeout = Getattr(n, "tmap:dtype:out");
+ if (dtypeout) {
+ // The type in the dtype typemap's out attribute overrides the type
+ // in the typemap itself.
+ dp_return_type = dtypeout;
+ replaceClassname(dp_return_type, returntype);
+ }
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number,
+ "No dtype typemap defined for %s\n", SwigType_str(type, 0));
+ dp_return_type = NewString("");
+ }
+
+ UpcallData *udata = addUpcallMethod(imclass_dmethod, symname, decl, overloaded_name, dp_return_type, proxy_method_param_list);
+ Delete(dp_return_type);
+
+ // Write the global callback function pointer on the C code.
+ String *methid = Getattr(udata, "class_methodidx");
+
+ Printf(director_callback_typedefs, " typedef %s (* SWIG_Callback%s_t)", c_ret_type, methid);
+ Printf(director_callback_typedefs, "(void *dobj%s);\n", callback_typedef_parms);
+ Printf(director_callback_pointers, " SWIG_Callback%s_t swig_callback_%s;\n", methid, overloaded_name);
+
+ // Write the type alias for the callback to the intermediary D module.
+ String* proxy_callback_type = NewString("");
+ Printf(proxy_callback_type, "SwigDirector_%s_Callback%s", classname, methid);
+ Printf(im_dmodule_code, "alias extern(C) %s function(void*%s) %s;\n", proxy_callback_return_type, delegate_parms, proxy_callback_type);
+ Delete(proxy_callback_type);
+ }
+
+ Delete(qualified_return);
+ Delete(c_ret_type);
+ Delete(declaration);
+ Delete(callback_typedef_parms);
+ Delete(delegate_parms);
+ Delete(proxy_method_param_list);
+ Delete(callback_def);
+ Delete(callback_code);
+ DelWrapper(w);
+
+ return status;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::classDirectorConstructor()
+ * --------------------------------------------------------------------------- */
+ virtual int classDirectorConstructor(Node *n) {
+ Node *parent = parentNode(n);
+ String *decl = Getattr(n, "decl");;
+ String *supername = Swig_class_name(parent);
+ String *classname = getDirectorClassName(parent);
+ String *sub = NewString("");
+ Parm *p;
+ ParmList *superparms = Getattr(n, "parms");
+ ParmList *parms;
+ int argidx = 0;
+
+ /* Assign arguments to superclass's parameters, if not already done */
+ for (p = superparms; p; p = nextSibling(p)) {
+ String *pname = Getattr(p, "name");
+
+ if (!pname) {
+ pname = NewStringf("arg%d", argidx++);
+ Setattr(p, "name", pname);
+ }
+ }
+
+ // TODO: Is this copy needed?
+ parms = CopyParmList(superparms);
+
+ if (!Getattr(n, "defaultargs")) {
+ /* constructor */
+ {
+ String *basetype = Getattr(parent, "classtype");
+ String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
+ String *call = Swig_csuperclass_call(0, basetype, superparms);
+ String *classtype = SwigType_namestr(Getattr(n, "name"));
+
+ Printf(f_directors, "%s::%s : %s, %s {\n", classname, target, call, Getattr(parent, "director:ctor"));
+ Printf(f_directors, " swig_init_callbacks();\n");
+ Printf(f_directors, "}\n\n");
+
+ Delete(classtype);
+ Delete(target);
+ Delete(call);
+ }
+
+ /* constructor header */
+ {
+ String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
+ Printf(f_directors_h, " %s;\n", target);
+ Delete(target);
+ }
+ }
+
+ Delete(sub);
+ Delete(supername);
+ Delete(parms);
+ return Language::classDirectorConstructor(n);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::classDirectorDefaultConstructor()
+ * --------------------------------------------------------------------------- */
+ virtual int classDirectorDefaultConstructor(Node *n) {
+ String *classname = Swig_class_name(n);
+ String *classtype = SwigType_namestr(Getattr(n, "name"));
+ Wrapper *w = NewWrapper();
+
+ Printf(w->def, "SwigDirector_%s::SwigDirector_%s() : %s {", classname, classname, Getattr(n, "director:ctor"));
+ Printf(w->code, "}\n");
+ Wrapper_print(w, f_directors);
+
+ Printf(f_directors_h, " SwigDirector_%s();\n", classname);
+ DelWrapper(w);
+ Delete(classtype);
+ Delete(classname);
+ return Language::classDirectorDefaultConstructor(n);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::classDirectorDestructor()
+ * --------------------------------------------------------------------------- */
+ virtual int classDirectorDestructor(Node *n) {
+ Node *current_class = getCurrentClass();
+ String *classname = Swig_class_name(current_class);
+ Wrapper *w = NewWrapper();
+
+ if (Getattr(n, "throw")) {
+ Printf(f_directors_h, " virtual ~SwigDirector_%s() throw ();\n", classname);
+ Printf(w->def, "SwigDirector_%s::~SwigDirector_%s() throw () {\n", classname, classname);
+ } else {
+ Printf(f_directors_h, " virtual ~SwigDirector_%s();\n", classname);
+ Printf(w->def, "SwigDirector_%s::~SwigDirector_%s() {\n", classname, classname);
+ }
+
+ Printv(w->code, "}\n", NIL);
+
+ Wrapper_print(w, f_directors);
+
+ DelWrapper(w);
+ Delete(classname);
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::classDirectorEnd()
+ * --------------------------------------------------------------------------- */
+ virtual int classDirectorEnd(Node *n) {
+ int i;
+ String *director_classname = getDirectorClassName(n);
+
+ Wrapper *w = NewWrapper();
+
+ if (Len(director_callback_typedefs) > 0) {
+ Printf(f_directors_h, "\n%s", director_callback_typedefs);
+ }
+
+ Printf(f_directors_h, " void swig_connect_director(void* dobj");
+
+ Printf(w->def, "void %s::swig_connect_director(void* dobj", director_classname);
+ Printf(w->code, "d_object = dobj;");
+
+ for (i = first_class_dmethod; i < curr_class_dmethod; ++i) {
+ UpcallData *udata = Getitem(dmethods_seq, i);
+ String *methid = Getattr(udata, "class_methodidx");
+ String *overname = Getattr(udata, "overname");
+
+ Printf(f_directors_h, ", SWIG_Callback%s_t callback%s", methid, overname);
+ Printf(w->def, ", SWIG_Callback%s_t callback_%s", methid, overname);
+ Printf(w->code, "swig_callback_%s = callback_%s;\n", overname, overname);
+ }
+
+ Printf(f_directors_h, ");\n");
+ Printf(w->def, ") {");
+
+ Printf(f_directors_h, "\nprivate:\n");
+ Printf(f_directors_h, " void swig_init_callbacks();\n");
+ Printf(f_directors_h, " void *d_object;\n");
+ if (Len(director_callback_typedefs) > 0) {
+ Printf(f_directors_h, "%s", director_callback_pointers);
+ }
+ Printf(f_directors_h, "};\n\n");
+ Printf(w->code, "}\n\n");
+
+ Printf(w->code, "void %s::swig_init_callbacks() {\n", director_classname);
+ for (i = first_class_dmethod; i < curr_class_dmethod; ++i) {
+ UpcallData *udata = Getitem(dmethods_seq, i);
+ String *overname = Getattr(udata, "overname");
+ Printf(w->code, "swig_callback_%s = 0;\n", overname);
+ }
+ Printf(w->code, "}");
+
+ Wrapper_print(w, f_directors);
+
+ DelWrapper(w);
+
+ return Language::classDirectorEnd(n);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::classDirectorDisown()
+ * --------------------------------------------------------------------------- */
+ virtual int classDirectorDisown(Node *n) {
+ (void) n;
+ return SWIG_OK;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::replaceSpecialVariables()
+ * --------------------------------------------------------------------------- */
+ virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) {
+ (void)method;
+ SwigType *type = Getattr(parm, "type");
+
+ // Just assume that this goes to the proxy class, we cannot know.
+ replaceClassname(tm, type);
+ }
+
+protected:
+ /* ---------------------------------------------------------------------------
+ * D::extraDirectorProtectedCPPMethodsRequired()
+ * --------------------------------------------------------------------------- */
+ virtual bool extraDirectorProtectedCPPMethodsRequired() const {
+ return false;
+ }
+
+private:
+ /* ---------------------------------------------------------------------------
+ * D::writeImDModuleFunction()
+ *
+ * Writes a function declaration for the given (C) wrapper function to the
+ * intermediary D module.
+ *
+ * d_name - The name the function in the intermediary D module will get.
+ * wrapper_function_name - The name of the exported function in the C wrapper
+ * (usually d_name prefixed by »D_«).
+ * --------------------------------------------------------------------------- */
+ void writeImDModuleFunction(const_String_or_char_ptr d_name,
+ const_String_or_char_ptr return_type, const_String_or_char_ptr parameters,
+ const_String_or_char_ptr wrapper_function_name) {
+
+ // TODO: Add support for static linking here.
+ Printf(im_dmodule_code, "extern(C) %s function%s %s;\n", return_type,
+ parameters, d_name);
+ Printv(wrapper_loader_bind_code, wrapper_loader_bind_command, NIL);
+ Replaceall(wrapper_loader_bind_code, "$function", d_name);
+ Replaceall(wrapper_loader_bind_code, "$symbol", wrapper_function_name);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::writeProxyClassFunction()
+ *
+ * Creates a D proxy function for a C++ function in the wrapped class. Used
+ * for both static and non-static C++ class functions.
+ *
+ * The Node must contain two extra attributes.
+ * - "proxyfuncname": The name of the D proxy function.
+ * - "imfuncname": The corresponding function in the intermediary D module.
+ * --------------------------------------------------------------------------- */
+ void writeProxyClassFunction(Node *n) {
+ SwigType *t = Getattr(n, "type");
+ ParmList *l = Getattr(n, "parms");
+ String *intermediary_function_name = Getattr(n, "imfuncname");
+ String *proxy_function_name = Getattr(n, "proxyfuncname");
+ String *tm;
+ Parm *p;
+ int i;
+ String *imcall = NewString("");
+ String *return_type = NewString("");
+ String *function_code = NewString("");
+ bool setter_flag = false;
+ String *pre_code = NewString("");
+ String *post_code = NewString("");
+ String *terminator_code = NewString("");
+
+ // Wrappers not wanted for some methods where the parameters cannot be
+ // overloaded in D.
+ if (Getattr(n, "overload:ignore"))
+ return;
+
+ // Don't generate proxy method for additional explicitcall method used in
+ // directors.
+ if (GetFlag(n, "explicitcall"))
+ return;
+
+ // RESEARCH: What is this good for?
+ if (l) {
+ if (SwigType_type(Getattr(l, "type")) == T_VOID) {
+ l = nextSibling(l);
+ }
+ }
+
+ /* Attach the non-standard typemaps to the parameter list */
+ Swig_typemap_attach_parms("in", l, NULL);
+ Swig_typemap_attach_parms("dtype", l, NULL);
+ Swig_typemap_attach_parms("din", l, NULL);
+
+ // Get return types.
+ if ((tm = lookupDTypemap(n, "dtype"))) {
+ String *dtypeout = Getattr(n, "tmap:dtype:out");
+ if (dtypeout) {
+ // The type in the dtype typemap's out attribute overrides the type in
+ // the typemap.
+ tm = dtypeout;
+ replaceClassname(tm, t);
+ }
+ Printf(return_type, "%s", tm);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number,
+ "No dtype typemap defined for %s\n", SwigType_str(t, 0));
+ }
+
+ if (wrapping_member_flag) {
+ // Check if this is a setter method for a public member.
+ setter_flag = (Cmp(Getattr(n, "sym:name"),
+ Swig_name_set(NSPACE_TODO,Swig_name_member(NSPACE_TODO,proxy_class_name, variable_name))) == 0);
+ }
+
+ // Write function modifiers.
+ {
+ String *modifiers;
+
+ const String *mods_override = Getattr(n, "feature:d:methodmodifiers");
+ if (mods_override) {
+ modifiers = Copy(mods_override);
+ } else {
+ modifiers = Copy(is_public(n) ? public_string : protected_string);
+
+ if (Getattr(n, "override")) {
+ Printf(modifiers, " override");
+ }
+ }
+
+ if (is_smart_pointer()) {
+ // Smart pointer classes do not mirror the inheritance hierarchy of the
+ // underlying pointer type, so no override required.
+ Replaceall(modifiers, "override", "");
+ }
+
+ Chop(modifiers);
+
+ if (static_flag) {
+ Printf(modifiers, " static");
+ }
+
+ Printf(function_code, "%s ", modifiers);
+ Delete(modifiers);
+ }
+
+ // Complete the function declaration up to the parameter list.
+ Printf(function_code, "%s %s(", return_type, proxy_function_name);
+
+ // Write the wrapper function call up to the parameter list.
+ Printv(imcall, im_dmodule_fq_name, ".$imfuncname(", NIL);
+ if (!static_flag) {
+ Printf(imcall, "cast(void*)swigCPtr");
+ }
+
+ String *proxy_param_types = NewString("");
+
+ // Write the parameter list for the proxy function declaration and the
+ // wrapper function call.
+ emit_mark_varargs(l);
+ int gencomma = !static_flag;
+ for (i = 0, p = l; p; i++) {
+ // Ignored varargs.
+ if (checkAttribute(p, "varargs:ignore", "1")) {
+ p = nextSibling(p);
+ continue;
+ }
+
+ // Ignored parameters.
+ if (checkAttribute(p, "tmap:in:numinputs", "0")) {
+ p = Getattr(p, "tmap:in:next");
+ continue;
+ }
+
+ // Ignore the 'this' argument for variable wrappers.
+ if (!(variable_wrapper_flag && i == 0)) {
+ String *param_name = makeParameterName(n, p, i, setter_flag);
+ SwigType *pt = Getattr(p, "type");
+
+ // Write the wrapper function call argument.
+ {
+ if (gencomma) {
+ Printf(imcall, ", ");
+ }
+
+ if ((tm = lookupDTypemap(p, "din", true))) {
+ Replaceall(tm, "$dinput", param_name);
+ String *pre = Getattr(p, "tmap:din:pre");
+ if (pre) {
+ replaceClassname(pre, pt);
+ Replaceall(pre, "$dinput", param_name);
+ if (Len(pre_code) > 0)
+ Printf(pre_code, "\n");
+ Printv(pre_code, pre, NIL);
+ }
+ String *post = Getattr(p, "tmap:din:post");
+ if (post) {
+ replaceClassname(post, pt);
+ Replaceall(post, "$dinput", param_name);
+ if (Len(post_code) > 0)
+ Printf(post_code, "\n");
+ Printv(post_code, post, NIL);
+ }
+ String *terminator = Getattr(p, "tmap:din:terminator");
+ if (terminator) {
+ replaceClassname(terminator, pt);
+ Replaceall(terminator, "$dinput", param_name);
+ if (Len(terminator_code) > 0)
+ Insert(terminator_code, 0, "\n");
+ Insert(terminator_code, 0, terminator);
+ }
+ Printv(imcall, tm, NIL);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_DIN_UNDEF, input_file, line_number,
+ "No din typemap defined for %s\n", SwigType_str(pt, 0));
+ }
+ }
+
+ // Write the D proxy function parameter.
+ {
+ String *proxy_type = NewString("");
+
+ if ((tm = lookupDTypemap(p, "dtype"))) {
+ const String *inattributes = Getattr(p, "tmap:dtype:inattributes");
+ Printf(proxy_type, "%s%s", inattributes ? inattributes : empty_string, tm);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number,
+ "No dtype typemap defined for %s\n", SwigType_str(pt, 0));
+ }
+
+ if (gencomma >= 2) {
+ Printf(function_code, ", ");
+ Printf(proxy_param_types, ", ");
+ }
+ gencomma = 2;
+ Printf(function_code, "%s %s", proxy_type, param_name);
+ Append(proxy_param_types, proxy_type);
+
+ Delete(proxy_type);
+ }
+
+ Delete(param_name);
+ }
+ p = Getattr(p, "tmap:in:next");
+ }
+
+ Printf(imcall, ")");
+ Printf(function_code, ") ");
+
+ if (d_version > 1 && wrapping_member_flag) {
+ Printf(function_code, "@property ");
+ }
+
+ if (wrapMemberFunctionAsDConst(n)) {
+ Printf(function_code, "const ");
+ }
+
+ // Lookup the code used to convert the wrapper return value to the proxy
+ // function return type.
+ if ((tm = lookupDTypemap(n, "dout"))) {
+ replaceExcode(n, tm, "dout", n);
+ bool is_pre_code = Len(pre_code) > 0;
+ bool is_post_code = Len(post_code) > 0;
+ bool is_terminator_code = Len(terminator_code) > 0;
+ if (is_pre_code || is_post_code || is_terminator_code) {
+ if (is_post_code) {
+ Insert(tm, 0, "\n try ");
+ Printv(tm, " finally {\n", post_code, "\n }", NIL);
+ } else {
+ Insert(tm, 0, "\n ");
+ }
+ if (is_pre_code) {
+ Insert(tm, 0, pre_code);
+ Insert(tm, 0, "\n");
+ }
+ if (is_terminator_code) {
+ Printv(tm, "\n", terminator_code, NIL);
+ }
+ Insert(tm, 0, "{");
+ Printv(tm, "}", NIL);
+ }
+ if (GetFlag(n, "feature:new"))
+ Replaceall(tm, "$owner", "true");
+ else
+ Replaceall(tm, "$owner", "false");
+ replaceClassname(tm, t);
+
+ // For director methods: generate code to selectively make a normal
+ // polymorphic call or an explicit method call. Needed to prevent infinite
+ // recursion when calling director methods.
+ Node *explicit_n = Getattr(n, "explicitcallnode");
+ if (explicit_n) {
+ String *ex_overloaded_name = getOverloadedName(explicit_n);
+ String *ex_intermediary_function_name = Swig_name_member(NSPACE_TODO,proxy_class_name, ex_overloaded_name);
+
+ String *ex_imcall = Copy(imcall);
+ Replaceall(ex_imcall, "$imfuncname", ex_intermediary_function_name);
+ Replaceall(imcall, "$imfuncname", intermediary_function_name);
+
+ String *excode = NewString("");
+ if (!Cmp(return_type, "void"))
+ Printf(excode, "if (swigIsMethodOverridden!(%s delegate(%s), %s function(%s), %s)()) %s; else %s",
+ return_type, proxy_param_types, return_type, proxy_param_types, proxy_function_name, ex_imcall, imcall);
+ else
+ Printf(excode, "((swigIsMethodOverridden!(%s delegate(%s), %s function(%s), %s)()) ? %s : %s)",
+ return_type, proxy_param_types, return_type, proxy_param_types, proxy_function_name, ex_imcall, imcall);
+
+ Clear(imcall);
+ Printv(imcall, excode, NIL);
+ Delete(ex_overloaded_name);
+ Delete(excode);
+ } else {
+ Replaceall(imcall, "$imfuncname", intermediary_function_name);
+ }
+ Replaceall(tm, "$imcall", imcall);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_DOUT_UNDEF, input_file, line_number,
+ "No dout typemap defined for %s\n", SwigType_str(t, 0));
+ }
+
+ Delete(proxy_param_types);
+
+ // The whole function body is now in stored tm (if there was a matching type
+ // map, of course), so simply append it to the code buffer. The braces are
+ // included in the typemap.
+ Printv(function_code, tm, NIL);
+
+ // Write function code buffer to the class code.
+ Printv(proxy_class_body_code, "\n", function_code, "\n", NIL);
+
+ Delete(pre_code);
+ Delete(post_code);
+ Delete(terminator_code);
+ Delete(function_code);
+ Delete(return_type);
+ Delete(imcall);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::writeProxyDModuleFunction()
+ * --------------------------------------------------------------------------- */
+ void writeProxyDModuleFunction(Node *n) {
+ SwigType *t = Getattr(n, "type");
+ ParmList *l = Getattr(n, "parms");
+ String *tm;
+ Parm *p;
+ int i;
+ String *imcall = NewString("");
+ String *return_type = NewString("");
+ String *function_code = NewString("");
+ int num_arguments = 0;
+ int num_required = 0;
+ String *overloaded_name = getOverloadedName(n);
+ String *func_name = NULL;
+ String *pre_code = NewString("");
+ String *post_code = NewString("");
+ String *terminator_code = NewString("");
+
+ // RESEARCH: What is this good for?
+ if (l) {
+ if (SwigType_type(Getattr(l, "type")) == T_VOID) {
+ l = nextSibling(l);
+ }
+ }
+
+ /* Attach the non-standard typemaps to the parameter list */
+ Swig_typemap_attach_parms("dtype", l, NULL);
+ Swig_typemap_attach_parms("din", l, NULL);
+
+ /* Get return types */
+ if ((tm = lookupDTypemap(n, "dtype"))) {
+ String *dtypeout = Getattr(n, "tmap:dtype:out");
+ if (dtypeout) {
+ // The type in the dtype typemap's out attribute overrides the type in
+ // the typemap.
+ tm = dtypeout;
+ replaceClassname(tm, t);
+ }
+ Printf(return_type, "%s", tm);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number,
+ "No dtype typemap defined for %s\n", SwigType_str(t, 0));
+ }
+
+ /* Change function name for global variables */
+ if (global_variable_flag) {
+ // RESEARCH: Is the Copy() needed here?
+ func_name = Copy(variable_name);
+ } else {
+ func_name = Copy(Getattr(n, "sym:name"));
+ }
+
+ /* Start generating the function */
+ const String *outattributes = Getattr(n, "tmap:dtype:outattributes");
+ if (outattributes)
+ Printf(function_code, " %s\n", outattributes);
+
+ const String *methodmods = Getattr(n, "feature:d:methodmodifiers");
+ // TODO: Check if is_public(n) could possibly make any sense here
+ // (private global functions would be useless anyway?).
+ methodmods = methodmods ? methodmods : empty_string;
+
+ Printf(function_code, "\n%s%s %s(", methodmods, return_type, func_name);
+ Printv(imcall, im_dmodule_fq_name, ".", overloaded_name, "(", NIL);
+
+ /* Get number of required and total arguments */
+ num_arguments = emit_num_arguments(l);
+ num_required = emit_num_required(l);
+
+ int gencomma = 0;
+
+ /* Output each parameter */
+ for (i = 0, p = l; i < num_arguments; i++) {
+
+ /* Ignored parameters */
+ while (checkAttribute(p, "tmap:in:numinputs", "0")) {
+ p = Getattr(p, "tmap:in:next");
+ }
+
+ SwigType *pt = Getattr(p, "type");
+ String *param_type = NewString("");
+
+ // Get the D parameter type.
+ if ((tm = lookupDTypemap(p, "dtype", true))) {
+ const String *inattributes = Getattr(p, "tmap:dtype:inattributes");
+ Printf(param_type, "%s%s", inattributes ? inattributes : empty_string, tm);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number,
+ "No dtype typemap defined for %s\n", SwigType_str(pt, 0));
+ }
+
+ if (gencomma)
+ Printf(imcall, ", ");
+
+ const bool generating_setter = global_variable_flag || wrapping_member_flag;
+ String *arg = makeParameterName(n, p, i, generating_setter);
+
+ // Get the D code to convert the parameter value to the type used in the
+ // wrapper D module.
+ if ((tm = lookupDTypemap(p, "din", true))) {
+ Replaceall(tm, "$dinput", arg);
+ String *pre = Getattr(p, "tmap:din:pre");
+ if (pre) {
+ replaceClassname(pre, pt);
+ Replaceall(pre, "$dinput", arg);
+ if (Len(pre_code) > 0)
+ Printf(pre_code, "\n");
+ Printv(pre_code, pre, NIL);
+ }
+ String *post = Getattr(p, "tmap:din:post");
+ if (post) {
+ replaceClassname(post, pt);
+ Replaceall(post, "$dinput", arg);
+ if (Len(post_code) > 0)
+ Printf(post_code, "\n");
+ Printv(post_code, post, NIL);
+ }
+ String *terminator = Getattr(p, "tmap:din:terminator");
+ if (terminator) {
+ replaceClassname(terminator, pt);
+ Replaceall(terminator, "$dinput", arg);
+ if (Len(terminator_code) > 0)
+ Insert(terminator_code, 0, "\n");
+ Insert(terminator_code, 0, terminator);
+ }
+ Printv(imcall, tm, NIL);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_DIN_UNDEF, input_file, line_number,
+ "No din typemap defined for %s\n", SwigType_str(pt, 0));
+ }
+
+ /* Add parameter to module class function */
+ if (gencomma >= 2)
+ Printf(function_code, ", ");
+ gencomma = 2;
+ Printf(function_code, "%s %s", param_type, arg);
+
+ p = Getattr(p, "tmap:in:next");
+ Delete(arg);
+ Delete(param_type);
+ }
+
+ Printf(imcall, ")");
+ Printf(function_code, ") ");
+
+ if (global_variable_flag && (d_version > 1)) {
+ Printf(function_code, "@property ");
+ }
+
+ // Lookup the code used to convert the wrapper return value to the proxy
+ // function return type.
+ if ((tm = lookupDTypemap(n, "dout"))) {
+ replaceExcode(n, tm, "dout", n);
+ bool is_pre_code = Len(pre_code) > 0;
+ bool is_post_code = Len(post_code) > 0;
+ bool is_terminator_code = Len(terminator_code) > 0;
+ if (is_pre_code || is_post_code || is_terminator_code) {
+ if (is_post_code) {
+ Insert(tm, 0, "\n try ");
+ Printv(tm, " finally {\n", post_code, "\n }", NIL);
+ } else {
+ Insert(tm, 0, "\n ");
+ }
+ if (is_pre_code) {
+ Insert(tm, 0, pre_code);
+ Insert(tm, 0, "\n");
+ }
+ if (is_terminator_code) {
+ Printv(tm, "\n", terminator_code, NIL);
+ }
+ Insert(tm, 0, " {");
+ Printf(tm, "\n}");
+ }
+ if (GetFlag(n, "feature:new"))
+ Replaceall(tm, "$owner", "true");
+ else
+ Replaceall(tm, "$owner", "false");
+ replaceClassname(tm, t);
+ Replaceall(tm, "$imcall", imcall);
+ } else {
+ Swig_warning(WARN_D_TYPEMAP_DOUT_UNDEF, input_file, line_number,
+ "No dout typemap defined for %s\n", SwigType_str(t, 0));
+ }
+
+ // The whole function code is now stored in tm (if there was a matching
+ // type map, of course), so simply append it to the code buffer.
+ Printf(function_code, "%s\n", tm ? (const String *) tm : empty_string);
+ Printv(proxy_dmodule_code, function_code, NIL);
+
+ Delete(pre_code);
+ Delete(post_code);
+ Delete(terminator_code);
+ Delete(function_code);
+ Delete(return_type);
+ Delete(imcall);
+ Delete(func_name);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::writeProxyClassAndUpcasts()
+ * --------------------------------------------------------------------------- */
+ void writeProxyClassAndUpcasts(Node *n) {
+ SwigType *typemap_lookup_type = Getattr(n, "classtypeobj");
+
+ /*
+ * Handle inheriting from D and C++ classes.
+ */
+
+ String *c_classname = SwigType_namestr(Getattr(n, "name"));
+ String *c_baseclass = NULL;
+ String *baseclass = NULL;
+ String *c_baseclassname = NULL;
+
+ // Inheritance from pure D classes.
+ Node *attributes = NewHash();
+ const String *pure_baseclass =
+ lookupCodeTypemap(n, "dbase", typemap_lookup_type, WARN_NONE, attributes);
+ bool purebase_replace = GetFlag(attributes, "tmap:dbase:replace") ? true : false;
+ bool purebase_notderived = GetFlag(attributes, "tmap:dbase:notderived") ? true : false;
+ Delete(attributes);
+
+ // C++ inheritance.
+ if (!purebase_replace) {
+ List *baselist = Getattr(n, "bases");
+ if (baselist) {
+ Iterator base = First(baselist);
+ while (base.item && GetFlag(base.item, "feature:ignore")) {
+ base = Next(base);
+ }
+ if (base.item) {
+ c_baseclassname = Getattr(base.item, "name");
+ baseclass = Copy(getProxyName(c_baseclassname));
+ if (baseclass)
+ c_baseclass = SwigType_namestr(Getattr(base.item, "name"));
+ base = Next(base);
+ /* Warn about multiple inheritance for additional base class(es) */
+ while (base.item) {
+ if (GetFlag(base.item, "feature:ignore")) {
+ base = Next(base);
+ continue;
+ }
+ String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
+ String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0);
+ Swig_warning(WARN_D_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
+ "Base %s of class %s ignored: multiple inheritance is not supported in D.\n", baseclassname, proxyclassname);
+ base = Next(base);
+ }
+ }
+ }
+ }
+
+ bool derived = baseclass && getProxyName(c_baseclassname);
+
+ if (derived && purebase_notderived) {
+ pure_baseclass = empty_string;
+ }
+ const String *wanted_base = baseclass ? baseclass : pure_baseclass;
+
+ if (purebase_replace) {
+ wanted_base = pure_baseclass;
+ derived = false;
+ Delete(baseclass);
+ baseclass = NULL;
+ if (purebase_notderived) {
+ Swig_error(Getfile(n), Getline(n),
+ "The dbase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n",
+ typemap_lookup_type);
+ }
+ } else if (baseclass && Len(pure_baseclass) > 0) {
+ Swig_warning(WARN_D_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
+ "Warning for %s proxy: Base class %s ignored. Multiple inheritance is not supported in D. "
+ "Perhaps you need one of the 'replace' or 'notderived' attributes in the dbase typemap?\n", typemap_lookup_type, pure_baseclass);
+ }
+
+ // Add code to do C++ casting to base class (only for classes in an inheritance hierarchy)
+ if (derived) {
+ writeClassUpcast(n, proxy_class_name, c_classname, c_baseclass);
+ }
+
+ /*
+ * Write needed imports.
+ */
+ // If this class is derived from a C++ class, we need to have the D class
+ // generated for it in scope.
+ if (derived) {
+ requireDType(baseclass);
+
+ if (split_proxy_dmodule) {
+ // Fully qualify the baseclass name.
+ String *module = NewStringf("%s%s.", package, baseclass);
+ Insert(baseclass, 0, module);
+ Delete(module);
+ }
+ }
+
+ // Write any custom import statements to the proxy module header.
+ const String *imports = lookupCodeTypemap(n, "dimports", typemap_lookup_type, WARN_NONE);
+ if (Len(imports) > 0) {
+ String* imports_trimmed = Copy(imports);
+ Chop(imports_trimmed);
+ replaceImportTypeMacros(imports_trimmed);
+ Printv(proxy_class_imports, imports_trimmed, "\n", NIL);
+ Delete(imports_trimmed);
+ }
+
+ /*
+ * Write the proxy class header.
+ */
+ // Class modifiers.
+ const String *modifiers =
+ lookupCodeTypemap(n, "dclassmodifiers", typemap_lookup_type, WARN_D_TYPEMAP_CLASSMOD_UNDEF);
+
+ // User-defined interfaces.
+ const String *interfaces =
+ lookupCodeTypemap(n, derived ? "dinterfaces_derived" : "dinterfaces", typemap_lookup_type, WARN_NONE);
+
+ Printv(proxy_class_code,
+ "\n",
+ modifiers,
+ " $dclassname",
+ (*Char(wanted_base) || *Char(interfaces)) ? " : " : "", wanted_base,
+ (*Char(wanted_base) && *Char(interfaces)) ? ", " : "", interfaces, " {",
+ NIL);
+
+ /*
+ * Write the proxy class body.
+ */
+ String* body = NewString("");
+
+ // Default class body.
+ const String *dbody;
+ if (derived) {
+ dbody = lookupCodeTypemap(n, "dbody_derived", typemap_lookup_type, WARN_D_TYPEMAP_DBODY_UNDEF);
+ } else {
+ dbody = lookupCodeTypemap(n, "dbody", typemap_lookup_type, WARN_D_TYPEMAP_DBODY_UNDEF);
+ }
+
+ Printv(body, dbody, NIL);
+
+ // Destructor and dispose().
+ // If the C++ destructor is accessible (public), it is wrapped by the
+ // dispose() method which is also called by the emitted D constructor. If it
+ // is not accessible, no D destructor is written and the generated dispose()
+ // method throws an exception.
+ // This enables C++ classes with protected or private destructors to be used
+ // in D as it would be used in C++ (GC finalization is a no-op then because
+ // of the empty D destructor) while preventing usage in »scope« variables.
+ // The method name for the dispose() method is specified in a typemap
+ // attribute called »methodname«.
+ const String *tm = NULL;
+
+ String *dispose_methodname;
+ String *dispose_methodmodifiers;
+ attributes = NewHash();
+ if (derived) {
+ tm = lookupCodeTypemap(n, "ddispose_derived", typemap_lookup_type, WARN_NONE, attributes);
+ dispose_methodname = Getattr(attributes, "tmap:ddispose_derived:methodname");
+ dispose_methodmodifiers = Getattr(attributes, "tmap:ddispose_derived:methodmodifiers");
+ } else {
+ tm = lookupCodeTypemap(n, "ddispose", typemap_lookup_type, WARN_NONE, attributes);
+ dispose_methodname = Getattr(attributes, "tmap:ddispose:methodname");
+ dispose_methodmodifiers = Getattr(attributes, "tmap:ddispose:methodmodifiers");
+ }
+
+ if (tm && *Char(tm)) {
+ if (!dispose_methodname) {
+ Swig_error(Getfile(n), Getline(n),
+ "No methodname attribute defined in the ddispose%s typemap for %s\n",
+ (derived ? "_derived" : ""), proxy_class_name);
+ }
+ if (!dispose_methodmodifiers) {
+ Swig_error(Getfile(n), Getline(n),
+ "No methodmodifiers attribute defined in ddispose%s typemap for %s.\n",
+ (derived ? "_derived" : ""), proxy_class_name);
+ }
+ }
+
+ if (tm) {
+ // Write the destructor if the C++ one is accessible.
+ if (*Char(destructor_call)) {
+ Printv(body,
+ lookupCodeTypemap(n, "ddestructor", typemap_lookup_type, WARN_NONE), NIL);
+ }
+
+ // Write the dispose() method.
+ String *dispose_code = NewString("");
+ Printv(dispose_code, tm, NIL);
+
+ if (*Char(destructor_call)) {
+ Replaceall(dispose_code, "$imcall", destructor_call);
+ } else {
+ Replaceall(dispose_code, "$imcall", "throw new object.Exception(\"C++ destructor does not have public access\")");
+ }
+
+ if (*Char(dispose_code)) {
+ Printv(body, "\n", dispose_methodmodifiers,
+ (derived ? " override" : ""), " void ", dispose_methodname, "() ",
+ dispose_code, "\n", NIL);
+ }
+ }
+
+ if (Swig_directorclass(n)) {
+ // If directors are enabled for the current class, generate the
+ // director connect helper function which is called from the constructor
+ // and write it to the class body.
+ writeDirectorConnectProxy();
+ }
+
+ // Write all constants and enumerations first to prevent forward reference
+ // errors.
+ Printv(body, proxy_class_enums_code, NIL);
+
+ // Write the code generated in other methods to the class body.
+ Printv(body, proxy_class_body_code, NIL);
+
+ // Append extra user D code to the class body.
+ Printv(body,
+ lookupCodeTypemap(n, "dcode", typemap_lookup_type, WARN_NONE), "\n", NIL);
+
+ // Write the class body and the curly bracket closing the class definition
+ // to the proxy module.
+ indentCode(body);
+ Replaceall(body, "$dbaseclass", baseclass);
+ Delete(baseclass);
+
+ Printv(proxy_class_code, body, "\n}\n", NIL);
+ Delete(body);
+
+ // Write the epilogue code if there is any.
+ Printv(proxy_class_code, proxy_class_epilogue_code, NIL);
+ }
+
+
+ /* ---------------------------------------------------------------------------
+ * D::writeClassUpcast()
+ * --------------------------------------------------------------------------- */
+ void writeClassUpcast(Node *n, const String* d_class_name,
+ String* c_class_name, String* c_base_name) {
+
+ String *smartptr = Getattr(n, "feature:smartptr");
+ String *upcast_name = NewString("");
+ Printv(upcast_name, d_class_name,
+ (smartptr != 0 ? "SmartPtrUpcast" : "Upcast"), NIL);
+
+ String *upcast_wrapper_name = Swig_name_wrapper(upcast_name);
+
+ writeImDModuleFunction(upcast_name, "void*", "(void* objectRef)",
+ upcast_wrapper_name);
+
+ if (smartptr) {
+ SwigType *spt = Swig_cparse_type(smartptr);
+ if (spt) {
+ SwigType *smart = SwigType_typedef_resolve_all(spt);
+ Delete(spt);
+ SwigType *bsmart = Copy(smart);
+ SwigType *rclassname = SwigType_typedef_resolve_all(c_class_name);
+ SwigType *rbaseclass = SwigType_typedef_resolve_all(c_base_name);
+ Replaceall(bsmart, rclassname, rbaseclass);
+ Delete(rclassname);
+ Delete(rbaseclass);
+ String *smartnamestr = SwigType_namestr(smart);
+ String *bsmartnamestr = SwigType_namestr(bsmart);
+ Printv(upcasts_code,
+ "SWIGEXPORT ", bsmartnamestr, " * ", upcast_wrapper_name,
+ "(", smartnamestr, " *objectRef) {\n",
+ " return objectRef ? new ", bsmartnamestr, "(*objectRef) : 0;\n"
+ "}\n",
+ "\n", NIL);
+ Delete(bsmartnamestr);
+ Delete(smartnamestr);
+ Delete(bsmart);
+ } else {
+ Swig_error(Getfile(n), Getline(n),
+ "Invalid type (%s) in 'smartptr' feature for class %s.\n",
+ smartptr, c_class_name);
+ }
+ } else {
+ Printv(upcasts_code,
+ "SWIGEXPORT ", c_base_name, " * ", upcast_wrapper_name,
+ "(", c_base_name, " *objectRef) {\n",
+ " return (", c_base_name, " *)objectRef;\n"
+ "}\n",
+ "\n", NIL);
+ }
+
+ Replaceall(upcasts_code, "$cclass", c_class_name);
+ Replaceall(upcasts_code, "$cbaseclass", c_base_name);
+
+ Delete(upcast_name);
+ Delete(upcast_wrapper_name);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::writeTypeWrapperClass()
+ * --------------------------------------------------------------------------- */
+ void writeTypeWrapperClass(String *classname, SwigType *type) {
+ Node *n = NewHash();
+ Setfile(n, input_file);
+ Setline(n, line_number);
+
+ assertClassNameValidity(classname);
+
+ String* imports_target;
+ String* code_target;
+ File *class_file = NULL;
+ if (split_proxy_dmodule) {
+ String *filename = NewStringf("%s%s.d", dmodule_directory, classname);
+ class_file = NewFile(filename, "w", SWIG_output_files());
+ if (!class_file) {
+ FileErrorDisplay(filename);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ Append(filenames_list, Copy(filename));
+ Delete(filename);
+
+ emitBanner(class_file);
+ Printf(class_file, "module %s%s;\n", package, classname);
+ Printf(class_file, "\nstatic import %s;\n", im_dmodule_fq_name);
+
+ imports_target = NewString("");
+ code_target = NewString("");
+ } else {
+ imports_target = proxy_dmodule_imports;
+ code_target = proxy_dmodule_code;
+ }
+
+ // Import statements.
+ const String *imports = lookupCodeTypemap(n, "dimports", type, WARN_NONE);
+ if (Len(imports) > 0) {
+ String *imports_trimmed = Copy(imports);
+ Chop(imports_trimmed);
+ replaceImportTypeMacros(imports_trimmed);
+ Printv(imports_target, imports_trimmed, "\n", NIL);
+ Delete(imports_trimmed);
+ }
+
+ // Pure D baseclass and interfaces (no C++ inheritance possible.
+ const String *pure_baseclass = lookupCodeTypemap(n, "dbase", type, WARN_NONE);
+ const String *pure_interfaces = lookupCodeTypemap(n, "dinterfaces", type, WARN_NONE);
+
+ // Emit the class.
+ Printv(code_target,
+ "\n",
+ lookupCodeTypemap(n, "dclassmodifiers", type, WARN_D_TYPEMAP_CLASSMOD_UNDEF),
+ " $dclassname",
+ (*Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", pure_baseclass,
+ ((*Char(pure_baseclass)) && *Char(pure_interfaces)) ? ", " : "", pure_interfaces,
+ " {", NIL);
+
+ String* body = NewString("");
+ Printv(body, lookupCodeTypemap(n, "dbody", type, WARN_D_TYPEMAP_DBODY_UNDEF),
+ lookupCodeTypemap(n, "dcode", type, WARN_NONE), NIL);
+ indentCode(body);
+ Printv(code_target, body, "\n}\n", NIL);
+ Delete(body);
+
+ Replaceall(code_target, "$dclassname", classname);
+
+ if (split_proxy_dmodule) {
+ Printv(class_file, imports_target, NIL);
+ Delete(imports_target);
+
+ replaceModuleVariables(code_target);
+ Printv(class_file, code_target, NIL);
+ Delete(code_target);
+
+ Close(class_file);
+ Delete(class_file);
+ }
+
+ Delete(n);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::writeDirectorConnectProxy()
+ *
+ * Writes the helper method which registers the director callbacks by calling
+ * the director connect function from the D side to the proxy class.
+ * --------------------------------------------------------------------------- */
+ void writeDirectorConnectProxy() {
+ Printf(proxy_class_body_code, "\nprivate void swigDirectorConnect() {\n");
+
+ int i;
+ for (i = first_class_dmethod; i < curr_class_dmethod; ++i) {
+ UpcallData *udata = Getitem(dmethods_seq, i);
+ String *method = Getattr(udata, "method");
+ String *overloaded_name = Getattr(udata, "overname");
+ String *return_type = Getattr(udata, "return_type");
+ String *param_list = Getattr(udata, "param_list");
+ String *methid = Getattr(udata, "class_methodidx");
+ Printf(proxy_class_body_code, " %s.SwigDirector_%s_Callback%s callback%s;\n", im_dmodule_fq_name, proxy_class_name, methid, methid);
+ Printf(proxy_class_body_code, " if (swigIsMethodOverridden!(%s delegate(%s), %s function(%s), %s)()) {\n", return_type, param_list, return_type, param_list, method);
+ Printf(proxy_class_body_code, " callback%s = &swigDirectorCallback_%s_%s;\n", methid, proxy_class_name, overloaded_name);
+ Printf(proxy_class_body_code, " }\n\n");
+ }
+ Printf(proxy_class_body_code, " %s.%s_director_connect(cast(void*)swigCPtr, cast(void*)this", im_dmodule_fq_name, proxy_class_name);
+ for (i = first_class_dmethod; i < curr_class_dmethod; ++i) {
+ UpcallData *udata = Getitem(dmethods_seq, i);
+ String *methid = Getattr(udata, "class_methodidx");
+ Printf(proxy_class_body_code, ", callback%s", methid);
+ }
+ Printf(proxy_class_body_code, ");\n");
+ Printf(proxy_class_body_code, "}\n");
+
+ // Helper function to determine if a method has been overridden in a
+ // subclass of the wrapped class. If not, we just pass null to the
+ // director_connect_function since the method from the C++ class should
+ // be called as usual (see above).
+ // Only emit it if the proxy class has at least one method.
+ if (first_class_dmethod < curr_class_dmethod) {
+ Printf(proxy_class_body_code, "\n");
+ Printf(proxy_class_body_code, "private bool swigIsMethodOverridden(DelegateType, FunctionType, alias fn)() %s{\n", (d_version > 1) ? "const " : "");
+ Printf(proxy_class_body_code, " DelegateType dg = &fn;\n");
+ Printf(proxy_class_body_code, " return dg.funcptr != SwigNonVirtualAddressOf!(FunctionType, fn);\n");
+ Printf(proxy_class_body_code, "}\n");
+ Printf(proxy_class_body_code, "\n");
+ Printf(proxy_class_body_code, "private static Function SwigNonVirtualAddressOf(Function, alias fn)() {\n");
+ Printf(proxy_class_body_code, " return cast(Function) &fn;\n");
+ Printf(proxy_class_body_code, "}\n");
+ }
+
+ if (Len(director_dcallbacks_code) > 0) {
+ Printv(proxy_class_epilogue_code, director_dcallbacks_code, NIL);
+ }
+
+ Delete(director_callback_typedefs);
+ director_callback_typedefs = NULL;
+ Delete(director_callback_pointers);
+ director_callback_pointers = NULL;
+ Delete(director_dcallbacks_code);
+ director_dcallbacks_code = NULL;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::writeDirectorConnectWrapper()
+ *
+ * Writes the director connect function and the corresponding declaration to
+ * the C++ wrapper respectively the D wrapper.
+ * --------------------------------------------------------------------------- */
+ void writeDirectorConnectWrapper(Node *n) {
+ if (!Swig_directorclass(n))
+ return;
+
+ // Output the director connect method.
+ String *norm_name = SwigType_namestr(Getattr(n, "name"));
+ String *connect_name = NewStringf("%s_director_connect", proxy_class_name);
+ String *sym_name = Getattr(n, "sym:name");
+ Wrapper *code_wrap;
+
+ Printv(wrapper_loader_bind_code, wrapper_loader_bind_command, NIL);
+ Replaceall(wrapper_loader_bind_code, "$function", connect_name);
+ Replaceall(wrapper_loader_bind_code, "$symbol", Swig_name_wrapper(connect_name));
+
+ Printf(im_dmodule_code, "extern(C) void function(void* cObject, void* dObject");
+
+ code_wrap = NewWrapper();
+ Printf(code_wrap->def, "SWIGEXPORT void D_%s(void *objarg, void *dobj", connect_name);
+
+ Printf(code_wrap->code, " %s *obj = (%s *)objarg;\n", norm_name, norm_name);
+ Printf(code_wrap->code, " SwigDirector_%s *director = dynamic_cast<SwigDirector_%s *>(obj);\n", sym_name, sym_name);
+
+ Printf(code_wrap->code, " if (director) {\n");
+ Printf(code_wrap->code, " director->swig_connect_director(dobj");
+
+ for (int i = first_class_dmethod; i < curr_class_dmethod; ++i) {
+ UpcallData *udata = Getitem(dmethods_seq, i);
+ String *methid = Getattr(udata, "class_methodidx");
+
+ Printf(code_wrap->def, ", SwigDirector_%s::SWIG_Callback%s_t callback%s", sym_name, methid, methid);
+ Printf(code_wrap->code, ", callback%s", methid);
+ Printf(im_dmodule_code, ", SwigDirector_%s_Callback%s callback%s", sym_name, methid, methid);
+ }
+
+ Printf(code_wrap->def, ") {\n");
+ Printf(code_wrap->code, ");\n");
+ Printf(im_dmodule_code, ") %s;\n", connect_name);
+ Printf(code_wrap->code, " }\n");
+ Printf(code_wrap->code, "}\n");
+
+ Wrapper_print(code_wrap, f_wrappers);
+ DelWrapper(code_wrap);
+
+ Delete(connect_name);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::requireDType()
+ *
+ * Adds an import statement for the given module to the header of current
+ * module. This is only used for dependencies created in generated code, user-
+ * (read: typemap-) specified import statements are handeled seperately.
+ * --------------------------------------------------------------------------- */
+ void requireDType(const String *dmodule_name) {
+ String *import = createImportStatement(dmodule_name);
+ Append(import, "\n");
+ if (is_wrapping_class()) {
+ addImportStatement(proxy_class_imports, import);
+ } else {
+ addImportStatement(proxy_dmodule_imports, import);
+ }
+ Delete(import);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::addImportStatement()
+ *
+ * Adds the given import statement to the given list of import statements if
+ * there is no statement importing that module present yet.
+ * --------------------------------------------------------------------------- */
+ void addImportStatement(String *target, const String *import) const {
+ char *position = Strstr(target, import);
+ if (position) {
+ // If the import statement has been found in the target string, we have to
+ // check if the previous import was static, which would lead to problems
+ // if this import is not.
+ // Thus, we check if the seven characters in front of the occurence are
+ // »static «. If the import string passed is also static, the checks fail
+ // even if the found statement is also static because the last seven
+ // characters would be part of the previous import statement then.
+
+ if (position - Char(target) < 7) {
+ return;
+ }
+ if (strncmp(position - 7, "static ", 7)) {
+ return;
+ }
+ }
+
+ Printv(target, import, NIL);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::createImportStatement()
+ *
+ * Creates a string containing an import statement for the given module if it
+ * is needed in the currently generated proxy D module (i.e. if it is not the
+ * current module itself).
+ * --------------------------------------------------------------------------- */
+ String *createImportStatement(const String *dmodule_name,
+ bool static_import = true) const {
+
+ if (inProxyModule(dmodule_name)) {
+ return NewStringf("");
+ } else {
+ if (static_import) {
+ return NewStringf("static import %s%s;", package, dmodule_name);
+ } else {
+ return NewStringf("import %s%s;", package, dmodule_name);
+ }
+ }
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::inProxyModule()
+ *
+ * Determines if the specified proxy class is decleared in the currently
+ * processed proxy D module.
+ *
+ * This function is used to determine if fully qualified type names have to be
+ * used (package, module and type name). This is never the case if the split
+ * proxy mode is not used, all proxy types are written to the same module then.
+ * --------------------------------------------------------------------------- */
+ bool inProxyModule(const String *type_name) const {
+ if (!split_proxy_dmodule) {
+ // If we are not in split proxy module mode, proxy code is always written
+ // to the same module.
+ return true;
+ }
+
+ if (!Len(proxy_class_name)) {
+ return false;
+ }
+
+ return (Strcmp(proxy_class_name, type_name) == 0);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::addUpcallMethod()
+ *
+ * Adds new director upcall signature.
+ * --------------------------------------------------------------------------- */
+ UpcallData *addUpcallMethod(String *imclass_method, String *class_method,
+ String *decl, String *overloaded_name, String *return_type, String *param_list) {
+
+ UpcallData *udata;
+ String *imclass_methodidx;
+ String *class_methodidx;
+ Hash *new_udata;
+ String *key = NewStringf("%s|%s", imclass_method, decl);
+
+ ++curr_class_dmethod;
+
+ /* Do we know about this director class already? */
+ if ((udata = Getattr(dmethods_table, key))) {
+ Delete(key);
+ return Getattr(udata, "methodoff");
+ }
+
+ imclass_methodidx = NewStringf("%d", n_dmethods);
+ class_methodidx = NewStringf("%d", n_dmethods - first_class_dmethod);
+ n_dmethods++;
+
+ new_udata = NewHash();
+ Append(dmethods_seq, new_udata);
+ Setattr(dmethods_table, key, new_udata);
+
+ Setattr(new_udata, "method", Copy(class_method));
+ Setattr(new_udata, "class_methodidx", class_methodidx);
+ Setattr(new_udata, "decl", Copy(decl));
+ Setattr(new_udata, "overname", Copy(overloaded_name));
+ Setattr(new_udata, "return_type", Copy(return_type));
+ Setattr(new_udata, "param_list", Copy(param_list));
+
+ Delete(key);
+ return new_udata;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::assertClassNameValidity()
+ * --------------------------------------------------------------------------- */
+ void assertClassNameValidity(const String* class_name) const {
+ if (split_proxy_dmodule) {
+ if (Cmp(class_name, im_dmodule_name) == 0) {
+ Swig_error(input_file, line_number, "Class name cannot be equal to intermediary D module name: %s\n",
+ class_name);
+ SWIG_exit(EXIT_FAILURE);
+ }
+
+ if (Cmp(class_name, proxy_dmodule_name) == 0) {
+ Swig_error(input_file, line_number, "Class name cannot be equal to proxy D module name: %s\n",
+ class_name);
+ SWIG_exit(EXIT_FAILURE);
+ }
+ }
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::getPrimitiveDptype()
+ *
+ * Returns the D proxy type for the passed type if it is a primitive type in
+ * both C and D.
+ * --------------------------------------------------------------------------- */
+ String *getPrimitiveDptype(Node *node, SwigType *type) {
+ SwigType *stripped_type = SwigType_typedef_resolve_all(type);
+
+ // A reference can only be the »outermost element« of a type.
+ bool mutable_ref = false;
+ if (SwigType_isreference(stripped_type)) {
+ SwigType_del_reference(stripped_type);
+
+ if (SwigType_isconst(stripped_type)) {
+ SwigType_del_qualifier(stripped_type);
+ } else {
+ mutable_ref = true;
+ }
+ }
+
+ // Strip all the pointers from the type.
+ int indirection_count = 0;
+ while (SwigType_ispointer(stripped_type)) {
+ ++indirection_count;
+ SwigType_del_pointer(stripped_type);
+ }
+
+ // Now that we got rid of the pointers, see if we are dealing with a
+ // primitive type.
+ String *dtype = 0;
+ if (SwigType_isfunction(stripped_type) && indirection_count > 0) {
+ // type was a function pointer, split it up.
+ SwigType_add_pointer(stripped_type);
+ --indirection_count;
+
+ SwigType *return_type = Copy(stripped_type);
+ SwigType *params_type = SwigType_functionpointer_decompose(return_type);
+ String *return_dtype = getPrimitiveDptype(node, return_type);
+ Delete(return_type);
+ if (!return_dtype) {
+ return 0;
+ }
+
+ List *parms = SwigType_parmlist(params_type);
+ List *param_dtypes = NewList();
+ for (Iterator it = First(parms); it.item; it = Next(it)) {
+ String *current_dtype = getPrimitiveDptype(node, it.item);
+ if (Cmp(current_dtype, "void") == 0) {
+ // void somefunc(void) is legal syntax in C, but not in D, so simply
+ // skip the void parameter.
+ Delete(current_dtype);
+ continue;
+ }
+ if (!current_dtype) {
+ Delete(return_dtype);
+ Delete(param_dtypes);
+ return 0;
+ }
+ Append(param_dtypes, current_dtype);
+ }
+
+ String *param_list = NewString("");
+ {
+ bool gen_comma = false;
+ for (Iterator it = First(param_dtypes); it.item; it = Next(it)) {
+ if (gen_comma) {
+ Append(param_list, ", ");
+ }
+ Append(param_list, it.item);
+ Delete(it.item);
+ gen_comma = true;
+ }
+ }
+
+ dtype = NewStringf("%s function(%s)", return_dtype, param_list);
+ Delete(param_list);
+ Delete(param_dtypes);
+ Delete(return_dtype);
+ } else {
+ Hash *attributes = NewHash();
+ const String *tm =
+ lookupCodeTypemap(node, "dtype", stripped_type, WARN_NONE, attributes);
+ if(!GetFlag(attributes, "tmap:dtype:cprimitive")) {
+ dtype = 0;
+ } else {
+ dtype = Copy(tm);
+
+ // We need to call replaceClassname here with the stripped type to avoid
+ // $dclassname in the enum typemaps being replaced later with the full
+ // type.
+ replaceClassname(dtype, stripped_type);
+ }
+ Delete(attributes);
+ }
+ Delete(stripped_type);
+
+ if (!dtype) {
+ // The type passed is no primitive type.
+ return 0;
+ }
+
+ // The type is ultimately a primitive type, now append the right number of
+ // indirection levels (pointers).
+ for (int i = 0; i < indirection_count; ++i) {
+ Append(dtype, "*");
+ }
+
+ // Add a level of indirection for a mutable reference since it is wrapped
+ // as a pointer.
+ if (mutable_ref) {
+ Append(dtype, "*");
+ }
+
+ return dtype;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::lookupCodeTypemap()
+ *
+ * Looks up a D code fragment for generating the wrapper class for the given
+ * type.
+ *
+ * n - for input only and must contain info for Getfile(n) and Getline(n) to work
+ * tmap_method - typemap method name
+ * type - typemap type to lookup
+ * warning - warning number to issue if no typemaps found
+ * typemap_attributes - the typemap attributes are attached to this node and will
+ * also be used for temporary storage if non null
+ * return is never NULL, unlike Swig_typemap_lookup()
+ * --------------------------------------------------------------------------- */
+ const String *lookupCodeTypemap(Node *n, const_String_or_char_ptr tmap_method,
+ SwigType *type, int warning, Node *typemap_attributes = 0) const {
+
+ Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
+ Setattr(node, "type", type);
+ Setfile(node, Getfile(n));
+ Setline(node, Getline(n));
+ const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0);
+ if (!tm) {
+ tm = empty_string;
+ if (warning != WARN_NONE) {
+ Swig_warning(warning, Getfile(n), Getline(n),
+ "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0));
+ }
+ }
+ if (!typemap_attributes) {
+ Delete(node);
+ }
+
+ return tm;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::lookupDTypemap()
+ *
+ * Looks up a D typemap for the given node, replacing D-specific special
+ * variables as needed.
+ *
+ * The method parameter specifies the typemap method to use. If attached is
+ * true, the value is just fetched from the tmap:<method> node attribute,
+ * Swig_typemap_lookup is used otherwise.
+ * --------------------------------------------------------------------------- */
+ String *lookupDTypemap(Node *n, const_String_or_char_ptr method, bool attached = false) {
+ String *result = 0;
+
+ if (attached) {
+ String *attr_name = NewStringf("tmap:%s", method);
+ result = Getattr(n, attr_name);
+ Delete(attr_name);
+ } else {
+ // FIXME: As a workaround for a bug so far only surfacing in the
+ // smart_pointer_const_overload test case, remove the nativepointer
+ // typemap attribute since it seems to be already there from a dout
+ // typemap of a different type in that test.
+ String *np_key = NewStringf("tmap:%s:nativepointer", method);
+ Delattr(n, np_key);
+ Delete(np_key);
+
+ result = Swig_typemap_lookup(method, n, "", 0);
+ }
+
+ if (!result) {
+ return 0;
+ }
+
+ // Check if the passed node actually has type information attached. This
+ // is not the case e.g. in constructorWrapper.
+ SwigType *type = Getattr(n, "type");
+ if (type) {
+ String *np_key = NewStringf("tmap:%s:nativepointer", method);
+ String *np_value = Getattr(n, np_key);
+ Delete(np_key);
+ String *dtype;
+ if (np_value && (dtype = getPrimitiveDptype(n, type))) {
+ // If the typemap in question has a »nativepointer« attribute and we
+ // are dealing with a primitive type, use it instead.
+ result = Copy(np_value);
+ Replaceall(result, "$dtype", dtype);
+ }
+
+ replaceClassname(result, type);
+ }
+
+ return result;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::replaceClassname()
+ *
+ * Replaces the special variable $dclassname with the proxy class name for
+ * classes/structs/unions SWIG knows about. Also substitutes the enumeration
+ * name for non-anonymous enums. Otherwise, $classname is replaced with a
+ * $descriptor(type)-like name.
+ *
+ * $*dclassname and $&classname work like with descriptors (see manual section
+ * 10.4.3), they remove a prointer from respectively add a pointer to the type.
+ *
+ * Inputs:
+ * tm - String to perform the substitution at (will usually come from a
+ * typemap.
+ * pt - The type to substitute for the variables.
+ * Outputs:
+ * tm - String with the variables substituted.
+ * Return:
+ * substitution_performed - flag indicating if a substitution was performed
+ * --------------------------------------------------------------------------- */
+ bool replaceClassname(String *tm, SwigType *pt) {
+ bool substitution_performed = false;
+ SwigType *type = Copy(SwigType_typedef_resolve_all(pt));
+ SwigType *strippedtype = SwigType_strip_qualifiers(type);
+
+ if (Strstr(tm, "$dclassname")) {
+ SwigType *classnametype = Copy(strippedtype);
+ replaceClassnameVariable(tm, "$dclassname", classnametype);
+ substitution_performed = true;
+ Delete(classnametype);
+ }
+ if (Strstr(tm, "$*dclassname")) {
+ SwigType *classnametype = Copy(strippedtype);
+ Delete(SwigType_pop(classnametype));
+ replaceClassnameVariable(tm, "$*dclassname", classnametype);
+ substitution_performed = true;
+ Delete(classnametype);
+ }
+ if (Strstr(tm, "$&dclassname")) {
+ SwigType *classnametype = Copy(strippedtype);
+ SwigType_add_pointer(classnametype);
+ replaceClassnameVariable(tm, "$&dclassname", classnametype);
+ substitution_performed = true;
+ Delete(classnametype);
+ }
+
+ Delete(strippedtype);
+ Delete(type);
+
+ return substitution_performed;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::replaceClassnameVariable()
+ *
+ * See D::replaceClassname().
+ * --------------------------------------------------------------------------- */
+ void replaceClassnameVariable(String *target, const char *variable, SwigType *type) {
+ // TODO: Fix const-correctness of methods called in here and make type const.
+
+ // We make use of the fact that this function is called at least once for
+ // every type encountered which is written to a seperate file, which allows
+ // us to handle imports here.
+ // When working in split proxy module mode, each generated proxy class/enum
+ // is written to a seperate module. This requires us to add a corresponding
+ // import when a type is used in another generated module. If we are not
+ // working in split proxy module mode, this is not relevant and the
+ // generated module name is discarded.
+ String *import_name;
+
+ String *qualified_type_name;
+ if (SwigType_isenum(type)) {
+ // RESEARCH: Make sure that we really cannot get here for anonymous enums.
+ Node *n = enumLookup(type);
+ const String *symname = Getattr(n, "sym:name");
+
+ // Add in class scope when referencing enum if not a global enum.
+ const String *parent_name = NULL;
+ String *scopename_prefix = Swig_scopename_prefix(Getattr(n, "name"));
+ if (scopename_prefix) {
+ parent_name = getProxyName(scopename_prefix);
+ Delete(scopename_prefix);
+ }
+
+ if (parent_name) {
+ qualified_type_name = createQualifiedName(parent_name);
+ Printv(qualified_type_name, ".", symname, NIL);
+
+ // An enum nested in a class is not written to a seperate module (this
+ // would not even be possible in D), so just import the parent.
+ import_name = Copy(parent_name);
+ } else {
+ qualified_type_name = createQualifiedName(symname);
+
+ // A non-nested enum is written to a seperate module, import it.
+ import_name = Copy(symname);
+ }
+ } else {
+ const String *class_name = getProxyName(type);
+ if (class_name) {
+ // This is something wrapped as a proxy class (getProxyName() works for
+ // pointers to classes too).
+ qualified_type_name = createQualifiedName(class_name);
+ import_name = Copy(class_name);
+ } else {
+ // SWIG does not know anything about the type (after resolving typedefs).
+ // Just mangle the type name string like $descriptor(type) would do.
+ String *descriptor = NewStringf("SWIGTYPE%s", SwigType_manglestr(type));
+ qualified_type_name = createQualifiedName(descriptor);
+ import_name = Copy(descriptor);
+
+ // Add to hash table so that a type wrapper class can be created later.
+ Setattr(unknown_types, descriptor, type);
+
+ Delete(descriptor);
+ }
+ }
+
+ Replaceall(target, variable, qualified_type_name);
+ Delete(qualified_type_name);
+
+ requireDType(import_name);
+ Delete(import_name);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::createQualifiedName()
+ * --------------------------------------------------------------------------- */
+ String *createQualifiedName(const String *class_name) const {
+ if (inProxyModule(class_name)) {
+ return Copy(class_name);
+ } else {
+ return NewStringf("%s%s.%s", package, class_name, class_name);
+ }
+}
+
+ /* ---------------------------------------------------------------------------
+ * D::replaceModuleVariables()
+ *
+ * Replaces the $imdmodule and $module variables with their values in the
+ * target string.
+ * --------------------------------------------------------------------------- */
+ void replaceModuleVariables(String *target) const {
+ Replaceall(target, "$imdmodule", im_dmodule_fq_name);
+ Replaceall(target, "$module", proxy_dmodule_name);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::replaceExcode()
+ *
+ * If a C++ method can throw a exception, additional code is added to the
+ * proxy method to check if an exception is pending so that it can be
+ * rethrown on the D side.
+ *
+ * This method replaces the $excode variable with the exception handling code
+ * in the excode typemap attribute if it »canthrow« an exception.
+ * --------------------------------------------------------------------------- */
+ void replaceExcode(Node *n, String *code, const String *typemap, Node *parameter) const {
+ String *excode_attribute = NewStringf("tmap:%s:excode", typemap);
+ String *excode = Getattr(parameter, excode_attribute);
+ if (Getattr(n, "d:canthrow")) {
+ int count = Replaceall(code, "$excode", excode);
+ if (count < 1 || !excode) {
+ Swig_warning(WARN_D_EXCODE_MISSING, input_file, line_number,
+ "D exception may not be thrown – no $excode or excode attribute in '%s' typemap.\n",
+ typemap);
+ }
+ } else {
+ Replaceall(code, "$excode", "");
+ }
+ Delete(excode_attribute);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::replaceImportTypeMacros()
+ *
+ * Replaces the $importtype(SomeDClass) macro with an import statement if it
+ * is required to get SomeDClass in scope for the currently generated proxy
+ * D module.
+ * --------------------------------------------------------------------------- */
+ void replaceImportTypeMacros(String *target) const {
+ // Code from replace_embedded_typemap.
+ char *start = 0;
+ while ((start = Strstr(target, "$importtype("))) {
+ char *end = 0;
+ char *param_start = 0;
+ char *param_end = 0;
+ int level = 0;
+ char *c = start;
+ while (*c) {
+ if (*c == '(') {
+ if (level == 0) {
+ param_start = c + 1;
+ }
+ level++;
+ }
+ if (*c == ')') {
+ level--;
+ if (level == 0) {
+ param_end = c;
+ end = c + 1;
+ break;
+ }
+ }
+ c++;
+ }
+
+ if (end) {
+ String *current_macro = NewStringWithSize(start, (end - start));
+ String *current_param = NewStringWithSize(param_start, (param_end - param_start));
+
+ String *import = createImportStatement(current_param, false);
+ Replace(target, current_macro, import, DOH_REPLACE_ANY);
+ Delete(import);
+
+ Delete(current_param);
+ Delete(current_macro);
+ } else {
+ String *current_macro = NewStringWithSize(start, (c - start));
+ Swig_error(Getfile(target), Getline(target), "Syntax error in: %s\n", current_macro);
+ Replace(target, current_macro, "<error in $importtype macro>", DOH_REPLACE_ANY);
+ Delete(current_macro);
+ }
+ }
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::getOverloadedName()
+ * --------------------------------------------------------------------------- */
+ String *getOverloadedName(Node *n) const {
+ // A void* parameter is used for all wrapped classes in the wrapper code.
+ // Thus, the wrapper function names for overloaded functions are postfixed
+ // with a counter string to make them unique.
+ String *overloaded_name = Copy(Getattr(n, "sym:name"));
+
+ if (Getattr(n, "sym:overloaded")) {
+ Append(overloaded_name, Getattr(n, "sym:overname"));
+ }
+
+ return overloaded_name;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::getProxyName()
+ *
+ * Returns the D class name if a type corresponds to something wrapped with a
+ * proxy class, NULL otherwise.
+ * --------------------------------------------------------------------------- */
+ const String *getProxyName(SwigType *t) {
+ Node *n = classLookup(t);
+ if (n) {
+ return Getattr(n, "sym:name");
+ } else {
+ return NULL;
+ }
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::directorClassName()
+ * --------------------------------------------------------------------------- */
+ String *getDirectorClassName(Node *n) const {
+ String *dirclassname;
+ const char *attrib = "director:classname";
+
+ if (!(dirclassname = Getattr(n, attrib))) {
+ String *classname = Getattr(n, "sym:name");
+
+ dirclassname = NewStringf("SwigDirector_%s", classname);
+ Setattr(n, attrib, dirclassname);
+ }
+
+ return dirclassname;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::makeParameterName()
+ *
+ * Inputs:
+ * n - Node
+ * p - parameter node
+ * arg_num - parameter argument number
+ * setter - set this flag when wrapping variables
+ * Return:
+ * arg - a unique parameter name
+ * --------------------------------------------------------------------------- */
+ String *makeParameterName(Node *n, Parm *p, int arg_num, bool setter) const {
+ String *arg = 0;
+ String *pn = Getattr(p, "name");
+
+ // Use C parameter name unless it is a duplicate or an empty parameter name
+ int count = 0;
+ ParmList *plist = Getattr(n, "parms");
+ while (plist) {
+ if ((Cmp(pn, Getattr(plist, "name")) == 0))
+ count++;
+ plist = nextSibling(plist);
+ }
+ String *wrn = pn ? Swig_name_warning(p, 0, pn, 0) : 0;
+ arg = (!pn || (count > 1) || wrn) ? NewStringf("arg%d", arg_num) : Copy(pn);
+
+ if (setter && Cmp(arg, "self") != 0) {
+ // In theory, we could use the normal parameter name for setter functions.
+ // Unfortunately, it is set to "Class::VariableName" for static public
+ // members by the parser, which is not legal D syntax. Thus, we just force
+ // it to "value".
+ Delete(arg);
+ arg = NewString("value");
+ }
+
+ if (split_proxy_dmodule && Strncmp(arg, package, Len(arg)) == 0) {
+ // If we are in split proxy mode and the argument is named like the target
+ // package, we append an underscore to its name to avoid clashes.
+ Append(arg, "_");
+ }
+
+ return arg;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::canThrow()
+ *
+ * Determines whether the code in the typemap can throw a D exception.
+ * If so, note it for later when excodeSubstitute() is called.
+ * --------------------------------------------------------------------------- */
+ void canThrow(Node *n, const String *typemap, Node *parameter) const {
+ String *canthrow_attribute = NewStringf("tmap:%s:canthrow", typemap);
+ String *canthrow = Getattr(parameter, canthrow_attribute);
+ if (canthrow)
+ Setattr(n, "d:canthrow", "1");
+ Delete(canthrow_attribute);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::wrapMemberFunctionAsDConst()
+ *
+ * Determines whether the member function represented by the passed node is
+ * wrapped as D »const« or not.
+ * --------------------------------------------------------------------------- */
+ bool wrapMemberFunctionAsDConst(Node *n) const {
+ if (d_version == 1) return false;
+ if (static_flag) return false; // Never emit »const« for static member functions.
+ return GetFlag(n, "memberget") || SwigType_isconst(Getattr(n, "decl"));
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::areAllOverloadsOverridden()
+ *
+ * Determines whether the class the passed function node belongs to overrides
+ * all the overlaods for the passed function node defined somewhere up the
+ * inheritance hierachy.
+ * --------------------------------------------------------------------------- */
+ bool areAllOverloadsOverridden(Node *n) const {
+ List *base_list = Getattr(parentNode(n), "bases");
+ if (!base_list) {
+ // If the class which contains n is not derived from any other class,
+ // there cannot be any not-overridden overloads.
+ return true;
+ }
+
+ // In case of multiple base classes, skip to the one which has not been
+ // ignored.
+ // RESEARCH: Also emit a warning in case of multiple inheritance here?
+ Iterator it = First(base_list);
+ while (it.item && GetFlag(it.item, "feature:ignore")) {
+ it = Next(it);
+ }
+ Node *base_class = it.item;
+
+ if (!base_class) {
+ // If all base classes have been ignored, there cannot be one either.
+ return true;
+ }
+
+ // We try to find at least a single overload which exists in the base class
+ // so we can progress up the inheritance hierachy even if there have been
+ // new overloads introduced after the topmost class.
+ Node *base_function = NULL;
+ for (Node *tmp = firstChild(base_class); tmp; tmp = nextSibling(tmp)) {
+ if (Strcmp(Getattr(tmp, "sym:name"), Getattr(n, "sym:name")) == 0) {
+ base_function = tmp;
+ break;
+ }
+ }
+
+ if (!base_function) {
+ // If there is no overload which also exists in the super class, there
+ // cannot be any base class overloads not overridden.
+ return true;
+ }
+
+ size_t base_overload_count = 0;
+ for (Node *tmp = firstSibling(base_function); tmp; tmp = Getattr(tmp, "sym:nextSibling")) {
+ if (is_protected(base_function) &&
+ !(Swig_director_mode() && Swig_director_protected_mode() && Swig_all_protected_mode())) {
+ // If the base class function is »protected« and were are not in
+ // director mode, it is not emitted to the base class and thus we do
+ // not count it. Otherwise, we would run into issues if the visiblity
+ // of some functions was changed from protected to public in a child
+ // class with the using directive.
+ continue;
+ }
+ ++base_overload_count;
+ }
+
+ return ((base_overload_count <= overridingOverloadCount(n)) &&
+ areAllOverloadsOverridden(base_function));
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::overridingOverloadCount()
+ *
+ * Given a member function node, this function counts how many of the
+ * overloads of the function (including itself) override a function in the
+ * base class.
+ * --------------------------------------------------------------------------- */
+ size_t overridingOverloadCount(Node *n) const {
+ size_t result = 0;
+
+ Node *tmp = firstSibling(n);
+ do {
+ // KLUDGE: We also have to count the function if the access attribute is
+ // not present, since this means that it has been promoted into another
+ // protection level in the base class with the C++ »using« directive, and
+ // is thus taken into account when counting the base class overloads, even
+ // if it is not marked as »override« by the SWIG parser.
+ if (Getattr(n, "override") || !Getattr(n, "access")) {
+ ++result;
+ }
+ } while((tmp = Getattr(tmp, "sym:nextSibling")));
+
+ return result;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::firstSibling()
+ *
+ * Returns the first sibling of the passed node.
+ * --------------------------------------------------------------------------- */
+ Node *firstSibling(Node *n) const {
+ Node *result = n;
+ while (Node *tmp = Getattr(result, "sym:previousSibling")) {
+ result = tmp;
+ }
+ return result;
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::indentCode()
+ *
+ * Helper function to indent a code (string) by one level.
+ * --------------------------------------------------------------------------- */
+ void indentCode(String* code) const {
+ Replaceall(code, "\n", "\n ");
+ Replaceall(code, " \n", "\n");
+ Chop(code);
+ }
+
+ /* ---------------------------------------------------------------------------
+ * D::emitBanner()
+ * --------------------------------------------------------------------------- */
+ void emitBanner(File *f) const {
+ Printf(f, "/* ----------------------------------------------------------------------------\n");
+ Swig_banner_target_lang(f, " *");
+ Printf(f, " * ----------------------------------------------------------------------------- */\n\n");
+ }
+};
+
+static Language *new_swig_d() {
+ return new D();
+}
+
+/* -----------------------------------------------------------------------------
+ * swig_d() - Instantiate module
+ * ----------------------------------------------------------------------------- */
+extern "C" Language *swig_d(void) {
+ return new_swig_d();
+}
+
+/* -----------------------------------------------------------------------------
+ * Usage information displayed at the command line.
+ * ----------------------------------------------------------------------------- */
+const char *D::usage = (char *) "\
+D Options (available with -d)\n\
+ -splitproxy - Write each D type to a dedicated file instead of\n\
+ generating a single proxy D module.\n\
+ -noproxy - Generate the low-level functional interface instead\n\
+ of proxy classes\n\
+ -package <pkg> - Write generated D modules into package <pkg>\n\
+ -wrapperlibrary <wl> - Sets the name of the wrapper library to <wl>\n\
+\n";
diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx
index f62586b92..094b1dd5a 100644
--- a/Source/Modules/go.cxx
+++ b/Source/Modules/go.cxx
@@ -43,11 +43,9 @@ class GO:public Language {
File *f_go_runtime;
File *f_go_header;
File *f_go_wrappers;
- File *f_go_once;
File *f_gc_runtime;
File *f_gc_header;
File *f_gc_wrappers;
- File *f_gc_once;
// True if we imported a module.
bool saw_import;
@@ -100,11 +98,9 @@ public:
f_go_runtime(NULL),
f_go_header(NULL),
f_go_wrappers(NULL),
- f_go_once(NULL),
f_gc_runtime(NULL),
f_gc_header(NULL),
f_gc_wrappers(NULL),
- f_gc_once(NULL),
saw_import(false),
imported_package(NULL),
interfaces(NULL),
@@ -303,12 +299,10 @@ private:
f_go_runtime = NewString("");
f_go_header = NewString("");
f_go_wrappers = NewString("");
- f_go_once = NewString("");
if (!gccgo_flag) {
f_gc_runtime = NewString("");
f_gc_header = NewString("");
f_gc_wrappers = NewString("");
- f_gc_once = NewString("");
}
Swig_register_filebyname("begin", f_c_begin);
@@ -322,13 +316,11 @@ private:
Swig_register_filebyname("go_runtime", f_go_runtime);
Swig_register_filebyname("go_header", f_go_header);
Swig_register_filebyname("go_wrapper", f_go_wrappers);
- Swig_register_filebyname("go_once", f_go_once);
if (!gccgo_flag) {
Swig_register_filebyname("gc_begin", f_gc_begin);
Swig_register_filebyname("gc_runtime", f_gc_runtime);
Swig_register_filebyname("gc_header", f_gc_header);
Swig_register_filebyname("gc_wrapper", f_gc_wrappers);
- Swig_register_filebyname("gc_once", f_gc_once);
}
Swig_banner(f_c_begin);
@@ -349,6 +341,7 @@ private:
if (!gccgo_flag) {
Swig_banner(f_gc_begin);
Printf(f_gc_begin, "\n/* This file should be compiled with 6c/8c. */\n");
+ Printf(f_gc_begin, "#pragma dynimport _ _ \"%s\"\n", soname);
}
// Output module initialization code.
@@ -414,16 +407,10 @@ private:
Dump(f_c_wrappers, f_c_begin);
Dump(f_c_init, f_c_begin);
Dump(f_go_header, f_go_begin);
- if (!saw_import) {
- Dump(f_go_once, f_go_begin);
- }
Dump(f_go_runtime, f_go_begin);
Dump(f_go_wrappers, f_go_begin);
if (!gccgo_flag) {
Dump(f_gc_header, f_gc_begin);
- if (!saw_import) {
- Dump(f_gc_once, f_gc_begin);
- }
Dump(f_gc_runtime, f_gc_begin);
Dump(f_gc_wrappers, f_gc_begin);
}
@@ -1011,8 +998,9 @@ private:
int gcFunctionWrapper(Node *n, String *name, String *go_name, String *overname, String *wname, ParmList *parms, SwigType *result, bool is_static, bool needs_wrapper) {
Wrapper *f = NewWrapper();
- Printv(f->def, "#pragma dynimport ", wname, " ", wname, " \"", soname, "\"\n", NULL);
- Printv(f->def, "void (*", wname, ")(void*);\n", NULL);
+ Printv(f->def, "#pragma dynimport ", wname, " ", wname, " \"\"\n", NULL);
+ Printv(f->def, "extern void (*", wname, ")(void*);\n", NULL);
+ Printv(f->def, "static void (*x", wname, ")(void*) = ", wname, ";\n", NULL);
Printv(f->def, "\n", NULL);
Printv(f->def, "void\n", NULL);
@@ -1068,7 +1056,7 @@ private:
Delete(parm_size);
Printv(f->code, "{\n", NULL);
- Printv(f->code, "\tcgocall(", wname, ", &p);\n", NULL);
+ Printv(f->code, "\truntime\xc2\xb7" "cgocall(x", wname, ", &p);\n", NULL);
Printv(f->code, "}\n", NULL);
Printv(f->code, "\n", NULL);
@@ -1128,7 +1116,7 @@ private:
Parm *base_parm = NULL;
if (base && !isStatic(n)) {
- SwigType *base_type = Copy(Getattr(class_node, "classtype"));
+ SwigType *base_type = Copy(getClassType());
SwigType_add_pointer(base_type);
base_parm = NewParm(base_type, NewString("arg1"), n);
set_nextSibling(base_parm, parms);
@@ -1166,7 +1154,7 @@ private:
p = nextParm(p);
}
if (SwigType_type(result) != T_VOID) {
- Printv(f->code, "\t\tint : 0;\n", NULL);
+ Printv(f->code, "\t\tlong : 0;\n", NULL);
String *ln = NewString("result");
String *ct = gcCTypeForGoValue(n, result, ln);
Delete(ln);
@@ -1244,7 +1232,7 @@ private:
Parm *base_parm = NULL;
if (base && !isStatic(n)) {
- SwigType *base_type = Copy(Getattr(class_node, "classtype"));
+ SwigType *base_type = Copy(getClassType());
SwigType_add_pointer(base_type);
base_parm = NewParm(base_type, NewString("arg1"), n);
set_nextSibling(base_parm, parms);
@@ -1270,7 +1258,11 @@ private:
Parm *p = parms;
for (int i = 0; i < parm_count; ++i) {
p = getParm(p);
- SwigType *pt = Getattr(p, "type");
+ SwigType *pt = Copy(Getattr(p, "type"));
+ if (SwigType_isarray(pt)) {
+ SwigType_del_array(pt);
+ SwigType_add_pointer(pt);
+ }
String *pn = NewString("g");
Append(pn, Getattr(p, "lname"));
String *ct = gccgoCTypeForGoValue(p, pt, pn);
@@ -1280,6 +1272,7 @@ private:
Printv(fnname, ct, NULL);
Delete(ct);
Delete(pn);
+ Delete(pt);
p = nextParm(p);
}
@@ -1945,7 +1938,7 @@ private:
String *ty = NewString(Getattr(ni, "type"));
SwigType_push(ty, Getattr(ni, "decl"));
String *fullty = SwigType_typedef_resolve_all(ty);
- bool is_function = SwigType_isfunction(fullty);
+ bool is_function = SwigType_isfunction(fullty) ? true : false;
Delete(ty);
Delete(fullty);
@@ -2426,7 +2419,7 @@ private:
* ------------------------------------------------------------ */
int classDirectorConstructor(Node *n) {
- bool is_ignored = GetFlag(n, "feature:ignore");
+ bool is_ignored = GetFlag(n, "feature:ignore") ? true : false;
String *name = Getattr(n, "sym:name");
if (!name) {
@@ -2667,7 +2660,7 @@ private:
return SWIG_OK;
}
- bool is_ignored = GetFlag(n, "feature:ignore");
+ bool is_ignored = GetFlag(n, "feature:ignore") ? true : false;
if (!is_ignored) {
String *fnname = NewString("DeleteDirector");
@@ -2679,7 +2672,7 @@ private:
Setattr(n, "wrap:name", fnname);
- Swig_DestructorToFunction(n, getNSpace(), Getattr(parentNode(n), "classtype"), CPlusPlus, Extend);
+ Swig_DestructorToFunction(n, getNSpace(), getClassType(), CPlusPlus, Extend);
ParmList *parms = Getattr(n, "parms");
Setattr(n, "wrap:parms", parms);
@@ -2749,7 +2742,7 @@ private:
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, "\tcgocallback(\xc2\xb7", go_name, ", a, n);\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);
@@ -2781,7 +2774,7 @@ private:
int classDirectorMethod(Node *n, Node *parent, String *super) {
(void) super;
- bool is_ignored = GetFlag(n, "feature:ignore");
+ bool is_ignored = GetFlag(n, "feature:ignore") ? true : false;
bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 && Cmp(Getattr(n, "value"), "0") == 0);
// We don't need explicit calls.
@@ -2869,7 +2862,7 @@ private:
* ------------------------------------------------------------ */
int oneClassDirectorMethod(Node *n, Node *parent) {
- bool is_ignored = GetFlag(n, "feature:ignore");
+ bool is_ignored = GetFlag(n, "feature:ignore") ? true : false;
bool is_pure_virtual = (Cmp(Getattr(n, "storage"), "virtual") == 0 && Cmp(Getattr(n, "value"), "0") == 0);
String *name = Getattr(n, "sym:name");
@@ -3415,7 +3408,7 @@ private:
p = Getattr(p, "tmap:directorin:next");
}
if (SwigType_type(result) != T_VOID) {
- Printv(f->code, " int : 0;\n", NULL);
+ Printv(f->code, " long : 0;\n", NULL);
String *rname = NewString("result");
String *cg = gcCTypeForGoValue(n, result, rname);
Printv(f->code, " ", cg, ";\n", NULL);
@@ -3475,7 +3468,7 @@ private:
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, "\tcgocallback(\xc2\xb7", callback_name, ", a, n);\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) {
@@ -3545,7 +3538,7 @@ private:
}
} else {
assert(is_pure_virtual);
- Printv(f->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n");
+ Printv(f->code, " _swig_gopanic(\"call to pure virtual function ", Getattr(parent, "sym:name"), name, "\");\n", NULL);
if (SwigType_type(result) != T_VOID) {
String *retstr = SwigType_rcaststr(Getattr(n, "returntype"), "c_result");
Printv(f->code, " return ", retstr, ";\n", NULL);
@@ -3782,7 +3775,7 @@ private:
int num_required = emit_num_required(pi);
int num_arguments = emit_num_arguments(pi);
- bool varargs = emit_isvarargs(pi);
+ bool varargs = emit_isvarargs(pi) ? true : false;
if (varargs) {
Printf(f_go_wrappers, "\tif argc >= %d {\n", num_required);
@@ -4138,7 +4131,7 @@ private:
n1, name, n2);
return false;
}
- bool r = addSymbol(name, n, scope);
+ bool r = addSymbol(name, n, scope) ? true : false;
assert(r);
return true;
}
diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx
index 4a6abd569..234a1e85b 100644
--- a/Source/Modules/java.cxx
+++ b/Source/Modules/java.cxx
@@ -1714,10 +1714,10 @@ public:
base = Next(base);
continue;
}
- String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
- String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0);
- Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, input_file, line_number,
- "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", proxyclassname, baseclassname);
+ String *proxyclassname = Getattr(n, "classtypeobj");
+ String *baseclassname = Getattr(base.item, "name");
+ Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
+ "Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java.\n", SwigType_namestr(proxyclassname), SwigType_namestr(baseclassname));
base = Next(base);
}
}
@@ -1735,9 +1735,9 @@ public:
Delete(baseclass);
baseclass = NULL;
if (purebase_notderived)
- Swig_error(input_file, line_number, "The javabase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
+ Swig_error(Getfile(n), Getline(n), "The javabase typemap for proxy %s must contain just one of the 'replace' or 'notderived' attributes.\n", typemap_lookup_type);
} else if (Len(pure_baseclass) > 0 && Len(baseclass) > 0) {
- Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, input_file, line_number,
+ Swig_warning(WARN_JAVA_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Java. "
"Perhaps you need one of the 'replace' or 'notderived' attributes in the csbase typemap?\n", typemap_lookup_type, pure_baseclass);
}
@@ -1772,12 +1772,10 @@ public:
}
if (tm && *Char(tm)) {
if (!destruct_methodname) {
- Swig_error(input_file, line_number,
- "No methodname attribute defined in javadestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
+ Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in javadestruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
}
if (!destruct_methodmodifiers) {
- Swig_error(input_file, line_number,
- "No methodmodifiers attribute defined in javadestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name);
+ Swig_error(Getfile(n), Getline(n), "No methodmodifiers attribute defined in javadestruct%s typemap for %s.\n", (derived ? "_derived" : ""), proxy_class_name);
}
}
// Emit the finalize and delete methods
@@ -3326,8 +3324,10 @@ public:
}
Printf(f_runtime, "namespace Swig {\n");
- Printf(f_runtime, " static jclass jclass_%s = NULL;\n", imclass_name);
- Printf(f_runtime, " static jmethodID director_methids[%d];\n", n_methods);
+ Printf(f_runtime, " namespace {\n");
+ Printf(f_runtime, " jclass jclass_%s = NULL;\n", imclass_name);
+ Printf(f_runtime, " jmethodID director_methids[%d];\n", n_methods);
+ Printf(f_runtime, " }\n");
Printf(f_runtime, "}\n");
Printf(w->def, "SWIGEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls) {", jnipackage, jni_imclass_name, swig_module_init_jni);
@@ -3548,7 +3548,6 @@ public:
String *callback_def = NewString("");
String *callback_code = NewString("");
String *imcall_args = NewString("");
- int gencomma = 0;
int classmeth_off = curr_class_dmethod - first_class_dmethod;
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
@@ -3767,14 +3766,14 @@ public:
Delete(tp);
/* Go through argument list, convert from native to Java */
- for (p = l; p; /* empty */ ) {
+ for (i = 0, p = l; p; ++i) {
/* Is this superfluous? */
while (checkAttribute(p, "tmap:directorin:numinputs", "0")) {
p = Getattr(p, "tmap:directorin:next");
}
SwigType *pt = Getattr(p, "type");
- String *ln = Copy(Getattr(p, "name"));
+ String *ln = makeParameterName(n, p, i, false);
String *c_param_type = NULL;
String *c_decl = NewString("");
String *arg = NewString("");
@@ -3833,7 +3832,7 @@ public:
substituteClassname(pt, din);
Replaceall(din, "$jniinput", ln);
- if (++gencomma > 1)
+ if (i > 0)
Printf(imcall_args, ", ");
Printf(callback_def, ", %s %s", tm, ln);
@@ -3896,6 +3895,7 @@ public:
Delete(arg);
Delete(c_decl);
Delete(c_param_type);
+ Delete(ln);
}
/* header declaration, start wrapper definition */
diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
index e28fcbb89..82af250f7 100644
--- a/Source/Modules/lang.cxx
+++ b/Source/Modules/lang.cxx
@@ -52,7 +52,7 @@ extern "C" {
return all_protected_mode;
}
void Language_replace_special_variables(String *method, String *tm, Parm *parm) {
- Language::instance()->replaceSpecialVariables(method, tm, parm);
+ Language::instance()->replaceSpecialVariables(method, tm, parm);
}
}
@@ -1344,7 +1344,7 @@ int Language::variableHandler(Node *n) {
Swig_save("variableHandler", n, "feature:immutable", NIL);
if (SmartPointer) {
/* If a smart-pointer and it's a constant access, we have to set immutable */
- if (Getattr(CurrentClass, "allocate:smartpointerconst")) {
+ if (!Getattr(CurrentClass, "allocate:smartpointermutable")) {
SetFlag(n, "feature:immutable");
}
}
@@ -1391,7 +1391,7 @@ int Language::membervariableHandler(Node *n) {
int assignable = is_assignable(n);
if (SmartPointer) {
- if (Getattr(CurrentClass, "allocate:smartpointerconst")) {
+ if (!Getattr(CurrentClass, "allocate:smartpointermutable")) {
assignable = 0;
}
}
@@ -1806,17 +1806,25 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
classname = Getattr(n, "name");
for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) {
/* we only need to check the virtual members */
- if (!checkAttribute(ni, "storage", "virtual"))
- continue;
nodeType = Getattr(ni, "nodeType");
+ int is_using = (Cmp(nodeType, "using") == 0);
+ Node *nn = is_using ? firstChild(ni) : ni; /* assume there is only one child node for "using" nodes */
+ if (is_using) {
+ if (nn)
+ nodeType = Getattr(nn, "nodeType");
+ else
+ continue; // A private "using" node
+ }
+ if (!checkAttribute(nn, "storage", "virtual"))
+ continue;
/* we need to add methods(cdecl) and destructor (to check for throw decl) */
int is_destructor = (Cmp(nodeType, "destructor") == 0);
if ((Cmp(nodeType, "cdecl") == 0) || is_destructor) {
- decl = Getattr(ni, "decl");
+ decl = Getattr(nn, "decl");
/* extra check for function type and proper access */
- if (SwigType_isfunction(decl) && (((!protectedbase || dirprot_mode()) && is_public(ni)) || need_nonpublic_member(ni))) {
- String *name = Getattr(ni, "name");
- Node *method_id = is_destructor ? NewStringf("~destructor") : vtable_method_id(ni);
+ if (SwigType_isfunction(decl) && (((!protectedbase || dirprot_mode()) && is_public(nn)) || need_nonpublic_member(nn))) {
+ String *name = Getattr(nn, "name");
+ Node *method_id = is_destructor ? NewStringf("~destructor") : vtable_method_id(nn);
/* Make sure that the new method overwrites the existing: */
int len = Len(vm);
const int DO_NOT_REPLACE = -1;
@@ -1834,7 +1842,7 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
String *fqdname = NewStringf("%s::%s", classname, name);
Hash *item = NewHash();
Setattr(item, "fqdname", fqdname);
- Node *m = Copy(ni);
+ Node *m = Copy(nn);
/* Store the complete return type - needed for non-simple return types (pointers, references etc.) */
SwigType *ty = NewString(Getattr(m, "type"));
@@ -1854,6 +1862,7 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
Append(vm, item);
else
Setitem(vm, replace, item);
+ Setattr(nn, "directorNode", m);
Delete(mname);
}
@@ -2443,6 +2452,9 @@ int Language::classHandler(Node *n) {
List *methods = Getattr(n, "allocate:smartpointer");
cplus_mode = PUBLIC;
SmartPointer = CWRAP_SMART_POINTER;
+ if (Getattr(n, "allocate:smartpointerconst") && Getattr(n, "allocate:smartpointermutable")) {
+ SmartPointer |= CWRAP_SMART_POINTER_OVERLOAD;
+ }
Iterator c;
for (c = First(methods); c.item; c = Next(c)) {
emit_one(c.item);
@@ -2803,7 +2815,7 @@ int Language::validIdentifier(String *s) {
* ----------------------------------------------------------------------------- */
int Language::usingDeclaration(Node *n) {
- if ((cplus_mode == PUBLIC)) {
+ if ((cplus_mode == PUBLIC) || (!is_public(n) && dirprot_mode())) {
Node *np = Copy(n);
Node *c;
for (c = firstChild(np); c; c = nextSibling(c)) {
@@ -3008,7 +3020,7 @@ Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) {
* Tries to locate a class from a type definition
* ----------------------------------------------------------------------------- */
-Node *Language::classLookup(SwigType *s) {
+Node *Language::classLookup(const SwigType *s) {
Node *n = 0;
/* Look in hash of cached values */
diff --git a/Source/Modules/lua.cxx b/Source/Modules/lua.cxx
index d240d3d6f..d0cbc9195 100644
--- a/Source/Modules/lua.cxx
+++ b/Source/Modules/lua.cxx
@@ -919,7 +919,7 @@ public:
String *wrap_class = NewStringf("&_wrap_class_%s", mangled_classname);
SwigType_remember_clientdata(t, wrap_class);
- String *rt = Copy(Getattr(n, "classtype"));
+ String *rt = Copy(getClassType());
SwigType_add_pointer(rt);
// Register the class structure with the type checker
diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
index f0e941f22..95327018d 100644
--- a/Source/Modules/main.cxx
+++ b/Source/Modules/main.cxx
@@ -129,6 +129,7 @@ static const char *usage3 = (const char *) "\
-oh <headfile> - Set name of the output header file to <headfile>\n\
-outcurrentdir - Set default output dir to current dir instead of input file's path\n\
-outdir <dir> - Set language specific files output directory to <dir>\n\
+ -pcreversion - Display PCRE version information\n\
-small - Compile in virtual elimination & compact mode\n\
-swiglib - Report location of SWIG library and exit\n\
-templatereduce - Reduce all the typedefs in templates\n\
@@ -515,6 +516,12 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else if (strcmp(argv[i], "-nodirprot") == 0) {
Wrapper_director_protected_mode_set(0);
Swig_mark_arg(i);
+ } else if (strcmp(argv[i], "-pcreversion") == 0) {
+ String *version = Swig_pcre_version();
+ Printf(stdout, "%s\n", version);
+ Delete(version);
+ Swig_mark_arg(i);
+ SWIG_exit(EXIT_SUCCESS);
} else if (strcmp(argv[i], "-small") == 0) {
Wrapper_compact_print_mode_set(1);
Wrapper_virtual_elimination_mode_set(1);
@@ -622,7 +629,14 @@ void SWIG_getoptions(int argc, char *argv[]) {
} else if (strcmp(argv[i], "-version") == 0) {
fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version());
fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM);
- fprintf(stdout, "Please see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT);
+ fprintf(stdout, "\nConfigured options: %cpcre\n",
+#ifdef HAVE_PCRE
+ '+'
+#else
+ '-'
+#endif
+ );
+ fprintf(stdout, "\nPlease see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT);
SWIG_exit(EXIT_SUCCESS);
} else if (strcmp(argv[i], "-copyright") == 0) {
fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version());
diff --git a/Source/Modules/modula3.cxx b/Source/Modules/modula3.cxx
index edd6690ce..45ceba1a4 100644
--- a/Source/Modules/modula3.cxx
+++ b/Source/Modules/modula3.cxx
@@ -2222,8 +2222,7 @@ MODULA3():
}
base = Next(base);
if (base.item != NIL) {
- Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
- line_number,
+ Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
classDeclarationName, Getattr(base.item, "name"));
}
@@ -2236,8 +2235,7 @@ MODULA3():
// Inheritance from pure Modula 3 classes
const String *pure_baseclass = typemapLookup(n, "m3base", classDeclarationName, WARN_NONE);
if (hasContent(pure_baseclass) && hasContent(baseclass)) {
- Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
- line_number,
+ Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", classDeclarationName, pure_baseclass);
}
// Pure Modula 3 interfaces
@@ -2273,7 +2271,7 @@ MODULA3():
destruct_methodname = Getattr(attributes, "tmap:m3destruct:methodname");
}
if (!destruct_methodname) {
- Swig_error(input_file, line_number, "No methodname attribute defined in m3destruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
+ Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in m3destruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
}
// Emit the Finalize and Dispose methods
if (tm) {
@@ -2466,8 +2464,7 @@ MODULA3():
Append(baseclassname, Getattr(base.item, "sym:name"));
base = Next(base);
if (base.item != NIL) {
- Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
- line_number,
+ Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
proxy_class_name, Getattr(base.item, "name"));
}
diff --git a/Source/Modules/mzscheme.cxx b/Source/Modules/mzscheme.cxx
index 0bc3c8a68..d071dc870 100644
--- a/Source/Modules/mzscheme.cxx
+++ b/Source/Modules/mzscheme.cxx
@@ -682,7 +682,7 @@ public:
String *mangled_classname = 0;
String *real_classname = 0;
String *scm_structname = NewString("");
- SwigType *ctype_ptr = NewStringf("p.%s", Getattr(n, "classtype"));
+ SwigType *ctype_ptr = NewStringf("p.%s", getClassType());
SwigType *t = NewStringf("p.%s", Getattr(n, "name"));
swigtype_ptr = SwigType_manglestr(t);
diff --git a/Source/Modules/ocaml.cxx b/Source/Modules/ocaml.cxx
index 82e3f846a..6021cf276 100644
--- a/Source/Modules/ocaml.cxx
+++ b/Source/Modules/ocaml.cxx
@@ -35,7 +35,7 @@ static String *classname = 0;
static String *module = 0;
static String *init_func_def = 0;
static String *f_classtemplate = 0;
-static String *name_qualifier = 0;
+static SwigType *name_qualifier_type = 0;
static Hash *seen_enums = 0;
static Hash *seen_enumvalues = 0;
@@ -898,12 +898,12 @@ public:
String *name = Getattr(n, "feature:symname");
SwigType *type = Getattr(n, "type");
String *value = Getattr(n, "value");
- String *qvalue = Getattr(n, "qualified:value");
+ SwigType *qname = Getattr(n, "qualified:name");
String *rvalue = NewString("");
String *temp = 0;
- if (qvalue)
- value = qvalue;
+ if (qname)
+ value = qname;
if (!name) {
name = mangleNameForCaml(Getattr(n, "name"));
@@ -1228,20 +1228,18 @@ public:
return out;
}
- String *fully_qualify_enum_name(Node *n, String *name) {
+ SwigType *fully_qualified_enum_type(Node *n) {
Node *parent = 0;
- String *qualification = NewString("");
String *fully_qualified_name = NewString("");
String *parent_type = 0;
- String *normalized_name;
parent = parentNode(n);
while (parent) {
parent_type = nodeType(parent);
if (Getattr(parent, "name")) {
String *parent_copy = NewStringf("%s::", Getattr(parent, "name"));
- if (!Cmp(parent_type, "class") || !Cmp(parent_type, "namespace"))
- Insert(qualification, 0, parent_copy);
+ if (Cmp(parent_type, "class") == 0 || Cmp(parent_type, "namespace") == 0)
+ Insert(fully_qualified_name, 0, parent_copy);
Delete(parent_copy);
}
if (!Cmp(parent_type, "class"))
@@ -1249,25 +1247,18 @@ public:
parent = parentNode(parent);
}
- Printf(fully_qualified_name, "%s%s", qualification, name);
-
- normalized_name = normalizeTemplatedClassName(fully_qualified_name);
- if (!strncmp(Char(normalized_name), "enum ", 5)) {
- Insert(normalized_name, 5, qualification);
- }
-
- return normalized_name;
+ return fully_qualified_name;
}
/* Benedikt Grundmann inspired --> Enum wrap styles */
int enumvalueDeclaration(Node *n) {
String *name = Getattr(n, "name");
- String *qvalue = 0;
+ SwigType *qtype = 0;
- if (name_qualifier) {
- qvalue = Copy(name_qualifier);
- Printv(qvalue, name, NIL);
+ if (name_qualifier_type) {
+ qtype = Copy(name_qualifier_type);
+ Printv(qtype, name, NIL);
}
if (const_enum && name && !Getattr(seen_enumvalues, name)) {
@@ -1275,10 +1266,10 @@ public:
SetFlag(n, "feature:immutable");
Setattr(n, "feature:enumvalue", "1"); // this does not appear to be used
- if (qvalue)
- Setattr(n, "qualified:value", qvalue);
+ if (qtype)
+ Setattr(n, "qualified:name", SwigType_namestr(qtype));
- String *evname = SwigType_manglestr(qvalue);
+ String *evname = SwigType_manglestr(qtype);
Insert(evname, 0, "SWIG_ENUM_");
Setattr(n, "feature:enumvname", name);
@@ -1309,10 +1300,10 @@ public:
/* name is now fully qualified */
String *fully_qualified_name = NewString(name);
bool seen_enum = false;
- if (name_qualifier)
- Delete(name_qualifier);
+ if (name_qualifier_type)
+ Delete(name_qualifier_type);
char *strip_position;
- name_qualifier = fully_qualify_enum_name(n, NewString(""));
+ name_qualifier_type = fully_qualified_enum_type(n);
strip_position = strstr(Char(oname), "::");
diff --git a/Source/Modules/php.cxx b/Source/Modules/php.cxx
index 365fcd370..554e40bb8 100644
--- a/Source/Modules/php.cxx
+++ b/Source/Modules/php.cxx
@@ -126,7 +126,7 @@ static enum {
} wrapperType = standard;
extern "C" {
- static void (*r_prevtracefunc) (SwigType *t, String *mangled, String *clientdata) = 0;
+ static void (*r_prevtracefunc) (const SwigType *t, String *mangled, String *clientdata) = 0;
}
static void SwigPHP_emit_resource_registrations() {
@@ -666,7 +666,7 @@ public:
/* We have an extra 'this' parameter. */
SetFlag(n, "wrap:this");
}
- String *dispatch = Swig_overload_dispatch(n, "return %s(INTERNAL_FUNCTION_PARAM_PASSTHRU);", &maxargs);
+ String *dispatch = Swig_overload_dispatch(n, "%s(INTERNAL_FUNCTION_PARAM_PASSTHRU); return;", &maxargs);
/* Generate a dispatch wrapper for all overloaded functions */
@@ -915,8 +915,10 @@ public:
}
/* Insert argument output code */
+ bool hasargout = false;
for (i = 0, p = l; p; i++) {
if ((tm = Getattr(p, "tmap:argout"))) {
+ hasargout = true;
Replaceall(tm, "$source", Getattr(p, "lname"));
// Replaceall(tm,"$input",Getattr(p,"lname"));
Replaceall(tm, "$target", "return_value");
@@ -974,7 +976,7 @@ public:
/* Error handling code */
Printf(f->code, "fail:\n");
Printv(f->code, cleanup, NIL);
- Printv(f->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL);
+ Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL);
Printf(f->code, "}\n");
@@ -1599,10 +1601,9 @@ public:
Delete(args);
args = NewString("$res=null");
}
- SwigType *t = Getattr(current_class, "classtype");
- String *mangled_type = SwigType_manglestr(SwigType_ltype(t));
+ String *mangled_type = SwigType_manglestr(Getattr(n, "type"));
Printf(output, "\t%sfunction %s(%s) {\n", acc, methodname, args);
- Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) === '_p%s') {\n", arg0, arg0, mangled_type);
+ Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) === '%s') {\n", arg0, arg0, mangled_type);
Printf(output, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg0);
Printf(output, "\t\t\treturn;\n");
Printf(output, "\t\t}\n");
@@ -1663,7 +1664,7 @@ public:
}
}
Printf(output, "%s", prepare);
- } else if (Cmp(d, "void") == 0) {
+ } else if (Cmp(d, "void") == 0 && !hasargout) {
if (Cmp(invoke, "$r") != 0)
Printf(output, "\t\t%s;\n", invoke);
} else if (is_class(d)) {
@@ -2289,7 +2290,7 @@ done:
Append(f->code, "return;\n");
Append(f->code, "fail:\n");
- Append(f->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
+ Append(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
Printf(f->code, "}\n");
Wrapper_print(f, s_wrappers);
@@ -2664,7 +2665,7 @@ done:
}
Append(w->code, "fail:\n");
- Append(w->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
+ Append(w->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
Append(w->code, "}\n");
// We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method
@@ -2709,7 +2710,7 @@ static PHP *maininstance = 0;
// We use this function to be able to write out zend_register_list_destructor_ex
// lines for most things in the type table
// NOTE: it's a function NOT A PHP::METHOD
-extern "C" void typetrace(SwigType *ty, String *mangled, String *clientdata) {
+extern "C" void typetrace(const SwigType *ty, String *mangled, String *clientdata) {
Node *class_node;
if (!zend_types) {
zend_types = NewHash();
diff --git a/Source/Modules/python.cxx b/Source/Modules/python.cxx
index fed5205e1..6d5f500a4 100644
--- a/Source/Modules/python.cxx
+++ b/Source/Modules/python.cxx
@@ -130,7 +130,7 @@ static const char *usage2 = (char *) "\
-nofastproxy - Use traditional proxy mechanism for member methods (default) \n\
-nofastquery - Use traditional query mechanism for types (default) \n\
-noh - Don't generate the output header file\n\
- -nomodern - Don't use modern python features which are not back compatible \n\
+ -nomodern - Don't use modern python features which are not backwards compatible \n\
-nomodernargs - Use classic ParseTuple/CallFunction methods to pack/unpack the function arguments (default) \n";
static const char *usage3 = (char *) "\
-noolddefs - Don't emit the old method definitions even when using fastproxy (default) \n\
@@ -1799,7 +1799,7 @@ public:
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
Append(f->code, "fail:\n");
Printf(f->code, "SWIG_SetErrorMsg(PyExc_NotImplementedError,"
- "\"Wrong number of arguments for overloaded function '%s'.\\n\"" "\n\" Possible C/C++ prototypes are:\\n\"%s);\n", symname, protoTypes);
+ "\"Wrong number or type of arguments for overloaded function '%s'.\\n\"" "\n\" Possible C/C++ prototypes are:\\n\"%s);\n", symname, protoTypes);
Append(f->code, "return NULL;\n");
Delete(protoTypes);
}
@@ -2866,7 +2866,7 @@ public:
bool ignore = GetFlag(b.item, "feature:ignore") ? true : false;
if (!bname || ignore) {
if (!bname && !ignore) {
- Swig_warning(WARN_TYPE_UNDEFINED_CLASS, input_file, line_number,
+ Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(n), Getline(n),
"Base class '%s' ignored - unknown module name for base. Either import the appropriate module interface file or specify the name of the module in the %%import directive.\n", SwigType_namestr(Getattr(b.item, "name")));
}
b = Next(b);
diff --git a/Source/Modules/r.cxx b/Source/Modules/r.cxx
index 749797c78..64583175b 100644
--- a/Source/Modules/r.cxx
+++ b/Source/Modules/r.cxx
@@ -300,7 +300,7 @@ public:
Printf(stderr, "<memberfunctionHandler> %s %s\n",
Getattr(n, "name"),
Getattr(n, "type"));
- member_name = Getattr(n, "name");
+ member_name = Getattr(n, "sym:name");
processing_class_member_function = 1;
int status = Language::memberfunctionHandler(n);
processing_class_member_function = 0;
@@ -1603,6 +1603,16 @@ void R::dispatchFunction(Node *n) {
j == 0 ? "" : " && ",
j+1);
}
+ else if (DohStrcmp(tm,"integer")==0) {
+ Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))",
+ j == 0 ? "" : " && ",
+ j+1, j+1);
+ }
+ else if (DohStrcmp(tm,"character")==0) {
+ Printf(f->code, "%sis.character(argv[[%d]])",
+ j == 0 ? "" : " && ",
+ j+1);
+ }
else {
Printf(f->code, "%sextends(argtypes[%d], '%s')",
j == 0 ? "" : " && ",
@@ -1617,7 +1627,10 @@ void R::dispatchFunction(Node *n) {
}
}
if (cur_args != -1) {
- Printv(f->code, "}", NIL);
+ Printf(f->code, "} else {\n"
+ "stop(\"cannot find overloaded function for %s with argtypes (\","
+ "toString(argtypes),\")\");\n"
+ "}", sfname);
}
Printv(f->code, ";\nf(...)", NIL);
Printv(f->code, ";\n}", NIL);
diff --git a/Source/Modules/ruby.cxx b/Source/Modules/ruby.cxx
index bcdfd69d3..8461b8bef 100644
--- a/Source/Modules/ruby.cxx
+++ b/Source/Modules/ruby.cxx
@@ -2054,8 +2054,15 @@ public:
// Construct real method name
String* methodName = NewString("");
- if ( isMethod )
- Printv( methodName, Getattr(parentNode(sibl),"sym:name"), ".", NIL );
+ if ( isMethod ) {
+ // Sometimes a method node has no parent (SF#3034054).
+ // This value is used in an exception message, so just skip the class
+ // name in this case so at least we don't segfault. This is probably
+ // just working around a problem elsewhere though.
+ Node *parent_node = parentNode(sibl);
+ if (parent_node)
+ Printv( methodName, Getattr(parent_node,"sym:name"), ".", NIL );
+ }
Append( methodName, Getattr(sibl,"sym:name" ) );
if ( isCtor ) Append( methodName, ".new" );
@@ -2395,7 +2402,7 @@ public:
}
String *proxyclassname = SwigType_str(Getattr(n, "classtypeobj"), 0);
String *baseclassname = SwigType_str(Getattr(base.item, "name"), 0);
- Swig_warning(WARN_RUBY_MULTIPLE_INHERITANCE, input_file, line_number,
+ Swig_warning(WARN_RUBY_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Ruby.\n", proxyclassname, baseclassname);
base = Next(base);
}
diff --git a/Source/Modules/swigmain.cxx b/Source/Modules/swigmain.cxx
index 844229a96..bcccf7a1b 100644
--- a/Source/Modules/swigmain.cxx
+++ b/Source/Modules/swigmain.cxx
@@ -53,6 +53,7 @@ extern "C" {
Language *swig_uffi(void);
Language *swig_r(void);
Language *swig_go(void);
+ Language *swig_d(void);
}
struct swig_module {
@@ -71,6 +72,7 @@ static swig_module modules[] = {
{"-clisp", swig_clisp, "CLISP"},
{"-cffi", swig_cffi, "CFFI"},
{"-csharp", swig_csharp, "C#"},
+ {"-d", swig_d, "D"},
{"-fortran", swig_fortran, "FORTRAN"},
{"-go", swig_go, "Go"},
{"-guile", swig_guile, "Guile"},
diff --git a/Source/Modules/swigmod.h b/Source/Modules/swigmod.h
index 693a67071..142130628 100644
--- a/Source/Modules/swigmod.h
+++ b/Source/Modules/swigmod.h
@@ -213,7 +213,7 @@ public:
virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */
virtual void dumpSymbols();
virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
- virtual Node *classLookup(SwigType *s); /* Class lookup */
+ virtual Node *classLookup(const SwigType *s); /* Class lookup */
virtual Node *enumLookup(SwigType *s); /* Enum lookup */
virtual int abstractClassTest(Node *n); /* Is class really abstract? */
virtual int is_assignable(Node *n); /* Is variable assignable? */
@@ -382,9 +382,15 @@ void Wrapper_fast_dispatch_mode_set(int);
void Wrapper_cast_dispatch_mode_set(int);
void Wrapper_naturalvar_mode_set(int);
-
void clean_overloaded(Node *n);
+extern "C" {
+ const char *Swig_to_string(DOH *object, int count = -1);
+ const char *Swig_to_string_with_location(DOH *object, int count = -1);
+ void Swig_print(DOH *object, int count = -1);
+ void Swig_print_with_location(DOH *object, int count = -1);
+}
+
/* Contracts */
void Swig_contracts(Node *n);
@@ -397,5 +403,4 @@ void Swig_browser(Node *n, int);
void Swig_default_allocators(Node *n);
void Swig_process_types(Node *n);
-
#endif
diff --git a/Source/Modules/tcl8.cxx b/Source/Modules/tcl8.cxx
index b6b4c6965..dfdd71b64 100644
--- a/Source/Modules/tcl8.cxx
+++ b/Source/Modules/tcl8.cxx
@@ -783,10 +783,7 @@ public:
String *wrap_class = NewStringf("&_wrap_class_%s", mangled_classname);
SwigType_remember_clientdata(t, wrap_class);
- // t = Copy(Getattr(n,"classtype"));
- // SwigType_add_pointer(t);
-
- String *rt = Copy(Getattr(n, "classtype"));
+ String *rt = Copy(getClassType());
SwigType_add_pointer(rt);
// Register the class structure with the type checker
diff --git a/Source/Modules/typepass.cxx b/Source/Modules/typepass.cxx
index e0e06d54e..3e2c9ca1e 100644
--- a/Source/Modules/typepass.cxx
+++ b/Source/Modules/typepass.cxx
@@ -175,10 +175,10 @@ class TypePass:private Dispatcher {
}
}
if (Strcmp(nodeType(bcls), "classforward") != 0) {
- Swig_error(Getfile(cls), Getline(cls), "'%s' does not have a valid base class.\n", Getattr(cls, "name"));
- Swig_error(Getfile(bcls), Getline(bcls), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
+ Swig_error(Getfile(bname), Getline(bname), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
+ Swig_error(Getfile(bcls), Getline(bcls), "See definition of '%s'.\n", SwigType_namestr(bname));
} else {
- Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(cls), Getline(cls), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
+ Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bname), Getline(bname), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bcls), Getline(bcls), "Only forward declaration '%s' was found.\n", SwigType_namestr(bname));
clsforward = 1;
}
@@ -189,7 +189,7 @@ class TypePass:private Dispatcher {
ilist = alist = NewList();
Append(ilist, bcls);
} else {
- Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Base class '%s' undefined.\n", SwigType_namestr(bname));
+ Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' undefined.\n", SwigType_namestr(bname));
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "'%s' must be defined before it is used as a base class.\n", SwigType_namestr(bname));
}
}
@@ -202,10 +202,9 @@ class TypePass:private Dispatcher {
if (!bcls) {
if (!clsforward) {
if (ispublic && !Getmeta(bname, "already_warned")) {
- Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
+ Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
if (Strchr(bname, '<')) {
- Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Maybe you forgot to instantiate '%s' using %%template.\n",
- SwigType_namestr(bname));
+ Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Maybe you forgot to instantiate '%s' using %%template.\n", SwigType_namestr(bname));
}
Setmeta(bname, "already_warned", "1");
}
@@ -255,12 +254,17 @@ class TypePass:private Dispatcher {
Delete(smartnamestr);
/* setup inheritance relationship between smart pointer templates */
SwigType_inherit(smart, bsmart, 0, convcode);
+ if (!GetFlag(bclass, "feature:smartptr"))
+ Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name")));
Delete(convcode);
Delete(bsmart);
Delete(smart);
} else {
- Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, clsname);
+ Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname));
}
+ } else {
+ if (GetFlag(bclass, "feature:smartptr"))
+ Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name")));
}
if (!importmode) {
String *btype = Copy(bname);
@@ -275,7 +279,7 @@ class TypePass:private Dispatcher {
Symtab *st = Getattr(cls, "symtab");
Symtab *bst = Getattr(bclass, "symtab");
if (st == bst) {
- Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", Getattr(cls, "name"));
+ Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", SwigType_namestr(Getattr(cls, "name")));
continue;
}
Symtab *s = Swig_symbol_current();
@@ -995,6 +999,7 @@ class TypePass:private Dispatcher {
}
Node *nn = copyNode(c);
Delattr(nn, "access"); // access might be different from the method in the base class
+ Setattr(nn, "access", Getattr(n, "access"));
if (!Getattr(nn, "sym:name"))
Setattr(nn, "sym:name", symname);
diff --git a/Source/Modules/utils.cxx b/Source/Modules/utils.cxx
index 3fe7a2709..13a504bcf 100644
--- a/Source/Modules/utils.cxx
+++ b/Source/Modules/utils.cxx
@@ -100,3 +100,116 @@ void clean_overloaded(Node *n) {
Delattr(n, "sym:overloaded");
}
}
+
+/* -----------------------------------------------------------------------------
+ * Swig_set_max_hash_expand()
+ *
+ * Controls how many Hash objects are displayed when displaying nested Hash objects.
+ * Makes DohSetMaxHashExpand an externally callable function (for debugger).
+ * ----------------------------------------------------------------------------- */
+
+void Swig_set_max_hash_expand(int count) {
+ SetMaxHashExpand(count);
+}
+
+extern "C" {
+
+/* -----------------------------------------------------------------------------
+ * Swig_get_max_hash_expand()
+ *
+ * Returns how many Hash objects are displayed when displaying nested Hash objects.
+ * Makes DohGetMaxHashExpand an externally callable function (for debugger).
+ * ----------------------------------------------------------------------------- */
+
+int Swig_get_max_hash_expand() {
+ return GetMaxHashExpand();
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_to_doh_string()
+ *
+ * DOH version of Swig_to_string()
+ * ----------------------------------------------------------------------------- */
+
+static String *Swig_to_doh_string(DOH *object, int count) {
+ int old_count = Swig_get_max_hash_expand();
+ if (count >= 0)
+ Swig_set_max_hash_expand(count);
+
+ String *debug_string = object ? NewStringf("%s", object) : NewString("NULL");
+
+ Swig_set_max_hash_expand(old_count);
+ return debug_string;
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_to_doh_string_with_location()
+ *
+ * DOH version of Swig_to_string_with_location()
+ * ----------------------------------------------------------------------------- */
+
+static String *Swig_to_doh_string_with_location(DOH *object, int count) {
+ int old_count = Swig_get_max_hash_expand();
+ if (count >= 0)
+ Swig_set_max_hash_expand(count);
+
+ String *debug_string = Swig_stringify_with_location(object);
+
+ Swig_set_max_hash_expand(old_count);
+ return debug_string;
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_to_string()
+ *
+ * Swig debug - return C string representation of any DOH type.
+ * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
+ * Note: leaks memory.
+ * ----------------------------------------------------------------------------- */
+
+const char *Swig_to_string(DOH *object, int count) {
+ return Char(Swig_to_doh_string(object, count));
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_to_string_with_location()
+ *
+ * Swig debug - return C string representation of any DOH type, within [] brackets
+ * for Hash and List types, prefixed by line and file information.
+ * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
+ * Note: leaks memory.
+ * ----------------------------------------------------------------------------- */
+
+const char *Swig_to_string_with_location(DOH *object, int count) {
+ return Char(Swig_to_doh_string_with_location(object, count));
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_print()
+ *
+ * Swig debug - display string representation of any DOH type.
+ * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
+ * ----------------------------------------------------------------------------- */
+
+void Swig_print(DOH *object, int count) {
+ String *output = Swig_to_doh_string(object, count);
+ Printf(stdout, "%s\n", output);
+ Delete(output);
+}
+
+/* -----------------------------------------------------------------------------
+ * Swig_to_string_with_location()
+ *
+ * Swig debug - display string representation of any DOH type, within [] brackets
+ * for Hash and List types, prefixed by line and file information.
+ * Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
+ * ----------------------------------------------------------------------------- */
+
+void Swig_print_with_location(DOH *object, int count) {
+ String *output = Swig_to_doh_string_with_location(object, count);
+ Printf(stdout, "%s\n", output);
+ Delete(output);
+}
+
+} // extern "C"
+
diff --git a/Source/Preprocessor/cpp.c b/Source/Preprocessor/cpp.c
index 5dd320994..2da4944c9 100644
--- a/Source/Preprocessor/cpp.c
+++ b/Source/Preprocessor/cpp.c
@@ -33,6 +33,10 @@ static Hash *included_files = 0;
static List *dependencies = 0;
static Scanner *id_scan = 0;
static int error_as_warning = 0; /* Understand the cpp #error directive as a special #warning */
+static int expand_defined_operator = 0;
+static int macro_level = 0;
+static int macro_start_line = 0;
+static const String * macro_start_file = 0;
/* Test a character to see if it starts an identifier */
#define isidentifier(c) ((isalpha(c)) || (c == '_') || (c == '$'))
@@ -40,7 +44,7 @@ static int error_as_warning = 0; /* Understand the cpp #error directive as a spe
/* Test a character to see if it valid in an identifier (after the first letter) */
#define isidchar(c) ((isalnum(c)) || (c == '_') || (c == '$'))
-DOH *Preprocessor_replace(DOH *);
+static DOH *Preprocessor_replace(DOH *);
/* Skip whitespace */
static void skip_whitespace(String *s, String *out) {
@@ -148,6 +152,9 @@ static String *kpp_dextern = 0;
static String *kpp_LINE = 0;
static String *kpp_FILE = 0;
+static String *kpp_hash_if = 0;
+static String *kpp_hash_elif = 0;
+
void Preprocessor_init(void) {
Hash *s;
@@ -184,6 +191,9 @@ void Preprocessor_init(void) {
kpp_LINE = NewString("__LINE__");
kpp_FILE = NewString("__FILE__");
+ kpp_hash_if = NewString("#if");
+ kpp_hash_elif = NewString("#elif");
+
cpp = NewHash();
s = NewHash();
Setattr(cpp, kpp_symbols, s);
@@ -225,9 +235,12 @@ void Preprocessor_delete(void) {
Delete(kpp_ddefine);
Delete(kpp_dline);
-
Delete(kpp_LINE);
Delete(kpp_FILE);
+
+ Delete(kpp_hash_if);
+ Delete(kpp_hash_elif);
+
Delete(cpp);
Delete(included_files);
Preprocessor_expr_delete();
@@ -322,6 +335,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
/* Now look for a macro name */
macroname = NewStringEmpty();
+ copy_location(str, macroname);
while ((c = Getc(str)) != EOF) {
if (c == '(') {
argstr = NewStringEmpty();
@@ -334,7 +348,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
Putc(c, argstr);
}
if (c != ')') {
- Swig_error(Getfile(str), Getline(str), "Missing \')\' in macro parameters\n");
+ Swig_error(Getfile(argstr), Getline(argstr), "Missing \')\' in macro parameters\n");
goto macro_error;
}
break;
@@ -350,8 +364,6 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
break;
}
} else {
- /*Swig_error(Getfile(str),Getline(str),"Illegal character in macro name\n");
- goto macro_error; */
Ungetc(c, str);
break;
}
@@ -359,6 +371,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
if (!swigmacro)
skip_whitespace(str, 0);
macrovalue = NewStringEmpty();
+ copy_location(str, macrovalue);
while ((c = Getc(str)) != EOF) {
Putc(c, macrovalue);
}
@@ -371,10 +384,10 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
argname = NewStringEmpty();
while ((c = Getc(argstr)) != EOF) {
if (c == ',') {
- varargname = Macro_vararg_name(argname, str);
+ varargname = Macro_vararg_name(argname, argstr);
if (varargname) {
Delete(varargname);
- Swig_error(Getfile(str), Getline(str), "Variable-length macro argument must be last parameter\n");
+ Swig_error(Getfile(argstr), Getline(argstr), "Variable length macro argument must be last parameter\n");
} else {
Append(arglist, argname);
}
@@ -384,13 +397,13 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
Putc(c, argname);
} else if (!(isspace(c) || (c == '\\'))) {
Delete(argname);
- Swig_error(Getfile(str), Getline(str), "Illegal character in macro argument name\n");
+ Swig_error(Getfile(argstr), Getline(argstr), "Illegal character in macro argument name\n");
goto macro_error;
}
}
if (Len(argname)) {
/* Check for varargs */
- varargname = Macro_vararg_name(argname, str);
+ varargname = Macro_vararg_name(argname, argstr);
if (varargname) {
Append(arglist, varargname);
Delete(varargname);
@@ -508,7 +521,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
symbols = Getattr(cpp, kpp_symbols);
if ((m1 = Getattr(symbols, macroname))) {
if (!Checkattr(m1, kpp_value, macrovalue)) {
- Swig_error(Getfile(str), Getline(str), "Macro '%s' redefined,\n", macroname);
+ Swig_error(Getfile(macroname), Getline(macroname), "Macro '%s' redefined,\n", macroname);
Swig_error(Getfile(m1), Getline(m1), "previous definition of '%s'.\n", macroname);
goto macro_error;
}
@@ -551,7 +564,7 @@ void Preprocessor_undef(const_String_or_char_ptr str) {
* Isolates macro arguments and returns them in a list. For each argument,
* leading and trailing whitespace is stripped (ala K&R, pg. 230).
* ----------------------------------------------------------------------------- */
-static List *find_args(String *s) {
+static List *find_args(String *s, int ismacro, String *macro_name) {
List *args;
String *str;
int c, level;
@@ -622,12 +635,15 @@ static List *find_args(String *s) {
c = Getc(s);
}
unterm:
- Swig_error(Getfile(args), Getline(args), "Unterminated macro call.\n");
+ if (ismacro)
+ Swig_error(Getfile(args), Getline(args), "Unterminated call invoking macro '%s'\n", macro_name);
+ else
+ Swig_error(Getfile(args), Getline(args), "Unterminated call to '%s'\n", macro_name);
return args;
}
/* -----------------------------------------------------------------------------
- * DOH *get_filename(DOH *str)
+ * DOH *get_filename()
*
* Read a filename from str. A filename can be enclosed in quotes, angle brackets,
* or bare.
@@ -637,7 +653,6 @@ static String *get_filename(String *str, int *sysfile) {
String *fn;
int c;
- skip_whitespace(str, 0);
fn = NewStringEmpty();
copy_location(str, fn);
c = Getc(str);
@@ -663,9 +678,7 @@ static String *get_filename(String *str, int *sysfile) {
}
static String *get_options(String *str) {
-
int c;
- skip_whitespace(str, 0);
c = Getc(str);
if (c == '(') {
String *opt;
@@ -694,9 +707,12 @@ static String *get_options(String *str) {
*
* Perform macro expansion and return a new string. Returns NULL if some sort
* of error occurred.
+ * name - name of the macro
+ * args - arguments passed to the macro
+ * line_file - only used for line/file name when reporting errors
* ----------------------------------------------------------------------------- */
-static String *expand_macro(String *name, List *args) {
+static String *expand_macro(String *name, List *args, String *line_file) {
String *ns;
DOH *symbols, *macro, *margs, *mvalue, *temp, *tempa, *e;
int i, l;
@@ -710,6 +726,14 @@ static String *expand_macro(String *name, List *args) {
macro = Getattr(symbols, name);
if (!macro)
return 0;
+
+ if (macro_level == 0) {
+ /* Store the start of the macro should the macro contain __LINE__ and __FILE__ for expansion */
+ macro_start_line = Getline(args ? args : line_file);
+ macro_start_file = Getfile(args ? args : line_file);
+ }
+ macro_level++;
+
if (Getattr(macro, kpp_expanded)) {
ns = NewStringEmpty();
Append(ns, name);
@@ -725,6 +749,7 @@ static String *expand_macro(String *name, List *args) {
if (i)
Putc(')', ns);
}
+ macro_level--;
return ns;
}
@@ -759,16 +784,18 @@ static String *expand_macro(String *name, List *args) {
/* If there are arguments, see if they match what we were given */
if (args && (margs) && (Len(margs) != Len(args))) {
if (Len(margs) > (1 + isvarargs))
- Swig_error(Getfile(args), Getline(args), "Macro '%s' expects %d arguments\n", name, Len(margs) - isvarargs);
+ Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects %d arguments\n", name, Len(margs) - isvarargs);
else if (Len(margs) == (1 + isvarargs))
- Swig_error(Getfile(args), Getline(args), "Macro '%s' expects 1 argument\n", name);
+ Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects 1 argument\n", name);
else
- Swig_error(Getfile(args), Getline(args), "Macro '%s' expects no arguments\n", name);
+ Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects no arguments\n", name);
+ macro_level--;
return 0;
}
/* If the macro expects arguments, but none were supplied, we leave it in place */
if (!args && (margs) && Len(margs) > 0) {
+ macro_level--;
return NewString(name);
}
@@ -922,28 +949,13 @@ static String *expand_macro(String *name, List *args) {
Delete(e);
e = f;
}
+ macro_level--;
Delete(temp);
Delete(tempa);
return e;
}
/* -----------------------------------------------------------------------------
- * evaluate_args()
- *
- * Evaluate the arguments of a macro
- * ----------------------------------------------------------------------------- */
-
-List *evaluate_args(List *x) {
- Iterator i;
- List *nl = NewList();
-
- for (i = First(x); i.item; i = Next(i)) {
- Append(nl, Preprocessor_replace(i.item));
- }
- return nl;
-}
-
-/* -----------------------------------------------------------------------------
* DOH *Preprocessor_replace(DOH *s)
*
* Performs a macro substitution on a string s. Returns a new string with
@@ -954,10 +966,9 @@ List *evaluate_args(List *x) {
/* #define SWIG_PUT_BUFF */
-DOH *Preprocessor_replace(DOH *s) {
+static DOH *Preprocessor_replace(DOH *s) {
DOH *ns, *symbols, *m;
int c, i, state = 0;
-
String *id = NewStringEmpty();
assert(cpp);
@@ -971,10 +982,18 @@ DOH *Preprocessor_replace(DOH *s) {
while ((c = Getc(s)) != EOF) {
switch (state) {
case 0:
- if (isidentifier(c) || (c == '%')) {
+ if (isidentifier(c)) {
Clear(id);
Putc(c, id);
- state = 1;
+ state = 4;
+ } else if (c == '%') {
+ Clear(id);
+ Putc(c, id);
+ state = 2;
+ } else if (c == '#') {
+ Clear(id);
+ Putc(c, id);
+ state = 4;
} else if (c == '\"') {
Putc(c, ns);
skip_tochar(s, '\"', ns);
@@ -984,86 +1003,115 @@ DOH *Preprocessor_replace(DOH *s) {
} else if (c == '/') {
Putc(c, ns);
state = 10;
+ } else if (c == '\\') {
+ Putc(c, ns);
+ c = Getc(s);
+ if (c == '\n') {
+ Putc(c, ns);
+ } else {
+ Ungetc(c, s);
+ }
+ } else if (c == '\n') {
+ Putc(c, ns);
+ expand_defined_operator = 0;
} else {
Putc(c, ns);
}
break;
- case 1: /* An identifier */
+ case 2:
+ /* Found '%#' */
+ if (c == '#') {
+ Putc(c, id);
+ state = 4;
+ } else {
+ Ungetc(c, s);
+ state = 4;
+ }
+ break;
+ case 4: /* An identifier */
if (isidchar(c)) {
Putc(c, id);
- state = 1;
+ state = 4;
} else {
/* We found the end of a valid identifier */
Ungetc(c, s);
- /* See if this is the special "defined" macro */
- if (Equal(kpp_defined, id)) {
- int lenargs = 0;
- DOH *args = 0;
- /* See whether or not a paranthesis has been used */
- skip_whitespace(s, 0);
- c = Getc(s);
- if (c == '(') {
- Ungetc(c, s);
- args = find_args(s);
- } else if (isidchar(c)) {
- DOH *arg = NewStringEmpty();
- args = NewList();
- Putc(c, arg);
- while (((c = Getc(s)) != EOF)) {
- if (!isidchar(c)) {
- Ungetc(c, s);
+ /* See if this is the special "defined" operator */
+ if (Equal(kpp_defined, id)) {
+ if (expand_defined_operator) {
+ int lenargs = 0;
+ DOH *args = 0;
+ /* See whether or not a parenthesis has been used */
+ skip_whitespace(s, 0);
+ c = Getc(s);
+ if (c == '(') {
+ Ungetc(c, s);
+ args = find_args(s, 0, kpp_defined);
+ } else if (isidchar(c)) {
+ DOH *arg = NewStringEmpty();
+ args = NewList();
+ Putc(c, arg);
+ while (((c = Getc(s)) != EOF)) {
+ if (!isidchar(c)) {
+ Ungetc(c, s);
+ break;
+ }
+ Putc(c, arg);
+ }
+ if (Len(arg))
+ Append(args, arg);
+ Delete(arg);
+ } else {
+ Seek(s, -1, SEEK_CUR);
+ }
+ lenargs = Len(args);
+ if ((!args) || (!lenargs)) {
+ /* This is not a defined() operator. */
+ Append(ns, id);
+ state = 0;
+ break;
+ }
+ for (i = 0; i < lenargs; i++) {
+ DOH *o = Getitem(args, i);
+ if (!Getattr(symbols, o)) {
break;
}
- Putc(c, arg);
}
- if (Len(arg))
- Append(args, arg);
- Delete(arg);
+ if (i < lenargs)
+ Putc('0', ns);
+ else
+ Putc('1', ns);
+ Delete(args);
} else {
- Seek(s, -1, SEEK_CUR);
- }
- lenargs = Len(args);
- if ((!args) || (!lenargs)) {
- /* This is not a defined() macro. */
Append(ns, id);
- state = 0;
- break;
- }
- for (i = 0; i < lenargs; i++) {
- DOH *o = Getitem(args, i);
- if (!Getattr(symbols, o)) {
- break;
- }
}
- if (i < lenargs)
- Putc('0', ns);
- else
- Putc('1', ns);
- Delete(args);
state = 0;
break;
- }
- if (Equal(kpp_LINE, id)) {
- Printf(ns, "%d", Getline(s));
+ } else if (Equal(kpp_LINE, id)) {
+ Printf(ns, "%d", macro_level > 0 ? macro_start_line : Getline(s));
state = 0;
break;
- }
- if (Equal(kpp_FILE, id)) {
- String *fn = Copy(Getfile(s));
+ } else if (Equal(kpp_FILE, id)) {
+ String *fn = Copy(macro_level > 0 ? macro_start_file : Getfile(s));
Replaceall(fn, "\\", "\\\\");
Printf(ns, "\"%s\"", fn);
Delete(fn);
state = 0;
break;
- }
- /* See if the macro is defined in the preprocessor symbol table */
- if ((m = Getattr(symbols, id))) {
+ } else if (Equal(kpp_hash_if, id) || Equal(kpp_hash_elif, id)) {
+ expand_defined_operator = 1;
+ Append(ns, id);
+ } else if ((m = Getattr(symbols, id))) {
+ /* See if the macro is defined in the preprocessor symbol table */
DOH *args = 0;
DOH *e;
+ int macro_additional_lines = 0;
/* See if the macro expects arguments */
if (Getattr(m, kpp_args)) {
/* Yep. We need to go find the arguments and do a substitution */
- args = find_args(s);
+ int line = Getline(s);
+ args = find_args(s, 1, id);
+ macro_additional_lines = Getline(s) - line;
+ assert(macro_additional_lines >= 0);
if (!Len(args)) {
Delete(args);
args = 0;
@@ -1071,10 +1119,13 @@ DOH *Preprocessor_replace(DOH *s) {
} else {
args = 0;
}
- e = expand_macro(id, args);
+ e = expand_macro(id, args, s);
if (e) {
Append(ns, e);
}
+ while (macro_additional_lines--) {
+ Putc('\n', ns);
+ }
Delete(e);
Delete(args);
} else {
@@ -1096,11 +1147,15 @@ DOH *Preprocessor_replace(DOH *s) {
Putc(c, ns);
break;
case 11:
+ /* in C++ comment */
Putc(c, ns);
- if (c == '\n')
+ if (c == '\n') {
+ expand_defined_operator = 0;
state = 0;
+ }
break;
case 12:
+ /* in C comment */
Putc(c, ns);
if (c == '*')
state = 13;
@@ -1119,10 +1174,17 @@ DOH *Preprocessor_replace(DOH *s) {
}
/* Identifier at the end */
- if (state == 1) {
- /* See if this is the special "defined" macro */
+ if (state == 2 || state == 4) {
+ /* See if this is the special "defined" operator */
if (Equal(kpp_defined, id)) {
Swig_error(Getfile(s), Getline(s), "No arguments given to defined()\n");
+ } else if (Equal(kpp_LINE, id)) {
+ Printf(ns, "%d", macro_level > 0 ? macro_start_line : Getline(s));
+ } else if (Equal(kpp_FILE, id)) {
+ String *fn = Copy(macro_level > 0 ? macro_start_file : Getfile(s));
+ Replaceall(fn, "\\", "\\\\");
+ Printf(ns, "\"%s\"", fn);
+ Delete(fn);
} else if ((m = Getattr(symbols, id))) {
DOH *e;
/* Yes. There is a macro here */
@@ -1130,8 +1192,9 @@ DOH *Preprocessor_replace(DOH *s) {
/* if (Getattr(m,"args")) {
Swig_error(Getfile(id),Getline(id),"Macro arguments expected.\n");
} */
- e = expand_macro(id, 0);
- Append(ns, e);
+ e = expand_macro(id, 0, s);
+ if (e)
+ Append(ns, e);
Delete(e);
} else {
Append(ns, id);
@@ -1264,8 +1327,8 @@ String *Preprocessor_parse(String *s) {
case 0: /* Initial state - in first column */
/* Look for C preprocessor directives. Otherwise, go directly to state 1 */
if (c == '#') {
- add_chunk(ns, chunk, allow);
copy_location(s, chunk);
+ add_chunk(ns, chunk, allow);
cpp_lines = 1;
state = 40;
} else if (isspace(c)) {
@@ -1414,7 +1477,6 @@ String *Preprocessor_parse(String *s) {
else if (c == '\n') {
Putc('/', value);
Ungetc(c, s);
- cpp_lines++;
state = 50;
} else {
Putc('/', value);
@@ -1422,15 +1484,14 @@ String *Preprocessor_parse(String *s) {
state = 43;
}
break;
- case 46:
+ case 46: /* in C++ comment */
if (c == '\n') {
Ungetc(c, s);
- cpp_lines++;
state = 50;
} else
Putc(c, comment);
break;
- case 47:
+ case 47: /* in C comment */
if (c == '*')
state = 48;
else
@@ -1457,6 +1518,7 @@ String *Preprocessor_parse(String *s) {
m = Preprocessor_define(value, 0);
if ((m) && !(Getattr(m, kpp_args))) {
v = Copy(Getattr(m, kpp_value));
+ copy_location(m, v);
if (Len(v)) {
Swig_error_silent(1);
v1 = Preprocessor_replace(v);
@@ -1525,7 +1587,9 @@ String *Preprocessor_parse(String *s) {
level++;
if (allow) {
int val;
- String *sval = Preprocessor_replace(value);
+ String *sval;
+ expand_defined_operator = 1;
+ sval = Preprocessor_replace(value);
start_level = level;
Seek(sval, 0, SEEK_SET);
/* Printf(stdout,"Evaluating '%s'\n", sval); */
@@ -1541,6 +1605,7 @@ String *Preprocessor_parse(String *s) {
if (val == 0)
allow = 0;
}
+ expand_defined_operator = 0;
mask = 1;
}
} else if (Equal(id, kpp_elif)) {
@@ -1548,6 +1613,7 @@ String *Preprocessor_parse(String *s) {
Swig_error(Getfile(s), Getline(id), "Misplaced #elif.\n");
} else {
cond_lines[level - 1] = Getline(id);
+ expand_defined_operator = 1;
if (allow) {
allow = 0;
mask = 0;
@@ -1570,6 +1636,7 @@ String *Preprocessor_parse(String *s) {
allow = 0;
}
}
+ expand_defined_operator = 0;
}
} else if (Equal(id, kpp_warning)) {
if (allow) {
@@ -1589,12 +1656,14 @@ String *Preprocessor_parse(String *s) {
String *s1, *s2, *fn;
char *dirname;
int sysfile = 0;
+ String *filename_processed;
if (include_all && import_all) {
Swig_warning(WARN_PP_INCLUDEALL_IMPORTALL, Getfile(s), Getline(id), "Both includeall and importall are defined: using includeall\n");
import_all = 0;
}
- Seek(value, 0, SEEK_SET);
- fn = get_filename(value, &sysfile);
+ filename_processed = Preprocessor_replace(value);
+ Seek(filename_processed, 0, SEEK_SET);
+ fn = get_filename(filename_processed, &sysfile);
s1 = cpp_include(fn, sysfile);
if (s1) {
if (include_all)
@@ -1614,7 +1683,7 @@ String *Preprocessor_parse(String *s) {
}
s2 = Preprocessor_parse(s1);
addline(ns, s2, allow);
- Append(ns, "\n]");
+ Append(ns, "]");
if (dirname) {
Swig_pop_directory();
}
@@ -1622,8 +1691,8 @@ String *Preprocessor_parse(String *s) {
pop_imported();
}
Delete(s2);
+ Delete(s1);
}
- Delete(s1);
Delete(fn);
}
} else if (Equal(id, kpp_pragma)) {
@@ -1658,8 +1727,8 @@ String *Preprocessor_parse(String *s) {
/* %{,%} block */
if (c == '{') {
start_line = Getline(s);
- add_chunk(ns, chunk, allow);
copy_location(s, chunk);
+ add_chunk(ns, chunk, allow);
Putc('%', chunk);
Putc(c, chunk);
state = 105;
@@ -1720,9 +1789,13 @@ String *Preprocessor_parse(String *s) {
Ungetc(c, s);
/* Look for common SWIG directives */
if (Equal(decl, kpp_dinclude) || Equal(decl, kpp_dimport) || Equal(decl, kpp_dextern)) {
- /* Got some kind of file inclusion directive */
+ /* Got some kind of file inclusion directive, eg: %import(option1="value1") "filename" */
if (allow) {
DOH *s1, *s2, *fn, *opt;
+ String *options_whitespace = NewStringEmpty();
+ String *filename_whitespace = NewStringEmpty();
+ String *filename_unprocessed = NewStringEmpty();
+ String *filename_processed;
int sysfile = 0;
if (Equal(decl, kpp_dextern)) {
@@ -1730,14 +1803,25 @@ String *Preprocessor_parse(String *s) {
Clear(decl);
Append(decl, "%%import");
}
+ skip_whitespace(s, options_whitespace);
opt = get_options(s);
- fn = get_filename(s, &sysfile);
+
+ skip_whitespace(s, filename_whitespace);
+ copy_location(s, filename_unprocessed);
+ while (((c = Getc(s)) != EOF) && (!isspace(c)))
+ Putc(c, filename_unprocessed);
+ if (isspace(c))
+ Ungetc(c, s);
+ filename_processed = Preprocessor_replace(filename_unprocessed);
+ Seek(filename_processed, 0, SEEK_SET);
+
+ fn = get_filename(filename_processed, &sysfile);
s1 = cpp_include(fn, sysfile);
if (s1) {
char *dirname;
- add_chunk(ns, chunk, allow);
copy_location(s, chunk);
- Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_filename_escape(Swig_last_file()));
+ add_chunk(ns, chunk, allow);
+ Printf(ns, "%sfile%s%s%s\"%s\" [\n", decl, options_whitespace, opt, filename_whitespace, Swig_filename_escape(Swig_last_file()));
if (Equal(decl, kpp_dimport)) {
push_imported();
}
@@ -1756,11 +1840,15 @@ String *Preprocessor_parse(String *s) {
pop_imported();
}
addline(ns, s2, allow);
- Append(ns, "\n]");
+ Append(ns, "]");
Delete(s2);
Delete(s1);
}
Delete(fn);
+ Delete(filename_processed);
+ Delete(filename_unprocessed);
+ Delete(filename_whitespace);
+ Delete(options_whitespace);
}
state = 1;
} else if (Equal(decl, kpp_dline)) {
@@ -1769,8 +1857,8 @@ String *Preprocessor_parse(String *s) {
} else if (Equal(decl, kpp_ddefine)) {
/* Got a define directive */
dlevel++;
- add_chunk(ns, chunk, allow);
copy_location(s, chunk);
+ add_chunk(ns, chunk, allow);
Clear(value);
copy_location(s, value);
state = 150;
@@ -1815,7 +1903,6 @@ String *Preprocessor_parse(String *s) {
Seek(value, 0, SEEK_SET);
Preprocessor_define(value, 1);
}
- /* Putc('\n',ns); */
addline(ns, value, 0);
state = 0;
}
@@ -1844,8 +1931,9 @@ String *Preprocessor_parse(String *s) {
if ((state >= 30) && (state < 40)) {
Swig_error(Getfile(s), -1, "Unterminated comment starting on line %d\n", start_line);
}
- add_chunk(ns, chunk, allow);
+
copy_location(s, chunk);
+ add_chunk(ns, chunk, allow);
/* DelScope(scp); */
Delete(decl);
@@ -1854,6 +1942,5 @@ String *Preprocessor_parse(String *s) {
Delete(comment);
Delete(chunk);
- /* fprintf(stderr,"cpp: %d\n", Len(Getattr(cpp,"symbols"))); */
return ns;
}
diff --git a/Source/Swig/cwrap.c b/Source/Swig/cwrap.c
index b8812563e..28401f89f 100644
--- a/Source/Swig/cwrap.c
+++ b/Source/Swig/cwrap.c
@@ -216,7 +216,7 @@ int Swig_cargs(Wrapper *w, ParmList *p) {
SwigType_del_reference(tvalue);
tycode = SwigType_type(tvalue);
if (tycode != T_USER) {
- /* plain primitive type, we copy the the def value */
+ /* plain primitive type, we copy the def value */
String *lstr = SwigType_lstr(tvalue, defname);
defvalue = NewStringf("%s = %s", lstr, qvalue);
Delete(lstr);
@@ -783,15 +783,32 @@ int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parm
* ----------------------------------------------------------------------------- */
int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director) {
- String *name, *qualifier;
+ String *name;
ParmList *parms;
SwigType *type;
Parm *p;
String *self = 0;
-
- /* If smart pointer, change self dereferencing */
+ int is_smart_pointer_overload = 0;
+ String *qualifier = Getattr(n, "qualifier");
+
+ /* If smart pointer without const overload or mutable method, change self dereferencing */
if (flags & CWRAP_SMART_POINTER) {
- self = NewString("(*this)->");
+ if (flags & CWRAP_SMART_POINTER_OVERLOAD) {
+ String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : classname;
+ if (qualifier && strncmp(Char(qualifier), "q(const)", 8) == 0) {
+ self = NewString("(*(this))->");
+ is_smart_pointer_overload = 1;
+ }
+ else if (Cmp(Getattr(n, "storage"), "static") == 0) {
+ self = NewStringf("(*(%s const *)this)->", cname);
+ is_smart_pointer_overload = 1;
+ }
+ else {
+ self = NewString("(*this)->");
+ }
+ } else {
+ self = NewString("(*this)->");
+ }
}
/* If node is a member template expansion, we don't allow added code */
@@ -799,7 +816,6 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
flags &= ~(CWRAP_EXTEND);
name = Getattr(n, "name");
- qualifier = Getattr(n, "qualifier");
parms = CopyParmList(nonvoid_parms(Getattr(n, "parms")));
type = NewString(classname);
@@ -921,10 +937,16 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
if (Cmp(Getattr(n, "storage"), "static") != 0) {
String *pname = Swig_cparm_name(pp, i);
- String *ctname = SwigType_namestr(cname);
- String *fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname);
+ String *ctname = SwigType_namestr(cname);
+ String *fadd = 0;
+ if (is_smart_pointer_overload) {
+ fadd = NewStringf("(%s const *)((%s const *)%s)->operator ->()", ctname, classname, pname);
+ }
+ else {
+ fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname);
+ }
Append(func, fadd);
- Delete(ctname);
+ Delete(ctname);
Delete(fadd);
Delete(pname);
pp = nextSibling(pp);
@@ -1310,6 +1332,8 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
Node *sn = Getattr(n, "cplus:staticbase");
String *base = Getattr(sn, "name");
self = NewStringf("%s::", base);
+ } else if (flags & CWRAP_SMART_POINTER_OVERLOAD) {
+ self = NewStringf("(*(%s const *)this)->", classname);
} else {
self = NewString("(*this)->");
}
diff --git a/Source/Swig/error.c b/Source/Swig/error.c
index fa82ad8d9..5dfcf605b 100644
--- a/Source/Swig/error.c
+++ b/Source/Swig/error.c
@@ -285,6 +285,41 @@ static String *format_filename(const_String_or_char_ptr filename) {
}
/* -----------------------------------------------------------------------------
+ * Swig_stringify_with_location()
+ *
+ * Return a string representation of any DOH object with line and file location
+ * information in the appropriate error message format. The string representation
+ * is enclosed within [] brackets after the line and file information.
+ * ----------------------------------------------------------------------------- */
+
+String *Swig_stringify_with_location(DOH *object) {
+ String *str = NewStringEmpty();
+
+ if (!init_fmt)
+ Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
+
+ if (object) {
+ int line = Getline(object);
+ String *formatted_filename = format_filename(Getfile(object));
+ if (line > 0) {
+ Printf(str, diag_line_fmt, formatted_filename, line);
+ } else {
+ Printf(str, diag_eof_fmt, formatted_filename);
+ }
+ if (Len(object) == 0) {
+ Printf(str, "[EMPTY]");
+ } else {
+ Printf(str, "[%s]", object);
+ }
+ Delete(formatted_filename);
+ } else {
+ Printf(str, "[NULL]");
+ }
+
+ return str;
+}
+
+/* -----------------------------------------------------------------------------
* Swig_diagnostic()
*
* Issue a diagnostic message on stdout.
diff --git a/Source/Swig/include.c b/Source/Swig/include.c
index baae44bb8..e3f256901 100644
--- a/Source/Swig/include.c
+++ b/Source/Swig/include.c
@@ -221,6 +221,8 @@ String *Swig_read_file(FILE *f) {
Append(str, buffer);
}
len = Len(str);
+ /* Add a newline if not present on last line -- the preprocessor seems to
+ * rely on \n and not EOF terminating lines */
if (len) {
char *cstr = Char(str);
if (cstr[len - 1] != '\n') {
diff --git a/Source/Swig/misc.c b/Source/Swig/misc.c
index f0a9155eb..9868ee844 100644
--- a/Source/Swig/misc.c
+++ b/Source/Swig/misc.c
@@ -220,7 +220,14 @@ String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) {
* ----------------------------------------------------------------------------- */
void Swig_filename_correct(String *filename) {
- (void)filename;
+ int network_path = 0;
+ if (Len(filename) >= 2) {
+ const char *fname = Char(filename);
+ if (fname[0] == '\\' && fname[1] == '\\')
+ network_path = 1;
+ if (fname[0] == '/' && fname[1] == '/')
+ network_path = 1;
+ }
#if defined(_WIN32) || defined(MACSWIG)
/* accept Unix path separator on non-Unix systems */
Replaceall(filename, "/", SWIG_FILE_DELIMITER);
@@ -232,6 +239,9 @@ void Swig_filename_correct(String *filename) {
/* remove all duplicate file name delimiters */
while (Replaceall(filename, SWIG_FILE_DELIMITER SWIG_FILE_DELIMITER, SWIG_FILE_DELIMITER)) {
}
+ /* Network paths can start with a double slash on Windows - unremove the duplicate slash we just removed */
+ if (network_path)
+ Insert(filename, 0, SWIG_FILE_DELIMITER);
}
/* -----------------------------------------------------------------------------
@@ -242,13 +252,11 @@ void Swig_filename_correct(String *filename) {
String *Swig_filename_escape(String *filename) {
String *adjusted_filename = Copy(filename);
+ Swig_filename_correct(adjusted_filename);
#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
- /* remove all double '\' in case any already present */
- while (Replaceall(adjusted_filename, "\\\\", "\\")) {
- }
Replaceall(adjusted_filename, "\\", "\\\\");
#endif
- return adjusted_filename;
+ return adjusted_filename;
}
/* -----------------------------------------------------------------------------
@@ -527,7 +535,6 @@ String *Swig_string_schemify(String *s) {
return ns;
}
-
/* -----------------------------------------------------------------------------
* Swig_string_typecode()
*
@@ -1108,112 +1115,128 @@ String *Swig_string_strip(String *s) {
}
-/* -----------------------------------------------------------------------------
- * Swig_string_rxspencer()
- *
- * Executes a regexp substitution via the RxSpencer library. For example:
- *
- * Printf(stderr,"gsl%(rxspencer:[GSL_.*_][@1])s","GSL_Hello_") -> gslHello
- * ----------------------------------------------------------------------------- */
-#if defined(HAVE_RXSPENCER)
-#include <sys/types.h>
-#include <rxspencer/regex.h>
-#define USE_RXSPENCER
-#endif
+#ifdef HAVE_PCRE
+#include <pcre.h>
+
+static int split_regex_pattern_subst(String *s, String **pattern, String **subst, const char **input)
+{
+ const char *pats, *pate;
+ const char *subs, *sube;
+
+ /* Locate the search pattern */
+ const char *p = Char(s);
+ if (*p++ != '/') goto err_out;
+ pats = p;
+ p = strchr(p, '/');
+ if (!p) goto err_out;
+ pate = p;
+
+ /* Locate the substitution string */
+ subs = ++p;
+ p = strchr(p, '/');
+ if (!p) goto err_out;
+ sube = p;
+
+ *pattern = NewStringWithSize(pats, pate - pats);
+ *subst = NewStringWithSize(subs, sube - subs);
+ *input = p + 1;
+ return 1;
+
+err_out:
+ Swig_error("SWIG", Getline(s), "Invalid regex substitution: '%s'.\n", s);
+ exit(1);
+}
+
+String *replace_captures(const char *input, String *subst, int captures[])
+{
+ String *result = NewStringEmpty();
+ const char *p = Char(subst);
-const char *skip_delim(char pb, char pe, const char *ce) {
- int end = 0;
- int lb = 0;
- while (!end && *ce != '\0') {
- if (*ce == pb) {
- ++lb;
+ while (*p) {
+ /* Copy part without substitutions */
+ const char *q = strchr(p, '\\');
+ if (!q) {
+ Write(result, p, strlen(p));
+ break;
}
- if (*ce == pe) {
- if (!lb) {
- end = 1;
- --ce;
- } else {
- --lb;
+ Write(result, p, q - p);
+ p = q + 1;
+
+ /* Handle substitution */
+ if (*p == '\0') {
+ Putc('\\', result);
+ } else if (isdigit(*p)) {
+ int group = *p++ - '0';
+ int l = captures[group*2], r = captures[group*2 + 1];
+ if (l != -1) {
+ Write(result, input + l, r - l);
}
}
- ++ce;
}
- return end ? ce : 0;
+
+ return result;
}
+/* -----------------------------------------------------------------------------
+ * Swig_string_regex()
+ *
+ * Executes a regular expression substitution. For example:
+ *
+ * Printf(stderr,"gsl%(regex:/GSL_.*_/\\1/)s","GSL_Hello_") -> gslHello
+ * ----------------------------------------------------------------------------- */
+String *Swig_string_regex(String *s) {
+ const int pcre_options = 0;
-#if defined(USE_RXSPENCER)
-String *Swig_string_rxspencer(String *s) {
String *res = 0;
- if (Len(s)) {
- const char *cs = Char(s);
- const char *cb;
- const char *ce;
- if (*cs == '[') {
- int retval;
- regex_t compiled;
- cb = ++cs;
- ce = skip_delim('[', ']', cb);
- if (ce) {
- char bregexp[512];
- strncpy(bregexp, cb, ce - cb);
- bregexp[ce - cb] = '\0';
- ++ce;
- retval = regcomp(&compiled, bregexp, REG_EXTENDED);
- if (retval == 0) {
- cs = ce;
- if (*cs == '[') {
- cb = ++cs;
- ce = skip_delim('[', ']', cb);
- if (ce) {
- const char *cvalue = ce + 1;
- int nsub = (int) compiled.re_nsub + 1;
- regmatch_t *pmatch = (regmatch_t *) malloc(sizeof(regmatch_t) * (nsub));
- retval = regexec(&compiled, cvalue, nsub, pmatch, 0);
- if (retval != REG_NOMATCH) {
- char *spos = 0;
- res = NewStringWithSize(cb, ce - cb);
- spos = Strchr(res, '@');
- while (spos) {
- char cd = *(++spos);
- if (isdigit(cd)) {
- char arg[8];
- size_t len;
- int i = cd - '0';
- sprintf(arg, "@%d", i);
- if (i < nsub && (len = pmatch[i].rm_eo - pmatch[i].rm_so)) {
- char value[256];
- strncpy(value, cvalue + pmatch[i].rm_so, len);
- value[len] = 0;
- Replaceall(res, arg, value);
- } else {
- Replaceall(res, arg, "");
- }
- spos = Strchr(res, '@');
- } else if (cd == '@') {
- spos = strchr(spos + 1, '@');
- }
- }
- }
- free(pmatch);
- }
- }
- }
- regfree(&compiled);
- }
+ pcre *compiled_pat = 0;
+ const char *pcre_error, *input;
+ int pcre_errorpos;
+ String *pattern = 0, *subst = 0;
+ int captures[30];
+
+ if (split_regex_pattern_subst(s, &pattern, &subst, &input)) {
+ int rc;
+
+ compiled_pat = pcre_compile(
+ Char(pattern), pcre_options, &pcre_error, &pcre_errorpos, NULL);
+ if (!compiled_pat) {
+ Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n",
+ pcre_error, Char(pattern), pcre_errorpos);
+ exit(1);
+ }
+ rc = pcre_exec(compiled_pat, NULL, input, strlen(input), 0, 0, captures, 30);
+ if (rc >= 0) {
+ res = replace_captures(input, subst, captures);
+ }
+ else if (rc != PCRE_ERROR_NOMATCH) {
+ Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" in \"%s\".\n",
+ rc, Char(pattern), input);
+ exit(1);
}
}
- if (!res)
- res = NewStringEmpty();
- return res;
+
+ DohDelete(pattern);
+ DohDelete(subst);
+ pcre_free(compiled_pat);
+ return res ? res : NewStringEmpty();
}
+
+String *Swig_pcre_version(void) {
+ return NewStringf("PCRE Version: %s", pcre_version());
+}
+
#else
-String *Swig_string_rxspencer(String *s) {
- (void) s;
- return NewStringEmpty();
+
+String *Swig_string_regex(String *s) {
+ Swig_error("SWIG", Getline(s), "PCRE regex support not enabled in this SWIG build.\n");
+ exit(1);
}
-#endif
+String *Swig_pcre_version(void) {
+ return NewStringf("PCRE not used");
+}
+
+#endif
/* -----------------------------------------------------------------------------
* Swig_init()
@@ -1233,9 +1256,9 @@ void Swig_init() {
DohEncoding("typecode", Swig_string_typecode);
DohEncoding("mangle", Swig_string_emangle);
DohEncoding("command", Swig_string_command);
- DohEncoding("rxspencer", Swig_string_rxspencer);
DohEncoding("schemify", Swig_string_schemify);
DohEncoding("strip", Swig_string_strip);
+ DohEncoding("regex", Swig_string_regex);
/* aliases for the case encoders */
DohEncoding("uppercase", Swig_string_upper);
diff --git a/Source/Swig/naming.c b/Source/Swig/naming.c
index 07e42f2d4..d4a7adf84 100644
--- a/Source/Swig/naming.c
+++ b/Source/Swig/naming.c
@@ -1000,7 +1000,7 @@ int Swig_need_redefined_warn(Node *a, Node *b, int InClass) {
* This is basically any protected members when the allprotected mode is set.
* Otherwise we take just the protected virtual methods and non-static methods
* (potentially virtual methods) as well as constructors/destructors.
- *
+ * Also any "using" statements in a class may potentially be virtual.
* ----------------------------------------------------------------------------- */
int Swig_need_protected(Node *n) {
@@ -1017,6 +1017,8 @@ int Swig_need_protected(Node *n) {
}
} else if (Equal(nodetype, "constructor") || Equal(nodetype, "destructor")) {
return 1;
+ } else if (Equal(nodetype, "using") && !Getattr(n, "namespace")) {
+ return 1;
}
}
return 0;
@@ -1061,25 +1063,21 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
if (ckey) {
const char **rkey;
int isnotmatch = 0;
- int isrxsmatch = 0;
+ int isregexmatch = 0;
if ((strncmp(ckey, "match", 5) == 0)
|| (isnotmatch = (strncmp(ckey, "notmatch", 8) == 0))
- || (isrxsmatch = (strncmp(ckey, "rxsmatch", 8) == 0))
- || (isnotmatch = isrxsmatch = (strncmp(ckey, "notrxsmatch", 11) == 0))) {
+ || (isregexmatch = (strncmp(ckey, "regexmatch", 10) == 0))
+ || (isnotmatch = isregexmatch = (strncmp(ckey, "notregexmatch", 13) == 0))) {
Hash *mi = NewHash();
List *attrlist = Swig_make_attrlist(ckey);
if (!matchlist)
matchlist = NewList();
Setattr(mi, "value", Getattr(kw, "value"));
Setattr(mi, "attrlist", attrlist);
-#ifdef SWIG_DEBUG
- if (isrxsmatch)
- Printf(stdout, "rxsmatch to use: %s %s %s\n", ckey, Getattr(kw, "value"), attrlist);
-#endif
if (isnotmatch)
SetFlag(mi, "notmatch");
- if (isrxsmatch)
- SetFlag(mi, "rxsmatch");
+ if (isregexmatch)
+ SetFlag(mi, "regexmatch");
Delete(attrlist);
Append(matchlist, mi);
Delete(mi);
@@ -1114,7 +1112,7 @@ void Swig_name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, Str
}
if (!nname || !Len(nname) || Getattr(nameobj, "fullname") || /* any of these options trigger a 'list' nameobj */
- Getattr(nameobj, "sourcefmt") || Getattr(nameobj, "matchlist")) {
+ Getattr(nameobj, "sourcefmt") || Getattr(nameobj, "matchlist") || Getattr(nameobj, "regextarget")) {
if (decl)
Setattr(nameobj, "decl", decl);
if (nname && Len(nname))
@@ -1155,36 +1153,50 @@ static DOH *Swig_get_lattr(Node *n, List *lattr) {
return res;
}
-#if defined(HAVE_RXSPENCER)
-#include <sys/types.h>
-#include <rxspencer/regex.h>
-#define USE_RXSPENCER
-#endif
+#ifdef HAVE_PCRE
+#include <pcre.h>
+
+int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
+ pcre *compiled_pat;
+ const char *err;
+ int errpos;
+ int rc;
+
+ compiled_pat = pcre_compile(Char(pattern), 0, &err, &errpos, NULL);
+ if (!compiled_pat) {
+ Swig_error("SWIG", Getline(n),
+ "Invalid regex \"%s\": compilation failed at %d: %s\n",
+ Char(pattern), errpos, err);
+ exit(1);
+ }
-#if defined(USE_RXSPENCER)
-int Swig_name_rxsmatch_value(String *mvalue, String *value) {
- int match = 0;
- char *cvalue = Char(value);
- char *cmvalue = Char(mvalue);
- regex_t compiled;
- int retval = regcomp(&compiled, cmvalue, REG_EXTENDED | REG_NOSUB);
- if (retval != 0)
+ rc = pcre_exec(compiled_pat, NULL, Char(s), Len(s), 0, 0, NULL, 0);
+ pcre_free(compiled_pat);
+
+ if (rc == PCRE_ERROR_NOMATCH)
return 0;
- retval = regexec(&compiled, cvalue, 0, 0, 0);
- match = (retval == REG_NOMATCH) ? 0 : 1;
-#ifdef SWIG_DEBUG
- Printf(stdout, "rxsmatch_value: %s %s %d\n", cvalue, cmvalue, match);
-#endif
- regfree(&compiled);
- return match;
+
+ if (rc < 0 ) {
+ Swig_error("SWIG", Getline(n),
+ "Matching \"%s\" against regex \"%s\" failed: %d\n",
+ Char(s), Char(pattern), rc);
+ exit(1);
+ }
+
+ return 1;
}
-#else
-int Swig_name_rxsmatch_value(String *mvalue, String *value) {
- (void) mvalue;
- (void) value;
- return 0;
+
+#else /* !HAVE_PCRE */
+
+int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
+ (void)pattern;
+ (void)s;
+ Swig_error("SWIG", Getline(n),
+ "PCRE regex matching is not available in this SWIG build.\n");
+ exit(1);
}
-#endif
+
+#endif /* HAVE_PCRE/!HAVE_PCRE */
int Swig_name_match_value(String *mvalue, String *value) {
#if defined(SWIG_USE_SIMPLE_MATCHOR)
@@ -1227,17 +1239,11 @@ int Swig_name_match_nameobj(Hash *rn, Node *n) {
List *lattr = Getattr(mi, "attrlist");
String *nval = Swig_get_lattr(n, lattr);
int notmatch = GetFlag(mi, "notmatch");
- int rxsmatch = GetFlag(mi, "rxsmatch");
-#ifdef SWIG_DEBUG
- Printf(stdout, "mi %d %s re %d not %d \n", i, nval, notmatch, rxsmatch);
- if (rxsmatch) {
- Printf(stdout, "rxsmatch %s\n", lattr);
- }
-#endif
+ int regexmatch = GetFlag(mi, "regexmatch");
match = 0;
if (nval) {
String *kwval = Getattr(mi, "value");
- match = rxsmatch ? Swig_name_rxsmatch_value(kwval, nval)
+ match = regexmatch ? Swig_name_regexmatch_value(n, kwval, nval)
: Swig_name_match_value(kwval, nval);
#ifdef SWIG_DEBUG
Printf(stdout, "val %s %s %d %d \n", nval, kwval, match, ilen);
@@ -1277,7 +1283,7 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
String *sfmt = Getattr(rn, "sourcefmt");
String *sname = 0;
int fullname = GetFlag(rn, "fullname");
- int rxstarget = GetFlag(rn, "rxstarget");
+ int regextarget = GetFlag(rn, "regextarget");
if (sfmt) {
if (fullname && prefix) {
String *pname = NewStringf("%s::%s", prefix, name);
@@ -1294,10 +1300,17 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
DohIncref(name);
}
}
- match = rxstarget ? Swig_name_rxsmatch_value(tname, sname) : Swig_name_match_value(tname, sname);
+ match = regextarget ? Swig_name_regexmatch_value(n, tname, sname)
+ : Swig_name_match_value(tname, sname);
Delete(sname);
} else {
- match = 1;
+ /* Applying the renaming rule may fail if it contains a %(regex)s expression that doesn't match the given name. */
+ String *sname = NewStringf(Getattr(rn, "name"), name);
+ if (sname) {
+ if (Len(sname))
+ match = 1;
+ Delete(sname);
+ }
}
}
if (match) {
@@ -1393,7 +1406,7 @@ void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *ne
ParmList *declparms = declaratorparms;
- const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "rxstarget", 0 };
+ const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "regextarget", 0 };
Swig_name_object_attach_keys(rename_keys, newname);
/* Add the name */
diff --git a/Source/Swig/scanner.c b/Source/Swig/scanner.c
index 9b5b35f96..0cdadaa7f 100644
--- a/Source/Swig/scanner.c
+++ b/Source/Swig/scanner.c
@@ -20,6 +20,7 @@ char cvsroot_scanner_c[] = "$Id$";
#include <ctype.h>
extern String *cparse_file;
+extern int cparse_line;
extern int cparse_cplusplus;
extern int cparse_start_line;
@@ -38,6 +39,13 @@ struct Scanner {
int freeze_line; /* Suspend line number updates */
};
+typedef struct Locator {
+ String *filename;
+ int line_number;
+ struct Locator *next;
+} Locator;
+static int follow_locators = 0;
+
/* -----------------------------------------------------------------------------
* NewScanner()
*
@@ -230,8 +238,7 @@ static void set_error(Scanner *s, int line, const_String_or_char_ptr msg) {
* Returns error information (if any)
* ----------------------------------------------------------------------------- */
-String *
-Scanner_errmsg(Scanner *s) {
+String *Scanner_errmsg(Scanner *s) {
return s->error;
}
@@ -241,13 +248,12 @@ Scanner_errline(Scanner *s) {
}
/* -----------------------------------------------------------------------------
- * Scanner_freeze_line()
+ * freeze_line()
*
* Freezes the current line number.
* ----------------------------------------------------------------------------- */
-void
-Scanner_freeze_line(Scanner *s, int val) {
+static void freeze_line(Scanner *s, int val) {
s->freeze_line = val;
}
@@ -1153,6 +1159,7 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
int l;
int state = 0;
char temp[2] = { 0, 0 };
+ String *locator = 0;
l = s->line;
temp[0] = (char) startchar;
Clear(s->text);
@@ -1162,6 +1169,7 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
Append(s->text, temp);
while (num_levels > 0) {
if ((c = nextchar(s)) == 0) {
+ Delete(locator);
return -1;
}
switch (state) {
@@ -1195,17 +1203,25 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
else
state = 11;
break;
- case 12:
+ case 12: /* first character inside C comment */
if (c == '*')
+ state = 14;
+ else if (c == '@')
+ state = 40;
+ else
state = 13;
break;
case 13:
if (c == '*')
- state = 13;
+ state = 14;
+ break;
+ case 14: /* possible end of C comment */
+ if (c == '*')
+ state = 14;
else if (c == '/')
state = 0;
else
- state = 12;
+ state = 13;
break;
case 20:
if (c == '\"')
@@ -1225,10 +1241,43 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
case 31:
state = 30;
break;
+ /* 40-45 SWIG locator checks - a C comment with contents starting: @SWIG */
+ case 40:
+ state = (c == 'S') ? 41 : (c == '*') ? 14 : 13;
+ break;
+ case 41:
+ state = (c == 'W') ? 42 : (c == '*') ? 14 : 13;
+ break;
+ case 42:
+ state = (c == 'I') ? 43 : (c == '*') ? 14 : 13;
+ break;
+ case 43:
+ state = (c == 'G') ? 44 : (c == '*') ? 14 : 13;
+ if (c == 'G') {
+ Delete(locator);
+ locator = NewString("/*@SWIG");
+ }
+ break;
+ case 44:
+ if (c == '*')
+ state = 45;
+ Putc(c, locator);
+ break;
+ case 45: /* end of SWIG locator in C comment */
+ if (c == '/') {
+ state = 0;
+ Putc(c, locator);
+ Scanner_locator(s, locator);
+ } else {
+ /* malformed locator */
+ state = (c == '*') ? 14 : 13;
+ }
+ break;
default:
break;
}
}
+ Delete(locator);
return 0;
}
@@ -1239,8 +1288,98 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
* operator.
* ----------------------------------------------------------------------------- */
-int
-Scanner_isoperator(int tokval) {
+int Scanner_isoperator(int tokval) {
if (tokval >= 100) return 1;
return 0;
}
+
+/* ----------------------------------------------------------------------
+ * locator()
+ *
+ * Support for locator strings. These are strings of the form
+ * @SWIG:filename,line,id@ emitted by the SWIG preprocessor. They
+ * are primarily used for macro line number reporting.
+ * We just use the locator to mark when to activate/deactivate linecounting.
+ * ---------------------------------------------------------------------- */
+
+
+void Scanner_locator(Scanner *s, String *loc) {
+ static Locator *locs = 0;
+ static int expanding_macro = 0;
+
+ if (!follow_locators) {
+ if (Equal(loc, "/*@SWIG@*/")) {
+ /* End locator. */
+ if (expanding_macro)
+ --expanding_macro;
+ } else {
+ /* Begin locator. */
+ ++expanding_macro;
+ }
+ /* Freeze line number processing in Scanner */
+ freeze_line(s,expanding_macro);
+ } else {
+ int c;
+ Locator *l;
+ Seek(loc, 7, SEEK_SET);
+ c = Getc(loc);
+ if (c == '@') {
+ /* Empty locator. We pop the last location off */
+ if (locs) {
+ Scanner_set_location(s, locs->filename, locs->line_number);
+ cparse_file = locs->filename;
+ cparse_line = locs->line_number;
+ l = locs->next;
+ free(locs);
+ locs = l;
+ }
+ return;
+ }
+
+ /* We're going to push a new location */
+ l = (Locator *) malloc(sizeof(Locator));
+ l->filename = cparse_file;
+ l->line_number = cparse_line;
+ l->next = locs;
+ locs = l;
+
+ /* Now, parse the new location out of the locator string */
+ {
+ String *fn = NewStringEmpty();
+ /* Putc(c, fn); */
+
+ while ((c = Getc(loc)) != EOF) {
+ if ((c == '@') || (c == ','))
+ break;
+ Putc(c, fn);
+ }
+ cparse_file = Swig_copy_string(Char(fn));
+ Clear(fn);
+ cparse_line = 1;
+ /* Get the line number */
+ while ((c = Getc(loc)) != EOF) {
+ if ((c == '@') || (c == ','))
+ break;
+ Putc(c, fn);
+ }
+ cparse_line = atoi(Char(fn));
+ Clear(fn);
+
+ /* Get the rest of it */
+ while ((c = Getc(loc)) != EOF) {
+ if (c == '@')
+ break;
+ Putc(c, fn);
+ }
+ /* Swig_diagnostic(cparse_file, cparse_line, "Scanner_set_location\n"); */
+ Scanner_set_location(s, cparse_file, cparse_line);
+ Delete(fn);
+ }
+ }
+}
+
+void Swig_cparse_follow_locators(int v) {
+ follow_locators = v;
+}
+
+
diff --git a/Source/Swig/stype.c b/Source/Swig/stype.c
index dd2aea688..c2c17e515 100644
--- a/Source/Swig/stype.c
+++ b/Source/Swig/stype.c
@@ -177,7 +177,7 @@ void SwigType_push(SwigType *t, String *cons) {
* Testing functions for querying a raw datatype
* ----------------------------------------------------------------------------- */
-int SwigType_ispointer_return(SwigType *t) {
+int SwigType_ispointer_return(const SwigType *t) {
char *c;
int idx;
if (!t)
@@ -190,7 +190,7 @@ int SwigType_ispointer_return(SwigType *t) {
return 0;
}
-int SwigType_isreference_return(SwigType *t) {
+int SwigType_isreference_return(const SwigType *t) {
char *c;
int idx;
if (!t)
@@ -203,7 +203,7 @@ int SwigType_isreference_return(SwigType *t) {
return 0;
}
-int SwigType_isconst(SwigType *t) {
+int SwigType_isconst(const SwigType *t) {
char *c;
if (!t)
return 0;
@@ -229,7 +229,7 @@ int SwigType_isconst(SwigType *t) {
return 0;
}
-int SwigType_ismutable(SwigType *t) {
+int SwigType_ismutable(const SwigType *t) {
int r;
SwigType *qt = SwigType_typedef_resolve_all(t);
if (SwigType_isreference(qt) || SwigType_isarray(qt)) {
@@ -240,7 +240,7 @@ int SwigType_ismutable(SwigType *t) {
return r ? 0 : 1;
}
-int SwigType_isenum(SwigType *t) {
+int SwigType_isenum(const SwigType *t) {
char *c = Char(t);
if (!t)
return 0;
@@ -250,7 +250,7 @@ int SwigType_isenum(SwigType *t) {
return 0;
}
-int SwigType_issimple(SwigType *t) {
+int SwigType_issimple(const SwigType *t) {
char *c = Char(t);
if (!t)
return 0;
@@ -308,7 +308,7 @@ int SwigType_issimple(SwigType *t) {
* r.q(const).enum SWIGTYPE
* ----------------------------------------------------------------------------- */
-SwigType *SwigType_default_create(SwigType *ty) {
+SwigType *SwigType_default_create(const SwigType *ty) {
SwigType *r = 0;
List *l;
Iterator it;
@@ -366,7 +366,7 @@ SwigType *SwigType_default_create(SwigType *ty) {
* SwigType_default_create() before calling this function.
*
* Example deductions (matching the examples described in SwigType_default_create),
- * where the the most specialized matches are highest in the list:
+ * where the most specialized matches are highest in the list:
*
* a(ANY).a(ANY).SWIGTYPE
* a(ANY).a().SWIGTYPE
@@ -387,7 +387,7 @@ SwigType *SwigType_default_create(SwigType *ty) {
* SWIGTYPE
* ----------------------------------------------------------------------------- */
-SwigType *SwigType_default_deduce(SwigType *t) {
+SwigType *SwigType_default_deduce(const SwigType *t) {
SwigType *r = NewStringEmpty();
List *l;
Iterator it;
@@ -511,7 +511,7 @@ String *SwigType_namestr(const SwigType *t) {
* Create a C string representation of a datatype.
* ----------------------------------------------------------------------------- */
-String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
+String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
String *result;
String *element = 0, *nextelement;
List *elements;
@@ -606,12 +606,12 @@ String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
}
/* -----------------------------------------------------------------------------
- * SwigType_ltype(SwigType *ty)
+ * SwigType_ltype(const SwigType *ty)
*
* Create a locally assignable type
* ----------------------------------------------------------------------------- */
-SwigType *SwigType_ltype(SwigType *s) {
+SwigType *SwigType_ltype(const SwigType *s) {
String *result;
String *element;
SwigType *td, *tc = 0;
@@ -709,7 +709,7 @@ SwigType *SwigType_ltype(SwigType *s) {
* with an equivalent assignable version.
* -------------------------------------------------------------------- */
-String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id) {
+String *SwigType_lstr(const SwigType *s, const_String_or_char_ptr id) {
String *result;
SwigType *tc;
@@ -726,10 +726,11 @@ String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id) {
* datatype printed by str().
* ----------------------------------------------------------------------------- */
-String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
+String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
String *result, *cast;
String *element = 0, *nextelement;
- SwigType *td, *rs, *tc = 0;
+ SwigType *td, *tc = 0;
+ const SwigType *rs;
List *elements;
int nelements, i;
int clear = 1;
@@ -873,7 +874,7 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
* Casts a variable from the real type to the local datatype.
* ----------------------------------------------------------------------------- */
-String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr name) {
+String *SwigType_lcaststr(const SwigType *s, const_String_or_char_ptr name) {
String *result;
result = NewStringEmpty();
@@ -899,27 +900,163 @@ String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr name) {
return result;
}
+#if 0
+/* Alternative implementation for manglestr_default. Mangling is similar to the original
+ except for a few subtle differences for example in templates:
+ namespace foo {
+ template<class T> class bar {};
+ typedef int Integer;
+ void test2(bar<Integer *> *x);
+ }
+ Mangling is more consistent and changes from
+ _p_foo__barT_int_p_t to
+ _p_foo__barT_p_int_t.
+*/
+static void mangle_stringcopy(String *destination, const char *source, int count) {
+ while (count-- > 0) {
+ char newc = '_';
+ if (!(*source == '.' || *source == ':' || *source == ' '))
+ newc = *source;
+ /* TODO: occasionally '*' or numerics need converting to '_', eg in array dimensions and template expressions */
+ Putc(newc, destination);
+ source++;
+ }
+}
+
+static void mangle_subtype(String *mangled, SwigType *s);
+
+/* -----------------------------------------------------------------------------
+ * mangle_namestr()
+ *
+ * Mangles a type taking care of template expansions. Similar to SwigType_namestr().
+ * The type may include a trailing '.', for example "p."
+ * ----------------------------------------------------------------------------- */
+
+static void mangle_namestr(String *mangled, SwigType *t) {
+ int length = Len(t);
+ if (SwigType_isqualifier(t)) {
+ Append(mangled, "q_");
+ mangle_stringcopy(mangled, Char(t)+2, length-4);
+ Append(mangled, "__");
+ } else if (SwigType_ismemberpointer(t)) {
+ Append(mangled, "m_");
+ mangle_stringcopy(mangled, Char(t)+2, length-4);
+ Append(mangled, "__");
+ } else if (SwigType_isarray(t)) {
+ Append(mangled, "a_");
+ mangle_stringcopy(mangled, Char(t)+2, length-4);
+ Append(mangled, "__");
+ } else if (SwigType_isfunction(t)) {
+ List *p = SwigType_parmlist(t);
+ int sz = Len(p);
+ int i;
+ Append(mangled, "f_");
+ for (i = 0; i < sz; i++) {
+ mangle_subtype(mangled, Getitem(p, i));
+ Putc('_', mangled);
+ }
+ Append(mangled, (sz > 0) ? "_" : "__");
+ } else if (SwigType_isvarargs(t)) {
+ Append(mangled, "___");
+ } else {
+ char *d = Char(t);
+ char *c = strstr(d, "<(");
+ if (!c || !strstr(c + 2, ")>")) {
+ /* not a template type */
+ mangle_stringcopy(mangled, Char(t), Len(t));
+ } else {
+ /* a template type */
+ String *suffix;
+ List *p;
+ int i, sz;
+ mangle_stringcopy(mangled, d, c-d);
+ Putc('T', mangled);
+ Putc('_', mangled);
+
+ p = SwigType_parmlist(c + 1);
+ sz = Len(p);
+ for (i = 0; i < sz; i++) {
+ mangle_subtype(mangled, Getitem(p, i));
+ Putc('_', mangled);
+ }
+ Putc('t', mangled);
+ suffix = SwigType_templatesuffix(t);
+ if (Len(suffix) > 0) {
+ mangle_namestr(mangled, suffix);
+ } else {
+ Append(mangled, suffix);
+ }
+ Delete(suffix);
+ Delete(p);
+ }
+ }
+}
+
+static void mangle_subtype(String *mangled, SwigType *s) {
+ List *elements;
+ int nelements, i;
+
+ assert(s);
+ elements = SwigType_split(s);
+ nelements = Len(elements);
+ for (i = 0; i < nelements; i++) {
+ SwigType *element = Getitem(elements, i);
+ mangle_namestr(mangled, element);
+ }
+ Delete(elements);
+}
+
+static String *manglestr_default(const SwigType *s) {
+ String *mangled = NewString("_");
+ SwigType *sr = SwigType_typedef_resolve_all(s);
+ SwigType *sq = SwigType_typedef_qualified(sr);
+ SwigType *ss = SwigType_remove_global_scope_prefix(sq);
+ SwigType *type = ss;
+ SwigType *lt;
+
+ if (SwigType_istemplate(ss)) {
+ SwigType *ty = Swig_symbol_template_deftype(ss, 0);
+ Delete(ss);
+ ss = ty;
+ type = ss;
+ }
+
+ lt = SwigType_ltype(type);
-/* keep old mangling since Java codes need it */
-String *SwigType_manglestr_default(SwigType *s) {
+ Replace(lt, "struct ", "", DOH_REPLACE_ANY);
+ Replace(lt, "class ", "", DOH_REPLACE_ANY);
+ Replace(lt, "union ", "", DOH_REPLACE_ANY);
+ Replace(lt, "enum ", "", DOH_REPLACE_ANY);
+
+ mangle_subtype(mangled, lt);
+
+ Delete(ss);
+ Delete(sq);
+ Delete(sr);
+
+ return mangled;
+}
+
+#else
+
+static String *manglestr_default(const SwigType *s) {
char *c;
String *result = 0;
String *base = 0;
SwigType *lt;
- SwigType *sr = SwigType_typedef_qualified(s);
- SwigType *ss = SwigType_typedef_resolve_all(sr);
-
- s = ss;
+ SwigType *sr = SwigType_typedef_resolve_all(s);
+ SwigType *sq = SwigType_typedef_qualified(sr);
+ SwigType *ss = SwigType_remove_global_scope_prefix(sq);
+ SwigType *type = ss;
if (SwigType_istemplate(ss)) {
SwigType *ty = Swig_symbol_template_deftype(ss, 0);
Delete(ss);
ss = ty;
- s = ss;
+ type = ss;
}
- Delete(sr);
- lt = SwigType_ltype(s);
+ lt = SwigType_ltype(type);
result = SwigType_prefix(lt);
base = SwigType_base(lt);
@@ -966,13 +1103,23 @@ String *SwigType_manglestr_default(SwigType *s) {
Insert(result, 0, "_");
Delete(lt);
Delete(base);
- if (ss)
- Delete(ss);
+ Delete(ss);
+ Delete(sq);
+ Delete(sr);
return result;
}
-
-String *SwigType_manglestr(SwigType *s) {
- return SwigType_manglestr_default(s);
+#endif
+
+String *SwigType_manglestr(const SwigType *s) {
+#if 0
+ /* Debugging checks to ensure a proper SwigType is passed in and not a stringified type */
+ String *angle = Strstr(s, "<");
+ if (angle && Strncmp(angle, "<(", 2) != 0)
+ Printf(stderr, "SwigType_manglestr error: %s\n", s);
+ else if (Strstr(s, "*") || Strstr(s, "&") || Strstr(s, "["))
+ Printf(stderr, "SwigType_manglestr error: %s\n", s);
+#endif
+ return manglestr_default(s);
}
/* -----------------------------------------------------------------------------
@@ -1091,7 +1238,7 @@ SwigType *SwigType_remove_global_scope_prefix(const SwigType *t) {
* Checks type declarators for a match
* ----------------------------------------------------------------------------- */
-int SwigType_check_decl(SwigType *ty, const SwigType *decl) {
+int SwigType_check_decl(const SwigType *ty, const SwigType *decl) {
SwigType *t, *t1, *t2;
int r;
t = SwigType_typedef_resolve_all(ty);
diff --git a/Source/Swig/swig.h b/Source/Swig/swig.h
index f90a5ffb1..6607c333d 100644
--- a/Source/Swig/swig.h
+++ b/Source/Swig/swig.h
@@ -129,37 +129,37 @@ extern "C" {
extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms);
extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms);
extern SwigType *SwigType_pop_function(SwigType *t);
- extern ParmList *SwigType_function_parms(SwigType *t, Node *file_line_node);
+ extern ParmList *SwigType_function_parms(const SwigType *t, Node *file_line_node);
extern List *SwigType_split(const SwigType *t);
extern String *SwigType_pop(SwigType *t);
- extern void SwigType_push(SwigType *t, SwigType *s);
+ extern void SwigType_push(SwigType *t, String *s);
extern List *SwigType_parmlist(const SwigType *p);
- extern String *SwigType_parm(String *p);
- extern String *SwigType_str(SwigType *s, const_String_or_char_ptr id);
- extern String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id);
- extern String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr id);
- extern String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr id);
- extern String *SwigType_manglestr(SwigType *t);
- extern SwigType *SwigType_ltype(SwigType *t);
- extern int SwigType_ispointer(SwigType *t);
- extern int SwigType_ispointer_return(SwigType *t);
- extern int SwigType_isfunctionpointer(SwigType *t);
- extern int SwigType_ismemberpointer(SwigType *t);
- extern int SwigType_isreference(SwigType *t);
- extern int SwigType_isreference_return(SwigType *t);
- extern int SwigType_isarray(SwigType *t);
- extern int SwigType_prefix_is_simple_1D_array(SwigType *t);
- extern int SwigType_isfunction(SwigType *t);
- extern int SwigType_isqualifier(SwigType *t);
- extern int SwigType_isconst(SwigType *t);
- extern int SwigType_issimple(SwigType *t);
- extern int SwigType_ismutable(SwigType *t);
+ extern String *SwigType_parm(const SwigType *p);
+ extern String *SwigType_str(const SwigType *s, const_String_or_char_ptr id);
+ extern String *SwigType_lstr(const SwigType *s, const_String_or_char_ptr id);
+ extern String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr id);
+ extern String *SwigType_lcaststr(const SwigType *s, const_String_or_char_ptr id);
+ extern String *SwigType_manglestr(const SwigType *t);
+ extern SwigType *SwigType_ltype(const SwigType *t);
+ extern int SwigType_ispointer(const SwigType *t);
+ extern int SwigType_ispointer_return(const SwigType *t);
+ extern int SwigType_isfunctionpointer(const SwigType *t);
+ extern int SwigType_ismemberpointer(const SwigType *t);
+ extern int SwigType_isreference(const SwigType *t);
+ extern int SwigType_isreference_return(const SwigType *t);
+ extern int SwigType_isarray(const SwigType *t);
+ extern int SwigType_prefix_is_simple_1D_array(const SwigType *t);
+ extern int SwigType_isfunction(const SwigType *t);
+ extern int SwigType_isqualifier(const SwigType *t);
+ extern int SwigType_isconst(const SwigType *t);
+ extern int SwigType_issimple(const SwigType *t);
+ extern int SwigType_ismutable(const SwigType *t);
extern int SwigType_isvarargs(const SwigType *t);
extern int SwigType_istemplate(const SwigType *t);
- extern int SwigType_isenum(SwigType *t);
- extern int SwigType_check_decl(SwigType *t, const_String_or_char_ptr decl);
- extern SwigType *SwigType_strip_qualifiers(SwigType *t);
- extern SwigType *SwigType_strip_single_qualifier(SwigType *t);
+ extern int SwigType_isenum(const SwigType *t);
+ extern int SwigType_check_decl(const SwigType *t, const_String_or_char_ptr decl);
+ extern SwigType *SwigType_strip_qualifiers(const SwigType *t);
+ extern SwigType *SwigType_strip_single_qualifier(const SwigType *t);
extern SwigType *SwigType_functionpointer_decompose(SwigType *t);
extern String *SwigType_base(const SwigType *t);
extern String *SwigType_namestr(const SwigType *t);
@@ -168,27 +168,26 @@ extern "C" {
extern String *SwigType_istemplate_templateprefix(const SwigType *t);
extern String *SwigType_templateargs(const SwigType *t);
extern String *SwigType_prefix(const SwigType *t);
- extern int SwigType_array_ndim(SwigType *t);
- extern String *SwigType_array_getdim(SwigType *t, int n);
+ extern int SwigType_array_ndim(const SwigType *t);
+ extern String *SwigType_array_getdim(const SwigType *t, int n);
extern void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep);
- extern SwigType *SwigType_array_type(SwigType *t);
- extern String *SwigType_default(SwigType *t);
- extern SwigType *SwigType_default_create(SwigType *ty);
- extern SwigType *SwigType_default_deduce(SwigType *t);
+ extern SwigType *SwigType_array_type(const SwigType *t);
+ extern SwigType *SwigType_default_create(const SwigType *ty);
+ extern SwigType *SwigType_default_deduce(const SwigType *t);
extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep);
extern SwigType *SwigType_remove_global_scope_prefix(const SwigType *t);
- extern SwigType *SwigType_alttype(SwigType *t, int ltmap);
+ extern SwigType *SwigType_alttype(const SwigType *t, int ltmap);
extern void SwigType_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
extern SwigType *SwigType_template_deftype(const SwigType *type, Symtab *tscope);
/* --- Type-system managment --- */
extern void SwigType_typesystem_init(void);
- extern int SwigType_typedef(SwigType *type, const_String_or_char_ptr name);
+ extern int SwigType_typedef(const SwigType *type, const_String_or_char_ptr name);
extern int SwigType_typedef_class(const_String_or_char_ptr name);
extern int SwigType_typedef_using(const_String_or_char_ptr qname);
extern void SwigType_inherit(String *subclass, String *baseclass, String *cast, String *conversioncode);
- extern int SwigType_issubtype(SwigType *subtype, SwigType *basetype);
+ extern int SwigType_issubtype(const SwigType *subtype, const SwigType *basetype);
extern void SwigType_scope_alias(String *aliasname, Typetab *t);
extern void SwigType_using_scope(Typetab *t);
extern void SwigType_new_scope(const_String_or_char_ptr name);
@@ -197,17 +196,17 @@ extern "C" {
extern Typetab *SwigType_set_scope(Typetab *h);
extern void SwigType_print_scope(Typetab *t);
extern SwigType *SwigType_typedef_resolve(const SwigType *t);
- extern SwigType *SwigType_typedef_resolve_all(SwigType *t);
- extern SwigType *SwigType_typedef_qualified(SwigType *t);
- extern int SwigType_istypedef(SwigType *t);
- extern int SwigType_isclass(SwigType *t);
+ extern SwigType *SwigType_typedef_resolve_all(const SwigType *t);
+ extern SwigType *SwigType_typedef_qualified(const SwigType *t);
+ extern int SwigType_istypedef(const SwigType *t);
+ extern int SwigType_isclass(const SwigType *t);
extern void SwigType_attach_symtab(Symtab *syms);
- extern void SwigType_remember(SwigType *t);
- extern void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientdata);
+ extern void SwigType_remember(const SwigType *t);
+ extern void SwigType_remember_clientdata(const SwigType *t, const_String_or_char_ptr clientdata);
extern void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata);
- extern void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *);
+ extern void (*SwigType_remember_trace(void (*tf) (const SwigType *, String *, String *))) (const SwigType *, String *, String *);
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
- extern int SwigType_type(SwigType *t);
+ extern int SwigType_type(const SwigType *t);
/* --- Symbol table module --- */
@@ -240,7 +239,7 @@ extern "C" {
extern void Swig_symbol_inherit(Symtab *tab);
extern SwigType *Swig_symbol_type_qualify(const SwigType *ty, Symtab *tab);
extern String *Swig_symbol_string_qualify(String *s, Symtab *tab);
- extern SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab);
+ extern SwigType *Swig_symbol_typedef_reduce(const SwigType *ty, Symtab *tab);
extern ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
extern SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope);
@@ -319,7 +318,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern String *Swig_string_lower(String *s);
extern String *Swig_string_upper(String *s);
extern String *Swig_string_title(String *s);
-
+ extern String *Swig_pcre_version(void);
extern void Swig_init(void);
extern int Swig_value_wrapper_mode(int mode);
@@ -334,6 +333,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern int Swig_warn_count(void);
extern void Swig_error_msg_format(ErrorMessageFormat format);
extern void Swig_diagnostic(const_String_or_char_ptr filename, int line, const char *fmt, ...);
+ extern String *Swig_stringify_with_location(DOH *object);
/* --- C Wrappers --- */
extern String *Swig_cparm_name(Parm *p, int i);
@@ -369,6 +369,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
#define CWRAP_DIRECTOR_ONE_CALL 0x08
#define CWRAP_DIRECTOR_TWO_CALLS 0x10
#define CWRAP_ALL_PROTECTED_ACCESS 0x20
+#define CWRAP_SMART_POINTER_OVERLOAD 0x40
/* --- Director Helpers --- */
extern Node *Swig_methodclass(Node *n);
@@ -408,6 +409,8 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern void Wrapper_director_protected_mode_set(int);
extern void Wrapper_all_protected_mode_set(int);
extern void Language_replace_special_variables(String *method, String *tm, Parm *parm);
+ extern void Swig_print(DOH *object, int count);
+ extern void Swig_print_with_location(DOH *object, int count);
/* -- template init -- */
diff --git a/Source/Swig/swigscan.h b/Source/Swig/swigscan.h
index b07812fbe..a2d5911bd 100644
--- a/Source/Swig/swigscan.h
+++ b/Source/Swig/swigscan.h
@@ -30,7 +30,7 @@ extern void Scanner_idstart(Scanner *, const char *idchar);
extern String *Scanner_errmsg(Scanner *);
extern int Scanner_errline(Scanner *);
extern int Scanner_isoperator(int tokval);
-extern void Scanner_freeze_line(Scanner *s, int val);
+extern void Scanner_locator(Scanner *, String *loc);
/* Note: Tokens in range 100+ are for C/C++ operators */
diff --git a/Source/Swig/symbol.c b/Source/Swig/symbol.c
index b5e114683..4ec18e8c7 100644
--- a/Source/Swig/symbol.c
+++ b/Source/Swig/symbol.c
@@ -1642,7 +1642,7 @@ SwigType *Swig_symbol_template_reduce(SwigType *qt, Symtab *ntab) {
* Chase a typedef through symbol tables looking for a match.
* ----------------------------------------------------------------------------- */
-SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab) {
+SwigType *Swig_symbol_typedef_reduce(const SwigType *ty, Symtab *tab) {
SwigType *prefix, *base;
Node *n;
String *nt;
diff --git a/Source/Swig/tree.c b/Source/Swig/tree.c
index c76ac958e..e66670c7c 100644
--- a/Source/Swig/tree.c
+++ b/Source/Swig/tree.c
@@ -291,10 +291,10 @@ void Swig_require(const char *ns, Node *n, ...) {
if (view) {
if (Strcmp(view, ns) != 0) {
Setattr(n, NewStringf("%s:view", ns), view);
- Setattr(n, "view", ns);
+ Setattr(n, "view", NewString(ns));
}
} else {
- Setattr(n, "view", ns);
+ Setattr(n, "view", NewString(ns));
}
}
}
@@ -337,10 +337,10 @@ void Swig_save(const char *ns, Node *n, ...) {
if (view) {
if (Strcmp(view, ns) != 0) {
Setattr(n, NewStringf("%s:view", ns), view);
- Setattr(n, "view", ns);
+ Setattr(n, "view", NewString(ns));
}
} else {
- Setattr(n, "view", ns);
+ Setattr(n, "view", NewString(ns));
}
}
}
diff --git a/Source/Swig/typemap.c b/Source/Swig/typemap.c
index 607ab6d10..fe6a33641 100644
--- a/Source/Swig/typemap.c
+++ b/Source/Swig/typemap.c
@@ -963,7 +963,7 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
{
SwigType *star_type, *amp_type, *base_type, *lex_type;
SwigType *ltype, *star_ltype, *amp_ltype;
- String *mangle, *star_mangle, *amp_mangle, *base_mangle, *base_name;
+ String *mangle, *star_mangle, *amp_mangle, *base_mangle, *base_name, *base_type_str;
String *descriptor, *star_descriptor, *amp_descriptor;
String *ts;
char *sc;
@@ -1132,21 +1132,20 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
/* Base type */
if (SwigType_isarray(type)) {
- SwigType *bt = Copy(type);
- Delete(SwigType_pop_arrays(bt));
- base_type = SwigType_str(bt, 0);
- Delete(bt);
+ base_type = Copy(type);
+ Delete(SwigType_pop_arrays(base_type));
} else {
base_type = SwigType_base(type);
}
- base_name = SwigType_namestr(base_type);
+ base_type_str = SwigType_str(base_type, 0);
+ base_name = SwigType_namestr(base_type_str);
if (index == 1) {
Replace(s, "$basetype", base_name, DOH_REPLACE_ANY);
replace_local_types(locals, "$basetype", base_name);
}
strcpy(varname, "basetype");
- Replace(s, var, base_type, DOH_REPLACE_ANY);
+ Replace(s, var, base_type_str, DOH_REPLACE_ANY);
replace_local_types(locals, var, base_name);
base_mangle = SwigType_manglestr(base_type);
@@ -1155,8 +1154,9 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
strcpy(varname, "basemangle");
Replace(s, var, base_mangle, DOH_REPLACE_ANY);
Delete(base_mangle);
- Delete(base_type);
Delete(base_name);
+ Delete(base_type_str);
+ Delete(base_type);
lex_type = SwigType_base(rtype);
if (index == 1)
@@ -1440,8 +1440,8 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
num_substitutions = typemap_replace_vars(s, locals, type, type, pname, (char *) lname, 1);
}
if (optimal_substitution && num_substitutions > 1) {
- Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to optimal attribute usage in\n", Swig_name_decl(node));
- Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(s), Getline(s), "the out typemap.\n");
+ Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to\n", Swig_name_decl(node));
+ Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(s), Getline(s), "optimal attribute usage in the out typemap.\n");
}
if (locals && f) {
diff --git a/Source/Swig/typeobj.c b/Source/Swig/typeobj.c
index 074bbf904..dd8d901e0 100644
--- a/Source/Swig/typeobj.c
+++ b/Source/Swig/typeobj.c
@@ -210,7 +210,7 @@ SwigType *SwigType_pop(SwigType *t) {
* Returns the parameter of an operator as a string
* ----------------------------------------------------------------------------- */
-String *SwigType_parm(SwigType *t) {
+String *SwigType_parm(const SwigType *t) {
char *start, *c;
int nparens = 0;
@@ -362,7 +362,7 @@ SwigType *SwigType_del_pointer(SwigType *t) {
return t;
}
-int SwigType_ispointer(SwigType *t) {
+int SwigType_ispointer(const SwigType *t) {
char *c;
if (!t)
return 0;
@@ -404,7 +404,7 @@ SwigType *SwigType_del_reference(SwigType *t) {
return t;
}
-int SwigType_isreference(SwigType *t) {
+int SwigType_isreference(const SwigType *t) {
char *c;
if (!t)
return 0;
@@ -494,7 +494,7 @@ SwigType *SwigType_del_qualifier(SwigType *t) {
return t;
}
-int SwigType_isqualifier(SwigType *t) {
+int SwigType_isqualifier(const SwigType *t) {
char *c;
if (!t)
return 0;
@@ -509,7 +509,7 @@ int SwigType_isqualifier(SwigType *t) {
* Function Pointers
* ----------------------------------------------------------------------------- */
-int SwigType_isfunctionpointer(SwigType *t) {
+int SwigType_isfunctionpointer(const SwigType *t) {
char *c;
if (!t)
return 0;
@@ -562,7 +562,7 @@ SwigType *SwigType_del_memberpointer(SwigType *t) {
return t;
}
-int SwigType_ismemberpointer(SwigType *t) {
+int SwigType_ismemberpointer(const SwigType *t) {
char *c;
if (!t)
return 0;
@@ -606,7 +606,7 @@ SwigType *SwigType_del_array(SwigType *t) {
return t;
}
-int SwigType_isarray(SwigType *t) {
+int SwigType_isarray(const SwigType *t) {
char *c;
if (!t)
return 0;
@@ -622,7 +622,7 @@ int SwigType_isarray(SwigType *t) {
* Determine if the type is a 1D array type that is treated as a pointer within SWIG
* eg Foo[], Foo[3] return true, but Foo[3][3], Foo*[], Foo*[3], Foo**[] return false
*/
-int SwigType_prefix_is_simple_1D_array(SwigType *t) {
+int SwigType_prefix_is_simple_1D_array(const SwigType *t) {
char *c = Char(t);
if (c && (strncmp(c, "a(", 2) == 0)) {
@@ -648,7 +648,7 @@ SwigType *SwigType_pop_arrays(SwigType *t) {
}
/* Return number of array dimensions */
-int SwigType_array_ndim(SwigType *t) {
+int SwigType_array_ndim(const SwigType *t) {
int ndim = 0;
char *c = Char(t);
@@ -661,7 +661,7 @@ int SwigType_array_ndim(SwigType *t) {
}
/* Get nth array dimension */
-String *SwigType_array_getdim(SwigType *t, int n) {
+String *SwigType_array_getdim(const SwigType *t, int n) {
char *c = Char(t);
while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) {
c = strchr(c, '.');
@@ -713,7 +713,7 @@ void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep) {
}
/* Return base type of an array */
-SwigType *SwigType_array_type(SwigType *ty) {
+SwigType *SwigType_array_type(const SwigType *ty) {
SwigType *t;
t = Copy(ty);
while (SwigType_isarray(t)) {
@@ -771,7 +771,7 @@ SwigType *SwigType_pop_function(SwigType *t) {
return g;
}
-int SwigType_isfunction(SwigType *t) {
+int SwigType_isfunction(const SwigType *t) {
char *c;
if (!t) {
return 0;
@@ -793,7 +793,7 @@ int SwigType_isfunction(SwigType *t) {
/* Create a list of parameters from the type t, using the file_line_node Node for
* file and line numbering for the parameters */
-ParmList *SwigType_function_parms(SwigType *t, Node *file_line_node) {
+ParmList *SwigType_function_parms(const SwigType *t, Node *file_line_node) {
List *l = SwigType_parmlist(t);
Hash *p, *pp = 0, *firstp = 0;
Iterator o;
@@ -1094,7 +1094,7 @@ String *SwigType_prefix(const SwigType *t) {
* Strip all qualifiers from a type and return a new type
* ----------------------------------------------------------------------------- */
-SwigType *SwigType_strip_qualifiers(SwigType *t) {
+SwigType *SwigType_strip_qualifiers(const SwigType *t) {
static Hash *memoize_stripped = 0;
SwigType *r;
List *l;
@@ -1138,7 +1138,7 @@ SwigType *SwigType_strip_qualifiers(SwigType *t) {
* r.p.int => r.p.int
* ----------------------------------------------------------------------------- */
-SwigType *SwigType_strip_single_qualifier(SwigType *t) {
+SwigType *SwigType_strip_single_qualifier(const SwigType *t) {
static Hash *memoize_stripped = 0;
SwigType *r = 0;
List *l;
diff --git a/Source/Swig/typesys.c b/Source/Swig/typesys.c
index 2436e005c..a1445f200 100644
--- a/Source/Swig/typesys.c
+++ b/Source/Swig/typesys.c
@@ -107,12 +107,12 @@ static Typetab *global_scope = 0; /* The global scope
static Hash *scopes = 0; /* Hash table containing fully qualified scopes */
/* Performance optimization */
-#define SWIG_TYPEDEF_RESOLVE_CACHE
+#define SWIG_TYPEDEF_RESOLVE_CACHE
static Hash *typedef_resolve_cache = 0;
static Hash *typedef_all_cache = 0;
static Hash *typedef_qualified_cache = 0;
-static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix);
+static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix);
/* common attribute keys, to avoid calling find_key all the times */
@@ -167,7 +167,7 @@ void SwigType_typesystem_init() {
* already defined.
* ----------------------------------------------------------------------------- */
-int SwigType_typedef(SwigType *type, const_String_or_char_ptr name) {
+int SwigType_typedef(const SwigType *type, const_String_or_char_ptr name) {
if (Getattr(current_typetab, name))
return -1; /* Already defined */
if (Strcmp(type, name) == 0) { /* Can't typedef a name to itself */
@@ -414,7 +414,7 @@ void SwigType_print_scope(Typetab *t) {
}
}
-static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
+static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix) {
Typetab *ss;
String *nnameprefix = 0;
static int check_parent = 1;
@@ -806,9 +806,10 @@ return_result:
* Fully resolve a type down to its most basic datatype
* ----------------------------------------------------------------------------- */
-SwigType *SwigType_typedef_resolve_all(SwigType *t) {
+SwigType *SwigType_typedef_resolve_all(const SwigType *t) {
SwigType *n;
SwigType *r;
+ int count = 0;
/* Check to see if the typedef resolve has been done before by checking the cache */
if (!typedef_all_cache) {
@@ -824,6 +825,10 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) {
while ((n = SwigType_typedef_resolve(r))) {
Delete(r);
r = n;
+ if (++count >= 512) {
+ Swig_error(Getfile(t), Getline(t), "Recursive typedef detected resolving '%s' to '%s' to '%s' and so on...\n", SwigType_str(t, 0), SwigType_str(SwigType_typedef_resolve(t), 0), SwigType_str(SwigType_typedef_resolve(SwigType_typedef_resolve(t)), 0));
+ break;
+ }
}
/* Add the typedef to the cache for next time it is looked up */
@@ -848,7 +853,7 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) {
* scope, it is left in place.
* ----------------------------------------------------------------------------- */
-SwigType *SwigType_typedef_qualified(SwigType *t) {
+SwigType *SwigType_typedef_qualified(const SwigType *t) {
List *elements;
String *result;
int i, len;
@@ -1049,7 +1054,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t) {
* Checks a typename to see if it is a typedef.
* ----------------------------------------------------------------------------- */
-int SwigType_istypedef(SwigType *t) {
+int SwigType_istypedef(const SwigType *t) {
String *type;
type = SwigType_typedef_resolve(t);
@@ -1150,7 +1155,7 @@ int SwigType_typedef_using(const_String_or_char_ptr name) {
* a class.
* ----------------------------------------------------------------------------- */
-int SwigType_isclass(SwigType *t) {
+int SwigType_isclass(const SwigType *t) {
SwigType *qty, *qtys;
int isclass = 0;
@@ -1186,7 +1191,7 @@ int SwigType_isclass(SwigType *t) {
* everything is based on typemaps.
* ----------------------------------------------------------------------------- */
-int SwigType_type(SwigType *t) {
+int SwigType_type(const SwigType *t) {
char *c;
/* Check for the obvious stuff */
c = Char(t);
@@ -1295,7 +1300,7 @@ int SwigType_type(SwigType *t) {
* %feature("valuewrapper").
* ----------------------------------------------------------------------------- */
-SwigType *SwigType_alttype(SwigType *t, int local_tmap) {
+SwigType *SwigType_alttype(const SwigType *t, int local_tmap) {
Node *n;
SwigType *w = 0;
int use_wrapper = 0;
@@ -1413,7 +1418,7 @@ static Hash *r_clientdata = 0; /* Hash mapping resolved types to client data
static Hash *r_mangleddata = 0; /* Hash mapping mangled types to client data */
static Hash *r_remembered = 0; /* Hash of types we remembered already */
-static void (*r_tracefunc) (SwigType *t, String *mangled, String *clientdata) = 0;
+static void (*r_tracefunc) (const SwigType *t, String *mangled, String *clientdata) = 0;
void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata) {
if (!r_mangleddata) {
@@ -1423,7 +1428,7 @@ void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr cli
}
-void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientdata) {
+void SwigType_remember_clientdata(const SwigType *t, const_String_or_char_ptr clientdata) {
String *mt;
SwigType *lt;
Hash *h;
@@ -1536,12 +1541,12 @@ void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientda
}
}
-void SwigType_remember(SwigType *ty) {
+void SwigType_remember(const SwigType *ty) {
SwigType_remember_clientdata(ty, 0);
}
-void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *) {
- void (*o) (SwigType *, String *, String *) = r_tracefunc;
+void (*SwigType_remember_trace(void (*tf) (const SwigType *, String *, String *))) (const SwigType *, String *, String *) {
+ void (*o) (const SwigType *, String *, String *) = r_tracefunc;
r_tracefunc = tf;
return o;
}
@@ -1713,7 +1718,7 @@ void SwigType_inherit(String *derived, String *base, String *cast, String *conve
* Determines if a t1 is a subtype of t2, ie, is t1 derived from t2
* ----------------------------------------------------------------------------- */
-int SwigType_issubtype(SwigType *t1, SwigType *t2) {
+int SwigType_issubtype(const SwigType *t1, const SwigType *t2) {
SwigType *ft1, *ft2;
String *b1, *b2;
Hash *h;
diff --git a/Tools/config/ax_boost_base.m4 b/Tools/config/ax_boost_base.m4
new file mode 100644
index 000000000..54a2a1bee
--- /dev/null
+++ b/Tools/config/ax_boost_base.m4
@@ -0,0 +1,258 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_boost_base.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+#
+# DESCRIPTION
+#
+# Test for the Boost C++ libraries of a particular version (or newer)
+#
+# If no path to the installed boost library is given the macro searchs
+# under /usr, /usr/local, /opt and /opt/local and evaluates the
+# $BOOST_ROOT environment variable. Further documentation is available at
+# <http://randspringer.de/boost/index.html>.
+#
+# This macro calls:
+#
+# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
+#
+# And sets:
+#
+# HAVE_BOOST
+#
+# LICENSE
+#
+# Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
+# Copyright (c) 2009 Peter Adolphs
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 20
+
+AC_DEFUN([AX_BOOST_BASE],
+[
+AC_ARG_WITH([boost],
+ [AS_HELP_STRING([--with-boost@<:@=ARG@:>@],
+ [use Boost library from a standard location (ARG=yes),
+ from the specified location (ARG=<path>),
+ or disable it (ARG=no)
+ @<:@ARG=yes@:>@ ])],
+ [
+ if test "$withval" = "no"; then
+ want_boost="no"
+ elif test "$withval" = "yes"; then
+ want_boost="yes"
+ ac_boost_path=""
+ else
+ want_boost="yes"
+ ac_boost_path="$withval"
+ fi
+ ],
+ [want_boost="yes"])
+
+
+AC_ARG_WITH([boost-libdir],
+ AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
+ [Force given directory for boost libraries. Note that this will override library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
+ [
+ if test -d "$withval"
+ then
+ ac_boost_lib_path="$withval"
+ else
+ AC_MSG_ERROR(--with-boost-libdir expected directory name)
+ fi
+ ],
+ [ac_boost_lib_path=""]
+)
+
+if test "x$want_boost" = "xyes"; then
+ boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
+ boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
+ boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
+ boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
+ boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
+ if test "x$boost_lib_version_req_sub_minor" = "x" ; then
+ boost_lib_version_req_sub_minor="0"
+ fi
+ WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
+ AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
+ succeeded=no
+
+ dnl On 64-bit systems check for system libraries in both lib64 and lib.
+ dnl The former is specified by FHS, but e.g. Debian does not adhere to
+ dnl this (as it rises problems for generic multi-arch support).
+ dnl The last entry in the list is chosen by default when no libraries
+ dnl are found, e.g. when only header-only libraries are installed!
+ libsubdirs="lib"
+ ax_arch=`uname -m`
+ if test $ax_arch = x86_64 -o $ax_arch = ppc64 -o $ax_arch = s390x -o $ax_arch = sparc64; then
+ libsubdirs="lib64 lib lib64"
+ fi
+
+ dnl first we check the system location for boost libraries
+ dnl this location ist chosen if boost libraries are installed with the --layout=system option
+ dnl or if you install boost with RPM
+ if test "$ac_boost_path" != ""; then
+ BOOST_CPPFLAGS="-I$ac_boost_path/include"
+ for ac_boost_path_tmp in $libsubdirs; do
+ if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then
+ BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp"
+ break
+ fi
+ done
+ elif test "$cross_compiling" != yes; then
+ for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
+ if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
+ for libsubdir in $libsubdirs ; do
+ if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
+ done
+ BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir"
+ BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
+ break;
+ fi
+ done
+ fi
+
+ dnl overwrite ld flags if we have required special directory with
+ dnl --with-boost-libdir parameter
+ if test "$ac_boost_lib_path" != ""; then
+ BOOST_LDFLAGS="-L$ac_boost_lib_path"
+ fi
+
+ CPPFLAGS_SAVED="$CPPFLAGS"
+ CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+ export CPPFLAGS
+
+ LDFLAGS_SAVED="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+ export LDFLAGS
+
+ AC_REQUIRE([AC_PROG_CXX])
+ AC_LANG_PUSH(C++)
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ @%:@include <boost/version.hpp>
+ ]], [[
+ #if BOOST_VERSION >= $WANT_BOOST_VERSION
+ // Everything is okay
+ #else
+ # error Boost version is too old
+ #endif
+ ]])],[
+ AC_MSG_RESULT(yes)
+ succeeded=yes
+ found_system=yes
+ ],[
+ ])
+ AC_LANG_POP([C++])
+
+
+
+ dnl if we found no boost with system layout we search for boost libraries
+ dnl built and installed without the --layout=system option or for a staged(not installed) version
+ if test "x$succeeded" != "xyes"; then
+ _version=0
+ if test "$ac_boost_path" != ""; then
+ if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
+ for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
+ _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
+ V_CHECK=`expr $_version_tmp \> $_version`
+ if test "$V_CHECK" = "1" ; then
+ _version=$_version_tmp
+ fi
+ VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
+ BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
+ done
+ fi
+ else
+ if test "$cross_compiling" != yes; then
+ for ac_boost_path in /usr /usr/local /opt /opt/local ; do
+ if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
+ for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
+ _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
+ V_CHECK=`expr $_version_tmp \> $_version`
+ if test "$V_CHECK" = "1" ; then
+ _version=$_version_tmp
+ best_path=$ac_boost_path
+ fi
+ done
+ fi
+ done
+
+ VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
+ BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
+ if test "$ac_boost_lib_path" = ""; then
+ for libsubdir in $libsubdirs ; do
+ if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
+ done
+ BOOST_LDFLAGS="-L$best_path/$libsubdir"
+ fi
+ fi
+
+ if test "x$BOOST_ROOT" != "x"; then
+ for libsubdir in $libsubdirs ; do
+ if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi
+ done
+ if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then
+ version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
+ stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
+ stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
+ V_CHECK=`expr $stage_version_shorten \>\= $_version`
+ if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
+ AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
+ BOOST_CPPFLAGS="-I$BOOST_ROOT"
+ BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir"
+ fi
+ fi
+ fi
+ fi
+
+ CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
+ export CPPFLAGS
+ LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
+ export LDFLAGS
+
+ AC_LANG_PUSH(C++)
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+ @%:@include <boost/version.hpp>
+ ]], [[
+ #if BOOST_VERSION >= $WANT_BOOST_VERSION
+ // Everything is okay
+ #else
+ # error Boost version is too old
+ #endif
+ ]])],[
+ AC_MSG_RESULT(yes)
+ succeeded=yes
+ found_system=yes
+ ],[
+ ])
+ AC_LANG_POP([C++])
+ fi
+
+ if test "$succeeded" != "yes" ; then
+ if test "$_version" = "0" ; then
+ AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
+ else
+ AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).])
+ fi
+ # execute ACTION-IF-NOT-FOUND (if present):
+ ifelse([$3], , :, [$3])
+ else
+ AC_SUBST(BOOST_CPPFLAGS)
+ AC_SUBST(BOOST_LDFLAGS)
+ AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
+ # execute ACTION-IF-FOUND (if present):
+ ifelse([$2], , :, [$2])
+ fi
+
+ CPPFLAGS="$CPPFLAGS_SAVED"
+ LDFLAGS="$LDFLAGS_SAVED"
+fi
+
+])
diff --git a/Tools/config/ax_compare_version.m4 b/Tools/config/ax_compare_version.m4
new file mode 100644
index 000000000..74dc0fdd9
--- /dev/null
+++ b/Tools/config/ax_compare_version.m4
@@ -0,0 +1,177 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_compare_version.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
+#
+# DESCRIPTION
+#
+# This macro compares two version strings. Due to the various number of
+# minor-version numbers that can exist, and the fact that string
+# comparisons are not compatible with numeric comparisons, this is not
+# necessarily trivial to do in a autoconf script. This macro makes doing
+# these comparisons easy.
+#
+# The six basic comparisons are available, as well as checking equality
+# limited to a certain number of minor-version levels.
+#
+# The operator OP determines what type of comparison to do, and can be one
+# of:
+#
+# eq - equal (test A == B)
+# ne - not equal (test A != B)
+# le - less than or equal (test A <= B)
+# ge - greater than or equal (test A >= B)
+# lt - less than (test A < B)
+# gt - greater than (test A > B)
+#
+# Additionally, the eq and ne operator can have a number after it to limit
+# the test to that number of minor versions.
+#
+# eq0 - equal up to the length of the shorter version
+# ne0 - not equal up to the length of the shorter version
+# eqN - equal up to N sub-version levels
+# neN - not equal up to N sub-version levels
+#
+# When the condition is true, shell commands ACTION-IF-TRUE are run,
+# otherwise shell commands ACTION-IF-FALSE are run. The environment
+# variable 'ax_compare_version' is always set to either 'true' or 'false'
+# as well.
+#
+# Examples:
+#
+# AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8])
+# AX_COMPARE_VERSION([3.15],[lt],[3.15.8])
+#
+# would both be true.
+#
+# AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8])
+# AX_COMPARE_VERSION([3.15],[gt],[3.15.8])
+#
+# would both be false.
+#
+# AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8])
+#
+# would be true because it is only comparing two minor versions.
+#
+# AX_COMPARE_VERSION([3.15.7],[eq0],[3.15])
+#
+# would be true because it is only comparing the lesser number of minor
+# versions of the two values.
+#
+# Note: The characters that separate the version numbers do not matter. An
+# empty string is the same as version 0. OP is evaluated by autoconf, not
+# configure, so must be a string, not a variable.
+#
+# The author would like to acknowledge Guido Draheim whose advice about
+# the m4_case and m4_ifvaln functions make this macro only include the
+# portions necessary to perform the specific comparison specified by the
+# OP argument in the final configure script.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Tim Toolan <toolan@ele.uri.edu>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 11
+
+dnl #########################################################################
+AC_DEFUN([AX_COMPARE_VERSION], [
+ AC_REQUIRE([AC_PROG_AWK])
+
+ # Used to indicate true or false condition
+ ax_compare_version=false
+
+ # Convert the two version strings to be compared into a format that
+ # allows a simple string comparison. The end result is that a version
+ # string of the form 1.12.5-r617 will be converted to the form
+ # 0001001200050617. In other words, each number is zero padded to four
+ # digits, and non digits are removed.
+ AS_VAR_PUSHDEF([A],[ax_compare_version_A])
+ A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
+ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/[[^0-9]]//g'`
+
+ AS_VAR_PUSHDEF([B],[ax_compare_version_B])
+ B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
+ -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
+ -e 's/[[^0-9]]//g'`
+
+ dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary
+ dnl # then the first line is used to determine if the condition is true.
+ dnl # The sed right after the echo is to remove any indented white space.
+ m4_case(m4_tolower($2),
+ [lt],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"`
+ ],
+ [gt],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"`
+ ],
+ [le],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"`
+ ],
+ [ge],[
+ ax_compare_version=`echo "x$A
+x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"`
+ ],[
+ dnl Split the operator from the subversion count if present.
+ m4_bmatch(m4_substr($2,2),
+ [0],[
+ # A count of zero means use the length of the shorter version.
+ # Determine the number of characters in A and B.
+ ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'`
+ ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'`
+
+ # Set A to no more than B's length and B to no more than A's length.
+ A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"`
+ B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"`
+ ],
+ [[0-9]+],[
+ # A count greater than zero means use only that many subversions
+ A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
+ B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
+ ],
+ [.+],[
+ AC_WARNING(
+ [illegal OP numeric parameter: $2])
+ ],[])
+
+ # Pad zeros at end of numbers to make same length.
+ ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`"
+ B="$B`echo $A | sed 's/./0/g'`"
+ A="$ax_compare_version_tmp_A"
+
+ # Check for equality or inequality as necessary.
+ m4_case(m4_tolower(m4_substr($2,0,2)),
+ [eq],[
+ test "x$A" = "x$B" && ax_compare_version=true
+ ],
+ [ne],[
+ test "x$A" != "x$B" && ax_compare_version=true
+ ],[
+ AC_WARNING([illegal OP parameter: $2])
+ ])
+ ])
+
+ AS_VAR_POPDEF([A])dnl
+ AS_VAR_POPDEF([B])dnl
+
+ dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE.
+ if test "$ax_compare_version" = "true" ; then
+ m4_ifvaln([$4],[$4],[:])dnl
+ m4_ifvaln([$5],[else $5])dnl
+ fi
+]) dnl AX_COMPARE_VERSION
diff --git a/Tools/config/ax_path_generic.m4 b/Tools/config/ax_path_generic.m4
new file mode 100644
index 000000000..4db2da11b
--- /dev/null
+++ b/Tools/config/ax_path_generic.m4
@@ -0,0 +1,142 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_path_generic.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_PATH_GENERIC(LIBRARY,[MINIMUM-VERSION,[SED-EXPR-EXTRACTOR]],[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],[CONFIG-SCRIPTS],[CFLAGS-ARG],[LIBS-ARG])
+#
+# DESCRIPTION
+#
+# Runs the LIBRARY-config script and defines LIBRARY_CFLAGS and
+# LIBRARY_LIBS
+#
+# The script must support `--cflags' and `--libs' args. If MINIMUM-VERSION
+# is specified, the script must also support the `--version' arg. If the
+# `--with-library-[exec-]prefix' arguments to ./configure are given, it
+# must also support `--prefix' and `--exec-prefix'. Prefereable use
+# CONFIG-SCRIPTS as config script, CFLAGS-ARG instead of `--cflags` and
+# LIBS-ARG instead of `--libs`, if given.
+#
+# The SED-EXPR-EXTRACTOR parameter representes the expression used in sed
+# to extract the version number. Use it if your 'foo-config --version'
+# dumps something like 'Foo library v1.0.0 (alfa)' instead of '1.0.0'.
+#
+# Example:
+#
+# AX_PATH_GENERIC(Foo, 1.0.0)
+#
+# would run `foo-config --version' and check that it is at least 1.0.0, if
+# successful the following variables would be defined and substituted:
+#
+# FOO_CFLAGS to `foo-config --cflags`
+# FOO_LIBS to `foo-config --libs`
+#
+# Example:
+#
+# AX_PATH_GENERIC([Bar],,,[
+# AC_MSG_ERROR([Cannot find Bar library])
+# ])
+#
+# would check for bar-config program, defining and substituting the
+# following variables:
+#
+# BAR_CFLAGS to `bar-config --cflags`
+# BAR_LIBS to `bar-config --libs`
+#
+# This macro is a rearranged version of AC_PATH_GENERIC from Angus Lees.
+#
+# LICENSE
+#
+# Copyright (c) 2009 Francesco Salvestrini <salvestrini@users.sourceforge.net>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 10
+
+AU_ALIAS([AC_PATH_GENERIC], [AX_PATH_GENERIC])
+AC_DEFUN([AX_PATH_GENERIC],[
+ AC_REQUIRE([AC_PROG_SED])
+
+ dnl we're going to need uppercase and lowercase versions of the
+ dnl string `LIBRARY'
+ pushdef([UP], translit([$1], [a-z], [A-Z]))dnl
+ pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
+
+ AC_ARG_WITH(DOWN-prefix,[AS_HELP_STRING([--with-]DOWN[-prefix=PREFIX], [Prefix where $1 is installed (optional)])],
+ DOWN[]_config_prefix="$withval", DOWN[]_config_prefix="")
+ AC_ARG_WITH(DOWN-exec-prefix,[AS_HELP_STRING([--with-]DOWN[-exec-prefix=EPREFIX], [Exec prefix where $1 is installed (optional)])],
+ DOWN[]_config_exec_prefix="$withval", DOWN[]_config_exec_prefix="")
+
+ AC_ARG_VAR(UP[]_CONFIG, [config script used for $1])
+ AC_ARG_VAR(UP[]_CFLAGS, [CFLAGS used for $1])
+ AC_ARG_VAR(UP[]_LIBS, [LIBS used for $1])
+
+ AS_IF([test x$DOWN[]_config_exec_prefix != x],[
+ DOWN[]_config_args="$DOWN[]_config_args --exec-prefix=$DOWN[]_config_exec_prefix"
+ AS_IF([test x${UP[]_CONFIG+set} != xset],[
+ UP[]_CONFIG=$DOWN[]_config_exec_prefix/bin/DOWN-config
+ ])
+ ])
+ AS_IF([test x$DOWN[]_config_prefix != x],[
+ DOWN[]_config_args="$DOWN[]_config_args --prefix=$DOWN[]_config_prefix"
+ AS_IF([test x${UP[]_CONFIG+set} != xset],[
+ UP[]_CONFIG=$DOWN[]_config_prefix/bin/DOWN-config
+ ])
+ ])
+
+ AC_PATH_PROGS(UP[]_CONFIG,[$6 DOWN-config],[no])
+ AS_IF([test "$UP[]_CONFIG" == "no"],[
+ :
+ $5
+ ],[
+ dnl Get the CFLAGS from LIBRARY-config script
+ AS_IF([test x"$7" == x],[
+ UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args --cflags`"
+ ],[
+ UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args $7`"
+ ])
+
+ dnl Get the LIBS from LIBRARY-config script
+ AS_IF([test x"$8" == x],[
+ UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args --libs`"
+ ],[
+ UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args $8`"
+ ])
+
+ AS_IF([test x"$2" != x],[
+ dnl Check for provided library version
+ AS_IF([test x"$3" != x],[
+ dnl Use provided sed expression
+ DOWN[]_version="`$UP[]_CONFIG $DOWN[]_config_args --version | $SED -e $3`"
+ ],[
+ DOWN[]_version="`$UP[]_CONFIG $DOWN[]_config_args --version | $SED -e 's/^\ *\(.*\)\ *$/\1/'`"
+ ])
+
+ AC_MSG_CHECKING([for $1 ($DOWN[]_version) >= $2])
+ AX_COMPARE_VERSION($DOWN[]_version,[ge],[$2],[
+ AC_MSG_RESULT([yes])
+
+ AC_SUBST(UP[]_CFLAGS)
+ AC_SUBST(UP[]_LIBS)
+ :
+ $4
+ ],[
+ AC_MSG_RESULT([no])
+ :
+ $5
+ ])
+ ],[
+ AC_SUBST(UP[]_CFLAGS)
+ AC_SUBST(UP[]_LIBS)
+ :
+ $4
+ ])
+ ])
+
+ popdef([UP])
+ popdef([DOWN])
+])
diff --git a/Tools/mkwindows.sh b/Tools/mkwindows.sh
index 869fce01a..6042361b3 100755
--- a/Tools/mkwindows.sh
+++ b/Tools/mkwindows.sh
@@ -43,7 +43,7 @@ else
if test x$zip = x; then
zip=zip
fi
- extraconfigureoptions="--host=i586-mingw32msvc --build=i686-linux CXXFLAGS=-O2 CFLAGS=-O2"
+ extraconfigureoptions="--host=i586-mingw32msvc --build=i686-linux"
else
if test "$cygwin"; then
echo "Building native Windows executable on Cygwin"
@@ -61,6 +61,13 @@ fi
swigbasename=swig-$version
swigwinbasename=swigwin-$version
tarball=$swigbasename.tar.gz
+pcre_tarball=`ls pcre-*.tar.*`
+
+if ! test -f "$pcre_tarball"; then
+ echo "Could not find PCRE tarball. Please download a PCRE source tarball from http://www.pcre.org"
+ echo "and place in the same directory as the SWIG tarball."
+ exit 1
+fi
if test -f "$tarball"; then
builddir=build-$version
@@ -78,8 +85,11 @@ if test -f "$tarball"; then
mv $swigbasename $swigwinbasename
tar -zxf ../$tarball
cd $swigbasename
+ (cd ../.. && cp $pcre_tarball $builddir/$swigbasename)
+ echo Running: Tools/pcre-build.sh $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags"
+ ./Tools/pcre-build.sh $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" || exit 1
echo Running: ./configure $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags"
- ./configure $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags"
+ ./configure $extraconfigureoptions CFLAGS="$compileflags" CXXFLAGS="$compileflags" || exit 1
echo "Compiling (quietly)..."
make > build.log
echo "Simple check to see if swig.exe runs..."
diff --git a/Tools/pcre-build.sh b/Tools/pcre-build.sh
new file mode 100755
index 000000000..876a58a7e
--- /dev/null
+++ b/Tools/pcre-build.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+pcre_subdir=pcre/pcre-swig-install
+pcre_install_dir=`pwd`/$pcre_subdir
+
+usage() {
+ echo "Helper script to build PCRE as a static library from a tarball just for use during the"
+ echo "SWIG build. It does not install PCRE for global use on your system."
+ echo "Usage: pcre-build.sh [--help] [args]"
+ echo " args - optional additional arguments passed on to the PCRE configure script (leave out"
+ echo " unless you are an expert at configure)"
+ echo " --help - Display this help information."
+ echo "Instructions:"
+ echo " - Download the latest PCRE source tarball from http://www.pcre.org and place in the"
+ echo " directory that you will configure and build SWIG."
+ echo " - Run this script in the same directory that you intend to configure and build SWIG in."
+ echo " - Afterwards run the SWIG configure scrip which will then find and use the PCRE static"
+ echo " libraries in the $pcre_subdir subdirectory."
+ exit 0
+}
+
+bail() {
+ echo $1 >&2
+ exit 1
+}
+
+if test "$1" = "-h" -o "$1" = "-help" -o "$1" = "--help" ; then
+ usage
+fi
+
+if test -f "pcre-build.sh" ; then
+ echo "Error: this script should not be run in the Tools directory" >&2
+ echo ""
+ usage
+fi
+
+echo "Looking for PCRE tarball..."
+rm -rf pcre
+pcre_tarball=`ls pcre-*.tar.*`
+test -f "$pcre_tarball" || bail "Could not find tarball"
+
+echo "Extracting tarball: $pcre_tarball"
+tar -xf $pcre_tarball || bail "Could not untar $pcre_tarball"
+pcre_dir=`echo $pcre_tarball | sed -e "s/\.tar.*//"`
+echo "Configuring PCRE in directory: pcre"
+mv $pcre_dir pcre || bail "Could not create pcre directory"
+cd pcre && ./configure --prefix=$pcre_install_dir --disable-shared $* || bail "PCRE configure failed"
+echo "Building PCRE..."
+make -s || bail "Could not build PCRE"
+echo "Installing PCRE locally to $pcre_install_dir..."
+make -s install || bail "Could not install PCRE"
+echo ""
+echo "The SWIG configure script can now be run, whereupon PCRE will automatically be detected and used from $pcre_install_dir/bin/pcre-config."
diff --git a/Tools/swig.gdb b/Tools/swig.gdb
new file mode 100644
index 000000000..195032955
--- /dev/null
+++ b/Tools/swig.gdb
@@ -0,0 +1,41 @@
+# User-defined commands for easier debugging of SWIG in gdb
+#
+# This file can be "included" into your main .gdbinit file using:
+# source swig.gdb
+# or otherwise paste the contents into .gdbinit
+#
+# Note all user defined commands can be seen using:
+# (gdb) show user
+# The documentation for each command can be easily viewed, for example:
+# (gdb) help swigprint
+
+define swigprint
+ if ($argc == 2)
+ set $expand_count = $arg1
+ else
+ set $expand_count = -1
+ end
+ call Swig_print($arg0, $expand_count)
+end
+document swigprint
+Displays any SWIG DOH object
+Usage: swigprint swigobject [hashexpandcount]
+ swigobject - The object to display.
+ hashexpandcount - Number of nested Hash types to expand (default is 1). See Swig_set_max_hash_expand() to change default.
+end
+
+
+define locswigprint
+ if ($argc == 2)
+ set $expand_count = $arg1
+ else
+ set $expand_count = -1
+ end
+ call Swig_print_with_location($arg0, $expand_count)
+end
+document locswigprint
+Displays any SWIG DOH object prefixed with file and line location
+Usage: locswigprint swigobject [hashexpandcount]
+ swigobject - The object to display.
+ hashexpandcount - Number of nested Hash types to expand (default is 1). See Swig_set_max_hash_expand() to change default.
+end
diff --git a/configure.in b/configure.in
index b6eee4941..d84919861 100644
--- a/configure.in
+++ b/configure.in
@@ -2,8 +2,12 @@ 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],[2.0.1],[http://www.swig.org])
+AC_INIT([swig],[2.0.2],[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
AC_PREREQ(2.58)
+
AC_CONFIG_SRCDIR([Source/Swig/swig.h])
AC_CONFIG_AUX_DIR([Tools/config])
AC_CONFIG_HEADERS([Source/Include/swigconfig.h])
@@ -15,7 +19,7 @@ AH_BOTTOM([
/* Default language */
#define SWIG_LANG "-tcl"
-/* Deal with Microsoft's attempt at deprecating C standard runtime functions */
+/* Deal with Microsofts attempt at deprecating C standard runtime functions */
#if defined(_MSC_VER)
# define _CRT_SECURE_NO_DEPRECATE
#endif
@@ -49,23 +53,56 @@ else
AC_CHECK_FUNC(popen, AC_DEFINE(HAVE_POPEN, 1, [Define if popen is available]), AC_MSG_NOTICE([Disabling popen]))
fi
-dnl Look for RxSpencer
-AC_ARG_WITH(rxspencer, AS_HELP_STRING([--with-rxspencer], [Enable RxSpencer]), with_rxspencer="yes")
-if test x"${with_rxspencer}" = xyes ; then
-#check first for the header
- AC_CHECK_HEADER(rxspencer/regex.h,with_rxspencer="yes",with_rxspencer="no")
- if test x"${with_rxspencer}" = xyes ; then
-# now check for the library
- AC_CHECK_LIB(rxspencer, regcomp,with_rxspencer="yes",with_rxspencer="no")
- fi
- if test x"${with_rxspencer}" = xyes ; then
-# library and header are available
- AC_DEFINE(HAVE_RXSPENCER, 1,[Define if rxspencer is available])
- LIBS="$LIBS -lrxspencer"
- else
- AC_MSG_NOTICE([RxSpencer not found. Obtain it at http://arglist.com/regex or http://gnuwin32.sourceforge.net/packages.html])
- fi
-fi
+dnl PCRE
+
+dnl AX_PATH_GENERIC() relies on AC_PROG_SED() but it is defined only in
+dnl autoconf 2.60 so trivially predefine it ourselves for the older versions
+m4_ifdef([AC_PROG_SED],, [AC_DEFUN([AC_PROG_SED], [AC_PATH_PROG([SED], sed)])])
+
+AC_ARG_WITH([pcre],
+ [AS_HELP_STRING([--without-pcre],
+ [Disable support for regular expressions using PCRE])],
+ [],
+ [with_pcre=yes])
+
+AC_MSG_CHECKING([whether to enable PCRE support])
+AC_MSG_RESULT([$with_pcre])
+
+dnl To make configuring easier, check for a locally built PCRE using the Tools/pcre-build.sh script
+if test x"${with_pcre}" = xyes ; then
+ AC_MSG_CHECKING([whether to use local PCRE])
+ local_pcre_config=no
+ if test -z $PCRE_CONFIG; then
+ if test -f `pwd`/pcre/pcre-swig-install/bin/pcre-config; then
+ PCRE_CONFIG=`pwd`/pcre/pcre-swig-install/bin/pcre-config
+ local_pcre_config=$PCRE_CONFIG
+ fi
+ fi
+ AC_MSG_RESULT([$local_pcre_config])
+fi
+AS_IF([test "x$with_pcre" != xno],
+ [AX_PATH_GENERIC([pcre],
+ [], dnl Minimal version of PCRE we need -- accept any
+ [], dnl custom sed script for version parsing is not needed
+ [AC_DEFINE([HAVE_PCRE], [1], [Define if you have PCRE library])
+ LIBS="$LIBS $PCRE_LIBS"
+ CPPFLAGS="$CPPFLAGS $PCRE_CFLAGS"
+ ],
+ [AC_MSG_FAILURE([
+ Cannot find pcre-config script from PCRE (Perl Compatible Regular Expressions)
+ library package. This dependency is needed for configure to complete,
+ Either:
+ - Install the PCRE developer package on your system (preferred approach).
+ - Download the PCRE source tarball, build and install on your system
+ as you would for any package built from source distribution.
+ - Use the Tools/pcre-build.sh script to build PCRE just for SWIG to statically
+ link against. Run 'Tools/pcre-build.sh --help' for instructions.
+ (quite easy and does not require privileges to install PCRE on your system)
+ - Use configure --without-pcre to disable regular expressions support in SWIG
+ (not recommended).])
+ ])
+ ])
+
dnl CCache
AC_ARG_ENABLE([ccache], AS_HELP_STRING([--disable-ccache], [disable building and installation of ccache-swig executable (default enabled)]), [enable_ccache=$enableval], [enable_ccache=yes])
@@ -93,10 +130,14 @@ AC_CHECK_PROGS(YODL2HTML, yodl2html)
echo ""
-echo "Checking for installed target languages and other information in order to compile and run the examples."
+echo "Checking for installed target languages and other information in order to compile and run"
+echo "the examples and test-suite invoked by 'make check'."
echo "Note : None of the following packages are required for users to compile and install SWIG"
echo ""
+dnl Some test cases require Boost
+AX_BOOST_BASE(,,,)
+AC_SUBST(BOOST_CPPFLAGS)
dnl How to specify include directories that may be system directories.
# -I should not be used on system directories (GCC)
@@ -1981,28 +2022,123 @@ AC_ARG_WITH(go, AS_HELP_STRING([--without-go], [Disable Go])
AS_HELP_STRING([--with-go=path], [Set location of Go compiler]),[GOBIN="$withval"], [GOBIN=yes])
if test x"${GOBIN}" = xno -o x"${with_alllang}" = xno ; then
-AC_MSG_NOTICE([Disabling Go])
-GO=
-GOGCC=false
+ AC_MSG_NOTICE([Disabling Go])
+ GO=
+ GOGCC=false
else
- if test "x$GOBIN" = xyes; then
- AC_CHECK_PROGS(GO, 6g 8g gccgo)
- else
- GO="$GOBIN"
- fi
+ if test "x$GOBIN" = xyes; then
+ AC_CHECK_PROGS(GO, 6g 8g gccgo)
+ else
+ GO="$GOBIN"
+ fi
+ if test -n "$GO" ; then
GOGCC=false
if $GO --help 2>/dev/null | grep gccgo >/dev/null 2>&1 ; then
- GOGCC=true
+ GOGCC=true
+ else
+ AC_MSG_CHECKING([whether Go ($GO) version is too old])
+ go_version=`$GO -V | sed -e 's/.*version \([[0-9]]*\).*/\1/'`
+ go_min_version=7077
+ if test "$go_version" -lt $go_min_version; then
+ AC_MSG_RESULT([yes - minimum version is $go_min_version])
+ GO=
+ else
+ AC_MSG_RESULT([no])
+ fi
fi
-
+ fi
fi
AC_SUBST(GOGCC)
AC_SUBST(GO)
#----------------------------------------------------------------
+# Look for D
+#----------------------------------------------------------------
+
+AC_ARG_WITH(d, AS_HELP_STRING([--without-d], [Disable D]), [with_d="$withval"], [with_d=yes])
+AC_ARG_WITH(d1-compiler, [ --with-d1-compiler=path Set location of D1/Tango compiler (DMD compatible)],[D1COMPILERBIN="$withval"], [D1COMPILERBIN=])
+AC_ARG_WITH(d2-compiler, [ --with-d2-compiler=path Set location of D2 compiler (DMD compatible)],[D2COMPILERBIN="$withval"], [D2COMPILERBIN=])
+
+
+# First, check for "--without-d" or "--with-d=no".
+if test x"${with_d}" = xno -o x"${with_alllang}" = xno ; then
+ AC_MSG_NOTICE([Disabling D])
+ D1COMPILER=
+ D2COMPILER=
+else
+ old_ac_ext=$ac_ext
+ ac_ext=d
+
+ if test -z "$D1COMPILERBIN" ; then
+ AC_CHECK_PROGS(D1COMPILER, dmd ldmd gdmd)
+
+ if test -n "$D1COMPILER" ; then
+ AC_MSG_CHECKING(whether the D1/Tango compiler works)
+ cat > conftest.$ac_ext <<_ACEOF
+import tango.io.Stdout;
+void main() {
+}
+_ACEOF
+ rm -f conftest.$ac_objext
+ AS_IF(
+ [_AC_DO_STDERR($D1COMPILER conftest.$ac_ext) && test ! -s conftest.err && test -s conftest.$ac_objext],
+ [AC_MSG_RESULT([yes])],
+ [_AC_MSG_LOG_CONFTEST AC_MSG_RESULT([no])
+ D1COMPILER=]
+ )
+ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+ else
+ D1COMPILER="$D1COMPILERBIN"
+ fi
+
+ if test -z "$D2COMPILERBIN" ; then
+ AC_CHECK_PROGS(D2COMPILER, dmd gdmd)
+
+ if test -n "$D2COMPILER" ; then
+ AC_MSG_CHECKING(whether the D2 compiler works)
+ cat > conftest.$ac_ext <<_ACEOF
+import std.algorithm;
+void main() {
+}
+_ACEOF
+ rm -f conftest.$ac_objext
+ AS_IF(
+ [_AC_DO_STDERR($D2COMPILER conftest.$ac_ext) && test ! -s conftest.err && test -s conftest.$ac_objext],
+ [AC_MSG_RESULT([yes])],
+ [_AC_MSG_LOG_CONFTEST AC_MSG_RESULT([no])
+ D2COMPILER=]
+ )
+ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+ else
+ D2COMPILER="$D2COMPILERBIN"
+ fi
+
+ ac_ext=$old_ac_ext
+fi
+
+if test -n "$D1COMPILER"; then
+ DDEFAULTVERSION=1
+elif test -n "$D2COMPILER"; then
+ DDEFAULTVERSION=2
+fi
+
+# Do not prefix library file names with "lib" on Windows.
+case $host in
+*-*-cygwin* | *-*-mingw*) DLIBPREFIX="";;
+*)DLIBPREFIX="lib";;
+esac
+
+AC_SUBST(D1COMPILER)
+AC_SUBST(D2COMPILER)
+AC_SUBST(DDEFAULTVERSION)
+AC_SUBST(DLIBPREFIX)
+
+#----------------------------------------------------------------
# Determine which languages to use for examples/test-suite
#----------------------------------------------------------------
@@ -2158,6 +2294,12 @@ if test -z "$GO" ; then
fi
AC_SUBST(SKIP_GO)
+SKIP_D=
+if test -z "$DDEFAULTVERSION" ; then
+ SKIP_D="1"
+fi
+AC_SUBST(SKIP_D)
+
#----------------------------------------------------------------
# Additional language dependencies
#----------------------------------------------------------------
@@ -2218,6 +2360,7 @@ AC_CONFIG_FILES([ \
Examples/xml/Makefile \
Examples/test-suite/chicken/Makefile \
Examples/test-suite/csharp/Makefile \
+ Examples/test-suite/d/Makefile \
Examples/test-suite/guile/Makefile \
Examples/test-suite/guilescm/Makefile \
Examples/test-suite/java/Makefile \