[D] Replaced the term "wrap D module" with "intermediary D module" (including names derived from it).

This was suggested by wsfulton on the mailing list in order to bring the D module in line with the C# one, the naming scheme of which is intended to be language-independent.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12319 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
David Nadlinger 2010-11-28 23:12:03 +00:00
commit 3477a9dff1
19 changed files with 423 additions and 424 deletions

View file

@ -15,7 +15,7 @@
<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_cwtype_dwtype_dptype">cwtype, dwtype, dptype</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>
@ -64,18 +64,18 @@
<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>wrap</em> module (named like the proxy module, but suffixed with <tt>_wrap</tt>), which contains all the <tt>extern(C)</tt> function declarations and other private parts only used internally by the proxy module.</p>
<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 wrap D module are written to the root package. Using this option, you can specify another target package instead.</p>
<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>, just like the wrap D module is. 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>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>
@ -90,9 +90,9 @@
<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; cwtype
imtype &lt;-&gt; dwtype
cstype &lt;-&gt; dptype
ctype &lt;-&gt; ctype
imtype &lt;-&gt; imtype
cstype &lt;-&gt; dtype
csin &lt;-&gt; din
csout &lt;-&gt; dout
csdirectorin &lt;-&gt; ddirectorin
@ -110,12 +110,12 @@
</pre></div>
<H3><a name="D_cwtype_dwtype_dptype"></a>20.3.2 cwtype, dwtype, dptype</H3>
<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>cwtype</tt> typemap is used to determine the types to use in the C wrapper functions. The types from the <tt>dwtype</tt> typemap are used in the extern(C) declarations of these functions in the D wrap module. The <tt>dptype</tt> typemap contains the D types used in the D proxy module/class.</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>
@ -123,7 +123,7 @@
<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>cwtype</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>cwtype</tt>).</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>
@ -133,11 +133,11 @@
<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 D wrap module (the <a href="D.html#D_dinput"><tt>$dinput</tt></a> macro is replaced).</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).</p>
<p id="D_dout">The <tt>dout</tt> typemap is used for converting function return values from the return type used in the wrap 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_wcall"><tt>$wcall</tt> and <tt>$owner</tt></a> macros are replaced).</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_wcall"><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>$dpcall</tt> and <tt>$winput</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>
@ -145,13 +145,13 @@
↑ ↓
&lt;directorout&gt; &lt;directorin&gt;
↑ ↓
cwtype methodCallback(cwtype a) C++
ctype methodCallback(ctype a) C++
::::::::::::::::::::::::::::::::::::::::::
dwtype methodCallback(dwtype a) D
imtype methodCallback(imtype a) D
↑ ↓
&lt;ddirectorout&gt; &lt;ddirectorin&gt;
↑ ↓
dptype DClass.method(dptype a)</pre></div>
dtype DClass.method(dtype a)</pre></div>
<H3><a name="D_typecheck_typemaps"></a>20.3.5 typecheck typemaps</H3>
@ -202,16 +202,16 @@
<p>leads to the following D proxy code being generated:</p>
<div class="targetlang"><pre>
void foo(SomeClass arg) {
example_wrap.foo(SomeClass.getCPointer(arg));
example_im.foo(SomeClass.getCPointer(arg));
}</pre></div></dd>
<dt id="D_wcall"><tt>$wcall</tt> and <tt>$owner</tt> (C#: <tt>$imcall</tt>)</dt>
<dt id="D_wcall"><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>$wcall</tt> contains the call to the wrapper layer 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>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($wcall, $owner);
return new SomeClass($imcall, $owner);
}
%inline %{
@ -224,17 +224,17 @@ void foo(SomeClass arg) {
<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_wrap.foo(), false);
return new SomeClass(example_im.foo(), false);
}
SomeClass bar() {
return new SomeClass(example_wrap.bar(), true);
return new SomeClass(example_im.bar(), true);
}
</pre></div>
</dd>
<dt><tt>$dpcall</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>$wcall</tt> and <tt>$dinput</tt> macros: <tt>$dpcall</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>$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>
@ -248,7 +248,7 @@ SomeClass bar() {
<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($wcall, true);$excode$directorconnect
this($imcall, true);$excode$directorconnect
}
</pre></div>
</dd>
@ -280,8 +280,8 @@ $importtype(AnotherInterface)
<dt><tt>$module</tt></dt>
<dd><p>Expands to the name of the main proxy D module.</p></dd>
<dt><tt>$wrapdmodule</tt></dt>
<dd><p>Contains the fully qualified name of the wrap D module.</p></dd>
<dt><tt>$imdmodule</tt></dt>
<dd><p>Contains the fully qualified name of the intermediary D module.</p></dd>
</dl>
@ -295,7 +295,7 @@ $importtype(AnotherInterface)
<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 wrapper using the <tt>%dconstvalue</tt> directive, passing the new value as parameter.</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>
@ -321,11 +321,11 @@ struct A {
<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) wrapdmodulecode</tt></dt>
<dd><p>The passed text (D code) is copied verbatim to the wrap 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) 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) wrapdmoduleimports</tt></dt>
<dd><p>Additional code to be emitted to the imports section of the wrap 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>wrapdmodulecode</tt> pragma.</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>
@ -342,13 +342,13 @@ struct A {
<dt><tt>%pragma(d) wrapperloadercode</tt></dt>
<dd>
<p>The D code for loading the wrapper library (it is copied to the wrap 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 wrap D module.</p>
<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 wrap 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>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>
@ -384,11 +384,11 @@ struct A {
<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>dptype</tt> typemap and the <tt>nativepointer</tt> attribute on all the typemaps which influence the D side of the code (<tt>dptype</tt>, <tt>din</tt>, <tt>dout</tt>, …). When a D typemap is looked up, the following happens behind the scenes:</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>dptype</tt> attribute is used. For example, the <tt>dptype</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>
<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_test_suite"></a>20.8.2 Running the test-suite</H3>

View file

@ -39,7 +39,7 @@ public:
#if defined(SWIGD)
%typemap(dout, excode=SWIGEXCODE) Foo * {
Bar ret = new Bar($wcall, $owner);$excode
Bar ret = new Bar($imcall, $owner);$excode
return ret;
}
#endif

View file

@ -169,13 +169,13 @@ namespace Space {
#if (SWIG_D_VERSION == 1)
%typemap(dcode) Space::RenameMe %{
public static NewName factory(char[] s) {
return new $typemap(dptype, Space::RenameMe)( new $typemap(dptype, Name)(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(dptype, Space::RenameMe)( new $typemap(dptype, Name)(s) );
return new $typemap(dtype, Space::RenameMe)( new $typemap(dtype, Name)(s) );
}
%}
#endif

View file

@ -30,9 +30,9 @@ namespace Foo {
%typemap(gotype) Str1 * = char *;
#endif
#ifdef SWIGD
%typemap(cwtype) Str1 * = char *;
%typemap(dwtype) Str1 * = char *;
%typemap(dptype) Str1 * = char *;
%typemap(ctype) Str1 * = char *;
%typemap(imtype) Str1 * = char *;
%typemap(dtype) Str1 * = char *;
%typemap(din) Str1 * = char *;
%typemap(dout) Str1 * = char *;
#endif

View file

@ -82,62 +82,62 @@
%}
%typemap (cwtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
%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 (dwtype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
%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 (dptype) SWIG_SHARED_PTR_QNAMESPACE::shared_ptr< CONST TYPE >,
%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(dptype, 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(dptype, TYPE).swigGetCPtr($dinput)"
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 = $wcall;
auto ret = (cPtr is null) ? null : new $typemap(dptype, TYPE)(cPtr, true);$excode
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 = $wcall;
auto ret = (cPtr is null) ? null : new $typemap(dptype, TYPE)(cPtr, true);$excode
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 = $wcall;
auto ret = (cPtr is null) ? null : new $typemap(dptype, TYPE)(cPtr, true);$excode
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 = $wcall;
auto ret = (cPtr is null) ? null : new $typemap(dptype, TYPE)(cPtr, true);$excode
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(dptype, TYPE)($wcall, true);$excode
auto ret = new $typemap(dtype, TYPE)($imcall, true);$excode
return ret;
}
%typemap(dout, excode=SWIGEXCODE) CONST TYPE & {
auto ret = new $typemap(dptype, TYPE)($wcall, true);$excode
auto ret = new $typemap(dtype, TYPE)($imcall, true);$excode
return ret;
}
%typemap(dout, excode=SWIGEXCODE) CONST TYPE * {
void* cPtr = $wcall;
auto ret = (cPtr is null) ? null : new $typemap(dptype, TYPE)(cPtr, true);$excode
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 = $wcall;
auto ret = (cPtr is null) ? null : new $typemap(dptype, TYPE)(cPtr, true);$excode
void* cPtr = $imcall;
auto ret = (cPtr is null) ? null : new $typemap(dtype, TYPE)(cPtr, true);$excode
return ret;
}
@ -162,7 +162,7 @@ private void* swigCPtr;
private bool swigCMemOwn;
public this(void* cObject, bool ownCObject) {
super($wrapdmodule.$dclassnameSmartPtrUpcast(cObject), ownCObject);
super($imdmodule.$dclassnameSmartPtrUpcast(cObject), ownCObject);
swigCPtr = cObject;
swigCMemOwn = ownCObject;
}
@ -177,7 +177,7 @@ public static void* swigGetCPtr($dclassname obj) {
if (swigCPtr !is null) {
if (swigCMemOwn) {
swigCMemOwn = false;
$wcall;
$imcall;
}
swigCPtr = null;
}
@ -189,7 +189,7 @@ public static void* swigGetCPtr($dclassname obj) {
if (swigCPtr !is null) {
if (swigCMemOwn) {
swigCMemOwn = false;
$wcall;
$imcall;
}
swigCPtr = null;
super.dispose();

View file

@ -21,7 +21,7 @@
*/
%typemap(dconstructor, excode=SWIGEXCODE,directorconnect="\n swigDirectorConnect();") SWIGTYPE {
this($wcall, true);$excode$directorconnect
this($imcall, true);$excode$directorconnect
}
%typemap(ddestructor) SWIGTYPE %{
@ -38,7 +38,7 @@
if (swigCPtr !is null) {
if (swigCMemOwn) {
swigCMemOwn = false;
$wcall;
$imcall;
}
swigCPtr = null;
}
@ -50,7 +50,7 @@
if (swigCPtr !is null) {
if (swigCMemOwn) {
swigCMemOwn = false;
$wcall;
$imcall;
}
swigCPtr = null;
super.dispose();
@ -88,7 +88,7 @@ public static void* swigGetCPtr($dclassname obj) {
private void* swigCPtr;
public this(void* cObject, bool ownCObject) {
super($wrapdmodule.$dclassnameUpcast(cObject), ownCObject);
super($imdmodule.$dclassnameUpcast(cObject), ownCObject);
swigCPtr = cObject;
}

View file

@ -9,9 +9,9 @@
* Typemaps for enumeration types.
*/
%typemap(cwtype) enum SWIGTYPE "int"
%typemap(dwtype) enum SWIGTYPE "int"
%typemap(dptype, cprimitive="1") enum SWIGTYPE "$dclassname"
%typemap(ctype) enum SWIGTYPE "int"
%typemap(imtype) enum SWIGTYPE "int"
%typemap(dtype, cprimitive="1") enum SWIGTYPE "$dclassname"
%typecheck(SWIG_TYPECHECK_POINTER) enum SWIGTYPE ""
@ -21,11 +21,11 @@
%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)$dpcall"
%typemap(ddirectorout) enum SWIGTYPE "cast(int)$dcall"
%typemap(din) enum SWIGTYPE "cast(int)$dinput"
%typemap(dout, excode=SWIGEXCODE) enum SWIGTYPE {
$dclassname ret = cast($dclassname)$wcall;$excode
$dclassname ret = cast($dclassname)$imcall;$excode
return ret;
}
@ -34,9 +34,9 @@
* Typemaps for (const) references to enumeration types.
*/
%typemap(cwtype) const enum SWIGTYPE & "int"
%typemap(dwtype) const enum SWIGTYPE & "int"
%typemap(dptype) const enum SWIGTYPE & "$*dclassname"
%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 & ""
@ -51,10 +51,10 @@
$result = &temp; %}
%typemap(ddirectorin) const enum SWIGTYPE & "cast($*dclassname)$winput"
%typemap(ddirectorout) const enum SWIGTYPE & "cast(int)$dpcall"
%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)$wcall;$excode
$*dclassname ret = cast($*dclassname)$imcall;$excode
return ret;
}

View file

@ -6,7 +6,7 @@
// Code which is inserted into the dout typemaps and class constructors via
// excode if exceptions can be thrown.
%define SWIGEXCODE "\n if ($wrapdmodule.SwigPendingException.isPending) throw $wrapdmodule.SwigPendingException.retrieve();" %enddef
%define SWIGEXCODE "\n if ($imdmodule.SwigPendingException.isPending) throw $imdmodule.SwigPendingException.retrieve();" %enddef
%typemap(throws, canthrow=1) int,
long,

View file

@ -64,7 +64,7 @@ SWIGEXPORT void SWIGRegisterExceptionCallbacks_$module(
%}
#if (SWIG_D_VERSION == 1)
%pragma(d) wrapdmoduleimports=%{
%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;
@ -72,7 +72,7 @@ static import tango.core.Thread;
static import tango.stdc.stringz;
%}
%pragma(d) wrapdmodulecode=%{
%pragma(d) imdmodulecode=%{
private class SwigExceptionHelper {
static this() {
swigRegisterExceptionCallbacks(
@ -169,11 +169,11 @@ private:
alias void function(char* message) SwigExceptionCallback;
%}
#else
%pragma(d) wrapdmoduleimports=%{
%pragma(d) imdmoduleimports=%{
static import std.conv;
%}
%pragma(d) wrapdmodulecode=%{
%pragma(d) imdmodulecode=%{
private class SwigExceptionHelper {
static this() {
// The D1/Tango version maps C++ exceptions to multiple exception types.
@ -265,9 +265,9 @@ SWIGEXPORT void SWIGRegisterStringCallback_$module(SWIG_DStringHelperCallback ca
%}
#if (SWIG_D_VERSION == 1)
%pragma(d) wrapdmoduleimports = "static import tango.stdc.stringz;";
%pragma(d) imdmoduleimports = "static import tango.stdc.stringz;";
%pragma(d) wrapdmodulecode = %{
%pragma(d) imdmodulecode = %{
private class SwigStringHelper {
static this() {
swigRegisterStringCallback(&createString);
@ -281,12 +281,12 @@ private class SwigStringHelper {
alias char* function(char* cString) SwigStringCallback;
%}
#else
%pragma(d) wrapdmoduleimports = %{
%pragma(d) imdmoduleimports = %{
static import std.conv;
static import std.string;
%}
%pragma(d) wrapdmodulecode = %{
%pragma(d) imdmodulecode = %{
private class SwigStringHelper {
static this() {
swigRegisterStringCallback(&createString);

View file

@ -5,9 +5,9 @@
* ----------------------------------------------------------------------------- */
%typemap(cwtype) SWIGTYPE (CLASS::*) "char *"
%typemap(dwtype) SWIGTYPE (CLASS::*) "char*"
%typemap(dptype) SWIGTYPE (CLASS::*) "$dclassname"
%typemap(ctype) SWIGTYPE (CLASS::*) "char *"
%typemap(imtype) SWIGTYPE (CLASS::*) "char*"
%typemap(dtype) SWIGTYPE (CLASS::*) "$dclassname"
%typecheck(SWIG_TYPECHECK_POINTER)
SWIGTYPE (CLASS::*)
@ -34,11 +34,11 @@
%typemap(ddirectorin) SWIGTYPE (CLASS::*)
"($winput is null) ? null : new $dclassname($winput, false)"
%typemap(ddirectorout) SWIGTYPE (CLASS::*) "$dclassname.swigGetCPtr($dpcall)"
%typemap(ddirectorout) SWIGTYPE (CLASS::*) "$dclassname.swigGetCPtr($dcall)"
%typemap(din) SWIGTYPE (CLASS::*) "$dclassname.swigGetCMemberPtr($dinput)"
%typemap(dout, excode=SWIGEXCODE) SWIGTYPE (CLASS::*) {
char* cMemberPtr = $wcall;
char* cMemberPtr = $imcall;
$dclassname ret = (cMemberPtr is null) ? null : new $dclassname(cMemberPtr, $owner);$excode
return ret;
}

View file

@ -10,16 +10,16 @@
* cases are handeled below.
*/
%define SWIG_D_PRIMITIVE(TYPE, DTYPE)
%typemap(cwtype) TYPE, const TYPE & "TYPE"
%typemap(dwtype) TYPE, const TYPE & "DTYPE"
%typemap(dptype, cprimitive="1") TYPE, const 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 "$dpcall"
%typemap(ddirectorout) TYPE "$dcall"
%typemap(in) const TYPE & ($*1_ltype temp)
%{ temp = ($*1_ltype)$input;
@ -31,11 +31,11 @@
temp = ($*1_ltype)$input;
$result = &temp; %}
%typemap(ddirectorin) const TYPE & "$winput"
%typemap(ddirectorout) const TYPE & "$dpcall"
%typemap(ddirectorout) const TYPE & "$dcall"
%typemap(din) TYPE, const TYPE & "$dinput"
%typemap(dout, excode=SWIGEXCODE) TYPE, const TYPE & {
auto ret = $wcall;$excode
auto ret = $imcall;$excode
return ret;
}
%enddef
@ -60,8 +60,8 @@ 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(cwtype) bool, const bool & "unsigned int"
%typemap(dwtype) bool, const bool & "uint"
%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)
@ -78,7 +78,7 @@ SWIG_D_PRIMITIVE(double, double)
%typemap(ddirectorin) bool "($winput ? true : false)"
%typemap(dout, excode=SWIGEXCODE) bool, const bool & {
bool ret = $wcall ? true : false;$excode
bool ret = $imcall ? true : false;$excode
return ret;
}

View file

@ -5,9 +5,9 @@
* ----------------------------------------------------------------------------- */
%define SWIGD_STRING_TYPEMAPS(DW_STRING_TYPE, DP_STRING_TYPE, FROM_STRINGZ, TO_STRINGZ)
%typemap(cwtype) char *, char *&, char[ANY], char[] "char *"
%typemap(dwtype) char *, char *&, char[ANY], char[] #DW_STRING_TYPE
%typemap(dptype) char *, char *&, char[ANY], char[] #DP_STRING_TYPE
%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
/*
@ -19,7 +19,7 @@
%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($dpcall)"
%typemap(ddirectorout) char * "TO_STRINGZ($dcall)"
/*
@ -44,12 +44,12 @@
%typemap(directorin) char[ANY], char[] %{ $input = SWIG_d_string_callback((const char *)$1); %}
%typemap(ddirectorin) char[ANY], char[] "$winput"
%typemap(ddirectorout) char[ANY], char[] "$dpcall"
%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 ## ($wcall);$excode
DP_STRING_TYPE ret = FROM_STRINGZ ## ($imcall);$excode
return ret;
}

View file

@ -4,25 +4,25 @@
* Typemaps for non-primitive types (C/C++ classes and structs).
* ----------------------------------------------------------------------------- */
%typemap(cwtype) SWIGTYPE "void *"
%typemap(dwtype) SWIGTYPE "void*"
%typemap(dptype) SWIGTYPE "$&dclassname"
%typemap(ctype) SWIGTYPE "void *"
%typemap(imtype) SWIGTYPE "void*"
%typemap(dtype) SWIGTYPE "$&dclassname"
%typemap(cwtype) SWIGTYPE [] "void *"
%typemap(dwtype) SWIGTYPE [] "void*"
%typemap(dptype) SWIGTYPE [] "$dclassname"
%typemap(ctype) SWIGTYPE [] "void *"
%typemap(imtype) SWIGTYPE [] "void*"
%typemap(dtype) SWIGTYPE [] "$dclassname"
%typemap(cwtype) SWIGTYPE * "void *"
%typemap(dwtype) SWIGTYPE * "void*"
%typemap(dptype, nativepointer="$dptype") SWIGTYPE * "$dclassname"
%typemap(ctype) SWIGTYPE * "void *"
%typemap(imtype) SWIGTYPE * "void*"
%typemap(dtype, nativepointer="$dtype") SWIGTYPE * "$dclassname"
%typemap(cwtype) SWIGTYPE & "void *"
%typemap(dwtype) SWIGTYPE & "void*"
%typemap(dptype) SWIGTYPE & "$dclassname"
%typemap(ctype) SWIGTYPE & "void *"
%typemap(imtype) SWIGTYPE & "void*"
%typemap(dtype) SWIGTYPE & "$dclassname"
%typemap(cwtype) SWIGTYPE *const& "void *"
%typemap(dwtype) SWIGTYPE *const& "void*"
%typemap(dptype) SWIGTYPE *const& "$*dclassname"
%typemap(ctype) SWIGTYPE *const& "void *"
%typemap(imtype) SWIGTYPE *const& "void*"
%typemap(dtype) SWIGTYPE *const& "$*dclassname"
%typecheck(SWIG_TYPECHECK_POINTER)
SWIGTYPE,
@ -66,11 +66,11 @@
$result = *($&1_ltype)$input; %}
%typemap(ddirectorin) SWIGTYPE "new $&dclassname($winput, false)"
%typemap(ddirectorout) SWIGTYPE "$&dclassname.swigGetCPtr($dpcall)"
%typemap(ddirectorout) SWIGTYPE "$&dclassname.swigGetCPtr($dcall)"
%typemap(din) SWIGTYPE "$&dclassname.swigGetCPtr($dinput)"
%typemap(dout, excode=SWIGEXCODE) SWIGTYPE {
$&dclassname ret = new $&dclassname($wcall, true);$excode
$&dclassname ret = new $&dclassname($imcall, true);$excode
return ret;
}
@ -88,21 +88,21 @@
"$result = ($1_ltype)$input;"
%typemap(ddirectorin,
nativepointer="cast($dptype)$winput"
nativepointer="cast($dtype)$winput"
) SWIGTYPE * "($winput is null) ? null : new $dclassname($winput, false)"
%typemap(ddirectorout,
nativepointer="cast(void*)$dpcall"
) SWIGTYPE * "$dclassname.swigGetCPtr($dpcall)"
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($dptype)$wcall;$excode\n return ret;\n}"
nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}"
) SWIGTYPE * {
void* cPtr = $wcall;
void* cPtr = $imcall;
$dclassname ret = (cPtr is null) ? null : new $dclassname(cPtr, $owner);$excode
return ret;
}
@ -132,11 +132,11 @@
$result = ($1_ltype)$input; %}
%typemap(ddirectorin) SWIGTYPE & "new $dclassname($winput, false)"
%typemap(ddirectorout) SWIGTYPE & "$dclassname.swigGetCPtr($dpcall)"
%typemap(ddirectorout) SWIGTYPE & "$dclassname.swigGetCPtr($dcall)"
%typemap(din) SWIGTYPE & "$dclassname.swigGetCPtr($dinput)"
%typemap(dout, excode=SWIGEXCODE) SWIGTYPE & {
$dclassname ret = new $dclassname($wcall, $owner);$excode
$dclassname ret = new $dclassname($imcall, $owner);$excode
return ret;
}
@ -150,7 +150,7 @@
%typemap(din) SWIGTYPE [] "$dclassname.swigGetCPtr($dinput)"
%typemap(dout, excode=SWIGEXCODE) SWIGTYPE [] {
void* cPtr = $wcall;
void* cPtr = $imcall;
$dclassname ret = (cPtr is null) ? null : new $dclassname(cPtr, $owner);$excode
return ret;
}
@ -171,7 +171,7 @@
%typemap(din) SWIGTYPE *const& "$*dclassname.swigGetCPtr($dinput)"
%typemap(dout, excode=SWIGEXCODE) SWIGTYPE *const& {
void* cPtr = $wcall;
void* cPtr = $imcall;
$*dclassname ret = (cPtr is null) ? null : new $*dclassname(cPtr, $owner);$excode
return ret;
}

View file

@ -4,15 +4,15 @@
* Typemaps for handling void function return types and empty parameter lists.
* ----------------------------------------------------------------------------- */
%typemap(cwtype) void "void"
%typemap(dwtype) void "void"
%typemap(dptype, cprimitive="1") void "void"
%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 "$dpcall"
%typemap(ddirectorout) void "$dcall"
%typemap(directorin) void ""
%typemap(dout, excode=SWIGEXCODE) void {
$wcall;$excode
$imcall;$excode
}

View file

@ -21,9 +21,9 @@ class string;
%define SWIGD_STD_STRING_TYPEMAPS(DW_STRING_TYPE, DP_STRING_TYPE, FROM_STRINGZ, TO_STRINGZ)
// string
%typemap(cwtype) string, const string & "char *"
%typemap(dwtype) string, const string & #DW_STRING_TYPE
%typemap(dptype) string, const string & #DP_STRING_TYPE
%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) {
@ -44,7 +44,7 @@ class string;
%typemap(din) string, const string & "($dinput ? TO_STRINGZ($dinput) : null)"
%typemap(dout, excode=SWIGEXCODE) string, const string & {
DP_STRING_TYPE ret = FROM_STRINGZ($wcall);$excode
DP_STRING_TYPE ret = FROM_STRINGZ($imcall);$excode
return ret;
}
@ -68,7 +68,7 @@ class string;
$result = &$1_str; %}
%typemap(ddirectorin) string, const string & "FROM_STRINGZ($winput)"
%typemap(ddirectorout) string, const string & "TO_STRINGZ($dpcall)"
%typemap(ddirectorout) string, const string & "TO_STRINGZ($dcall)"
%typemap(throws, canthrow=1) string, const string &
%{ SWIG_DSetPendingException(SWIG_DException, $1.c_str());

View file

@ -21,11 +21,11 @@
%include <std_common.i>
// MACRO for use within the std::vector class body
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CONST_REFERENCE, CWTYPE...)
%define SWIG_STD_VECTOR_MINIMUM_INTERNAL(CONST_REFERENCE, CTYPE...)
#if (SWIG_D_VERSION == 1)
%typemap(dimports) std::vector< CWTYPE > "static import tango.core.Exception;"
%typemap(dcode) std::vector< CWTYPE > %{
public this($typemap(dptype, CWTYPE)[] values) {
%typemap(dimports) std::vector< CTYPE > "static import tango.core.Exception;"
%typemap(dcode) std::vector< CTYPE > %{
public this($typemap(dtype, CTYPE)[] values) {
this();
append(values);
}
@ -36,7 +36,7 @@ alias push_back opCatAssign;
alias size length;
alias opSlice slice;
public $typemap(dptype, CWTYPE) opIndexAssign($typemap(dptype, CWTYPE) value, size_t index) {
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.");
}
@ -44,28 +44,28 @@ public $typemap(dptype, CWTYPE) opIndexAssign($typemap(dptype, CWTYPE) value, si
return value;
}
public $typemap(dptype, CWTYPE) opIndex(size_t index) {
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(dptype, CWTYPE)[] value...) {
public void append($typemap(dtype, CTYPE)[] value...) {
foreach (v; value) {
add(v);
}
}
public $typemap(dptype, CWTYPE)[] opSlice() {
$typemap(dptype, CWTYPE)[] array = new $typemap(dptype, CWTYPE)[size()];
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(dptype, CWTYPE) value) dg) {
public int opApply(int delegate(ref $typemap(dtype, CTYPE) value) dg) {
int result;
size_t currentSize = size();
@ -77,7 +77,7 @@ public int opApply(int delegate(ref $typemap(dptype, CWTYPE) value) dg) {
return result;
}
public int opApply(int delegate(ref size_t index, ref $typemap(dptype, CWTYPE) value) dg) {
public int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) {
int result;
size_t currentSize = size();
@ -104,10 +104,10 @@ public void capacity(size_t value) {
public:
typedef size_t size_type;
typedef CWTYPE value_type;
typedef CTYPE value_type;
typedef CONST_REFERENCE const_reference;
void clear();
void push_back(CWTYPE const& x);
void push_back(CTYPE const& x);
size_type size() const;
size_type capacity() const;
void reserve(size_type n) throw (std::length_error);
@ -115,8 +115,8 @@ public void capacity(size_t value) {
vector(const vector &other);
%extend {
vector(size_type capacity) throw (std::length_error) {
std::vector< CWTYPE >* pv = 0;
pv = new std::vector< CWTYPE >();
std::vector< CTYPE >* pv = 0;
pv = new std::vector< CTYPE >();
// Might throw std::length_error.
pv->reserve(capacity);
@ -133,7 +133,7 @@ public void capacity(size_t value) {
throw std::out_of_range("Tried to remove last element from empty vector.");
}
std::vector< CWTYPE >::const_reference value = $self->back();
std::vector< CTYPE >::const_reference value = $self->back();
$self->pop_back();
return value;
}
@ -143,8 +143,8 @@ public void capacity(size_t value) {
throw std::out_of_range("Tried to remove element with invalid index.");
}
std::vector< CWTYPE >::iterator it = $self->begin() + index;
std::vector< CWTYPE >::const_reference value = *it;
std::vector< CTYPE >::iterator it = $self->begin() + index;
std::vector< CTYPE >::const_reference value = *it;
$self->erase(it);
return value;
}
@ -161,11 +161,11 @@ public void capacity(size_t value) {
}
}
// Use CWTYPE const& instead of const_reference to work around SWIG code
// 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, CWTYPE const& val) throw (std::out_of_range) {
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.");
}
@ -179,15 +179,15 @@ public void capacity(size_t value) {
#else
%typemap(dimports) std::vector< CWTYPE > %{
%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< CWTYPE > %{
%typemap(dcode) std::vector< CTYPE > %{
alias size_t KeyType;
alias $typemap(dptype, CWTYPE) ValueType;
alias $typemap(dtype, CTYPE) ValueType;
this(ValueType[] values...) {
this();
@ -198,17 +198,17 @@ this(ValueType[] values...) {
}
struct Range {
private $typemap(dptype, std::vector< CWTYPE >) _outer;
private $typemap(dtype, std::vector< CTYPE >) _outer;
private size_t _a, _b;
this($typemap(dptype, std::vector< CWTYPE >) data, size_t a, size_t 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(dptype, std::vector< CWTYPE >))_outer).length >= _b);
assert((cast($typemap(dtype, std::vector< CTYPE >))_outer).length >= _b);
return _a >= _b;
}
@ -411,7 +411,7 @@ Range linearRemove(Range r) {
}
alias remove stableLinearRemove;
int opApply(int delegate(ref $typemap(dptype, CWTYPE) value) dg) {
int opApply(int delegate(ref $typemap(dtype, CTYPE) value) dg) {
int result;
size_t currentSize = size();
@ -423,7 +423,7 @@ int opApply(int delegate(ref $typemap(dptype, CWTYPE) value) dg) {
return result;
}
int opApply(int delegate(ref size_t index, ref $typemap(dptype, CWTYPE) value) dg) {
int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg) {
int result;
size_t currentSize = size();
@ -442,11 +442,11 @@ int opApply(int delegate(ref size_t index, ref $typemap(dptype, CWTYPE) value) d
public:
typedef size_t size_type;
typedef CWTYPE value_type;
typedef CTYPE value_type;
typedef CONST_REFERENCE const_reference;
bool empty() const;
void clear();
void push_back(CWTYPE const& x);
void push_back(CTYPE const& x);
void pop_back();
size_type size() const;
size_type capacity() const;
@ -455,8 +455,8 @@ int opApply(int delegate(ref size_t index, ref $typemap(dptype, CWTYPE) value) d
vector(const vector &other);
%extend {
vector(size_type capacity) throw (std::length_error) {
std::vector< CWTYPE >* pv = 0;
pv = new std::vector< CWTYPE >();
std::vector< CTYPE >* pv = 0;
pv = new std::vector< CTYPE >();
// Might throw std::length_error.
pv->reserve(capacity);
@ -469,7 +469,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dptype, CWTYPE) value) d
throw std::out_of_range("Tried to remove last element from empty vector.");
}
std::vector< CWTYPE >::const_reference value = $self->back();
std::vector< CTYPE >::const_reference value = $self->back();
$self->pop_back();
return value;
}
@ -479,26 +479,26 @@ int opApply(int delegate(ref size_t index, ref $typemap(dptype, CWTYPE) value) d
throw std::out_of_range("Tried to remove element with invalid index.");
}
std::vector< CWTYPE >::iterator it = $self->begin() + index;
std::vector< CWTYPE >::const_reference value = *it;
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< CWTYPE >::iterator end = $self->end();
std::vector< CWTYPE >::iterator start = end - how_many;
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< CWTYPE >::iterator start = $self->begin() + start_index;
std::vector< CWTYPE >::iterator end = $self->begin() + end_index;
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, CWTYPE const& x) throw (std::out_of_range) {
std::vector< CWTYPE >::iterator it = $self->begin() + index;
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);
}
}
@ -513,11 +513,11 @@ int opApply(int delegate(ref size_t index, ref $typemap(dptype, CWTYPE) value) d
return (*$self)[index];
}
}
// Use CWTYPE const& instead of const_reference to work around SWIG code
// 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, CWTYPE const& val) throw (std::out_of_range) {
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.");
}
@ -532,7 +532,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dptype, CWTYPE) value) d
// 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(CWTYPE...)
%define SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE...)
%extend {
}
%enddef
@ -541,11 +541,11 @@ int opApply(int delegate(ref size_t index, ref $typemap(dptype, CWTYPE) value) d
#define %arg(X...) X
// Macros for std::vector class specializations/enhancements
%define SWIG_STD_VECTOR_ENHANCED(CWTYPE...)
%define SWIG_STD_VECTOR_ENHANCED(CTYPE...)
namespace std {
template<> class vector<CWTYPE > {
SWIG_STD_VECTOR_MINIMUM_INTERNAL(%arg(CWTYPE const&), %arg(CWTYPE))
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CWTYPE)
template<> class vector<CTYPE > {
SWIG_STD_VECTOR_MINIMUM_INTERNAL(%arg(CTYPE const&), %arg(CTYPE))
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE)
};
}
%enddef

View file

@ -53,13 +53,13 @@ In D you could then use it like this:
double answer = fadd(10.0, 20.0);
*/
%define INPUT_TYPEMAP(TYPE, CWTYPE, DTYPE)
%typemap(cwtype) TYPE *INPUT, TYPE &INPUT "CWTYPE"
%typemap(dwtype) TYPE *INPUT, TYPE &INPUT "DTYPE"
%typemap(dptype) TYPE *INPUT, TYPE &INPUT "DTYPE"
%define INPUT_TYPEMAP(TYPE, CTYPE, DTYPE)
%typemap(ctype) TYPE *INPUT, TYPE &INPUT "CTYPE"
%typemap(imtype) TYPE *INPUT, TYPE &INPUT "DTYPE"
%typemap(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 "$dpcall"
%typemap(ddirectorout) TYPE *INPUT, TYPE &INPUT "$dcall"
%typemap(in) TYPE *INPUT, TYPE &INPUT
%{ $1 = ($1_ltype)&$input; %}
@ -68,10 +68,10 @@ In D you could then use it like this:
%{ $result = ($1_ltype)&$input; %}
%typemap(directorin) TYPE &INPUT
%{ $input = (CWTYPE *)$1; %}
%{ $input = (CTYPE *)$1; %}
%typemap(directorin) TYPE *INPUT
%{ $input = (CWTYPE *)$1; %}
%{ $input = (CTYPE *)$1; %}
%typemap(typecheck) TYPE *INPUT = TYPE;
%typemap(typecheck) TYPE &INPUT = TYPE;
@ -93,7 +93,7 @@ INPUT_TYPEMAP(float, float, float)
INPUT_TYPEMAP(double, double, double)
INPUT_TYPEMAP(enum SWIGTYPE, unsigned int, int)
%typemap(dptype) enum SWIGTYPE *INPUT, enum SWIGTYPE &INPUT "$*dclassname"
%typemap(dtype) enum SWIGTYPE *INPUT, enum SWIGTYPE &INPUT "$*dclassname"
#undef INPUT_TYPEMAP
@ -148,13 +148,13 @@ value returned in the second output parameter. In D you would use it like this:
double fraction = modf(5, dptr);
*/
%define OUTPUT_TYPEMAP(TYPE, CWTYPE, DTYPE, TYPECHECKPRECEDENCE)
%typemap(cwtype) TYPE *OUTPUT, TYPE &OUTPUT "CWTYPE *"
%typemap(dwtype) TYPE *OUTPUT, TYPE &OUTPUT "out DTYPE"
%typemap(dptype) TYPE *OUTPUT, TYPE &OUTPUT "out DTYPE"
%define OUTPUT_TYPEMAP(TYPE, CTYPE, DTYPE, TYPECHECKPRECEDENCE)
%typemap(ctype) TYPE *OUTPUT, TYPE &OUTPUT "CTYPE *"
%typemap(imtype) TYPE *OUTPUT, TYPE &OUTPUT "out DTYPE"
%typemap(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 "$dpcall"
%typemap(ddirectorout) TYPE *OUTPUT, TYPE &OUTPUT "$dcall"
%typemap(in) TYPE *OUTPUT, TYPE &OUTPUT
@ -190,7 +190,7 @@ OUTPUT_TYPEMAP(float, float, float, FLOAT_PTR)
OUTPUT_TYPEMAP(double, double, double, DOUBLE_PTR)
OUTPUT_TYPEMAP(enum SWIGTYPE, unsigned int, int, INT32_PTR)
%typemap(dptype) enum SWIGTYPE *OUTPUT, enum SWIGTYPE &OUTPUT "out $*dclassname"
%typemap(dtype) enum SWIGTYPE *OUTPUT, enum SWIGTYPE &OUTPUT "out $*dclassname"
#undef OUTPUT_TYPEMAP
@ -253,13 +253,13 @@ languages in that the scripting languages will return the output value as part
of the function return value.
*/
%define INOUT_TYPEMAP(TYPE, CWTYPE, DTYPE, TYPECHECKPRECEDENCE)
%typemap(cwtype) TYPE *INOUT, TYPE &INOUT "CWTYPE *"
%typemap(dwtype) TYPE *INOUT, TYPE &INOUT "ref DTYPE"
%typemap(dptype) TYPE *INOUT, TYPE &INOUT "ref DTYPE"
%define INOUT_TYPEMAP(TYPE, CTYPE, DTYPE, TYPECHECKPRECEDENCE)
%typemap(ctype) TYPE *INOUT, TYPE &INOUT "CTYPE *"
%typemap(imtype) TYPE *INOUT, TYPE &INOUT "ref DTYPE"
%typemap(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 "$dpcall"
%typemap(ddirectorout) TYPE *INOUT, TYPE &INOUT "$dcall"
%typemap(in) TYPE *INOUT, TYPE &INOUT
%{ $1 = ($1_ltype)$input; %}
@ -293,6 +293,6 @@ INOUT_TYPEMAP(float, float, float, FLOAT_PTR)
INOUT_TYPEMAP(double, double, double, DOUBLE_PTR)
INOUT_TYPEMAP(enum SWIGTYPE, unsigned int, int, INT32_PTR)
%typemap(dptype) enum SWIGTYPE *INOUT, enum SWIGTYPE &INOUT "ref $*dclassname"
%typemap(dtype) enum SWIGTYPE *INOUT, enum SWIGTYPE &INOUT "ref $*dclassname"
#undef INOUT_TYPEMAP

View file

@ -201,9 +201,9 @@
/* 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_CWTYPE_UNDEF 700
#define WARN_D_TYPEMAP_DWTYPE_UNDEF 701
#define WARN_D_TYPEMAP_DPTYPE_UNDEF 702
#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

View file

@ -91,10 +91,10 @@ class D : public Language {
* Names of generated D entities.
*/
// The name of the D module containing the interface to the C wrapper.
String *wrap_dmodule_name;
String *im_dmodule_name;
// The fully qualified name of the wrap D module (package name included).
String *wrap_dmodule_fq_name;
String *im_dmodule_fq_name;
// The name of the proxy module which exposes the (SWIG) module contents as a
// D module.
@ -120,12 +120,12 @@ class D : public Language {
/*
* Variables temporarily holding the generated D code.
*/
// Import statements written to the wrap D module header set via
// %pragma(d) wrapdmoduleimports.
String *wrap_dmodule_imports;
// Import statements written to the intermediary D module header set via
// %pragma(d) imdmoduleimports.
String *im_dmodule_imports;
// The code for the wrap D module body.
String *wrap_dmodule_code;
// 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
@ -140,7 +140,7 @@ class D : public Language {
// module. If not in split proxy mode, this contains the whole proxy code.
String *proxy_dmodule_code;
// The D code generated for the currently wrapped enum.
// The D code generated for the currently processed enum.
String *proxy_enum_code;
/*
@ -176,14 +176,14 @@ class D : public Language {
/*
* Code for dynamically loading the wrapper library on the D side.
*/
// D code which is inserted into the wrapper module if dynamic linking is used.
// 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 wrapper functions to the C/C++
// library symbols.
// 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;
/*
@ -231,15 +231,15 @@ public:
upcasts_code(NULL),
director_callback_typedefs(NULL),
director_callback_pointers(NULL),
wrap_dmodule_name(NULL),
wrap_dmodule_fq_name(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),
wrap_dmodule_imports(NULL),
wrap_dmodule_code(NULL),
im_dmodule_imports(NULL),
im_dmodule_code(NULL),
global_proxy_imports(NULL),
proxy_dmodule_imports(NULL),
proxy_dmodule_code(NULL),
@ -335,8 +335,8 @@ public:
Node *optionsnode = Getattr(Getattr(n, "module"), "options");
if (optionsnode) {
if (Getattr(optionsnode, "wrapdmodulename")) {
wrap_dmodule_name = Copy(Getattr(optionsnode, "wrapdmodulename"));
if (Getattr(optionsnode, "imdmodulename")) {
im_dmodule_name = Copy(Getattr(optionsnode, "imdmodulename"));
}
if (Getattr(optionsnode, "directors")) {
@ -423,14 +423,14 @@ public:
// Make the wrap and proxy D module names.
// The wrap module name can be set in the module directive.
if (!wrap_dmodule_name) {
wrap_dmodule_name = NewStringf("%s_wrap", Getattr(n, "name"));
if (!im_dmodule_name) {
im_dmodule_name = NewStringf("%s_im", Getattr(n, "name"));
}
wrap_dmodule_fq_name = NewStringf("%s%s", package, wrap_dmodule_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);
wrap_dmodule_code = NewString("");
im_dmodule_code = NewString("");
proxy_class_imports = NewString("");
proxy_class_enums_code = NewString("");
proxy_class_body_code = NewString("");
@ -439,7 +439,7 @@ public:
destructor_call = NewString("");
proxy_dmodule_code = NewString("");
proxy_dmodule_imports = NewString("");
wrap_dmodule_imports = NewString("");
im_dmodule_imports = NewString("");
upcasts_code = NewString("");
global_proxy_imports = NewString("");
wrapper_loader_code = NewString("");
@ -450,10 +450,9 @@ public:
n_dmethods = 0;
// By default, expect the dynamically loaded wrapper library to be named
// like the wrapper D module (i.e. [lib]<module>_wrap[.so/.dll] unless the
// user overrides it).
// [lib]<module>_wrap[.so/.dll].
if (!wrap_library_name)
wrap_library_name = Copy(wrap_dmodule_name);
wrap_library_name = NewStringf("%s_wrap", Getattr(n, "name"));
Swig_banner(f_begin);
@ -496,9 +495,9 @@ public:
// Generate the wrap D module.
// TODO: Add support for »static« linking.
{
String *filen = NewStringf("%s%s.d", dmodule_directory, wrap_dmodule_name);
File *wrap_d_file = NewFile(filen, "w", SWIG_output_files());
if (!wrap_d_file) {
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);
}
@ -507,22 +506,22 @@ public:
filen = NULL;
// Start writing out the intermediary class file.
emitBanner(wrap_d_file);
emitBanner(im_d_file);
Printf(wrap_d_file, "module %s;\n", wrap_dmodule_fq_name);
Printf(im_d_file, "module %s;\n", im_dmodule_fq_name);
Printv(wrap_d_file, wrap_dmodule_imports, "\n", NIL);
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(wrap_d_file, "%s\n", wrapper_loader_code);
Printf(im_d_file, "%s\n", wrapper_loader_code);
// Add the wrapper function declarations.
replaceModuleVariables(wrap_dmodule_code);
Printv(wrap_d_file, wrap_dmodule_code, NIL);
replaceModuleVariables(im_dmodule_code);
Printv(im_d_file, im_dmodule_code, NIL);
Close(wrap_d_file);
Close(im_d_file);
}
// Generate the D proxy module for the wrapped module.
@ -540,7 +539,7 @@ public:
emitBanner(proxy_d_file);
Printf(proxy_d_file, "module %s;\n", proxy_dmodule_fq_name);
Printf(proxy_d_file, "\nstatic import %s;\n", wrap_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);
@ -588,12 +587,12 @@ public:
unknown_types = NULL;
Delete(filenames_list);
filenames_list = NULL;
Delete(wrap_dmodule_name);
wrap_dmodule_name = NULL;
Delete(wrap_dmodule_fq_name);
wrap_dmodule_fq_name = NULL;
Delete(wrap_dmodule_code);
wrap_dmodule_code = 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);
@ -614,8 +613,8 @@ public:
proxy_dmodule_code = NULL;
Delete(proxy_dmodule_imports);
proxy_dmodule_imports = NULL;
Delete(wrap_dmodule_imports);
wrap_dmodule_imports = NULL;
Delete(im_dmodule_imports);
im_dmodule_imports = NULL;
Delete(upcasts_code);
upcasts_code = NULL;
Delete(global_proxy_imports);
@ -681,17 +680,17 @@ public:
* D::pragmaDirective()
*
* Valid Pragmas:
* wrapdmodulecode - text (D code) is copied verbatim to the wrap module
* wrapdmoduleimports - import statements for the wrap module
* 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 wrap D module).
* the im D module).
* wrapperloaderbindcommand - D code for binding a symbol from the wrapper
* library to the declaration in the wrap D module.
* library to the declaration in the im D module.
* --------------------------------------------------------------------------- */
virtual int pragmaDirective(Node *n) {
if (!ImportMode) {
@ -703,12 +702,12 @@ public:
String *strvalue = NewString(value);
Replaceall(strvalue, "\\\"", "\"");
if (Strcmp(code, "wrapdmodulecode") == 0) {
Printf(wrap_dmodule_code, "%s\n", strvalue);
} else if (Strcmp(code, "wrapdmoduleimports") == 0) {
if (Strcmp(code, "imdmodulecode") == 0) {
Printf(im_dmodule_code, "%s\n", strvalue);
} else if (Strcmp(code, "imdmoduleimports") == 0) {
replaceImportTypeMacros(strvalue);
Chop(strvalue);
Printf(wrap_dmodule_imports, "%s\n", 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) {
@ -1035,24 +1034,24 @@ public:
// 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, "dwtype", true);
const String *wrapper_return_type = lookupDTypemap(n, "imtype", true);
String *dwtypeout = Getattr(n, "tmap:dwtype:out");
if (dwtypeout) {
// The type in the dwtype typemap's out attribute overrides the type in
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 = dwtypeout;
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, wrap_dmodule_fq_name, ".", mangled_overname, "(", NIL);
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("dptype", l, NULL);
Swig_typemap_attach_parms("dtype", l, NULL);
Swig_typemap_attach_parms("din", l, NULL);
emit_mark_varargs(l);
@ -1078,12 +1077,12 @@ public:
String *param_type = NewString("");
// Get the D parameter type.
if ((tm = lookupDTypemap(p, "dptype", true))) {
const String *inattributes = Getattr(p, "tmap:dptype:inattributes");
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_DPTYPE_UNDEF, input_file, line_number,
"No dptype typemap defined for %s\n", SwigType_str(pt, 0));
Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number,
"No dtype typemap defined for %s\n", SwigType_str(pt, 0));
}
if (gencomma)
@ -1093,7 +1092,7 @@ public:
String *parmtype = 0;
// Get the D code to convert the parameter value to the type used in the
// wrapper D module.
// intermediary D module.
if ((tm = lookupDTypemap(p, "din"))) {
Replaceall(tm, "$dinput", arg);
String *pre = Getattr(p, "tmap:din:pre");
@ -1198,10 +1197,10 @@ public:
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, "$wcall", helper_name);
Replaceall(proxy_constructor_code, "$imcall", helper_name);
Delete(helper_name);
} else {
Replaceall(proxy_constructor_code, "$wcall", imcall);
Replaceall(proxy_constructor_code, "$imcall", imcall);
}
Printv(proxy_class_body_code, proxy_constructor_code, "\n", NIL);
@ -1224,7 +1223,7 @@ public:
virtual int destructorHandler(Node *n) {
Language::destructorHandler(n);
String *symname = Getattr(n, "sym:name");
Printv(destructor_call, wrap_dmodule_fq_name, ".", Swig_name_destroy(NSPACE_TODO,symname), "(cast(void*)swigCPtr)", NIL);
Printv(destructor_call, im_dmodule_fq_name, ".", Swig_name_destroy(NSPACE_TODO,symname), "(cast(void*)swigCPtr)", NIL);
return SWIG_OK;
}
@ -1254,7 +1253,7 @@ public:
emitBanner(class_file);
Printf(class_file, "module %s%s;\n", package, proxy_class_name);
Printf(class_file, "\nstatic import %s;\n", wrap_dmodule_fq_name);
Printf(class_file, "\nstatic import %s;\n", im_dmodule_fq_name);
}
Clear(proxy_class_imports);
@ -1342,23 +1341,23 @@ public:
ParmList *l = Getattr(n, "parms");
// Attach the non-standard typemaps to the parameter list.
Swig_typemap_attach_parms("dptype", l, NULL);
Swig_typemap_attach_parms("dtype", l, NULL);
// Get D return type.
String *return_type = NewString("");
String *tm;
if ((tm = lookupDTypemap(n, "dptype"))) {
String *dptypeout = Getattr(n, "tmap:dptype:out");
if (dptypeout) {
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 dptype typemap.
tm = dptypeout;
// in the dtype typemap.
tm = dtypeout;
replaceClassname(tm, t);
}
Printf(return_type, "%s", tm);
} else {
Swig_warning(WARN_D_TYPEMAP_DPTYPE_UNDEF, input_file, line_number,
"No dptype typemap defined for %s\n", SwigType_str(t, 0));
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;
@ -1448,33 +1447,33 @@ public:
String *wname = Swig_name_wrapper(overloaded_name);
/* Attach the non-standard typemaps to the parameter list. */
Swig_typemap_attach_parms("cwtype", l, f);
Swig_typemap_attach_parms("dwtype", l, f);
Swig_typemap_attach_parms("ctype", l, f);
Swig_typemap_attach_parms("imtype", l, f);
/* Get return types */
if ((tm = lookupDTypemap(n, "cwtype"))) {
String *cwtypeout = Getattr(n, "tmap:cwtype:out");
if (cwtypeout) {
// The type in the cwtype typemap's out attribute overrides the type in
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 = cwtypeout;
tm = ctypeout;
}
Printf(c_return_type, "%s", tm);
} else {
Swig_warning(WARN_D_TYPEMAP_CWTYPE_UNDEF, input_file, line_number,
"No cwtype typemap defined for %s\n", SwigType_str(t, 0));
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, "dwtype"))) {
String *dwtypeout = Getattr(n, "tmap:dwtype:out");
if (dwtypeout) {
// The type in the dwtype typemap's out attribute overrides the type in
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 = dwtypeout;
tm = imtypeout;
}
Printf(im_return_type, "%s", tm);
} else {
Swig_warning(WARN_D_TYPEMAP_DWTYPE_UNDEF, input_file, line_number, "No dwtype typemap defined for %s\n", SwigType_str(t, 0));
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);
@ -1501,9 +1500,9 @@ public:
return SWIG_OK;
}
// Collect the parameter list for the wrap D module declaration of the
// generated wrapper function.
String *wrap_dmodule_parameters = NewString("(");
// 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);
@ -1525,25 +1524,25 @@ public:
Printf(arg, "j%s", ln);
/* Get the cwtype types of the parameter */
if ((tm = lookupDTypemap(p, "cwtype", true))) {
/* 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_CWTYPE_UNDEF, input_file, line_number, "No cwtype typemap defined for %s\n", SwigType_str(pt, 0));
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, "dwtype", true))) {
const String *inattributes = Getattr(p, "tmap:dwtype:inattributes");
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_DWTYPE_UNDEF, input_file, line_number, "No dwtype typemap defined for %s\n", SwigType_str(pt, 0));
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(wrap_dmodule_parameters, ", ");
Printf(wrap_dmodule_parameters, "%s %s", im_param_type, arg);
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);
@ -1674,11 +1673,11 @@ public:
}
}
// Complete D wrapper parameter list and emit the declaration/binding code.
Printv(wrap_dmodule_parameters, ")", NIL);
writeWrapDModuleFunction(overloaded_name, im_return_type,
wrap_dmodule_parameters, wname);
Delete(wrap_dmodule_parameters);
// 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, ") {");
@ -1931,32 +1930,32 @@ public:
/* Create the intermediate class wrapper */
Parm *tp = NewParm(returntype, empty_str, n);
tm = lookupDTypemap(tp, "dwtype");
tm = lookupDTypemap(tp, "imtype");
if (tm) {
String *dwtypeout = Getattr(tp, "tmap:dwtype:out");
if (dwtypeout) {
// The type in the dwtype typemap's out attribute overrides the type
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 = dwtypeout;
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_DWTYPE_UNDEF, input_file, line_number,
"No dwtype typemap defined for %s\n", SwigType_str(returntype, 0));
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("cwtype", retpm, "", 0))) {
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_CWTYPE_UNDEF, input_file, line_number,
"No cwtype typemap defined for %s for use in %s::%s (skipping director method)\n",
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;
}
@ -1980,9 +1979,9 @@ public:
// Attach the standard typemaps.
Swig_typemap_attach_parms("out", l, 0);
Swig_typemap_attach_parms("cwtype", l, 0);
Swig_typemap_attach_parms("dwtype", l, 0);
Swig_typemap_attach_parms("dptype", 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);
@ -2026,12 +2025,12 @@ public:
Printf(dcallback_call_args, ", %s", arg);
/* Get parameter's intermediary C type */
if ((c_param_type = lookupDTypemap(p, "cwtype", true))) {
String *cwtypeout = Getattr(p, "tmap:cwtype:out");
if (cwtypeout) {
// The type in the cwtype typemap's out attribute overrides the 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 = cwtypeout;
c_param_type = ctypeout;
}
Parm *tp = NewParm(c_param_type, empty_str, n);
@ -2060,14 +2059,14 @@ public:
/* Add parameter to the intermediate class code if generating the
* intermediate's upcall code */
if ((tm = lookupDTypemap(p, "dwtype", true))) {
String *dwtypeout = Getattr(p, "tmap:dwtype:out");
if (dwtypeout) {
// The type in the dwtype typemap's out attribute overrides the
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 = dwtypeout;
tm = imtypeout;
}
const String *im_directorinattributes = Getattr(p, "tmap:dwtype:directorinattributes");
const String *im_directorinattributes = Getattr(p, "tmap:imtype:directorinattributes");
// TODO: Is this copy really needed?
String *din = Copy(lookupDTypemap(p, "ddirectorin", true));
@ -2093,11 +2092,11 @@ public:
// 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, "dptype", true))) {
if ((tm = lookupDTypemap(p, "dtype", true))) {
Printf(proxy_method_param_list, "%s", tm);
} else {
Swig_warning(WARN_D_TYPEMAP_DPTYPE_UNDEF, input_file, line_number,
"No dptype typemap defined for %s\n", SwigType_str(pt, 0));
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,
@ -2106,8 +2105,8 @@ public:
output_director = false;
}
} else {
Swig_warning(WARN_D_TYPEMAP_DWTYPE_UNDEF, input_file, line_number,
"No dwtype typemap defined for %s for use in %s::%s (skipping director method)\n",
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;
}
@ -2133,8 +2132,8 @@ public:
Delete(tp);
} else {
Swig_warning(WARN_D_TYPEMAP_CWTYPE_UNDEF, input_file, line_number,
"No cwtype typemap defined for %s for use in %s::%s (skipping director method)\n",
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);
@ -2198,7 +2197,7 @@ public:
// RESEARCH: What happens if there is no ddirectorout typemap?
if ((tm = lookupDTypemap(tp, "ddirectorout"))) {
Replaceall(tm, "$dpcall", upcall);
Replaceall(tm, "$dcall", upcall);
Printf(callback_code, " return %s;\n", tm);
}
@ -2288,18 +2287,18 @@ public:
// the full return type any longer after Language::functionHandler has
// returned.
Parm *tp = NewParm(returntype, empty_str, n);
String *dp_return_type = lookupDTypemap(tp, "dptype");
String *dp_return_type = lookupDTypemap(tp, "dtype");
if (dp_return_type) {
String *dptypeout = Getattr(n, "tmap:dptype:out");
if (dptypeout) {
// The type in the dptype typemap's out attribute overrides the 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 = dptypeout;
dp_return_type = dtypeout;
replaceClassname(dp_return_type, returntype);
}
} else {
Swig_warning(WARN_D_TYPEMAP_DPTYPE_UNDEF, input_file, line_number,
"No dptype typemap defined for %s\n", SwigType_str(type, 0));
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("");
}
@ -2313,10 +2312,10 @@ public:
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 wrap D module.
// 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(wrap_dmodule_code, "alias extern(C) %s function(void*%s) %s;\n", proxy_callback_return_type, delegate_parms, proxy_callback_type);
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);
}
@ -2519,21 +2518,21 @@ protected:
private:
/* ---------------------------------------------------------------------------
* D::writeWrapDModuleFunction()
* D::writeImDModuleFunction()
*
* Writes a function declaration for the given (C) wrapper function to the
* wrap D module.
* intermediary D module.
*
* d_name - The name the function in the D wrap module will get.
* 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 writeWrapDModuleFunction(const_String_or_char_ptr d_name,
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(wrap_dmodule_code, "extern(C) %s function%s %s;\n", return_type,
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);
@ -2548,7 +2547,7 @@ private:
*
* The Node must contain two extra attributes.
* - "proxyfuncname": The name of the D proxy function.
* - "imfuncname": The corresponding function in the wrap D module.
* - "imfuncname": The corresponding function in the intermediary D module.
* --------------------------------------------------------------------------- */
void writeProxyClassFunction(Node *n) {
SwigType *t = Getattr(n, "type");
@ -2585,22 +2584,22 @@ private:
/* Attach the non-standard typemaps to the parameter list */
Swig_typemap_attach_parms("in", l, NULL);
Swig_typemap_attach_parms("dptype", l, NULL);
Swig_typemap_attach_parms("dtype", l, NULL);
Swig_typemap_attach_parms("din", l, NULL);
// Get return types.
if ((tm = lookupDTypemap(n, "dptype"))) {
String *dptypeout = Getattr(n, "tmap:dptype:out");
if (dptypeout) {
// The type in the dptype typemap's out attribute overrides the type in
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 = dptypeout;
tm = dtypeout;
replaceClassname(tm, t);
}
Printf(return_type, "%s", tm);
} else {
Swig_warning(WARN_D_TYPEMAP_DPTYPE_UNDEF, input_file, line_number,
"No dptype typemap defined for %s\n", SwigType_str(t, 0));
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) {
@ -2644,7 +2643,7 @@ private:
Printf(function_code, "%s %s(", return_type, proxy_function_name);
// Write the wrapper function call up to the parameter list.
Printv(imcall, wrap_dmodule_fq_name, ".$imfuncname(", NIL);
Printv(imcall, im_dmodule_fq_name, ".$imfuncname(", NIL);
if (!static_flag) {
Printf(imcall, "cast(void*)swigCPtr");
}
@ -2714,12 +2713,12 @@ private:
{
String *proxy_type = NewString("");
if ((tm = lookupDTypemap(p, "dptype"))) {
const String *inattributes = Getattr(p, "tmap:dptype:inattributes");
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_DPTYPE_UNDEF, input_file, line_number,
"No dptype typemap defined for %s\n", SwigType_str(pt, 0));
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)
@ -2801,7 +2800,7 @@ private:
} else {
Replaceall(imcall, "$imfuncname", intermediary_function_name);
}
Replaceall(tm, "$wcall", imcall);
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));
@ -2851,22 +2850,22 @@ private:
}
/* Attach the non-standard typemaps to the parameter list */
Swig_typemap_attach_parms("dptype", l, NULL);
Swig_typemap_attach_parms("dtype", l, NULL);
Swig_typemap_attach_parms("din", l, NULL);
/* Get return types */
if ((tm = lookupDTypemap(n, "dptype"))) {
String *dptypeout = Getattr(n, "tmap:dptype:out");
if (dptypeout) {
// The type in the dptype typemap's out attribute overrides the type in
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 = dptypeout;
tm = dtypeout;
replaceClassname(tm, t);
}
Printf(return_type, "%s", tm);
} else {
Swig_warning(WARN_D_TYPEMAP_DPTYPE_UNDEF, input_file, line_number,
"No dptype typemap defined for %s\n", SwigType_str(t, 0));
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 */
@ -2878,7 +2877,7 @@ private:
}
/* Start generating the function */
const String *outattributes = Getattr(n, "tmap:dptype:outattributes");
const String *outattributes = Getattr(n, "tmap:dtype:outattributes");
if (outattributes)
Printf(function_code, " %s\n", outattributes);
@ -2888,7 +2887,7 @@ private:
methodmods = methodmods ? methodmods : empty_string;
Printf(function_code, "\n%s%s %s(", methodmods, return_type, func_name);
Printv(imcall, wrap_dmodule_fq_name, ".", overloaded_name, "(", NIL);
Printv(imcall, im_dmodule_fq_name, ".", overloaded_name, "(", NIL);
/* Get number of required and total arguments */
num_arguments = emit_num_arguments(l);
@ -2908,12 +2907,12 @@ private:
String *param_type = NewString("");
// Get the D parameter type.
if ((tm = lookupDTypemap(p, "dptype", true))) {
const String *inattributes = Getattr(p, "tmap:dptype:inattributes");
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_DPTYPE_UNDEF, input_file, line_number,
"No dptype typemap defined for %s\n", SwigType_str(pt, 0));
Swig_warning(WARN_D_TYPEMAP_DTYPE_UNDEF, input_file, line_number,
"No dtype typemap defined for %s\n", SwigType_str(pt, 0));
}
if (gencomma)
@ -3003,7 +3002,7 @@ private:
else
Replaceall(tm, "$owner", "false");
replaceClassname(tm, t);
Replaceall(tm, "$wcall", imcall);
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));
@ -3214,9 +3213,9 @@ private:
Printv(dispose_code, tm, NIL);
if (*Char(destructor_call)) {
Replaceall(dispose_code, "$wcall", destructor_call);
Replaceall(dispose_code, "$imcall", destructor_call);
} else {
Replaceall(dispose_code, "$wcall", "throw new object.Exception(\"C++ destructor does not have public access\")");
Replaceall(dispose_code, "$imcall", "throw new object.Exception(\"C++ destructor does not have public access\")");
}
if (*Char(dispose_code)) {
@ -3271,7 +3270,7 @@ private:
String *upcast_wrapper_name = Swig_name_wrapper(upcast_name);
writeWrapDModuleFunction(upcast_name, "void*", "(void* objectRef)",
writeImDModuleFunction(upcast_name, "void*", "(void* objectRef)",
upcast_wrapper_name);
if (smartptr) {
@ -3342,7 +3341,7 @@ private:
emitBanner(class_file);
Printf(class_file, "module %s%s;\n", package, classname);
Printf(class_file, "\nstatic import %s;\n", wrap_dmodule_fq_name);
Printf(class_file, "\nstatic import %s;\n", im_dmodule_fq_name);
imports_target = NewString("");
code_target = NewString("");
@ -3415,12 +3414,12 @@ private:
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", wrap_dmodule_fq_name, proxy_class_name, methid, methid);
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", wrap_dmodule_fq_name, proxy_class_name);
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");
@ -3478,7 +3477,7 @@ private:
Replaceall(wrapper_loader_bind_code, "$function", connect_name);
Replaceall(wrapper_loader_bind_code, "$symbol", Swig_name_wrapper(connect_name));
Printf(wrap_dmodule_code, "extern(C) void function(void* cObject, void* dObject");
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);
@ -3495,12 +3494,12 @@ private:
Printf(code_wrap->def, ", SwigDirector_%s::SWIG_Callback%s_t callback%s", sym_name, methid, methid);
Printf(code_wrap->code, ", callback%s", methid);
Printf(wrap_dmodule_code, ", SwigDirector_%s_Callback%s callback%s", sym_name, methid, 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(wrap_dmodule_code, ") %s;\n", connect_name);
Printf(im_dmodule_code, ") %s;\n", connect_name);
Printf(code_wrap->code, " }\n");
Printf(code_wrap->code, "}\n");
@ -3647,8 +3646,8 @@ private:
* --------------------------------------------------------------------------- */
void assertClassNameValidity(const String* class_name) const {
if (split_proxy_dmodule) {
if (Cmp(class_name, wrap_dmodule_name) == 0) {
Swig_error(input_file, line_number, "Class name cannot be equal to wrap D module name: %s\n",
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);
}
@ -3691,7 +3690,7 @@ private:
// Now that we got rid of the pointers, see if we are dealing with a
// primitive type.
String *dptype = 0;
String *dtype = 0;
if (SwigType_isfunction(stripped_type) && indirection_count > 0) {
// type was a function pointer, split it up.
SwigType_add_pointer(stripped_type);
@ -3736,29 +3735,29 @@ private:
}
}
dptype = NewStringf("%s function(%s)", return_dtype, param_list);
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, "dptype", stripped_type, WARN_NONE, attributes);
if(!GetFlag(attributes, "tmap:dptype:cprimitive")) {
dptype = 0;
lookupCodeTypemap(node, "dtype", stripped_type, WARN_NONE, attributes);
if(!GetFlag(attributes, "tmap:dtype:cprimitive")) {
dtype = 0;
} else {
dptype = Copy(tm);
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(dptype, stripped_type);
replaceClassname(dtype, stripped_type);
}
Delete(attributes);
}
Delete(stripped_type);
if (!dptype) {
if (!dtype) {
// The type passed is no primitive type.
return 0;
}
@ -3766,16 +3765,16 @@ private:
// 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(dptype, "*");
Append(dtype, "*");
}
// Add a level of indirection for a mutable reference since it is wrapped
// as a pointer.
if (mutable_ref) {
Append(dptype, "*");
Append(dtype, "*");
}
return dptype;
return dtype;
}
/* ---------------------------------------------------------------------------
@ -3854,12 +3853,12 @@ private:
String *np_key = NewStringf("tmap:%s:nativepointer", method);
String *np_value = Getattr(n, np_key);
Delete(np_key);
String *dptype;
if (np_value && (dptype = getPrimitiveDptype(n, type))) {
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, "$dptype", dptype);
Replaceall(result, "$dtype", dtype);
}
replaceClassname(result, type);
@ -4007,11 +4006,11 @@ private:
/* ---------------------------------------------------------------------------
* D::replaceModuleVariables()
*
* Replaces the $wrapdmodule and $module variables with their values in the
* Replaces the $imdmodule and $module variables with their values in the
* target string.
* --------------------------------------------------------------------------- */
void replaceModuleVariables(String *target) const {
Replaceall(target, "$wrapdmodule", wrap_dmodule_fq_name);
Replaceall(target, "$imdmodule", im_dmodule_fq_name);
Replaceall(target, "$module", proxy_dmodule_name);
}