diff --git a/CHANGES.current b/CHANGES.current index a4fd78430..4b2931798 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,30 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 3.0.12 (in progress) ============================ +2017-01-15: wsfulton + [C# D Java] + The SWIG library no longer uses the javatype, dtype or cstype typemaps, thereby + completely freeing them up for users to use without having to replicate the library + code that they previously added. The code previously generated by these typemaps + has been replaced by the new %proxycode directive. Their use in the library code + was fairly minimal: + + C# cstype: std_array.i std_map.i std_vector.i + D dtype: std_vector.i + Java javatype: arrays_java.i + +2017-01-14: wsfulton + The %extend directive can now optionally support one of the 'class', 'struct' or 'union' + keywords before the identifier name, for example: + + struct X { ... }; + %extend struct X { ... } + + Previously this had to specified as: + + struct X { ... }; + %extend X { ... } + 2017-01-13: wsfulton [C# D Java] Add new %proxycode directive which is a macro for %insert("proxycode"). This is a way of adding pure C#/D/Java code into the appropriate proxy class, eg: diff --git a/Lib/csharp/std_array.i b/Lib/csharp/std_array.i index c1fee124d..61bb510de 100644 --- a/Lib/csharp/std_array.i +++ b/Lib/csharp/std_array.i @@ -17,7 +17,7 @@ %define SWIG_STD_ARRAY_INTERNAL(T, N) %typemap(csinterfaces) std::array< T, N > "global::System.IDisposable, global::System.Collections.IEnumerable\n , global::System.Collections.Generic.IEnumerable<$typemap(cstype, T)>\n"; -%typemap(cscode) std::array< T, N > %{ +%proxycode %{ public $csclassname(global::System.Collections.ICollection c) : this() { if (c == null) throw new global::System.ArgumentNullException("c"); diff --git a/Lib/csharp/std_map.i b/Lib/csharp/std_map.i index db6fa7bd1..90a865079 100644 --- a/Lib/csharp/std_map.i +++ b/Lib/csharp/std_map.i @@ -27,7 +27,7 @@ %define SWIG_STD_MAP_INTERNAL(K, T, C) %typemap(csinterfaces) std::map< K, T, C > "global::System.IDisposable \n , global::System.Collections.Generic.IDictionary<$typemap(cstype, K), $typemap(cstype, T)>\n"; -%typemap(cscode) std::map %{ +%proxycode %{ public $typemap(cstype, T) this[$typemap(cstype, K) key] { get { diff --git a/Lib/csharp/std_vector.i b/Lib/csharp/std_vector.i index fad729dff..12220aa57 100644 --- a/Lib/csharp/std_vector.i +++ b/Lib/csharp/std_vector.i @@ -25,7 +25,7 @@ // MACRO for use within the std::vector class body %define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CSINTERFACE, CONST_REFERENCE, CTYPE...) %typemap(csinterfaces) std::vector< CTYPE > "global::System.IDisposable, global::System.Collections.IEnumerable\n , global::System.Collections.Generic.CSINTERFACE<$typemap(cstype, CTYPE)>\n"; -%typemap(cscode) std::vector< CTYPE > %{ +%proxycode %{ public $csclassname(global::System.Collections.ICollection c) : this() { if (c == null) throw new global::System.ArgumentNullException("c"); diff --git a/Lib/d/std_vector.i b/Lib/d/std_vector.i index 50942f289..56f7188c7 100644 --- a/Lib/d/std_vector.i +++ b/Lib/d/std_vector.i @@ -24,7 +24,7 @@ %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 > %{ +%proxycode %{ public this($typemap(dtype, CTYPE)[] values) { this(); append(values); @@ -185,7 +185,7 @@ static import std.exception; static import std.range; static import std.traits; %} -%typemap(dcode) std::vector< CTYPE > %{ +%proxycode %{ alias size_t KeyType; alias $typemap(dtype, CTYPE) ValueType; diff --git a/Lib/java/arrays_java.i b/Lib/java/arrays_java.i index 402f088d5..dd38438a3 100644 --- a/Lib/java/arrays_java.i +++ b/Lib/java/arrays_java.i @@ -337,7 +337,8 @@ JAVA_ARRAYS_TYPEMAPS(double, double, jdouble, Double, "[D") /* double[ANY] * /* Add some code to the proxy class of the array type for converting between type used in * JNI class (long[]) and type used in proxy class ( ARRAYSOFCLASSES[] ) */ -%typemap(javacode) ARRAYSOFCLASSES %{ +%extend ARRAYSOFCLASSES { +%proxycode %{ protected static long[] cArrayUnwrap($javaclassname[] arrayWrapper) { long[] cArray = new long[arrayWrapper.length]; for (int i=0; i parm valparm rawvalparms valparms valptail ; %type

typemap_parm tm_list tm_tail ; %type

templateparameter ; -%type templcpptype cpptype access_specifier; +%type templcpptype cpptype classkey classkeyopt access_specifier; %type base_specifier; %type ellipsis variadic; %type type rawtype type_right anon_bitfield_type decltype ; @@ -1627,14 +1627,14 @@ swig_directive : extend_directive { $$ = $1; } %extend classname { ... } ------------------------------------------------------------ */ -extend_directive : EXTEND options idcolon LBRACE { +extend_directive : EXTEND options classkeyopt idcolon LBRACE { Node *cls; String *clsname; extendmode = 1; cplus_mode = CPLUS_PUBLIC; if (!classes) classes = NewHash(); if (!classes_typedefs) classes_typedefs = NewHash(); - clsname = make_class_name($3); + clsname = make_class_name($4); cls = Getattr(classes,clsname); if (!cls) { cls = Getattr(classes_typedefs, clsname); @@ -1643,7 +1643,7 @@ extend_directive : EXTEND options idcolon LBRACE { Node *am = Getattr(Swig_extend_hash(),clsname); if (!am) { Swig_symbol_newscope(); - Swig_symbol_setscopename($3); + Swig_symbol_setscopename($4); prev_symtab = 0; } else { prev_symtab = Swig_symbol_setscope(Getattr(am,"symtab")); @@ -1656,7 +1656,7 @@ extend_directive : EXTEND options idcolon LBRACE { prev_symtab = Swig_symbol_setscope(Getattr(cls, "symtab")); current_class = cls; SWIG_WARN_NODE_BEGIN(cls); - Swig_warning(WARN_PARSE_EXTEND_NAME, cparse_file, cparse_line, "Deprecated %%extend name used - the %s name '%s' should be used instead of the typedef name '%s'.\n", Getattr(cls, "kind"), SwigType_namestr(Getattr(cls, "name")), $3); + Swig_warning(WARN_PARSE_EXTEND_NAME, cparse_file, cparse_line, "Deprecated %%extend name used - the %s name '%s' should be used instead of the typedef name '%s'.\n", Getattr(cls, "kind"), SwigType_namestr(Getattr(cls, "name")), $4); SWIG_WARN_NODE_END(cls); } } else { @@ -1664,7 +1664,7 @@ extend_directive : EXTEND options idcolon LBRACE { prev_symtab = Swig_symbol_setscope(Getattr(cls,"symtab")); current_class = cls; } - Classprefix = NewString($3); + Classprefix = NewString($4); Namespaceprefix= Swig_symbol_qualifiedscopename(0); Delete(clsname); } cpp_members RBRACE { @@ -1676,22 +1676,22 @@ extend_directive : EXTEND options idcolon LBRACE { Swig_symbol_setscope(prev_symtab); } Namespaceprefix = Swig_symbol_qualifiedscopename(0); - clsname = make_class_name($3); + clsname = make_class_name($4); Setattr($$,"name",clsname); - mark_nodes_as_extend($6); + mark_nodes_as_extend($7); if (current_class) { /* We add the extension to the previously defined class */ - appendChild($$,$6); + appendChild($$, $7); appendChild(current_class,$$); } else { /* We store the extensions in the extensions hash */ Node *am = Getattr(Swig_extend_hash(),clsname); if (am) { /* Append the members to the previous extend methods */ - appendChild(am,$6); + appendChild(am, $7); } else { - appendChild($$,$6); + appendChild($$, $7); Setattr(Swig_extend_hash(),clsname,$$); } } @@ -6310,7 +6310,6 @@ access_specifier : PUBLIC { $$ = (char*)"public"; } | PROTECTED { $$ = (char*)"protected"; } ; - templcpptype : CLASS { $$ = (char*)"class"; if (!inherit_list) last_cpptype = $$; @@ -6342,6 +6341,28 @@ cpptype : templcpptype { } ; +classkey : CLASS { + $$ = (char*)"class"; + if (!inherit_list) last_cpptype = $$; + } + | STRUCT { + $$ = (char*)"struct"; + if (!inherit_list) last_cpptype = $$; + } + | UNION { + $$ = (char*)"union"; + if (!inherit_list) last_cpptype = $$; + } + ; + +classkeyopt : classkey { + $$ = $1; + } + | empty { + $$ = 0; + } + ; + opt_virtual : VIRTUAL | empty ;