merge from trunk

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11423 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Baozeng Ding 2009-07-18 23:45:53 +00:00
commit 37ebcb9e67
31 changed files with 560 additions and 369 deletions

View file

@ -1,6 +1,16 @@
Version 1.3.40 (in progress)
============================
2009-07-15: olly
[Perl] Don't specify Perl prototype "()" for a constructor with a
different name to the class, as such constructors can still take
parameters.
2009-07-05: olly
[PHP] Update the list of PHP keywords - "cfunction" is no longer a
keyword in PHP5 and PHP 5.3 added "goto", "namespace", "__DIR__",
and "__NAMESPACE__".
2009-07-03: olly
[Tcl] To complement USE_TCL_STUBS, add support for USE_TK_STUBS
and SWIG_TCL_STUBS_VERSION. Document all three in the Tcl chapter

View file

@ -40,7 +40,7 @@
<li><a href="#Perl5_nn24">Modules and packages</a>
</ul>
<li><a href="#Perl5_nn25">Input and output parameters</a>
<li><a href="#Perl5_nn26">Exception handling </a>
<li><a href="#Perl5_nn26">Exception handling</a>
<li><a href="#Perl5_nn27">Remapping datatypes with typemaps</a>
<ul>
<li><a href="#Perl5_nn28">A simple typemap example</a>
@ -50,8 +50,8 @@
</ul>
<li><a href="#Perl5_nn32">Typemap Examples</a>
<ul>
<li><a href="#Perl5_nn33">Converting a Perl5 array to a char ** </a>
<li><a href="#Perl5_nn34">Return values </a>
<li><a href="#Perl5_nn33">Converting a Perl5 array to a char **</a>
<li><a href="#Perl5_nn34">Return values</a>
<li><a href="#Perl5_nn35">Returning values from arguments</a>
<li><a href="#Perl5_nn36">Accessing array structure members</a>
<li><a href="#Perl5_nn37">Turning Perl references into C pointers</a>
@ -815,7 +815,7 @@ extern char *path; // Declared later in the input
<p>
Constants are wrapped as read-only Perl variables. For example:
By default, constants are wrapped as read-only Perl variables. For example:
</p>
<div class="code">
@ -838,6 +838,19 @@ $example::FOO = 2; # Error
</pre>
</div>
<p>
Alternatively, if you use swig's <tt>-const</tt> option, constants are wrapped
such that the leading $ isn't required (by using a constant subroutine), which
usually gives a more natural Perl interface, for example:
</p>
<div class="targetlang">
<pre>
use example;
print example::FOO,"\n";
</pre>
</div>
<H3><a name="Perl5_nn18"></a>28.4.4 Pointers</H3>
@ -879,7 +892,7 @@ if (defined($ptr)) {
</pre></div>
<p>
To create a NULL pointer, you should pass the <tt>undef </tt>value to
To create a NULL pointer, you should pass the <tt>undef</tt> value to
a function.
</p>
@ -889,7 +902,7 @@ pointer that SWIG wrapper functions return. Suppose that <tt>$a</tt>
and <tt>$b</tt> are two references that point to the same C object.
In general, <tt>$a</tt> and <tt>$b</tt> will be different--since they
are different references. Thus, it is a mistake to check the equality
of <tt>$a </tt>and <tt>$b</tt> to check the equality of two C
of <tt>$a</tt> and <tt>$b</tt> to check the equality of two C
pointers. The correct method to check equality of C pointers is to
dereference them as follows :
</p>
@ -1567,7 +1580,7 @@ print "$c\n";
<b>Note:</b> The <tt>REFERENCE</tt> feature is only currently supported for numeric types (integers and floating point).
</p>
<H2><a name="Perl5_nn26"></a>28.6 Exception handling </H2>
<H2><a name="Perl5_nn26"></a>28.6 Exception handling</H2>
<p>
@ -2107,7 +2120,7 @@ might look at the files "<tt>perl5.swg</tt>" and "<tt>typemaps.i</tt>" in
the SWIG library.
</p>
<H3><a name="Perl5_nn33"></a>28.8.1 Converting a Perl5 array to a char ** </H3>
<H3><a name="Perl5_nn33"></a>28.8.1 Converting a Perl5 array to a char **</H3>
<p>
@ -2199,7 +2212,7 @@ print @$b,"\n"; # Print it out
</pre></div>
<H3><a name="Perl5_nn34"></a>28.8.2 Return values </H3>
<H3><a name="Perl5_nn34"></a>28.8.2 Return values</H3>
<p>
@ -2714,7 +2727,7 @@ corresponding Perl object (this situation turns out to come up
frequently when constructing objects like linked lists and trees).
When C takes possession of an object, you can change Perl's ownership
by simply deleting the object from the <tt>%OWNER</tt> hash. This is
done using the <tt>DISOWN </tt>method.
done using the <tt>DISOWN</tt> method.
</p>
<div class="targetlang"><pre>

View file

@ -2636,8 +2636,9 @@ The example above also shows a common approach of issuing a warning for an as ye
<p>
The "out" typemap is the main typemap for return types.
This typemap supports an optional attribute flag called "optimal", which is for reducing
temporary variables and the amount of generated code.
It only really makes a difference when returning objects by value and it cannot always be used,
temporary variables and the amount of generated code, thereby giving the compiler the opportunity to
use <i>return value optimization</i> for generating faster executing code.
It only really makes a difference when returning objects by value and has some limitations on usage,
as explained later on.
</p>
@ -2695,7 +2696,7 @@ XX(const XX &amp;)
Note that three objects are being created as well as an assignment.
Wouldn't it be great if the <tt>XX::create()</tt> method was the only time a constructor was called?
As the method returns by value, this is asking a lot and the code that SWIG generates by default
makes it impossible for the compiler to make this type of optimisation.
makes it impossible for the compiler to use <i>return value optimisation (RVO)</i>.
However, this is where the "optimal" attribute in the "out" typemap can help out.
If the typemap code is kept the same and just the "optimal" attribute specified like this:
</p>
@ -2754,7 +2755,7 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_XX_create() {
<p>
The major difference is the <tt>result</tt> temporary variable holding the value returned from <tt>XX::create()</tt> is no longer generated and instead the copy constructor call is made directly from
the value returned by <tt>XX::create()</tt>.
With modern compiler optimisations turned on, the copy is not actually done, in fact the object is never created
With modern compilers implementing RVO, the copy is not actually done, in fact the object is never created
on the stack in <tt>XX::create()</tt> at all, it is simply created directly on the heap.
In the first instance, the <tt>$1</tt> special variable in the typemap is expanded into <tt>result</tt>.
In the second instance, <tt>$1</tt> is expanded into <tt>XX::create()</tt> and this is essentially
@ -2762,7 +2763,7 @@ what the "optimal" attribute is telling SWIG to do.
</p>
<p>
This kind of optimisation is not turned on by default as it has a number of restrictions.
The "optimal" attribute optimisation is not turned on by default as it has a number of restrictions.
Firstly, some code cannot be condensed into a simple call for passing into the copy constructor.
One common occurrence is when <a href="Customization.html#exception">%exception</a> is used.
Consider adding the following <tt>%exception</tt> to the example:

View file

@ -248,7 +248,7 @@ Execute the steps in the order shown and don't use spaces in path names. In fact
<ol>
<li>
Download the following packages from the <a href="http://www.mingw.org/download.shtml">MinGW download page</a>
or <a href="http://sourceforge.net/project/showfiles.php?group_id=2435">MinGW SourceForge download page</a>.
or <a href="http://sourceforge.net/projects/mingw/files/">MinGW SourceForge download page</a>.
Note that at the time of writing, the majority of these are in the Current
release list and some are in the Snapshot or Previous release list.
<ul>

View file

@ -1,6 +1,6 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
SRCS = example.i
SRCS = example.c
TARGET = example
INTERFACE = example.i

View file

@ -1,6 +1,26 @@
/* File : example.i */
%module example
FILE *fopen(char *filename, char *mode);
int fputs(char* , FILE *);
int fclose(FILE *);
%{
extern void add(int *, int *, int *);
extern void sub(int *, int *, int *);
extern int divide(int, int, int *);
%}
/* This example illustrates a couple of different techniques
for manipulating C pointers */
/* First we'll use the pointer library */
extern void add(int *x, int *y, int *result);
%include cpointer.i
%pointer_functions(int, intp);
/* Next we'll use some typemaps */
%include typemaps.i
extern void sub(int *INPUT, int *INPUT, int *OUTPUT);
/* Next we'll use typemaps and the %apply directive */
%apply int *OUTPUT { int *r };
extern int divide(int n, int d, int *r);

View file

@ -1,6 +1,6 @@
TOP = ../..
SWIG = $(TOP)/../preinst-swig
SRCS = example.i
SRCS = example.c
TARGET = example
INTERFACE = example.i

View file

@ -79,7 +79,7 @@ CPP_TEST_BROKEN += \
extend_variable \
li_std_vector_ptr \
namespace_union \
nested_struct \
nested_structs \
overload_complicated \
template_default_pointer \
template_expr
@ -220,6 +220,7 @@ CPP_TEST_CASES += \
li_typemaps \
li_windows \
long_long_apply \
memberin_extend \
member_pointer \
member_template \
minherit \

View file

@ -0,0 +1,26 @@
import memberin_extend.*;
public class memberin_extend_runme {
static {
try {
System.loadLibrary("memberin_extend");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[])
{
ExtendMe em1 = new ExtendMe();
ExtendMe em2 = new ExtendMe();
em1.setThing("em1thing");
em2.setThing("em2thing");
if (!em1.getThing().equals("em1thing"))
throw new RuntimeException("wrong: " + em1.getThing());
if (!em2.getThing().equals("em2thing"))
throw new RuntimeException("wrong: " + em2.getThing());
}
}

View file

@ -0,0 +1,22 @@
%module memberin_extend
// Tests memberin typemap. The default char * memberin typemap will be used.
// The test extends the struct with a pseudo member variable
%inline %{
#include <string>
struct ExtendMe {
};
%}
%{
#include <map>
std::map<ExtendMe*, char *> ExtendMeStringMap;
#define ExtendMe_thing_set(self_, val_) ExtendMeStringMap[self_]
#define ExtendMe_thing_get(self_) ExtendMeStringMap[self_]
%}
%extend ExtendMe {
char *thing;
}

View file

@ -1 +1,17 @@
empty
printf("begin\n");
who global
printf("after load\n");
who global
#clear -g
printf("after clear\n");
who global
#clear empty
printf("after clear specific\n");
who global
printf("before shutdown\n");

View file

@ -6,12 +6,12 @@ require "rename_scope.php";
check::classes(array("rename_scope","Interface_UP","Interface_BP","Natural_UP","Natural_BP","Bucket"));
check::classmethods("Interface_UP",array("interface_up"));
check::classmethods("Interface_BP",array("interface_bp"));
check::classmethods("Natural_UP",array("interface_up","natural_up","rtest"));
check::classmethods("Natural_BP",array("interface_bp","natural_bp","rtest"));
check::classparent("Natural_UP","interface_up");
check::classparent("Natural_BP","interface_bp");
check::classmethods("Interface_UP",array("__construct"));
check::classmethods("Interface_BP",array("__construct"));
check::classmethods("Natural_UP",array("__construct","rtest"));
check::classmethods("Natural_BP",array("__construct","rtest"));
check::classparent("Natural_UP","Interface_UP");
check::classparent("Natural_BP","Interface_BP");
check::done();
?>

View file

@ -8,6 +8,9 @@
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Namespace::enum1;
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Namespace::enum2;
#ifdef SWIGPHP
%warnfilter(SWIGWARN_PARSE_KEYWORD) Namespace;
#endif
// Tests SWIG's automatic exception mechanism

View file

@ -105,27 +105,35 @@ namespace Swig {
typedef std::map < void *, Director * > rtdir_map;
SWIGINTERN rtdir_map &get_rtdir_map() {
SWIGINTERN rtdir_map* get_rtdir_map() {
static swig_module_info *module = 0;
if (!module)
module = SWIG_GetModule(0);
assert(module);
if (!module)
return 0;
if (!module->clientdata)
module->clientdata = new rtdir_map;
return *(rtdir_map *) module->clientdata;
return (rtdir_map *) module->clientdata;
}
SWIGINTERNINLINE void set_rtdir(void *vptr, Director *d) {
get_rtdir_map()[vptr] = d;
rtdir_map* rm = get_rtdir_map();
if (rm)
(*rm)[vptr] = d;
}
SWIGINTERNINLINE void erase_rtdir(void *vptr) {
get_rtdir_map().erase(vptr);
rtdir_map* rm = get_rtdir_map();
if (rm)
(*rm).erase(vptr);
}
SWIGINTERNINLINE Director *get_rtdir(void *vptr) {
rtdir_map::const_iterator pos = get_rtdir_map().find(vptr);
Director *rtdir = (pos != get_rtdir_map().end())? pos->second : 0;
rtdir_map* rm = get_rtdir_map();
if (!rm)
return 0;
rtdir_map::const_iterator pos = rm->find(vptr);
Director *rtdir = (pos != rm->end())? pos->second : 0;
return rtdir;
}
}
@ -439,9 +447,15 @@ namespace Swig {
install_builtin_function(it->second.first->method, it->first,
it->second.first->doc?it->second.first->doc:std::string());
else if (it->second.second.is_defined()) {
#if USE_OCTAVE_API_VERSION<37
link_to_global_variable(curr_sym_tab->lookup(it->first, true));
#else
symbol_table::varref(it->first);
symbol_table::mark_global(it->first);
#endif
set_global_value(it->first, it->second.second);
#if USE_OCTAVE_API_VERSION<37
octave_swig_type *ost = Swig::swig_value_deref(it->second.second);
if (ost) {
const char* h = ost->help_text();
@ -450,6 +464,7 @@ namespace Swig {
sr->document(h);
}
}
#endif
}
}
}
@ -1352,6 +1367,11 @@ SWIGRUNTIME swig_module_info *SWIG_Octave_GetModule(void *clientdata) {
SWIGRUNTIME void SWIG_Octave_SetModule(void *clientdata, swig_module_info *pointer) {
octave_value ov = new octave_swig_packed(0, &pointer, sizeof(swig_module_info *));
const char *module_var = "__SWIG_MODULE__" SWIG_TYPE_TABLE_NAME SWIG_RUNTIME_VERSION;
#if USE_OCTAVE_API_VERSION<37
link_to_global_variable(curr_sym_tab->lookup(module_var, true));
#else
symbol_table::varref(module_var);
symbol_table::mark_global(module_var);
#endif
set_global_value(module_var, ov);
}

View file

@ -72,11 +72,33 @@ DEFUN_DLD (SWIG_name,args,nargout,SWIG_name_d) {
module_ns->install_global();
module_ns->decref();
#if USE_OCTAVE_API_VERSION<37
link_to_global_variable(curr_sym_tab->lookup(SWIG_name_d,true));
#else
symbol_table::varref(SWIG_name_d);
symbol_table::mark_global(SWIG_name_d);
#endif
set_global_value(SWIG_name_d,Swig::swig_value_ref(module_ns));
#if USE_OCTAVE_API_VERSION>=37
mlock();
#endif
return octave_value_list();
}
// workaround bug in octave where installing global variable of custom type and then
// exiting without explicitly clearing the variable causes octave to segfault.
#if USE_OCTAVE_API_VERSION>=37
struct oct_file_unload {
~oct_file_unload() {
string_vector vars = symbol_table::global_variable_names();
for (int i = 0; i < vars.length(); i++)
symbol_table::clear_global(vars[i]);
}
};
static oct_file_unload __unload;
#endif
%}

View file

@ -8,21 +8,22 @@
* when used as class methods.
* ----------------------------------------------------------------------------- */
#define PHPKW(x) %keywordwarn("'" `x` "' is a php keyword, renamed as 'c_" `x` "'",sourcefmt="%(lower)s", rename="c_%s",fullname=1) `x`
#define PHPKW(x) %keywordwarn("'" `x` "' is a PHP keyword, renamed as 'c_" `x` "'",sourcefmt="%(lower)s", rename="c_%s",fullname=1) `x`
%define PHPCN(x)
%keywordwarn("'" `x` "' is a php reserved class name, class renamed as 'c_" `x` "'",%$isclass,rename="c_%s") `x`;
%keywordwarn("'" `x` "' is a php reserved class name, constructor renamed as 'c_" `x` "'",%$isconstructor,rename="c_%s") `x`;
%keywordwarn("'" `x` "' is a PHP reserved class name, class renamed as 'c_" `x` "'",%$isclass,rename="c_%s") `x`;
%keywordwarn("'" `x` "' is a PHP reserved class name, constructor renamed as 'c_" `x` "'",%$isconstructor,rename="c_%s") `x`;
%enddef
#define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in php",sourcefmt="%(lower)s",fullname=1) `x`
#define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in php") "::" `x`
#define PHPBN1(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP",sourcefmt="%(lower)s",fullname=1) `x`
#define PHPBN2(x) %builtinwarn("'" `x` "' conflicts with a built-in name in PHP") "::" `x`
/*
From
http://aspn.activestate.com/ASPN/docs/PHP/reserved.html
http://php.net/manual/en/reserved.keywords.php
and reviewed by Olly Betts.
@ -30,76 +31,81 @@
*/
/* We classify these as kw since PHP will not run if used globally. */
/* "You cannot use any of the following words as constants, class names,
* function or method names. Using them as variable names is generally OK, but
* could lead to confusion."
*/
/* case insensitive */
PHPKW(__halt_compiler);
PHPKW(abstract);
PHPKW(and);
PHPKW(array);
PHPKW(as);
PHPKW(break);
PHPKW(case);
PHPKW(cfunction); /* No longer reserved in PHP5 */
PHPKW(catch);
PHPKW(class);
PHPKW(clone);
PHPKW(const);
PHPKW(continue);
PHPKW(declare);
PHPKW(default);
PHPKW(die);
PHPKW(die); // "Language construct"
PHPKW(do);
PHPKW(echo);
PHPKW(echo); // "Language construct"
PHPKW(else);
PHPKW(elseif);
PHPKW(empty);
PHPKW(empty); // "Language construct"
PHPKW(enddeclare);
PHPKW(endfor);
PHPKW(endforeach);
PHPKW(endif);
PHPKW(endswitch);
PHPKW(endwhile);
PHPKW(eval);
PHPKW(exit);
PHPKW(eval); // "Language construct"
PHPKW(exit); // "Language construct"
PHPKW(extends);
PHPKW(final);
PHPKW(for);
PHPKW(foreach);
PHPKW(function);
PHPKW(global);
PHPKW(goto); // As of PHP5.3
PHPKW(if);
PHPKW(include);
PHPKW(include_once);
PHPKW(isset);
PHPKW(list);
PHPKW(implements);
PHPKW(include); // "Language construct"
PHPKW(include_once); // "Language construct"
PHPKW(instanceof);
PHPKW(interface);
PHPKW(isset); // "Language construct"
PHPKW(list); // "Language construct"
PHPKW(namespace); // As of PHP5.3
PHPKW(new);
// PHPKW(old_function); /* No longer reserved in PHP5 */
PHPKW(or);
PHPKW(print);
PHPKW(require);
PHPKW(require_once);
PHPKW(return);
PHPKW(print); // "Language construct"
PHPKW(private);
PHPKW(protected);
PHPKW(public);
PHPKW(require); // "Language construct"
PHPKW(require_once); // "Language construct"
PHPKW(return); // "Language construct"
PHPKW(static);
PHPKW(switch);
PHPKW(unset);
PHPKW(throw);
PHPKW(try);
PHPKW(unset); // "Language construct"
PHPKW(use);
PHPKW(var);
PHPKW(while);
PHPKW(xor);
PHPKW(__FILE__);
PHPKW(__LINE__);
PHPKW(__FUNCTION__);
// Compile-time constants
PHPKW(__CLASS__);
/* Added in PHP5 */
PHPKW(__halt_compiler);
PHPKW(abstract);
PHPKW(catch);
PHPKW(clone);
PHPKW(final);
PHPKW(implements);
PHPKW(instanceof);
PHPKW(interface);
PHPKW(private);
PHPKW(protected);
PHPKW(public);
PHPKW(throw);
PHPKW(try);
PHPKW(__DIR__); // As of PHP5.3
PHPKW(__FILE__);
PHPKW(__FUNCTION__);
PHPKW(__METHOD__);
PHPKW(__NAMESPACE__); // As of PHP5.3
PHPKW(__LINE__);
/* We classify these as built-in names since they conflict, but PHP still runs */

View file

@ -75,7 +75,7 @@ static int default_error_code = E_ERROR;
/* used to wrap returned objects in so we know whether they are newobject
and need freeing, or not */
typedef struct _swig_object_wrapper {
typedef struct {
void * ptr;
int newobject;
} swig_object_wrapper;

View file

@ -248,13 +248,6 @@
/* please leave 850-869 free for Modula 3 */
/* These are needed for backward compatibility, but you don't need to add
* PHP4 versions of new warnings since existing user interface files can't
* be using them.
*/
#define WARN_PHP_MULTIPLE_INHERITANCE 870
#define WARN_PHP_UNKNOWN_PRAGMA 871
#define WARN_PHP_MULTIPLE_INHERITANCE 870
#define WARN_PHP_UNKNOWN_PRAGMA 871

View file

@ -626,7 +626,7 @@ void note_implicit_template_instantiation(SwigType *t) {
add_defined_foreign_type(0, 0, t, t, implicit_ns ? implicit_ns : current_namespace);
}
String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
/* lookup defined foreign type.
if it exists, it will return a form suitable for placing
into lisp code to generate the def-foreign-type name */
@ -641,18 +641,20 @@ String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
#ifdef ALLEGROCL_TYPE_DEBUG
Printf(stderr, "found_type '%s'\n", found_type);
#endif
return (Strcmp(found_type, "forward-reference") ? Copy(found_type) :
get_ffi_type(fwdref_ffi_type, ""));
return (Strcmp(found_type, "forward-reference") ? Copy(found_type) : get_ffi_type(n, fwdref_ffi_type, ""));
} else {
Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
Node *node = NewHash();
Setattr(node, "type", ty);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup("ffitype", node, name, 0);
Delete(node);
if (tm) {
#ifdef ALLEGROCL_TYPE_DEBUG
Printf(stderr, "g-f-t: found ffitype typemap '%s'\n%s\n", typespec, typemap);
Printf(stderr, "g-f-t: found ffitype typemap '%s'\n", tm);
#endif
return NewString(typespec);
return NewString(tm);
}
if (SwigType_istemplate(ty)) {
@ -673,7 +675,7 @@ String *lookup_defined_foreign_ltype(String *l) {
/* walk type and return string containing lisp version.
recursive. */
String *internal_compose_foreign_type(SwigType *ty) {
String *internal_compose_foreign_type(Node *n, SwigType *ty) {
SwigType *tok;
String *ffiType = NewString("");
@ -691,18 +693,18 @@ String *internal_compose_foreign_type(SwigType *ty) {
Printf(ffiType, "("); // start parm list
for (Iterator i = First(pl); i.item; i = Next(i)) {
SwigType *f_arg = SwigType_strip_qualifiers(i.item);
Printf(ffiType, "%s ", internal_compose_foreign_type(f_arg));
Printf(ffiType, "%s ", internal_compose_foreign_type(n, f_arg));
Delete(f_arg);
}
Printf(ffiType, ")"); // end parm list.
// do function return type.
Printf(ffiType, " %s)", internal_compose_foreign_type(ty));
Printf(ffiType, " %s)", internal_compose_foreign_type(n, ty));
break;
} else if (SwigType_ispointer(tok) || SwigType_isreference(tok)) {
Printf(ffiType, "(* %s)", internal_compose_foreign_type(ty));
Printf(ffiType, "(* %s)", internal_compose_foreign_type(n, ty));
} else if (SwigType_isarray(tok)) {
Printf(ffiType, "(:array %s", internal_compose_foreign_type(ty));
Printf(ffiType, "(:array %s", internal_compose_foreign_type(n, ty));
String *atype = NewString("int");
String *dim = convert_literal(SwigType_array_getdim(tok, 0), atype);
Delete(atype);
@ -713,18 +715,18 @@ String *internal_compose_foreign_type(SwigType *ty) {
}
} else if (SwigType_ismemberpointer(tok)) {
// temp
Printf(ffiType, "(* %s)", internal_compose_foreign_type(ty));
Printf(ffiType, "(* %s)", internal_compose_foreign_type(n, ty));
} else {
String *res = get_ffi_type(tok, "");
String *res = get_ffi_type(n, tok, "");
if (res) {
Printf(ffiType, "%s", res);
} else {
SwigType *resolved_type = SwigType_typedef_resolve(tok);
if (resolved_type) {
res = get_ffi_type(resolved_type, "");
res = get_ffi_type(n, resolved_type, "");
if (res) {
} else {
res = internal_compose_foreign_type(resolved_type);
res = internal_compose_foreign_type(n, resolved_type);
}
if (res)
Printf(ffiType, "%s", res);
@ -762,7 +764,7 @@ String *internal_compose_foreign_type(SwigType *ty) {
add_forward_referenced_type(nn, 0);
// tok_name is dangling here, unused. ouch. why?
Printf(ffiType, "%s", get_ffi_type(tok, ""), tok_name);
Printf(ffiType, "%s", get_ffi_type(n, tok, ""), tok_name);
}
}
}
@ -770,9 +772,7 @@ String *internal_compose_foreign_type(SwigType *ty) {
return ffiType;
}
String *compose_foreign_type(SwigType *ty, String * /*id*/ = 0) {
/* Hash *lookup_res = Swig_typemap_search("ffitype", ty, id, 0); */
String *compose_foreign_type(Node *n, SwigType *ty, String * /*id*/ = 0) {
#ifdef ALLEGROCL_TYPE_DEBUG
Printf(stderr, "compose_foreign_type: ENTER (%s)...\n ", ty);
@ -802,7 +802,7 @@ String *compose_foreign_type(SwigType *ty, String * /*id*/ = 0) {
*/
SwigType *temp = SwigType_strip_qualifiers(ty);
String *res = internal_compose_foreign_type(temp);
String *res = internal_compose_foreign_type(n, temp);
Delete(temp);
#ifdef ALLEGROCL_TYPE_DEBUG
@ -1239,7 +1239,7 @@ void emit_full_class(Node *n) {
#ifdef ALLEGROCL_WRAP_DEBUG
Printf(stderr, "slot name = '%s' ns = '%s' class-of '%s' and type = '%s'\n", cname, ns, name, childType);
#endif
Printf(slotdefs, "(#.(swig-insert-id \"%s\" %s :type :slot :class \"%s\") %s)", cname, ns, name, compose_foreign_type(childType));
Printf(slotdefs, "(#.(swig-insert-id \"%s\" %s :type :slot :class \"%s\") %s)", cname, ns, name, compose_foreign_type(n, childType));
Delete(ns);
if (access && Strcmp(access, "public"))
Printf(slotdefs, " ;; %s member", access);
@ -1322,7 +1322,7 @@ void emit_typedef(Node *n) {
String *name;
String *sym_name = Getattr(n, "sym:name");
String *type = NewStringf("%s%s", Getattr(n, "decl"), Getattr(n, "type"));
String *lisp_type = compose_foreign_type(type);
String *lisp_type = compose_foreign_type(n, type);
Delete(type);
Node *in_class = Getattr(n, "allegrocl:typedef:in-class");
@ -1371,9 +1371,13 @@ void emit_enum_type_no_wrap(Node *n) {
name = unnamed ? Getattr(n, "allegrocl:name") : Getattr(n, "sym:name");
SwigType *tmp = NewStringf("enum %s", unnamed ? unnamed : name);
Hash *typemap = Swig_typemap_search("ffitype", tmp, 0, 0);
String *enumtype = Getattr(typemap, "code");
// enumtype = compose_foreign_type(tmp);
Node *node = NewHash();
Setattr(node, "type", tmp);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *enumtype = Swig_typemap_lookup("ffitype", node, "", 0);
Delete(node);
Delete(tmp);
if (name) {
@ -1427,12 +1431,14 @@ void emit_enum_type(Node *n) {
name = unnamed ? Getattr(n, "allegrocl:name") : Getattr(n, "sym:name");
SwigType *tmp = NewStringf("enum %s", unnamed ? unnamed : name);
// SwigType *tmp = NewStringf("enum ACL_SWIG_ENUM_NAME");
Hash *typemap = Swig_typemap_search("ffitype", tmp, 0, 0);
String *enumtype = Getattr(typemap, "code");
Node *node = NewHash();
Setattr(node, "type", tmp);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *enumtype = Swig_typemap_lookup("ffitype", node, "", 0);
Delete(node);
// enumtype = compose_foreign_type(tmp);
Delete(tmp);
if (name) {
@ -1979,14 +1985,16 @@ int any_varargs(ParmList *pl) {
return 0;
}
String *get_lisp_type(SwigType *ty, const_String_or_char_ptr name) {
Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
return NewString(typespec);
} else {
return NewString("");
}
String *get_lisp_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
Node *node = NewHash();
Setattr(node, "type", ty);
Setattr(node, "name", name);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup("lisptype", node, "", 0);
Delete(node);
return tm ? NewString(tm) : NewString("");
}
Node *parent_node_skipping_extends(Node *n) {
@ -2274,18 +2282,21 @@ int ALLEGROCL::emit_buffered_defuns(Node *n) {
return SWIG_OK;
}
String *dispatching_type(Parm *p) {
String *dispatching_type(Node *n, Parm *p) {
String *result = 0;
String *parsed = Getattr(p, "type"); //Swig_cparse_type(Getattr(p,"tmap:ctype"));
String *cl_t = SwigType_typedef_resolve_all(parsed);
Hash *typemap = Swig_typemap_search("lispclass", parsed, Getattr(p, "name"), 0);
// Printf(stderr,"inspecting type '%s' for class\n", parsed);
// Printf(stderr," cfcocr = '%s' res_all = '%s'\n",
// class_from_class_or_class_ref(parsed), cl_t);
if (typemap) {
result = Copy(Getattr(typemap, "code"));
Node *node = NewHash();
Setattr(node, "type", parsed);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup("lispclass", node, Getattr(p, "name"), 0);
Delete(node);
if (tm) {
result = Copy(tm);
} else {
String *lookup_type = class_from_class_or_class_ref(parsed);
if (lookup_type)
@ -2305,24 +2316,6 @@ String *dispatching_type(Parm *p) {
return result;
}
String *defmethod_lambda_list(Node *overload) {
String *result = NewString("");
ParmList *parms = Getattr(overload, "wrap:parms");
Parm *p;
int a;
for (a = 0, p = parms; p; p = nextSibling(p), ++a) {
if (a != 0)
Printf(result, " ");
Printf(result, "(arg%d ", a);
Printf(result, "%s", dispatching_type(p));
Printf(result, ")");
}
return result;
}
int ALLEGROCL::emit_dispatch_defun(Node *n) {
#ifdef ALLEGROCL_WRAP_DEBUG
Printf(stderr, "emit_dispatch_defun: ENTER... ");
@ -2429,9 +2422,9 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
String *argname = NewStringf("PARM%d_%s", largnum, Getattr(p, "name"));
// Printf(stderr,"%s\n", Getattr(p,"tmap:lin"));
String *ffitype = compose_foreign_type(argtype, Getattr(p,"name"));
String *ffitype = compose_foreign_type(n, argtype, Getattr(p,"name"));
String *deref_ffitype = dereference_ffitype(ffitype);
String *lisptype = get_lisp_type(parmtype, Getattr(p, "name"));
String *lisptype = get_lisp_type(n, parmtype, Getattr(p, "name"));
#ifdef ALLEGROCL_DEBUG
Printf(stderr, "lisptype of '%s' '%s' = '%s'\n", parmtype,
@ -2454,7 +2447,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
Replaceall(wrap->code, "$body", parm_code);
}
String *dispatchtype = Getattr(n, "sym:overloaded") ? dispatching_type(p) : NewString("");
String *dispatchtype = Getattr(n, "sym:overloaded") ? dispatching_type(n, p) : NewString("");
// if this parameter has been removed from the C/++ wrapper
// it shouldn't be in the lisp wrapper either.
@ -2485,13 +2478,13 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
SwigType *parsed = Swig_cparse_type(Getattr(n, "tmap:ctype"));
// SwigType *cl_t = SwigType_typedef_resolve_all(parsed);
SwigType *cl_t = class_from_class_or_class_ref(parsed);
String *out_ffitype = compose_foreign_type(parsed);
String *out_ffitype = compose_foreign_type(n, parsed);
String *deref_out_ffitype;
String *out_temp = Copy(parsed);
if (SwigType_ispointer(out_temp)) {
SwigType_pop(out_temp);
deref_out_ffitype = compose_foreign_type(out_temp);
deref_out_ffitype = compose_foreign_type(n, out_temp);
} else {
deref_out_ffitype = Copy(out_ffitype);
}
@ -2547,7 +2540,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
/////////////////////////////////////////////////////
// Lisp foreign call return type and optimizations //
/////////////////////////////////////////////////////
Printf(fcl, " (:returning (%s %s)", compose_foreign_type(result_type), get_lisp_type(Getattr(n, "type"), "result"));
Printf(fcl, " (:returning (%s %s)", compose_foreign_type(n, result_type), get_lisp_type(n, Getattr(n, "type"), "result"));
for (Iterator option = First(n); option.item; option = Next(option)) {
if (Strncmp("feature:ffargs:", option.key, 15))
@ -2926,10 +2919,6 @@ int ALLEGROCL::variableWrapper(Node *n) {
Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name, ctype, mangled_name, (pointer_added ? "&" : ""), name);
Printf(f_cl, "(swig-defvar \"%s\" :type %s)\n", mangled_name, ((SwigType_isconst(type)) ? ":constant" : ":variable"));
/*
Printf(f_runtime, "// swigtype: %s\n", SwigType_typedef_resolve_all(Getattr(n,"type")));
Printf(f_runtime, "// vwrap: %s\n", compose_foreign_type(SwigType_strip_qualifiers(Copy(rtype))));
*/
Printf(stderr,"***\n");
Delete(mangled_name);
@ -2971,7 +2960,7 @@ int ALLEGROCL::typedefHandler(Node *n) {
SwigType *typedef_type = Getattr(n,"type");
// has the side-effect of noting any implicit
// template instantiations in type.
String *ff_type = compose_foreign_type(typedef_type);
String *ff_type = compose_foreign_type(n, typedef_type);
String *sym_name = Getattr(n, "sym:name");
@ -3132,7 +3121,7 @@ int ALLEGROCL::cppClassHandler(Node *n) {
Printf(stderr, "looking at child '%x' of type '%s'\n", c, childType);
#endif
if (!SwigType_isfunction(childType))
Delete(compose_foreign_type(childType));
Delete(compose_foreign_type(n, childType));
Delete(childType);
}

View file

@ -819,21 +819,24 @@ void CFFI::emit_struct_union(Node *n, bool un = false) {
// Getattr(c, "type"));
// SWIG_exit(EXIT_FAILURE);
} else {
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"),
Getattr(c, "type"));
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"), Getattr(c, "type"));
Hash *typemap = Swig_typemap_search("cin", childType, "", 0);
String *typespec = NewString("");
if (typemap) {
typespec = NewString(Getattr(typemap, "code"));
}
Node *node = NewHash();
Setattr(node, "type", childType);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup("cin", node, "", 0);
String *typespec = tm ? NewString(tm) : NewString("");
String *slot_name = lispify_name(c, Getattr(c, "sym:name"), "'slotname");
if (Strcmp(slot_name, "t") == 0 || Strcmp(slot_name, "T") == 0)
slot_name = NewStringf("t_var");
slot_name = NewStringf("t_var");
Printf(f_cl, "\n\t(%s %s)", slot_name, typespec);
Delete(node);
Delete(childType);
Delete(typespec);
}
}

View file

@ -25,7 +25,7 @@ public:
virtual int typedefHandler(Node *n);
List *entries;
private:
String *get_ffi_type(SwigType *ty);
String *get_ffi_type(Node *n, SwigType *ty);
String *convert_literal(String *num_param, String *type);
String *strip_parens(String *string);
int extern_all_flag;
@ -167,7 +167,7 @@ int CLISP::functionWrapper(Node *n) {
String *argname = Getattr(p, "name");
// SwigType *argtype;
String *ffitype = get_ffi_type(Getattr(p, "type"));
String *ffitype = get_ffi_type(n, Getattr(p, "type"));
int tempargname = 0;
@ -190,7 +190,7 @@ int CLISP::functionWrapper(Node *n) {
if (ParmList_len(pl) != 0) {
Printf(f_cl, ")\n"); /* finish arg list */
}
String *ffitype = get_ffi_type(Getattr(n, "type"));
String *ffitype = get_ffi_type(n, Getattr(n, "type"));
if (Strcmp(ffitype, "NIL")) { //when return type is not nil
Printf(f_cl, "\t(:return-type %s)\n", ffitype);
}
@ -222,7 +222,7 @@ int CLISP::variableWrapper(Node *n) {
return SWIG_OK;
String *var_name = Getattr(n, "sym:name");
String *lisp_type = get_ffi_type(Getattr(n, "type"));
String *lisp_type = get_ffi_type(n, Getattr(n, "type"));
Printf(f_cl, "\n(ffi:def-c-var %s\n (:name \"%s\")\n (:type %s)\n", var_name, var_name, lisp_type);
Printf(f_cl, "\t(:library +library-name+))\n");
Append(entries, var_name);
@ -234,7 +234,7 @@ int CLISP::variableWrapper(Node *n) {
int CLISP::typedefHandler(Node *n) {
if (generate_typedef_flag) {
is_function = 0;
Printf(f_cl, "\n(ffi:def-c-type %s %s)\n", Getattr(n, "name"), get_ffi_type(Getattr(n, "type")));
Printf(f_cl, "\n(ffi:def-c-type %s %s)\n", Getattr(n, "name"), get_ffi_type(n, Getattr(n, "type")));
}
return Language::typedefHandler(n);
@ -290,7 +290,7 @@ int CLISP::classDeclaration(Node *n) {
String *temp = Copy(Getattr(c, "decl"));
Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
String *lisp_type = get_ffi_type(temp);
String *lisp_type = get_ffi_type(n, temp);
Delete(temp);
String *slot_name = Getattr(c, "sym:name");
@ -371,15 +371,20 @@ String *CLISP::convert_literal(String *num_param, String *type) {
return res;
}
String *CLISP::get_ffi_type(SwigType *ty) {
Hash *typemap = Swig_typemap_search("in", ty, "", 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
return NewString(typespec);
String *CLISP::get_ffi_type(Node *n, SwigType *ty) {
Node *node = NewHash();
Setattr(node, "type", ty);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup("in", node, "", 0);
Delete(node);
if (tm) {
return NewString(tm);
} else if (SwigType_ispointer(ty)) {
SwigType *cp = Copy(ty);
SwigType_del_pointer(cp);
String *inner_type = get_ffi_type(cp);
String *inner_type = get_ffi_type(n, cp);
if (SwigType_isfunction(cp)) {
return inner_type;
@ -409,12 +414,12 @@ String *CLISP::get_ffi_type(SwigType *ty) {
Delete(array_dim);
SwigType_del_array(cp);
SwigType_add_pointer(cp);
String *str = get_ffi_type(cp);
String *str = get_ffi_type(n, cp);
Delete(cp);
return str;
} else {
SwigType_pop_arrays(cp);
String *inner_type = get_ffi_type(cp);
String *inner_type = get_ffi_type(n, cp);
Delete(cp);
int ndim = SwigType_array_ndim(ty);
@ -455,7 +460,7 @@ String *CLISP::get_ffi_type(SwigType *ty) {
for (Parm *p = pl; p; p = nextSibling(p), argnum++) {
String *argname = Getattr(p, "name");
SwigType *argtype = Getattr(p, "type");
String *ffitype = get_ffi_type(argtype);
String *ffitype = get_ffi_type(n, argtype);
int tempargname = 0;
@ -475,7 +480,7 @@ String *CLISP::get_ffi_type(SwigType *ty) {
if (ParmList_len(pl) != 0) {
Printf(args, ")\n"); /* finish arg list */
}
String *ffitype = get_ffi_type(cp);
String *ffitype = get_ffi_type(n, cp);
String *str = NewStringf("(ffi:c-function %s \t\t\t\t(:return-type %s))", args, ffitype);
Delete(fn);
Delete(args);

View file

@ -1115,16 +1115,16 @@ public:
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum
// Pure C# baseclass and interfaces
const String *pure_baseclass = typemapLookup("csbase", typemap_lookup_type, WARN_NONE);
const String *pure_interfaces = typemapLookup("csinterfaces", typemap_lookup_type, WARN_NONE);
const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE);
const String *pure_interfaces = typemapLookup(n, "csinterfaces", typemap_lookup_type, WARN_NONE);
// Class attributes
const String *csattributes = typemapLookup("csattributes", typemap_lookup_type, WARN_NONE);
const String *csattributes = typemapLookup(n, "csattributes", typemap_lookup_type, WARN_NONE);
if (csattributes && *Char(csattributes))
Printf(enum_code, "%s\n", csattributes);
// Emit the enum
Printv(enum_code, typemapLookup("csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really)
Printv(enum_code, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really)
" ", symname, (*Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", pure_baseclass, ((*Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces
", " : "", pure_interfaces, " {\n", NIL);
} else {
@ -1140,8 +1140,8 @@ public:
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum
// Finish the enum declaration
// Typemaps are used to generate the enum definition in a similar manner to proxy classes.
Printv(enum_code, (enum_feature == ProperEnum) ? "\n" : typemapLookup("csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
typemapLookup("cscode", typemap_lookup_type, WARN_NONE), // extra C# code
Printv(enum_code, (enum_feature == ProperEnum) ? "\n" : typemapLookup(n, "csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
typemapLookup(n, "cscode", typemap_lookup_type, WARN_NONE), // extra C# code
"}", NIL);
Replaceall(enum_code, "$csclassname", symname);
@ -1177,7 +1177,7 @@ public:
addOpenNamespace(namespce, f_enum);
Printv(f_enum, typemapLookup("csimports", typemap_lookup_type, WARN_NONE), // Import statements
Printv(f_enum, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements
"\n", enum_code, "\n", NIL);
addCloseNamespace(namespce, f_enum);
@ -1243,7 +1243,7 @@ public:
// Wrap C/C++ enums with constant integers or use the typesafe enum pattern
const String *parent_name = Getattr(parentNode(n), "name");
String *typemap_lookup_type = parent_name ? Copy(parent_name) : NewString("int");
const String *tm = typemapLookup("cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF);
const String *tm = typemapLookup(n, "cstype", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSTYPE_UNDEF);
String *return_type = Copy(tm);
Delete(typemap_lookup_type);
typemap_lookup_type = NULL;
@ -1490,12 +1490,12 @@ public:
String *c_baseclass = NULL;
String *baseclass = NULL;
String *c_baseclassname = NULL;
String *typemap_lookup_type = Getattr(n, "classtypeobj");
SwigType *typemap_lookup_type = Getattr(n, "classtypeobj");
bool feature_director = Swig_directorclass(n) ? true : false;
// Inheritance from pure C# classes
Node *attributes = NewHash();
const String *pure_baseclass = typemapLookup("csbase", typemap_lookup_type, WARN_NONE, attributes);
const String *pure_baseclass = typemapLookup(n, "csbase", typemap_lookup_type, WARN_NONE, attributes);
bool purebase_replace = GetFlag(attributes, "tmap:csbase:replace") ? true : false;
bool purebase_notderived = GetFlag(attributes, "tmap:csbase:notderived") ? true : false;
Delete(attributes);
@ -1549,21 +1549,21 @@ public:
}
// Pure C# interfaces
const String *pure_interfaces = typemapLookup(derived ? "csinterfaces_derived" : "csinterfaces", typemap_lookup_type, WARN_NONE);
const String *pure_interfaces = typemapLookup(n, derived ? "csinterfaces_derived" : "csinterfaces", typemap_lookup_type, WARN_NONE);
// Start writing the proxy class
Printv(proxy_class_def, typemapLookup("csimports", typemap_lookup_type, WARN_NONE), // Import statements
Printv(proxy_class_def, typemapLookup(n, "csimports", typemap_lookup_type, WARN_NONE), // Import statements
"\n", NIL);
// Class attributes
const String *csattributes = typemapLookup("csattributes", typemap_lookup_type, WARN_NONE);
const String *csattributes = typemapLookup(n, "csattributes", typemap_lookup_type, WARN_NONE);
if (csattributes && *Char(csattributes))
Printf(proxy_class_def, "%s\n", csattributes);
Printv(proxy_class_def, typemapLookup("csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
Printv(proxy_class_def, typemapLookup(n, "csclassmodifiers", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" $csclassname", // Class name and base class
(*Char(wanted_base) || *Char(pure_interfaces)) ? " : " : "", wanted_base, (*Char(wanted_base) && *Char(pure_interfaces)) ? // Interfaces
", " : "", pure_interfaces, " {", derived ? typemapLookup("csbody_derived", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF) : // main body of class
typemapLookup("csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
", " : "", pure_interfaces, " {", derived ? typemapLookup(n, "csbody_derived", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF) : // main body of class
typemapLookup(n, "csbody", typemap_lookup_type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
NIL);
// C++ destructor is wrapped by the Dispose method
@ -1574,11 +1574,11 @@ public:
String *destruct_methodname = NULL;
String *destruct_methodmodifiers = NULL;
if (derived) {
tm = typemapLookup("csdestruct_derived", typemap_lookup_type, WARN_NONE, attributes);
tm = typemapLookup(n, "csdestruct_derived", typemap_lookup_type, WARN_NONE, attributes);
destruct_methodname = Getattr(attributes, "tmap:csdestruct_derived:methodname");
destruct_methodmodifiers = Getattr(attributes, "tmap:csdestruct_derived:methodmodifiers");
} else {
tm = typemapLookup("csdestruct", typemap_lookup_type, WARN_NONE, attributes);
tm = typemapLookup(n, "csdestruct", typemap_lookup_type, WARN_NONE, attributes);
destruct_methodname = Getattr(attributes, "tmap:csdestruct:methodname");
destruct_methodmodifiers = Getattr(attributes, "tmap:csdestruct:methodmodifiers");
}
@ -1595,7 +1595,7 @@ public:
if (tm) {
// Finalize method
if (*Char(destructor_call)) {
Printv(proxy_class_def, typemapLookup("csfinalize", typemap_lookup_type, WARN_NONE), NIL);
Printv(proxy_class_def, typemapLookup(n, "csfinalize", typemap_lookup_type, WARN_NONE), NIL);
}
// Dispose method
Printv(destruct, tm, NIL);
@ -1690,7 +1690,7 @@ public:
Delete(destruct);
// Emit extra user code
Printv(proxy_class_def, typemapLookup("cscode", typemap_lookup_type, WARN_NONE), // extra C# code
Printv(proxy_class_def, typemapLookup(n, "cscode", typemap_lookup_type, WARN_NONE), // extra C# code
"\n", NIL);
// Substitute various strings into the above template
@ -2355,7 +2355,7 @@ public:
/* Insert the csconstruct typemap, doing the replacement for $directorconnect, as needed */
Hash *attributes = NewHash();
String *construct_tm = Copy(typemapLookup("csconstruct", Getattr(n, "name"),
String *construct_tm = Copy(typemapLookup(n, "csconstruct", Getattr(n, "name"),
WARN_CSHARP_TYPEMAP_CSCONSTRUCT_UNDEF, attributes));
if (construct_tm) {
if (!feature_director) {
@ -2972,6 +2972,10 @@ public:
* ----------------------------------------------------------------------------- */
void emitTypeWrapperClass(String *classname, SwigType *type) {
Node *n = NewHash();
Setfile(n, input_file);
Setline(n, line_number);
String *swigtype = NewString("");
String *filen = NewStringf("%s%s.cs", SWIG_output_directory(), classname);
File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
@ -2989,23 +2993,23 @@ public:
addOpenNamespace(namespce, f_swigtype);
// Pure C# baseclass and interfaces
const String *pure_baseclass = typemapLookup("csbase", type, WARN_NONE);
const String *pure_interfaces = typemapLookup("csinterfaces", type, WARN_NONE);
const String *pure_baseclass = typemapLookup(n, "csbase", type, WARN_NONE);
const String *pure_interfaces = typemapLookup(n, "csinterfaces", type, WARN_NONE);
// Emit the class
Printv(swigtype, typemapLookup("csimports", type, WARN_NONE), // Import statements
Printv(swigtype, typemapLookup(n, "csimports", type, WARN_NONE), // Import statements
"\n", NIL);
// Class attributes
const String *csattributes = typemapLookup("csattributes", type, WARN_NONE);
const String *csattributes = typemapLookup(n, "csattributes", type, WARN_NONE);
if (csattributes && *Char(csattributes))
Printf(swigtype, "%s\n", csattributes);
Printv(swigtype, typemapLookup("csclassmodifiers", type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
Printv(swigtype, typemapLookup(n, "csclassmodifiers", type, WARN_CSHARP_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" $csclassname", // Class name and base class
(*Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", pure_baseclass, ((*Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces
", " : "", pure_interfaces, " {", typemapLookup("csbody", type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
typemapLookup("cscode", type, WARN_NONE), // extra C# code
", " : "", pure_interfaces, " {", typemapLookup(n, "csbody", type, WARN_CSHARP_TYPEMAP_CSBODY_UNDEF), // main body of class
typemapLookup(n, "cscode", type, WARN_NONE), // extra C# code
"}\n", NIL);
Replaceall(swigtype, "$csclassname", classname);
@ -3019,29 +3023,34 @@ public:
Close(f_swigtype);
Delete(swigtype);
Delete(n);
}
/* -----------------------------------------------------------------------------
* typemapLookup()
* n - for input only and must contain info for Getfile(n) and Getline(n) to work
* op - typemap method name
* type - typemap type to lookup
* warning - warning number to issue if no typemaps found
* typemap_attributes - the typemap attributes are attached to this node and will
* also be used for temporary storage if non null
* return is never NULL, unlike Swig_typemap_lookup()
* ----------------------------------------------------------------------------- */
const String *typemapLookup(const String *op, String *type, int warning, Node *typemap_attributes = NULL) {
String *tm = NULL;
const String *code = NULL;
if ((tm = Swig_typemap_search(op, type, NULL, NULL))) {
code = Getattr(tm, "code");
if (typemap_attributes)
Swig_typemap_attach_kwargs(tm, op, typemap_attributes);
}
if (!code) {
code = empty_string;
const String *typemapLookup(Node *n, const_String_or_char_ptr op, SwigType *type, int warning, Node *typemap_attributes = 0) {
Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
Setattr(node, "type", type);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup(op, node, "", 0);
if (!tm) {
tm = empty_string;
if (warning != WARN_NONE)
Swig_warning(warning, input_file, line_number, "No %s typemap defined for %s\n", op, type);
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", op, SwigType_str(type, 0));
}
return code ? code : empty_string;
if (!typemap_attributes)
Delete(node);
return tm;
}
/* -----------------------------------------------------------------------------
@ -3820,7 +3829,7 @@ public:
Node *disconn_attr = NewHash();
String *disconn_methodname = NULL;
disconn_tm = typemapLookup("directordisconnect", full_classname, WARN_NONE, disconn_attr);
disconn_tm = typemapLookup(n, "directordisconnect", full_classname, WARN_NONE, disconn_attr);
disconn_methodname = Getattr(disconn_attr, "tmap:directordisconnect:methodname");
Printv(w->code, "}\n", NIL);

View file

@ -1171,11 +1171,11 @@ public:
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum
// Pure Java baseclass and interfaces
const String *pure_baseclass = typemapLookup("javabase", typemap_lookup_type, WARN_NONE);
const String *pure_interfaces = typemapLookup("javainterfaces", typemap_lookup_type, WARN_NONE);
const String *pure_baseclass = typemapLookup(n, "javabase", typemap_lookup_type, WARN_NONE);
const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE);
// Emit the enum
Printv(enum_code, typemapLookup("javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really)
Printv(enum_code, typemapLookup(n, "javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers (enum modifiers really)
" ", symname, *Char(pure_baseclass) ? // Bases
" extends " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces
" implements " : "", pure_interfaces, " {\n", NIL);
@ -1196,8 +1196,8 @@ public:
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum
// Finish the enum declaration
// Typemaps are used to generate the enum definition in a similar manner to proxy classes.
Printv(enum_code, (enum_feature == ProperEnum) ? ";\n" : "", typemapLookup("javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
typemapLookup("javacode", typemap_lookup_type, WARN_NONE), // extra Java code
Printv(enum_code, (enum_feature == ProperEnum) ? ";\n" : "", typemapLookup(n, "javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
typemapLookup(n, "javacode", typemap_lookup_type, WARN_NONE), // extra Java code
"}", NIL);
Replaceall(enum_code, "$javaclassname", symname);
@ -1234,7 +1234,7 @@ public:
if (Len(package) > 0)
Printf(f_enum, "package %s;\n", package);
Printv(f_enum, typemapLookup("javaimports", typemap_lookup_type, WARN_NONE), // Import statements
Printv(f_enum, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE), // Import statements
"\n", enum_code, "\n", NIL);
Printf(f_enum, "\n");
@ -1295,7 +1295,7 @@ public:
// Wrap C/C++ enums with constant integers or use the typesafe enum pattern
const String *parent_name = Getattr(parentNode(n), "name");
String *typemap_lookup_type = parent_name ? Copy(parent_name) : NewString("int");
const String *tm = typemapLookup("jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF);
const String *tm = typemapLookup(n, "jstype", typemap_lookup_type, WARN_JAVA_TYPEMAP_JSTYPE_UNDEF);
String *return_type = Copy(tm);
Delete(typemap_lookup_type);
typemap_lookup_type = NULL;
@ -1560,12 +1560,12 @@ public:
String *c_baseclass = NULL;
String *baseclass = NULL;
String *c_baseclassname = NULL;
String *typemap_lookup_type = Getattr(n, "classtypeobj");
SwigType *typemap_lookup_type = Getattr(n, "classtypeobj");
bool feature_director = Swig_directorclass(n) ? true : false;
// Inheritance from pure Java classes
Node *attributes = NewHash();
const String *pure_baseclass = typemapLookup("javabase", typemap_lookup_type, WARN_NONE, attributes);
const String *pure_baseclass = typemapLookup(n, "javabase", typemap_lookup_type, WARN_NONE, attributes);
bool purebase_replace = GetFlag(attributes, "tmap:javabase:replace") ? true : false;
bool purebase_notderived = GetFlag(attributes, "tmap:javabase:notderived") ? true : false;
Delete(attributes);
@ -1619,15 +1619,15 @@ public:
}
// Pure Java interfaces
const String *pure_interfaces = typemapLookup("javainterfaces", typemap_lookup_type, WARN_NONE);
const String *pure_interfaces = typemapLookup(n, "javainterfaces", typemap_lookup_type, WARN_NONE);
// Start writing the proxy class
Printv(proxy_class_def, typemapLookup("javaimports", typemap_lookup_type, WARN_NONE), // Import statements
"\n", typemapLookup("javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
Printv(proxy_class_def, typemapLookup(n, "javaimports", typemap_lookup_type, WARN_NONE), // Import statements
"\n", typemapLookup(n, "javaclassmodifiers", typemap_lookup_type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" $javaclassname", // Class name and bases
(*Char(wanted_base)) ? " extends " : "", wanted_base, *Char(pure_interfaces) ? // Pure Java interfaces
" implements " : "", pure_interfaces, " {", derived ? typemapLookup("javabody_derived", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) : // main body of class
typemapLookup("javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
" implements " : "", pure_interfaces, " {", derived ? typemapLookup(n, "javabody_derived", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF) : // main body of class
typemapLookup(n, "javabody", typemap_lookup_type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
NIL);
// C++ destructor is wrapped by the delete method
@ -1638,11 +1638,11 @@ public:
String *destruct_methodname = NULL;
String *destruct_methodmodifiers = NULL;
if (derived) {
tm = typemapLookup("javadestruct_derived", typemap_lookup_type, WARN_NONE, attributes);
tm = typemapLookup(n, "javadestruct_derived", typemap_lookup_type, WARN_NONE, attributes);
destruct_methodname = Getattr(attributes, "tmap:javadestruct_derived:methodname");
destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct_derived:methodmodifiers");
} else {
tm = typemapLookup("javadestruct", typemap_lookup_type, WARN_NONE, attributes);
tm = typemapLookup(n, "javadestruct", typemap_lookup_type, WARN_NONE, attributes);
destruct_methodname = Getattr(attributes, "tmap:javadestruct:methodname");
destruct_methodmodifiers = Getattr(attributes, "tmap:javadestruct:methodmodifiers");
}
@ -1660,7 +1660,7 @@ public:
if (tm) {
// Finalize method
if (*Char(destructor_call)) {
Printv(proxy_class_def, typemapLookup("javafinalize", typemap_lookup_type, WARN_NONE), NIL);
Printv(proxy_class_def, typemapLookup(n, "javafinalize", typemap_lookup_type, WARN_NONE), NIL);
}
// delete method
Printv(destruct, tm, NIL);
@ -1681,9 +1681,9 @@ public:
release_jnicall = NewStringf("%s.%s_change_ownership(this, swigCPtr, false)", imclass_name, proxy_class_name);
take_jnicall = NewStringf("%s.%s_change_ownership(this, swigCPtr, true)", imclass_name, proxy_class_name);
emitCodeTypemap(false, typemap_lookup_type, "directordisconnect", "methodname", destruct_jnicall);
emitCodeTypemap(false, typemap_lookup_type, "directorowner_release", "methodname", release_jnicall);
emitCodeTypemap(false, typemap_lookup_type, "directorowner_take", "methodname", take_jnicall);
emitCodeTypemap(n, false, typemap_lookup_type, "directordisconnect", "methodname", destruct_jnicall);
emitCodeTypemap(n, false, typemap_lookup_type, "directorowner_release", "methodname", release_jnicall);
emitCodeTypemap(n, false, typemap_lookup_type, "directorowner_take", "methodname", take_jnicall);
Delete(destruct_jnicall);
Delete(release_jnicall);
@ -1694,7 +1694,7 @@ public:
Delete(destruct);
// Emit extra user code
Printv(proxy_class_def, typemapLookup("javacode", typemap_lookup_type, WARN_NONE), // extra Java code
Printv(proxy_class_def, typemapLookup(n, "javacode", typemap_lookup_type, WARN_NONE), // extra Java code
"\n", NIL);
// Substitute various strings into the above template
@ -2285,7 +2285,7 @@ public:
/* Insert the javaconstruct typemap, doing the replacement for $directorconnect, as needed */
Hash *attributes = NewHash();
String *construct_tm = Copy(typemapLookup("javaconstruct", Getattr(n, "name"),
String *construct_tm = Copy(typemapLookup(n, "javaconstruct", Getattr(n, "name"),
WARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF, attributes));
if (construct_tm) {
if (!feature_director) {
@ -2815,6 +2815,10 @@ public:
* ----------------------------------------------------------------------------- */
void emitTypeWrapperClass(String *classname, SwigType *type) {
Node *n = NewHash();
Setfile(n, input_file);
Setline(n, line_number);
String *swigtype = NewString("");
String *filen = NewStringf("%s%s.java", SWIG_output_directory(), classname);
File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
@ -2833,16 +2837,16 @@ public:
Printf(f_swigtype, "package %s;\n", package);
// Pure Java baseclass and interfaces
const String *pure_baseclass = typemapLookup("javabase", type, WARN_NONE);
const String *pure_interfaces = typemapLookup("javainterfaces", type, WARN_NONE);
const String *pure_baseclass = typemapLookup(n, "javabase", type, WARN_NONE);
const String *pure_interfaces = typemapLookup(n, "javainterfaces", type, WARN_NONE);
// Emit the class
Printv(swigtype, typemapLookup("javaimports", type, WARN_NONE), // Import statements
"\n", typemapLookup("javaclassmodifiers", type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
Printv(swigtype, typemapLookup(n, "javaimports", type, WARN_NONE), // Import statements
"\n", typemapLookup(n, "javaclassmodifiers", type, WARN_JAVA_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" $javaclassname", // Class name and bases
*Char(pure_baseclass) ? " extends " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces
" implements " : "", pure_interfaces, " {", typemapLookup("javabody", type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
typemapLookup("javacode", type, WARN_NONE), // extra Java code
" implements " : "", pure_interfaces, " {", typemapLookup(n, "javabody", type, WARN_JAVA_TYPEMAP_JAVABODY_UNDEF), // main body of class
typemapLookup(n, "javacode", type, WARN_NONE), // extra Java code
"}\n", "\n", NIL);
Replaceall(swigtype, "$javaclassname", classname);
@ -2852,29 +2856,34 @@ public:
Close(f_swigtype);
Delete(swigtype);
Delete(n);
}
/* -----------------------------------------------------------------------------
* typemapLookup()
* n - for input only and must contain info for Getfile(n) and Getline(n) to work
* op - typemap method name
* type - typemap type to lookup
* warning - warning number to issue if no typemaps found
* typemap_attributes - the typemap attributes are attached to this node and will
* also be used for temporary storage if non null
* return is never NULL, unlike Swig_typemap_lookup()
* ----------------------------------------------------------------------------- */
const String *typemapLookup(const String *op, String *type, int warning, Node *typemap_attributes = NULL) {
String *tm = NULL;
const String *code = NULL;
if ((tm = Swig_typemap_search(op, type, NULL, NULL))) {
code = Getattr(tm, "code");
if (typemap_attributes)
Swig_typemap_attach_kwargs(tm, op, typemap_attributes);
}
if (!code) {
code = empty_string;
const String *typemapLookup(Node *n, const_String_or_char_ptr op, SwigType *type, int warning, Node *typemap_attributes = 0) {
Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
Setattr(node, "type", type);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup(op, node, "", 0);
if (!tm) {
tm = empty_string;
if (warning != WARN_NONE)
Swig_warning(warning, input_file, line_number, "No %s typemap defined for %s\n", op, type);
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", op, SwigType_str(type, 0));
}
return code ? code : empty_string;
if (!typemap_attributes)
Delete(node);
return tm;
}
/* -----------------------------------------------------------------------------
@ -3183,8 +3192,7 @@ public:
* typemaps.
*--------------------------------------------------------------------*/
void
emitCodeTypemap(bool derived, String *lookup_type, const String *typemap, const String *methodname, const String *jnicall) {
void emitCodeTypemap(Node *n, bool derived, SwigType *lookup_type, const String *typemap, const String *methodname, const String *jnicall) {
const String *tm = NULL;
Node *tmattrs = NewHash();
String *lookup_tmname = NewString(typemap);
@ -3195,7 +3203,7 @@ public:
Append(lookup_tmname, "_derived");
}
tm = typemapLookup(lookup_tmname, lookup_type, WARN_NONE, tmattrs);
tm = typemapLookup(n, lookup_tmname, lookup_type, WARN_NONE, tmattrs);
method_attr_name = NewStringf("tmap:%s:%s", lookup_tmname, methodname);
method_attr = Getattr(tmattrs, method_attr_name);
@ -3979,7 +3987,7 @@ public:
Node *disconn_attr = NewHash();
String *disconn_methodname = NULL;
disconn_tm = typemapLookup("directordisconnect", full_classname, WARN_NONE, disconn_attr);
disconn_tm = typemapLookup(n, "directordisconnect", full_classname, WARN_NONE, disconn_attr);
disconn_methodname = Getattr(disconn_attr, "tmap:directordisconnect:methodname");
Printv(w->code, " swig_disconnect_director_self(\"", disconn_methodname, "\");\n", "}\n", NIL);

View file

@ -2230,23 +2230,23 @@ MODULA3():
baseclass = NewString("");
// Inheritance from pure Modula 3 classes
const String *pure_baseclass = typemapLookup("m3base", classDeclarationName, WARN_NONE);
const String *pure_baseclass = typemapLookup(n, "m3base", classDeclarationName, WARN_NONE);
if (hasContent(pure_baseclass) && hasContent(baseclass)) {
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, input_file,
line_number,
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", classDeclarationName, pure_baseclass);
}
// Pure Modula 3 interfaces
const String *pure_interfaces = typemapLookup(derived ? "m3interfaces_derived" : "m3interfaces",
const String *pure_interfaces = typemapLookup(n, derived ? "m3interfaces_derived" : "m3interfaces",
classDeclarationName, WARN_NONE);
// Start writing the proxy class
Printv(proxy_class_def, typemapLookup("m3imports", classDeclarationName, WARN_NONE), // Import statements
"\n", typemapLookup("m3classmodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
Printv(proxy_class_def, typemapLookup(n, "m3imports", classDeclarationName, WARN_NONE), // Import statements
"\n", typemapLookup(n, "m3classmodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" class $m3classname", // Class name and bases
(derived || *Char(pure_baseclass) || *Char(pure_interfaces)) ? " : " : "", baseclass, pure_baseclass, ((derived || *Char(pure_baseclass)) && *Char(pure_interfaces)) ? // Interfaces
", " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", // Member variables for memory handling
derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup("m3ptrconstructormodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
" $m3classname(IntPtr cPtr, bool cMemoryOwn) ", // Constructor used for wrapping pointers
derived ?
": base($imclassname.$m3classnameTo$baseclass(cPtr), cMemoryOwn) {\n"
@ -2262,10 +2262,10 @@ MODULA3():
Node *attributes = NewHash();
String *destruct_methodname = NULL;
if (derived) {
tm = typemapLookup("m3destruct_derived", classDeclarationName, WARN_NONE, attributes);
tm = typemapLookup(n, "m3destruct_derived", classDeclarationName, WARN_NONE, attributes);
destruct_methodname = Getattr(attributes, "tmap:m3destruct_derived:methodname");
} else {
tm = typemapLookup("m3destruct", classDeclarationName, WARN_NONE, attributes);
tm = typemapLookup(n, "m3destruct", classDeclarationName, WARN_NONE, attributes);
destruct_methodname = Getattr(attributes, "tmap:m3destruct:methodname");
}
if (!destruct_methodname) {
@ -2275,7 +2275,7 @@ MODULA3():
if (tm) {
// Finalize method
if (*Char(destructor_call)) {
Printv(proxy_class_def, typemapLookup("m3finalize", classDeclarationName, WARN_NONE), NIL);
Printv(proxy_class_def, typemapLookup(n, "m3finalize", classDeclarationName, WARN_NONE), NIL);
}
// Dispose method
Printv(destruct, tm, NIL);
@ -2290,8 +2290,8 @@ MODULA3():
Delete(destruct);
// Emit various other methods
Printv(proxy_class_def, typemapLookup("m3getcptr", classDeclarationName, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
typemapLookup("m3code", classDeclarationName, WARN_NONE), // extra Modula 3 code
Printv(proxy_class_def, typemapLookup(n, "m3getcptr", classDeclarationName, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
typemapLookup(n, "m3code", classDeclarationName, WARN_NONE), // extra Modula 3 code
"\n", NIL);
// Substitute various strings into the above template
@ -3765,6 +3765,10 @@ MODULA3():
* ----------------------------------------------------------------------------- */
void emitTypeWrapperClass(String *classname, SwigType *type) {
Node *n = NewHash();
Setfile(n, input_file);
Setline(n, line_number);
String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), classname);
File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
if (!f_swigtype) {
@ -3777,19 +3781,19 @@ MODULA3():
emitBanner(f_swigtype);
// Pure Modula 3 baseclass and interfaces
const String *pure_baseclass = typemapLookup("m3base", type, WARN_NONE);
const String *pure_interfaces = typemapLookup("m3interfaces", type, WARN_NONE);
const String *pure_baseclass = typemapLookup(n, "m3base", type, WARN_NONE);
const String *pure_interfaces = typemapLookup(n, "m3interfaces", type, WARN_NONE);
// Emit the class
Printv(swigtype, typemapLookup("m3imports", type, WARN_NONE), // Import statements
"\n", typemapLookup("m3classmodifiers", type, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
Printv(swigtype, typemapLookup(n, "m3imports", type, WARN_NONE), // Import statements
"\n", typemapLookup(n, "m3classmodifiers", type, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
" class $m3classname", // Class name and bases
*Char(pure_baseclass) ? " : " : "", pure_baseclass, *Char(pure_interfaces) ? // Interfaces
" : " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", "\n", " ", typemapLookup("m3ptrconstructormodifiers", type, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
" : " : "", pure_interfaces, " {\n", " private IntPtr swigCPtr;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", type, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
" $m3classname(IntPtr cPtr, bool bFutureUse) {\n", // Constructor used for wrapping pointers
" swigCPtr = cPtr;\n", " }\n", "\n", " protected $m3classname() {\n", // Default constructor
" swigCPtr = IntPtr.Zero;\n", " }\n", typemapLookup("m3getcptr", type, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
typemapLookup("m3code", type, WARN_NONE), // extra Modula 3 code
" swigCPtr = IntPtr.Zero;\n", " }\n", typemapLookup(n, "m3getcptr", type, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
typemapLookup(n, "m3code", type, WARN_NONE), // extra Modula 3 code
"}\n", "\n", NIL);
Replaceall(swigtype, "$m3classname", classname);
@ -3802,25 +3806,29 @@ MODULA3():
/* -----------------------------------------------------------------------------
* typemapLookup()
* n - for input only and must contain info for Getfile(n) and Getline(n) to work
* op - typemap method name
* type - typemap type to lookup
* warning - warning number to issue if no typemaps found
* typemap_attributes - the typemap attributes are attached to this node and will
* also be used for temporary storage if non null
* return is never NULL, unlike Swig_typemap_lookup()
* ----------------------------------------------------------------------------- */
const String *typemapLookup(const String *op, String *type, int warning, Node *typemap_attributes = NULL) {
String *tm = NULL;
const String *code = NULL;
if ((tm = Swig_typemap_search(op, type, NULL, NULL))) {
code = Getattr(tm, "code");
if (typemap_attributes)
Swig_typemap_attach_kwargs(tm, op, typemap_attributes);
}
if (!code) {
code = empty_string;
const String *typemapLookup(Node *n, const_String_or_char_ptr op, SwigType *type, int warning, Node *typemap_attributes = 0) {
Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
Setattr(node, "type", type);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup(op, node, "", 0);
if (!tm) {
tm = empty_string;
if (warning != WARN_NONE)
Swig_warning(warning, input_file, line_number, "No %s typemap defined for %s\n", op, type);
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", op, SwigType_str(type, 0));
}
return code ? code : empty_string;
if (!typemap_attributes)
Delete(node);
return tm;
}
/* -----------------------------------------------------------------------------

View file

@ -13,7 +13,8 @@ char cvsroot_octave_cxx[] = "$Id$";
static const char *usage = (char *) "\
Octave Options (available with -octave)\n\
(none yet)\n\n";
-api <N> - Generate code that assumes Octave API N [default: 37]\n\
\n";
class OCTAVE:public Language {
@ -35,6 +36,8 @@ private:
int have_destructor;
String *constructor_name;
int api_version;
Hash *docs;
public:
@ -53,6 +56,7 @@ public:
director_multiple_inheritance = 1;
director_language = 1;
docs = NewHash();
api_version = 37;
}
virtual void main(int argc, char *argv[]) {
@ -60,6 +64,15 @@ public:
if (argv[i]) {
if (strcmp(argv[i], "-help") == 0) {
fputs(usage, stderr);
} else if (strcmp(argv[i], "-api") == 0) {
if (argv[i + 1]) {
api_version = atoi(argv[i + 1]);
Swig_mark_arg(i);
Swig_mark_arg(i + 1);
i++;
} else {
Swig_arg_error();
}
}
}
}
@ -125,6 +138,7 @@ public:
Printf(f_runtime, "#define SWIGOCTAVE\n");
Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module);
Printf(f_runtime, "#define SWIG_name %s\n", module);
Printf(f_runtime, "#define USE_OCTAVE_API_VERSION %i\n", api_version);
if (directorsEnabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");

View file

@ -1511,7 +1511,7 @@ public:
Printf(pcode, "sub new {\n");
} else {
/* Constructor doesn't match classname so we'll just use the normal name */
Printv(pcode, "sub ", Swig_name_construct(symname), " () {\n", NIL);
Printv(pcode, "sub ", Swig_name_construct(symname), " {\n", NIL);
}
Printv(pcode,

View file

@ -322,7 +322,7 @@ public:
Printf(f_phpcode, "\n");
Printf(f_phpcode, "// Try to load our extension if it's not already loaded.\n");
Printf(f_phpcode, "if (!extension_loaded(\"%s\")) {\n", module);
Printf(f_phpcode, "if (!extension_loaded('%s')) {\n", module);
Printf(f_phpcode, " if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {\n");
Printf(f_phpcode, " if (!dl('php_%s.dll')) return;\n", module);
Printf(f_phpcode, " } else {\n");
@ -1383,7 +1383,7 @@ public:
SwigType *t = Getattr(current_class, "classtype");
String *mangled_type = SwigType_manglestr(SwigType_ltype(t));
Printf(output, "\tfunction %s(%s) {\n", methodname, args);
Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) == \"_p%s\") {\n", arg0, arg0, mangled_type);
Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) == '_p%s') {\n", arg0, arg0, mangled_type);
Printf(output, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg0);
Printf(output, "\t\t\treturn;\n");
Printf(output, "\t\t}\n");
@ -1433,7 +1433,7 @@ public:
class_node = Getattr(zend_types, mangled);
}
if (i.item) {
Printf(output, "case \"%s\": ", mangled);
Printf(output, "case '%s': ", mangled);
} else {
Printf(output, "default: ");
}
@ -1603,7 +1603,7 @@ public:
}
} else if (Strcmp(type, "include") == 0) {
if (value) {
Printf(pragma_incl, "include \"%s\";\n", value);
Printf(pragma_incl, "include '%s';\n", value);
}
} else if (Strcmp(type, "phpinfo") == 0) {
if (value) {

View file

@ -1913,7 +1913,7 @@ public:
Printv(f->def, "SWIGINTERN PyObject *", wname, "__varargs__", "(PyObject *SWIGUNUSEDPARM(self), PyObject *args, PyObject *varargs) {", NIL);
}
if (allow_kwargs) {
Swig_warning(WARN_LANG_OVERLOAD_KEYWORD, input_file, line_number, "Can't use keyword arguments with overloaded functions.\n");
Swig_warning(WARN_LANG_OVERLOAD_KEYWORD, input_file, line_number, "Can't use keyword arguments with overloaded functions (%s).\n", Swig_name_decl(n));
allow_kwargs = 0;
}
} else {

View file

@ -131,11 +131,17 @@ static void add_defined_foreign_type(String *type) {
}
static String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
Hash *typemap = Swig_typemap_search("ffitype", ty, name, 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
return NewString(typespec);
static String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
Node *node = NewHash();
Setattr(node, "type", ty);
Setattr(node, "name", name);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup("ffitype", node, "", 0);
Delete(node);
if (tm) {
return NewString(tm);
} else {
SwigType *tr = SwigType_typedef_resolve_all(ty);
char *type_reduced = Char(tr);
@ -167,14 +173,16 @@ static String *get_ffi_type(SwigType *ty, const_String_or_char_ptr name) {
return 0;
}
static String *get_lisp_type(SwigType *ty, const_String_or_char_ptr name) {
Hash *typemap = Swig_typemap_search("lisptype", ty, name, 0);
if (typemap) {
String *typespec = Getattr(typemap, "code");
return NewString(typespec);
} else {
return NewString("");
}
static String *get_lisp_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
Node *node = NewHash();
Setattr(node, "type", ty);
Setattr(node, "name", name);
Setfile(node, Getfile(n));
Setline(node, Getline(n));
const String *tm = Swig_typemap_lookup("lisptype", node, "", 0);
Delete(node);
return tm ? NewString(tm) : NewString("");
}
void UFFI::main(int argc, char *argv[]) {
@ -280,8 +288,8 @@ int UFFI::functionWrapper(Node *n) {
for (p = pl; p; p = nextSibling(p), argnum++) {
String *argname = Getattr(p, "name");
SwigType *argtype = Getattr(p, "type");
String *ffitype = get_ffi_type(argtype, argname);
String *lisptype = get_lisp_type(argtype, argname);
String *ffitype = get_ffi_type(n, argtype, argname);
String *lisptype = get_lisp_type(n, argtype, argname);
int tempargname = 0;
if (!argname) {
@ -307,7 +315,7 @@ int UFFI::functionWrapper(Node *n) {
//" :strings-convert t\n"
//" :call-direct %s\n"
//" :optimize-for-space t"
")\n", get_ffi_type(Getattr(n, "type"), "result")
")\n", get_ffi_type(n, Getattr(n, "type"), "result")
//,varargs ? "nil" : "t"
);
@ -361,7 +369,7 @@ int UFFI::classHandler(Node *n) {
/* Printf(stdout, "Converting %s in %s\n", type, name); */
lisp_type = get_ffi_type(type, Getattr(c, "sym:name"));
lisp_type = get_ffi_type(n, type, Getattr(c, "sym:name"));
Printf(f_cl, " (#.(%s \"%s\" :type :slot) %s)\n", identifier_converter, Getattr(c, "sym:name"), lisp_type);

View file

@ -370,11 +370,8 @@ extern int ParmList_is_compactdefargs(ParmList *p);
extern void Swig_typemap_clear_apply(ParmList *pattern);
extern void Swig_typemap_debug(void);
extern Hash *Swig_typemap_search(const_String_or_char_ptr op, SwigType *type, const_String_or_char_ptr pname, SwigType **matchtype);
extern Hash *Swig_typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch);
extern String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *n, const_String_or_char_ptr lname, Wrapper *f);
extern String *Swig_typemap_lookup_out(const_String_or_char_ptr op, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode);
extern void Swig_typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p);
extern void Swig_typemap_new_scope(void);
extern Hash *Swig_typemap_pop_scope(void);

View file

@ -114,7 +114,7 @@ static String *tmop_name(const_String_or_char_ptr op) {
we have to make sure that we only intern strings without object
identity into the hash table.
(Swig_typemap_attach_kwargs calls tmop_name several times with
(typemap_attach_kwargs calls tmop_name several times with
the "same" String *op (i.e., same object identity) but differing
string values.)
@ -134,6 +134,7 @@ static String *tmop_name(const_String_or_char_ptr op) {
return s;
}
#if 0
/* -----------------------------------------------------------------------------
* Swig_typemap_new_scope()
*
@ -157,6 +158,7 @@ Hash *Swig_typemap_pop_scope() {
}
return 0;
}
#endif
/* -----------------------------------------------------------------------------
* Swig_typemap_register()
@ -265,12 +267,12 @@ void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_S
}
/* -----------------------------------------------------------------------------
* Swig_typemap_get()
* typemap_get()
*
* Retrieve typemap information from current scope.
* ----------------------------------------------------------------------------- */
static Hash *Swig_typemap_get(SwigType *type, const_String_or_char_ptr name, int scope) {
static Hash *typemap_get(SwigType *type, const_String_or_char_ptr name, int scope) {
Hash *tm, *tm1;
/* See if this type has been seen before */
if ((scope < 0) || (scope > tm_scope))
@ -312,7 +314,7 @@ int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList
pname = Getattr(p, "name");
/* Lookup the type */
tm = Swig_typemap_get(ptype, pname, ts);
tm = typemap_get(ptype, pname, ts);
if (!tm)
break;
@ -360,7 +362,7 @@ void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) {
while (p) {
type = Getattr(p, "type");
name = Getattr(p, "name");
tm = Swig_typemap_get(type, name, tm_scope);
tm = typemap_get(type, name, tm_scope);
if (!tm)
return;
p = nextSibling(p);
@ -385,8 +387,7 @@ void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) {
* it works.
* ----------------------------------------------------------------------------- */
static
int count_args(String *s) {
static int count_args(String *s) {
/* Count up number of arguments */
int na = 0;
char *c = Char(s);
@ -456,7 +457,7 @@ int Swig_typemap_apply(ParmList *src, ParmList *dest) {
while (ts >= 0) {
/* See if there is a matching typemap in this scope */
sm = Swig_typemap_get(type, name, ts);
sm = typemap_get(type, name, ts);
/* if there is not matching, look for a typemap in the
original typedef, if any, like in:
@ -468,7 +469,7 @@ int Swig_typemap_apply(ParmList *src, ParmList *dest) {
if (!sm) {
SwigType *ntype = SwigType_typedef_resolve(type);
if (ntype && (Cmp(ntype, type) != 0)) {
sm = Swig_typemap_get(ntype, name, ts);
sm = typemap_get(ntype, name, ts);
}
Delete(ntype);
}
@ -584,13 +585,13 @@ static SwigType *strip_arrays(SwigType *type) {
}
/* -----------------------------------------------------------------------------
* Swig_typemap_search()
* typemap_search()
*
* Search for a typemap match. Tries to find the most specific typemap
* that includes a 'code' attribute.
* ----------------------------------------------------------------------------- */
Hash *Swig_typemap_search(const_String_or_char_ptr op, SwigType *type, const_String_or_char_ptr name, SwigType **matchtype) {
static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_String_or_char_ptr name, SwigType **matchtype) {
Hash *result = 0, *tm, *tm1, *tma;
Hash *backup = 0;
SwigType *noarrays = 0;
@ -732,12 +733,12 @@ ret_result:
/* -----------------------------------------------------------------------------
* Swig_typemap_search_multi()
* typemap_search_multi()
*
* Search for a multi-valued typemap.
* ----------------------------------------------------------------------------- */
Hash *Swig_typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch) {
static Hash *typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch) {
SwigType *type;
SwigType *mtype = 0;
String *name;
@ -752,14 +753,14 @@ Hash *Swig_typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, in
name = Getattr(parms, "name");
/* Try to find a match on the first type */
tm = Swig_typemap_search(op, type, name, &mtype);
tm = typemap_search(op, type, name, &mtype);
if (tm) {
if (mtype && SwigType_isarray(mtype)) {
Setattr(parms, "tmap:match", mtype);
}
Delete(mtype);
newop = NewStringf("%s-%s+%s:", op, type, name);
tm1 = Swig_typemap_search_multi(newop, nextSibling(parms), nmatch);
tm1 = typemap_search_multi(newop, nextSibling(parms), nmatch);
if (tm1)
tm = tm1;
if (Getattr(tm, "code")) {
@ -780,8 +781,7 @@ Hash *Swig_typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, in
* type and pname are the type and parameter name.
* ----------------------------------------------------------------------------- */
static
void replace_local_types(ParmList *p, const String *name, const String *rep) {
static void replace_local_types(ParmList *p, const String *name, const String *rep) {
SwigType *t;
while (p) {
t = Getattr(p, "type");
@ -790,8 +790,7 @@ void replace_local_types(ParmList *p, const String *name, const String *rep) {
}
}
static
int check_locals(ParmList *p, const char *s) {
static int check_locals(ParmList *p, const char *s) {
while (p) {
char *c = GetChar(p, "type");
if (strstr(c, s))
@ -801,8 +800,7 @@ int check_locals(ParmList *p, const char *s) {
return 0;
}
static
int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, SwigType *rtype, String *pname, String *lname, int index) {
static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, SwigType *rtype, String *pname, String *lname, int index) {
char var[512];
char *varname;
SwigType *ftype;
@ -1216,7 +1214,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
String *qsn = st ? Swig_symbol_string_qualify(pname, st) : 0;
if (qsn) {
if (Len(qsn) && !Equal(qsn, pname)) {
tm = Swig_typemap_search(op, type, qsn, &mtype);
tm = typemap_search(op, type, qsn, &mtype);
if (tm && (!Getattr(tm, "pname") || strstr(Char(Getattr(tm, "type")), "SWIGTYPE"))) {
tm = 0;
}
@ -1226,7 +1224,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
}
if (!tm)
#endif
tm = Swig_typemap_search(op, type, pname, &mtype);
tm = typemap_search(op, type, pname, &mtype);
if (!tm)
return sdef;
@ -1394,9 +1392,8 @@ String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *node, const_Strin
return Swig_typemap_lookup_impl(op, node, lname, f, 0);
}
/* -----------------------------------------------------------------------------
* Swig_typemap_attach_kwargs()
* typemap_attach_kwargs()
*
* If this hash (tm) contains a linked list of parameters under its "kwargs"
* attribute, add keys for each of those named keyword arguments to this
@ -1406,7 +1403,7 @@ String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *node, const_Strin
* A new attribute called "tmap:in:foo" with value "xyz" is attached to p.
* ----------------------------------------------------------------------------- */
void Swig_typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p) {
static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p) {
String *temp = NewStringEmpty();
Parm *kw = Getattr(tm, "kwargs");
while (kw) {
@ -1432,13 +1429,13 @@ void Swig_typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p)
}
/* -----------------------------------------------------------------------------
* Swig_typemap_warn()
* typemap_warn()
*
* If any warning message is attached to this parameter's "tmap:op:warning"
* attribute, print that warning message.
* ----------------------------------------------------------------------------- */
static void Swig_typemap_warn(const_String_or_char_ptr op, Parm *p) {
static void typemap_warn(const_String_or_char_ptr op, Parm *p) {
String *temp = NewStringf("%s:warning", op);
String *w = Getattr(p, tmop_name(temp));
Delete(temp);
@ -1447,7 +1444,7 @@ static void Swig_typemap_warn(const_String_or_char_ptr op, Parm *p) {
}
}
static void Swig_typemap_emit_code_fragments(const_String_or_char_ptr op, Parm *p) {
static void typemap_emit_code_fragments(const_String_or_char_ptr op, Parm *p) {
String *temp = NewStringf("%s:fragment", op);
String *f = Getattr(p, tmop_name(temp));
if (f) {
@ -1467,7 +1464,7 @@ static void Swig_typemap_emit_code_fragments(const_String_or_char_ptr op, Parm *
* given typemap type
* ----------------------------------------------------------------------------- */
String *Swig_typemap_get_option(Hash *tm, const_String_or_char_ptr name) {
static String *typemap_get_option(Hash *tm, const_String_or_char_ptr name) {
Parm *kw = Getattr(tm, "kwargs");
while (kw) {
String *kname = Getattr(kw, "name");
@ -1502,7 +1499,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra
#ifdef SWIG_DEBUG
Printf(stdout, "parms: %s %s %s\n", op, Getattr(p, "name"), Getattr(p, "type"));
#endif
tm = Swig_typemap_search_multi(op, p, &nmatch);
tm = typemap_search_multi(op, p, &nmatch);
#ifdef SWIG_DEBUG
if (tm)
Printf(stdout, "found: %s\n", tm);
@ -1521,7 +1518,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra
here, the freearg typemap requires the "in" typemap to match,
or the 'var$argnum' variable will not exist.
*/
kwmatch = Swig_typemap_get_option(tm, "match");
kwmatch = typemap_get_option(tm, "match");
if (kwmatch) {
String *tmname = NewStringf("tmap:%s", kwmatch);
String *tmin = Getattr(p, tmname);
@ -1547,7 +1544,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra
continue;
} else {
int nnmatch;
Hash *tmapin = Swig_typemap_search_multi(kwmatch, p, &nnmatch);
Hash *tmapin = typemap_search_multi(kwmatch, p, &nnmatch);
String *tmname = Getattr(tm, "pname");
String *tnname = Getattr(tmapin, "pname");
if (!(tmname && tnname && Equal(tmname, tnname)) && !(!tmname && !tnname)) {
@ -1640,13 +1637,13 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra
Setattr(firstp, tmop_name(temp), p);
/* Attach kwargs */
Swig_typemap_attach_kwargs(tm, op, firstp);
typemap_attach_kwargs(tm, op, firstp);
/* Print warnings, if any */
Swig_typemap_warn(op, firstp);
typemap_warn(op, firstp);
/* Look for code fragments */
Swig_typemap_emit_code_fragments(op, firstp);
typemap_emit_code_fragments(op, firstp);
/* increase argnum to consider numinputs */
argnum += nmatch - 1;