typemap m3wrapargconst allow definition of local constants
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@6617 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
38d71bb5e2
commit
70ff24a677
2 changed files with 41 additions and 8 deletions
|
|
@ -146,7 +146,7 @@ On the one hand Modula-3 can be safe
|
||||||
while providing much static and dynamic safety.
|
while providing much static and dynamic safety.
|
||||||
On the other hand you can write efficient
|
On the other hand you can write efficient
|
||||||
but less safe code in the style of C
|
but less safe code in the style of C
|
||||||
within UNSAFE modules.
|
within <tt>UNSAFE</tt> modules.
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
Unfortunately Modula's safety and strength
|
Unfortunately Modula's safety and strength
|
||||||
|
|
@ -187,7 +187,7 @@ and the low level of the C libraries.
|
||||||
SWIG converts C headers to Modula-3 interfaces for you.
|
SWIG converts C headers to Modula-3 interfaces for you.
|
||||||
You could call the C functions without loss
|
You could call the C functions without loss
|
||||||
of efficiency but it won't be joy
|
of efficiency but it won't be joy
|
||||||
because you could not pass TEXTs
|
because you could not pass <tt>TEXT</tt>s
|
||||||
or open arrays and
|
or open arrays and
|
||||||
you would have to process error return codes
|
you would have to process error return codes
|
||||||
rather then exceptions.
|
rather then exceptions.
|
||||||
|
|
@ -650,11 +650,18 @@ consist of the following parts:
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>m3wrapargvar</td>
|
<td>m3wrapargvar</td>
|
||||||
<td><tt>$1: Ptr := $1_name;</tt></td>
|
<td><tt>$1: INTEGER := $1_name;</tt></td>
|
||||||
<td>
|
<td>
|
||||||
Declaration of some variables needed for temporary results.
|
Declaration of some variables needed for temporary results.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>m3wrapargconst</td>
|
||||||
|
<td><tt>$1 = "$1_name";</tt></td>
|
||||||
|
<td>
|
||||||
|
Declaration of some constant, maybe for debug purposes.
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>m3wrapargraw</td>
|
<td>m3wrapargraw</td>
|
||||||
<td><tt>ORD($1_name)</tt></td>
|
<td><tt>ORD($1_name)</tt></td>
|
||||||
|
|
@ -909,6 +916,8 @@ where almost everything is generated by a typemap:
|
||||||
PROCEDURE Name (READONLY str : TEXT := "" )
|
PROCEDURE Name (READONLY str : TEXT := "" )
|
||||||
<I> (* m3wrapoutcheck:throws *)</I>
|
<I> (* m3wrapoutcheck:throws *)</I>
|
||||||
: NameResult RAISES {E} =
|
: NameResult RAISES {E} =
|
||||||
|
CONST
|
||||||
|
arg1name = "str"; <I>(* m3wrapargconst *)</I>
|
||||||
VAR
|
VAR
|
||||||
arg0 : C.char_star; <I>(* m3wrapretvar *)</I>
|
arg0 : C.char_star; <I>(* m3wrapretvar *)</I>
|
||||||
arg1 : C.char_star; <I>(* m3wrapargvar *)</I>
|
arg1 : C.char_star; <I>(* m3wrapargvar *)</I>
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,12 @@ char cvsroot_modula3_cxx[] =
|
||||||
It's not a good concept to use functions of superclasses for specific services.
|
It's not a good concept to use functions of superclasses for specific services.
|
||||||
E.g. For SWIG this means: Generating accessor functions for member variables
|
E.g. For SWIG this means: Generating accessor functions for member variables
|
||||||
is the most common but no general task to be processed in membervariableHandler.
|
is the most common but no general task to be processed in membervariableHandler.
|
||||||
Better provide a service functions which generates accessor function code
|
Better provide a service function which generates accessor function code
|
||||||
and equip this service function with all parameters needed for input (parse node)
|
and equip this service function with all parameters needed for input (parse node)
|
||||||
and output (generated code).
|
and output (generated code).
|
||||||
- How can I make globalvariableHandler not to generate
|
- How can I make globalvariableHandler not to generate
|
||||||
interface functions to two accessor functions
|
interface functions to two accessor functions
|
||||||
(that don't exist)
|
(that don't exist) ?
|
||||||
- How can I generate a typemap that turns every C reference argument into
|
- How can I generate a typemap that turns every C reference argument into
|
||||||
its Modula 3 counterpart, that is
|
its Modula 3 counterpart, that is
|
||||||
void test(Complex &z);
|
void test(Complex &z);
|
||||||
|
|
@ -3292,6 +3292,7 @@ MODULA3 ():
|
||||||
String *rawcall = NewString ("");
|
String *rawcall = NewString ("");
|
||||||
String *reccall = NewString ("");
|
String *reccall = NewString ("");
|
||||||
String *local_variables = NewString ("");
|
String *local_variables = NewString ("");
|
||||||
|
String *local_constants = NewString ("");
|
||||||
String *incheck = NewString ("");
|
String *incheck = NewString ("");
|
||||||
String *outcheck = NewString ("");
|
String *outcheck = NewString ("");
|
||||||
String *setup = NewString ("");
|
String *setup = NewString ("");
|
||||||
|
|
@ -3316,6 +3317,7 @@ MODULA3 ():
|
||||||
|
|
||||||
/* Attach the non-standard typemaps to the parameter list */
|
/* Attach the non-standard typemaps to the parameter list */
|
||||||
Swig_typemap_attach_parms ("m3wrapargvar", l, NULL);
|
Swig_typemap_attach_parms ("m3wrapargvar", l, NULL);
|
||||||
|
Swig_typemap_attach_parms ("m3wrapargconst", l, NULL);
|
||||||
Swig_typemap_attach_parms ("m3wrapargraw", l, NULL);
|
Swig_typemap_attach_parms ("m3wrapargraw", l, NULL);
|
||||||
Swig_typemap_attach_parms ("m3wrapargdir", l, NULL);
|
Swig_typemap_attach_parms ("m3wrapargdir", l, NULL);
|
||||||
Swig_typemap_attach_parms ("m3wrapinmode", l, NULL);
|
Swig_typemap_attach_parms ("m3wrapinmode", l, NULL);
|
||||||
|
|
@ -3429,6 +3431,26 @@ MODULA3 ():
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Declare local constants e.g. for storing argument names. */
|
||||||
|
{
|
||||||
|
Parm *p = l;
|
||||||
|
while (p != NIL) {
|
||||||
|
|
||||||
|
String *arg = Getattr (p, "autoname");
|
||||||
|
|
||||||
|
String *tm = Getattr (p, "tmap:m3wrapargconst");
|
||||||
|
if (tm != NIL) {
|
||||||
|
addImports (m3wrap_impl.import, "m3wrapargconst", p);
|
||||||
|
Replaceall (tm, "$input", arg);
|
||||||
|
Printv (local_constants, tm, "\n", NIL);
|
||||||
|
p = Getattr (p, "tmap:m3wrapargconst:next");
|
||||||
|
} else {
|
||||||
|
p = nextSibling (p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Declare local variables e.g. for converted input values. */
|
/* Declare local variables e.g. for converted input values. */
|
||||||
{
|
{
|
||||||
String *tm = getMappedTypeNew (n, "m3wrapretvar", "", false);
|
String *tm = getMappedTypeNew (n, "m3wrapretvar", "", false);
|
||||||
|
|
@ -3722,9 +3744,10 @@ MODULA3 ():
|
||||||
exc_handler = NewStringf ("%s%s", body, cleanup);
|
exc_handler = NewStringf ("%s%s", body, cleanup);
|
||||||
}
|
}
|
||||||
|
|
||||||
Printf (function_code, " =\n%s%sBEGIN\n%s%sEND %s;\n\n",
|
Printf (function_code, " =\n%s%s%s%sBEGIN\n%s%sEND %s;\n\n",
|
||||||
hasContent (local_variables) ? "VAR\n" : "",
|
hasContent (local_constants) ? "CONST\n" : "", local_constants,
|
||||||
local_variables, exc_handler, outarg, func_name);
|
hasContent (local_variables) ? "VAR\n" : "", local_variables,
|
||||||
|
exc_handler, outarg, func_name);
|
||||||
|
|
||||||
Delete (exc_handler);
|
Delete (exc_handler);
|
||||||
Delete (body);
|
Delete (body);
|
||||||
|
|
@ -3771,6 +3794,7 @@ MODULA3 ():
|
||||||
Delete (arguments);
|
Delete (arguments);
|
||||||
Delete (return_variables);
|
Delete (return_variables);
|
||||||
Delete (local_variables);
|
Delete (local_variables);
|
||||||
|
Delete (local_constants);
|
||||||
Delete (outarg);
|
Delete (outarg);
|
||||||
Delete (incheck);
|
Delete (incheck);
|
||||||
Delete (outcheck);
|
Delete (outcheck);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue