Merge branch 'master' into gsoc2009-matevz
parser.y still to be fixed up Conflicts: Doc/Devel/engineering.html Examples/Makefile.in Lib/allegrocl/allegrocl.swg Lib/csharp/csharp.swg Lib/csharp/enums.swg Lib/csharp/enumsimple.swg Lib/csharp/enumtypesafe.swg Lib/java/java.swg Lib/python/pydocs.swg Lib/r/rtype.swg Source/Include/swigwarn.h Source/Modules/octave.cxx Source/Modules/python.cxx Source/Modules/ruby.cxx Source/Swig/scanner.c Source/Swig/stype.c Source/Swig/swig.h configure.ac
This commit is contained in:
commit
e805d5f925
1074 changed files with 54339 additions and 20134 deletions
|
|
@ -9,14 +9,12 @@
|
|||
* scanner.c
|
||||
*
|
||||
* SWIG tokenizer. This file is a wrapper around the generic C scanner
|
||||
* found in Swig/scanner.c. Extra logic is added both to accomodate the
|
||||
* found in Swig/scanner.c. Extra logic is added both to accommodate the
|
||||
* bison-based grammar and certain peculiarities of C++ parsing (e.g.,
|
||||
* operator overloading, typedef resolution, etc.). This code also splits
|
||||
* C identifiers up into keywords and SWIG directives.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_cscanner_c[] = "$Id$";
|
||||
|
||||
#include "cparse.h"
|
||||
#include "parser.h"
|
||||
#include <string.h>
|
||||
|
|
@ -45,8 +43,6 @@ static int num_brace = 0;
|
|||
static int last_brace = 0;
|
||||
static int last_id = 0;
|
||||
static int rename_active = 0;
|
||||
static int expanding_macro = 0;
|
||||
static int follow_locators = 0;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_cparse_cplusplus()
|
||||
|
|
@ -56,101 +52,6 @@ void Swig_cparse_cplusplus(int v) {
|
|||
cparse_cplusplus = v;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* locator()
|
||||
*
|
||||
* Support for locator strings. These are strings of the form
|
||||
* @SWIG:filename,line,id@ emitted by the SWIG preprocessor. They
|
||||
* are primarily used for macro line number reporting
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
typedef struct Locator {
|
||||
String *filename;
|
||||
int line_number;
|
||||
struct Locator *next;
|
||||
} Locator;
|
||||
|
||||
static Locator *locs = 0;
|
||||
|
||||
/* we just use the locator to mark when active/deactive the linecounting */
|
||||
|
||||
static void scanner_locator(String *loc) {
|
||||
if (!follow_locators) {
|
||||
if (Equal(loc, "/*@SWIG@*/")) {
|
||||
/* End locator. */
|
||||
if (expanding_macro)
|
||||
--expanding_macro;
|
||||
} else {
|
||||
/* Begin locator. */
|
||||
++expanding_macro;
|
||||
}
|
||||
/* Freeze line number processing in Scanner */
|
||||
Scanner_freeze_line(scan,expanding_macro);
|
||||
} else {
|
||||
int c;
|
||||
Locator *l;
|
||||
Seek(loc, 7, SEEK_SET);
|
||||
c = Getc(loc);
|
||||
if (c == '@') {
|
||||
/* Empty locator. We pop the last location off */
|
||||
if (locs) {
|
||||
Scanner_set_location(scan,locs->filename,locs->line_number);
|
||||
cparse_file = locs->filename;
|
||||
cparse_line = locs->line_number;
|
||||
l = locs->next;
|
||||
free(locs);
|
||||
locs = l;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* We're going to push a new location */
|
||||
l = (Locator *) malloc(sizeof(Locator));
|
||||
l->filename = cparse_file;
|
||||
l->line_number = cparse_line;
|
||||
l->next = locs;
|
||||
locs = l;
|
||||
|
||||
/* Now, parse the new location out of the locator string */
|
||||
{
|
||||
String *fn = NewStringEmpty();
|
||||
/* Putc(c, fn); */
|
||||
|
||||
while ((c = Getc(loc)) != EOF) {
|
||||
if ((c == '@') || (c == ','))
|
||||
break;
|
||||
Putc(c, fn);
|
||||
}
|
||||
cparse_file = Swig_copy_string(Char(fn));
|
||||
Clear(fn);
|
||||
cparse_line = 1;
|
||||
/* Get the line number */
|
||||
while ((c = Getc(loc)) != EOF) {
|
||||
if ((c == '@') || (c == ','))
|
||||
break;
|
||||
Putc(c, fn);
|
||||
}
|
||||
cparse_line = atoi(Char(fn));
|
||||
Clear(fn);
|
||||
|
||||
/* Get the rest of it */
|
||||
while ((c = Getc(loc)) != EOF) {
|
||||
if (c == '@')
|
||||
break;
|
||||
Putc(c, fn);
|
||||
}
|
||||
/* Swig_diagnostic(cparse_file, cparse_line, "Scanner_set_location\n"); */
|
||||
Scanner_set_location(scan,cparse_file,cparse_line);
|
||||
Delete(fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Swig_cparse_follow_locators(int v) {
|
||||
follow_locators = v;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* scanner_init()
|
||||
*
|
||||
|
|
@ -200,10 +101,11 @@ void start_inline(char *text, int line) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void skip_balanced(int startchar, int endchar) {
|
||||
int start_line = Scanner_line(scan);
|
||||
Clear(scanner_ccode);
|
||||
|
||||
if (Scanner_skip_balanced(scan,startchar,endchar) < 0) {
|
||||
Swig_error(Scanner_file(scan),Scanner_errline(scan), "Missing '%c'. Reached end of input.\n", endchar);
|
||||
Swig_error(cparse_file, start_line, "Missing '%c'. Reached end of input.\n", endchar);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -446,7 +348,7 @@ static int yylook(void) {
|
|||
String *cmt = Scanner_text(scan);
|
||||
char *loc = Char(cmt);
|
||||
if ((strncmp(loc,"/*@SWIG",7) == 0) && (loc[Len(cmt)-3] == '@')) {
|
||||
scanner_locator(cmt);
|
||||
Scanner_locator(scan, cmt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -483,7 +385,7 @@ void scanner_clear_rename() {
|
|||
rename_active = 0;
|
||||
}
|
||||
|
||||
/* Used to push a ficticious token into the scanner */
|
||||
/* Used to push a fictitious token into the scanner */
|
||||
static int next_token = 0;
|
||||
void scanner_next_token(int tok) {
|
||||
next_token = tok;
|
||||
|
|
@ -820,7 +722,7 @@ int yylex(void) {
|
|||
if (strcmp(yytext, "typename") == 0)
|
||||
return (TYPENAME);
|
||||
if (strcmp(yytext, "template") == 0) {
|
||||
yylval.ivalue = cparse_line;
|
||||
yylval.intvalue = cparse_line;
|
||||
return (TEMPLATE);
|
||||
}
|
||||
if (strcmp(yytext, "delete") == 0) {
|
||||
|
|
@ -862,7 +764,7 @@ int yylex(void) {
|
|||
return (SIZEOF);
|
||||
|
||||
if (strcmp(yytext, "typedef") == 0) {
|
||||
yylval.ivalue = 0;
|
||||
yylval.intvalue = 0;
|
||||
return (TYPEDEF);
|
||||
}
|
||||
|
||||
|
|
@ -893,6 +795,10 @@ int yylex(void) {
|
|||
}
|
||||
if (strcmp(yytext, "%includefile") == 0)
|
||||
return (INCLUDE);
|
||||
if (strcmp(yytext, "%beginfile") == 0)
|
||||
return (BEGINFILE);
|
||||
if (strcmp(yytext, "%endoffile") == 0)
|
||||
return (ENDOFFILE);
|
||||
if (strcmp(yytext, "%val") == 0) {
|
||||
Swig_warning(WARN_DEPRECATED_VAL, cparse_file, cparse_line, "%%val directive deprecated (ignored).\n");
|
||||
return (yylex());
|
||||
|
|
@ -904,7 +810,7 @@ int yylex(void) {
|
|||
if (strcmp(yytext, "%constant") == 0)
|
||||
return (CONSTANT);
|
||||
if (strcmp(yytext, "%typedef") == 0) {
|
||||
yylval.ivalue = 1;
|
||||
yylval.intvalue = 1;
|
||||
return (TYPEDEF);
|
||||
}
|
||||
if (strcmp(yytext, "%native") == 0)
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ to work, see Byacc man page: http://invisible-island.net/byacc/manpage/yacc.html
|
|||
%{
|
||||
#define yylex yylex
|
||||
|
||||
char cvsroot_parser_y[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include "cparse.h"
|
||||
#include "preprocessor.h"
|
||||
|
|
@ -210,7 +208,7 @@ static String *yyrename = 0;
|
|||
|
||||
/* Forward renaming operator */
|
||||
|
||||
static String *resolve_node_scope(String *cname);
|
||||
static String *resolve_create_node_scope(String *cname);
|
||||
|
||||
|
||||
Hash *Swig_cparse_features(void) {
|
||||
|
|
@ -219,6 +217,7 @@ Hash *Swig_cparse_features(void) {
|
|||
return features_hash;
|
||||
}
|
||||
|
||||
/* Fully qualify any template parameters */
|
||||
static String *feature_identifier_fix(String *s) {
|
||||
String *tp = SwigType_istemplate_templateprefix(s);
|
||||
if (tp) {
|
||||
|
|
@ -732,33 +731,33 @@ static void check_extensions() {
|
|||
|
||||
/* Check a set of declarations to see if any are pure-abstract */
|
||||
|
||||
static List *pure_abstract(Node *n) {
|
||||
List *abs = 0;
|
||||
static List *pure_abstracts(Node *n) {
|
||||
List *abstracts = 0;
|
||||
while (n) {
|
||||
if (Cmp(nodeType(n),"cdecl") == 0) {
|
||||
String *decl = Getattr(n,"decl");
|
||||
if (SwigType_isfunction(decl)) {
|
||||
String *init = Getattr(n,"value");
|
||||
if (Cmp(init,"0") == 0) {
|
||||
if (!abs) {
|
||||
abs = NewList();
|
||||
if (!abstracts) {
|
||||
abstracts = NewList();
|
||||
}
|
||||
Append(abs,n);
|
||||
Setattr(n,"abstract","1");
|
||||
Append(abstracts,n);
|
||||
SetFlag(n,"abstract");
|
||||
}
|
||||
}
|
||||
} else if (Cmp(nodeType(n),"destructor") == 0) {
|
||||
if (Cmp(Getattr(n,"value"),"0") == 0) {
|
||||
if (!abs) {
|
||||
abs = NewList();
|
||||
if (!abstracts) {
|
||||
abstracts = NewList();
|
||||
}
|
||||
Append(abs,n);
|
||||
Setattr(n,"abstract","1");
|
||||
Append(abstracts,n);
|
||||
SetFlag(n,"abstract");
|
||||
}
|
||||
}
|
||||
n = nextSibling(n);
|
||||
}
|
||||
return abs;
|
||||
return abstracts;
|
||||
}
|
||||
|
||||
/* Make a classname */
|
||||
|
|
@ -871,26 +870,85 @@ static Node *nscope = 0;
|
|||
static Node *nscope_inner = 0;
|
||||
|
||||
/* Remove the scope prefix from cname and return the base name without the prefix.
|
||||
* The scopes specified in the prefix are found, or created in the current namespace.
|
||||
* So ultimately the scope is changed to that required for the base name.
|
||||
* The scopes required for the symbol name are resolved and/or created, if required.
|
||||
* For example AA::BB::CC as input returns CC and creates the namespace AA then inner
|
||||
* namespace BB in the current scope. If no scope separator (::) in the input, then nothing happens! */
|
||||
static String *resolve_node_scope(String *cname) {
|
||||
* namespace BB in the current scope. If cname is found to already exist as a weak symbol
|
||||
* (forward reference) then the scope might be changed to match, such as when a symbol match
|
||||
* is made via a using reference. */
|
||||
static String *resolve_create_node_scope(String *cname) {
|
||||
Symtab *gscope = 0;
|
||||
Node *cname_node = 0;
|
||||
int skip_lookup = 0;
|
||||
nscope = 0;
|
||||
nscope_inner = 0;
|
||||
|
||||
if (Strncmp(cname,"::",2) == 0)
|
||||
skip_lookup = 1;
|
||||
|
||||
cname_node = skip_lookup ? 0 : Swig_symbol_clookup_no_inherit(cname, 0);
|
||||
|
||||
if (cname_node) {
|
||||
/* The symbol has been defined already or is in another scope.
|
||||
If it is a weak symbol, it needs replacing and if it was brought into the current scope
|
||||
via a using declaration, the scope needs adjusting appropriately for the new symbol.
|
||||
Similarly for defined templates. */
|
||||
Symtab *symtab = Getattr(cname_node, "sym:symtab");
|
||||
Node *sym_weak = Getattr(cname_node, "sym:weak");
|
||||
if ((symtab && sym_weak) || Equal(nodeType(cname_node), "template")) {
|
||||
/* Check if the scope is the current scope */
|
||||
String *current_scopename = Swig_symbol_qualifiedscopename(0);
|
||||
String *found_scopename = Swig_symbol_qualifiedscopename(symtab);
|
||||
int len;
|
||||
if (!current_scopename)
|
||||
current_scopename = NewString("");
|
||||
if (!found_scopename)
|
||||
found_scopename = NewString("");
|
||||
len = Len(current_scopename);
|
||||
if ((len > 0) && (Strncmp(current_scopename, found_scopename, len) == 0)) {
|
||||
if (Len(found_scopename) > len + 2) {
|
||||
/* A matching weak symbol was found in non-global scope, some scope adjustment may be required */
|
||||
String *new_cname = NewString(Char(found_scopename) + len + 2); /* skip over "::" prefix */
|
||||
String *base = Swig_scopename_last(cname);
|
||||
Printf(new_cname, "::%s", base);
|
||||
cname = new_cname;
|
||||
Delete(base);
|
||||
} else {
|
||||
/* A matching weak symbol was found in the same non-global local scope, no scope adjustment required */
|
||||
assert(len == Len(found_scopename));
|
||||
}
|
||||
} else {
|
||||
String *base = Swig_scopename_last(cname);
|
||||
if (Len(found_scopename) > 0) {
|
||||
/* A matching weak symbol was found in a different scope to the local scope - probably via a using declaration */
|
||||
cname = NewStringf("%s::%s", found_scopename, base);
|
||||
} else {
|
||||
/* Either:
|
||||
1) A matching weak symbol was found in a different scope to the local scope - this is actually a
|
||||
symbol with the same name in a different scope which we don't want, so no adjustment required.
|
||||
2) A matching weak symbol was found in the global scope - no adjustment required.
|
||||
*/
|
||||
cname = Copy(base);
|
||||
}
|
||||
Delete(base);
|
||||
}
|
||||
Delete(current_scopename);
|
||||
Delete(found_scopename);
|
||||
}
|
||||
}
|
||||
|
||||
if (Swig_scopename_check(cname)) {
|
||||
Node *ns;
|
||||
String *prefix = Swig_scopename_prefix(cname);
|
||||
String *base = Swig_scopename_last(cname);
|
||||
if (prefix && (Strncmp(prefix,"::",2) == 0)) {
|
||||
/* I don't think we can use :: global scope to declare classes and hence neither %template. - consider reporting error instead - wsfulton. */
|
||||
/* Use the global scope */
|
||||
String *nprefix = NewString(Char(prefix)+2);
|
||||
Delete(prefix);
|
||||
prefix= nprefix;
|
||||
gscope = set_scope_to_global();
|
||||
}
|
||||
if (!prefix || (Len(prefix) == 0)) {
|
||||
}
|
||||
if (Len(prefix) == 0) {
|
||||
/* Use the global scope, but we need to add a 'global' namespace. */
|
||||
if (!gscope) gscope = set_scope_to_global();
|
||||
/* note that this namespace is not the "unnamed" one,
|
||||
|
|
@ -908,8 +966,7 @@ static String *resolve_node_scope(String *cname) {
|
|||
} else {
|
||||
Symtab *nstab = Getattr(ns,"symtab");
|
||||
if (!nstab) {
|
||||
Swig_error(cparse_file,cparse_line,
|
||||
"'%s' is not defined as a valid scope.\n", prefix);
|
||||
Swig_error(cparse_file,cparse_line, "'%s' is not defined as a valid scope.\n", prefix);
|
||||
ns = 0;
|
||||
} else {
|
||||
/* Check if the node scope is the current scope */
|
||||
|
|
@ -950,7 +1007,6 @@ static String *resolve_node_scope(String *cname) {
|
|||
} else {
|
||||
/* now this last part is a class */
|
||||
si = Next(si);
|
||||
ns1 = Swig_symbol_clookup(sname,0);
|
||||
/* or a nested class tree, which is unrolled here */
|
||||
for (; si.item; si = Next(si)) {
|
||||
if (si.item) {
|
||||
|
|
@ -990,6 +1046,7 @@ static String *resolve_node_scope(String *cname) {
|
|||
}
|
||||
Delete(prefix);
|
||||
}
|
||||
|
||||
return cname;
|
||||
}
|
||||
|
||||
|
|
@ -1099,7 +1156,7 @@ static void nested_new_struct(const char *kind, String *struct_code, Node *cpp_o
|
|||
* nested class solution is implemented.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static Node *nested_forward_declaration(const char *storage, const char *kind, String *sname, const char *name, Node *cpp_opt_declarators) {
|
||||
static Node *nested_forward_declaration(const char *storage, const char *kind, String *sname, String *name, Node *cpp_opt_declarators) {
|
||||
Node *nn = 0;
|
||||
int warned = 0;
|
||||
|
||||
|
|
@ -1124,7 +1181,7 @@ static Node *nested_forward_declaration(const char *storage, const char *kind, S
|
|||
if (!variable_of_anonymous_type) {
|
||||
int anonymous_typedef = !sname && (storage && (strcmp(storage, "typedef") == 0));
|
||||
Node *n = cpp_opt_declarators;
|
||||
SwigType *type = NewString(name);
|
||||
SwigType *type = name;
|
||||
while (n) {
|
||||
Setattr(n, "type", type);
|
||||
Setattr(n, "storage", storage);
|
||||
|
|
@ -1134,7 +1191,6 @@ static Node *nested_forward_declaration(const char *storage, const char *kind, S
|
|||
}
|
||||
n = nextSibling(n);
|
||||
}
|
||||
Delete(type);
|
||||
add_symbols(cpp_opt_declarators);
|
||||
|
||||
if (nn) {
|
||||
|
|
@ -1633,7 +1689,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
|
|||
String *str;
|
||||
Parm *p;
|
||||
ParmList *pl;
|
||||
int ivalue;
|
||||
int intvalue;
|
||||
Node *node;
|
||||
};
|
||||
|
||||
|
|
@ -1644,10 +1700,11 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
|
|||
%token <loc> INCLUDE IMPORT INSERT
|
||||
%token <str> CHARCONST WCHARCONST
|
||||
%token <dtype> NUM_INT NUM_FLOAT NUM_UNSIGNED NUM_LONG NUM_ULONG NUM_LONGLONG NUM_ULONGLONG NUM_BOOL
|
||||
%token <ivalue> TYPEDEF
|
||||
%token <intvalue> TYPEDEF
|
||||
%token <type> TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_WCHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW TYPE_NON_ISO_INT8 TYPE_NON_ISO_INT16 TYPE_NON_ISO_INT32 TYPE_NON_ISO_INT64
|
||||
%token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD
|
||||
%token CONST_QUAL VOLATILE REGISTER STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET
|
||||
%token BEGINFILE ENDOFFILE
|
||||
%token ILLEGAL CONSTANT
|
||||
%token NAME RENAME NAMEWARN EXTEND PRAGMA FEATURE VARARGS
|
||||
%token ENUM
|
||||
|
|
@ -1664,7 +1721,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
|
|||
%token QUESTIONMARK
|
||||
%token TYPES PARMS
|
||||
%token NONID DSTAR DCNOT
|
||||
%token <ivalue> TEMPLATE
|
||||
%token <intvalue> TEMPLATE
|
||||
%token <str> OPERATOR
|
||||
%token <str> COPERATOR
|
||||
%token PARSETYPE PARSEPARM PARSEPARMS
|
||||
|
|
@ -1736,7 +1793,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
|
|||
%type <id> string stringnum wstring;
|
||||
%type <tparms> template_parms;
|
||||
%type <dtype> cpp_end cpp_vend;
|
||||
%type <ivalue> rename_namewarn;
|
||||
%type <intvalue> rename_namewarn;
|
||||
%type <ptype> type_specifier primitive_type_list ;
|
||||
%type <node> fname stringtype;
|
||||
%type <node> featattr;
|
||||
|
|
@ -2119,7 +2176,7 @@ fragment_directive: FRAGMENT LPAREN fname COMMA kwargs RPAREN HBLOCK {
|
|||
%importfile(option1="xyz", ...) "filename" [ declarations ]
|
||||
------------------------------------------------------------ */
|
||||
|
||||
include_directive: includetype options string LBRACKET {
|
||||
include_directive: includetype options string BEGINFILE {
|
||||
$1.filename = Copy(cparse_file);
|
||||
$1.line = cparse_line;
|
||||
scanner_set_location(NewString($3),1);
|
||||
|
|
@ -2128,10 +2185,10 @@ include_directive: includetype options string LBRACKET {
|
|||
if (maininput)
|
||||
scanner_set_main_input_file(NewString(maininput));
|
||||
}
|
||||
} interface RBRACKET {
|
||||
} interface ENDOFFILE {
|
||||
String *mname = 0;
|
||||
$$ = $6;
|
||||
scanner_set_location($1.filename,$1.line);
|
||||
scanner_set_location($1.filename,$1.line+1);
|
||||
if (strcmp($1.type,"include") == 0) set_nodeType($$,"include");
|
||||
if (strcmp($1.type,"import") == 0) {
|
||||
mname = $2 ? Getattr($2,"module") : 0;
|
||||
|
|
@ -2186,15 +2243,14 @@ inline_directive : INLINE HBLOCK {
|
|||
String *cpps;
|
||||
if (Namespaceprefix) {
|
||||
Swig_error(cparse_file, cparse_start_line, "%%inline directive inside a namespace is disallowed.\n");
|
||||
|
||||
$$ = 0;
|
||||
} else {
|
||||
$$ = new_node("insert");
|
||||
Setattr($$,"code",$2);
|
||||
/* Need to run through the preprocessor */
|
||||
Seek($2,0,SEEK_SET);
|
||||
Setline($2,cparse_start_line);
|
||||
Setfile($2,cparse_file);
|
||||
Seek($2,0,SEEK_SET);
|
||||
cpps = Preprocessor_parse($2);
|
||||
start_inline(Char(cpps), cparse_start_line);
|
||||
Delete($2);
|
||||
|
|
@ -2638,10 +2694,15 @@ varargs_parms : parms { $$ = $1; }
|
|||
Swig_error(cparse_file, cparse_line,"Argument count in %%varargs must be positive.\n");
|
||||
$$ = 0;
|
||||
} else {
|
||||
String *name = Getattr($3, "name");
|
||||
$$ = Copy($3);
|
||||
Setattr($$,"name","VARARGS_SENTINEL");
|
||||
for (i = 0; i < n; i++) {
|
||||
if (name)
|
||||
Setattr($$, "name", NewStringf("%s%d", name, n));
|
||||
for (i = 1; i < n; i++) {
|
||||
p = Copy($3);
|
||||
name = Getattr(p, "name");
|
||||
if (name)
|
||||
Setattr(p, "name", NewStringf("%s%d", name, n-i));
|
||||
set_nextSibling(p,$$);
|
||||
Delete($$);
|
||||
$$ = p;
|
||||
|
|
@ -2779,7 +2840,6 @@ types_directive : TYPES LPAREN parms RPAREN stringbracesemi {
|
|||
template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN valparms GREATERTHAN SEMI {
|
||||
Parm *p, *tp;
|
||||
Node *n;
|
||||
Node *tnode = 0;
|
||||
Symtab *tscope = 0;
|
||||
int specialized = 0;
|
||||
int variadic = 0;
|
||||
|
|
@ -2790,7 +2850,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
|
|||
|
||||
/* If the class name is qualified, we need to create or lookup namespace entries */
|
||||
if (!inclass) {
|
||||
$5 = resolve_node_scope($5);
|
||||
$5 = resolve_create_node_scope($5);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -2946,7 +3006,6 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
|
|||
}
|
||||
Delattr(templnode,"templatetype");
|
||||
Setattr(templnode,"template",nn);
|
||||
tnode = templnode;
|
||||
Setfile(templnode,cparse_file);
|
||||
Setline(templnode,cparse_line);
|
||||
Delete(temparms);
|
||||
|
|
@ -2956,7 +3015,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
|
|||
if (Strcmp(nodeType(templnode),"class") == 0) {
|
||||
|
||||
/* Identify pure abstract methods */
|
||||
Setattr(templnode,"abstract", pure_abstract(firstChild(templnode)));
|
||||
Setattr(templnode,"abstracts", pure_abstracts(firstChild(templnode)));
|
||||
|
||||
/* Set up inheritance in symbol table */
|
||||
{
|
||||
|
|
@ -3000,7 +3059,7 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va
|
|||
if (am) {
|
||||
Symtab *st = Swig_symbol_current();
|
||||
Swig_symbol_setscope(Getattr(templnode,"symtab"));
|
||||
/* Printf(stdout,"%s: %s %x %x\n", Getattr(templnode,"name"), clsname, Swig_symbol_current(), Getattr(templnode,"symtab")); */
|
||||
/* Printf(stdout,"%s: %s %p %p\n", Getattr(templnode,"name"), clsname, Swig_symbol_current(), Getattr(templnode,"symtab")); */
|
||||
merge_extensions(templnode,am);
|
||||
Swig_symbol_setscope(st);
|
||||
append_previous_extension(templnode,am);
|
||||
|
|
@ -3093,7 +3152,7 @@ c_declaration : c_decl {
|
|||
appendChild($$,n);
|
||||
while (n) {
|
||||
SwigType *decl = Getattr(n,"decl");
|
||||
if (SwigType_isfunction(decl) && Strcmp(Getattr(n, "storage"), "typedef") != 0) {
|
||||
if (SwigType_isfunction(decl) && !Equal(Getattr(n, "storage"), "typedef")) {
|
||||
Setattr(n,"storage","externc");
|
||||
}
|
||||
n = nextSibling(n);
|
||||
|
|
@ -3597,7 +3656,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
|||
prev_symtab = Swig_symbol_current();
|
||||
|
||||
/* If the class name is qualified. We need to create or lookup namespace/scope entries */
|
||||
scope = resolve_node_scope($3);
|
||||
scope = resolve_create_node_scope($3);
|
||||
Setfile(scope,cparse_file);
|
||||
Setline(scope,cparse_line);
|
||||
$3 = scope;
|
||||
|
|
@ -3707,7 +3766,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
|||
inclass = 0;
|
||||
|
||||
/* Check for pure-abstract class */
|
||||
Setattr($$,"abstract", pure_abstract($7));
|
||||
Setattr($$,"abstracts", pure_abstracts($7));
|
||||
|
||||
/* This bit of code merges in a previously defined %extend directive (if any) */
|
||||
|
||||
|
|
@ -3752,20 +3811,25 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
|||
if (Cmp($1,"typedef") == 0) {
|
||||
if (!decltype || !Len(decltype)) {
|
||||
String *cname;
|
||||
String *tdscopename;
|
||||
String *class_scope = Swig_symbol_qualifiedscopename(cscope);
|
||||
name = Getattr($9,"name");
|
||||
cname = Copy(name);
|
||||
Setattr($$,"tdname",cname);
|
||||
Delete(cname);
|
||||
tdscopename = class_scope ? NewStringf("%s::%s", class_scope, name) : Copy(name);
|
||||
|
||||
/* Use typedef name as class name */
|
||||
if (class_rename && (Strcmp(class_rename,$3) == 0)) {
|
||||
Delete(class_rename);
|
||||
class_rename = NewString(name);
|
||||
}
|
||||
if (!Getattr(classes,name)) {
|
||||
Setattr(classes,name,$$);
|
||||
if (!Getattr(classes,tdscopename)) {
|
||||
Setattr(classes,tdscopename,$$);
|
||||
}
|
||||
Setattr($$,"decl",decltype);
|
||||
Delete(class_scope);
|
||||
Delete(cname);
|
||||
Delete(tdscopename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3865,7 +3929,7 @@ cpp_class_decl : storage_class cpptype idcolon inherit LBRACE {
|
|||
unnamed = Getattr($$,"unnamed");
|
||||
|
||||
/* Check for pure-abstract class */
|
||||
Setattr($$,"abstract", pure_abstract($5));
|
||||
Setattr($$,"abstracts", pure_abstracts($5));
|
||||
|
||||
n = new_node("cdecl");
|
||||
Setattr(n,"name",$7.id);
|
||||
|
|
@ -4625,17 +4689,7 @@ cpp_destructor_decl : NOT idtemplate LPAREN parms RPAREN cpp_end {
|
|||
|
||||
| VIRTUAL NOT idtemplate LPAREN parms RPAREN cpp_vend {
|
||||
String *name;
|
||||
char *c = 0;
|
||||
$$ = new_node("destructor");
|
||||
/* Check for template names. If the class is a template
|
||||
and the constructor is missing the template part, we
|
||||
add it */
|
||||
if (Classprefix) {
|
||||
c = strchr(Char(Classprefix),'<');
|
||||
if (c && !Strchr($3,'<')) {
|
||||
$3 = NewStringf("%s%s",$3,c);
|
||||
}
|
||||
}
|
||||
Setattr($$,"storage","virtual");
|
||||
name = NewStringf("%s",$3);
|
||||
if (*(Char(name)) != '~') Insert(name,0,"~");
|
||||
|
|
@ -4714,6 +4768,25 @@ cpp_conversion_operator : storage_class COPERATOR type pointer LPAREN parms RPAR
|
|||
add_symbols($$);
|
||||
}
|
||||
|
||||
| storage_class COPERATOR type pointer AND LPAREN parms RPAREN cpp_vend {
|
||||
SwigType *decl;
|
||||
$$ = new_node("cdecl");
|
||||
Setattr($$,"type",$3);
|
||||
Setattr($$,"name",$2);
|
||||
Setattr($$,"storage",$1);
|
||||
decl = NewStringEmpty();
|
||||
SwigType_add_pointer(decl);
|
||||
SwigType_add_reference(decl);
|
||||
SwigType_add_function(decl,$7);
|
||||
if ($9.qualifier) {
|
||||
SwigType_push(decl,$9.qualifier);
|
||||
}
|
||||
Setattr($$,"decl",decl);
|
||||
Setattr($$,"parms",$7);
|
||||
Setattr($$,"conversion_operator","1");
|
||||
add_symbols($$);
|
||||
}
|
||||
|
||||
| storage_class COPERATOR type LPAREN parms RPAREN cpp_vend {
|
||||
String *t = NewStringEmpty();
|
||||
$$ = new_node("cdecl");
|
||||
|
|
@ -4784,13 +4857,15 @@ cpp_protection_decl : PUBLIC COLON {
|
|||
------------------------------------------------------------ */
|
||||
|
||||
cpp_nested : storage_class cpptype idcolon inherit LBRACE {
|
||||
cparse_start_line = cparse_line; skip_balanced('{','}');
|
||||
cparse_start_line = cparse_line;
|
||||
skip_balanced('{','}');
|
||||
$<str>$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */
|
||||
} cpp_opt_declarators {
|
||||
$$ = 0;
|
||||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
if (cparse_cplusplus) {
|
||||
$$ = nested_forward_declaration($1, $2, $3, $3, $7);
|
||||
String *name = Copy($3);
|
||||
$$ = nested_forward_declaration($1, $2, $3, name, $7);
|
||||
} else if ($7) {
|
||||
nested_new_struct($2, $<str>6, $7);
|
||||
}
|
||||
|
|
@ -4809,13 +4884,14 @@ cpp_nested : storage_class cpptype idcolon inherit LBRACE {
|
|||
------------------------------------------------------------ */
|
||||
|
||||
| storage_class cpptype inherit LBRACE {
|
||||
cparse_start_line = cparse_line; skip_balanced('{','}');
|
||||
cparse_start_line = cparse_line;
|
||||
skip_balanced('{','}');
|
||||
$<str>$ = NewString(scanner_ccode); /* copied as initializers overwrite scanner_ccode */
|
||||
} cpp_opt_declarators {
|
||||
$$ = 0;
|
||||
if (cplus_mode == CPLUS_PUBLIC) {
|
||||
if (cparse_cplusplus) {
|
||||
const char *name = $6 ? Getattr($6, "name") : 0;
|
||||
String *name = $6 ? Copy(Getattr($6, "name")) : 0;
|
||||
$$ = nested_forward_declaration($1, $2, 0, name, $6);
|
||||
} else {
|
||||
if ($6) {
|
||||
|
|
@ -5398,7 +5474,7 @@ notso_direct_declarator : idcolon {
|
|||
$$.have_parms = 0;
|
||||
}
|
||||
|
||||
/* This generate a shift-reduce conflict with constructors */
|
||||
/* This generates a shift-reduce conflict with constructors */
|
||||
| LPAREN idcolon RPAREN {
|
||||
$$.id = Char($2);
|
||||
$$.type = 0;
|
||||
|
|
@ -5769,26 +5845,26 @@ direct_abstract_declarator : direct_abstract_declarator LBRACKET RBRACKET {
|
|||
|
||||
|
||||
pointer : STAR type_qualifier pointer {
|
||||
$$ = NewStringEmpty();
|
||||
SwigType_add_pointer($$);
|
||||
SwigType_push($$,$2);
|
||||
SwigType_push($$,$3);
|
||||
Delete($3);
|
||||
$$ = NewStringEmpty();
|
||||
SwigType_add_pointer($$);
|
||||
SwigType_push($$,$2);
|
||||
SwigType_push($$,$3);
|
||||
Delete($3);
|
||||
}
|
||||
| STAR pointer {
|
||||
$$ = NewStringEmpty();
|
||||
SwigType_add_pointer($$);
|
||||
SwigType_push($$,$2);
|
||||
Delete($2);
|
||||
}
|
||||
}
|
||||
| STAR type_qualifier {
|
||||
$$ = NewStringEmpty();
|
||||
SwigType_add_pointer($$);
|
||||
SwigType_push($$,$2);
|
||||
$$ = NewStringEmpty();
|
||||
SwigType_add_pointer($$);
|
||||
SwigType_push($$,$2);
|
||||
}
|
||||
| STAR {
|
||||
$$ = NewStringEmpty();
|
||||
SwigType_add_pointer($$);
|
||||
$$ = NewStringEmpty();
|
||||
SwigType_add_pointer($$);
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -5816,7 +5892,7 @@ type : rawtype {
|
|||
}
|
||||
;
|
||||
|
||||
rawtype : type_qualifier type_right {
|
||||
rawtype : type_qualifier type_right {
|
||||
$$ = $2;
|
||||
SwigType_push($$,$1);
|
||||
}
|
||||
|
|
@ -5834,7 +5910,7 @@ rawtype : type_qualifier type_right {
|
|||
|
||||
type_right : primitive_type { $$ = $1;
|
||||
/* Printf(stdout,"primitive = '%s'\n", $$);*/
|
||||
}
|
||||
}
|
||||
| TYPE_BOOL { $$ = $1; }
|
||||
| TYPE_VOID { $$ = $1; }
|
||||
| TYPE_TYPEDEF template_decl { $$ = NewStringf("%s%s",$1,$2); }
|
||||
|
|
@ -6062,21 +6138,14 @@ edecl : ID {
|
|||
Delete(type);
|
||||
}
|
||||
| ID EQUAL etype {
|
||||
SwigType *type = NewSwigType($3.type == T_BOOL ? T_BOOL : ($3.type == T_CHAR ? T_CHAR : T_INT));
|
||||
$$ = new_node("enumitem");
|
||||
Setattr($$,"name",$1);
|
||||
Setattr($$,"enumvalue", $3.val);
|
||||
if ($3.type == T_CHAR) {
|
||||
SwigType *type = NewSwigType(T_CHAR);
|
||||
Setattr($$,"value",NewStringf("\'%(escape)s\'", $3.val));
|
||||
Setattr($$,"type",type);
|
||||
Delete(type);
|
||||
} else {
|
||||
SwigType *type = NewSwigType($3.type == T_BOOL ? T_BOOL : T_INT);
|
||||
Setattr($$,"value",$1);
|
||||
Setattr($$,"type",type);
|
||||
Delete(type);
|
||||
}
|
||||
Setattr($$,"type",type);
|
||||
SetFlag($$,"feature:immutable");
|
||||
Setattr($$,"enumvalue", $3.val);
|
||||
Setattr($$,"value",$1);
|
||||
Delete(type);
|
||||
}
|
||||
| empty { $$ = 0; }
|
||||
;
|
||||
|
|
@ -6085,12 +6154,12 @@ etype : expr {
|
|||
$$ = $1;
|
||||
if (($$.type != T_INT) && ($$.type != T_UINT) &&
|
||||
($$.type != T_LONG) && ($$.type != T_ULONG) &&
|
||||
($$.type != T_LONGLONG) && ($$.type != T_ULONGLONG) &&
|
||||
($$.type != T_SHORT) && ($$.type != T_USHORT) &&
|
||||
($$.type != T_SCHAR) && ($$.type != T_UCHAR) &&
|
||||
($$.type != T_CHAR) && ($$.type != T_BOOL)) {
|
||||
Swig_error(cparse_file,cparse_line,"Type error. Expecting an integral type\n");
|
||||
}
|
||||
if ($$.type == T_CHAR) $$.type = T_INT;
|
||||
}
|
||||
;
|
||||
|
||||
|
|
@ -6395,28 +6464,34 @@ base_list : base_specifier {
|
|||
}
|
||||
;
|
||||
|
||||
base_specifier : opt_virtual idcolon {
|
||||
base_specifier : opt_virtual {
|
||||
$<intvalue>$ = cparse_line;
|
||||
} idcolon {
|
||||
$$ = NewHash();
|
||||
Setfile($$,cparse_file);
|
||||
Setline($$,cparse_line);
|
||||
Setattr($$,"name",$2);
|
||||
Setline($$,$<intvalue>2);
|
||||
Setattr($$,"name",$3);
|
||||
Setfile($3,cparse_file);
|
||||
Setline($3,$<intvalue>2);
|
||||
if (last_cpptype && (Strcmp(last_cpptype,"struct") != 0)) {
|
||||
Setattr($$,"access","private");
|
||||
Swig_warning(WARN_PARSE_NO_ACCESS,cparse_file,cparse_line,
|
||||
"No access specifier given for base class %s (ignored).\n",$2);
|
||||
Swig_warning(WARN_PARSE_NO_ACCESS, Getfile($$), Getline($$), "No access specifier given for base class '%s' (ignored).\n", SwigType_namestr($3));
|
||||
} else {
|
||||
Setattr($$,"access","public");
|
||||
}
|
||||
}
|
||||
| opt_virtual access_specifier opt_virtual idcolon {
|
||||
| opt_virtual access_specifier {
|
||||
$<intvalue>$ = cparse_line;
|
||||
} opt_virtual idcolon {
|
||||
$$ = NewHash();
|
||||
Setfile($$,cparse_file);
|
||||
Setline($$,cparse_line);
|
||||
Setattr($$,"name",$4);
|
||||
Setline($$,$<intvalue>3);
|
||||
Setattr($$,"name",$5);
|
||||
Setfile($5,cparse_file);
|
||||
Setline($5,$<intvalue>3);
|
||||
Setattr($$,"access",$2);
|
||||
if (Strcmp($2,"public") != 0) {
|
||||
Swig_warning(WARN_PARSE_PRIVATE_INHERIT, cparse_file,
|
||||
cparse_line,"%s inheritance ignored.\n", $2);
|
||||
Swig_warning(WARN_PARSE_PRIVATE_INHERIT, Getfile($$), Getline($$), "%s inheritance from base '%s' (ignored).\n", $2, SwigType_namestr($5));
|
||||
}
|
||||
}
|
||||
| opt_virtual idcolon PERIOD PERIOD PERIOD { /* Variadic inheritance */
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Expands a template into a specialized version.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_templ_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include "cparse.h"
|
||||
|
||||
|
|
@ -766,6 +764,7 @@ static Node *template_locate(String *name, Parm *tparms, Symtab *tscope) {
|
|||
for (i = 1; i < posslen; i++) {
|
||||
String *templcsymname = Getattr(Getitem(possiblepartials, i), "templcsymname");
|
||||
Node *ignored_node = Swig_symbol_clookup_local(templcsymname, primary_scope);
|
||||
assert(ignored_node);
|
||||
Swig_warning(WARN_PARSE_TEMPLATE_AMBIG, Getfile(ignored_node), Getline(ignored_node), " instantiation '%s' ignored.\n", SwigType_namestr(Getattr(ignored_node, "name")));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Parsing utilities.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_util_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include "cparse.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ Close(obj) Close
|
|||
|
||||
String Operations
|
||||
-----------------
|
||||
Replace(obj, orig, rep, flags) Replace occurences of orig with rep.
|
||||
Replace(obj, orig, rep, flags) Replace occurrences of orig with rep.
|
||||
Chop(obj) Remove trailing whitespace
|
||||
|
||||
flags is one of the following:
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
* DOH objects. A number of small utility functions are also included.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_base_c[] = "$Id$";
|
||||
|
||||
#include "dohint.h"
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -259,7 +257,7 @@ int DohEqual(const DOH *obj1, const DOH *obj2) {
|
|||
|
||||
if (!b1info) {
|
||||
return obj1 == obj2;
|
||||
} else if ((b1info == b2info)) {
|
||||
} else if (b1info == b2info) {
|
||||
return b1info->doh_equal ? (b1info->doh_equal) (b1, b2) : (b1info->doh_cmp ? (b1info->doh_cmp) (b1, b2) == 0 : (b1 == b2));
|
||||
} else {
|
||||
return 0;
|
||||
|
|
@ -645,7 +643,7 @@ int DohRead(DOH *obj, void *buffer, int length) {
|
|||
* DohWrite()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int DohWrite(DOH *obj, void *buffer, int length) {
|
||||
int DohWrite(DOH *obj, const void *buffer, int length) {
|
||||
DohBase *b = (DohBase *) obj;
|
||||
DohObjInfo *objinfo;
|
||||
if (DohCheck(obj)) {
|
||||
|
|
@ -761,6 +759,7 @@ int DohUngetc(int ch, DOH *obj) {
|
|||
* DohClose()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/*
|
||||
int DohClose(DOH *obj) {
|
||||
DohBase *b = (DohBase *) obj;
|
||||
DohObjInfo *objinfo;
|
||||
|
|
@ -773,6 +772,7 @@ int DohClose(DOH *obj) {
|
|||
}
|
||||
return fclose((FILE *) obj);
|
||||
}
|
||||
*/
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* DohIsString()
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ extern int DohDelslice(DOH *obj, int sindex, int eindex);
|
|||
|
||||
/* File methods */
|
||||
|
||||
extern int DohWrite(DOHFile * obj, void *buffer, int length);
|
||||
extern int DohWrite(DOHFile * obj, const void *buffer, int length);
|
||||
extern int DohRead(DOHFile * obj, void *buffer, int length);
|
||||
extern int DohSeek(DOHFile * obj, long offset, int whence);
|
||||
extern long DohTell(DOHFile * obj);
|
||||
|
|
@ -254,7 +254,7 @@ extern int DohDelmeta(DOH *, const DOH *);
|
|||
|
||||
/* Utility functions */
|
||||
|
||||
extern void DohEncoding(char *name, DOH *(*fn) (DOH *s));
|
||||
extern void DohEncoding(const char *name, DOH *(*fn) (DOH *s));
|
||||
extern int DohPrintf(DOHFile * obj, const char *format, ...);
|
||||
extern int DohvPrintf(DOHFile * obj, const char *format, va_list ap);
|
||||
extern int DohPrintv(DOHFile * obj, ...);
|
||||
|
|
@ -267,6 +267,8 @@ extern int DohIsSequence(const DOH *obj);
|
|||
extern int DohIsString(const DOH *obj);
|
||||
extern int DohIsFile(const DOH *obj);
|
||||
|
||||
extern void DohSetMaxHashExpand(int count);
|
||||
extern int DohGetMaxHashExpand(void);
|
||||
extern void DohSetmark(DOH *obj, int x);
|
||||
extern int DohGetmark(DOH *obj);
|
||||
|
||||
|
|
@ -275,9 +277,9 @@ extern int DohGetmark(DOH *obj);
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
extern DOHString *DohNewStringEmpty(void);
|
||||
extern DOHString *DohNewString(const DOH *c);
|
||||
extern DOHString *DohNewStringWithSize(const DOH *c, int len);
|
||||
extern DOHString *DohNewStringf(const DOH *fmt, ...);
|
||||
extern DOHString *DohNewString(const DOHString_or_char *c);
|
||||
extern DOHString *DohNewStringWithSize(const DOHString_or_char *c, int len);
|
||||
extern DOHString *DohNewStringf(const DOHString_or_char *fmt, ...);
|
||||
|
||||
extern int DohStrcmp(const DOHString_or_char *s1, const DOHString_or_char *s2);
|
||||
extern int DohStrncmp(const DOHString_or_char *s1, const DOHString_or_char *s2, int n);
|
||||
|
|
@ -292,6 +294,7 @@ extern char *DohStrchr(const DOHString_or_char *s1, int ch);
|
|||
#define DOH_REPLACE_FIRST 0x08
|
||||
#define DOH_REPLACE_ID_BEGIN 0x10
|
||||
#define DOH_REPLACE_ID_END 0x20
|
||||
#define DOH_REPLACE_NUMBER_END 0x40
|
||||
|
||||
#define Replaceall(s,t,r) DohReplace(s,t,r,DOH_REPLACE_ANY)
|
||||
#define Replaceid(s,t,r) DohReplace(s,t,r,DOH_REPLACE_ID)
|
||||
|
|
@ -304,7 +307,10 @@ extern DOHFile *DohNewFile(DOH *filename, const char *mode, DOHList *outfiles);
|
|||
extern DOHFile *DohNewFileFromFile(FILE *f);
|
||||
extern DOHFile *DohNewFileFromFd(int fd);
|
||||
extern void DohFileErrorDisplay(DOHString * filename);
|
||||
/*
|
||||
Deprecated, just use DohDelete
|
||||
extern int DohClose(DOH *file);
|
||||
*/
|
||||
extern int DohCopyto(DOHFile * input, DOHFile * output);
|
||||
|
||||
|
||||
|
|
@ -424,6 +430,8 @@ extern void DohMemoryDebug(void);
|
|||
#define SplitLines DohSplitLines
|
||||
#define Setmark DohSetmark
|
||||
#define Getmark DohGetmark
|
||||
#define SetMaxHashExpand DohSetMaxHashExpand
|
||||
#define GetMaxHashExpand DohGetMaxHashExpand
|
||||
#define None DohNone
|
||||
#define Call DohCall
|
||||
#define First DohFirst
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ typedef struct {
|
|||
/* File methods */
|
||||
typedef struct {
|
||||
int (*doh_read) (DOH *obj, void *buffer, int nbytes); /* Read bytes */
|
||||
int (*doh_write) (DOH *obj, void *buffer, int nbytes); /* Write bytes */
|
||||
int (*doh_write) (DOH *obj, const void *buffer, int nbytes); /* Write bytes */
|
||||
int (*doh_putc) (DOH *obj, int ch); /* Put character */
|
||||
int (*doh_getc) (DOH *obj); /* Get character */
|
||||
int (*doh_ungetc) (DOH *obj, int ch); /* Unget character */
|
||||
|
|
@ -54,7 +54,7 @@ typedef struct {
|
|||
|
||||
/* String methods */
|
||||
typedef struct {
|
||||
int (*doh_replace) (DOH *obj, DOH *old, DOH *rep, int flags);
|
||||
int (*doh_replace) (DOH *obj, const DOHString_or_char *old, const DOHString_or_char *rep, int flags);
|
||||
void (*doh_chop) (DOH *obj);
|
||||
} DohStringMethods;
|
||||
|
||||
|
|
@ -63,7 +63,7 @@ typedef struct {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
typedef struct DohObjInfo {
|
||||
char *objname; /* Object name */
|
||||
const char *objname; /* Object name */
|
||||
|
||||
/* Basic object methods */
|
||||
void (*doh_del) (DOH *obj); /* Delete object */
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
* ordinary FILE * or integer file descriptor.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_file_c[] = "$Id$";
|
||||
|
||||
#include "dohint.h"
|
||||
|
||||
#ifdef DOH_INTFILE
|
||||
|
|
@ -67,7 +65,7 @@ static int File_read(DOH *fo, void *buffer, int len) {
|
|||
* File_write()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int File_write(DOH *fo, void *buffer, int len) {
|
||||
static int File_write(DOH *fo, const void *buffer, int len) {
|
||||
DohFile *f = (DohFile *) ObjData(fo);
|
||||
if (f->filep) {
|
||||
int ret = (int) fwrite(buffer, 1, len, f->filep);
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
* formatted output, readline, and splitting.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_fio_c[] = "$Id$";
|
||||
|
||||
#include "dohint.h"
|
||||
|
||||
#define OBUFLEN 512
|
||||
|
|
@ -47,7 +45,7 @@ static int Writen(DOH *out, void *buffer, int len) {
|
|||
* two file-like objects and operate as a filter.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void DohEncoding(char *name, DOH *(*fn) (DOH *s)) {
|
||||
void DohEncoding(const char *name, DOH *(*fn) (DOH *s)) {
|
||||
if (!encodings)
|
||||
encodings = NewHash();
|
||||
Setattr(encodings, (void *) name, NewVoid((void *) fn, 0));
|
||||
|
|
@ -76,7 +74,8 @@ static DOH *encode(char *name, DOH *s) {
|
|||
Seek(s, 0, SEEK_SET);
|
||||
fn = (DOH *(*)(DOH *)) Data(handle);
|
||||
ns = (*fn) (s);
|
||||
Seek(s, pos, SEEK_SET);
|
||||
assert(pos != -1);
|
||||
(void)Seek(s, pos, SEEK_SET);
|
||||
if (tmp)
|
||||
Delete(tmp);
|
||||
return ns;
|
||||
|
|
@ -101,7 +100,7 @@ static DOH *encode(char *name, DOH *s) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int DohvPrintf(DOH *so, const char *format, va_list ap) {
|
||||
static char *fmt_codes = "dioxXucsSfeEgGpn";
|
||||
static const char *fmt_codes = "dioxXucsSfeEgGpn";
|
||||
int state = 0;
|
||||
const char *p = format;
|
||||
char newformat[256];
|
||||
|
|
@ -480,16 +479,19 @@ int DohCopyto(DOH *in, DOH *out) {
|
|||
cw = buffer;
|
||||
while (nwrite) {
|
||||
wret = Write(out, cw, nwrite);
|
||||
if (wret < 0)
|
||||
return -1;
|
||||
if (wret < 0) {
|
||||
nbytes = -1;
|
||||
break;
|
||||
}
|
||||
nwrite = nwrite - wret;
|
||||
cw += wret;
|
||||
}
|
||||
nbytes += ret;
|
||||
} else {
|
||||
return nbytes;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -577,15 +579,16 @@ DOH *DohReadline(DOH *in) {
|
|||
if (Read(in, &c, 1) < 0) {
|
||||
if (n == 0) {
|
||||
Delete(s);
|
||||
return 0;
|
||||
s = 0;
|
||||
}
|
||||
return s;
|
||||
break;
|
||||
}
|
||||
if (c == '\n')
|
||||
return s;
|
||||
break;
|
||||
if (c == '\r')
|
||||
continue;
|
||||
Putc(c, s);
|
||||
n++;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Implements a simple hash table object.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_hash_c[] = "$Id$";
|
||||
|
||||
#include "dohint.h"
|
||||
|
||||
extern DohObjInfo DohHashType;
|
||||
|
|
@ -42,6 +40,7 @@ typedef struct KeyValue {
|
|||
} KeyValue;
|
||||
|
||||
static KeyValue *root = 0;
|
||||
static int max_expand = 1;
|
||||
|
||||
/* Find or create a key in the interned key table */
|
||||
static DOH *find_key(DOH *doh_c) {
|
||||
|
|
@ -362,7 +361,7 @@ static DohIterator Hash_nextiter(DohIterator iter) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Hash_keys(DOH *)
|
||||
* Hash_keys()
|
||||
*
|
||||
* Return a list of keys
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -378,6 +377,26 @@ static DOH *Hash_keys(DOH *so) {
|
|||
return keys;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* DohSetMaxHashExpand()
|
||||
*
|
||||
* Controls how many Hash objects are displayed in full in Hash_str
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void DohSetMaxHashExpand(int count) {
|
||||
max_expand = count;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* DohGetMaxHashExpand()
|
||||
*
|
||||
* Returns how many Hash objects are displayed in full in Hash_str
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int DohGetMaxHashExpand(void) {
|
||||
return max_expand;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Hash_str()
|
||||
*
|
||||
|
|
@ -388,30 +407,44 @@ static DOH *Hash_str(DOH *ho) {
|
|||
int i, j;
|
||||
HashNode *n;
|
||||
DOH *s;
|
||||
static int indent = 4;
|
||||
static int expanded = 0;
|
||||
static const char *tab = " ";
|
||||
Hash *h = (Hash *) ObjData(ho);
|
||||
|
||||
s = NewStringEmpty();
|
||||
if (ObjGetMark(ho)) {
|
||||
Printf(s, "Hash(0x%x)", ho);
|
||||
Printf(s, "Hash(%p)", ho);
|
||||
return s;
|
||||
}
|
||||
if (expanded >= max_expand) {
|
||||
/* replace each hash attribute with a '.' */
|
||||
Printf(s, "Hash(%p) {", ho);
|
||||
for (i = 0; i < h->hashsize; i++) {
|
||||
n = h->hashtable[i];
|
||||
while (n) {
|
||||
Putc('.', s);
|
||||
n = n->next;
|
||||
}
|
||||
}
|
||||
Putc('}', s);
|
||||
return s;
|
||||
}
|
||||
ObjSetMark(ho, 1);
|
||||
Printf(s, "Hash {\n");
|
||||
Printf(s, "Hash(%p) {\n", ho);
|
||||
for (i = 0; i < h->hashsize; i++) {
|
||||
n = h->hashtable[i];
|
||||
while (n) {
|
||||
for (j = 0; j < indent; j++)
|
||||
Putc(' ', s);
|
||||
indent += 4;
|
||||
for (j = 0; j < expanded + 1; j++)
|
||||
Printf(s, tab);
|
||||
expanded += 1;
|
||||
Printf(s, "'%s' : %s, \n", n->key, n->object);
|
||||
indent -= 4;
|
||||
expanded -= 1;
|
||||
n = n->next;
|
||||
}
|
||||
}
|
||||
for (j = 0; j < (indent - 4); j++)
|
||||
Putc(' ', s);
|
||||
Printf(s, "}\n");
|
||||
for (j = 0; j < expanded; j++)
|
||||
Printf(s, tab);
|
||||
Printf(s, "}");
|
||||
ObjSetMark(ho, 0);
|
||||
return s;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Implements a simple list object.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_list_c[] = "$Id$";
|
||||
|
||||
#include "dohint.h"
|
||||
|
||||
typedef struct List {
|
||||
|
|
@ -242,7 +240,7 @@ static DOH *List_str(DOH *lo) {
|
|||
List *l = (List *) ObjData(lo);
|
||||
s = NewStringEmpty();
|
||||
if (ObjGetMark(lo)) {
|
||||
Printf(s, "List(%x)", lo);
|
||||
Printf(s, "List(%p)", lo);
|
||||
return s;
|
||||
}
|
||||
ObjSetMark(lo, 1);
|
||||
|
|
@ -252,7 +250,7 @@ static DOH *List_str(DOH *lo) {
|
|||
if ((i + 1) < l->nitems)
|
||||
Printf(s, ", ");
|
||||
}
|
||||
Printf(s, " ]\n");
|
||||
Printf(s, " ]");
|
||||
ObjSetMark(lo, 0);
|
||||
return s;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,14 +12,17 @@
|
|||
* of objects and checking of objects.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_memory_c[] = "$Id$";
|
||||
|
||||
#include "dohint.h"
|
||||
|
||||
#ifndef DOH_POOL_SIZE
|
||||
#define DOH_POOL_SIZE 16384
|
||||
#endif
|
||||
|
||||
/* Checks stale DOH object use - will use a lot more memory as pool memory is not re-used. */
|
||||
/*
|
||||
#define DOH_DEBUG_MEMORY_POOLS
|
||||
*/
|
||||
|
||||
static int PoolSize = DOH_POOL_SIZE;
|
||||
|
||||
DOH *DohNone = 0; /* The DOH None object */
|
||||
|
|
@ -81,8 +84,14 @@ int DohCheck(const DOH *ptr) {
|
|||
register Pool *p = Pools;
|
||||
register char *cptr = (char *) ptr;
|
||||
while (p) {
|
||||
if ((cptr >= p->pbeg) && (cptr < p->pend))
|
||||
if ((cptr >= p->pbeg) && (cptr < p->pend)) {
|
||||
#ifdef DOH_DEBUG_MEMORY_POOLS
|
||||
DohBase *b = (DohBase *) ptr;
|
||||
int DOH_object_already_deleted = b->type == 0;
|
||||
assert(!DOH_object_already_deleted);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
/*
|
||||
pptr = (char *) p->ptr;
|
||||
if ((cptr >= pptr) && (cptr < (pptr+(p->current*sizeof(DohBase))))) return 1; */
|
||||
|
|
@ -110,16 +119,20 @@ DOH *DohObjMalloc(DohObjInfo *type, void *data) {
|
|||
DohBase *obj;
|
||||
if (!pools_initialized)
|
||||
InitPools();
|
||||
#ifndef DOH_DEBUG_MEMORY_POOLS
|
||||
if (FreeList) {
|
||||
obj = FreeList;
|
||||
FreeList = (DohBase *) obj->data;
|
||||
} else {
|
||||
#endif
|
||||
while (Pools->current == Pools->len) {
|
||||
CreatePool();
|
||||
}
|
||||
obj = Pools->ptr + Pools->current;
|
||||
++Pools->current;
|
||||
#ifndef DOH_DEBUG_MEMORY_POOLS
|
||||
}
|
||||
#endif
|
||||
obj->type = type;
|
||||
obj->data = data;
|
||||
obj->meta = 0;
|
||||
|
|
@ -144,6 +157,7 @@ void DohObjFree(DOH *ptr) {
|
|||
b->data = (void *) FreeList;
|
||||
b->meta = 0;
|
||||
b->type = 0;
|
||||
b->refcount = 0;
|
||||
FreeList = b;
|
||||
if (meta) {
|
||||
Delete(meta);
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
* file semantics.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_string_c[] = "$Id$";
|
||||
|
||||
#include "dohint.h"
|
||||
|
||||
extern DohObjInfo DohStringType;
|
||||
|
|
@ -29,7 +27,7 @@ typedef struct String {
|
|||
} String;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void *String_data() - Return as a 'void *'
|
||||
* String_data() - Return as a 'void *'
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void *String_data(DOH *so) {
|
||||
|
|
@ -44,7 +42,7 @@ static void *String_data(DOH *so) {
|
|||
*/
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_dump() - Serialize a string onto out
|
||||
* String_dump() - Serialize a string onto out
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_dump(DOH *so, DOH *out) {
|
||||
|
|
@ -105,7 +103,7 @@ static int String_len(DOH *so) {
|
|||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_cmp() - Compare two strings
|
||||
* String_cmp() - Compare two strings
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_cmp(DOH *so1, DOH *so2) {
|
||||
|
|
@ -137,7 +135,7 @@ static int String_cmp(DOH *so1, DOH *so2) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_equal() - Say if two string are equal
|
||||
* String_equal() - Say if two string are equal
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_equal(DOH *so1, DOH *so2) {
|
||||
|
|
@ -174,7 +172,7 @@ static int String_equal(DOH *so1, DOH *so2) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_hash() - Compute string hash value
|
||||
* String_hash() - Compute string hash value
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_hash(DOH *so) {
|
||||
|
|
@ -203,10 +201,10 @@ static int String_hash(DOH *so) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* DohString_append(String *s, const char *newstr) - Append to s
|
||||
* DohString_append() - Append to s
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void DohString_append(DOH *so, DOH *str) {
|
||||
static void DohString_append(DOH *so, const DOHString_or_char *str) {
|
||||
int oldlen, newlen, newmaxsize, l, sp;
|
||||
char *tc;
|
||||
String *s = (String *) ObjData(so);
|
||||
|
|
@ -251,7 +249,7 @@ void DohString_append(DOH *so, DOH *str) {
|
|||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void String_clear() - Clear a string
|
||||
* String_clear() - Clear a string
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void String_clear(DOH *so) {
|
||||
|
|
@ -264,12 +262,11 @@ static void String_clear(DOH *so) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void String_insert() - Insert a string
|
||||
* String_insert() - Insert a string
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_insert(DOH *so, int pos, DOH *str) {
|
||||
String *s;
|
||||
char *nstr;
|
||||
int len;
|
||||
char *data;
|
||||
|
||||
|
|
@ -289,7 +286,6 @@ static int String_insert(DOH *so, int pos, DOH *str) {
|
|||
data = (char *) (str);
|
||||
len = (int) strlen(data);
|
||||
}
|
||||
nstr = s->str;
|
||||
|
||||
if (pos < 0)
|
||||
pos = 0;
|
||||
|
|
@ -320,7 +316,7 @@ static int String_insert(DOH *so, int pos, DOH *str) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_delitem() - Delete a character
|
||||
* String_delitem() - Delete a character
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_delitem(DOH *so, int pos) {
|
||||
|
|
@ -346,7 +342,7 @@ static int String_delitem(DOH *so, int pos) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_delslice() - Delete a range
|
||||
* String_delslice() - Delete a range
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_delslice(DOH *so, int sindex, int eindex) {
|
||||
|
|
@ -384,7 +380,7 @@ static int String_delslice(DOH *so, int sindex, int eindex) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* DOH *String_str() - Returns a string (used by printing commands)
|
||||
* String_str() - Returns a string (used by printing commands)
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static DOH *String_str(DOH *so) {
|
||||
|
|
@ -394,7 +390,7 @@ static DOH *String_str(DOH *so) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_read() - Read data from a string
|
||||
* String_read() - Read data from a string
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_read(DOH *so, void *buffer, int len) {
|
||||
|
|
@ -417,9 +413,9 @@ static int String_read(DOH *so, void *buffer, int len) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_write() - Write data to a string
|
||||
* String_write() - Write data to a string
|
||||
* ----------------------------------------------------------------------------- */
|
||||
static int String_write(DOH *so, void *buffer, int len) {
|
||||
static int String_write(DOH *so, const void *buffer, int len) {
|
||||
int newlen;
|
||||
String *s = (String *) ObjData(so);
|
||||
s->hashkey = -1;
|
||||
|
|
@ -441,7 +437,7 @@ static int String_write(DOH *so, void *buffer, int len) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_seek() - Seek to a new position
|
||||
* String_seek() - Seek to a new position
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_seek(DOH *so, long offset, int whence) {
|
||||
|
|
@ -498,7 +494,7 @@ static int String_seek(DOH *so, long offset, int whence) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* long String_tell() - Return current position
|
||||
* String_tell() - Return current position
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static long String_tell(DOH *so) {
|
||||
|
|
@ -507,7 +503,7 @@ static long String_tell(DOH *so) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_putc()
|
||||
* String_putc()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_putc(DOH *so, int ch) {
|
||||
|
|
@ -538,7 +534,7 @@ static int String_putc(DOH *so, int ch) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_getc()
|
||||
* String_getc()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_getc(DOH *so) {
|
||||
|
|
@ -554,7 +550,7 @@ static int String_getc(DOH *so) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_ungetc()
|
||||
* String_ungetc()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_ungetc(DOH *so, int ch) {
|
||||
|
|
@ -569,12 +565,6 @@ static int String_ungetc(DOH *so, int ch) {
|
|||
return ch;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* replace_simple(String *str, char *token, char *rep, int flags, int count)
|
||||
*
|
||||
* Replaces count non-overlapping occurrences of token with rep in a string.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static char *end_quote(char *s) {
|
||||
char *qs;
|
||||
char qc;
|
||||
|
|
@ -659,6 +649,27 @@ static char *match_identifier_end(char *base, char *s, char *token, int tokenlen
|
|||
return 0;
|
||||
}
|
||||
|
||||
static char *match_number_end(char *base, char *s, char *token, int tokenlen) {
|
||||
(void) base;
|
||||
while (s) {
|
||||
s = strstr(s, token);
|
||||
if (!s)
|
||||
return 0;
|
||||
if (isdigit((int) *(s + tokenlen))) {
|
||||
s += tokenlen;
|
||||
continue;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* replace_simple()
|
||||
*
|
||||
* Replaces count non-overlapping occurrences of token with rep in a string.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int replace_simple(String *str, char *token, char *rep, int flags, int count, char *(*match) (char *, char *, char *, int)) {
|
||||
int tokenlen; /* Length of the token */
|
||||
int replen; /* Length of the replacement */
|
||||
|
|
@ -885,10 +896,10 @@ static int replace_simple(String *str, char *token, char *rep, int flags, int co
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* int String_replace()
|
||||
* String_replace()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int String_replace(DOH *stro, DOH *token, DOH *rep, int flags) {
|
||||
static int String_replace(DOH *stro, const DOHString_or_char *token, const DOHString_or_char *rep, int flags) {
|
||||
int count = -1;
|
||||
String *str = (String *) ObjData(stro);
|
||||
|
||||
|
|
@ -901,13 +912,15 @@ static int String_replace(DOH *stro, DOH *token, DOH *rep, int flags) {
|
|||
return replace_simple(str, Char(token), Char(rep), flags, count, match_identifier_begin);
|
||||
} else if (flags & DOH_REPLACE_ID) {
|
||||
return replace_simple(str, Char(token), Char(rep), flags, count, match_identifier);
|
||||
} else if (flags & DOH_REPLACE_NUMBER_END) {
|
||||
return replace_simple(str, Char(token), Char(rep), flags, count, match_number_end);
|
||||
} else {
|
||||
return replace_simple(str, Char(token), Char(rep), flags, count, match_simple);
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void String_chop(DOH *str)
|
||||
* String_chop()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void String_chop(DOH *so) {
|
||||
|
|
@ -1012,10 +1025,10 @@ DohObjInfo DohStringType = {
|
|||
#define INIT_MAXSIZE 16
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* NewString(const char *c) - Create a new string
|
||||
* NewString() - Create a new string
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
DOHString *DohNewString(const DOH *so) {
|
||||
DOHString *DohNewString(const DOHString_or_char *so) {
|
||||
int l = 0, max;
|
||||
String *str;
|
||||
char *s;
|
||||
|
|
@ -1073,10 +1086,10 @@ DOHString *DohNewStringEmpty(void) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* NewStringWithSize(const char *c, int len) - Create a new string
|
||||
* NewStringWithSize() - Create a new string
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
DOHString *DohNewStringWithSize(const DOH *so, int len) {
|
||||
DOHString *DohNewStringWithSize(const DOHString_or_char *so, int len) {
|
||||
int l = 0, max;
|
||||
String *str;
|
||||
char *s;
|
||||
|
|
@ -1111,12 +1124,12 @@ DOHString *DohNewStringWithSize(const DOH *so, int len) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* NewStringf(DOH *fmt, ...)
|
||||
* NewStringf()
|
||||
*
|
||||
* Create a new string from a list of objects.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
DOHString *DohNewStringf(const DOH *fmt, ...) {
|
||||
DOHString *DohNewStringf(const DOHString_or_char *fmt, ...) {
|
||||
va_list ap;
|
||||
DOH *r;
|
||||
va_start(ap, fmt);
|
||||
|
|
@ -1138,11 +1151,7 @@ DOHString *DohNewStringf(const DOH *fmt, ...) {
|
|||
int DohStrcmp(const DOHString_or_char *s1, const DOHString_or_char *s2) {
|
||||
const char *c1 = Char(s1);
|
||||
const char *c2 = Char(s2);
|
||||
if (c1 && c2) {
|
||||
return strcmp(c1, c2);
|
||||
} else {
|
||||
return c1 < c2;
|
||||
}
|
||||
return strcmp(c1, c2);
|
||||
}
|
||||
|
||||
int DohStrncmp(const DOHString_or_char *s1, const DOHString_or_char *s2, int n) {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
* an arbitrary C object represented as a void *.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_void_c[] = "$Id$";
|
||||
|
||||
#include "dohint.h"
|
||||
|
||||
typedef struct {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* -----------------------------------------------------------------------------
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
/* -----------------------------------------------------------------------------
|
||||
* This file is part of SWIG, which is licensed as a whole under version 3
|
||||
* (or any later version) of the GNU General Public License. Some additional
|
||||
* terms also apply to certain portions of SWIG. The full details of the SWIG
|
||||
* license and copyrights can be found in the LICENSE and COPYRIGHT files
|
||||
|
|
@ -60,6 +60,7 @@
|
|||
#define WARN_PP_INCLUDEALL_IMPORTALL 203
|
||||
#define WARN_PP_CPP_WARNING 204
|
||||
#define WARN_PP_CPP_ERROR 205
|
||||
#define WARN_PP_UNEXPECTED_TOKENS 206
|
||||
|
||||
/* -- C/C++ Parser -- */
|
||||
|
||||
|
|
@ -198,15 +199,39 @@
|
|||
#define WARN_LANG_DIRECTOR_ABSTRACT 517
|
||||
#define WARN_LANG_PORTABILITY_FILENAME 518
|
||||
#define WARN_LANG_TEMPLATE_METHOD_IGNORE 519
|
||||
#define WARN_LANG_INITIALIZER_LIST 520
|
||||
#define WARN_LANG_SMARTPTR_MISSING 520
|
||||
#define WARN_LANG_ILLEGAL_DESTRUCTOR 521
|
||||
#define WARN_LANG_INITIALIZER_LIST 522
|
||||
|
||||
/* -- Reserved (600-799) -- */
|
||||
|
||||
/* -- Language module specific warnings (800 - 999) -- */
|
||||
/* -- Language module specific warnings (700 - 899) -- */
|
||||
|
||||
/* Feel free to claim any number in this space that's not currently being used. Just make sure you
|
||||
add an entry here */
|
||||
|
||||
#define WARN_D_TYPEMAP_CTYPE_UNDEF 700
|
||||
#define WARN_D_TYPEMAP_IMTYPE_UNDEF 701
|
||||
#define WARN_D_TYPEMAP_DTYPE_UNDEF 702
|
||||
#define WARN_D_MULTIPLE_INHERITANCE 703
|
||||
#define WARN_D_TYPEMAP_CLASSMOD_UNDEF 704
|
||||
#define WARN_D_TYPEMAP_DBODY_UNDEF 705
|
||||
#define WARN_D_TYPEMAP_DOUT_UNDEF 706
|
||||
#define WARN_D_TYPEMAP_DIN_UNDEF 707
|
||||
#define WARN_D_TYPEMAP_DDIRECTORIN_UNDEF 708
|
||||
#define WARN_D_TYPEMAP_DCONSTRUCTOR_UNDEF 709
|
||||
#define WARN_D_EXCODE_MISSING 710
|
||||
#define WARN_D_CANTHROW_MISSING 711
|
||||
#define WARN_D_NO_DIRECTORCONNECT_ATTR 712
|
||||
#define WARN_D_NAME_COLLISION 713
|
||||
|
||||
/* please leave 700-719 free for D */
|
||||
|
||||
#define WARN_RUBY_WRONG_NAME 801
|
||||
#define WARN_RUBY_MULTIPLE_INHERITANCE 802
|
||||
|
||||
/* please leave 800-809 free for Ruby */
|
||||
|
||||
#define WARN_JAVA_TYPEMAP_JNI_UNDEF 810
|
||||
#define WARN_JAVA_TYPEMAP_JTYPE_UNDEF 811
|
||||
#define WARN_JAVA_TYPEMAP_JSTYPE_UNDEF 812
|
||||
|
|
@ -222,6 +247,7 @@
|
|||
#define WARN_JAVA_TYPEMAP_JAVACONSTRUCT_UNDEF 823
|
||||
#define WARN_JAVA_TYPEMAP_DIRECTORIN_NODESC 824
|
||||
#define WARN_JAVA_NO_DIRECTORCONNECT_ATTR 825
|
||||
#define WARN_JAVA_NSPACE_WITHOUT_PACKAGE 826
|
||||
|
||||
/* please leave 810-829 free for Java */
|
||||
|
||||
|
|
@ -268,7 +294,6 @@
|
|||
|
||||
/* please leave 890-899 free for Go */
|
||||
|
||||
/* Feel free to claim any number in this space that's not currently being used. Just make sure you
|
||||
add an entry here */
|
||||
/* -- User defined warnings (900 - 999) -- */
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ eswig_SOURCES = CParse/cscanner.c \
|
|||
Modules/clisp.cxx \
|
||||
Modules/contract.cxx \
|
||||
Modules/csharp.cxx \
|
||||
Modules/d.cxx \
|
||||
Modules/directors.cxx \
|
||||
Modules/emit.cxx \
|
||||
Modules/go.cxx \
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* ALLEGROCL language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_allegrocl_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
#include <ctype.h>
|
||||
|
|
@ -22,6 +20,21 @@ char cvsroot_allegrocl_cxx[] = "$Id$";
|
|||
// #define ALLEGROCL_TYPE_DEBUG
|
||||
// #define ALLEGROCL_CLASS_DEBUG
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
Allegro CL Options (available with -allegrocl)\n\
|
||||
-identifier-converter <type or funcname> - \n\
|
||||
Specifies the type of conversion to do on C identifiers to convert\n\
|
||||
them to symbols. There are two built-in converters: 'null' and\n\
|
||||
'lispify'. The default is 'null'. If you supply a name other\n\
|
||||
than one of the built-ins, then a function by that name will be\n\
|
||||
called to convert identifiers to symbols.\n\
|
||||
-[no]cwrap - Turn on or turn off generation of an intermediate C file when\n\
|
||||
creating a C interface. By default this is only done for C++ code.\n\
|
||||
-isolate - Define all SWIG helper functions in a package unique to this\n\
|
||||
module. Avoids redefinition warnings when loading multiple\n\
|
||||
SWIGged modules into the same running Allegro CL image.\n\
|
||||
";
|
||||
|
||||
static File *f_cl = 0;
|
||||
String *f_clhead = NewString("");
|
||||
String *f_clwrap = NewString("(swig-in-package ())\n\n");
|
||||
|
|
@ -33,7 +46,7 @@ static File *f_cxx_wrapper = 0;
|
|||
static String *module_name = 0;
|
||||
static String *swig_package = 0;
|
||||
|
||||
const char *identifier_converter = "identifier-convert-null";
|
||||
static String *identifier_converter = NewString("identifier-convert-null");
|
||||
|
||||
static bool CWrap = true; // generate wrapper file for C code by default. most correct.
|
||||
static bool Generate_Wrapper = false;
|
||||
|
|
@ -147,34 +160,12 @@ String *namespaced_name(Node *n, String *ns = current_namespace) {
|
|||
|
||||
// "Namespace::Nested::Class2::Baz" -> "Baz"
|
||||
static String *strip_namespaces(String *str) {
|
||||
char *result = Char(str);
|
||||
String *stripped_one;
|
||||
while ((stripped_one = Strstr(result, "::")))
|
||||
result = Char(stripped_one) + 2;
|
||||
return NewString(result);
|
||||
}
|
||||
|
||||
static String *namespace_of(String *str) {
|
||||
char *p = Char(str);
|
||||
char *start = Char(str);
|
||||
char *result = 0;
|
||||
String *stripped_one;
|
||||
|
||||
while ((stripped_one = Strstr(p, "::"))) {
|
||||
p = Char(stripped_one) + 2;
|
||||
}
|
||||
if (p > start) {
|
||||
int len = p - start - 1;
|
||||
result = (char *) malloc(len);
|
||||
strncpy(result, start, len - 1);
|
||||
result[len - 1] = 0;
|
||||
}
|
||||
return Char(result);
|
||||
return Swig_scopename_last(str);
|
||||
}
|
||||
|
||||
void add_linked_type(Node *n) {
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "Adding linked node of type: %s(%s) %s(%x)\n\n", nodeType(n), Getattr(n, "storage"), Getattr(n, "name"), n);
|
||||
Printf(stderr, "Adding linked node of type: %s(%s) %s(%p)\n\n", nodeType(n), Getattr(n, "storage"), Getattr(n, "name"), n);
|
||||
// Swig_print_node(n);
|
||||
#endif
|
||||
if (!first_linked_type) {
|
||||
|
|
@ -268,13 +259,13 @@ Node *get_primary_synonym_of(Node *n) {
|
|||
Node *p = Getattr(n, "allegrocl:synonym-of");
|
||||
Node *prim = n;
|
||||
|
||||
// Printf(stderr, "getting primary synonym of %x\n", n);
|
||||
// Printf(stderr, "getting primary synonym of %p\n", n);
|
||||
while (p) {
|
||||
// Printf(stderr, " found one! %x\n", p);
|
||||
// Printf(stderr, " found one! %p\n", p);
|
||||
prim = p;
|
||||
p = Getattr(p, "allegrocl:synonym-of");
|
||||
}
|
||||
// Printf(stderr,"get_primary_syn: DONE. returning %s(%x)\n", Getattr(prim,"name"),prim);
|
||||
// Printf(stderr,"get_primary_syn: DONE. returning %s(%p)\n", Getattr(prim,"name"),prim);
|
||||
return prim;
|
||||
}
|
||||
|
||||
|
|
@ -299,7 +290,7 @@ void add_forward_referenced_type(Node *n, int overwrite = 0) {
|
|||
// , name);
|
||||
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "Linking forward reference type = %s(%x)\n", k, n);
|
||||
Printf(stderr, "Linking forward reference type = %s(%p)\n", k, n);
|
||||
#endif
|
||||
add_linked_type(n);
|
||||
}
|
||||
|
|
@ -311,11 +302,11 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
|
|||
String *val;
|
||||
String *ns_list = listify_namespace(ns);
|
||||
String *templated = n ? Getattr(n, "template") : 0;
|
||||
String *cDeclName = n ? Getattr(n, "classDeclaration:name") : 0;
|
||||
String *cDeclName = n ? Getattr(n, "name") : 0;
|
||||
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "IN A-D-F-T. (n=%x, ow=%d, k=%s, name=%s, ns=%s\n", n, overwrite, k, name, ns);
|
||||
Printf(stderr, " templated = '%x', classDecl = '%x'\n", templated, cDeclName);
|
||||
Printf(stderr, "IN A-D-F-T. (n=%p, ow=%d, k=%s, name=%s, ns=%s\n", n, overwrite, k, name, ns);
|
||||
Printf(stderr, " templated = '%p', classDecl = '%p'\n", templated, cDeclName);
|
||||
#endif
|
||||
if (n) {
|
||||
if (!name)
|
||||
|
|
@ -424,11 +415,12 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
|
|||
}
|
||||
}
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "looking to add %s/%s(%x) to linked_type_list...\n", k, name, n);
|
||||
Printf(stderr, "looking to add %s/%s(%p) to linked_type_list...\n", k, name, n);
|
||||
#endif
|
||||
if (is_fwd_ref) {
|
||||
// Printf(stderr,"*** 1\n");
|
||||
add_linked_type(n);
|
||||
if (n)
|
||||
add_linked_type(n);
|
||||
} else {
|
||||
// Printf(stderr,"*** 1-a\n");
|
||||
if (SwigType_istemplate(k)) {
|
||||
|
|
@ -477,7 +469,7 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
|
|||
Setattr(new_node, "allegrocl:synonym:is-primary", "1");
|
||||
} else {
|
||||
// a synonym type was found (held in variable 'match')
|
||||
// Printf(stderr, "setting primary synonym of %x to %x\n", new_node, match);
|
||||
// Printf(stderr, "setting primary synonym of %p to %p\n", new_node, match);
|
||||
if (new_node == match)
|
||||
Printf(stderr, "Hey-4 * - '%s' is a synonym of iteself!\n", Getattr(new_node, "name"));
|
||||
Setattr(new_node, "allegrocl:synonym-of", match);
|
||||
|
|
@ -524,8 +516,8 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
|
|||
Setattr(n, "allegrocl:synonym-of", match);
|
||||
Setattr(n, "real-name", Copy(lookup_type));
|
||||
|
||||
// Printf(stderr, "*** pre-5: found match of '%s'(%x)\n", Getattr(match,"name"),match);
|
||||
// if(n == match) Printf(stderr, "Hey-5 *** setting synonym of %x to %x\n", n, match);
|
||||
// Printf(stderr, "*** pre-5: found match of '%s'(%p)\n", Getattr(match,"name"),match);
|
||||
// if(n == match) Printf(stderr, "Hey-5 *** setting synonym of %p to %p\n", n, match);
|
||||
// Printf(stderr,"*** 5\n");
|
||||
add_linked_type(n);
|
||||
} else {
|
||||
|
|
@ -583,7 +575,7 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
|
|||
match = find_linked_type_by_name(resolved);
|
||||
if (!match) {
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "found no implicit instantiation of %%template node %s(%x)\n", Getattr(n, "name"), n);
|
||||
Printf(stderr, "found no implicit instantiation of %%template node %s(%p)\n", Getattr(n, "name"), n);
|
||||
#endif
|
||||
add_linked_type(n);
|
||||
} else {
|
||||
|
|
@ -592,14 +584,14 @@ void add_defined_foreign_type(Node *n, int overwrite = 0, String *k = 0,
|
|||
Setattr(n, "allegrocl:synonym:is-primary", "1");
|
||||
Delattr(primary, "allegrocl:synonym:is-primary");
|
||||
if (n == match)
|
||||
Printf(stderr, "Hey-7 * setting synonym of %x to %x\n (match = %x)", primary, n, match);
|
||||
Printf(stderr, "Hey-7 * setting synonym of %p to %p\n (match = %p)", primary, n, match);
|
||||
Setattr(primary, "allegrocl:synonym-of", n);
|
||||
// Printf(stderr,"*** 7\n");
|
||||
add_linked_type(n);
|
||||
}
|
||||
} else {
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "linking type '%s'(%x)\n", k, n);
|
||||
Printf(stderr, "linking type '%s'(%p)\n", k, n);
|
||||
#endif
|
||||
// Printf(stderr,"*** 8\n");
|
||||
add_linked_type(n);
|
||||
|
|
@ -629,8 +621,12 @@ void note_implicit_template_instantiation(SwigType *t) {
|
|||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "culling namespace of '%s' from '%s'\n", t, SwigType_templateprefix(t));
|
||||
#endif
|
||||
String *implicit_ns = namespace_of(SwigType_templateprefix(t));
|
||||
SwigType *type = Copy(t);
|
||||
SwigType *tok = SwigType_pop(type);
|
||||
String *implicit_ns = SwigType_istemplate(tok) ? Swig_scopename_prefix(SwigType_templateprefix(tok)) : 0;
|
||||
add_defined_foreign_type(0, 0, t, t, implicit_ns ? implicit_ns : current_namespace);
|
||||
|
||||
Delete(type);
|
||||
}
|
||||
|
||||
String *get_ffi_type(Node *n, SwigType *ty, const_String_or_char_ptr name) {
|
||||
|
|
@ -785,7 +781,7 @@ String *compose_foreign_type(Node *n, SwigType *ty, String * /*id*/ = 0) {
|
|||
Printf(stderr, "compose_foreign_type: ENTER (%s)...\n ", ty);
|
||||
// Printf(stderr, "compose_foreign_type: ENTER (%s)(%s)...\n ", ty, (id ? id : 0));
|
||||
/* String *id_ref = SwigType_str(ty, id);
|
||||
Printf(stderr, "looking up typemap for %s, found '%s'(%x)\n",
|
||||
Printf(stderr, "looking up typemap for %s, found '%s'(%p)\n",
|
||||
id_ref, lookup_res ? Getattr(lookup_res, "code") : 0, lookup_res);
|
||||
if (lookup_res) Swig_print_node(lookup_res);
|
||||
*/
|
||||
|
|
@ -824,7 +820,7 @@ void update_package_if_needed(Node *n, File *f = f_clwrap) {
|
|||
Printf(stderr, "update_package: ENTER... \n");
|
||||
Printf(stderr, " current_package = '%s'\n", current_package);
|
||||
Printf(stderr, " node_package = '%s'\n", Getattr(n, "allegrocl:package"));
|
||||
Printf(stderr, " node(%x) = '%s'\n", n, Getattr(n, "name"));
|
||||
Printf(stderr, " node(%p) = '%s'\n", n, Getattr(n, "name"));
|
||||
#endif
|
||||
String *node_package = Getattr(n, "allegrocl:package");
|
||||
if (Strcmp(current_package, node_package)) {
|
||||
|
|
@ -1083,7 +1079,8 @@ String *convert_literal(String *literal, String *type, bool try_to_split) {
|
|||
void emit_stub_class(Node *n) {
|
||||
|
||||
#ifdef ALLEGROCL_WRAP_DEBUG
|
||||
Printf(stderr, "emit_stub_class: ENTER... '%s'(%x)\n", Getattr(n, "sym:name"), n);
|
||||
Printf(stderr, "emit_stub_class: ENTER... '%s'(%p)\n", Getattr(n, "sym:name"), n);
|
||||
Swig_print_node(n);
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -1120,7 +1117,7 @@ void emit_synonym(Node *synonym) {
|
|||
Printf(stderr, "emit_synonym: ENTER... \n");
|
||||
#endif
|
||||
|
||||
// Printf(stderr,"in emit_synonym for %s(%x)\n", Getattr(synonym,"name"),synonym);
|
||||
// Printf(stderr,"in emit_synonym for %s(%p)\n", Getattr(synonym,"name"),synonym);
|
||||
int is_tempInst = !Strcmp(nodeType(synonym), "templateInst");
|
||||
String *synonym_type;
|
||||
|
||||
|
|
@ -1144,13 +1141,14 @@ void emit_synonym(Node *synonym) {
|
|||
String *of_name = namespaced_name(of, of_ns);
|
||||
|
||||
if (CPlusPlus && !Strcmp(nodeType(synonym), "cdecl")) {
|
||||
syn_ltype = NewStringf("#.(swig-insert-id \"%s\" %s :type :class)",
|
||||
strip_namespaces(Getattr(synonym, "real-name")), synonym_ns);
|
||||
syn_type = NewStringf("#.(swig-insert-id \"%s\" %s :type :type)",
|
||||
strip_namespaces(Getattr(synonym, "real-name")), synonym_ns);
|
||||
String *real_name = Getattr(synonym, "real-name");
|
||||
if (!real_name)
|
||||
real_name = NewString("Unknown"); // TODO: fix
|
||||
syn_ltype = NewStringf("#.(swig-insert-id \"%s\" %s :type :class)", strip_namespaces(real_name), synonym_ns);
|
||||
syn_type = NewStringf("#.(swig-insert-id \"%s\" %s :type :type)", strip_namespaces(real_name), synonym_ns);
|
||||
} else {
|
||||
syn_ltype = lookup_defined_foreign_ltype(synonym_type);
|
||||
syn_type = lookup_defined_foreign_type(synonym_type);
|
||||
syn_ltype = lookup_defined_foreign_ltype(synonym_type);
|
||||
syn_type = lookup_defined_foreign_type(synonym_type);
|
||||
}
|
||||
|
||||
of_ltype = lookup_defined_foreign_ltype(of_name);
|
||||
|
|
@ -1177,7 +1175,7 @@ void emit_full_class(Node *n) {
|
|||
String *name = Getattr(n, "sym:name");
|
||||
String *kind = Getattr(n, "kind");
|
||||
|
||||
// Printf(stderr,"in emit_full_class: '%s'(%x).", Getattr(n,"name"),n);
|
||||
// Printf(stderr,"in emit_full_class: '%s'(%p).", Getattr(n,"name"),n);
|
||||
if (Getattr(n, "allegrocl:synonym-of")) {
|
||||
// Printf(stderr,"but it's a synonym of something.\n");
|
||||
update_package_if_needed(n, f_clhead);
|
||||
|
|
@ -1206,7 +1204,8 @@ void emit_full_class(Node *n) {
|
|||
Printf(supers, "ff:foreign-pointer");
|
||||
}
|
||||
|
||||
Printf(supers, ")");
|
||||
// check for "feature:aclmixins" and add those as well.
|
||||
Printf(supers, " %s)", Getattr(n,"feature:aclmixins"));
|
||||
|
||||
// Walk children to generate type definition.
|
||||
String *slotdefs = NewString(" ");
|
||||
|
|
@ -1224,7 +1223,7 @@ void emit_full_class(Node *n) {
|
|||
// hack. why would decl have a value of "variableHandler" and now "0"?
|
||||
String *childDecl = Getattr(c, "decl");
|
||||
// Printf(stderr,"childDecl = '%s' (%s)\n", childDecl, Getattr(c,"view"));
|
||||
if (!Strcmp(childDecl, "0"))
|
||||
if (!childDecl || !Strcmp(childDecl, "0"))
|
||||
childDecl = NewString("");
|
||||
|
||||
SwigType *childType;
|
||||
|
|
@ -1276,7 +1275,7 @@ void emit_full_class(Node *n) {
|
|||
void emit_class(Node *n) {
|
||||
|
||||
#ifdef ALLEGROCL_WRAP_DEBUG
|
||||
Printf(stderr, "emit_class: ENTER... '%s'(%x)\n", Getattr(n, "sym:name"), n);
|
||||
Printf(stderr, "emit_class: ENTER... '%s'(%p)\n", Getattr(n, "sym:name"), n);
|
||||
#endif
|
||||
|
||||
int is_tempInst = !Strcmp(nodeType(n), "templateInst");
|
||||
|
|
@ -1335,7 +1334,7 @@ void emit_typedef(Node *n) {
|
|||
Delete(type);
|
||||
Node *in_class = Getattr(n, "allegrocl:typedef:in-class");
|
||||
|
||||
// Printf(stderr,"in emit_typedef: '%s'(%x).",Getattr(n,"name"),n);
|
||||
// Printf(stderr,"in emit_typedef: '%s'(%p).",Getattr(n,"name"),n);
|
||||
if (Getattr(n, "allegrocl:synonym-of")) {
|
||||
// Printf(stderr," but it's a synonym of something.\n");
|
||||
emit_synonym(n);
|
||||
|
|
@ -1498,11 +1497,11 @@ void dump_linked_types(File *f) {
|
|||
Node *n = first_linked_type;
|
||||
int i = 0;
|
||||
while (n) {
|
||||
Printf(f, "%d: (%x) node '%s' name '%s'\n", i++, n, nodeType(n), Getattr(n, "sym:name"));
|
||||
Printf(f, "%d: (%p) node '%s' name '%s'\n", i++, n, nodeType(n), Getattr(n, "sym:name"));
|
||||
|
||||
Node *t = Getattr(n, "allegrocl:synonym-of");
|
||||
if (t)
|
||||
Printf(f, " synonym-of %s(%x)\n", Getattr(t, "name"), t);
|
||||
Printf(f, " synonym-of %s(%p)\n", Getattr(t, "name"), t);
|
||||
n = Getattr(n, "allegrocl:next_linked_type");
|
||||
}
|
||||
}
|
||||
|
|
@ -1518,7 +1517,7 @@ void emit_linked_types() {
|
|||
while (n) {
|
||||
String *node_type = nodeType(n);
|
||||
|
||||
// Printf(stderr,"emitting node %s(%x) of type %s.", Getattr(n,"name"),n, nodeType(n));
|
||||
// Printf(stderr,"emitting node %s(%p) of type %s.", Getattr(n,"name"),n, nodeType(n));
|
||||
if (!Strcmp(node_type, "class") || !Strcmp(node_type, "templateInst")) {
|
||||
// may need to emit a stub, so it will update the package itself.
|
||||
// Printf(stderr," Passing to emit_class.");
|
||||
|
|
@ -1566,14 +1565,15 @@ void ALLEGROCL::main(int argc, char *argv[]) {
|
|||
|
||||
/* check for built-ins */
|
||||
if (!strcmp(conv, "lispify")) {
|
||||
identifier_converter = "identifier-convert-lispify";
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString("identifier-convert-lispify");
|
||||
} else if (!strcmp(conv, "null")) {
|
||||
identifier_converter = "identifier-convert-null";
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString("identifier-convert-null");
|
||||
} else {
|
||||
/* Must be user defined */
|
||||
char *idconv = new char[strlen(conv) + 1];
|
||||
strcpy(idconv, conv);
|
||||
identifier_converter = idconv;
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString(conv);
|
||||
}
|
||||
} else if (!strcmp(argv[i], "-cwrap")) {
|
||||
CWrap = true;
|
||||
|
|
@ -1587,21 +1587,7 @@ void ALLEGROCL::main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
if (!strcmp(argv[i], "-help")) {
|
||||
fprintf(stdout, "Allegro CL Options (available with -allegrocl)\n");
|
||||
fprintf(stdout,
|
||||
" -identifier-converter <type or funcname>\n"
|
||||
"\tSpecifies the type of conversion to do on C identifiers to convert\n"
|
||||
"\tthem to symbols. There are two built-in converters: 'null' and\n"
|
||||
"\t 'lispify'. The default is 'null'. If you supply a name other\n"
|
||||
"\tthan one of the built-ins, then a function by that name will be\n"
|
||||
"\tcalled to convert identifiers to symbols.\n"
|
||||
"\n"
|
||||
" -[no]cwrap\n"
|
||||
"\tTurn on or turn off generation of an intermediate C file when\n" "\tcreating a C interface. By default this is only done for C++ code.\n"
|
||||
" -isolate\n"
|
||||
"Define all SWIG helper functions in a package unique to this module. Avoids redefinition warnings when loading multiple SWIGged modules\n"
|
||||
"into the same running Allegro CL image.\n");
|
||||
|
||||
Printf(stdout, "%s\n", usage);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1629,7 +1615,6 @@ int ALLEGROCL::top(Node *n) {
|
|||
if (Generate_Wrapper) {
|
||||
f_begin = NewFile(cxx_filename, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
Close(f_cl);
|
||||
Delete(f_cl);
|
||||
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
|
|
@ -1686,15 +1671,13 @@ int ALLEGROCL::top(Node *n) {
|
|||
Printf(f_cl, "%s\n", f_clhead);
|
||||
Printf(f_cl, "%s\n", f_clwrap);
|
||||
|
||||
Close(f_cl);
|
||||
Delete(f_cl); // Delete the handle, not the file
|
||||
Delete(f_cl);
|
||||
Delete(f_clhead);
|
||||
Delete(f_clwrap);
|
||||
|
||||
Dump(f_runtime, f_begin);
|
||||
Printf(f_begin, "%s\n", f_cxx_wrapper);
|
||||
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
Delete(f_cxx_wrapper);
|
||||
|
|
@ -2025,7 +2008,7 @@ int emit_num_lin_arguments(ParmList *parms) {
|
|||
int nargs = 0;
|
||||
|
||||
while (p) {
|
||||
// Printf(stderr,"enla: '%s' lin='%x'\n", Getattr(p,"name"), Getattr(p,"tmap:lin"));
|
||||
// Printf(stderr,"enla: '%s' lin='%p' numinputs='%s'\n", Getattr(p,"name"), Getattr(p,"tmap:lin"), Getattr(p,"tmap:lin:numinputs"));
|
||||
if (Getattr(p, "tmap:lin")) {
|
||||
nargs += GetInt(p, "tmap:lin:numinputs");
|
||||
p = Getattr(p, "tmap:lin:next");
|
||||
|
|
@ -2196,15 +2179,23 @@ struct IDargs {
|
|||
return result;
|
||||
}
|
||||
|
||||
String *noname_str() {
|
||||
String *noname_str(bool include_class = true) {
|
||||
String *result = NewString("");
|
||||
Printf(result, " :type :%s", type);
|
||||
if (klass)
|
||||
if (klass && include_class)
|
||||
Printf(result, " :class \"%s\"", klass);
|
||||
if (arity)
|
||||
Printf(result, " :arity %s", arity);
|
||||
return result;
|
||||
}
|
||||
|
||||
String *noname_no_others_str(bool include_class = true) {
|
||||
String *result = NewString("");
|
||||
Printf(result, " :type :%s", type);
|
||||
if (klass && include_class)
|
||||
Printf(result, " :class \"%s\"", klass);
|
||||
return result;
|
||||
}
|
||||
};
|
||||
IDargs *id_converter_arguments(Node *n) {
|
||||
IDargs *result = (IDargs *) GetVoid(n, "allegrocl:id-converter-args");
|
||||
|
|
@ -2240,8 +2231,9 @@ IDargs *id_converter_arguments(Node *n) {
|
|||
// :class
|
||||
if (Strstr(result->type, "member ")) {
|
||||
Replaceall(result->type, "member ", "");
|
||||
if (!result->klass)
|
||||
if (!result->klass) {
|
||||
result->klass = Copy(Getattr(parent_node_skipping_extends(n), "sym:name"));
|
||||
}
|
||||
}
|
||||
// :arity
|
||||
if (Getattr(n, "sym:overloaded")) {
|
||||
|
|
@ -2250,7 +2242,7 @@ IDargs *id_converter_arguments(Node *n) {
|
|||
result->arity = NewStringf("%d",
|
||||
// emit_num_arguments(Getattr(n, "wrap:parms")));
|
||||
emit_num_lin_arguments(Getattr(n, "wrap:parms")));
|
||||
// Printf(stderr, "got arity of '%s' node '%s' '%x'\n", result->arity, Getattr(n,"name"), Getattr(n,"wrap:parms"));
|
||||
// Printf(stderr, "got arity of '%s' node '%s' '%p'\n", result->arity, Getattr(n,"name"), Getattr(n,"wrap:parms"));
|
||||
}
|
||||
|
||||
SetVoid(n, "allegrocl:id-converter-args", result);
|
||||
|
|
@ -2328,8 +2320,16 @@ int ALLEGROCL::emit_dispatch_defun(Node *n) {
|
|||
#endif
|
||||
List *overloads = Swig_overload_rank(n, true);
|
||||
|
||||
String *id_args = id_converter_arguments(n)->no_others_quoted_str();
|
||||
Printf(f_clwrap, "(swig-dispatcher (%s :arities (", id_args);
|
||||
// Printf(stderr,"\ndispatch node=%p\n\n", n);
|
||||
// Swig_print_node(n);
|
||||
|
||||
Node *overloaded_from = Getattr(n,"sym:overloaded");
|
||||
bool include_class = Getattr(overloaded_from, "allegrocl:dispatcher:include-class") ? true : false;
|
||||
String *id_args = id_converter_arguments(n)->noname_no_others_str(include_class);
|
||||
Printf(f_clwrap, "(swig-dispatcher (\"%s\" %s :arities (", Getattr(overloaded_from, "allegrocl:dispatcher:name"), id_args);
|
||||
|
||||
Delattr(overloaded_from, "allegrocl:dispatcher:include-class");
|
||||
Delattr(overloaded_from, "allegrocl:dispatcher:name");
|
||||
|
||||
int last_arity = -1;
|
||||
for (Iterator i = First(overloads); i.item; i = Next(i)) {
|
||||
|
|
@ -2358,16 +2358,24 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
Printf(stderr, "emit_defun: ENTER... ");
|
||||
#endif
|
||||
|
||||
// avoid name conflicts between smart pointer wrappers and the wrappers for the
|
||||
// actual class.
|
||||
bool smartmemberwrapper = (!Cmp(Getattr(n, "view"), "memberfunctionHandler") &&
|
||||
Getattr(n,"allocate:smartpointeraccess"));
|
||||
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
int auto_generated = Cmp(Getattr(n, "view"), "globalfunctionHandler");
|
||||
Printf(stderr, "%s%sfunction %s%s%s\n", auto_generated ? "> " : "", Getattr(n, "sym:overloaded")
|
||||
? "overloaded " : "", current_namespace, (current_namespace) > 0 ? "::" : "", Getattr(n, "sym:name"));
|
||||
Printf(stderr, " (view: %s)\n", Getattr(n, "view"));
|
||||
Swig_print_node(n);
|
||||
#endif
|
||||
|
||||
|
||||
String *funcname = Getattr(n, "allegrocl:old-sym:name");
|
||||
if (!funcname)
|
||||
if (smartmemberwrapper || !funcname)
|
||||
funcname = Getattr(n, "sym:name");
|
||||
|
||||
String *mangled_name = Getattr(n, "wrap:name");
|
||||
ParmList *pl = parmlist_with_names(Getattr(n, "wrap:parms"));
|
||||
|
||||
|
|
@ -2375,7 +2383,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
Wrapper *wrap = NewWrapper();
|
||||
Swig_typemap_attach_parms("lin", pl, wrap);
|
||||
// Swig_typemap_attach_parms("ffitype", pl, wrap);
|
||||
Swig_typemap_lookup("lout", n, "result", 0);
|
||||
Swig_typemap_lookup("lout", n, Swig_cresult_name(), 0);
|
||||
|
||||
SwigType *result_type = Swig_cparse_type(Getattr(n, "tmap:ctype"));
|
||||
// prime the pump, with support for OUTPUT, INOUT typemaps.
|
||||
|
|
@ -2387,10 +2395,16 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
int largnum = 0, argnum = 0, first = 1;
|
||||
// int varargs=0;
|
||||
if (Generate_Wrapper) {
|
||||
String *extra_parms = id_converter_arguments(n)->noname_str();
|
||||
if (Getattr(n, "sym:overloaded"))
|
||||
String *extra_parms = id_converter_arguments(n)->noname_str(smartmemberwrapper ? false : true);
|
||||
Node *overloaded_from = Getattr(n,"sym:overloaded");
|
||||
if (overloaded_from) {
|
||||
if(!GetFlag(overloaded_from,"allegrocl:dispatcher:name")) {
|
||||
Setattr(overloaded_from,"allegrocl:dispatcher:name",funcname);
|
||||
Setattr(overloaded_from,"allegrocl:dispatcher:include-class", smartmemberwrapper ? 0 : "1");
|
||||
// Printf(stderr, " set a:d:name='%s', a:d:i-c='%s'\n", Getattr(n,"allegrocl:dispatcher:name"), Getattr(n,"allegrocl:dispatcher:include-class"));
|
||||
}
|
||||
Printf(fcl, "(swig-defmethod (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms);
|
||||
else
|
||||
} else
|
||||
Printf(fcl, "(swig-defun (\"%s\" \"%s\"%s)\n", funcname, mangled_name, extra_parms);
|
||||
Delete(extra_parms);
|
||||
}
|
||||
|
|
@ -2499,11 +2513,8 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
|
||||
Delete(parsed);
|
||||
|
||||
int isPtrReturn = 0;
|
||||
|
||||
if (cl_t) {
|
||||
lclass = lookup_defined_foreign_ltype(cl_t);
|
||||
isPtrReturn = 1;
|
||||
}
|
||||
|
||||
int ff_foreign_ptr = 0;
|
||||
|
|
@ -2522,17 +2533,8 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
Replaceall(wrap->code, "$out_fftype", out_ffitype);
|
||||
if (deref_out_ffitype)
|
||||
Replaceall(wrap->code, "$*out_fftype", deref_out_ffitype);
|
||||
// if(Replaceall(wrap->code,"$lclass", lclass) && !isPtrReturn) {
|
||||
// Swig_warning(WARN_LANG_RETURN_TYPE,Getfile(n), Getline(n),
|
||||
// "While Wrapping %s, replaced a $lclass reference when return type is non-pointer %s!\n",
|
||||
// Getattr(n,"name"), cl_t);
|
||||
// }
|
||||
|
||||
Replaceall(wrap->code, "$body", NewStringf("(swig-ff-call%s)", wrap->locals));
|
||||
// Replaceall(wrap->code,"$body",
|
||||
// (!Strcmp(result_type,"void") ?
|
||||
// NewStringf("(swig-ff-call%s)", wrap->locals) :
|
||||
// NewStringf("(push (swig-ff-call%s) ACL_result)", wrap->locals)));
|
||||
String *ldestructor = Copy(lclass);
|
||||
if (ff_foreign_ptr)
|
||||
Replaceall(ldestructor, ldestructor, "cl::identity");
|
||||
|
|
@ -2546,7 +2548,7 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
/////////////////////////////////////////////////////
|
||||
// Lisp foreign call return type and optimizations //
|
||||
/////////////////////////////////////////////////////
|
||||
Printf(fcl, " (:returning (%s %s)", compose_foreign_type(n, result_type), get_lisp_type(n, Getattr(n, "type"), "result"));
|
||||
Printf(fcl, " (:returning (%s %s)", compose_foreign_type(n, result_type), get_lisp_type(n, Getattr(n, "type"), Swig_cresult_name()));
|
||||
|
||||
for (Iterator option = First(n); option.item; option = Next(option)) {
|
||||
if (Strncmp("feature:ffargs:", option.key, 15))
|
||||
|
|
@ -2579,7 +2581,6 @@ int ALLEGROCL::emit_defun(Node *n, File *fcl) {
|
|||
int ALLEGROCL::functionWrapper(Node *n) {
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
Printf(stderr, "functionWrapper %s\n", Getattr(n,"name"));
|
||||
Swig_print_node(n);
|
||||
#endif
|
||||
|
||||
|
||||
|
|
@ -2627,7 +2628,7 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
if (Getattr(n, "overload:ignore")) {
|
||||
// if we're the last overload, make sure to force the emit
|
||||
// of the rest of the overloads before we leave.
|
||||
Printf(stderr, "ignored overload %s(%x)\n", name, Getattr(n, "sym:nextSibling"));
|
||||
// Printf(stderr, "ignored overload %s(%p)\n", name, Getattr(n, "sym:nextSibling"));
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
update_package_if_needed(n);
|
||||
emit_buffered_defuns(n);
|
||||
|
|
@ -2650,6 +2651,12 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
Parm *p;
|
||||
for (i = 0, p = parms; i < num_arguments; i++) {
|
||||
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
String *temp1 = Getattr(p,"tmap:in");
|
||||
String *temp2 = Getattr(p,"tmap:in:numinputs");
|
||||
Printf(stderr," parm %d: %s, tmap:in='%s', tmap:in:numinputs='%s'\n", i, Getattr(p,"name"), temp1 ? temp1 : "", temp2 ? temp2 : "");
|
||||
#endif
|
||||
|
||||
while (p && checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
}
|
||||
|
|
@ -2688,6 +2695,10 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
}
|
||||
Printf(name_and_parms, ")");
|
||||
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
Printf(stderr, " arity = %d(%d)\n", emit_num_lin_arguments(parms), emit_num_lin_arguments(Getattr(n,"wrap:parms")));
|
||||
#endif
|
||||
|
||||
// Emit the function definition
|
||||
String *signature = SwigType_str(return_type, name_and_parms);
|
||||
Printf(f->def, "EXPORT %s {", signature);
|
||||
|
|
@ -2696,8 +2707,8 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
String *tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode);
|
||||
if (!is_void_return && tm) {
|
||||
String *tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode);
|
||||
if (!is_void_return) {
|
||||
if (tm) {
|
||||
Replaceall(tm, "$result", "lresult");
|
||||
Printf(f->code, "%s\n", tm);
|
||||
|
|
@ -2746,7 +2757,7 @@ int ALLEGROCL::functionWrapper(Node *n) {
|
|||
|
||||
int ALLEGROCL::namespaceDeclaration(Node *n) {
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
Printf(stderr, "namespaceDecl: '%s'(0x%x) (fc=0x%x)\n", Getattr(n, "sym:name"), n, firstChild(n));
|
||||
Printf(stderr, "namespaceDecl: '%s'(%p) (fc=%p)\n", Getattr(n, "sym:name"), n, firstChild(n));
|
||||
#endif
|
||||
|
||||
/* don't wrap a namespace with no contents. package bloat.
|
||||
|
|
@ -2869,23 +2880,13 @@ int ALLEGROCL::globalvariableHandler(Node *n) {
|
|||
|
||||
// String *name = Getattr(n, "name");
|
||||
SwigType *type = Getattr(n, "type");
|
||||
SwigType *ctype;
|
||||
SwigType *rtype = SwigType_typedef_resolve_all(type);
|
||||
|
||||
int pointer_added = 0;
|
||||
|
||||
if (SwigType_isclass(rtype)) {
|
||||
SwigType_add_pointer(type);
|
||||
SwigType_add_pointer(rtype);
|
||||
pointer_added = 1;
|
||||
}
|
||||
|
||||
ctype = SwigType_str(type, 0);
|
||||
// EXPORT <SwigType_str> <mangled_name>;
|
||||
// <SwigType_str> <mangled_name> = <name>;
|
||||
// Printf(f_runtime, "EXPORT %s %s;\n%s %s = %s%s;\n", ctype, mangled_name,
|
||||
// ctype, mangled_name, (pointer_added ? "&" : ""), name);
|
||||
|
||||
Printf(f_clwrap, "(swig-defvar \"%s\" \"%s\" :type %s)\n",
|
||||
Getattr(n, "sym:name"), Getattr(n, "sym:name"), ((SwigType_isconst(type)) ? ":constant" : ":variable"));
|
||||
|
||||
|
|
@ -2939,6 +2940,7 @@ int ALLEGROCL::variableWrapper(Node *n) {
|
|||
int ALLEGROCL::memberfunctionHandler(Node *n) {
|
||||
#ifdef ALLEGROCL_DEBUG
|
||||
Printf(stderr, "memberfunctionHandler %s::%s\n", Getattr(parent_node_skipping_extends(n), "name"), Getattr(n, "name"));
|
||||
Swig_print_node(n);
|
||||
#endif
|
||||
Setattr(n, "allegrocl:kind", "member function");
|
||||
Setattr(n, "allegrocl:old-sym:name", Getattr(n, "sym:name"));
|
||||
|
|
@ -2975,7 +2977,7 @@ int ALLEGROCL::typedefHandler(Node *n) {
|
|||
|
||||
if (in_class) {
|
||||
#ifdef ALLEGROCL_TYPE_DEBUG
|
||||
Printf(stderr, " typedef in class '%s'(%x)\n", Getattr(in_class, "sym:name"), in_class);
|
||||
Printf(stderr, " typedef in class '%s'(%p)\n", Getattr(in_class, "sym:name"), in_class);
|
||||
#endif
|
||||
Setattr(n, "allegrocl:typedef:in-class", in_class);
|
||||
|
||||
|
|
@ -2993,7 +2995,7 @@ int ALLEGROCL::typedefHandler(Node *n) {
|
|||
String *lookup = lookup_defined_foreign_type(typedef_type);
|
||||
|
||||
#ifdef ALLEGROCL_TYPE_DEBUG
|
||||
Printf(stderr, "** lookup='%s'(%x), typedef_type='%s', strcmp = '%d' strstr = '%d'\n", lookup, lookup, typedef_type, Strcmp(typedef_type,"void"), Strstr(ff_type,"__SWIGACL_FwdReference"));
|
||||
Printf(stderr, "** lookup='%s'(%p), typedef_type='%s', strcmp = '%d' strstr = '%d'\n", lookup, lookup, typedef_type, Strcmp(typedef_type,"void"), Strstr(ff_type,"__SWIGACL_FwdReference"));
|
||||
#endif
|
||||
|
||||
if(lookup || (!lookup && Strcmp(typedef_type,"void")) ||
|
||||
|
|
@ -3041,11 +3043,6 @@ int ALLEGROCL::cClassHandler(Node *n) {
|
|||
#ifdef ALLEGROCL_TYPE_DEBUG
|
||||
Printf(stderr, "In cClassHandler\n");
|
||||
#endif
|
||||
// String *cDeclName = Getattr(n,"classDeclaration:name");
|
||||
// String *name= Getattr(n, "sym:name");
|
||||
// String *kind = Getattr(n,"kind");
|
||||
// Node *c;
|
||||
|
||||
/* Add this structure to the known lisp types */
|
||||
// Printf(stderr, "Adding %s foreign type\n", name);
|
||||
String *ns = listify_namespace(current_namespace);
|
||||
|
|
@ -3124,7 +3121,8 @@ int ALLEGROCL::cppClassHandler(Node *n) {
|
|||
SwigType *childType = NewStringf("%s%s", Getattr(c, "decl"),
|
||||
Getattr(c, "type"));
|
||||
#ifdef ALLEGROCL_CLASS_DEBUG
|
||||
Printf(stderr, "looking at child '%x' of type '%s'\n", c, childType);
|
||||
Printf(stderr, "looking at child '%p' of type '%s' '%d'\n", c, childType, SwigType_isfunction(childType));
|
||||
// Swig_print_node(c);
|
||||
#endif
|
||||
if (!SwigType_isfunction(childType))
|
||||
Delete(compose_foreign_type(n, childType));
|
||||
|
|
@ -3230,3 +3228,4 @@ int ALLEGROCL::templateDeclaration(Node *n) {
|
|||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@
|
|||
* Doc/Manual/SWIGPlus.html for details.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_allocate_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
|
||||
|
|
@ -43,7 +41,7 @@ extern "C" {
|
|||
SwigType *decl1 = SwigType_typedef_resolve_all(decl);
|
||||
SwigType *decl2 = SwigType_pop_function(decl1);
|
||||
if (Strcmp(decl2, search_decl) == 0) {
|
||||
if (!Getattr(n, "abstract")) {
|
||||
if (!GetFlag(n, "abstract")) {
|
||||
Delete(decl1);
|
||||
Delete(decl2);
|
||||
return 1;
|
||||
|
|
@ -216,7 +214,7 @@ class Allocate:public Dispatcher {
|
|||
|
||||
if (!most_base_covariant_type) {
|
||||
// Eliminate the derived virtual method.
|
||||
if (virtual_elimination_mode)
|
||||
if (virtual_elimination_mode && !is_member_director(n))
|
||||
if (both_have_public_access)
|
||||
if (!is_non_public_base(inclass, b))
|
||||
if (!Swig_symbol_isoverloaded(n)) {
|
||||
|
|
@ -327,38 +325,36 @@ class Allocate:public Dispatcher {
|
|||
Swig_symbol_setscope(oldtab);
|
||||
return ret;
|
||||
}
|
||||
List *abstract = Getattr(base, "abstract");
|
||||
if (abstract) {
|
||||
List *abstracts = Getattr(base, "abstracts");
|
||||
if (abstracts) {
|
||||
int dabstract = 0;
|
||||
int len = Len(abstract);
|
||||
int len = Len(abstracts);
|
||||
for (int i = 0; i < len; i++) {
|
||||
Node *nn = Getitem(abstract, i);
|
||||
Node *nn = Getitem(abstracts, i);
|
||||
String *name = Getattr(nn, "name");
|
||||
if (!name)
|
||||
continue;
|
||||
if (Strchr(name, '~'))
|
||||
continue; /* Don't care about destructors */
|
||||
String *base_decl = Getattr(nn, "decl");
|
||||
if (base_decl)
|
||||
base_decl = SwigType_typedef_resolve_all(base_decl);
|
||||
if (Strchr(name, '~'))
|
||||
continue; /* Don't care about destructors */
|
||||
|
||||
if (SwigType_isfunction(base_decl)) {
|
||||
if (SwigType_isfunction(base_decl))
|
||||
search_decl = SwigType_pop_function(base_decl);
|
||||
}
|
||||
Node *dn = Swig_symbol_clookup_local_check(name, 0, check_implemented);
|
||||
Delete(search_decl);
|
||||
Delete(base_decl);
|
||||
|
||||
if (!dn) {
|
||||
List *nabstract = Getattr(n, "abstract");
|
||||
if (!nabstract) {
|
||||
nabstract = NewList();
|
||||
Setattr(n, "abstract", nabstract);
|
||||
Delete(nabstract);
|
||||
List *nabstracts = Getattr(n, "abstracts");
|
||||
if (!nabstracts) {
|
||||
nabstracts = NewList();
|
||||
Setattr(n, "abstracts", nabstracts);
|
||||
Delete(nabstracts);
|
||||
}
|
||||
Append(nabstract, nn);
|
||||
if (!Getattr(n, "abstract:firstnode")) {
|
||||
Setattr(n, "abstract:firstnode", nn);
|
||||
Append(nabstracts, nn);
|
||||
if (!Getattr(n, "abstracts:firstnode")) {
|
||||
Setattr(n, "abstracts:firstnode", nn);
|
||||
}
|
||||
dabstract = base != n;
|
||||
}
|
||||
|
|
@ -386,10 +382,6 @@ class Allocate:public Dispatcher {
|
|||
}
|
||||
|
||||
Node *c = firstChild(cls);
|
||||
String *kind = Getattr(cls, "kind");
|
||||
int mode = PUBLIC;
|
||||
if (kind && (Strcmp(kind, "class") == 0))
|
||||
mode = PRIVATE;
|
||||
|
||||
while (c) {
|
||||
if (Getattr(c, "error") || GetFlag(c, "feature:ignore")) {
|
||||
|
|
@ -419,7 +411,7 @@ class Allocate:public Dispatcher {
|
|||
match = 1;
|
||||
break;
|
||||
}
|
||||
if ((!symname || (!Getattr(e, "sym:name"))) && (Cmp(name, Getattr(e, "name")) == 0)) {
|
||||
if (!Getattr(e, "sym:name") && (Cmp(name, Getattr(e, "name")) == 0)) {
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
|
|
@ -457,13 +449,6 @@ class Allocate:public Dispatcher {
|
|||
}
|
||||
}
|
||||
|
||||
if (Strcmp(nodeType(c), "access") == 0) {
|
||||
kind = Getattr(c, "kind");
|
||||
if (Strcmp(kind, "public") == 0)
|
||||
mode = PUBLIC;
|
||||
else
|
||||
mode = PRIVATE;
|
||||
}
|
||||
c = nextSibling(c);
|
||||
}
|
||||
/* Look for methods in base classes */
|
||||
|
|
@ -609,19 +594,19 @@ Allocate():
|
|||
/* Check if the class is abstract via inheritance. This might occur if a class didn't have
|
||||
any pure virtual methods of its own, but it didn't implement all of the pure methods in
|
||||
a base class */
|
||||
if (!Getattr(n, "abstract") && is_abstract_inherit(n)) {
|
||||
if (!Getattr(n, "abstracts") && is_abstract_inherit(n)) {
|
||||
if (((Getattr(n, "allocate:public_constructor") || (!GetFlag(n, "feature:nodefault") && !Getattr(n, "allocate:has_constructor"))))) {
|
||||
if (!GetFlag(n, "feature:notabstract")) {
|
||||
Node *na = Getattr(n, "abstract:firstnode");
|
||||
Node *na = Getattr(n, "abstracts:firstnode");
|
||||
if (na) {
|
||||
Swig_warning(WARN_TYPE_ABSTRACT, Getfile(n), Getline(n),
|
||||
"Class '%s' might be abstract, " "no constructors generated,\n", SwigType_namestr(Getattr(n, "name")));
|
||||
Swig_warning(WARN_TYPE_ABSTRACT, Getfile(na), Getline(na), "Method %s might not be implemented.\n", Swig_name_decl(na));
|
||||
if (!Getattr(n, "abstract")) {
|
||||
List *abstract = NewList();
|
||||
Append(abstract, na);
|
||||
Setattr(n, "abstract", abstract);
|
||||
Delete(abstract);
|
||||
if (!Getattr(n, "abstracts")) {
|
||||
List *abstracts = NewList();
|
||||
Append(abstracts, na);
|
||||
Setattr(n, "abstracts", abstracts);
|
||||
Delete(abstracts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -631,7 +616,7 @@ Allocate():
|
|||
if (!Getattr(n, "allocate:has_constructor")) {
|
||||
/* No constructor is defined. We need to check a few things */
|
||||
/* If class is abstract. No default constructor. Sorry */
|
||||
if (Getattr(n, "abstract")) {
|
||||
if (Getattr(n, "abstracts")) {
|
||||
Delattr(n, "allocate:default_constructor");
|
||||
}
|
||||
if (!Getattr(n, "allocate:default_constructor")) {
|
||||
|
|
@ -652,7 +637,7 @@ Allocate():
|
|||
}
|
||||
}
|
||||
if (!Getattr(n, "allocate:has_copy_constructor")) {
|
||||
if (Getattr(n, "abstract")) {
|
||||
if (Getattr(n, "abstracts")) {
|
||||
Delattr(n, "allocate:copy_constructor");
|
||||
}
|
||||
if (!Getattr(n, "allocate:copy_constructor")) {
|
||||
|
|
@ -824,9 +809,12 @@ Allocate():
|
|||
int isconst = 0;
|
||||
Delete(SwigType_pop(type));
|
||||
if (SwigType_isconst(type)) {
|
||||
isconst = 1;
|
||||
isconst = !Getattr(inclass, "allocate:smartpointermutable");
|
||||
Setattr(inclass, "allocate:smartpointerconst", "1");
|
||||
}
|
||||
else {
|
||||
Setattr(inclass, "allocate:smartpointermutable", "1");
|
||||
}
|
||||
List *methods = smart_pointer_methods(sc, 0, isconst);
|
||||
Setattr(inclass, "allocate:smartpointer", methods);
|
||||
Setattr(inclass, "allocate:smartpointerbase", base);
|
||||
|
|
@ -834,7 +822,6 @@ Allocate():
|
|||
/* Hmmm. The return value is not a pointer. If the type is a value
|
||||
or reference. We're going to chase it to see if another operator->()
|
||||
can be found */
|
||||
|
||||
if ((SwigType_check_decl(type, "")) || (SwigType_check_decl(type, "r."))) {
|
||||
Node *nn = Swig_symbol_clookup((char *) "operator ->", Getattr(sc, "symtab"));
|
||||
if (nn) {
|
||||
|
|
@ -945,6 +932,9 @@ Allocate():
|
|||
} else if (cplus_mode == PROTECTED) {
|
||||
Setattr(inclass, "allocate:default_base_destructor", "1");
|
||||
}
|
||||
} else {
|
||||
Setattr(inclass, "allocate:has_destructor", "1");
|
||||
Setattr(inclass, "allocate:default_destructor", "1");
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
* feature that's normally disabled.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_browser_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#ifdef SWIG_SWILL
|
||||
|
|
@ -29,9 +27,9 @@ class Browser:public Dispatcher {
|
|||
v = 1;
|
||||
}
|
||||
if (v) {
|
||||
Printf(out, "<a name=\"n%x\"></a>[<a href=\"hide.html?node=0x%x&hn=0x%x#n%x\">-</a>] ", n, t, n, n);
|
||||
Printf(out, "<a name=\"n%p\"></a>[<a href=\"hide.html?node=%p&hn=%p#n%p\">-</a>] ", n, t, n, n);
|
||||
} else {
|
||||
Printf(out, "<a name=\"n%x\"></a>[<a href=\"show.html?node=0x%x&hn=0x%x#n%x\">+</a>] ", n, t, n, n);
|
||||
Printf(out, "<a name=\"n%p\"></a>[<a href=\"show.html?node=%p&hn=%p#n%p\">+</a>] ", n, t, n, n);
|
||||
}
|
||||
}
|
||||
void show_attributes(Node *obj) {
|
||||
|
|
@ -52,7 +50,7 @@ class Browser:public Dispatcher {
|
|||
Replaceall(o, "&", "&");
|
||||
Replaceall(o, "<", "<");
|
||||
Replaceall(o, ">", ">");
|
||||
Printf(os, "<a href=\"data.html?n=0x%x\">?</a> %-12s - %s\n", Getattr(obj, k), k, o);
|
||||
Printf(os, "<a href=\"data.html?n=%p\">?</a> %-12s - %s\n", Getattr(obj, k), k, o);
|
||||
Delete(o);
|
||||
} else {
|
||||
DOH *o;
|
||||
|
|
@ -64,10 +62,10 @@ class Browser:public Dispatcher {
|
|||
}
|
||||
Replaceall(o, "&", "&");
|
||||
Replaceall(o, "<", "<");
|
||||
Printf(os, "<a href=\"data.html?n=0x%x\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc);
|
||||
Printf(os, "<a href=\"data.html?n=%p\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc);
|
||||
Delete(o);
|
||||
} else {
|
||||
Printf(os, "<a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj, k), k, Getattr(obj, k));
|
||||
Printf(os, "<a href=\"data.html?n=%p\">?</a> %-12s - %p\n", Getattr(obj, k), k, Getattr(obj, k));
|
||||
}
|
||||
}
|
||||
ki = Next(ki);
|
||||
|
|
@ -84,7 +82,7 @@ public:
|
|||
char *name = GetChar(n, "name");
|
||||
|
||||
show_checkbox(view_top, n);
|
||||
Printf(out, "<b><a href=\"index.html?node=0x%x\">%s</a></b>", n, tag);
|
||||
Printf(out, "<b><a href=\"index.html?node=%p\">%s</a></b>", n, tag);
|
||||
if (name) {
|
||||
Printf(out, " (%s)", name);
|
||||
}
|
||||
|
|
@ -184,9 +182,9 @@ static void display(FILE *f, Node *n) {
|
|||
Printf(f, "<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", Swig_package_version());
|
||||
Printf(f, "<b>SWIG-%s</b><br>\n", Swig_package_version());
|
||||
Printf(f, "[ <a href=\"exit.html\">Exit</a> ]");
|
||||
Printf(f, " [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
|
||||
Printf(f, " [ <a href=\"index.html?node=%p\">Top</a> ]", tree_top);
|
||||
if (n != tree_top) {
|
||||
Printf(f, " [ <a href=\"index.html?node=0x%x\">Up</a> ]", parentNode(n));
|
||||
Printf(f, " [ <a href=\"index.html?node=%p\">Up</a> ]", parentNode(n));
|
||||
}
|
||||
Printf(f, " [ <a href=\"symbol.html\">Symbols</a> ]");
|
||||
Printf(f, "<br><hr><p>\n");
|
||||
|
|
@ -255,10 +253,10 @@ void raw_data(FILE *out, Node *obj) {
|
|||
trunc = "...";
|
||||
}
|
||||
Replaceall(o, "<", "<");
|
||||
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc);
|
||||
Printf(os, " <a href=\"data.html?n=%p\">?</a> %-12s - \"%(escape)-0.70s%s\"\n", Getattr(obj, k), k, o, trunc);
|
||||
Delete(o);
|
||||
} else {
|
||||
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> %-12s - 0x%x\n", Getattr(obj, k), k, Getattr(obj, k));
|
||||
Printf(os, " <a href=\"data.html?n=%p\">?</a> %-12s - %p\n", Getattr(obj, k), k, Getattr(obj, k));
|
||||
}
|
||||
ki = Next(ki);
|
||||
}
|
||||
|
|
@ -283,10 +281,10 @@ void raw_data(FILE *out, Node *obj) {
|
|||
trunc = "...";
|
||||
}
|
||||
Replaceall(o, "<", "<");
|
||||
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> [%d] - \"%(escape)-0.70s%s\"\n", o, i, s, trunc);
|
||||
Printf(os, " <a href=\"data.html?n=%p\">?</a> [%d] - \"%(escape)-0.70s%s\"\n", o, i, s, trunc);
|
||||
Delete(s);
|
||||
} else {
|
||||
Printf(os, " <a href=\"data.html?n=0x%x\">?</a> [%d] - 0x%x\n", o, i, o);
|
||||
Printf(os, " <a href=\"data.html?n=%p\">?</a> [%d] - %p\n", o, i, o);
|
||||
}
|
||||
}
|
||||
Printf(os, "\n]\n");
|
||||
|
|
@ -303,7 +301,7 @@ void data_handler(FILE *f) {
|
|||
Printf(f, "<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", Swig_package_version());
|
||||
Printf(f, "<b>SWIG-%s</b><br>\n", Swig_package_version());
|
||||
Printf(f, "[ <a href=\"exit.html\">Exit</a> ]");
|
||||
Printf(f, " [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
|
||||
Printf(f, " [ <a href=\"index.html?node=%p\">Top</a> ]", tree_top);
|
||||
Printf(f, "<br><hr><p>\n");
|
||||
if (n) {
|
||||
raw_data(f, n);
|
||||
|
|
@ -319,7 +317,7 @@ void symbol_handler(FILE *f) {
|
|||
Printf(f, "<HTML><HEAD><TITLE>SWIG-%s</TITLE></HEAD><BODY BGCOLOR=\"#ffffff\">\n", Swig_package_version());
|
||||
Printf(f, "<b>SWIG-%s</b><br>\n", Swig_package_version());
|
||||
Printf(f, "[ <a href=\"exit.html\">Exit</a> ]");
|
||||
Printf(f, " [ <a href=\"index.html?node=0x%x\">Top</a> ]", tree_top);
|
||||
Printf(f, " [ <a href=\"index.html?node=%p\">Top</a> ]", tree_top);
|
||||
Printf(f, " [ <a href=\"symbol.html\">Symbols</a> ]");
|
||||
Printf(f, "<br><hr><p>\n");
|
||||
|
||||
|
|
@ -343,7 +341,7 @@ void symbol_handler(FILE *f) {
|
|||
|
||||
fprintf(f, "<p><form action=\"symbol.html\" method=GET>\n");
|
||||
fprintf(f, "Symbol lookup: <input type=text name=name size=40></input><br>\n");
|
||||
fprintf(f, "<input type=hidden name=sym value=\"0x%x\">\n", sym);
|
||||
fprintf(f, "<input type=hidden name=sym value=\"%p\">\n", sym);
|
||||
fprintf(f, "Submit : <input type=submit></input>\n");
|
||||
fprintf(f, "</form>");
|
||||
|
||||
|
|
@ -365,7 +363,7 @@ void symbol_handler(FILE *f) {
|
|||
Hash *h;
|
||||
h = firstChild(sym);
|
||||
while (h) {
|
||||
Printf(f, "<a href=\"symbol.html?sym=0x%x\">%s</a>\n", h, Getattr(h, "name"));
|
||||
Printf(f, "<a href=\"symbol.html?sym=%p\">%s</a>\n", h, Getattr(h, "name"));
|
||||
h = nextSibling(h);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* cffi language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_cffi_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
#include <ctype.h>
|
||||
|
|
@ -20,6 +18,19 @@ char cvsroot_cffi_cxx[] = "$Id$";
|
|||
//#define CFFI_DEBUG
|
||||
//#define CFFI_WRAP_DEBUG
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
CFFI Options (available with -cffi)\n\
|
||||
-generate-typedef - Use defctype to generate shortcuts according to the\n\
|
||||
typedefs in the input.\n\
|
||||
-[no]cwrap - Turn on or turn off generation of an intermediate C\n\
|
||||
file when creating a C interface. By default this is\n\
|
||||
only done for C++ code.\n\
|
||||
-[no]swig-lisp - Turn on or off generation of code for helper lisp\n\
|
||||
macro, functions, etc. which SWIG uses while\n\
|
||||
generating wrappers. These macros, functions may still\n\
|
||||
be used by generated wrapper code.\n\
|
||||
";
|
||||
|
||||
class CFFI:public Language {
|
||||
public:
|
||||
String *f_cl;
|
||||
|
|
@ -80,17 +91,7 @@ void CFFI::main(int argc, char *argv[]) {
|
|||
CWrap = false;
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!Strcmp(argv[i], "-help")) {
|
||||
Printf(stdout, "cffi Options (available with -cffi)\n");
|
||||
Printf(stdout,
|
||||
" -generate-typedef\n"
|
||||
"\tIf this option is given then defctype will be used to generate\n"
|
||||
"\tshortcuts according to the typedefs in the input.\n"
|
||||
" -[no]cwrap\n"
|
||||
"\tTurn on or turn off generation of an intermediate C file when\n"
|
||||
"\tcreating a C interface. By default this is only done for C++ code.\n"
|
||||
" -[no]swig-lisp\n"
|
||||
"\tTurns on or off generation of code for helper lisp macro, functions,\n"
|
||||
"\tetc. which SWIG uses while generating wrappers. These macros, functions\n" "\tmay still be used by generated wrapper code.\n");
|
||||
Printf(stdout, "%s\n", usage);
|
||||
} else if (!strcmp(argv[i], "-cwrap")) {
|
||||
CWrap = true;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -134,7 +135,6 @@ int CFFI::top(Node *n) {
|
|||
if (CPlusPlus || CWrap) {
|
||||
f_begin = NewFile(cxx_filename, "w", SWIG_output_files());
|
||||
if (!f_begin) {
|
||||
Close(f_lisp);
|
||||
Delete(f_lisp);
|
||||
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
|
|
@ -144,7 +144,6 @@ int CFFI::top(Node *n) {
|
|||
Printf(clos_filename, "%s%s-clos.lisp", SWIG_output_directory(), module);
|
||||
f_clos = NewFile(clos_filename, "w", SWIG_output_files());
|
||||
if (!f_clos) {
|
||||
Close(f_lisp);
|
||||
Delete(f_lisp);
|
||||
Printf(stderr, "Unable to open %s for writing\n", cxx_filename);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
|
|
@ -181,13 +180,11 @@ int CFFI::top(Node *n) {
|
|||
Printf(f_lisp, "%s\n", f_cl);
|
||||
Printf(f_lisp, "%s\n", f_clwrap);
|
||||
|
||||
Close(f_lisp);
|
||||
Delete(f_lisp); // Deletes the handle, not the file
|
||||
Delete(f_lisp);
|
||||
Delete(f_cl);
|
||||
Delete(f_clhead);
|
||||
Delete(f_clwrap);
|
||||
Dump(f_runtime, f_begin);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
Delete(f_cxx_wrapper);
|
||||
|
|
@ -323,7 +320,7 @@ void CFFI::emit_initialize_instance(Node *n) {
|
|||
else
|
||||
Printf(args_placeholder, " %s", argname);
|
||||
|
||||
if (Strcmp(ffitype, lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'classname")) == 0)
|
||||
if (ffitype && Strcmp(ffitype, lispify_name(parent, lispy_name(Char(Getattr(parent, "sym:name"))), "'classname")) == 0)
|
||||
Printf(args_call, " (ff-pointer %s)", argname);
|
||||
else
|
||||
Printf(args_call, " %s", argname);
|
||||
|
|
@ -458,11 +455,13 @@ int CFFI::functionWrapper(Node *n) {
|
|||
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
String *result_convert = Swig_typemap_lookup_out("out", n, "result", f, actioncode);
|
||||
Replaceall(result_convert, "$result", "lresult");
|
||||
Printf(f->code, "%s\n", result_convert);
|
||||
if(!is_void_return) Printf(f->code, " return lresult;\n");
|
||||
Delete(result_convert);
|
||||
String *result_convert = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode);
|
||||
if (result_convert) {
|
||||
Replaceall(result_convert, "$result", "lresult");
|
||||
Printf(f->code, "%s\n", result_convert);
|
||||
if(!is_void_return) Printf(f->code, " return lresult;\n");
|
||||
Delete(result_convert);
|
||||
}
|
||||
emit_return_variable(n, Getattr(n, "type"), f);
|
||||
|
||||
Printf(f->code, " } catch (...) {\n");
|
||||
|
|
@ -564,7 +563,13 @@ void CFFI::emit_defun(Node *n, String *name) {
|
|||
|
||||
int CFFI::constantWrapper(Node *n) {
|
||||
String *type = Getattr(n, "type");
|
||||
String *converted_value = convert_literal(Getattr(n, "value"), type);
|
||||
String *converted_value;
|
||||
if (SwigType_type(type) == T_STRING) {
|
||||
converted_value = NewString(Getattr(n, "rawval"));
|
||||
} else {
|
||||
converted_value = convert_literal(Getattr(n, "value"), type);
|
||||
}
|
||||
|
||||
String *name = lispify_name(n, Getattr(n, "sym:name"), "'constant");
|
||||
|
||||
if (Strcmp(name, "t") == 0 || Strcmp(name, "T") == 0)
|
||||
|
|
@ -668,7 +673,7 @@ int CFFI::enumDeclaration(Node *n) {
|
|||
void CFFI::emit_class(Node *n) {
|
||||
|
||||
#ifdef CFFI_WRAP_DEBUG
|
||||
Printf(stderr, "emit_class: ENTER... '%s'(%x)\n", Getattr(n, "sym:name"), n);
|
||||
Printf(stderr, "emit_class: ENTER... '%s'(%p)\n", Getattr(n, "sym:name"), n);
|
||||
#endif
|
||||
|
||||
String *name = Getattr(n, "sym:name");
|
||||
|
|
@ -834,7 +839,7 @@ void CFFI::emit_struct_union(Node *n, bool un = false) {
|
|||
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)
|
||||
if (slot_name && (Strcmp(slot_name, "t") == 0 || Strcmp(slot_name, "T") == 0))
|
||||
slot_name = NewStringf("t_var");
|
||||
|
||||
Printf(f_cl, "\n\t(%s %s)", slot_name, typespec);
|
||||
|
|
@ -1020,9 +1025,8 @@ String *CFFI::convert_literal(String *literal, String *type, bool try_to_split)
|
|||
return num;
|
||||
} else if (SwigType_type(type) == T_CHAR) {
|
||||
/* Use CL syntax for character literals */
|
||||
String* result = NewStringf("#\\%c", s[2]);
|
||||
String* result = NewStringf("#\\%c", s[0]);
|
||||
Delete(num);
|
||||
// Printf(stderr, "%s %c %d", s, s[2], s);
|
||||
return result;
|
||||
} else if (SwigType_type(type) == T_STRING) {
|
||||
/* Use CL syntax for string literals */
|
||||
|
|
@ -1031,10 +1035,14 @@ String *CFFI::convert_literal(String *literal, String *type, bool try_to_split)
|
|||
return result;
|
||||
} else if (SwigType_type(type) == T_INT || SwigType_type(type) == T_UINT) {
|
||||
// Printf(stderr, "Is a T_INT or T_UINT %s, before replaceall\n", s);
|
||||
Replaceall(num, "u", "");
|
||||
Replaceall(num, "U", "");
|
||||
Replaceall(num, "l", "");
|
||||
Replaceall(num, "L", "");
|
||||
const char *num_start = Char(num);
|
||||
bool is_literal = isdigit(*num_start) || (*num_start == '.') || (*num_start == '+') || (*num_start == '-');
|
||||
if (is_literal) {
|
||||
Replaceall(num, "u", "");
|
||||
Replaceall(num, "U", "");
|
||||
Replaceall(num, "l", "");
|
||||
Replaceall(num, "L", "");
|
||||
}
|
||||
|
||||
int i, j;
|
||||
if (sscanf(s, "%d >> %d", &i, &j) == 2) {
|
||||
|
|
@ -1050,10 +1058,10 @@ String *CFFI::convert_literal(String *literal, String *type, bool try_to_split)
|
|||
|
||||
if (Len(num) >= 2 && s[0] == '0') { /* octal or hex */
|
||||
if (s[1] == 'x'){
|
||||
DohReplace(num,"0","#",DOH_REPLACE_FIRST);
|
||||
Replace(num,"0","#",DOH_REPLACE_FIRST);
|
||||
}
|
||||
else{
|
||||
DohReplace(num,"0","#o",DOH_REPLACE_FIRST);
|
||||
Replace(num,"0","#o",DOH_REPLACE_FIRST);
|
||||
}
|
||||
}
|
||||
return num;
|
||||
|
|
|
|||
|
|
@ -11,23 +11,21 @@
|
|||
* CHICKEN language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_chicken_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
static const char *chicken_usage = (char *) "\
|
||||
static const char *usage = (char *) "\
|
||||
\
|
||||
CHICKEN Options (available with -chicken)\n\
|
||||
-proxy - Export TinyCLOS class definitions\n\
|
||||
-closprefix <prefix> - Prepend <prefix> to all clos identifiers\n\
|
||||
-useclassprefix - Prepend the class name to all clos identifiers\n\
|
||||
-unhideprimitive - Unhide the primitive: symbols\n\
|
||||
-nounit - Do not (declare (unit ...)) in scheme file\n\
|
||||
-noclosuses - Do not (declare (uses ...)) in scheme file\n\
|
||||
-nocollection - Do not register pointers with chicken garbage\n\
|
||||
collector and export destructors\n\
|
||||
-nounit - Do not (declare (unit ...)) in scheme file\n\
|
||||
-proxy - Export TinyCLOS class definitions\n\
|
||||
-unhideprimitive - Unhide the primitive: symbols\n\
|
||||
-useclassprefix - Prepend the class name to all clos identifiers\n\
|
||||
\n";
|
||||
|
||||
static char *module = 0;
|
||||
|
|
@ -137,7 +135,7 @@ void CHICKEN::main(int argc, char *argv[]) {
|
|||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) {
|
||||
fputs(chicken_usage, stdout);
|
||||
fputs(usage, stdout);
|
||||
SWIG_exit(0);
|
||||
} else if (strcmp(argv[i], "-proxy") == 0) {
|
||||
clos = 1;
|
||||
|
|
@ -290,8 +288,6 @@ int CHICKEN::top(Node *n) {
|
|||
|
||||
Printf(f_scm, "%s\n", chickentext);
|
||||
|
||||
|
||||
Close(f_scm);
|
||||
Delete(f_scm);
|
||||
|
||||
char buftmp[20];
|
||||
|
|
@ -324,7 +320,6 @@ int CHICKEN::top(Node *n) {
|
|||
Delete(f_wrappers);
|
||||
Delete(f_sym_size);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
|
|
@ -533,8 +528,8 @@ int CHICKEN::functionWrapper(Node *n) {
|
|||
String *actioncode = emit_action(n);
|
||||
|
||||
/* Return the function value */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "resultobj");
|
||||
Replaceall(tm, "$result", "resultobj");
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
|
|
@ -561,15 +556,15 @@ int CHICKEN::functionWrapper(Node *n) {
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
@ -684,9 +679,6 @@ int CHICKEN::variableWrapper(Node *n) {
|
|||
String *overname = 0;
|
||||
String *scmname;
|
||||
|
||||
int num_required;
|
||||
int num_arguments;
|
||||
|
||||
scmname = NewString(iname);
|
||||
Replaceall(scmname, "_", "-");
|
||||
|
||||
|
|
@ -705,10 +697,6 @@ int CHICKEN::variableWrapper(Node *n) {
|
|||
emit_attach_parmmaps(l, f);
|
||||
Setattr(n, "wrap:parms", l);
|
||||
|
||||
/* Get number of required and total arguments */
|
||||
num_arguments = emit_num_arguments(l);
|
||||
num_required = emit_num_required(l);
|
||||
|
||||
// evaluation function names
|
||||
Append(wname, Swig_name_wrapper(iname));
|
||||
if (overname) {
|
||||
|
|
@ -845,9 +833,6 @@ int CHICKEN::constantWrapper(Node *n) {
|
|||
String *rvalue;
|
||||
SwigType *nctype;
|
||||
|
||||
int num_required;
|
||||
int num_arguments;
|
||||
|
||||
scmname = NewString(iname);
|
||||
Replaceall(scmname, "_", "-");
|
||||
|
||||
|
|
@ -873,9 +858,10 @@ int CHICKEN::constantWrapper(Node *n) {
|
|||
Delete(SwigType_pop(nctype));
|
||||
}
|
||||
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
if (SwigType_type(nctype) == T_STRING) {
|
||||
rvalue = NewStringf("\"%s\"", value);
|
||||
} else if (SwigType_type(nctype) == T_CHAR) {
|
||||
} else if (SwigType_type(nctype) == T_CHAR && !is_enum_item) {
|
||||
rvalue = NewStringf("\'%s\'", value);
|
||||
} else {
|
||||
rvalue = NewString(value);
|
||||
|
|
@ -903,10 +889,6 @@ int CHICKEN::constantWrapper(Node *n) {
|
|||
emit_attach_parmmaps(l, f);
|
||||
Setattr(n, "wrap:parms", l);
|
||||
|
||||
/* Get number of required and total arguments */
|
||||
num_arguments = emit_num_arguments(l);
|
||||
num_required = emit_num_required(l);
|
||||
|
||||
// evaluation function names
|
||||
|
||||
// Check for interrupts
|
||||
|
|
@ -1382,12 +1364,10 @@ void CHICKEN::dispatchFunction(Node *n) {
|
|||
SortList(flist, compareTypeLists);
|
||||
|
||||
String *clos_name;
|
||||
int construct = 0;
|
||||
if (have_constructor && !has_constructor_args) {
|
||||
has_constructor_args = 1;
|
||||
constructor_dispatch = NewStringf("%s@SWIG@new@dispatch", short_class_name);
|
||||
clos_name = Copy(constructor_dispatch);
|
||||
construct = 1;
|
||||
Printf(clos_methods, "(declare (hide %s))\n", clos_name);
|
||||
} else if (in_class)
|
||||
clos_name = NewString(member_name);
|
||||
|
|
|
|||
|
|
@ -11,10 +11,17 @@
|
|||
* clisp language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_clisp_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
CLISP Options (available with -clisp)\n\
|
||||
-extern-all - Create clisp definitions for all the functions and\n\
|
||||
global variables otherwise only definitions for\n\
|
||||
externed functions and variables are created.\n\
|
||||
-generate-typedef - Use def-c-type to generate shortcuts according to the\n\
|
||||
typedefs in the input.\n\
|
||||
";
|
||||
|
||||
class CLISP:public Language {
|
||||
public:
|
||||
File *f_cl;
|
||||
|
|
@ -48,15 +55,7 @@ void CLISP::main(int argc, char *argv[]) {
|
|||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (!strcmp(argv[i], "-help")) {
|
||||
Printf(stdout, "clisp Options (available with -clisp)\n");
|
||||
Printf(stdout,
|
||||
" -extern-all\n"
|
||||
"\t If this option is given then clisp definitions for all the functions\n"
|
||||
"and global variables will be created otherwise only definitions for \n"
|
||||
"externed functions and variables are created.\n"
|
||||
" -generate-typedef\n"
|
||||
"\t If this option is given then def-c-type will be used to generate shortcuts\n"
|
||||
"according to the typedefs in the input.\n");
|
||||
Printf(stdout, "%s\n", usage);
|
||||
} else if ((Strcmp(argv[i], "-extern-all") == 0)) {
|
||||
extern_all_flag = 1;
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -77,13 +76,13 @@ int CLISP::top(Node *n) {
|
|||
/* Get the output file name */
|
||||
String *outfile = Getattr(n, "outfile");
|
||||
|
||||
if (!outfile)
|
||||
output_filename = outfile;
|
||||
else {
|
||||
output_filename = NewString("");
|
||||
Printf(output_filename, "%s%s.lisp", SWIG_output_directory(), module);
|
||||
if (!outfile) {
|
||||
Printf(stderr, "Unable to determine outfile\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
output_filename = NewStringf("%s%s.lisp", SWIG_output_directory(), module);
|
||||
|
||||
f_cl = NewFile(output_filename, "w+", SWIG_output_files());
|
||||
if (!f_cl) {
|
||||
FileErrorDisplay(output_filename);
|
||||
|
|
@ -131,17 +130,16 @@ int CLISP::top(Node *n) {
|
|||
|
||||
for (len--; len >= 0; len--) {
|
||||
end--;
|
||||
Seek(f_cl, len, SEEK_SET);
|
||||
(void)Seek(f_cl, len, SEEK_SET);
|
||||
int ch = Getc(f_cl);
|
||||
Seek(f_cl, end, SEEK_SET);
|
||||
(void)Seek(f_cl, end, SEEK_SET);
|
||||
Putc(ch, f_cl);
|
||||
}
|
||||
|
||||
Seek(f_cl, 0, SEEK_SET);
|
||||
Write(f_cl, Char(header), Len(header));
|
||||
|
||||
Close(f_cl);
|
||||
Delete(f_cl); // Deletes the handle, not the file
|
||||
Delete(f_cl);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -293,16 +291,18 @@ int CLISP::classDeclaration(Node *n) {
|
|||
}
|
||||
|
||||
String *temp = Copy(Getattr(c, "decl"));
|
||||
Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
|
||||
String *lisp_type = get_ffi_type(n, temp);
|
||||
Delete(temp);
|
||||
if (temp) {
|
||||
Append(temp, Getattr(c, "type")); //appending type to the end, otherwise wrong type
|
||||
String *lisp_type = get_ffi_type(n, temp);
|
||||
Delete(temp);
|
||||
|
||||
String *slot_name = Getattr(c, "sym:name");
|
||||
Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type);
|
||||
String *slot_name = Getattr(c, "sym:name");
|
||||
Printf(f_cl, "\n\t(%s %s)", slot_name, lisp_type);
|
||||
|
||||
Append(entries, NewStringf("%s-%s", name, slot_name));
|
||||
Append(entries, NewStringf("%s-%s", name, slot_name));
|
||||
|
||||
Delete(lisp_type);
|
||||
Delete(lisp_type);
|
||||
}
|
||||
}
|
||||
|
||||
Printf(f_cl, ")\n");
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Support for Wrap by Contract in SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_contract_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
/* Contract structure. This holds rules about the different kinds of contract sections
|
||||
|
|
@ -213,7 +211,7 @@ String *Contracts::make_expression(String *s, Node *n) {
|
|||
for (ei = First(list_assert); ei.item; ei = Next(ei)) {
|
||||
expr = ei.item;
|
||||
if (Len(expr)) {
|
||||
Replaceid(expr, Getattr(n, "name"), "result");
|
||||
Replaceid(expr, Getattr(n, "name"), Swig_cresult_name());
|
||||
if (Len(str_assert))
|
||||
Append(str_assert, "&&");
|
||||
Printf(str_assert, "(%s)", expr);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
4665
Source/Modules/d.cxx
Normal file
4665
Source/Modules/d.cxx
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -13,8 +13,6 @@
|
|||
* in SWIG. --MR
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_directors_cxx[] = "$Id";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
/* Swig_csuperclass_call()
|
||||
|
|
@ -78,9 +76,10 @@ String *Swig_class_name(Node *n) {
|
|||
|
||||
String *Swig_director_declaration(Node *n) {
|
||||
String *classname = Swig_class_name(n);
|
||||
String *directorname = NewStringf("SwigDirector_%s", classname);
|
||||
String *directorname = Language::instance()->directorClassName(n);
|
||||
String *base = Getattr(n, "classtype");
|
||||
String *declaration = Swig_class_declaration(n, directorname);
|
||||
|
||||
Printf(declaration, " : public %s, public Swig::Director {\n", base);
|
||||
Delete(classname);
|
||||
Delete(directorname);
|
||||
|
|
@ -132,7 +131,7 @@ String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms) {
|
|||
*
|
||||
*/
|
||||
|
||||
String *Swig_method_decl(SwigType *returntype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values) {
|
||||
String *Swig_method_decl(SwigType *rettype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values) {
|
||||
String *result;
|
||||
List *elements;
|
||||
String *element = 0, *nextelement;
|
||||
|
|
@ -203,7 +202,7 @@ String *Swig_method_decl(SwigType *returntype, SwigType *decl, const_String_or_c
|
|||
Append(result, ", ");
|
||||
}
|
||||
Append(result, ")");
|
||||
} else if (returntype) { // This check is intended for conversion operators to a pointer/reference which needs the pointer/reference ignoring in the declaration
|
||||
} else if (rettype) { // This check is intended for conversion operators to a pointer/reference which needs the pointer/reference ignoring in the declaration
|
||||
if (SwigType_ispointer(element)) {
|
||||
Insert(result, 0, "*");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
|
|
@ -256,9 +255,9 @@ String *Swig_method_decl(SwigType *returntype, SwigType *decl, const_String_or_c
|
|||
|
||||
Chop(result);
|
||||
|
||||
if (returntype) {
|
||||
if (rettype) {
|
||||
Insert(result, 0, " ");
|
||||
String *rtype = SwigType_str(returntype, 0);
|
||||
String *rtype = SwigType_str(rettype, 0);
|
||||
Insert(result, 0, rtype);
|
||||
Delete(rtype);
|
||||
}
|
||||
|
|
@ -280,9 +279,10 @@ void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f) {
|
|||
checkAttribute(n, "storage", "static"))
|
||||
&& !Equal(nodeType(n), "constructor"))) {
|
||||
Node *parent = Getattr(n, "parentNode");
|
||||
String *symname = Getattr(parent, "sym:name");
|
||||
String *dirname = NewStringf("SwigDirector_%s", symname);
|
||||
String *dirdecl = NewStringf("%s *darg = 0", dirname);
|
||||
String *dirname;
|
||||
String *dirdecl;
|
||||
dirname = Language::instance()->directorClassName(parent);
|
||||
dirdecl = NewStringf("%s *darg = 0", dirname);
|
||||
Wrapper_add_local(f, "darg", dirdecl);
|
||||
Printf(f->code, "darg = dynamic_cast<%s *>(arg1);\n", dirname);
|
||||
Delete(dirname);
|
||||
|
|
@ -290,3 +290,29 @@ void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f) {
|
|||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* Swig_director_parms_fixup()
|
||||
*
|
||||
* For each parameter in the C++ member function, copy the parameter name
|
||||
* to its "lname"; this ensures that Swig_typemap_attach_parms() will do
|
||||
* the right thing when it sees strings like "$1" in "directorin" typemaps.
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
void Swig_director_parms_fixup(ParmList *parms) {
|
||||
Parm *p;
|
||||
int i;
|
||||
for (i = 0, p = parms; p; p = nextSibling(p), ++i) {
|
||||
String *arg = Getattr(p, "name");
|
||||
String *lname = 0;
|
||||
|
||||
if (!arg && !Equal(Getattr(p, "type"), "void")) {
|
||||
lname = NewStringf("arg%d", i);
|
||||
Setattr(p, "name", lname);
|
||||
} else
|
||||
lname = Copy(arg);
|
||||
|
||||
Setattr(p, "lname", lname);
|
||||
Delete(lname);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Useful functions for emitting various pieces of code.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_emit_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -32,11 +30,11 @@ void emit_return_variable(Node *n, SwigType *rt, Wrapper *f) {
|
|||
SwigType *vt = cplus_value_type(rt);
|
||||
SwigType *tt = vt ? vt : rt;
|
||||
SwigType *lt = SwigType_ltype(tt);
|
||||
String *lstr = SwigType_str(lt, "result");
|
||||
String *lstr = SwigType_str(lt, Swig_cresult_name());
|
||||
if (SwigType_ispointer(lt)) {
|
||||
Wrapper_add_localv(f, "result", lstr, "= 0", NULL);
|
||||
Wrapper_add_localv(f, Swig_cresult_name(), lstr, "= 0", NULL);
|
||||
} else {
|
||||
Wrapper_add_local(f, "result", lstr);
|
||||
Wrapper_add_local(f, Swig_cresult_name(), lstr);
|
||||
}
|
||||
if (vt) {
|
||||
Delete(vt);
|
||||
|
|
@ -363,24 +361,9 @@ int emit_action_code(Node *n, String *wrappercode, String *eaction) {
|
|||
tm = Copy(tm);
|
||||
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
|
||||
if (Strstr(tm, "$")) {
|
||||
Replaceall(tm, "$name", Getattr(n, "name"));
|
||||
Replaceall(tm, "$symname", Getattr(n, "sym:name"));
|
||||
Swig_replace_special_variables(n, parentNode(n), tm);
|
||||
Replaceall(tm, "$function", eaction); // deprecated
|
||||
Replaceall(tm, "$action", eaction);
|
||||
Replaceall(tm, "$wrapname", Getattr(n, "wrap:name"));
|
||||
String *overloaded = Getattr(n, "sym:overloaded");
|
||||
Replaceall(tm, "$overname", overloaded ? Char(Getattr(n, "sym:overname")) : "");
|
||||
|
||||
if (Strstr(tm, "$decl")) {
|
||||
String *decl = Swig_name_decl(n);
|
||||
Replaceall(tm, "$decl", decl);
|
||||
Delete(decl);
|
||||
}
|
||||
if (Strstr(tm, "$fulldecl")) {
|
||||
String *fulldecl = Swig_name_fulldecl(n);
|
||||
Replaceall(tm, "$fulldecl", fulldecl);
|
||||
Delete(fulldecl);
|
||||
}
|
||||
}
|
||||
Printv(wrappercode, tm, "\n", NIL);
|
||||
Delete(tm);
|
||||
|
|
@ -402,7 +385,6 @@ String *emit_action(Node *n) {
|
|||
String *tm;
|
||||
String *action;
|
||||
String *wrap;
|
||||
SwigType *rt;
|
||||
ParmList *catchlist = Getattr(n, "catchlist");
|
||||
|
||||
/* Look for fragments */
|
||||
|
|
@ -440,9 +422,6 @@ String *emit_action(Node *n) {
|
|||
action = Getattr(n, "wrap:action");
|
||||
assert(action != 0);
|
||||
|
||||
/* Get the return type */
|
||||
rt = Getattr(n, "type");
|
||||
|
||||
/* Emit contract code (if any) */
|
||||
if (Swig_contract_mode_get()) {
|
||||
/* Preassertion */
|
||||
|
|
@ -474,6 +453,7 @@ String *emit_action(Node *n) {
|
|||
|
||||
if (catchlist) {
|
||||
int unknown_catch = 0;
|
||||
int has_varargs = 0;
|
||||
Printf(eaction, "}\n");
|
||||
for (Parm *ep = catchlist; ep; ep = nextSibling(ep)) {
|
||||
String *em = Swig_typemap_lookup("throws", ep, "_e", 0);
|
||||
|
|
@ -484,6 +464,7 @@ String *emit_action(Node *n) {
|
|||
Printf(eaction, "catch(%s) {", SwigType_str(et, "_e"));
|
||||
} else if (SwigType_isvarargs(etr)) {
|
||||
Printf(eaction, "catch(...) {");
|
||||
has_varargs = 1;
|
||||
} else {
|
||||
Printf(eaction, "catch(%s) {", SwigType_str(et, "&_e"));
|
||||
}
|
||||
|
|
@ -494,13 +475,13 @@ String *emit_action(Node *n) {
|
|||
unknown_catch = 1;
|
||||
}
|
||||
}
|
||||
if (unknown_catch) {
|
||||
Printf(eaction, "catch(...) { throw; }\n");
|
||||
if (unknown_catch && !has_varargs) {
|
||||
Printf(eaction, "catch(...) { throw; }\n");
|
||||
}
|
||||
}
|
||||
|
||||
/* Look for except typemap (Deprecated) */
|
||||
tm = Swig_typemap_lookup("except", n, "result", 0);
|
||||
tm = Swig_typemap_lookup("except", n, Swig_cresult_name(), 0);
|
||||
if (tm) {
|
||||
Setattr(n, "feature:except", tm);
|
||||
tm = 0;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -11,26 +11,20 @@
|
|||
* Guile language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_guile_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
// Note string broken in half for compilers that can't handle long strings
|
||||
static const char *guile_usage = (char *) "\
|
||||
static const char *usage = (char *) "\
|
||||
Guile Options (available with -guile)\n\
|
||||
-prefix <name> - Use <name> as prefix [default \"gswig_\"]\n\
|
||||
-package <name> - Set the path of the module to <name>\n\
|
||||
(default NULL)\n\
|
||||
-emitsetters - Emit procedures-with-setters for variables\n\
|
||||
and structure slots.\n\
|
||||
-onlysetters - Don't emit traditional getter and setter\n\
|
||||
procedures for structure slots,\n\
|
||||
only emit procedures-with-setters.\n\
|
||||
-procdoc <file> - Output procedure documentation to <file>\n\
|
||||
-procdocformat <format> - Output procedure documentation in <format>;\n\
|
||||
one of `guile-1.4', `plain', `texinfo'\n\
|
||||
-emitslotaccessors - Emit accessor methods for all GOOPS slots\n" "\
|
||||
-exportprimitive - Add the (export ...) code from scmstub into the\n\
|
||||
GOOPS file.\n\
|
||||
-gh - Use the gh_ Guile API. (Guile <= 1.8) \n\
|
||||
-goopsprefix <prefix> - Prepend <prefix> to all goops identifiers\n\
|
||||
-linkage <lstyle> - Use linkage protocol <lstyle> (default `simple')\n\
|
||||
Use `module' for native Guile module linking\n\
|
||||
(requires Guile >= 1.5.0). Use `passive' for\n\
|
||||
|
|
@ -38,18 +32,23 @@ Guile Options (available with -guile)\n\
|
|||
`ltdlmod' for Guile's old dynamic module\n\
|
||||
convention (Guile <= 1.4), or `hobbit' for hobbit\n\
|
||||
modules.\n\
|
||||
-scmstub - Output Scheme file with module declaration and\n\
|
||||
exports; only with `passive' and `simple' linkage\n\
|
||||
-gh - Use the gh_ Guile API. (Guile <= 1.8) \n\
|
||||
-scm - Use the scm Guile API. (Guile >= 1.6, default) \n\
|
||||
-onlysetters - Don't emit traditional getter and setter\n\
|
||||
procedures for structure slots,\n\
|
||||
only emit procedures-with-setters.\n\
|
||||
-package <name> - Set the path of the module to <name>\n\
|
||||
(default NULL)\n\
|
||||
-prefix <name> - Use <name> as prefix [default \"gswig_\"]\n\
|
||||
-procdoc <file> - Output procedure documentation to <file>\n\
|
||||
-procdocformat <format> - Output procedure documentation in <format>;\n\
|
||||
one of `guile-1.4', `plain', `texinfo'\n\
|
||||
-proxy - Export GOOPS class definitions\n\
|
||||
-emitslotaccessors - Emit accessor methods for all GOOPS slots\n" "\
|
||||
-primsuffix <suffix> - Name appended to primitive module when exporting\n\
|
||||
GOOPS classes. (default = \"primitive\")\n\
|
||||
-goopsprefix <prefix> - Prepend <prefix> to all goops identifiers\n\
|
||||
-scm - Use the scm Guile API. (Guile >= 1.6, default) \n\
|
||||
-scmstub - Output Scheme file with module declaration and\n\
|
||||
exports; only with `passive' and `simple' linkage\n\
|
||||
-useclassprefix - Prepend the class name to all goops identifiers\n\
|
||||
-exportprimitive - Add the (export ...) code from scmstub into the\n\
|
||||
GOOPS file.\n";
|
||||
\n";
|
||||
|
||||
static File *f_begin = 0;
|
||||
static File *f_runtime = 0;
|
||||
|
|
@ -58,9 +57,9 @@ static File *f_wrappers = 0;
|
|||
static File *f_init = 0;
|
||||
|
||||
|
||||
static char *prefix = (char *) "gswig_";
|
||||
static String *prefix = NewString("gswig_");
|
||||
static char *module = 0;
|
||||
static char *package = 0;
|
||||
static String *package = 0;
|
||||
static enum {
|
||||
GUILE_LSTYLE_SIMPLE, // call `SWIG_init()'
|
||||
GUILE_LSTYLE_PASSIVE, // passive linking (no module code)
|
||||
|
|
@ -126,7 +125,7 @@ public:
|
|||
* ------------------------------------------------------------ */
|
||||
|
||||
virtual void main(int argc, char *argv[]) {
|
||||
int i, orig_len;
|
||||
int i;
|
||||
|
||||
SWIG_library_directory("guile");
|
||||
SWIG_typemap_lang("guile");
|
||||
|
|
@ -135,12 +134,11 @@ public:
|
|||
for (i = 1; i < argc; i++) {
|
||||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) {
|
||||
fputs(guile_usage, stdout);
|
||||
fputs(usage, stdout);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-prefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
prefix = new char[strlen(argv[i + 1]) + 2];
|
||||
strcpy(prefix, argv[i + 1]);
|
||||
prefix = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -149,8 +147,7 @@ public:
|
|||
}
|
||||
} else if (strcmp(argv[i], "-package") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
package = new char[strlen(argv[i + 1]) + 2];
|
||||
strcpy(package, argv[i + 1]);
|
||||
package = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -277,12 +274,12 @@ public:
|
|||
// should use Swig_warning() ?
|
||||
Printf(stderr, "guile: Warning: -exportprimitive only makes sense with passive linkage without a scmstub.\n");
|
||||
}
|
||||
// Make sure `prefix' ends in an underscore
|
||||
|
||||
orig_len = strlen(prefix);
|
||||
if (prefix[orig_len - 1] != '_') {
|
||||
prefix[1 + orig_len] = 0;
|
||||
prefix[orig_len] = '_';
|
||||
// Make sure `prefix' ends in an underscore
|
||||
if (prefix) {
|
||||
const char *px = Char(prefix);
|
||||
if (px[Len(prefix) - 1] != '_')
|
||||
Printf(prefix, "_");
|
||||
}
|
||||
|
||||
/* Add a symbol for this module */
|
||||
|
|
@ -408,7 +405,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
|
|
@ -881,10 +877,10 @@ public:
|
|||
Printv(actioncode, tab4, "gh_allow_ints();\n", NIL);
|
||||
|
||||
// Now have return value, figure out what to do with it.
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$result", "gswig_result");
|
||||
Replaceall(tm, "$target", "gswig_result");
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
if (GetFlag(n, "feature:new"))
|
||||
Replaceall(tm, "$owner", "1");
|
||||
else
|
||||
|
|
@ -921,14 +917,14 @@ public:
|
|||
// Look for any remaining cleanup
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
}
|
||||
// Free any memory allocated by the function being wrapped..
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
// Wrap things up (in a manner of speaking)
|
||||
|
|
@ -1392,9 +1388,10 @@ public:
|
|||
}
|
||||
// See if there's a typemap
|
||||
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
if (SwigType_type(nctype) == T_STRING) {
|
||||
rvalue = NewStringf("\"%s\"", value);
|
||||
} else if (SwigType_type(nctype) == T_CHAR) {
|
||||
} else if (SwigType_type(nctype) == T_CHAR && !is_enum_item) {
|
||||
rvalue = NewStringf("\'%s\'", value);
|
||||
} else {
|
||||
rvalue = NewString(value);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -11,8 +11,6 @@
|
|||
* Language base class functions. Default C++ handling is also implemented here.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_lang_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
#include <ctype.h>
|
||||
|
|
@ -52,7 +50,7 @@ extern "C" {
|
|||
return all_protected_mode;
|
||||
}
|
||||
void Language_replace_special_variables(String *method, String *tm, Parm *parm) {
|
||||
Language::instance()->replaceSpecialVariables(method, tm, parm);
|
||||
Language::instance()->replaceSpecialVariables(method, tm, parm);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -347,6 +345,27 @@ Language::~Language() {
|
|||
this_ = 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* directorClassName()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Language::directorClassName(Node *n) {
|
||||
String *dirclassname;
|
||||
String *nspace = NewString(Getattr(n, "sym:nspace"));
|
||||
const char *attrib = "director:classname";
|
||||
String *classname = Getattr(n, "sym:name");
|
||||
|
||||
Replace(nspace, NSPACE_SEPARATOR, "_", DOH_REPLACE_ANY);
|
||||
if (Len(nspace) > 0)
|
||||
dirclassname = NewStringf("SwigDirector_%s_%s", nspace, classname);
|
||||
else
|
||||
dirclassname = NewStringf("SwigDirector_%s", classname);
|
||||
Setattr(n, attrib, dirclassname);
|
||||
|
||||
Delete(nspace);
|
||||
return dirclassname;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
emit_one()
|
||||
---------------------------------------------------------------------- */
|
||||
|
|
@ -834,14 +853,29 @@ int Language::cDeclaration(Node *n) {
|
|||
File *f_header = 0;
|
||||
SwigType *ty, *fullty;
|
||||
|
||||
if (Getattr(n, "feature:onlychildren")) {
|
||||
if (GetFlag(n, "feature:ignore")) {
|
||||
return SWIG_NOWRAP;
|
||||
} else {
|
||||
// Found an unignored templated method that has an empty template instantiation (%template())
|
||||
// Ignore it unless it has been %rename'd
|
||||
if (Strncmp(symname, "__dummy_", 8) == 0) {
|
||||
SetFlag(n, "feature:ignore");
|
||||
Swig_warning(WARN_LANG_TEMPLATE_METHOD_IGNORE, input_file, line_number,
|
||||
"%%template() contains no name. Template method ignored: %s\n", Swig_name_decl(n));
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* discards nodes following the access control rules */
|
||||
if (cplus_mode != PUBLIC || !is_public(n)) {
|
||||
/* except for friends, they are not affected by access control */
|
||||
int isfriend = storage && (Cmp(storage, "friend") == 0);
|
||||
int isfriend = Cmp(storage, "friend") == 0;
|
||||
if (!isfriend) {
|
||||
/* Check what the director needs. If the method is pure virtual, it is always needed.
|
||||
* Also wrap non-virtual protected members if asked for (allprotected mode). */
|
||||
if (!(directorsEnabled() && ((is_member_director(CurrentClass, n) && need_nonpublic_member(n)) || is_non_virtual_protected_access(n)))) {
|
||||
if (!(directorsEnabled() && ((is_member_director(CurrentClass, n) && need_nonpublic_member(n)) || isNonVirtualProtectedAccess(n)))) {
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
// Prevent wrapping protected overloaded director methods more than once -
|
||||
|
|
@ -894,7 +928,7 @@ int Language::cDeclaration(Node *n) {
|
|||
}
|
||||
}
|
||||
|
||||
if (symname && !validIdentifier(symname)) {
|
||||
if (!validIdentifier(symname)) {
|
||||
Swig_warning(WARN_LANG_IDENTIFIER, input_file, line_number, "Can't wrap '%s' unless renamed to a valid identifier.\n", symname);
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
|
|
@ -964,17 +998,9 @@ int Language::cDeclaration(Node *n) {
|
|||
Delete(SwigType_pop_function(ty));
|
||||
DohIncref(type);
|
||||
Setattr(n, "type", ty);
|
||||
if (GetFlag(n, "feature:onlychildren") && !GetFlag(n, "feature:ignore")) {
|
||||
// Found an unignored templated method that has a an empty template instantiation (%template())
|
||||
// Ignore it unless it has been %rename'd
|
||||
if (Strncmp(symname, "__dummy_", 8) == 0) {
|
||||
SetFlag(n, "feature:ignore");
|
||||
Swig_warning(WARN_LANG_TEMPLATE_METHOD_IGNORE, input_file, line_number,
|
||||
"%%template() contains no name. Template method ignored: %s\n", Swig_name_decl(n));
|
||||
}
|
||||
}
|
||||
if (!GetFlag(n, "feature:ignore"))
|
||||
functionHandler(n);
|
||||
|
||||
functionHandler(n);
|
||||
|
||||
Setattr(n, "type", type);
|
||||
Delete(ty);
|
||||
Delete(type);
|
||||
|
|
@ -1044,7 +1070,10 @@ int Language::functionHandler(Node *n) {
|
|||
if (isstatic) {
|
||||
staticmemberfunctionHandler(n);
|
||||
} else if (isfriend) {
|
||||
int oldInClass = InClass;
|
||||
InClass = 0;
|
||||
globalfunctionHandler(n);
|
||||
InClass = oldInClass;
|
||||
} else {
|
||||
Node *explicit_n = 0;
|
||||
if (directorsEnabled() && is_member_director(CurrentClass, n) && !extraDirectorProtectedCPPMethodsRequired()) {
|
||||
|
|
@ -1108,7 +1137,7 @@ int Language::globalfunctionHandler(Node *n) {
|
|||
}
|
||||
Setattr(n, "parms", nonvoid_parms(parms));
|
||||
String *call = Swig_cfunction_call(name, parms);
|
||||
String *cres = Swig_cresult(type, "result", call);
|
||||
String *cres = Swig_cresult(type, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
|
|
@ -1124,22 +1153,15 @@ int Language::globalfunctionHandler(Node *n) {
|
|||
|
||||
int Language::callbackfunctionHandler(Node *n) {
|
||||
Swig_require("callbackfunctionHandler", n, "name", "*sym:name", "*type", "?value", NIL);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *type = Getattr(n, "type");
|
||||
String *name = Getattr(n, "name");
|
||||
String *parms = Getattr(n, "parms");
|
||||
String *cb = GetFlagAttr(n, "feature:callback");
|
||||
String *cbname = Getattr(n, "feature:callback:name");
|
||||
String *calltype = NewStringf("(%s (*)(%s))(%s)", SwigType_str(type, 0), ParmList_str(parms), SwigType_namestr(name));
|
||||
SwigType *cbty = Copy(type);
|
||||
SwigType_add_function(cbty, parms);
|
||||
SwigType_add_pointer(cbty);
|
||||
|
||||
if (!cbname) {
|
||||
cbname = NewStringf(cb, symname);
|
||||
Setattr(n, "feature:callback:name", cbname);
|
||||
}
|
||||
|
||||
Setattr(n, "sym:name", cbname);
|
||||
Setattr(n, "type", cbty);
|
||||
Setattr(n, "value", calltype);
|
||||
|
|
@ -1148,7 +1170,6 @@ int Language::callbackfunctionHandler(Node *n) {
|
|||
if (!ns)
|
||||
constantWrapper(n);
|
||||
|
||||
Delete(cbname);
|
||||
Delete(cbty);
|
||||
|
||||
Swig_restore(n);
|
||||
|
|
@ -1221,7 +1242,7 @@ int Language::memberfunctionHandler(Node *n) {
|
|||
// Set up the type for the cast to this class for use when wrapping const director (virtual) methods.
|
||||
// Note: protected director methods or when allprotected mode turned on.
|
||||
String *director_type = 0;
|
||||
if (!is_public(n) && (is_member_director(CurrentClass, n) || GetFlag(n, "explicitcall") || is_non_virtual_protected_access(n))) {
|
||||
if (!is_public(n) && (is_member_director(CurrentClass, n) || GetFlag(n, "explicitcall") || isNonVirtualProtectedAccess(n))) {
|
||||
director_type = Copy(DirectorClassName);
|
||||
String *qualifier = Getattr(n, "qualifier");
|
||||
if (qualifier)
|
||||
|
|
@ -1267,7 +1288,7 @@ int Language::staticmemberfunctionHandler(Node *n) {
|
|||
if (!Extend) {
|
||||
Node *sb = Getattr(n, "cplus:staticbase");
|
||||
String *sname = Getattr(sb, "name");
|
||||
if (is_non_virtual_protected_access(n))
|
||||
if (isNonVirtualProtectedAccess(n))
|
||||
cname = NewStringf("%s::%s", DirectorClassName, name);
|
||||
else
|
||||
cname = NewStringf("%s::%s", sname, name);
|
||||
|
|
@ -1344,7 +1365,7 @@ int Language::variableHandler(Node *n) {
|
|||
Swig_save("variableHandler", n, "feature:immutable", NIL);
|
||||
if (SmartPointer) {
|
||||
/* If a smart-pointer and it's a constant access, we have to set immutable */
|
||||
if (Getattr(CurrentClass, "allocate:smartpointerconst")) {
|
||||
if (!Getattr(CurrentClass, "allocate:smartpointermutable")) {
|
||||
SetFlag(n, "feature:immutable");
|
||||
}
|
||||
}
|
||||
|
|
@ -1391,7 +1412,7 @@ int Language::membervariableHandler(Node *n) {
|
|||
int assignable = is_assignable(n);
|
||||
|
||||
if (SmartPointer) {
|
||||
if (Getattr(CurrentClass, "allocate:smartpointerconst")) {
|
||||
if (!Getattr(CurrentClass, "allocate:smartpointermutable")) {
|
||||
assignable = 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -1412,14 +1433,19 @@ int Language::membervariableHandler(Node *n) {
|
|||
Delete(pname);
|
||||
}
|
||||
} else {
|
||||
String *pname = is_non_virtual_protected_access(n) ? NewString("darg") : Swig_cparm_name(0, 0);
|
||||
String *pname = isNonVirtualProtectedAccess(n) ? NewString("darg") : Swig_cparm_name(0, 0);
|
||||
target = NewStringf("%s->%s", pname, name);
|
||||
Delete(pname);
|
||||
}
|
||||
tm = Swig_typemap_lookup("memberin", n, target, 0);
|
||||
|
||||
// This is an input type typemap lookup and so it should not use Node n
|
||||
// otherwise qualification is done on the parameter name for the setter function
|
||||
Parm *nin = NewParm(type, name, n);
|
||||
tm = Swig_typemap_lookup("memberin", nin, target, 0);
|
||||
Delete(nin);
|
||||
}
|
||||
int flags = Extend | SmartPointer | use_naturalvar_mode(n);
|
||||
if (is_non_virtual_protected_access(n))
|
||||
if (isNonVirtualProtectedAccess(n))
|
||||
flags = flags | CWRAP_ALL_PROTECTED_ACCESS;
|
||||
|
||||
Swig_MembersetToFunction(n, ClassType, flags);
|
||||
|
|
@ -1467,7 +1493,7 @@ int Language::membervariableHandler(Node *n) {
|
|||
/* Emit get function */
|
||||
{
|
||||
int flags = Extend | SmartPointer | use_naturalvar_mode(n);
|
||||
if (is_non_virtual_protected_access(n))
|
||||
if (isNonVirtualProtectedAccess(n))
|
||||
flags = flags | CWRAP_ALL_PROTECTED_ACCESS;
|
||||
Swig_MembergetToFunction(n, ClassType, flags);
|
||||
Setattr(n, "sym:name", mrename_get);
|
||||
|
|
@ -1527,7 +1553,7 @@ int Language::membervariableHandler(Node *n) {
|
|||
int Language::staticmembervariableHandler(Node *n) {
|
||||
Swig_require("staticmembervariableHandler", n, "*name", "*sym:name", "*type", "?value", NIL);
|
||||
String *value = Getattr(n, "value");
|
||||
String *classname = !SmartPointer ? (is_non_virtual_protected_access(n) ? DirectorClassName : ClassName) : Getattr(CurrentClass, "allocate:smartpointerbase");
|
||||
String *classname = !SmartPointer ? (isNonVirtualProtectedAccess(n) ? DirectorClassName : ClassName) : Getattr(CurrentClass, "allocate:smartpointerbase");
|
||||
|
||||
if (!value || !Getattr(n, "hasconsttype")) {
|
||||
String *name = Getattr(n, "name");
|
||||
|
|
@ -1661,6 +1687,8 @@ int Language::enumvalueDeclaration(Node *n) {
|
|||
|
||||
int Language::enumforwardDeclaration(Node *n) {
|
||||
(void) n;
|
||||
if (GetFlag(n, "enumMissing"))
|
||||
enumDeclaration(n); // Generate an empty enum in target language
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1690,7 +1718,7 @@ int Language::memberconstantHandler(Node *n) {
|
|||
if (Extend)
|
||||
new_name = Copy(value);
|
||||
else
|
||||
new_name = NewStringf("%s::%s", is_non_virtual_protected_access(n) ? DirectorClassName : ClassName, name);
|
||||
new_name = NewStringf("%s::%s", isNonVirtualProtectedAccess(n) ? DirectorClassName : ClassName, name);
|
||||
Setattr(n, "name", new_name);
|
||||
|
||||
constantWrapper(n);
|
||||
|
|
@ -1806,17 +1834,25 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
|
|||
classname = Getattr(n, "name");
|
||||
for (ni = Getattr(n, "firstChild"); ni; ni = nextSibling(ni)) {
|
||||
/* we only need to check the virtual members */
|
||||
if (!checkAttribute(ni, "storage", "virtual"))
|
||||
continue;
|
||||
nodeType = Getattr(ni, "nodeType");
|
||||
int is_using = (Cmp(nodeType, "using") == 0);
|
||||
Node *nn = is_using ? firstChild(ni) : ni; /* assume there is only one child node for "using" nodes */
|
||||
if (is_using) {
|
||||
if (nn)
|
||||
nodeType = Getattr(nn, "nodeType");
|
||||
else
|
||||
continue; // A private "using" node
|
||||
}
|
||||
if (!checkAttribute(nn, "storage", "virtual"))
|
||||
continue;
|
||||
/* we need to add methods(cdecl) and destructor (to check for throw decl) */
|
||||
int is_destructor = (Cmp(nodeType, "destructor") == 0);
|
||||
if ((Cmp(nodeType, "cdecl") == 0) || is_destructor) {
|
||||
decl = Getattr(ni, "decl");
|
||||
decl = Getattr(nn, "decl");
|
||||
/* extra check for function type and proper access */
|
||||
if (SwigType_isfunction(decl) && (((!protectedbase || dirprot_mode()) && is_public(ni)) || need_nonpublic_member(ni))) {
|
||||
String *name = Getattr(ni, "name");
|
||||
Node *method_id = is_destructor ? NewStringf("~destructor") : vtable_method_id(ni);
|
||||
if (SwigType_isfunction(decl) && (((!protectedbase || dirprot_mode()) && is_public(nn)) || need_nonpublic_member(nn))) {
|
||||
String *name = Getattr(nn, "name");
|
||||
Node *method_id = is_destructor ? NewStringf("~destructor") : vtable_method_id(nn);
|
||||
/* Make sure that the new method overwrites the existing: */
|
||||
int len = Len(vm);
|
||||
const int DO_NOT_REPLACE = -1;
|
||||
|
|
@ -1834,7 +1870,7 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
|
|||
String *fqdname = NewStringf("%s::%s", classname, name);
|
||||
Hash *item = NewHash();
|
||||
Setattr(item, "fqdname", fqdname);
|
||||
Node *m = Copy(ni);
|
||||
Node *m = Copy(nn);
|
||||
|
||||
/* Store the complete return type - needed for non-simple return types (pointers, references etc.) */
|
||||
SwigType *ty = NewString(Getattr(m, "type"));
|
||||
|
|
@ -1854,6 +1890,7 @@ int Language::unrollVirtualMethods(Node *n, Node *parent, List *vm, int default_
|
|||
Append(vm, item);
|
||||
else
|
||||
Setitem(vm, replace, item);
|
||||
Setattr(nn, "directorNode", m);
|
||||
|
||||
Delete(mname);
|
||||
}
|
||||
|
|
@ -2027,9 +2064,12 @@ int Language::classDirectorMethods(Node *n) {
|
|||
if (!Cmp(type, "destructor")) {
|
||||
classDirectorDestructor(method);
|
||||
} else {
|
||||
if (classDirectorMethod(method, n, fqdname) == SWIG_OK) {
|
||||
Setattr(item, "director", "1");
|
||||
}
|
||||
Swig_require("classDirectorMethods", method, "*type", NIL);
|
||||
assert(Getattr(method, "returntype"));
|
||||
Setattr(method, "type", Getattr(method, "returntype"));
|
||||
if (classDirectorMethod(method, n, fqdname) == SWIG_OK)
|
||||
SetFlag(item, "director");
|
||||
Swig_restore(method);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2102,7 +2142,7 @@ int Language::classDirector(Node *n) {
|
|||
Node *nodeType = Getattr(ni, "nodeType");
|
||||
bool cdeclaration = (Cmp(nodeType, "cdecl") == 0);
|
||||
if (cdeclaration && !GetFlag(ni, "feature:ignore")) {
|
||||
if (is_non_virtual_protected_access(ni)) {
|
||||
if (isNonVirtualProtectedAccess(ni)) {
|
||||
Node *overloaded = Getattr(ni, "sym:overloaded");
|
||||
// emit the using base::member statement (but only once if the method is overloaded)
|
||||
if (!overloaded || (overloaded && (overloaded == ni)))
|
||||
|
|
@ -2148,12 +2188,10 @@ static void addCopyConstructor(Node *n) {
|
|||
|
||||
String *cname = Getattr(n, "name");
|
||||
SwigType *type = Copy(cname);
|
||||
String *last = Swig_scopename_last(cname);
|
||||
String *name = NewStringf("%s::%s", cname, last);
|
||||
String *name = Swig_scopename_last(cname);
|
||||
String *cc = NewStringf("r.q(const).%s", type);
|
||||
String *decl = NewStringf("f(%s).", cc);
|
||||
String *csymname = Getattr(n, "sym:name");
|
||||
String *oldname = csymname;
|
||||
String *oldname = Getattr(n, "sym:name");
|
||||
|
||||
if (Getattr(n, "allocate:has_constructor")) {
|
||||
// to work properly with '%rename Class', we must look
|
||||
|
|
@ -2174,11 +2212,8 @@ static void addCopyConstructor(Node *n) {
|
|||
}
|
||||
}
|
||||
|
||||
String *symname = Swig_name_make(cn, cname, last, decl, oldname);
|
||||
String *symname = Swig_name_make(cn, cname, name, decl, oldname);
|
||||
if (Strcmp(symname, "$ignore") != 0) {
|
||||
if (!symname) {
|
||||
symname = Copy(csymname);
|
||||
}
|
||||
Parm *p = NewParm(cc, "other", n);
|
||||
|
||||
Setattr(cn, "name", name);
|
||||
|
|
@ -2191,8 +2226,8 @@ static void addCopyConstructor(Node *n) {
|
|||
|
||||
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
|
||||
Node *on = Swig_symbol_add(symname, cn);
|
||||
Swig_features_get(Swig_cparse_features(), Swig_symbol_qualifiedscopename(0), name, decl, cn);
|
||||
Swig_symbol_setscope(oldscope);
|
||||
Swig_features_get(Swig_cparse_features(), 0, name, decl, cn);
|
||||
|
||||
if (on == cn) {
|
||||
Node *access = NewHash();
|
||||
|
|
@ -2207,7 +2242,6 @@ static void addCopyConstructor(Node *n) {
|
|||
}
|
||||
}
|
||||
Delete(cn);
|
||||
Delete(last);
|
||||
Delete(name);
|
||||
Delete(decl);
|
||||
Delete(symname);
|
||||
|
|
@ -2221,28 +2255,21 @@ static void addDefaultConstructor(Node *n) {
|
|||
Setline(cn, Getline(n));
|
||||
|
||||
String *cname = Getattr(n, "name");
|
||||
String *last = Swig_scopename_last(cname);
|
||||
String *name = NewStringf("%s::%s", cname, last);
|
||||
String *name = Swig_scopename_last(cname);
|
||||
String *decl = NewString("f().");
|
||||
String *csymname = Getattr(n, "sym:name");
|
||||
String *oldname = csymname;
|
||||
String *symname = Swig_name_make(cn, cname, last, decl, oldname);
|
||||
String *oldname = Getattr(n, "sym:name");
|
||||
String *symname = Swig_name_make(cn, cname, name, decl, oldname);
|
||||
if (Strcmp(symname, "$ignore") != 0) {
|
||||
if (!symname) {
|
||||
symname = Copy(csymname);
|
||||
}
|
||||
|
||||
Setattr(cn, "name", name);
|
||||
Setattr(cn, "sym:name", symname);
|
||||
SetFlag(cn, "feature:new");
|
||||
Setattr(cn, "decl", decl);
|
||||
Setattr(cn, "parentNode", n);
|
||||
Setattr(cn, "default_constructor", "1");
|
||||
|
||||
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
|
||||
Node *on = Swig_symbol_add(symname, cn);
|
||||
Swig_features_get(Swig_cparse_features(), Swig_symbol_qualifiedscopename(0), name, decl, cn);
|
||||
Swig_symbol_setscope(oldscope);
|
||||
Swig_features_get(Swig_cparse_features(), 0, name, decl, cn);
|
||||
|
||||
if (on == cn) {
|
||||
Node *access = NewHash();
|
||||
|
|
@ -2256,7 +2283,6 @@ static void addDefaultConstructor(Node *n) {
|
|||
}
|
||||
}
|
||||
Delete(cn);
|
||||
Delete(last);
|
||||
Delete(name);
|
||||
Delete(decl);
|
||||
Delete(symname);
|
||||
|
|
@ -2270,15 +2296,12 @@ static void addDestructor(Node *n) {
|
|||
Setline(cn, Getline(n));
|
||||
|
||||
String *cname = Getattr(n, "name");
|
||||
String *last = Swig_scopename_last(cname);
|
||||
Insert(last, 0, "~");
|
||||
String *name = NewStringf("%s::%s", cname, last);
|
||||
String *name = Swig_scopename_last(cname);
|
||||
Insert(name, 0, "~");
|
||||
String *decl = NewString("f().");
|
||||
String *symname = Swig_name_make(cn, cname, last, decl, 0);
|
||||
String *symname = Swig_name_make(cn, cname, name, decl, 0);
|
||||
if (Strcmp(symname, "$ignore") != 0) {
|
||||
if (!symname) {
|
||||
symname = NewStringf("~%s", Getattr(n, "sym:name"));
|
||||
}
|
||||
String *possible_nonstandard_symname = NewStringf("~%s", Getattr(n, "sym:name"));
|
||||
|
||||
Setattr(cn, "name", name);
|
||||
Setattr(cn, "sym:name", symname);
|
||||
|
|
@ -2286,23 +2309,29 @@ static void addDestructor(Node *n) {
|
|||
Setattr(cn, "parentNode", n);
|
||||
|
||||
Symtab *oldscope = Swig_symbol_setscope(Getattr(n, "symtab"));
|
||||
Node *nonstandard_destructor = Equal(possible_nonstandard_symname, symname) ? 0 : Swig_symbol_clookup(possible_nonstandard_symname, 0);
|
||||
Node *on = Swig_symbol_add(symname, cn);
|
||||
Swig_features_get(Swig_cparse_features(), Swig_symbol_qualifiedscopename(0), name, decl, cn);
|
||||
Swig_symbol_setscope(oldscope);
|
||||
Swig_features_get(Swig_cparse_features(), 0, name, decl, cn);
|
||||
|
||||
if (on == cn) {
|
||||
Node *access = NewHash();
|
||||
set_nodeType(access, "access");
|
||||
Setattr(access, "kind", "public");
|
||||
appendChild(n, access);
|
||||
appendChild(n, cn);
|
||||
Setattr(n, "has_destructor", "1");
|
||||
Setattr(n, "allocate:destructor", "1");
|
||||
Delete(access);
|
||||
// SWIG accepts a non-standard named destructor in %extend that uses a typedef for the destructor name
|
||||
// For example: typedef struct X {} XX; %extend X { ~XX() {...} }
|
||||
// Don't add another destructor if a nonstandard one has been declared
|
||||
if (!nonstandard_destructor) {
|
||||
Node *access = NewHash();
|
||||
set_nodeType(access, "access");
|
||||
Setattr(access, "kind", "public");
|
||||
appendChild(n, access);
|
||||
appendChild(n, cn);
|
||||
Setattr(n, "has_destructor", "1");
|
||||
Setattr(n, "allocate:destructor", "1");
|
||||
Delete(access);
|
||||
}
|
||||
}
|
||||
Delete(possible_nonstandard_symname);
|
||||
}
|
||||
Delete(cn);
|
||||
Delete(last);
|
||||
Delete(name);
|
||||
Delete(decl);
|
||||
Delete(symname);
|
||||
|
|
@ -2321,14 +2350,12 @@ int Language::classDeclaration(Node *n) {
|
|||
String *kind = Getattr(n, "kind");
|
||||
String *name = Getattr(n, "name");
|
||||
String *tdname = Getattr(n, "tdname");
|
||||
String *unnamed = Getattr(n, "unnamed");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
|
||||
char *classname = tdname ? Char(tdname) : Char(name);
|
||||
char *iname = Char(symname);
|
||||
int strip = (tdname || CPlusPlus) ? 1 : 0;
|
||||
int strip = CPlusPlus ? 1 : unnamed && tdname;
|
||||
|
||||
|
||||
if (!classname) {
|
||||
if (!name) {
|
||||
Swig_warning(WARN_LANG_CLASS_UNNAMED, input_file, line_number, "Can't generate wrappers for unnamed struct/class.\n");
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
|
|
@ -2339,21 +2366,18 @@ int Language::classDeclaration(Node *n) {
|
|||
return SWIG_NOWRAP;
|
||||
}
|
||||
|
||||
Swig_save("classDeclaration", n, "name", NIL);
|
||||
Setattr(n, "name", classname);
|
||||
|
||||
if (Cmp(kind, "class") == 0) {
|
||||
cplus_mode = PRIVATE;
|
||||
} else {
|
||||
cplus_mode = PUBLIC;
|
||||
}
|
||||
|
||||
ClassName = NewString(classname);
|
||||
ClassPrefix = NewString(iname);
|
||||
ClassName = Copy(name);
|
||||
ClassPrefix = Copy(symname);
|
||||
if (strip) {
|
||||
ClassType = NewString(classname);
|
||||
ClassType = Copy(name);
|
||||
} else {
|
||||
ClassType = NewStringf("%s %s", kind, classname);
|
||||
ClassType = NewStringf("%s %s", kind, name);
|
||||
}
|
||||
Setattr(n, "classtypeobj", Copy(ClassType));
|
||||
Setattr(n, "classtype", SwigType_namestr(ClassType));
|
||||
|
|
@ -2400,7 +2424,7 @@ int Language::classDeclaration(Node *n) {
|
|||
}
|
||||
|
||||
if (dir) {
|
||||
DirectorClassName = NewStringf("SwigDirector_%s", symname);
|
||||
DirectorClassName = directorClassName(n);
|
||||
classDirector(n);
|
||||
}
|
||||
/* check for abstract after resolving directors */
|
||||
|
|
@ -2423,7 +2447,6 @@ int Language::classDeclaration(Node *n) {
|
|||
ClassName = 0;
|
||||
Delete(DirectorClassName);
|
||||
DirectorClassName = 0;
|
||||
Swig_restore(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -2443,6 +2466,9 @@ int Language::classHandler(Node *n) {
|
|||
List *methods = Getattr(n, "allocate:smartpointer");
|
||||
cplus_mode = PUBLIC;
|
||||
SmartPointer = CWRAP_SMART_POINTER;
|
||||
if (Getattr(n, "allocate:smartpointerconst") && Getattr(n, "allocate:smartpointermutable")) {
|
||||
SmartPointer |= CWRAP_SMART_POINTER_OVERLOAD;
|
||||
}
|
||||
Iterator c;
|
||||
for (c = First(methods); c.item; c = Next(c)) {
|
||||
emit_one(c.item);
|
||||
|
|
@ -2595,10 +2621,25 @@ int Language::constructorDeclaration(Node *n) {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
if (name && (Cmp(Swig_scopename_last(name), Swig_scopename_last(ClassName))) && !(Getattr(n, "template"))) {
|
||||
Swig_warning(WARN_LANG_RETURN_TYPE, input_file, line_number, "Function %s must have a return type.\n", SwigType_namestr(name));
|
||||
Swig_restore(n);
|
||||
return SWIG_NOWRAP;
|
||||
String *expected_name = ClassName;
|
||||
String *scope = Swig_scopename_check(ClassName) ? Swig_scopename_prefix(ClassName) : 0;
|
||||
String *actual_name = scope ? NewStringf("%s::%s", scope, name) : NewString(name);
|
||||
Delete(scope);
|
||||
if (!Equal(actual_name, expected_name) && !(Getattr(n, "template"))) {
|
||||
bool illegal_name = true;
|
||||
if (Extend) {
|
||||
// SWIG extension - allow typedef names as destructor name in %extend - an unnamed struct declared with a typedef can thus be given a 'destructor'.
|
||||
SwigType *name_resolved = SwigType_typedef_resolve_all(actual_name);
|
||||
SwigType *expected_name_resolved = SwigType_typedef_resolve_all(expected_name);
|
||||
illegal_name = !Equal(name_resolved, expected_name_resolved);
|
||||
Delete(name_resolved);
|
||||
Delete(expected_name_resolved);
|
||||
}
|
||||
if (illegal_name) {
|
||||
Swig_warning(WARN_LANG_RETURN_TYPE, input_file, line_number, "Function %s must have a return type. Ignored.\n", Swig_name_decl(n));
|
||||
Swig_restore(n);
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
}
|
||||
constructorHandler(n);
|
||||
}
|
||||
|
|
@ -2613,23 +2654,25 @@ int Language::constructorDeclaration(Node *n) {
|
|||
* get_director_ctor_code()
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
static String *get_director_ctor_code(Node *n, String *director_ctor_code, String *director_prot_ctor_code, List *&abstract) {
|
||||
static String *get_director_ctor_code(Node *n, String *director_ctor_code, String *director_prot_ctor_code, List *&abstracts) {
|
||||
String *director_ctor = director_ctor_code;
|
||||
int use_director = Swig_directorclass(n);
|
||||
if (use_director) {
|
||||
Node *pn = Swig_methodclass(n);
|
||||
abstract = Getattr(pn, "abstract");
|
||||
abstracts = Getattr(pn, "abstracts");
|
||||
if (director_prot_ctor_code) {
|
||||
int is_notabstract = GetFlag(pn, "feature:notabstract");
|
||||
int is_abstract = abstract && !is_notabstract;
|
||||
int is_abstract = abstracts && !is_notabstract;
|
||||
if (is_protected(n) || is_abstract) {
|
||||
director_ctor = director_prot_ctor_code;
|
||||
Delattr(pn, "abstract");
|
||||
abstracts = Copy(abstracts);
|
||||
Delattr(pn, "abstracts");
|
||||
} else {
|
||||
if (is_notabstract) {
|
||||
Delattr(pn, "abstract");
|
||||
abstracts = Copy(abstracts);
|
||||
Delattr(pn, "abstracts");
|
||||
} else {
|
||||
abstract = 0;
|
||||
abstracts = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2648,10 +2691,10 @@ int Language::constructorHandler(Node *n) {
|
|||
String *mrename = Swig_name_construct(NSpace, symname);
|
||||
String *nodeType = Getattr(n, "nodeType");
|
||||
int constructor = (!Cmp(nodeType, "constructor"));
|
||||
List *abstract = 0;
|
||||
List *abstracts = 0;
|
||||
String *director_ctor = get_director_ctor_code(n, director_ctor_code,
|
||||
director_prot_ctor_code,
|
||||
abstract);
|
||||
abstracts);
|
||||
if (!constructor) {
|
||||
/* if not originally a constructor, still handle it as one */
|
||||
Setattr(n, "handled_as_constructor", "1");
|
||||
|
|
@ -2662,8 +2705,8 @@ int Language::constructorHandler(Node *n) {
|
|||
functionWrapper(n);
|
||||
Delete(mrename);
|
||||
Swig_restore(n);
|
||||
if (abstract)
|
||||
Setattr(Swig_methodclass(n), "abstract", abstract);
|
||||
if (abstracts)
|
||||
Setattr(Swig_methodclass(n), "abstracts", abstracts);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -2675,17 +2718,17 @@ int Language::copyconstructorHandler(Node *n) {
|
|||
Swig_require("copyconstructorHandler", n, "?name", "*sym:name", "?type", "?parms", NIL);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *mrename = Swig_name_copyconstructor(NSpace, symname);
|
||||
List *abstract = 0;
|
||||
List *abstracts = 0;
|
||||
String *director_ctor = get_director_ctor_code(n, director_ctor_code,
|
||||
director_prot_ctor_code,
|
||||
abstract);
|
||||
abstracts);
|
||||
Swig_ConstructorToFunction(n, NSpace, ClassType, none_comparison, director_ctor, CPlusPlus, Getattr(n, "template") ? 0 : Extend);
|
||||
Setattr(n, "sym:name", mrename);
|
||||
functionWrapper(n);
|
||||
Delete(mrename);
|
||||
Swig_restore(n);
|
||||
if (abstract)
|
||||
Setattr(Swig_methodclass(n), "abstract", abstract);
|
||||
if (abstracts)
|
||||
Setattr(Swig_methodclass(n), "abstracts", abstracts);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -2702,24 +2745,12 @@ int Language::destructorDeclaration(Node *n) {
|
|||
if (ImportMode)
|
||||
return SWIG_NOWRAP;
|
||||
|
||||
if (Extend) {
|
||||
/* extend destructor can be safetly ignored if there is already one */
|
||||
if (Getattr(CurrentClass, "has_destructor")) {
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
}
|
||||
|
||||
Swig_save("destructorDeclaration", n, "name", "sym:name", NIL);
|
||||
|
||||
char *c = GetChar(n, "name");
|
||||
if (c && (*c == '~'))
|
||||
Setattr(n, "name", c + 1);
|
||||
|
||||
c = GetChar(n, "sym:name");
|
||||
if (c && (*c == '~'))
|
||||
char *c = GetChar(n, "sym:name");
|
||||
if (c && (*c == '~')) {
|
||||
Setattr(n, "sym:name", c + 1);
|
||||
|
||||
/* Name adjustment for %name */
|
||||
}
|
||||
|
||||
String *name = Getattr(n, "name");
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
|
|
@ -2728,6 +2759,28 @@ int Language::destructorDeclaration(Node *n) {
|
|||
Setattr(n, "sym:name", ClassPrefix);
|
||||
}
|
||||
|
||||
String *expected_name = ClassName;
|
||||
String *scope = Swig_scopename_check(ClassName) ? Swig_scopename_prefix(ClassName) : 0;
|
||||
String *actual_name = scope ? NewStringf("%s::%s", scope, name) : NewString(name);
|
||||
Delete(scope);
|
||||
Replace(actual_name, "~", "", DOH_REPLACE_FIRST);
|
||||
if (!Equal(actual_name, expected_name) && !(Getattr(n, "template"))) {
|
||||
bool illegal_name = true;
|
||||
if (Extend) {
|
||||
// SWIG extension - allow typedef names as destructor name in %extend - an unnamed struct declared with a typedef can thus be given a 'destructor'.
|
||||
SwigType *name_resolved = SwigType_typedef_resolve_all(actual_name);
|
||||
SwigType *expected_name_resolved = SwigType_typedef_resolve_all(expected_name);
|
||||
illegal_name = !Equal(name_resolved, expected_name_resolved);
|
||||
Delete(name_resolved);
|
||||
Delete(expected_name_resolved);
|
||||
}
|
||||
|
||||
if (illegal_name) {
|
||||
Swig_warning(WARN_LANG_ILLEGAL_DESTRUCTOR, input_file, line_number, "Illegal destructor name %s. Ignored.\n", Swig_name_decl(n));
|
||||
Swig_restore(n);
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
}
|
||||
destructorHandler(n);
|
||||
|
||||
Setattr(CurrentClass, "has_destructor", "1");
|
||||
|
|
@ -2746,7 +2799,7 @@ int Language::destructorHandler(Node *n) {
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
String *mrename;
|
||||
char *csymname = Char(symname);
|
||||
if (csymname && (*csymname == '~'))
|
||||
if (*csymname == '~')
|
||||
csymname += 1;
|
||||
|
||||
mrename = Swig_name_destroy(NSpace, csymname);
|
||||
|
|
@ -2803,7 +2856,7 @@ int Language::validIdentifier(String *s) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Language::usingDeclaration(Node *n) {
|
||||
if ((cplus_mode == PUBLIC)) {
|
||||
if ((cplus_mode == PUBLIC) || (!is_public(n) && dirprot_mode())) {
|
||||
Node *np = Copy(n);
|
||||
Node *c;
|
||||
for (c = firstChild(np); c; c = nextSibling(c)) {
|
||||
|
|
@ -2950,8 +3003,8 @@ int Language::addSymbol(const String *s, const Node *n, const_String_or_char_ptr
|
|||
} else {
|
||||
Node *c = Getattr(symbols, s);
|
||||
if (c && (c != n)) {
|
||||
if (scope)
|
||||
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module in scope %s.\n", s, scope);
|
||||
if (scope && Len(scope) > 0)
|
||||
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module in scope '%s'.\n", s, scope);
|
||||
else
|
||||
Swig_error(input_file, line_number, "'%s' is multiply defined in the generated target language module.\n", s);
|
||||
Swig_error(Getfile(c), Getline(c), "Previous declaration of '%s'\n", s);
|
||||
|
|
@ -3008,7 +3061,7 @@ Node *Language::symbolLookup(String *s, const_String_or_char_ptr scope) {
|
|||
* Tries to locate a class from a type definition
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Node *Language::classLookup(SwigType *s) {
|
||||
Node *Language::classLookup(const SwigType *s) {
|
||||
Node *n = 0;
|
||||
|
||||
/* Look in hash of cached values */
|
||||
|
|
@ -3119,7 +3172,9 @@ Node *Language::enumLookup(SwigType *s) {
|
|||
n = Swig_symbol_clookup(base, stab);
|
||||
if (!n)
|
||||
break;
|
||||
if (Strcmp(nodeType(n), "enum") == 0)
|
||||
if (Equal(nodeType(n), "enum"))
|
||||
break;
|
||||
if (Equal(nodeType(n), "enumforward") && GetFlag(n, "enumMissing"))
|
||||
break;
|
||||
n = parentNode(n);
|
||||
if (!n)
|
||||
|
|
@ -3290,7 +3345,7 @@ int Language::need_nonpublic_ctor(Node *n) {
|
|||
* Language::need_nonpublic_member()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
int Language::need_nonpublic_member(Node *n) {
|
||||
if (directorsEnabled()) {
|
||||
if (directorsEnabled() && DirectorClassName) {
|
||||
if (is_protected(n)) {
|
||||
if (dirprot_mode()) {
|
||||
/* when using dirprot mode, the protected members are always needed. */
|
||||
|
|
@ -3314,6 +3369,16 @@ int Language::is_smart_pointer() const {
|
|||
return SmartPointer;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
bool Language::isNonVirtualProtectedAccess(Node *n) const {
|
||||
// Ideally is_non_virtual_protected_access() would contain all this logic, see
|
||||
// comments therein about vtable.
|
||||
return DirectorClassName && is_non_virtual_protected_access(n);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::extraDirectorProtectedCPPMethodsRequired()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -3381,17 +3446,17 @@ int Language::abstractClassTest(Node *n) {
|
|||
if (Getattr(n, "allocate:nonew"))
|
||||
return 1;
|
||||
/* now check for the rest */
|
||||
List *abstract = Getattr(n, "abstract");
|
||||
if (!abstract)
|
||||
List *abstracts = Getattr(n, "abstracts");
|
||||
if (!abstracts)
|
||||
return 0;
|
||||
int labs = Len(abstract);
|
||||
int labs = Len(abstracts);
|
||||
#ifdef SWIG_DEBUG
|
||||
List *bases = Getattr(n, "allbases");
|
||||
Printf(stderr, "testing %s %d %d\n", Getattr(n, "name"), labs, Len(bases));
|
||||
#endif
|
||||
if (!labs)
|
||||
return 0; /*strange, but need to be fixed */
|
||||
if (abstract && !directorsEnabled())
|
||||
if (abstracts && !directorsEnabled())
|
||||
return 1;
|
||||
if (!GetFlag(n, "feature:director"))
|
||||
return 1;
|
||||
|
|
@ -3403,7 +3468,7 @@ int Language::abstractClassTest(Node *n) {
|
|||
Printf(stderr, "vtable %s %d %d\n", Getattr(n, "name"), Len(vtable), labs);
|
||||
#endif
|
||||
for (int i = 0; i < labs; i++) {
|
||||
Node *ni = Getitem(abstract, i);
|
||||
Node *ni = Getitem(abstracts, i);
|
||||
Node *method_id = vtable_method_id(ni);
|
||||
if (!method_id)
|
||||
continue;
|
||||
|
|
@ -3440,7 +3505,7 @@ int Language::abstractClassTest(Node *n) {
|
|||
} else {
|
||||
return 1;
|
||||
}
|
||||
return dirabstract ? 1 : 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Language::setSubclassInstanceCheck(String *nc) {
|
||||
|
|
|
|||
|
|
@ -40,12 +40,10 @@
|
|||
* ver009
|
||||
class support: ok for basic types, but methods still TDB
|
||||
(code is VERY messed up & needs to be cleaned)
|
||||
|
||||
|
||||
* ver010
|
||||
Added support for embedded Lua. Try swig -lua -help for more information
|
||||
*/
|
||||
|
||||
char cvsroot_lua_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
/**** Diagnostics:
|
||||
|
|
@ -62,7 +60,7 @@ char cvsroot_lua_cxx[] = "$Id$";
|
|||
void display_mapping(DOH *d) {
|
||||
if (d == 0 || !DohIsMapping(d))
|
||||
return;
|
||||
for (DohIterator it = DohFirst(d); it.item; it = DohNext(it)) {
|
||||
for (Iterator it = First(d); it.item; it = Next(it)) {
|
||||
if (DohIsString(it.item))
|
||||
Printf(stdout, " %s = %s\n", it.key, it.item);
|
||||
else if (DohIsMapping(it.item))
|
||||
|
|
@ -82,10 +80,16 @@ void display_mapping(DOH *d) {
|
|||
(though for now I have not bothered)
|
||||
NEW LANGUAGE NOTE:END ************************************************/
|
||||
static const char *usage = (char *) "\
|
||||
Lua Options (available with -lua)\n\
|
||||
(coming soon.)\n\n";
|
||||
|
||||
Lua Options (available with -lua)\n\
|
||||
-elua - Generates LTR compatible wrappers for smaller devices running elua\n\
|
||||
-eluac - LTR compatible wrappers in \"crass compress\" mode for elua\n\
|
||||
-nomoduleglobal - Do not register the module name as a global variable \n\
|
||||
but return the module table from calls to require.\n\
|
||||
\n";
|
||||
|
||||
static int nomoduleglobal = 0;
|
||||
static int elua_ltr = 0;
|
||||
static int eluac_ltr = 0;
|
||||
|
||||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
To add a new language, you need to derive your class from
|
||||
|
|
@ -107,8 +111,11 @@ private:
|
|||
String *s_var_tab; // table of global variables
|
||||
String *s_const_tab; // table of global constants
|
||||
String *s_methods_tab; // table of class methods
|
||||
String *s_attr_tab; // table of class atributes
|
||||
String *s_attr_tab; // table of class attributes
|
||||
String *s_luacode; // luacode to be called during init
|
||||
String *s_dot_get; // table of variable 'get' functions
|
||||
String *s_dot_set; // table of variable 'set' functions
|
||||
String *s_vars_meta_tab; // metatable for variables
|
||||
|
||||
int have_constructor;
|
||||
int have_destructor;
|
||||
|
|
@ -136,17 +143,29 @@ public:
|
|||
* Initialize member data
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
LUA() {
|
||||
f_begin = 0;
|
||||
f_runtime = 0;
|
||||
f_header = 0;
|
||||
f_wrappers = 0;
|
||||
f_init = 0;
|
||||
f_initbeforefunc = 0;
|
||||
PrefixPlusUnderscore = 0;
|
||||
|
||||
s_cmd_tab = s_var_tab = s_const_tab = s_luacode = 0;
|
||||
current=NO_CPP;
|
||||
LUA() :
|
||||
f_begin(0),
|
||||
f_runtime(0),
|
||||
f_header(0),
|
||||
f_wrappers(0),
|
||||
f_init(0),
|
||||
f_initbeforefunc(0),
|
||||
PrefixPlusUnderscore(0),
|
||||
s_cmd_tab(0),
|
||||
s_var_tab(0),
|
||||
s_const_tab(0),
|
||||
s_methods_tab(0),
|
||||
s_attr_tab(0),
|
||||
s_luacode(0),
|
||||
s_dot_get(0),
|
||||
s_dot_set(0),
|
||||
s_vars_meta_tab(0),
|
||||
have_constructor(0),
|
||||
have_destructor(0),
|
||||
destructor_action(0),
|
||||
class_name(0),
|
||||
constructor_name(0),
|
||||
current(NO_CPP) {
|
||||
}
|
||||
|
||||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
|
|
@ -170,7 +189,16 @@ public:
|
|||
for (int i = 1; i < argc; i++) {
|
||||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) { // usage flags
|
||||
fputs(usage, stderr);
|
||||
fputs(usage, stdout);
|
||||
} else if (strcmp(argv[i], "-nomoduleglobal") == 0) {
|
||||
nomoduleglobal = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if(strcmp(argv[i], "-elua") == 0) {
|
||||
elua_ltr = 1;
|
||||
Swig_mark_arg(i);
|
||||
} else if(strcmp(argv[i], "-eluac") == 0) {
|
||||
eluac_ltr = 1;
|
||||
Swig_mark_arg(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -250,6 +278,10 @@ public:
|
|||
s_var_tab = NewString("");
|
||||
// s_methods_tab = NewString("");
|
||||
s_const_tab = NewString("");
|
||||
|
||||
s_dot_get = NewString("");
|
||||
s_dot_set = NewString("");
|
||||
s_vars_meta_tab = NewString("");
|
||||
|
||||
s_luacode = NewString("");
|
||||
Swig_register_filebyname("luacode", s_luacode);
|
||||
|
|
@ -262,6 +294,14 @@ public:
|
|||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIGLUA\n");
|
||||
|
||||
emitLuaFlavor(f_runtime);
|
||||
|
||||
if (nomoduleglobal) {
|
||||
Printf(f_runtime, "#define SWIG_LUA_NO_MODULE_GLOBAL\n");
|
||||
} else {
|
||||
Printf(f_runtime, "#define SWIG_LUA_MODULE_GLOBAL\n");
|
||||
}
|
||||
|
||||
// if (NoInclude) {
|
||||
// Printf(f_runtime, "#define SWIG_NOINCLUDE\n");
|
||||
// }
|
||||
|
|
@ -276,12 +316,31 @@ public:
|
|||
Printf(f_header, "#define SWIG_name \"%s\"\n", module);
|
||||
Printf(f_header, "#define SWIG_init luaopen_%s\n", module);
|
||||
Printf(f_header, "#define SWIG_init_user luaopen_%s_user\n\n", module);
|
||||
Printf(f_header, "#define SWIG_LUACODE luaopen_%s_luacode\n\n", module);
|
||||
Printf(f_header, "#define SWIG_LUACODE luaopen_%s_luacode\n", module);
|
||||
|
||||
Printf(s_cmd_tab, "\nstatic const struct luaL_reg swig_commands[] = {\n");
|
||||
Printf(s_var_tab, "\nstatic swig_lua_var_info swig_variables[] = {\n");
|
||||
Printf(s_const_tab, "\nstatic swig_lua_const_info swig_constants[] = {\n");
|
||||
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
if (elua_ltr || eluac_ltr)
|
||||
Printf(f_header, "#define swig_commands %s_map\n\n", module);
|
||||
|
||||
if (elua_ltr || eluac_ltr) {
|
||||
Printf(s_cmd_tab, "\n#define MIN_OPT_LEVEL 2\n#include \"lrodefs.h\"\n");
|
||||
Printf(s_cmd_tab, "#include \"lrotable.h\"\n");
|
||||
Printf(s_cmd_tab, "\nconst LUA_REG_TYPE swig_constants[];\n");
|
||||
if (elua_ltr)
|
||||
Printf(s_cmd_tab, "const LUA_REG_TYPE mt[];\n");
|
||||
|
||||
Printf(s_cmd_tab, "\nconst LUA_REG_TYPE swig_commands[] = {\n");
|
||||
Printf(s_const_tab, "\nconst LUA_REG_TYPE swig_constants[] = {\n");
|
||||
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
if (elua_ltr) {
|
||||
Printf(s_dot_get, "\nconst LUA_REG_TYPE dot_get[] = {\n");
|
||||
Printf(s_dot_set, "\nconst LUA_REG_TYPE dot_set[] = {\n");
|
||||
}
|
||||
} else {
|
||||
Printf(s_cmd_tab, "\nstatic const struct luaL_Reg swig_commands[] = {\n");
|
||||
Printf(s_var_tab, "\nstatic swig_lua_var_info swig_variables[] = {\n");
|
||||
Printf(s_const_tab, "\nstatic swig_lua_const_info swig_constants[] = {\n");
|
||||
Printf(f_wrappers, "#ifdef __cplusplus\nextern \"C\" {\n#endif\n");
|
||||
}
|
||||
|
||||
/* %init code inclusion, effectively in the SWIG_init function */
|
||||
Printf(f_init, "void SWIG_init_user(lua_State* L)\n{\n");
|
||||
|
|
@ -292,11 +351,39 @@ public:
|
|||
Printf(f_wrappers, "#ifdef __cplusplus\n}\n#endif\n");
|
||||
|
||||
// Done. Close up the module & write to the wrappers
|
||||
Printv(s_cmd_tab, tab4, "{0,0}\n", "};\n", NIL);
|
||||
Printv(s_var_tab, tab4, "{0,0,0}\n", "};\n", NIL);
|
||||
Printv(s_const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL);
|
||||
Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
if (elua_ltr || eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"const\"), LROVAL(swig_constants)},\n", NIL);
|
||||
if (elua_ltr)
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"__metatable\"), LROVAL(mt)},\n", NIL);
|
||||
Printv(s_cmd_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL);
|
||||
Printv(s_const_tab, tab4, "{LNILKEY, LNILVAL}\n", "};\n", NIL);
|
||||
} else {
|
||||
Printv(s_cmd_tab, tab4, "{0,0}\n", "};\n", NIL);
|
||||
Printv(s_var_tab, tab4, "{0,0,0}\n", "};\n", NIL);
|
||||
Printv(s_const_tab, tab4, "{0,0,0,0,0,0}\n", "};\n", NIL);
|
||||
}
|
||||
|
||||
if (elua_ltr) {
|
||||
/* Generate the metatable */
|
||||
Printf(s_vars_meta_tab, "\nconst LUA_REG_TYPE mt[] = {\n");
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\"__index\"), LFUNCVAL(SWIG_Lua_module_get)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\"__newindex\"), LFUNCVAL(SWIG_Lua_module_set)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\".get\"), LROVAL(dot_get)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LSTRKEY(\".set\"), LROVAL(dot_set)},\n", NIL);
|
||||
Printv(s_vars_meta_tab, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL);
|
||||
|
||||
Printv(s_dot_get, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL);
|
||||
Printv(s_dot_set, tab4, "{LNILKEY, LNILVAL}\n};\n", NIL);
|
||||
}
|
||||
|
||||
if (elua_ltr || eluac_ltr) {
|
||||
/* Final close up of wrappers */
|
||||
Printv(f_wrappers, s_cmd_tab, s_dot_get, s_dot_set, s_vars_meta_tab, s_var_tab, s_const_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
} else {
|
||||
Printv(f_wrappers, s_cmd_tab, s_var_tab, s_const_tab, NIL);
|
||||
SwigType_emit_type_table(f_runtime, f_wrappers);
|
||||
}
|
||||
|
||||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
this basically combines several of the strings together
|
||||
|
|
@ -319,9 +406,11 @@ public:
|
|||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Delete(f_initbeforefunc);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
Delete(s_dot_get);
|
||||
Delete(s_dot_set);
|
||||
Delete(s_vars_meta_tab);
|
||||
|
||||
/* Done */
|
||||
return SWIG_OK;
|
||||
|
|
@ -445,10 +534,8 @@ public:
|
|||
String *argument_check = NewString("");
|
||||
String *argument_parse = NewString("");
|
||||
String *checkfn = NULL;
|
||||
// String *numoutputs=NULL;
|
||||
char source[64];
|
||||
//Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",name,num_required,num_arguments);
|
||||
Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",name,num_required+args_to_ignore,num_arguments+args_to_ignore);
|
||||
Printf(argument_check, "SWIG_check_num_args(\"%s\",%d,%d)\n",Swig_name_str(n),num_required+args_to_ignore,num_arguments+args_to_ignore);
|
||||
|
||||
for (i = 0, p = l; i < num_arguments; i++) {
|
||||
|
||||
|
|
@ -484,7 +571,7 @@ public:
|
|||
} else {
|
||||
Printf(argument_check, "if(lua_gettop(L)>=%s && !%s(L,%s))", source, checkfn, source);
|
||||
}
|
||||
Printf(argument_check, " SWIG_fail_arg(\"%s\",%s,\"%s\");\n", name, source, SwigType_str(pt, 0));
|
||||
Printf(argument_check, " SWIG_fail_arg(\"%s\",%s,\"%s\");\n", Swig_name_str(n), source, SwigType_str(pt, 0));
|
||||
}
|
||||
/* NEW LANGUAGE NOTE:***********************************************
|
||||
lua states the number of arguments passed to a function using the fn
|
||||
|
|
@ -554,7 +641,7 @@ public:
|
|||
// }
|
||||
// else returnval++;
|
||||
Replaceall(tm, "$source", Getattr(p, "lname"));
|
||||
Replaceall(tm, "$target", "result");
|
||||
Replaceall(tm, "$target", Swig_cresult_name());
|
||||
Replaceall(tm, "$arg", Getattr(p, "emit:input"));
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:input"));
|
||||
Printv(outarg, tm, "\n", NIL);
|
||||
|
|
@ -575,7 +662,7 @@ public:
|
|||
this is because there is a typemap for void
|
||||
NEW LANGUAGE NOTE:END ************************************************/
|
||||
// Return value if necessary
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
// managing the number of returning variables
|
||||
// if (numoutputs=Getattr(tm,"numoutputs")){
|
||||
// int i=GetInt(tm,"numoutputs");
|
||||
|
|
@ -583,7 +670,7 @@ public:
|
|||
// returnval+=GetInt(tm,"numoutputs");
|
||||
// }
|
||||
// else returnval++;
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
Replaceall(tm, "$owner", "1");
|
||||
} else {
|
||||
|
|
@ -604,15 +691,15 @@ public:
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
@ -631,7 +718,7 @@ public:
|
|||
|
||||
/* Substitute the function name */
|
||||
Replaceall(f->code, "$symname", iname);
|
||||
Replaceall(f->code, "$result", "result");
|
||||
Replaceall(f->code, "$result", Swig_cresult_name());
|
||||
|
||||
/* Dump the function out */
|
||||
/* in Lua we will not emit the destructor as a wrappered function,
|
||||
|
|
@ -652,9 +739,13 @@ public:
|
|||
/* Now register the function with the interpreter. */
|
||||
if (!Getattr(n, "sym:overloaded")) {
|
||||
// add_method(n, iname, wname, description);
|
||||
if (current==NO_CPP || current==STATIC_FUNC) // emit normal fns & static fns
|
||||
Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
if (current==NO_CPP || current==STATIC_FUNC) { // emit normal fns & static fns
|
||||
if(elua_ltr || eluac_ltr)
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "\")", ", LFUNCVAL(", Swig_name_wrapper(iname), ")", "},\n", NIL);
|
||||
else
|
||||
Printv(s_cmd_tab, tab4, "{ \"", iname, "\", ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
// Printv(s_cmd_tab, tab4, "{ SWIG_prefix \"", iname, "\", (swig_wrapper_func) ", Swig_name_wrapper(iname), "},\n", NIL);
|
||||
}
|
||||
} else {
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
dispatchFunction(n);
|
||||
|
|
@ -718,7 +809,9 @@ public:
|
|||
sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up
|
||||
String *protoTypes = NewString("");
|
||||
do {
|
||||
Printf(protoTypes, "\n\" %s(%s)\\n\"", SwigType_str(Getattr(sibl, "name"), 0), ParmList_protostr(Getattr(sibl, "wrap:parms")));
|
||||
String *fulldecl = Swig_name_decl(sibl);
|
||||
Printf(protoTypes, "\n\" %s\\n\"", fulldecl);
|
||||
Delete(fulldecl);
|
||||
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
|
||||
Printf(f->code, "lua_pushstring(L,\"Wrong arguments for overloaded function '%s'\\n\"\n"
|
||||
"\" Possible C/C++ prototypes are:\\n\"%s);\n",symname,protoTypes);
|
||||
|
|
@ -761,7 +854,7 @@ public:
|
|||
String *getName = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, iname));
|
||||
String *setName = 0;
|
||||
// checking whether it can be set to or not appears to be a very error prone issue
|
||||
// I refered to the Language::variableWrapper() to find this out
|
||||
// I referred to the Language::variableWrapper() to find this out
|
||||
bool assignable=is_assignable(n) ? true : false;
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *tm = Swig_typemap_lookup("globalin", n, iname, 0);
|
||||
|
|
@ -776,8 +869,17 @@ public:
|
|||
setName = NewString("SWIG_Lua_set_immutable"); // error message
|
||||
//setName = NewString("0");
|
||||
}
|
||||
|
||||
// register the variable
|
||||
Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName);
|
||||
if (elua_ltr) {
|
||||
Printf(s_dot_get, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, iname, getName);
|
||||
Printf(s_dot_set, "%s{LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", tab4, iname, setName);
|
||||
} else if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "_get", "\")", ", LFUNCVAL(", getName, ")", "},\n", NIL);
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", iname, "_set", "\")", ", LFUNCVAL(", setName, ")", "},\n", NIL);
|
||||
} else {
|
||||
Printf(s_var_tab, "%s{ \"%s\", %s, %s },\n", tab4, iname, getName, setName);
|
||||
}
|
||||
Delete(getName);
|
||||
Delete(setName);
|
||||
return result;
|
||||
|
|
@ -811,7 +913,7 @@ public:
|
|||
Replaceall(tm, "$target", name);
|
||||
Replaceall(tm, "$value", value);
|
||||
Replaceall(tm, "$nsname", nsname);
|
||||
Printf(s_const_tab, "%s,\n", tm);
|
||||
Printf(s_const_tab, " %s,\n", tm);
|
||||
} else if ((tm = Swig_typemap_lookup("constcode", n, name, 0))) {
|
||||
Replaceall(tm, "$source", value);
|
||||
Replaceall(tm, "$target", name);
|
||||
|
|
@ -889,7 +991,7 @@ public:
|
|||
real_classname = Getattr(n, "name");
|
||||
mangled_classname = Swig_name_mangle(real_classname);
|
||||
|
||||
// not sure exactly how this workswhat this works,
|
||||
// not sure exactly how this works,
|
||||
// but tcl has a static hashtable of all classes emitted and then only emits code for them once.
|
||||
// this fixes issues in test suites: template_default2 & template_specialization
|
||||
|
||||
|
|
@ -919,7 +1021,7 @@ public:
|
|||
String *wrap_class = NewStringf("&_wrap_class_%s", mangled_classname);
|
||||
SwigType_remember_clientdata(t, wrap_class);
|
||||
|
||||
String *rt = Copy(Getattr(n, "classtype"));
|
||||
String *rt = Copy(getClassType());
|
||||
SwigType_add_pointer(rt);
|
||||
|
||||
// Register the class structure with the type checker
|
||||
|
|
@ -951,7 +1053,7 @@ public:
|
|||
Delete(s_attr_tab);
|
||||
|
||||
// Handle inheritance
|
||||
// note: with the idea of class hireachied spread over multiple modules
|
||||
// note: with the idea of class hierarchies spread over multiple modules
|
||||
// cf test-suite: imports.i
|
||||
// it is not possible to just add the pointers to the base classes to the code
|
||||
// (as sometimes these classes are not present)
|
||||
|
|
@ -995,7 +1097,17 @@ public:
|
|||
Printv(f_wrappers, "static swig_lua_class _wrap_class_", mangled_classname, " = { \"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
|
||||
|
||||
if (have_constructor) {
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
if (elua_ltr) {
|
||||
Printf(s_cmd_tab, " {LSTRKEY(\"%s\"), LFUNCVAL(%s)},\n", class_name, \
|
||||
Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
} else if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", "new_", class_name, "\")", ", LFUNCVAL(", \
|
||||
Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)), ")", "},\n", NIL);
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
} else {
|
||||
Printf(f_wrappers, "%s", Swig_name_wrapper(Swig_name_construct(NSPACE_TODO, constructor_name)));
|
||||
}
|
||||
Delete(constructor_name);
|
||||
constructor_name = 0;
|
||||
} else {
|
||||
|
|
@ -1003,7 +1115,12 @@ public:
|
|||
}
|
||||
|
||||
if (have_destructor) {
|
||||
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||
if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", "free_", class_name, "\")", ", LFUNCVAL(", "swig_delete_", class_name, ")", "},\n", NIL);
|
||||
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||
} else {
|
||||
Printv(f_wrappers, ", swig_delete_", class_name, NIL);
|
||||
}
|
||||
} else {
|
||||
Printf(f_wrappers, ",0");
|
||||
}
|
||||
|
|
@ -1069,6 +1186,12 @@ public:
|
|||
sname = NewString("SWIG_Lua_set_immutable"); // error message
|
||||
}
|
||||
Printf(s_attr_tab,"%s{ \"%s\", %s, %s},\n",tab4,symname,gname,sname);
|
||||
if (eluac_ltr) {
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", class_name, "_", symname, "_get", "\")", \
|
||||
", LFUNCVAL(", gname, ")", "},\n", NIL);
|
||||
Printv(s_cmd_tab, tab4, "{LSTRKEY(\"", class_name, "_", symname, "_set", "\")", \
|
||||
", LFUNCVAL(", sname, ")", "},\n", NIL);
|
||||
}
|
||||
Delete(gname);
|
||||
Delete(sname);
|
||||
return SWIG_OK;
|
||||
|
|
@ -1149,9 +1272,10 @@ public:
|
|||
*/
|
||||
String *runtimeCode() {
|
||||
String *s = NewString("");
|
||||
const char *filenames[] = { "luarun.swg", 0
|
||||
}
|
||||
; // must be 0 termiated
|
||||
const char *filenames[] = { "luarun.swg", 0 } ; // must be 0 terminated
|
||||
|
||||
emitLuaFlavor(s);
|
||||
|
||||
String *sfile;
|
||||
for (int i = 0; filenames[i] != 0; i++) {
|
||||
sfile = Swig_include_sys(filenames[i]);
|
||||
|
|
@ -1174,6 +1298,16 @@ public:
|
|||
* helpers
|
||||
* --------------------------------------------------------------------- */
|
||||
|
||||
void emitLuaFlavor(String *s) {
|
||||
if (elua_ltr)
|
||||
Printf(s, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUA\n");
|
||||
else if (eluac_ltr)
|
||||
Printf(s, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_ELUAC\n");
|
||||
else
|
||||
Printf(s, "#define SWIG_LUA_TARGET SWIG_LUA_FLAVOR_LUA\n");
|
||||
}
|
||||
|
||||
|
||||
/* This is to convert the string of Lua code into a proper string, which can then be
|
||||
emitted into the C/C++ code.
|
||||
Basically is is a lot of search & replacing of odd sequences
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Main entry point to the SWIG core.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_main_cxx[] = "$Id$";
|
||||
|
||||
#include "swigconfig.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
|
@ -129,6 +127,7 @@ static const char *usage3 = (const char *) "\
|
|||
-oh <headfile> - Set name of the output header file to <headfile>\n\
|
||||
-outcurrentdir - Set default output dir to current dir instead of input file's path\n\
|
||||
-outdir <dir> - Set language specific files output directory to <dir>\n\
|
||||
-pcreversion - Display PCRE version information\n\
|
||||
-small - Compile in virtual elimination & compact mode\n\
|
||||
-swiglib - Report location of SWIG library and exit\n\
|
||||
-templatereduce - Reduce all the typedefs in templates\n\
|
||||
|
|
@ -154,9 +153,9 @@ is equivalent to: \n\
|
|||
\n";
|
||||
|
||||
// Local variables
|
||||
static String *LangSubDir = 0; // Target language library subdirectory
|
||||
static char *SwigLib = 0; // Library directory
|
||||
static String *SwigLibWin = 0; // Extra Library directory for Windows
|
||||
static String *LangSubDir = 0; // Target language library subdirectory
|
||||
static String *SwigLib = 0; // Library directory
|
||||
static String *SwigLibWinUnix = 0; // Extra library directory on Windows
|
||||
static int freeze = 0;
|
||||
static String *lang_config = 0;
|
||||
static char *hpp_extension = (char *) "h";
|
||||
|
|
@ -198,22 +197,24 @@ static List *libfiles = 0;
|
|||
static List *all_output_files = 0;
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* check_suffix()
|
||||
* check_extension()
|
||||
*
|
||||
* Checks the suffix of a file to see if we should emit extern declarations.
|
||||
* Checks the extension of a file to see if we should emit extern declarations.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int check_suffix(String *filename) {
|
||||
static bool check_extension(String *filename) {
|
||||
bool wanted = false;
|
||||
const char *name = Char(filename);
|
||||
const char *c;
|
||||
if (!name)
|
||||
return 0;
|
||||
c = Swig_file_suffix(name);
|
||||
String *extension = Swig_file_extension(name);
|
||||
const char *c = Char(extension);
|
||||
if ((strcmp(c, ".c") == 0) ||
|
||||
(strcmp(c, ".C") == 0) || (strcmp(c, ".cc") == 0) || (strcmp(c, ".cxx") == 0) || (strcmp(c, ".c++") == 0) || (strcmp(c, ".cpp") == 0)) {
|
||||
return 1;
|
||||
wanted = true;
|
||||
}
|
||||
return 0;
|
||||
Delete(extension);
|
||||
return wanted;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -282,15 +283,16 @@ static unsigned int decode_numbers_list(String *numlist) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Sets the output directory for language specific (proxy) files if not set and
|
||||
* corrects the directory name and adds trailing file separator if necessary.
|
||||
* Sets the output directory for language specific (proxy) files from the
|
||||
* C wrapper file if not set and corrects the directory name and adds a trailing
|
||||
* file separator if necessary.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void configure_outdir(const String *c_wrapper_file_dir) {
|
||||
static void configure_outdir(const String *c_wrapper_outfile) {
|
||||
|
||||
// Use the C wrapper file's directory if the output directory has not been set by user
|
||||
if (!outdir || Len(outdir) == 0)
|
||||
outdir = NewString(c_wrapper_file_dir);
|
||||
outdir = Swig_file_dirname(c_wrapper_outfile);
|
||||
|
||||
Swig_filename_correct(outdir);
|
||||
|
||||
|
|
@ -402,7 +404,7 @@ static void SWIG_dump_runtime() {
|
|||
s = Swig_include_sys("swiglabels.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swiglabels.swg'\n");
|
||||
Close(runtime);
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
|
|
@ -411,23 +413,16 @@ static void SWIG_dump_runtime() {
|
|||
s = Swig_include_sys("swigerrors.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swigerrors.swg'\n");
|
||||
Close(runtime);
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
Delete(s);
|
||||
|
||||
s = Swig_include_sys("swigerrors.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swigerrors.swg'\n");
|
||||
Close(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
s = Swig_include_sys("swigrun.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'swigrun.swg'\n");
|
||||
Close(runtime);
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
|
|
@ -440,13 +435,12 @@ static void SWIG_dump_runtime() {
|
|||
s = Swig_include_sys("runtime.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'runtime.swg'\n");
|
||||
Close(runtime);
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
Printf(runtime, "%s", s);
|
||||
Delete(s);
|
||||
|
||||
Close(runtime);
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
|
@ -515,6 +509,12 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-nodirprot") == 0) {
|
||||
Wrapper_director_protected_mode_set(0);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-pcreversion") == 0) {
|
||||
String *version = Swig_pcre_version();
|
||||
Printf(stdout, "%s\n", version);
|
||||
Delete(version);
|
||||
Swig_mark_arg(i);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-small") == 0) {
|
||||
Wrapper_compact_print_mode_set(1);
|
||||
Wrapper_virtual_elimination_mode_set(1);
|
||||
|
|
@ -574,9 +574,9 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
Swig_cparse_follow_locators(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-swiglib") == 0) {
|
||||
if (SwigLibWin)
|
||||
Printf(stdout, "%s\n", SwigLibWin);
|
||||
Printf(stdout, "%s\n", SwigLib);
|
||||
if (SwigLibWinUnix)
|
||||
Printf(stdout, "%s\n", SwigLibWinUnix);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-o") == 0) {
|
||||
Swig_mark_arg(i);
|
||||
|
|
@ -622,7 +622,14 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
} else if (strcmp(argv[i], "-version") == 0) {
|
||||
fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version());
|
||||
fprintf(stdout, "\nCompiled with %s [%s]\n", SWIG_CXX, SWIG_PLATFORM);
|
||||
fprintf(stdout, "Please see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT);
|
||||
fprintf(stdout, "\nConfigured options: %cpcre\n",
|
||||
#ifdef HAVE_PCRE
|
||||
'+'
|
||||
#else
|
||||
'-'
|
||||
#endif
|
||||
);
|
||||
fprintf(stdout, "\nPlease see %s for reporting bugs and further information\n", PACKAGE_BUGREPORT);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
} else if (strcmp(argv[i], "-copyright") == 0) {
|
||||
fprintf(stdout, "\nSWIG Version %s\n", Swig_package_version());
|
||||
|
|
@ -900,14 +907,17 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
char *p;
|
||||
if (!(GetModuleFileName(0, buf, MAX_PATH) == 0 || (p = strrchr(buf, '\\')) == 0)) {
|
||||
*(p + 1) = '\0';
|
||||
SwigLibWin = NewStringf("%sLib", buf); // Native windows installation path
|
||||
SwigLib = NewStringf("%sLib", buf); // Native windows installation path
|
||||
} else {
|
||||
SwigLib = NewStringf(""); // Unexpected error
|
||||
}
|
||||
SwigLib = Swig_copy_string(SWIG_LIB_WIN_UNIX); // Unix installation path using a drive letter (for msys/mingw)
|
||||
if (Len(SWIG_LIB_WIN_UNIX) > 0)
|
||||
SwigLibWinUnix = NewString(SWIG_LIB_WIN_UNIX); // Unix installation path using a drive letter (for msys/mingw)
|
||||
#else
|
||||
SwigLib = Swig_copy_string(SWIG_LIB);
|
||||
SwigLib = NewString(SWIG_LIB);
|
||||
#endif
|
||||
} else {
|
||||
SwigLib = Swig_copy_string(c);
|
||||
SwigLib = NewString(c);
|
||||
}
|
||||
|
||||
libfiles = NewList();
|
||||
|
|
@ -939,9 +949,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
String *rl = NewString("");
|
||||
Printf(rl, ".%sswig_lib%s%s", SWIG_FILE_DELIMITER, SWIG_FILE_DELIMITER, LangSubDir);
|
||||
Swig_add_directory(rl);
|
||||
if (SwigLibWin) {
|
||||
if (SwigLibWinUnix) {
|
||||
rl = NewString("");
|
||||
Printf(rl, "%s%s%s", SwigLibWin, SWIG_FILE_DELIMITER, LangSubDir);
|
||||
Printf(rl, "%s%s%s", SwigLibWinUnix, SWIG_FILE_DELIMITER, LangSubDir);
|
||||
Swig_add_directory(rl);
|
||||
}
|
||||
rl = NewString("");
|
||||
|
|
@ -950,9 +960,9 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
}
|
||||
|
||||
Swig_add_directory((String *) "." SWIG_FILE_DELIMITER "swig_lib");
|
||||
if (SwigLibWin)
|
||||
Swig_add_directory((String *) SwigLibWin);
|
||||
Swig_add_directory((String *) SwigLib);
|
||||
if (SwigLibWinUnix)
|
||||
Swig_add_directory((String *) SwigLibWinUnix);
|
||||
Swig_add_directory(SwigLib);
|
||||
|
||||
if (Verbose) {
|
||||
Printf(stdout, "Language subdirectory: %s\n", LangSubDir);
|
||||
|
|
@ -999,7 +1009,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
if (Verbose)
|
||||
Printf(stdout, "'%s' checked out from the SWIG library.\n", outfile);
|
||||
Printv(f_outfile, s, NIL);
|
||||
Close(f_outfile);
|
||||
Delete(f_outfile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1059,7 +1069,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
String *outfile;
|
||||
File *f_dependencies_file = 0;
|
||||
|
||||
char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(input_file): Char(input_file));
|
||||
String *inputfile_filename = outcurrentdir ? Swig_file_filename(input_file): Copy(input_file);
|
||||
String *basename = Swig_file_basename(inputfile_filename);
|
||||
if (!outfile_name) {
|
||||
if (CPlusPlus || lang->cplus_runtime_mode()) {
|
||||
outfile = NewStringf("%s_wrap.%s", basename, cpp_extension);
|
||||
|
|
@ -1093,7 +1104,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
for (int i = 0; i < Len(files); i++) {
|
||||
int use_file = 1;
|
||||
if (depend == 2) {
|
||||
if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWin && (Strncmp(Getitem(files, i), SwigLibWin, Len(SwigLibWin)) == 0)))
|
||||
if ((Strncmp(Getitem(files, i), SwigLib, Len(SwigLib)) == 0) || (SwigLibWinUnix && (Strncmp(Getitem(files, i), SwigLibWinUnix, Len(SwigLibWinUnix)) == 0)))
|
||||
use_file = 0;
|
||||
}
|
||||
if (use_file)
|
||||
|
|
@ -1101,9 +1112,11 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
}
|
||||
Printf(f_dependencies_file, "\n");
|
||||
if (f_dependencies_file != stdout)
|
||||
Close(f_dependencies_file);
|
||||
Delete(f_dependencies_file);
|
||||
if (depend_only)
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
Delete(inputfile_filename);
|
||||
Delete(basename);
|
||||
} else {
|
||||
Printf(stderr, "Cannot generate dependencies with -nopreprocess\n");
|
||||
// Actually we could but it would be inefficient when just generating dependencies, as it would be done after Swig_cparse
|
||||
|
|
@ -1178,7 +1191,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
}
|
||||
|
||||
if (dump_typedef) {
|
||||
SwigType_print_scope(0);
|
||||
SwigType_print_scope();
|
||||
}
|
||||
|
||||
if (dump_symtabs) {
|
||||
|
|
@ -1211,7 +1224,8 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
Setattr(top, "infile", infile); // Note: if nopreprocess then infile is the original input file, otherwise input_file
|
||||
Setattr(top, "inputfile", input_file);
|
||||
|
||||
char *basename = Swig_file_basename(outcurrentdir ? Swig_file_filename(infile): Char(infile));
|
||||
String *infile_filename = outcurrentdir ? Swig_file_filename(infile): Copy(infile);
|
||||
String *basename = Swig_file_basename(infile_filename);
|
||||
if (!outfile_name) {
|
||||
if (CPlusPlus || lang->cplus_runtime_mode()) {
|
||||
Setattr(top, "outfile", NewStringf("%s_wrap.%s", basename, cpp_extension));
|
||||
|
|
@ -1226,19 +1240,21 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
} else {
|
||||
Setattr(top, "outfile_h", outfile_name_h);
|
||||
}
|
||||
configure_outdir(Swig_file_dirname(Getattr(top, "outfile")));
|
||||
configure_outdir(Getattr(top, "outfile"));
|
||||
if (Swig_contract_mode_get()) {
|
||||
Swig_contracts(top);
|
||||
}
|
||||
|
||||
// Check the suffix for a c/c++ file. If so, we're going to declare everything we see as "extern"
|
||||
ForceExtern = check_suffix(input_file);
|
||||
// Check the extension for a c/c++ file. If so, we're going to declare everything we see as "extern"
|
||||
ForceExtern = check_extension(input_file);
|
||||
|
||||
lang->top(top);
|
||||
|
||||
if (browse) {
|
||||
Swig_browser(top, 0);
|
||||
}
|
||||
Delete(infile_filename);
|
||||
Delete(basename);
|
||||
}
|
||||
}
|
||||
if (dump_lang_symbols) {
|
||||
|
|
@ -1275,7 +1291,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
int i;
|
||||
for (i = 0; i < Len(all_output_files); i++)
|
||||
Printf(f_outfiles, "%s\n", Getitem(all_output_files, i));
|
||||
Close(f_outfiles);
|
||||
Delete(f_outfiles);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Modula3 language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_modula3_cxx[] = "$Id$";
|
||||
|
||||
/*
|
||||
Text formatted with
|
||||
indent -sob -br -ce -nut -npsl
|
||||
|
|
@ -835,7 +833,7 @@ MODULA3():
|
|||
scanConstant(file, n);
|
||||
Printf(file, " return 0;\n");
|
||||
Printf(file, "}\n");
|
||||
Close(file);
|
||||
Delete(file);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -870,7 +868,7 @@ MODULA3():
|
|||
by SWIG with option -generaterename. */\n\
|
||||
\n", input_file);
|
||||
scanRename(file, n);
|
||||
Close(file);
|
||||
Delete(file);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -900,7 +898,7 @@ MODULA3():
|
|||
by SWIG with option -generatetypemap. */\n\
|
||||
\n", input_file);
|
||||
scanTypemap(file, n);
|
||||
Close(file);
|
||||
Delete(file);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -991,7 +989,7 @@ MODULA3():
|
|||
// Generate m3makefile
|
||||
// This will be unnecessary if SWIG is invoked from Quake.
|
||||
{
|
||||
File *file = openWriteFile(NewStringf("%sm3makefile", Swig_file_dirname(outfile)));
|
||||
File *file = openWriteFile(NewStringf("%sm3makefile", SWIG_output_directory()));
|
||||
|
||||
Printf(file, "%% automatically generated quake file for %s\n\n", name);
|
||||
|
||||
|
|
@ -1009,12 +1007,12 @@ MODULA3():
|
|||
} else {
|
||||
Printf(file, "library(\"m3%s\")\n", name);
|
||||
}
|
||||
Close(file);
|
||||
Delete(file);
|
||||
}
|
||||
|
||||
// Generate the raw interface
|
||||
{
|
||||
File *file = openWriteFile(NewStringf("%s%s.i3", Swig_file_dirname(outfile), m3raw_name));
|
||||
File *file = openWriteFile(NewStringf("%s%s.i3", SWIG_output_directory(), m3raw_name));
|
||||
|
||||
emitBanner(file);
|
||||
|
||||
|
|
@ -1027,12 +1025,12 @@ MODULA3():
|
|||
Printv(file, m3raw_intf.f, NIL);
|
||||
|
||||
Printf(file, "\nEND %s.\n", m3raw_name);
|
||||
Close(file);
|
||||
Delete(file);
|
||||
}
|
||||
|
||||
// Generate the raw module
|
||||
{
|
||||
File *file = openWriteFile(NewStringf("%s%s.m3", Swig_file_dirname(outfile), m3raw_name));
|
||||
File *file = openWriteFile(NewStringf("%s%s.m3", SWIG_output_directory(), m3raw_name));
|
||||
|
||||
emitBanner(file);
|
||||
|
||||
|
|
@ -1045,12 +1043,12 @@ MODULA3():
|
|||
Printv(file, m3raw_impl.f, NIL);
|
||||
|
||||
Printf(file, "BEGIN\nEND %s.\n", m3raw_name);
|
||||
Close(file);
|
||||
Delete(file);
|
||||
}
|
||||
|
||||
// Generate the interface for the comfort wrappers
|
||||
{
|
||||
File *file = openWriteFile(NewStringf("%s%s.i3", Swig_file_dirname(outfile), m3wrap_name));
|
||||
File *file = openWriteFile(NewStringf("%s%s.i3", SWIG_output_directory(), m3wrap_name));
|
||||
|
||||
emitBanner(file);
|
||||
|
||||
|
|
@ -1075,12 +1073,12 @@ MODULA3():
|
|||
|
||||
// Finish off the class
|
||||
Printf(file, "\nEND %s.\n", m3wrap_name);
|
||||
Close(file);
|
||||
Delete(file);
|
||||
}
|
||||
|
||||
// Generate the wrapper routines implemented in Modula 3
|
||||
{
|
||||
File *file = openWriteFile(NewStringf("%s%s.m3", Swig_file_dirname(outfile), m3wrap_name));
|
||||
File *file = openWriteFile(NewStringf("%s%s.m3", SWIG_output_directory(), m3wrap_name));
|
||||
|
||||
emitBanner(file);
|
||||
|
||||
|
|
@ -1096,7 +1094,7 @@ MODULA3():
|
|||
Printv(file, m3wrap_impl.f, NIL);
|
||||
|
||||
Printf(file, "\nBEGIN\nEND %s.\n", m3wrap_name);
|
||||
Close(file);
|
||||
Delete(file);
|
||||
}
|
||||
|
||||
if (upcasts_code)
|
||||
|
|
@ -1162,7 +1160,6 @@ MODULA3():
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
|
|
@ -1422,7 +1419,7 @@ MODULA3():
|
|||
|
||||
// below based on Swig_VargetToFunction()
|
||||
SwigType *ty = Swig_wrapped_var_type(Getattr(n, "type"), use_naturalvar_mode(n));
|
||||
Setattr(n, "wrap:action", NewStringf("result = (%s)(%s);", SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
Setattr(n, "wrap:action", NewStringf("%s = (%s)(%s);", Swig_cresult_name(), SwigType_lstr(ty, 0), Getattr(n, "value")));
|
||||
}
|
||||
|
||||
Setattr(n, "wrap:name", wname);
|
||||
|
|
@ -1437,9 +1434,9 @@ MODULA3():
|
|||
|
||||
/* Return value if necessary */
|
||||
String *tm;
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
addThrows(throws_hash, "out", n);
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Replaceall(tm, "$target", "cresult"); /* deprecated */
|
||||
Replaceall(tm, "$result", "cresult");
|
||||
Printf(f->code, "%s", tm);
|
||||
|
|
@ -1459,19 +1456,19 @@ MODULA3():
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
String *tm = Swig_typemap_lookup("newfree", n, "result", 0);
|
||||
String *tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0);
|
||||
if (tm != NIL) {
|
||||
addThrows(throws_hash, "newfree", n);
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if (!native_function_flag) {
|
||||
String *tm = Swig_typemap_lookup("ret", n, "result", 0);
|
||||
String *tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0);
|
||||
if (tm != NIL) {
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
|
@ -2030,7 +2027,7 @@ MODULA3():
|
|||
if (oldname != NIL) {
|
||||
Swig_warning(WARN_MODULA3_BAD_ENUMERATION, input_file, line_number, "The value <%s> is already assigned to <%s>.\n", value, oldname);
|
||||
}
|
||||
//printf("items %lx, set %s = %s\n", (long) items, Char(newvalue), Char(m3name));
|
||||
//printf("items %p, set %s = %s\n", items, Char(newvalue), Char(m3name));
|
||||
Setattr(items, newvalue, m3name);
|
||||
if (max < numvalue) {
|
||||
max = numvalue;
|
||||
|
|
@ -2097,7 +2094,7 @@ MODULA3():
|
|||
stem += Len(pat.prefix);
|
||||
}
|
||||
String *newname;
|
||||
if (Strcmp(srcstyle, "underscore") == 0) {
|
||||
if (srcstyle && Strcmp(srcstyle, "underscore") == 0) {
|
||||
if (newprefix != NIL) {
|
||||
String *newstem = nameToModula3(stem, true);
|
||||
newname = NewStringf("%s%s", newprefix, newstem);
|
||||
|
|
@ -2209,23 +2206,24 @@ MODULA3():
|
|||
String *c_baseclass = NULL;
|
||||
String *baseclass = NULL;
|
||||
String *c_baseclassname = NULL;
|
||||
String *classDeclarationName = Getattr(n, "classDeclaration:name");
|
||||
String *name = Getattr(n, "name");
|
||||
|
||||
/* Deal with inheritance */
|
||||
List *baselist = Getattr(n, "bases");
|
||||
if (baselist != NIL) {
|
||||
Iterator base = First(baselist);
|
||||
c_baseclassname = Getattr(base.item, "name");
|
||||
baseclass = Copy(getProxyName(c_baseclassname));
|
||||
if (baseclass) {
|
||||
c_baseclass = SwigType_namestr(Getattr(base.item, "name"));
|
||||
}
|
||||
base = Next(base);
|
||||
if (base.item != NIL) {
|
||||
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, Getattr(base.item, "name"));
|
||||
if (base.item) {
|
||||
c_baseclassname = Getattr(base.item, "name");
|
||||
baseclass = Copy(getProxyName(c_baseclassname));
|
||||
if (baseclass) {
|
||||
c_baseclass = SwigType_namestr(Getattr(base.item, "name"));
|
||||
}
|
||||
base = Next(base);
|
||||
if (base.item != NIL) {
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
|
||||
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
|
||||
name, Getattr(base.item, "name"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2234,23 +2232,22 @@ MODULA3():
|
|||
baseclass = NewString("");
|
||||
|
||||
// Inheritance from pure Modula 3 classes
|
||||
const String *pure_baseclass = typemapLookup(n, "m3base", classDeclarationName, WARN_NONE);
|
||||
const String *pure_baseclass = typemapLookup(n, "m3base", name, 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);
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
|
||||
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n", name, pure_baseclass);
|
||||
}
|
||||
// Pure Modula 3 interfaces
|
||||
const String *pure_interfaces = typemapLookup(n, derived ? "m3interfaces_derived" : "m3interfaces",
|
||||
classDeclarationName, WARN_NONE);
|
||||
name, WARN_NONE);
|
||||
|
||||
// Start writing the proxy class
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3imports", classDeclarationName, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup(n, "m3classmodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_CLASSMOD_UNDEF), // Class modifiers
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3imports", name, WARN_NONE), // Import statements
|
||||
"\n", typemapLookup(n, "m3classmodifiers", name, 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(n, "m3ptrconstructormodifiers", classDeclarationName, WARN_MODULA3_TYPEMAP_PTRCONSTMOD_UNDEF), // pointer constructor modifiers
|
||||
derived ? "" : " protected bool swigCMemOwn;\n", "\n", " ", typemapLookup(n, "m3ptrconstructormodifiers", name, 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"
|
||||
|
|
@ -2266,20 +2263,20 @@ MODULA3():
|
|||
Node *attributes = NewHash();
|
||||
String *destruct_methodname = NULL;
|
||||
if (derived) {
|
||||
tm = typemapLookup(n, "m3destruct_derived", classDeclarationName, WARN_NONE, attributes);
|
||||
tm = typemapLookup(n, "m3destruct_derived", name, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:m3destruct_derived:methodname");
|
||||
} else {
|
||||
tm = typemapLookup(n, "m3destruct", classDeclarationName, WARN_NONE, attributes);
|
||||
tm = typemapLookup(n, "m3destruct", name, WARN_NONE, attributes);
|
||||
destruct_methodname = Getattr(attributes, "tmap:m3destruct:methodname");
|
||||
}
|
||||
if (!destruct_methodname) {
|
||||
Swig_error(input_file, line_number, "No methodname attribute defined in m3destruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
|
||||
Swig_error(Getfile(n), Getline(n), "No methodname attribute defined in m3destruct%s typemap for %s\n", (derived ? "_derived" : ""), proxy_class_name);
|
||||
}
|
||||
// Emit the Finalize and Dispose methods
|
||||
if (tm) {
|
||||
// Finalize method
|
||||
if (*Char(destructor_call)) {
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3finalize", classDeclarationName, WARN_NONE), NIL);
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3finalize", name, WARN_NONE), NIL);
|
||||
}
|
||||
// Dispose method
|
||||
Printv(destruct, tm, NIL);
|
||||
|
|
@ -2294,8 +2291,8 @@ MODULA3():
|
|||
Delete(destruct);
|
||||
|
||||
// Emit various other methods
|
||||
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
|
||||
Printv(proxy_class_def, typemapLookup(n, "m3getcptr", name, WARN_MODULA3_TYPEMAP_GETCPTR_UNDEF), // getCPtr method
|
||||
typemapLookup(n, "m3code", name, WARN_NONE), // extra Modula 3 code
|
||||
"\n", NIL);
|
||||
|
||||
// Substitute various strings into the above template
|
||||
|
|
@ -2390,7 +2387,7 @@ MODULA3():
|
|||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), proxy_class_name);
|
||||
String *filen = NewStringf("%s%s.m3", SWIG_output_directory(), proxy_class_name);
|
||||
f_proxy = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_proxy) {
|
||||
FileErrorDisplay(filen);
|
||||
|
|
@ -2463,13 +2460,14 @@ MODULA3():
|
|||
/* Look for the first (principal?) base class -
|
||||
Modula 3 does not support multiple inheritance */
|
||||
Iterator base = First(baselist);
|
||||
Append(baseclassname, Getattr(base.item, "sym:name"));
|
||||
base = Next(base);
|
||||
if (base.item != NIL) {
|
||||
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",
|
||||
proxy_class_name, Getattr(base.item, "name"));
|
||||
if (base.item) {
|
||||
Append(baseclassname, Getattr(base.item, "sym:name"));
|
||||
base = Next(base);
|
||||
if (base.item) {
|
||||
Swig_warning(WARN_MODULA3_MULTIPLE_INHERITANCE, Getfile(n), Getline(n),
|
||||
"Warning for %s proxy: Base %s ignored. Multiple inheritance is not supported in Modula 3.\n",
|
||||
proxy_class_name, Getattr(base.item, "name"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2558,7 +2556,7 @@ MODULA3():
|
|||
Printv(f_proxy, proxy_class_def, proxy_class_code, NIL);
|
||||
|
||||
Printf(f_proxy, "}\n");
|
||||
Close(f_proxy);
|
||||
Delete(f_proxy);
|
||||
f_proxy = NULL;
|
||||
|
||||
Delete(proxy_class_name);
|
||||
|
|
@ -3200,7 +3198,7 @@ MODULA3():
|
|||
writeArg(return_variables, state, NIL, NIL, NIL, NIL);
|
||||
|
||||
if (multiretval) {
|
||||
Printv(result_name, "result", NIL);
|
||||
Printv(result_name, Swig_cresult_name(), NIL);
|
||||
Printf(result_m3wraptype, "%sResult", func_name);
|
||||
m3wrap_intf.enterBlock(blocktype);
|
||||
Printf(m3wrap_intf.f, "%s =\nRECORD\n%sEND;\n", result_m3wraptype, return_variables);
|
||||
|
|
@ -3458,7 +3456,7 @@ MODULA3():
|
|||
if ((hasContent(outcheck) || hasContent(storeout)
|
||||
|| hasContent(cleanup)) && (!hasContent(result_name))
|
||||
&& (return_raw == NIL)) {
|
||||
Printv(result_name, "result", NIL);
|
||||
Printv(result_name, Swig_cresult_name(), NIL);
|
||||
Printf(local_variables, "%s: %s;\n", result_name, result_m3wraptype);
|
||||
}
|
||||
|
||||
|
|
@ -3531,6 +3529,7 @@ MODULA3():
|
|||
|
||||
m3wrap_impl.enterBlock(no_block);
|
||||
if (proxy_flag && global_variable_flag) {
|
||||
setter_flag = (Cmp(Getattr(n, "sym:name"), Swig_name_set(NSPACE_TODO, variable_name)) == 0);
|
||||
// Properties
|
||||
if (setter_flag) {
|
||||
// Setter method
|
||||
|
|
@ -3784,7 +3783,7 @@ MODULA3():
|
|||
Setfile(n, input_file);
|
||||
Setline(n, line_number);
|
||||
|
||||
String *filen = NewStringf("%s%s.m3", Swig_file_dirname(outfile), classname);
|
||||
String *filen = NewStringf("%s%s.m3", SWIG_output_directory(), classname);
|
||||
File *f_swigtype = NewFile(filen, "w", SWIG_output_files());
|
||||
if (!f_swigtype) {
|
||||
FileErrorDisplay(filen);
|
||||
|
|
@ -3814,7 +3813,7 @@ MODULA3():
|
|||
Replaceall(swigtype, "$m3classname", classname);
|
||||
Printv(f_swigtype, swigtype, NIL);
|
||||
|
||||
Close(f_swigtype);
|
||||
Delete(f_swigtype);
|
||||
Delete(filen);
|
||||
Delete(swigtype);
|
||||
}
|
||||
|
|
@ -3978,10 +3977,10 @@ extern "C" Language *swig_modula3(void) {
|
|||
|
||||
const char *MODULA3::usage = (char *) "\
|
||||
Modula 3 Options (available with -modula3)\n\
|
||||
-generateconst <file> - generate code for computing numeric values of constants\n\
|
||||
-generaterename <file> - generate suggestions for %rename\n\
|
||||
-generatetypemap <file> - generate templates for some basic typemaps\n\
|
||||
-oldvarnames - old intermediary method names for variable wrappers\n\
|
||||
-generateconst <file> - Generate code for computing numeric values of constants\n\
|
||||
-generaterename <file> - Generate suggestions for %rename\n\
|
||||
-generatetypemap <file> - Generate templates for some basic typemaps\n\
|
||||
-oldvarnames - Old intermediary method names for variable wrappers\n\
|
||||
\n";
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* This file is responsible for the module system.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_module_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
struct Module {
|
||||
|
|
|
|||
|
|
@ -11,20 +11,18 @@
|
|||
* Mzscheme language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_mzscheme_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
Mzscheme Options (available with -mzscheme)\n\
|
||||
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
|
||||
-declaremodule - Create extension that declares a module\n\
|
||||
-noinit - Do not emit scheme_initialize, scheme_reload,\n\
|
||||
scheme_module_name functions\n\
|
||||
-dynamic-load <library>,[library,...] - Do not link with these libraries, dynamic load\n\
|
||||
them\n\
|
||||
-noinit - Do not emit scheme_initialize, scheme_reload,\n\
|
||||
scheme_module_name functions\n\
|
||||
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
|
||||
";
|
||||
|
||||
static String *fieldnames_tab = 0;
|
||||
|
|
@ -33,12 +31,10 @@ static String *convert_proto_tab = 0;
|
|||
static String *struct_name = 0;
|
||||
static String *mangled_struct_name = 0;
|
||||
|
||||
static char *prefix = 0;
|
||||
static String *prefix = 0;
|
||||
static bool declaremodule = false;
|
||||
static bool noinit = false;
|
||||
//DLOPEN PATCH
|
||||
static char *load_libraries = NULL;
|
||||
//DLOPEN PATCH
|
||||
static String *load_libraries = NULL;
|
||||
static String *module = 0;
|
||||
static char *mzscheme_path = (char *) "mzscheme";
|
||||
static String *init_func_def = 0;
|
||||
|
|
@ -75,8 +71,7 @@ public:
|
|||
SWIG_exit(0);
|
||||
} else if (strcmp(argv[i], "-prefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
prefix = new char[strlen(argv[i + 1]) + 2];
|
||||
strcpy(prefix, argv[i + 1]);
|
||||
prefix = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -90,26 +85,26 @@ public:
|
|||
noinit = true;
|
||||
Swig_mark_arg(i);
|
||||
}
|
||||
// DLOPEN PATCH
|
||||
else if (strcmp(argv[i], "-dynamic-load") == 0) {
|
||||
load_libraries = new char[strlen(argv[i + 1]) + 2];
|
||||
strcpy(load_libraries, argv[i + 1]);
|
||||
Swig_mark_arg(i++);
|
||||
Swig_mark_arg(i);
|
||||
if (argv[i + 1]) {
|
||||
Delete(load_libraries);
|
||||
load_libraries = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i++);
|
||||
Swig_mark_arg(i);
|
||||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
}
|
||||
// DLOPEN PATCH
|
||||
}
|
||||
}
|
||||
|
||||
// If a prefix has been specified make sure it ends in a '_'
|
||||
|
||||
// If a prefix has been specified make sure it ends in a '_' (not actually used!)
|
||||
if (prefix) {
|
||||
if (prefix[strlen(prefix)] != '_') {
|
||||
prefix[strlen(prefix) + 1] = 0;
|
||||
prefix[strlen(prefix)] = '_';
|
||||
}
|
||||
const char *px = Char(prefix);
|
||||
if (px[Len(prefix) - 1] != '_')
|
||||
Printf(prefix, "_");
|
||||
} else
|
||||
prefix = (char *) "swig_";
|
||||
prefix = NewString("swig_");
|
||||
|
||||
// Add a symbol for this module
|
||||
|
||||
|
|
@ -177,11 +172,9 @@ public:
|
|||
Printf(f_init, "\treturn scheme_void;\n}\n");
|
||||
Printf(f_init, "Scheme_Object *scheme_initialize(Scheme_Env *env) {\n");
|
||||
|
||||
// DLOPEN PATCH
|
||||
if (load_libraries) {
|
||||
Printf(f_init, "mz_set_dlopen_libraries(\"%s\");\n", load_libraries);
|
||||
}
|
||||
// DLOPEN PATCH
|
||||
|
||||
Printf(f_init, "\treturn scheme_reload(env);\n");
|
||||
Printf(f_init, "}\n");
|
||||
|
|
@ -203,7 +196,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
|
|
@ -240,20 +232,17 @@ public:
|
|||
String *outarg = NewString("");
|
||||
String *build = NewString("");
|
||||
String *tm;
|
||||
int argout_set = 0;
|
||||
int i = 0;
|
||||
int numargs;
|
||||
int numreq;
|
||||
String *overname = 0;
|
||||
|
||||
// PATCH DLOPEN
|
||||
if (load_libraries) {
|
||||
ParmList *parms = Getattr(n, "parms");
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *name = NewString("caller");
|
||||
Setattr(n, "wrap:action", Swig_cresult(type, "result", Swig_cfunction_call(name, parms)));
|
||||
Setattr(n, "wrap:action", Swig_cresult(type, Swig_cresult_name(), Swig_cfunction_call(name, parms)));
|
||||
}
|
||||
// PATCH DLOPEN
|
||||
|
||||
// Make a wrapper name for this
|
||||
String *wname = Swig_name_wrapper(iname);
|
||||
|
|
@ -293,7 +282,6 @@ public:
|
|||
numargs = emit_num_arguments(l);
|
||||
numreq = emit_num_required(l);
|
||||
|
||||
// DLOPEN PATCH
|
||||
/* Add the holder for the pointer to the function to be opened */
|
||||
if (load_libraries) {
|
||||
Wrapper_add_local(f, "_function_loaded", "static int _function_loaded=(1==0)");
|
||||
|
|
@ -304,19 +292,16 @@ public:
|
|||
Wrapper_add_local(f, "caller", SwigType_lstr(d, func)); /*"(*caller)()")); */
|
||||
}
|
||||
}
|
||||
// DLOPEN PATCH
|
||||
|
||||
// adds local variables
|
||||
Wrapper_add_local(f, "lenv", "int lenv = 1");
|
||||
Wrapper_add_local(f, "values", "Scheme_Object *values[MAXVALUES]");
|
||||
|
||||
// DLOPEN PATCH
|
||||
if (load_libraries) {
|
||||
Printf(f->code, "if (!_function_loaded) { _the_function=mz_load_function(\"%s\");_function_loaded=(1==1); }\n", iname);
|
||||
Printf(f->code, "if (!_the_function) { scheme_signal_error(\"Cannot load C function '%s'\"); }\n", iname);
|
||||
Printf(f->code, "caller=_the_function;\n");
|
||||
}
|
||||
// DLOPEN PATCH
|
||||
|
||||
// Now write code to extract the parameters (this is super ugly)
|
||||
|
||||
|
|
@ -381,7 +366,6 @@ public:
|
|||
Replaceall(tm, "$input", Getattr(p, "emit:input"));
|
||||
Printv(outarg, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:argout:next");
|
||||
argout_set = 1;
|
||||
} else {
|
||||
p = nextSibling(p);
|
||||
}
|
||||
|
|
@ -405,8 +389,8 @@ public:
|
|||
String *actioncode = emit_action(n);
|
||||
|
||||
// Now have return value, figure out what to do with it.
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "values[0]");
|
||||
Replaceall(tm, "$result", "values[0]");
|
||||
if (GetFlag(n, "feature:new"))
|
||||
|
|
@ -428,15 +412,15 @@ public:
|
|||
// Look for any remaining cleanup
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
}
|
||||
// Free any memory allocated by the function being wrapped..
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
// Wrap things up (in a manner of speaking)
|
||||
|
|
@ -639,9 +623,10 @@ public:
|
|||
// Create variable and assign it a value
|
||||
|
||||
Printf(f_header, "static %s = ", SwigType_lstr(type, var_name));
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
if ((SwigType_type(type) == T_STRING)) {
|
||||
Printf(f_header, "\"%s\";\n", value);
|
||||
} else if (SwigType_type(type) == T_CHAR) {
|
||||
} else if (SwigType_type(type) == T_CHAR && !is_enum_item) {
|
||||
Printf(f_header, "\'%s\';\n", value);
|
||||
} else {
|
||||
Printf(f_header, "%s;\n", value);
|
||||
|
|
@ -682,7 +667,7 @@ public:
|
|||
String *mangled_classname = 0;
|
||||
String *real_classname = 0;
|
||||
String *scm_structname = NewString("");
|
||||
SwigType *ctype_ptr = NewStringf("p.%s", Getattr(n, "classtype"));
|
||||
SwigType *ctype_ptr = NewStringf("p.%s", getClassType());
|
||||
|
||||
SwigType *t = NewStringf("p.%s", Getattr(n, "name"));
|
||||
swigtype_ptr = SwigType_manglestr(t);
|
||||
|
|
|
|||
|
|
@ -11,31 +11,31 @@
|
|||
* Ocaml language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_ocaml_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
static const char *usage = (char *)
|
||||
("Ocaml Options (available with -ocaml)\n"
|
||||
"-prefix <name> - Set a prefix <name> to be prepended to all names\n"
|
||||
"-where - Emit library location\n"
|
||||
"-suffix <name> - Change .cxx to something else\n" "-oldvarnames - old intermediary method names for variable wrappers\n" "\n");
|
||||
static const char *usage = (char *) "\
|
||||
Ocaml Options (available with -ocaml)\n\
|
||||
-oldvarnames - Old intermediary method names for variable wrappers\n\
|
||||
-prefix <name> - Set a prefix <name> to be prepended to all names\n\
|
||||
-suffix <name> - Change .cxx to something else\n\
|
||||
-where - Emit library location\n\
|
||||
\n";
|
||||
|
||||
static int classmode = 0;
|
||||
static int in_constructor = 0, in_destructor = 0, in_copyconst = 0;
|
||||
static int const_enum = 0;
|
||||
static int static_member_function = 0;
|
||||
static int generate_sizeof = 0;
|
||||
static char *prefix = 0;
|
||||
static String *prefix = 0;
|
||||
static char *ocaml_path = (char *) "ocaml";
|
||||
static bool old_variable_names = false;
|
||||
static String *classname = 0;
|
||||
static String *module = 0;
|
||||
static String *init_func_def = 0;
|
||||
static String *f_classtemplate = 0;
|
||||
static String *name_qualifier = 0;
|
||||
static SwigType *name_qualifier_type = 0;
|
||||
|
||||
static Hash *seen_enums = 0;
|
||||
static Hash *seen_enumvalues = 0;
|
||||
|
|
@ -105,8 +105,7 @@ public:
|
|||
SWIG_exit(0);
|
||||
} else if (strcmp(argv[i], "-prefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
prefix = new char[strlen(argv[i + 1]) + 2];
|
||||
strcpy(prefix, argv[i + 1]);
|
||||
prefix = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
|
|
@ -128,15 +127,13 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
// If a prefix has been specified make sure it ends in a '_'
|
||||
|
||||
// If a prefix has been specified make sure it ends in a '_' (not actually used!)
|
||||
if (prefix) {
|
||||
if (prefix[strlen(prefix)] != '_') {
|
||||
prefix[strlen(prefix) + 1] = 0;
|
||||
prefix[strlen(prefix)] = '_';
|
||||
}
|
||||
const char *px = Char(prefix);
|
||||
if (px[Len(prefix) - 1] != '_')
|
||||
Printf(prefix, "_");
|
||||
} else
|
||||
prefix = (char *) "swig_";
|
||||
prefix = NewString("swig_");
|
||||
|
||||
// Add a symbol for this module
|
||||
|
||||
|
|
@ -341,7 +338,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -355,14 +351,12 @@ public:
|
|||
Dump(f_class_ctors, f_mlout);
|
||||
Dump(f_class_ctors_end, f_mlout);
|
||||
Dump(f_mltail, f_mlout);
|
||||
Close(f_mlout);
|
||||
Delete(f_mlout);
|
||||
|
||||
Dump(f_enumtypes_type, f_mliout);
|
||||
Dump(f_enumtypes_value, f_mliout);
|
||||
Dump(f_mlibody, f_mliout);
|
||||
Dump(f_mlitail, f_mliout);
|
||||
Close(f_mliout);
|
||||
Delete(f_mliout);
|
||||
|
||||
return SWIG_OK;
|
||||
|
|
@ -443,7 +437,6 @@ public:
|
|||
String *outarg = NewString("");
|
||||
String *build = NewString("");
|
||||
String *tm;
|
||||
int argout_set = 0;
|
||||
int i = 0;
|
||||
int numargs;
|
||||
int numreq;
|
||||
|
|
@ -606,7 +599,6 @@ public:
|
|||
Replaceall(tm, "$ntype", normalizeTemplatedClassName(Getattr(p, "type")));
|
||||
Printv(outarg, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:argout:next");
|
||||
argout_set = 1;
|
||||
} else {
|
||||
p = nextSibling(p);
|
||||
}
|
||||
|
|
@ -657,7 +649,7 @@ public:
|
|||
Swig_director_emit_dynamic_cast(n, f);
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", "swig_result");
|
||||
Replaceall(tm, "$target", "rv");
|
||||
Replaceall(tm, "$result", "rv");
|
||||
|
|
@ -677,15 +669,15 @@ public:
|
|||
// Look for any remaining cleanup
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", "swig_result");
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
}
|
||||
// Free any memory allocated by the function being wrapped..
|
||||
|
||||
if ((tm = Swig_typemap_lookup("swig_result", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("swig_result", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printv(f->code, tm, "\n", NIL);
|
||||
}
|
||||
// Wrap things up (in a manner of speaking)
|
||||
|
|
@ -879,9 +871,8 @@ public:
|
|||
* ------------------------------------------------------------ */
|
||||
|
||||
virtual int staticmemberfunctionHandler(Node *n) {
|
||||
int rv;
|
||||
static_member_function = 1;
|
||||
rv = Language::staticmemberfunctionHandler(n);
|
||||
Language::staticmemberfunctionHandler(n);
|
||||
static_member_function = 0;
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -898,12 +889,12 @@ public:
|
|||
String *name = Getattr(n, "feature:symname");
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *value = Getattr(n, "value");
|
||||
String *qvalue = Getattr(n, "qualified:value");
|
||||
SwigType *qname = Getattr(n, "qualified:name");
|
||||
String *rvalue = NewString("");
|
||||
String *temp = 0;
|
||||
|
||||
if (qvalue)
|
||||
value = qvalue;
|
||||
if (qname)
|
||||
value = qname;
|
||||
|
||||
if (!name) {
|
||||
name = mangleNameForCaml(Getattr(n, "name"));
|
||||
|
|
@ -928,9 +919,10 @@ public:
|
|||
// Create variable and assign it a value
|
||||
|
||||
Printf(f_header, "static %s = ", SwigType_lstr(type, name));
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
if ((SwigType_type(type) == T_STRING)) {
|
||||
Printf(f_header, "\"%s\";\n", value);
|
||||
} else if (SwigType_type(type) == T_CHAR) {
|
||||
} else if (SwigType_type(type) == T_CHAR && !is_enum_item) {
|
||||
Printf(f_header, "\'%s\';\n", value);
|
||||
} else {
|
||||
Printf(f_header, "%s;\n", value);
|
||||
|
|
@ -1228,20 +1220,18 @@ public:
|
|||
return out;
|
||||
}
|
||||
|
||||
String *fully_qualify_enum_name(Node *n, String *name) {
|
||||
SwigType *fully_qualified_enum_type(Node *n) {
|
||||
Node *parent = 0;
|
||||
String *qualification = NewString("");
|
||||
String *fully_qualified_name = NewString("");
|
||||
String *parent_type = 0;
|
||||
String *normalized_name;
|
||||
|
||||
parent = parentNode(n);
|
||||
while (parent) {
|
||||
parent_type = nodeType(parent);
|
||||
if (Getattr(parent, "name")) {
|
||||
String *parent_copy = NewStringf("%s::", Getattr(parent, "name"));
|
||||
if (!Cmp(parent_type, "class") || !Cmp(parent_type, "namespace"))
|
||||
Insert(qualification, 0, parent_copy);
|
||||
if (Cmp(parent_type, "class") == 0 || Cmp(parent_type, "namespace") == 0)
|
||||
Insert(fully_qualified_name, 0, parent_copy);
|
||||
Delete(parent_copy);
|
||||
}
|
||||
if (!Cmp(parent_type, "class"))
|
||||
|
|
@ -1249,36 +1239,28 @@ public:
|
|||
parent = parentNode(parent);
|
||||
}
|
||||
|
||||
Printf(fully_qualified_name, "%s%s", qualification, name);
|
||||
|
||||
normalized_name = normalizeTemplatedClassName(fully_qualified_name);
|
||||
if (!strncmp(Char(normalized_name), "enum ", 5)) {
|
||||
Insert(normalized_name, 5, qualification);
|
||||
}
|
||||
|
||||
return normalized_name;
|
||||
return fully_qualified_name;
|
||||
}
|
||||
|
||||
/* Benedikt Grundmann inspired --> Enum wrap styles */
|
||||
|
||||
int enumvalueDeclaration(Node *n) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *qvalue = 0;
|
||||
SwigType *qtype = 0;
|
||||
|
||||
if (name_qualifier) {
|
||||
qvalue = Copy(name_qualifier);
|
||||
Printv(qvalue, name, NIL);
|
||||
if (name_qualifier_type) {
|
||||
qtype = Copy(name_qualifier_type);
|
||||
Printv(qtype, name, NIL);
|
||||
}
|
||||
|
||||
if (const_enum && name && !Getattr(seen_enumvalues, name)) {
|
||||
if (const_enum && qtype && name && !Getattr(seen_enumvalues, name)) {
|
||||
Setattr(seen_enumvalues, name, "true");
|
||||
SetFlag(n, "feature:immutable");
|
||||
Setattr(n, "feature:enumvalue", "1"); // this does not appear to be used
|
||||
|
||||
if (qvalue)
|
||||
Setattr(n, "qualified:value", qvalue);
|
||||
Setattr(n, "qualified:name", SwigType_namestr(qtype));
|
||||
|
||||
String *evname = SwigType_manglestr(qvalue);
|
||||
String *evname = SwigType_manglestr(qtype);
|
||||
Insert(evname, 0, "SWIG_ENUM_");
|
||||
|
||||
Setattr(n, "feature:enumvname", name);
|
||||
|
|
@ -1309,10 +1291,10 @@ public:
|
|||
/* name is now fully qualified */
|
||||
String *fully_qualified_name = NewString(name);
|
||||
bool seen_enum = false;
|
||||
if (name_qualifier)
|
||||
Delete(name_qualifier);
|
||||
if (name_qualifier_type)
|
||||
Delete(name_qualifier_type);
|
||||
char *strip_position;
|
||||
name_qualifier = fully_qualify_enum_name(n, NewString(""));
|
||||
name_qualifier_type = fully_qualified_enum_type(n);
|
||||
|
||||
strip_position = strstr(Char(oname), "::");
|
||||
|
||||
|
|
@ -1389,62 +1371,41 @@ public:
|
|||
int classDirectorMethod(Node *n, Node *parent, String *super) {
|
||||
int is_void = 0;
|
||||
int is_pointer = 0;
|
||||
String *storage;
|
||||
String *value;
|
||||
String *decl;
|
||||
String *type;
|
||||
String *name;
|
||||
String *classname;
|
||||
String *storage = Getattr(n, "storage");
|
||||
String *value = Getattr(n, "value");
|
||||
String *decl = Getattr(n, "decl");
|
||||
String *returntype = Getattr(n, "type");
|
||||
String *name = Getattr(n, "name");
|
||||
String *classname = Getattr(parent, "sym:name");
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration = NewString("");
|
||||
ParmList *l = Getattr(n, "parms");
|
||||
Wrapper *w = NewWrapper();
|
||||
String *tm;
|
||||
String *wrap_args = NewString("");
|
||||
String *return_type;
|
||||
int status = SWIG_OK;
|
||||
int idx;
|
||||
bool pure_virtual = false;
|
||||
bool ignored_method = GetFlag(n, "feature:ignore") ? true : false;
|
||||
|
||||
storage = Getattr(n, "storage");
|
||||
value = Getattr(n, "value");
|
||||
classname = Getattr(parent, "sym:name");
|
||||
type = Getattr(n, "type");
|
||||
name = Getattr(n, "name");
|
||||
|
||||
if (Cmp(storage, "virtual") == 0) {
|
||||
if (Cmp(value, "0") == 0) {
|
||||
pure_virtual = true;
|
||||
}
|
||||
}
|
||||
|
||||
w = NewWrapper();
|
||||
declaration = NewString("");
|
||||
Wrapper_add_local(w, "swig_result", "CAMLparam0();\n" "SWIG_CAMLlocal2(swig_result,args)");
|
||||
|
||||
/* determine if the method returns a pointer */
|
||||
decl = Getattr(n, "decl");
|
||||
is_pointer = SwigType_ispointer_return(decl);
|
||||
is_void = (!Cmp(type, "void") && !is_pointer);
|
||||
|
||||
/* form complete return type */
|
||||
return_type = Copy(type);
|
||||
{
|
||||
SwigType *t = Copy(decl);
|
||||
SwigType *f = 0;
|
||||
f = SwigType_pop_function(t);
|
||||
SwigType_push(return_type, t);
|
||||
Delete(f);
|
||||
Delete(t);
|
||||
}
|
||||
is_void = (!Cmp(returntype, "void") && !is_pointer);
|
||||
|
||||
/* virtual method definition */
|
||||
l = Getattr(n, "parms");
|
||||
String *target;
|
||||
String *pclassname = NewStringf("SwigDirector_%s", classname);
|
||||
String *qualified_name = NewStringf("%s::%s", pclassname, name);
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type;
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
|
||||
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
|
||||
Printf(w->def, "%s {", target);
|
||||
Delete(qualified_name);
|
||||
|
|
@ -1460,7 +1421,7 @@ public:
|
|||
*/
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(return_type, "c_result"), NIL);
|
||||
Wrapper_add_localv(w, "c_result", SwigType_lstr(returntype, "c_result"), NIL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1479,6 +1440,8 @@ public:
|
|||
/* attach typemaps to arguments (C/C++ -> Ocaml) */
|
||||
String *arglist = NewString("");
|
||||
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
Swig_typemap_attach_parms("in", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
Swig_typemap_attach_parms("directorargout", l, w);
|
||||
|
|
@ -1507,6 +1470,7 @@ public:
|
|||
|
||||
Putc(',', arglist);
|
||||
if ((tm = Getattr(p, "tmap:directorin")) != 0) {
|
||||
Setattr(p, "emit:directorinput", pname);
|
||||
Replaceall(tm, "$input", pname);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
if (Len(tm) == 0)
|
||||
|
|
@ -1594,12 +1558,12 @@ public:
|
|||
"swig_result = caml_swig_alloc(1,C_list);\n" "SWIG_Store_field(swig_result,0,args);\n" "args = swig_result;\n" "swig_result = Val_unit;\n", 0);
|
||||
Printf(w->code, "swig_result = " "callback3(*caml_named_value(\"swig_runmethod\")," "swig_get_self(),copy_string(\"%s\"),args);\n", Getattr(n, "name"));
|
||||
/* exception handling */
|
||||
tm = Swig_typemap_lookup("director:except", n, "result", 0);
|
||||
tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0);
|
||||
if (!tm) {
|
||||
tm = Getattr(n, "feature:director:except");
|
||||
}
|
||||
if ((tm) && Len(tm) && (Strcmp(tm, "1") != 0)) {
|
||||
Printf(w->code, "if (!result) {\n");
|
||||
Printf(w->code, "if (!%s) {\n", Swig_cresult_name());
|
||||
Printf(w->code, " CAML_VALUE error = *caml_named_value(\"director_except\");\n");
|
||||
Replaceall(tm, "$error", "error");
|
||||
Printv(w->code, Str(tm), "\n", NIL);
|
||||
|
|
@ -1621,16 +1585,7 @@ public:
|
|||
|
||||
idx = 0;
|
||||
|
||||
/* this seems really silly. the node's type excludes
|
||||
* qualifier/pointer/reference markers, which have to be retrieved
|
||||
* from the decl field to construct return_type. but the typemap
|
||||
* lookup routine uses the node's type, so we have to swap in and
|
||||
* out the correct type. it's not just me, similar silliness also
|
||||
* occurs in Language::cDeclaration().
|
||||
*/
|
||||
Setattr(n, "type", return_type);
|
||||
tm = Swig_typemap_lookup("directorout", n, "c_result", w);
|
||||
Setattr(n, "type", type);
|
||||
if (tm != 0) {
|
||||
Replaceall(tm, "$input", "swig_result");
|
||||
/* TODO check this */
|
||||
|
|
@ -1646,8 +1601,8 @@ public:
|
|||
/* marshal outputs */
|
||||
for (p = l; p;) {
|
||||
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
|
||||
Replaceall(tm, "$input", "swig_result");
|
||||
Replaceall(tm, "$result", Getattr(p, "name"));
|
||||
Replaceall(tm, "$result", "swig_result");
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
|
|
@ -1665,15 +1620,15 @@ public:
|
|||
if (!(ignored_method && !pure_virtual)) {
|
||||
/* A little explanation:
|
||||
* The director_enum test case makes a method whose return type
|
||||
* is an enum type. return_type here is "int". gcc complains
|
||||
* is an enum type. returntype here is "int". gcc complains
|
||||
* about an implicit enum conversion, and although i don't strictly
|
||||
* agree with it, I'm working on fixing the error:
|
||||
*
|
||||
* Below is what I came up with. It's not great but it should
|
||||
* always essentially work.
|
||||
*/
|
||||
if (!SwigType_isreference(return_type)) {
|
||||
Printf(w->code, "CAMLreturn_type((%s)c_result);\n", SwigType_lstr(return_type, ""));
|
||||
if (!SwigType_isreference(returntype)) {
|
||||
Printf(w->code, "CAMLreturn_type((%s)c_result);\n", SwigType_lstr(returntype, ""));
|
||||
} else {
|
||||
Printf(w->code, "CAMLreturn_type(*c_result);\n");
|
||||
}
|
||||
|
|
@ -1700,6 +1655,7 @@ public:
|
|||
/* emit the director method */
|
||||
if (status == SWIG_OK) {
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
|
|
@ -1708,7 +1664,6 @@ public:
|
|||
|
||||
/* clean up */
|
||||
Delete(wrap_args);
|
||||
Delete(return_type);
|
||||
Delete(pclassname);
|
||||
DelWrapper(w);
|
||||
return status;
|
||||
|
|
|
|||
|
|
@ -11,14 +11,17 @@
|
|||
* Octave language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_octave_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
static String *global_name = 0;
|
||||
static String *op_prefix = 0;
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
Octave Options (available with -octave)\n\
|
||||
[no additional options]\n\
|
||||
\n";
|
||||
-globals <name> - Set <name> used to access C global variables [default: 'cvar']\n\
|
||||
Use '.' to load C global variables into module namespace\n\
|
||||
-opprefix <str> - Prefix <str> for global operator functions [default: 'op_']\n\
|
||||
\n";
|
||||
|
||||
|
||||
class OCTAVE:public Language {
|
||||
|
|
@ -42,10 +45,35 @@ private:
|
|||
|
||||
Hash *docs;
|
||||
|
||||
void Octave_begin_function(Node *n, File *f, const_String_or_char_ptr cname, const_String_or_char_ptr wname, bool dld) {
|
||||
if (dld) {
|
||||
String *tname = texinfo_name(n, "std::string()");
|
||||
Printf(f, "SWIG_DEFUN( %s, %s, %s ) {", cname, wname, tname);
|
||||
}
|
||||
else {
|
||||
Printf(f, "static octave_value_list %s (const octave_value_list& args, int nargout) {", wname);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
OCTAVE():f_begin(0), f_runtime(0), f_header(0), f_doc(0), f_wrappers(0),
|
||||
f_init(0), f_initbeforefunc(0), f_directors(0), f_directors_h(0),
|
||||
s_global_tab(0), s_members_tab(0), class_name(0) {
|
||||
OCTAVE():
|
||||
f_begin(0),
|
||||
f_runtime(0),
|
||||
f_header(0),
|
||||
f_doc(0),
|
||||
f_wrappers(0),
|
||||
f_init(0),
|
||||
f_initbeforefunc(0),
|
||||
f_directors(0),
|
||||
f_directors_h(0),
|
||||
s_global_tab(0),
|
||||
s_members_tab(0),
|
||||
class_name(0),
|
||||
have_constructor(0),
|
||||
have_destructor(0),
|
||||
constructor_name(0),
|
||||
docs(0)
|
||||
{
|
||||
/* Add code to manage protected constructors and directors */
|
||||
director_prot_ctor_code = NewString("");
|
||||
Printv(director_prot_ctor_code,
|
||||
|
|
@ -64,11 +92,41 @@ public:
|
|||
for (int i = 1; i < argc; i++) {
|
||||
if (argv[i]) {
|
||||
if (strcmp(argv[i], "-help") == 0) {
|
||||
fputs(usage, stderr);
|
||||
}
|
||||
fputs(usage, stdout);
|
||||
} else if (strcmp(argv[i], "-global") == 0 ||
|
||||
strcmp(argv[i], "-noglobal") == 0) {
|
||||
Printv(stderr,
|
||||
"*** -global/-noglobal are no longer supported\n"
|
||||
"*** global load behaviour is now determined at module load\n"
|
||||
"*** see the Perl section in the manual for details.\n", NIL);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
} else if (strcmp(argv[i], "-globals") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
global_name = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
} else if (strcmp(argv[i], "-opprefix") == 0) {
|
||||
if (argv[i + 1]) {
|
||||
op_prefix = NewString(argv[i + 1]);
|
||||
Swig_mark_arg(i);
|
||||
Swig_mark_arg(i + 1);
|
||||
i++;
|
||||
} else {
|
||||
Swig_arg_error();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!global_name)
|
||||
global_name = NewString("cvar");
|
||||
if (!op_prefix)
|
||||
op_prefix = NewString("op_");
|
||||
|
||||
SWIG_library_directory("octave");
|
||||
Preprocessor_define("SWIGOCTAVE 1", 0);
|
||||
SWIG_config_file("octave.swg");
|
||||
|
|
@ -131,6 +189,10 @@ public:
|
|||
Printf(f_runtime, "#define SWIG_name_d \"%s\"\n", module);
|
||||
Printf(f_runtime, "#define SWIG_name %s\n", module);
|
||||
|
||||
Printf(f_runtime, "\n");
|
||||
Printf(f_runtime, "#define SWIG_global_name \"%s\"\n", global_name);
|
||||
Printf(f_runtime, "#define SWIG_op_prefix \"%s\"\n", op_prefix);
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
|
||||
Swig_banner(f_directors_h);
|
||||
|
|
@ -143,7 +205,7 @@ public:
|
|||
Printf(f_runtime, "\n");
|
||||
|
||||
Printf(s_global_tab, "\nstatic const struct swig_octave_member swig_globals[] = {\n");
|
||||
Printf(f_init, "static void SWIG_init_user(octave_swig_type* module_ns)\n{\n");
|
||||
Printf(f_init, "static bool SWIG_init_user(octave_swig_type* module_ns)\n{\n");
|
||||
|
||||
if (!CPlusPlus)
|
||||
Printf(f_header,"extern \"C\" {\n");
|
||||
|
|
@ -159,7 +221,7 @@ public:
|
|||
if (directorsEnabled())
|
||||
Swig_insert_file("director.swg", f_runtime);
|
||||
|
||||
Printf(f_init, "}\n");
|
||||
Printf(f_init, "return true;\n}\n");
|
||||
Printf(s_global_tab, "{0,0,0,0,0}\n};\n");
|
||||
|
||||
Printv(f_wrappers, s_global_tab, NIL);
|
||||
|
|
@ -183,7 +245,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_directors);
|
||||
Delete(f_directors_h);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -250,14 +311,14 @@ public:
|
|||
return !Len(synopsis) && !Len(decl_info) &&
|
||||
!Len(cdecl_info) && !Len(args_info);
|
||||
}
|
||||
String *texinfo_name(Node* n) {
|
||||
String *texinfo_name(Node* n, const char* defval = "0") {
|
||||
String *tname = NewString("");
|
||||
String *iname = Getattr(n, "sym:name");
|
||||
String *wname = Swig_name_wrapper(iname);
|
||||
Node* d = Getattr(docs, wname);
|
||||
|
||||
if (is_empty_doc_node(d))
|
||||
Printf(tname, "0");
|
||||
Printf(tname, defval);
|
||||
else
|
||||
Printf(tname, "%s_texinfo", wname);
|
||||
|
||||
|
|
@ -330,7 +391,7 @@ public:
|
|||
virtual int importDirective(Node *n) {
|
||||
String *modname = Getattr(n, "module");
|
||||
if (modname)
|
||||
Printf(f_init, "feval(\"%s\",octave_value_list(),0);\n", modname);
|
||||
Printf(f_init, "if (!SWIG_Octave_LoadModule(\"%s\")) return false;\n", modname);
|
||||
return Language::importDirective(n);
|
||||
}
|
||||
|
||||
|
|
@ -342,88 +403,140 @@ public:
|
|||
return conv ? "SWIG_POINTER_IMPLICIT_CONV" : "0";
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* addMissingParameterNames()
|
||||
* For functions that have not had nameless parameters set in the Language class.
|
||||
*
|
||||
* Inputs:
|
||||
* plist - entire parameter list
|
||||
* arg_offset - argument number for first parameter
|
||||
* Side effects:
|
||||
* The "lname" attribute in each parameter in plist will be contain a parameter name
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void addMissingParameterNames(ParmList *plist, int arg_offset) {
|
||||
Parm *p = plist;
|
||||
int i = arg_offset;
|
||||
while (p) {
|
||||
if (!Getattr(p, "lname")) {
|
||||
String *pname = Swig_cparm_name(p, i);
|
||||
Delete(pname);
|
||||
}
|
||||
i++;
|
||||
p = nextSibling(p);
|
||||
}
|
||||
}
|
||||
|
||||
void make_autodocParmList(Node *n, String *decl_str, String *args_str) {
|
||||
String *pdocs = Copy(Getattr(n, "feature:pdocs"));
|
||||
String *pdocs = 0;
|
||||
ParmList *plist = CopyParmList(Getattr(n, "parms"));
|
||||
Parm *p;
|
||||
Parm *pnext;
|
||||
Node *lookup;
|
||||
int start_arg_num = is_wrapping_class() ? 1 : 0;
|
||||
|
||||
if (pdocs)
|
||||
Append(pdocs, "\n");
|
||||
addMissingParameterNames(plist, start_arg_num); // for $1_name substitutions done in Swig_typemap_attach_parms
|
||||
|
||||
Swig_typemap_attach_parms("in", plist, 0);
|
||||
Swig_typemap_attach_parms("doc", plist, 0);
|
||||
|
||||
for (p = plist; p; p = pnext) {
|
||||
|
||||
String *tm = Getattr(p, "tmap:in");
|
||||
if (tm) {
|
||||
pnext = Getattr(p, "tmap:in:next");
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
pnext = nextSibling(p);
|
||||
}
|
||||
|
||||
String *name = 0;
|
||||
String *type = 0;
|
||||
String *value = 0;
|
||||
String *ptype = 0;
|
||||
String *pdoc = Getattr(p, "tmap:doc");
|
||||
if (pdoc) {
|
||||
name = Getattr(p, "tmap:doc:name");
|
||||
type = Getattr(p, "tmap:doc:type");
|
||||
value = Getattr(p, "tmap:doc:value");
|
||||
ptype = Getattr(p, "tmap:doc:pytype");
|
||||
}
|
||||
|
||||
// Note: the generated name should be consistent with that in kwnames[]
|
||||
name = name ? name : Getattr(p, "name");
|
||||
name = name ? name : Getattr(p, "lname");
|
||||
name = Swig_name_make(p, 0, name, 0, 0); // rename parameter if a keyword
|
||||
|
||||
type = type ? type : Getattr(p, "type");
|
||||
value = value ? value : Getattr(p, "value");
|
||||
|
||||
if (SwigType_isvarargs(type))
|
||||
break;
|
||||
|
||||
String *tex_name = NewString("");
|
||||
if (name)
|
||||
Printf(tex_name, "@var{%s}", name);
|
||||
else
|
||||
Printf(tex_name, "@var{?}");
|
||||
|
||||
String *tm = Getattr(p, "tmap:in");
|
||||
if (tm) {
|
||||
pnext = Getattr(p, "tmap:in:next");
|
||||
} else {
|
||||
pnext = nextSibling(p);
|
||||
}
|
||||
|
||||
if (Len(decl_str))
|
||||
Append(decl_str, ", ");
|
||||
Append(decl_str, tex_name);
|
||||
|
||||
if (value) {
|
||||
if (Strcmp(value, "NULL") == 0 || Strcmp(value, "nullptr") == 0)
|
||||
value = NewString("nil");
|
||||
else if (Strcmp(value, "true") == 0 || Strcmp(value, "TRUE") == 0)
|
||||
value = NewString("true");
|
||||
else if (Strcmp(value, "false") == 0 || Strcmp(value, "FALSE") == 0)
|
||||
value = NewString("false");
|
||||
else {
|
||||
lookup = Swig_symbol_clookup(value, 0);
|
||||
String *new_value = convertValue(value, Getattr(p, "type"));
|
||||
if (new_value) {
|
||||
value = new_value;
|
||||
} else {
|
||||
Node *lookup = Swig_symbol_clookup(value, 0);
|
||||
if (lookup)
|
||||
value = Getattr(lookup, "sym:name");
|
||||
}
|
||||
Printf(decl_str, " = %s", value);
|
||||
}
|
||||
|
||||
if (type) {
|
||||
String *type_str = NewString("");
|
||||
type = SwigType_base(type);
|
||||
lookup = Swig_symbol_clookup(type, 0);
|
||||
if (lookup)
|
||||
type = Getattr(lookup, "sym:name");
|
||||
Printf(type_str, "%s is of type %s. ", tex_name, type);
|
||||
Append(args_str, type_str);
|
||||
Delete(type_str);
|
||||
}
|
||||
Node *nn = classLookup(Getattr(p, "type"));
|
||||
String *type_str = nn ? Copy(Getattr(nn, "sym:name")) : SwigType_str(type, 0);
|
||||
Printf(args_str, "%s is of type %s. ", tex_name, type_str);
|
||||
|
||||
Delete(type_str);
|
||||
Delete(tex_name);
|
||||
Delete(name);
|
||||
}
|
||||
if (pdocs)
|
||||
Setattr(n, "feature:pdocs", pdocs);
|
||||
Delete(plist);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
* convertValue()
|
||||
* Check if string v can be an Octave value literal,
|
||||
* (eg. number or string), or translate it to an Octave literal.
|
||||
* ------------------------------------------------------------ */
|
||||
String *convertValue(String *v, SwigType *t) {
|
||||
if (v && Len(v) > 0) {
|
||||
char fc = (Char(v))[0];
|
||||
if (('0' <= fc && fc <= '9') || '\'' == fc || '"' == fc) {
|
||||
/* number or string (or maybe NULL pointer) */
|
||||
if (SwigType_ispointer(t) && Strcmp(v, "0") == 0)
|
||||
return NewString("None");
|
||||
else
|
||||
return v;
|
||||
}
|
||||
if (Strcmp(v, "NULL") == 0 || Strcmp(v, "nullptr") == 0)
|
||||
return SwigType_ispointer(t) ? NewString("nil") : NewString("0");
|
||||
else if (Strcmp(v, "true") == 0 || Strcmp(v, "TRUE") == 0)
|
||||
return NewString("true");
|
||||
else if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("false");
|
||||
if (Strcmp(v, "true") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("true");
|
||||
if (Strcmp(v, "false") == 0 || Strcmp(v, "FALSE") == 0)
|
||||
return NewString("false");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int functionWrapper(Node *n) {
|
||||
Wrapper *f = NewWrapper();
|
||||
Parm *p;
|
||||
String *tm;
|
||||
int j;
|
||||
|
|
@ -447,7 +560,11 @@ public:
|
|||
if (overloaded)
|
||||
Append(overname, Getattr(n, "sym:overname"));
|
||||
|
||||
Printv(f->def, "static octave_value_list ", overname, " (const octave_value_list& args, int nargout) {", NIL);
|
||||
if (!overloaded || last_overload)
|
||||
process_autodoc(n);
|
||||
|
||||
Wrapper *f = NewWrapper();
|
||||
Octave_begin_function(n, f->def, iname, overname, !overloaded);
|
||||
|
||||
emit_parameter_variables(l, f);
|
||||
emit_attach_parmmaps(l, f);
|
||||
|
|
@ -600,8 +717,8 @@ public:
|
|||
Wrapper_add_local(f, "_outv", "octave_value _outv");
|
||||
|
||||
// Return the function value
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "_outv");
|
||||
Replaceall(tm, "$result", "_outv");
|
||||
|
||||
|
|
@ -622,14 +739,14 @@ public:
|
|||
Printv(f->code, cleanup, NIL);
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$result", "_outv");
|
||||
Printf(f->code, "%s\n", tm);
|
||||
Delete(tm);
|
||||
|
|
@ -647,7 +764,6 @@ public:
|
|||
dispatchFunction(n);
|
||||
|
||||
if (!overloaded || last_overload) {
|
||||
process_autodoc(n);
|
||||
String *tname = texinfo_name(n);
|
||||
Printf(s_global_tab, "{\"%s\",%s,0,0,2,%s},\n", iname, wname, tname);
|
||||
Delete(tname);
|
||||
|
|
@ -670,7 +786,7 @@ public:
|
|||
String *dispatch = Swig_overload_dispatch(n, "return %s(args, nargout);", &maxargs);
|
||||
String *tmp = NewString("");
|
||||
|
||||
Printv(f->def, "static octave_value_list ", wname, " (const octave_value_list& args, int nargout) {", NIL);
|
||||
Octave_begin_function(n, f->def, iname, wname, true);
|
||||
Wrapper_add_local(f, "argc", "int argc = args.length()");
|
||||
Printf(tmp, "octave_value_ref argv[%d]={", maxargs);
|
||||
for (int j = 0; j < maxargs; ++j)
|
||||
|
|
@ -704,7 +820,10 @@ public:
|
|||
String *getname = Swig_name_get(NSPACE_TODO, iname);
|
||||
String *setname = Swig_name_set(NSPACE_TODO, iname);
|
||||
|
||||
Printf(setf->def, "static octave_value_list _wrap_%s(const octave_value_list& args,int nargout) {", setname);
|
||||
String *getwname = Swig_name_wrapper(getname);
|
||||
String *setwname = Swig_name_wrapper(setname);
|
||||
|
||||
Octave_begin_function(n, setf->def, setname, setwname, true);
|
||||
Printf(setf->def, "if (!SWIG_check_num_args(\"%s_set\",args.length(),1,1,0)) return octave_value_list();", iname);
|
||||
if (is_assignable(n)) {
|
||||
Setattr(n, "wrap:name", setname);
|
||||
|
|
@ -730,7 +849,7 @@ public:
|
|||
|
||||
Setattr(n, "wrap:name", getname);
|
||||
int addfail = 0;
|
||||
Printf(getf->def, "static octave_value_list _wrap_%s(const octave_value_list& args,int nargout) {", getname);
|
||||
Octave_begin_function(n, getf->def, getname, getwname, true);
|
||||
Wrapper_add_local(getf, "obj", "octave_value obj");
|
||||
if ((tm = Swig_typemap_lookup("varout", n, name, 0))) {
|
||||
Replaceall(tm, "$source", name);
|
||||
|
|
@ -749,7 +868,12 @@ public:
|
|||
Append(getf->code, "}\n");
|
||||
Wrapper_print(getf, f_wrappers);
|
||||
|
||||
Printf(s_global_tab, "{\"%s\",0,_wrap_%s,_wrap_%s,2,0},\n", iname, getname, setname);
|
||||
Printf(s_global_tab, "{\"%s\",0,%s,%s,2,0},\n", iname, getwname, setwname);
|
||||
|
||||
Delete(getwname);
|
||||
Delete(setwname);
|
||||
DelWrapper(setf);
|
||||
DelWrapper(getf);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -838,18 +962,24 @@ public:
|
|||
|
||||
int use_director = Swig_directorclass(n);
|
||||
if (use_director) {
|
||||
String *disown_shadow = NewString("");
|
||||
Printf(disown_shadow, "static octave_value_list _wrap_disown_%s_shadow " "(const octave_value_list& args, int nargout) {\n", class_name);
|
||||
Printf(disown_shadow, " if (args.length()!=1) {\n");
|
||||
Printf(disown_shadow, " error(\"disown takes no arguments\");\n");
|
||||
Printf(disown_shadow, " return octave_value_list();\n");
|
||||
Printf(disown_shadow, " }\n");
|
||||
Printf(disown_shadow, " _wrap_disown_%s (args, nargout);\n", class_name);
|
||||
Printf(disown_shadow, " return args;\n");
|
||||
Printf(disown_shadow, "}\n");
|
||||
Printv(f_wrappers, disown_shadow, NIL);
|
||||
Delete(disown_shadow);
|
||||
Printf(s_members_tab, "{\"__disown\",_wrap_disown_%s_shadow,0,0,0,0},\n", class_name);
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *cname = Swig_name_disown(nspace, class_name);
|
||||
String *wcname = Swig_name_wrapper(cname);
|
||||
String *cnameshdw = NewStringf("%s_shadow", cname);
|
||||
String *wcnameshdw = Swig_name_wrapper(cnameshdw);
|
||||
Octave_begin_function(n, f_wrappers, cnameshdw, wcnameshdw, true);
|
||||
Printf(f_wrappers, " if (args.length()!=1) {\n");
|
||||
Printf(f_wrappers, " error(\"disown takes no arguments\");\n");
|
||||
Printf(f_wrappers, " return octave_value_list();\n");
|
||||
Printf(f_wrappers, " }\n");
|
||||
Printf(f_wrappers, " %s (args, nargout);\n", wcname);
|
||||
Printf(f_wrappers, " return args;\n");
|
||||
Printf(f_wrappers, "}\n");
|
||||
Printf(s_members_tab, "{\"__disown\",%s,0,0,0,0},\n", wcnameshdw);
|
||||
Delete(wcname);
|
||||
Delete(cname);
|
||||
Delete(wcnameshdw);
|
||||
Delete(cnameshdw);
|
||||
}
|
||||
|
||||
Printf(s_members_tab, "{0,0,0,0}\n};\n");
|
||||
|
|
@ -883,7 +1013,8 @@ public:
|
|||
Printv(f_wrappers, "static swig_octave_class _wrap_class_", class_name, " = {\"", class_name, "\", &SWIGTYPE", SwigType_manglestr(t), ",", NIL);
|
||||
Printv(f_wrappers, Swig_directorclass(n) ? "1," : "0,", NIL);
|
||||
if (have_constructor) {
|
||||
String *cname = Swig_name_construct(NSPACE_TODO, constructor_name);
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *cname = Swig_name_construct(nspace, constructor_name);
|
||||
String *wcname = Swig_name_wrapper(cname);
|
||||
String *tname = texinfo_name(n);
|
||||
Printf(f_wrappers, "%s,%s,", wcname, tname);
|
||||
|
|
@ -892,9 +1023,14 @@ public:
|
|||
Delete(cname);
|
||||
} else
|
||||
Printv(f_wrappers, "0,0,", NIL);
|
||||
if (have_destructor)
|
||||
Printv(f_wrappers, "_wrap_delete_", class_name, ",", NIL);
|
||||
else
|
||||
if (have_destructor) {
|
||||
String *nspace = Getattr(n, "sym:nspace");
|
||||
String *cname = Swig_name_destroy(nspace, class_name);
|
||||
String *wcname = Swig_name_wrapper(cname);
|
||||
Printf(f_wrappers, "%s,", wcname);
|
||||
Delete(wcname);
|
||||
Delete(cname);
|
||||
} else
|
||||
Printv(f_wrappers, "0", ",", NIL);
|
||||
Printf(f_wrappers, "swig_%s_members,swig_%s_base_names,swig_%s_base };\n\n", class_name, class_name, class_name);
|
||||
|
||||
|
|
@ -916,16 +1052,21 @@ public:
|
|||
String *name = Getattr(n, "name");
|
||||
String *iname = GetChar(n, "sym:name");
|
||||
String *realname = iname ? iname : name;
|
||||
String *rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
|
||||
String *wname = Getattr(n, "wrap:name");
|
||||
assert(wname);
|
||||
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
String *tname = texinfo_name(n);
|
||||
String *rname = Copy(wname);
|
||||
bool overloaded = !!Getattr(n, "sym:overloaded");
|
||||
if (overloaded)
|
||||
Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
|
||||
Printf(s_members_tab, "{\"%s\",%s,0,0,0,%s},\n",
|
||||
realname, rname, tname);
|
||||
Delete(rname);
|
||||
Delete(tname);
|
||||
}
|
||||
|
||||
Delete(rname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -937,15 +1078,18 @@ public:
|
|||
assert(s_members_tab);
|
||||
assert(class_name);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *getname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
String *setname = GetFlag(n, "feature:immutable") ?
|
||||
NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
String *getname = Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
String *setname = Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
String *getwname = Swig_name_wrapper(getname);
|
||||
String *setwname = GetFlag(n, "feature:immutable") ? NewString("octave_set_immutable") : Swig_name_wrapper(setname);
|
||||
assert(s_members_tab);
|
||||
|
||||
Printf(s_members_tab, "{\"%s\",0,%s,%s,0,0},\n", symname, getname, setname);
|
||||
Printf(s_members_tab, "{\"%s\",0,%s,%s,0,0},\n", symname, getwname, setwname);
|
||||
|
||||
Delete(getname);
|
||||
Delete(setname);
|
||||
Delete(getwname);
|
||||
Delete(setwname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -989,16 +1133,21 @@ public:
|
|||
String *name = Getattr(n, "name");
|
||||
String *iname = GetChar(n, "sym:name");
|
||||
String *realname = iname ? iname : name;
|
||||
String *rname = Swig_name_wrapper(Swig_name_member(NSPACE_TODO, class_name, realname));
|
||||
String *wname = Getattr(n, "wrap:name");
|
||||
assert(wname);
|
||||
|
||||
if (!Getattr(n, "sym:nextSibling")) {
|
||||
String *tname = texinfo_name(n);
|
||||
String *rname = Copy(wname);
|
||||
bool overloaded = !!Getattr(n, "sym:overloaded");
|
||||
if (overloaded)
|
||||
Delslice(rname, Len(rname) - Len(Getattr(n, "sym:overname")), DOH_END);
|
||||
Printf(s_members_tab, "{\"%s\",%s,0,0,1,%s},\n",
|
||||
realname, rname, tname);
|
||||
Delete(rname);
|
||||
Delete(tname);
|
||||
}
|
||||
|
||||
Delete(rname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1015,15 +1164,18 @@ public:
|
|||
assert(s_members_tab);
|
||||
assert(class_name);
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *getname = Swig_name_wrapper(Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
String *setname = GetFlag(n, "feature:immutable") ?
|
||||
NewString("octave_set_immutable") : Swig_name_wrapper(Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname)));
|
||||
String *getname = Swig_name_get(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
String *setname = Swig_name_set(NSPACE_TODO, Swig_name_member(NSPACE_TODO, class_name, symname));
|
||||
String *getwname = Swig_name_wrapper(getname);
|
||||
String *setwname = GetFlag(n, "feature:immutable") ? NewString("octave_set_immutable") : Swig_name_wrapper(setname);
|
||||
assert(s_members_tab);
|
||||
|
||||
Printf(s_members_tab, "{\"%s\",0,%s,%s,1,0},\n", symname, getname, setname);
|
||||
Printf(s_members_tab, "{\"%s\",0,%s,%s,1,0},\n", symname, getwname, setwname);
|
||||
|
||||
Delete(getname);
|
||||
Delete(setname);
|
||||
Delete(getwname);
|
||||
Delete(setwname);
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -1109,17 +1261,17 @@ public:
|
|||
int classDirectorMethod(Node *n, Node *parent, String *super) {
|
||||
int is_void = 0;
|
||||
int is_pointer = 0;
|
||||
String *decl;
|
||||
String *type;
|
||||
String *name;
|
||||
String *classname;
|
||||
String *decl = Getattr(n, "decl");
|
||||
String *returntype = Getattr(n, "type");
|
||||
String *name = Getattr(n, "name");
|
||||
String *classname = Getattr(parent, "sym:name");
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration = NewString("");
|
||||
ParmList *l = Getattr(n, "parms");
|
||||
Wrapper *w = NewWrapper();
|
||||
String *tm;
|
||||
String *wrap_args = NewString("");
|
||||
String *return_type;
|
||||
String *value = Getattr(n, "value");
|
||||
String *storage = Getattr(n, "storage");
|
||||
bool pure_virtual = false;
|
||||
|
|
@ -1133,35 +1285,15 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
classname = Getattr(parent, "sym:name");
|
||||
type = Getattr(n, "type");
|
||||
name = Getattr(n, "name");
|
||||
|
||||
w = NewWrapper();
|
||||
declaration = NewString("");
|
||||
|
||||
// determine if the method returns a pointer
|
||||
decl = Getattr(n, "decl");
|
||||
is_pointer = SwigType_ispointer_return(decl);
|
||||
is_void = (!Cmp(type, "void") && !is_pointer);
|
||||
|
||||
// form complete return type
|
||||
return_type = Copy(type);
|
||||
{
|
||||
SwigType *t = Copy(decl);
|
||||
SwigType *f = 0;
|
||||
f = SwigType_pop_function(t);
|
||||
SwigType_push(return_type, t);
|
||||
Delete(f);
|
||||
Delete(t);
|
||||
}
|
||||
is_void = (!Cmp(returntype, "void") && !is_pointer);
|
||||
|
||||
// virtual method definition
|
||||
l = Getattr(n, "parms");
|
||||
String *target;
|
||||
String *pclassname = NewStringf("SwigDirector_%s", classname);
|
||||
String *qualified_name = NewStringf("%s::%s", pclassname, name);
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type;
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
|
||||
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
|
||||
Printf(w->def, "%s", target);
|
||||
Delete(qualified_name);
|
||||
|
|
@ -1185,7 +1317,7 @@ public:
|
|||
if (throw_parm_list)
|
||||
Swig_typemap_attach_parms("throws", throw_parm_list, 0);
|
||||
for (p = throw_parm_list; p; p = nextSibling(p)) {
|
||||
if ((tm = Getattr(p, "tmap:throws"))) {
|
||||
if (Getattr(p, "tmap:throws")) {
|
||||
if (gencomma++) {
|
||||
Append(w->def, ", ");
|
||||
Append(declaration, ", ");
|
||||
|
|
@ -1209,7 +1341,7 @@ public:
|
|||
// handle it, including declaration of c_result ($result).
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
String *cres = SwigType_lstr(return_type, "c_result");
|
||||
String *cres = SwigType_lstr(returntype, "c_result");
|
||||
Printf(w->code, "%s;\n", cres);
|
||||
Delete(cres);
|
||||
}
|
||||
|
|
@ -1230,6 +1362,8 @@ public:
|
|||
// attach typemaps to arguments (C/C++ -> Python)
|
||||
String *parse_args = NewString("");
|
||||
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
Swig_typemap_attach_parms("in", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
Swig_typemap_attach_parms("directorargout", l, w);
|
||||
|
|
@ -1243,7 +1377,6 @@ public:
|
|||
// build argument list and type conversion string
|
||||
idx = 0;
|
||||
p = l;
|
||||
int use_parse = 0;
|
||||
while (p) {
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
|
|
@ -1260,14 +1393,15 @@ public:
|
|||
if ((tm = Getattr(p, "tmap:directorin")) != 0) {
|
||||
String *parse = Getattr(p, "tmap:directorin:parse");
|
||||
if (!parse) {
|
||||
Setattr(p, "emit:directorinput", "tmpv");
|
||||
Replaceall(tm, "$input", "tmpv");
|
||||
Replaceall(tm, "$owner", "0");
|
||||
Printv(wrap_args, tm, "\n", NIL);
|
||||
Printf(wrap_args, "args.append(tmpv);\n");
|
||||
Putc('O', parse_args);
|
||||
} else {
|
||||
use_parse = 1;
|
||||
Append(parse_args, parse);
|
||||
Setattr(p, "emit:directorinput", pname);
|
||||
Replaceall(tm, "$input", pname);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
if (Len(tm) == 0)
|
||||
|
|
@ -1308,9 +1442,7 @@ public:
|
|||
"method %s.%s failed to return the required number " "of arguments.\");\n", classname, method_name);
|
||||
Printf(w->code, "}\n");
|
||||
|
||||
Setattr(n, "type", return_type);
|
||||
tm = Swig_typemap_lookup("directorout", n, "result", w);
|
||||
Setattr(n, "type", type);
|
||||
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
|
||||
if (tm != 0) {
|
||||
char temp[24];
|
||||
sprintf(temp, "out(%d)", idx);
|
||||
|
|
@ -1326,7 +1458,7 @@ public:
|
|||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
|
||||
"Unable to use return type %s in director method %s::%s (skipping method).\n",
|
||||
SwigType_str(return_type, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
|
||||
SwigType_str(returntype, 0), SwigType_namestr(c_classname), SwigType_namestr(name));
|
||||
status = SWIG_ERROR;
|
||||
}
|
||||
}
|
||||
|
|
@ -1337,8 +1469,8 @@ public:
|
|||
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
|
||||
char temp[24];
|
||||
sprintf(temp, "out(%d)", idx);
|
||||
Replaceall(tm, "$input", temp);
|
||||
Replaceall(tm, "$result", Getattr(p, "name"));
|
||||
Replaceall(tm, "$result", temp);
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
|
|
@ -1353,8 +1485,8 @@ public:
|
|||
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
String *rettype = SwigType_str(return_type, 0);
|
||||
if (!SwigType_isreference(return_type)) {
|
||||
String *rettype = SwigType_str(returntype, 0);
|
||||
if (!SwigType_isreference(returntype)) {
|
||||
Printf(w->code, "return (%s) c_result;\n", rettype);
|
||||
} else {
|
||||
Printf(w->code, "return (%s) *c_result;\n", rettype);
|
||||
|
|
@ -1382,6 +1514,7 @@ public:
|
|||
// emit the director method
|
||||
if (status == SWIG_OK) {
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
|
|
@ -1389,7 +1522,6 @@ public:
|
|||
}
|
||||
// clean up
|
||||
Delete(wrap_args);
|
||||
Delete(return_type);
|
||||
Delete(pclassname);
|
||||
DelWrapper(w);
|
||||
return status;
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@
|
|||
* building a dispatch function.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_overload_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#define MAX_OVERLOAD 4096
|
||||
|
|
@ -231,11 +229,12 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore"))
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
|
|
@ -248,11 +247,12 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
Swig_warning(WARN_LANG_OVERLOAD_CONST, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using non-const method %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore"))
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
|
|
@ -270,11 +270,12 @@ List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"as it is shadowed by %s.\n", Swig_name_decl(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore"))
|
||||
if (!Getattr(nodes[j].n, "overload:ignore")) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s ignored,\n", Swig_name_decl(nodes[j].n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"using %s instead.\n", Swig_name_decl(nodes[i].n));
|
||||
}
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
|
|
@ -386,16 +387,11 @@ String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *
|
|||
int num_arguments = emit_num_arguments(pi);
|
||||
if (num_arguments > *maxargs)
|
||||
*maxargs = num_arguments;
|
||||
int varargs = emit_isvarargs(pi);
|
||||
|
||||
if (!varargs) {
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if (%s >= %d) {\n", argc_template_string, num_required);
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
Printf(f, "SWIG_TypeRank _ranki = 0;\n");
|
||||
Printf(f, "SWIG_TypeRank _rankm = 0;\n");
|
||||
|
|
@ -565,16 +561,11 @@ String *Swig_overload_dispatch_fast(Node *n, const_String_or_char_ptr fmt, int *
|
|||
int num_arguments = emit_num_arguments(pi);
|
||||
if (num_arguments > *maxargs)
|
||||
*maxargs = num_arguments;
|
||||
int varargs = emit_isvarargs(pi);
|
||||
|
||||
if (!varargs) {
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if (%s >= %d) {\n", argc_template_string, num_required);
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
|
||||
/* create a list with the wrappers that collide with the
|
||||
|
|
@ -732,16 +723,11 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar
|
|||
}
|
||||
if (num_arguments > *maxargs)
|
||||
*maxargs = num_arguments;
|
||||
int varargs = emit_isvarargs(pi);
|
||||
|
||||
if (!varargs) {
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
if (num_required == num_arguments) {
|
||||
Printf(f, "if (%s == %d) {\n", argc_template_string, num_required);
|
||||
} else {
|
||||
Printf(f, "if (%s >= %d) {\n", argc_template_string, num_required);
|
||||
Printf(f, "if ((%s >= %d) && (%s <= %d)) {\n", argc_template_string, num_required, argc_template_string, num_arguments);
|
||||
}
|
||||
|
||||
if (num_arguments) {
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Perl5 language module for SWIG.
|
||||
* ------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_perl5_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
static int treduce = SWIG_cparse_template_reduce(0);
|
||||
|
|
@ -21,14 +19,15 @@ static int treduce = SWIG_cparse_template_reduce(0);
|
|||
|
||||
static const char *usage = (char *) "\
|
||||
Perl5 Options (available with -perl5)\n\
|
||||
-static - Omit code related to dynamic loading\n\
|
||||
-nopm - Do not generate the .pm file\n\
|
||||
-proxy - Create proxy classes\n\
|
||||
-noproxy - Don't create proxy classes\n\
|
||||
-compat - Compatibility mode\n\
|
||||
-const - Wrap constants as constants and not variables (implies -proxy)\n\
|
||||
-nocppcast - Disable C++ casting operators, useful for generating bugs\n\
|
||||
-cppcast - Enable C++ casting operators\n\
|
||||
-compat - Compatibility mode\n\n";
|
||||
-nocppcast - Disable C++ casting operators, useful for generating bugs\n\
|
||||
-nopm - Do not generate the .pm file\n\
|
||||
-noproxy - Don't create proxy classes\n\
|
||||
-proxy - Create proxy classes\n\
|
||||
-static - Omit code related to dynamic loading\n\
|
||||
\n";
|
||||
|
||||
static int compat = 0;
|
||||
|
||||
|
|
@ -131,7 +130,7 @@ public:
|
|||
Node *is_shadow(SwigType *t) {
|
||||
Node *n;
|
||||
n = classLookup(t);
|
||||
/* Printf(stdout,"'%s' --> '%x'\n", t, n); */
|
||||
/* Printf(stdout,"'%s' --> '%p'\n", t, n); */
|
||||
if (n) {
|
||||
if (!Getattr(n, "perl5:proxy")) {
|
||||
setclassname(n);
|
||||
|
|
@ -519,7 +518,6 @@ public:
|
|||
Printf(f_pm, "%s", additional_perl_code);
|
||||
|
||||
Printf(f_pm, "1;\n");
|
||||
Close(f_pm);
|
||||
Delete(f_pm);
|
||||
Delete(base);
|
||||
Delete(dest_package);
|
||||
|
|
@ -533,7 +531,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
|
|
@ -729,9 +726,9 @@ public:
|
|||
Swig_director_emit_dynamic_cast(n, f);
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
SwigType *t = Getattr(n, "type");
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "ST(argvi)");
|
||||
Replaceall(tm, "$result", "ST(argvi)");
|
||||
if (is_shadow(t)) {
|
||||
|
|
@ -759,14 +756,14 @@ public:
|
|||
Printv(f->code, cleanup, NIL);
|
||||
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
@ -791,7 +788,7 @@ public:
|
|||
} else if (!Getattr(n, "sym:nextSibling")) {
|
||||
/* Generate overloaded dispatch function */
|
||||
int maxargs;
|
||||
String *dispatch = Swig_overload_dispatch_cast(n, "++PL_markstack_ptr; SWIG_CALLXS(%s); return;", &maxargs);
|
||||
String *dispatch = Swig_overload_dispatch_cast(n, "PUSHMARK(MARK); SWIG_CALLXS(%s); return;", &maxargs);
|
||||
|
||||
/* Generate a dispatch wrapper for all overloaded functions */
|
||||
|
||||
|
|
@ -869,6 +866,8 @@ public:
|
|||
emit_action_code(n, setf->code, tm);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(t, 0));
|
||||
DelWrapper(setf);
|
||||
DelWrapper(getf);
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
Printf(setf->code, "fail:\n");
|
||||
|
|
@ -1637,8 +1636,8 @@ public:
|
|||
while (fgets(buffer, 4095, f)) {
|
||||
Printf(pragma_include, "%s", buffer);
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
} else {
|
||||
Swig_error(input_file, line_number, "Unrecognized pragma.\n");
|
||||
|
|
@ -1668,7 +1667,7 @@ public:
|
|||
}
|
||||
|
||||
/* Split the input text into lines */
|
||||
List *clist = DohSplitLines(temp);
|
||||
List *clist = SplitLines(temp);
|
||||
Delete(temp);
|
||||
int initial = 0;
|
||||
String *s = 0;
|
||||
|
|
|
|||
|
|
@ -37,8 +37,6 @@
|
|||
* (may need to add more WARN_PHP_xxx codes...)
|
||||
*/
|
||||
|
||||
char cvsroot_php_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h>
|
||||
|
|
@ -46,7 +44,7 @@ char cvsroot_php_cxx[] = "$Id$";
|
|||
|
||||
static const char *usage = (char *) "\
|
||||
PHP Options (available with -php)\n\
|
||||
-cppext - cpp file extension (default to .cpp)\n\
|
||||
-cppext <ext> - Change C++ file extension to <ext> (default is cpp)\n\
|
||||
-noproxy - Don't generate proxy classes.\n\
|
||||
-prefix <prefix> - Prepend <prefix> to all class names in PHP wrappers\n\
|
||||
\n";
|
||||
|
|
@ -126,7 +124,7 @@ static enum {
|
|||
} wrapperType = standard;
|
||||
|
||||
extern "C" {
|
||||
static void (*r_prevtracefunc) (SwigType *t, String *mangled, String *clientdata) = 0;
|
||||
static void (*r_prevtracefunc) (const SwigType *t, String *mangled, String *clientdata) = 0;
|
||||
}
|
||||
|
||||
static void SwigPHP_emit_resource_registrations() {
|
||||
|
|
@ -182,6 +180,23 @@ static void SwigPHP_emit_resource_registrations() {
|
|||
}
|
||||
|
||||
class PHP : public Language {
|
||||
String *emit_action(Node *n) {
|
||||
// Adjust wrap:action to add TSRMLS_CC.
|
||||
String * action = Getattr(n, "wrap:action");
|
||||
if (action) {
|
||||
char * p = Strstr(action, "Swig::DirectorPureVirtualException::raise(\"");
|
||||
if (p) {
|
||||
p += strlen("Swig::DirectorPureVirtualException::raise(\"");
|
||||
p = strchr(p, '"');
|
||||
if (p) {
|
||||
++p;
|
||||
Insert(action, p - Char(action), " TSRMLS_CC");
|
||||
}
|
||||
}
|
||||
}
|
||||
return ::emit_action(n);
|
||||
}
|
||||
|
||||
public:
|
||||
PHP() {
|
||||
director_language = 1;
|
||||
|
|
@ -250,7 +265,6 @@ public:
|
|||
virtual int top(Node *n) {
|
||||
|
||||
String *filen;
|
||||
String *s_type;
|
||||
|
||||
/* Check if directors are enabled for this module. */
|
||||
Node *mod = Getattr(n, "module");
|
||||
|
|
@ -283,7 +297,6 @@ public:
|
|||
r_shutdown = NewString("/* rshutdown section */\n");
|
||||
s_header = NewString("/* header section */\n");
|
||||
s_wrappers = NewString("/* wrapper section */\n");
|
||||
s_type = NewStringEmpty();
|
||||
/* subsections of the init section */
|
||||
s_vinit = NewString("/* vinit subsection */\n");
|
||||
s_vdecl = NewString("/* vdecl subsection */\n");
|
||||
|
|
@ -330,13 +343,18 @@ public:
|
|||
if (!prefix)
|
||||
prefix = NewStringEmpty();
|
||||
|
||||
Printf(f_runtime, "#define SWIG_PREFIX \"%s\"\n", prefix);
|
||||
Printf(f_runtime, "#define SWIG_PREFIX_LEN %lu\n", (unsigned long)Len(prefix));
|
||||
|
||||
if (directorsEnabled()) {
|
||||
Swig_banner(f_directors_h);
|
||||
Printf(f_directors_h, "\n");
|
||||
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", cap_module);
|
||||
Printf(f_directors_h, "#define SWIG_%s_WRAP_H_\n\n", cap_module);
|
||||
|
||||
Printf(f_directors, "\n#include \"%s\"\n\n", Swig_file_filename(outfile_h));
|
||||
String *filename = Swig_file_filename(outfile_h);
|
||||
Printf(f_directors, "\n#include \"%s\"\n\n", filename);
|
||||
Delete(filename);
|
||||
}
|
||||
|
||||
/* PHP module file */
|
||||
|
|
@ -391,6 +409,21 @@ public:
|
|||
Printf(s_header, "#define SWIG_ErrorCode() (%s_globals.error_code)\n", module);
|
||||
Printf(s_header, "#endif\n\n");
|
||||
|
||||
/* The following can't go in Lib/php/phprun.swg as it uses SWIG_ErrorMsg(), etc
|
||||
* which has to be dynamically generated as it depends on the module name.
|
||||
*/
|
||||
Append(s_header, "#ifdef __GNUC__\n");
|
||||
Append(s_header, "static void SWIG_FAIL() __attribute__ ((__noreturn__));\n");
|
||||
Append(s_header, "#endif\n\n");
|
||||
Append(s_header, "static void SWIG_FAIL() {\n");
|
||||
Append(s_header, " TSRMLS_FETCH();\n");
|
||||
Append(s_header, " zend_error(SWIG_ErrorCode(), \"%s\", SWIG_ErrorMsg());\n");
|
||||
// zend_error() should never return with the parameters we pass, but if it
|
||||
// does, we really don't want to let SWIG_FAIL() return. This also avoids
|
||||
// a warning about returning from a function marked as "__noreturn__".
|
||||
Append(s_header, " abort();\n");
|
||||
Append(s_header, "}\n\n");
|
||||
|
||||
Printf(s_header, "static void %s_init_globals(zend_%s_globals *globals ) {\n", module, module);
|
||||
Printf(s_header, " globals->error_msg = default_error_msg;\n");
|
||||
Printf(s_header, " globals->error_code = default_error_code;\n");
|
||||
|
|
@ -439,10 +472,6 @@ public:
|
|||
Append(s_header, "}\n");
|
||||
|
||||
Printf(s_header, "#define SWIG_name \"%s\"\n", module);
|
||||
/* Printf(s_header,"#ifdef HAVE_CONFIG_H\n");
|
||||
Printf(s_header,"#include \"config.h\"\n");
|
||||
Printf(s_header,"#endif\n\n");
|
||||
*/
|
||||
Printf(s_header, "#ifdef __cplusplus\n");
|
||||
Printf(s_header, "extern \"C\" {\n");
|
||||
Printf(s_header, "#endif\n");
|
||||
|
|
@ -504,7 +533,8 @@ public:
|
|||
Append(s_init, "#undef ZEND_MODULE_BUILD_ID\n");
|
||||
Append(s_init, "#define ZEND_MODULE_BUILD_ID (char*)\"API\" ZEND_TOSTR(ZEND_MODULE_API_NO) ZEND_BUILD_TS ZEND_BUILD_DEBUG ZEND_BUILD_SYSTEM ZEND_BUILD_EXTRA\n");
|
||||
Append(s_init, "#endif\n");
|
||||
Printv(s_init, "zend_module_entry ", module, "_module_entry = {\n" "#if ZEND_MODULE_API_NO > 20010900\n" " STANDARD_MODULE_HEADER,\n" "#endif\n", NIL);
|
||||
Printv(s_init, "zend_module_entry ", module, "_module_entry = {\n", NIL);
|
||||
Printf(s_init, " STANDARD_MODULE_HEADER,\n");
|
||||
Printf(s_init, " (char*)\"%s\",\n", module);
|
||||
Printf(s_init, " %s_functions,\n", module);
|
||||
Printf(s_init, " PHP_MINIT(%s),\n", module);
|
||||
|
|
@ -512,9 +542,7 @@ public:
|
|||
Printf(s_init, " PHP_RINIT(%s),\n", module);
|
||||
Printf(s_init, " PHP_RSHUTDOWN(%s),\n", module);
|
||||
Printf(s_init, " PHP_MINFO(%s),\n", module);
|
||||
Printf(s_init, "#if ZEND_MODULE_API_NO > 20010900\n");
|
||||
Printf(s_init, " NO_VERSION_YET,\n");
|
||||
Printf(s_init, "#endif\n");
|
||||
Printf(s_init, " STANDARD_MODULE_PROPERTIES\n");
|
||||
Printf(s_init, "};\n");
|
||||
Printf(s_init, "zend_module_entry* SWIG_module_entry = &%s_module_entry;\n\n", module);
|
||||
|
|
@ -588,7 +616,7 @@ public:
|
|||
|
||||
Printf(f_h, "#endif /* PHP_%s_H */\n", cap_module);
|
||||
|
||||
Close(f_h);
|
||||
Delete(f_h);
|
||||
|
||||
String *type_table = NewStringEmpty();
|
||||
SwigType_emit_type_table(f_runtime, type_table);
|
||||
|
|
@ -603,7 +631,7 @@ public:
|
|||
Dump(f_directors_h, f_runtime_h);
|
||||
Printf(f_runtime_h, "\n");
|
||||
Printf(f_runtime_h, "#endif\n");
|
||||
Close(f_runtime_h);
|
||||
Delete(f_runtime_h);
|
||||
}
|
||||
|
||||
Printf(s_header, "/* end header section */\n");
|
||||
|
|
@ -627,7 +655,6 @@ public:
|
|||
Delete(s_vdecl);
|
||||
Delete(all_cs_entry);
|
||||
Delete(s_entry);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -640,7 +667,7 @@ public:
|
|||
s_fakeoowrappers = NULL;
|
||||
}
|
||||
Printf(f_phpcode, "%s\n?>\n", s_phpclasses);
|
||||
Close(f_phpcode);
|
||||
Delete(f_phpcode);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -666,7 +693,7 @@ public:
|
|||
/* We have an extra 'this' parameter. */
|
||||
SetFlag(n, "wrap:this");
|
||||
}
|
||||
String *dispatch = Swig_overload_dispatch(n, "return %s(INTERNAL_FUNCTION_PARAM_PASSTHRU);", &maxargs);
|
||||
String *dispatch = Swig_overload_dispatch(n, "%s(INTERNAL_FUNCTION_PARAM_PASSTHRU); return;", &maxargs);
|
||||
|
||||
/* Generate a dispatch wrapper for all overloaded functions */
|
||||
|
||||
|
|
@ -692,7 +719,7 @@ public:
|
|||
|
||||
Printf(f->code, "SWIG_ErrorCode() = E_ERROR;\n");
|
||||
Printf(f->code, "SWIG_ErrorMsg() = \"No matching function for overloaded '%s'\";\n", symname);
|
||||
Printv(f->code, "zend_error(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n", NIL);
|
||||
Printv(f->code, "SWIG_FAIL();\n", NIL);
|
||||
|
||||
Printv(f->code, "}\n", NIL);
|
||||
Wrapper_print(f, s_wrappers);
|
||||
|
|
@ -799,8 +826,8 @@ public:
|
|||
Wrapper_add_local(f, "director", "Swig::Director *director = 0");
|
||||
Printf(f->code, "director = dynamic_cast<Swig::Director*>(arg1);\n");
|
||||
Wrapper_add_local(f, "upcall", "bool upcall = false");
|
||||
Printf(f->code, "upcall = !director->swig_is_overridden_method((char *)\"%s\", (char *)\"%s\");\n",
|
||||
Swig_class_name(Swig_methodclass(n)), name);
|
||||
Printf(f->code, "upcall = !director->swig_is_overridden_method((char *)\"%s%s\", (char *)\"%s\");\n",
|
||||
prefix, Swig_class_name(Swig_methodclass(n)), name);
|
||||
}
|
||||
|
||||
// This generated code may be called:
|
||||
|
|
@ -915,8 +942,10 @@ public:
|
|||
}
|
||||
|
||||
/* Insert argument output code */
|
||||
bool hasargout = false;
|
||||
for (i = 0, p = l; p; i++) {
|
||||
if ((tm = Getattr(p, "tmap:argout"))) {
|
||||
hasargout = true;
|
||||
Replaceall(tm, "$source", Getattr(p, "lname"));
|
||||
// Replaceall(tm,"$input",Getattr(p,"lname"));
|
||||
Replaceall(tm, "$target", "return_value");
|
||||
|
|
@ -935,9 +964,9 @@ public:
|
|||
/* emit function call */
|
||||
String *actioncode = emit_action(n);
|
||||
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$input", "result");
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$input", Swig_cresult_name());
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "return_value");
|
||||
Replaceall(tm, "$result", "return_value");
|
||||
Replaceall(tm, "$owner", newobject ? "1" : "0");
|
||||
|
|
@ -957,14 +986,14 @@ public:
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Printf(f->code, "%s\n", tm);
|
||||
Delete(tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Printf(f->code, "%s\n", tm);
|
||||
Delete(tm);
|
||||
}
|
||||
|
|
@ -974,7 +1003,7 @@ public:
|
|||
/* Error handling code */
|
||||
Printf(f->code, "fail:\n");
|
||||
Printv(f->code, cleanup, NIL);
|
||||
Printv(f->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());", NIL);
|
||||
Append(f->code, "SWIG_FAIL();\n");
|
||||
|
||||
Printf(f->code, "}\n");
|
||||
|
||||
|
|
@ -1003,7 +1032,7 @@ public:
|
|||
p += strlen(p) - 4;
|
||||
String *varname = Getattr(n, "membervariableHandler:sym:name");
|
||||
if (strcmp(p, "_get") == 0) {
|
||||
Setattr(shadow_get_vars, varname, iname);
|
||||
Setattr(shadow_get_vars, varname, Getattr(n, "type"));
|
||||
} else if (strcmp(p, "_set") == 0) {
|
||||
Setattr(shadow_set_vars, varname, iname);
|
||||
}
|
||||
|
|
@ -1061,12 +1090,11 @@ public:
|
|||
int min_num_of_arguments = emit_num_required(l);
|
||||
int max_num_of_arguments = emit_num_arguments(l);
|
||||
|
||||
// For a function with default arguments, we end up with the fullest
|
||||
// parmlist in full_parmlist.
|
||||
ParmList *full_parmlist = l;
|
||||
Hash *ret_types = NewHash();
|
||||
Setattr(ret_types, d, d);
|
||||
|
||||
bool non_void_return = (Cmp(d, "void") != 0);
|
||||
|
||||
if (overloaded) {
|
||||
// Look at all the overloaded versions of this method in turn to
|
||||
// decide if it's really an overloaded method, or just one where some
|
||||
|
|
@ -1083,6 +1111,7 @@ public:
|
|||
assert(constructor);
|
||||
} else if (!Getattr(ret_types, d2)) {
|
||||
Setattr(ret_types, d2, d2);
|
||||
non_void_return = non_void_return || (Cmp(d2, "void") != 0);
|
||||
}
|
||||
|
||||
ParmList *l2 = Getattr(o, "wrap:parms");
|
||||
|
|
@ -1093,7 +1122,6 @@ public:
|
|||
|
||||
if (num_arguments > max_num_of_arguments) {
|
||||
max_num_of_arguments = num_arguments;
|
||||
full_parmlist = l2;
|
||||
}
|
||||
o = Getattr(o, "sym:nextSibling");
|
||||
}
|
||||
|
|
@ -1144,11 +1172,6 @@ public:
|
|||
if (!o) {
|
||||
// This "overloaded method" is really just one with default args.
|
||||
really_overloaded = false;
|
||||
if (l != full_parmlist) {
|
||||
l = full_parmlist;
|
||||
if (wrapperType == memberfn)
|
||||
l = nextSibling(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1496,7 +1519,7 @@ public:
|
|||
while (last_handled_i < i) {
|
||||
Printf(prepare, "case %d: ", ++last_handled_i);
|
||||
}
|
||||
if (Cmp(d, "void") != 0) {
|
||||
if (non_void_return) {
|
||||
if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
|
||||
Append(prepare, "$r=");
|
||||
} else {
|
||||
|
|
@ -1518,7 +1541,7 @@ public:
|
|||
Printf(prepare, "\t\t");
|
||||
if (had_a_case)
|
||||
Printf(prepare, "default: ");
|
||||
if (Cmp(d, "void") != 0) {
|
||||
if (non_void_return) {
|
||||
if ((!directorsEnabled() || !Swig_directorclass(n)) && !newobject) {
|
||||
Append(prepare, "$r=");
|
||||
} else {
|
||||
|
|
@ -1551,7 +1574,8 @@ public:
|
|||
while (i.item) {
|
||||
Node *j = firstChild(i.item);
|
||||
while (j) {
|
||||
if (Strcmp(Getattr(j, "name"), Getattr(n, "name")) != 0) {
|
||||
String *jname = Getattr(j, "name");
|
||||
if (!jname || Strcmp(jname, Getattr(n, "name")) != 0) {
|
||||
j = nextSibling(j);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -1601,10 +1625,9 @@ public:
|
|||
Delete(args);
|
||||
args = NewString("$res=null");
|
||||
}
|
||||
SwigType *t = Getattr(current_class, "classtype");
|
||||
String *mangled_type = SwigType_manglestr(SwigType_ltype(t));
|
||||
String *mangled_type = SwigType_manglestr(Getattr(n, "type"));
|
||||
Printf(output, "\t%sfunction %s(%s) {\n", acc, methodname, args);
|
||||
Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) === '_p%s') {\n", arg0, arg0, mangled_type);
|
||||
Printf(output, "\t\tif (is_resource($%s) && get_resource_type($%s) === '%s') {\n", arg0, arg0, mangled_type);
|
||||
Printf(output, "\t\t\t$this->%s=$%s;\n", SWIG_PTR, arg0);
|
||||
Printf(output, "\t\t\treturn;\n");
|
||||
Printf(output, "\t\t}\n");
|
||||
|
|
@ -1645,7 +1668,7 @@ public:
|
|||
Printf(output, "\t\t$this->%s=%s;\n", SWIG_PTR, invoke);
|
||||
} else {
|
||||
String *classname = Swig_class_name(current_class);
|
||||
Printf(output, "\t\treturn new %s(%s);\n", classname, invoke);
|
||||
Printf(output, "\t\treturn new %s%s(%s);\n", prefix, classname, invoke);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -1665,43 +1688,33 @@ public:
|
|||
}
|
||||
}
|
||||
Printf(output, "%s", prepare);
|
||||
} else if (Cmp(d, "void") == 0) {
|
||||
} else if (!non_void_return && !hasargout) {
|
||||
if (Cmp(invoke, "$r") != 0)
|
||||
Printf(output, "\t\t%s;\n", invoke);
|
||||
} else if (is_class(d)) {
|
||||
if (Cmp(invoke, "$r") != 0)
|
||||
Printf(output, "\t\t$r=%s;\n", invoke);
|
||||
if (Len(ret_types) == 1) {
|
||||
/* If it has an abstract base, then we can't create a new
|
||||
* base object. */
|
||||
int hasabstractbase = 0;
|
||||
Node *bases = Getattr(Swig_methodclass(n), "bases");
|
||||
if (bases) {
|
||||
Iterator i = First(bases);
|
||||
while(i.item) {
|
||||
if (Getattr(i.item, "abstract")) {
|
||||
hasabstractbase = 1;
|
||||
break;
|
||||
}
|
||||
i = Next(i);
|
||||
}
|
||||
/* If d is abstract we can't create a new wrapper type d. */
|
||||
Node *d_class = classLookup(d);
|
||||
int is_abstract = 0;
|
||||
if (Getattr(d_class, "abstracts")) {
|
||||
is_abstract = 1;
|
||||
}
|
||||
if (newobject || !hasabstractbase) {
|
||||
/*
|
||||
* _p_Foo -> Foo, _p_ns__Bar -> Bar
|
||||
* TODO: do this in a more elegant way
|
||||
*/
|
||||
if (newobject || !is_abstract) {
|
||||
Printf(output, "\t\tif (is_resource($r)) {\n");
|
||||
if (Getattr(classLookup(Getattr(n, "type")), "module")) {
|
||||
/*
|
||||
* _p_Foo -> Foo, _p_ns__Bar -> Bar
|
||||
* TODO: do this in a more elegant way
|
||||
*/
|
||||
if (Len(prefix) == 0) {
|
||||
Printf(output, "\t\t\t$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n");
|
||||
} else {
|
||||
Printf(output, "\t\t\t$c='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix);
|
||||
}
|
||||
Printf(output, "\t\t\tif (!class_exists($c)) {\n");
|
||||
Printf(output, "\t\t\t\treturn new %s%s($r);\n", prefix, Getattr(classLookup(d), "sym:name"));
|
||||
Printf(output, "\t\t\t}\n");
|
||||
Printf(output, "\t\t\treturn new $c($r);\n");
|
||||
Printf(output, "\t\t\tif (class_exists($c)) return new $c($r);\n");
|
||||
Printf(output, "\t\t\treturn new %s%s($r);\n", prefix, Getattr(classLookup(d), "sym:name"));
|
||||
} else {
|
||||
Printf(output, "\t\t\t$c = new stdClass();\n");
|
||||
Printf(output, "\t\t\t$c->"SWIG_PTR" = $r;\n");
|
||||
|
|
@ -1719,7 +1732,6 @@ public:
|
|||
while (i.item) {
|
||||
SwigType *ret_type = i.item;
|
||||
i = Next(i);
|
||||
Printf(output, "\t\t");
|
||||
String *mangled = NewString("_p");
|
||||
Printf(mangled, "%s", SwigType_manglestr(ret_type));
|
||||
Node *class_node = Getattr(zend_types, mangled);
|
||||
|
|
@ -1730,7 +1742,13 @@ public:
|
|||
Delete(mangled);
|
||||
mangled = NewString(SwigType_manglestr(ret_type));
|
||||
class_node = Getattr(zend_types, mangled);
|
||||
if (!class_node) {
|
||||
// Return type isn't an object, so will be handled by the
|
||||
// !is_resource() check before the switch.
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Printf(output, "\t\t");
|
||||
if (i.item) {
|
||||
Printf(output, "case '%s': ", mangled);
|
||||
} else {
|
||||
|
|
@ -1748,7 +1766,11 @@ public:
|
|||
Printf(output, "\t\t}\n");
|
||||
}
|
||||
} else {
|
||||
Printf(output, "\t\treturn %s;\n", invoke);
|
||||
if (non_void_return) {
|
||||
Printf(output, "\t\treturn %s;\n", invoke);
|
||||
} else if (Cmp(invoke, "$r") != 0) {
|
||||
Printf(output, "\t\t%s;\n", invoke);
|
||||
}
|
||||
}
|
||||
Printf(output, "\t}\n");
|
||||
|
||||
|
|
@ -1984,7 +2006,6 @@ done:
|
|||
classnode = 0;
|
||||
|
||||
if (shadow) {
|
||||
DOH *key;
|
||||
List *baselist = Getattr(n, "bases");
|
||||
Iterator ki, base;
|
||||
|
||||
|
|
@ -1997,7 +2018,7 @@ done:
|
|||
base.item = NULL;
|
||||
}
|
||||
|
||||
if (Getattr(n, "abstract") && !GetFlag(n, "feature:notabstract")) {
|
||||
if (Getattr(n, "abstracts") && !GetFlag(n, "feature:notabstract")) {
|
||||
Printf(s_phpclasses, "abstract ");
|
||||
}
|
||||
|
||||
|
|
@ -2027,10 +2048,10 @@ done:
|
|||
// FIXME: tune this threshold...
|
||||
if (Len(shadow_set_vars) <= 2) {
|
||||
// Not many setters, so avoid call_user_func.
|
||||
while (ki.key) {
|
||||
key = ki.key;
|
||||
Printf(s_phpclasses, "\t\tif ($var === '%s') return %s($this->%s,$value);\n", key, ki.item, SWIG_PTR);
|
||||
ki = Next(ki);
|
||||
for (; ki.key; ki = Next(ki)) {
|
||||
DOH *key = ki.key;
|
||||
String *iname = ki.item;
|
||||
Printf(s_phpclasses, "\t\tif ($var === '%s') return %s($this->%s,$value);\n", key, iname, SWIG_PTR);
|
||||
}
|
||||
} else {
|
||||
Printf(s_phpclasses, "\t\t$func = '%s_'.$var.'_set';\n", shadow_classname);
|
||||
|
|
@ -2078,21 +2099,30 @@ done:
|
|||
if (ki.key) {
|
||||
// This class has getters.
|
||||
Printf(s_phpclasses, "\n\tfunction __get($var) {\n");
|
||||
// FIXME: Currently we always use call_user_func for __get, so we can
|
||||
// check and wrap the result. This is needless if all the properties
|
||||
// are primitive types. Also this doesn't handle all the cases which
|
||||
// a method returning an object does.
|
||||
Printf(s_phpclasses, "\t\t$func = '%s_'.$var.'_get';\n", shadow_classname);
|
||||
Printf(s_phpclasses, "\t\tif (function_exists($func)) {\n");
|
||||
Printf(s_phpclasses, "\t\t\t$r = call_user_func($func,$this->%s);\n", SWIG_PTR);
|
||||
Printf(s_phpclasses, "\t\t\tif (!is_resource($r)) return $r;\n");
|
||||
if (Len(prefix) == 0) {
|
||||
Printf(s_phpclasses, "\t\t\t$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n");
|
||||
} else {
|
||||
Printf(s_phpclasses, "\t\t\t$c='%s'.substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));\n", prefix);
|
||||
int non_class_getters = 0;
|
||||
for (; ki.key; ki = Next(ki)) {
|
||||
DOH *key = ki.key;
|
||||
SwigType *d = ki.item;
|
||||
if (!is_class(d)) {
|
||||
++non_class_getters;
|
||||
continue;
|
||||
}
|
||||
Printv(s_phpclasses, "\t\tif ($var === '", key, "') return new ", prefix, Getattr(classLookup(d), "sym:name"), "(", shadow_classname, "_", key, "_get($this->", SWIG_PTR, "));\n", NIL);
|
||||
}
|
||||
// FIXME: tune this threshold...
|
||||
if (non_class_getters <= 2) {
|
||||
// Not many non-class getters, so avoid call_user_func.
|
||||
for (ki = First(shadow_get_vars); non_class_getters && ki.key; ki = Next(ki)) {
|
||||
DOH *key = ki.key;
|
||||
SwigType *d = ki.item;
|
||||
if (is_class(d)) continue;
|
||||
Printv(s_phpclasses, "\t\tif ($var === '", key, "') return ", shadow_classname, "_", key, "_get($this->", SWIG_PTR, ");\n", NIL);
|
||||
--non_class_getters;
|
||||
}
|
||||
} else {
|
||||
Printf(s_phpclasses, "\t\t$func = '%s_'.$var.'_get';\n", shadow_classname);
|
||||
Printf(s_phpclasses, "\t\tif (function_exists($func)) return call_user_func($func,$this->%s);\n", SWIG_PTR);
|
||||
}
|
||||
Printf(s_phpclasses, "\t\t\treturn new $c($r);\n");
|
||||
Printf(s_phpclasses, "\t\t}\n");
|
||||
Printf(s_phpclasses, "\t\tif ($var === 'thisown') return swig_%s_get_newobject($this->%s);\n", module, SWIG_PTR);
|
||||
if (baseclass) {
|
||||
Printf(s_phpclasses, "\t\treturn %s%s::__get($var);\n", prefix, baseclass);
|
||||
|
|
@ -2224,13 +2254,13 @@ done:
|
|||
director_prot_ctor_code = NewStringEmpty();
|
||||
Printf(director_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n");
|
||||
Printf(director_prot_ctor_code, "if ( arg0->type == IS_NULL ) { /* not subclassed */\n");
|
||||
Printf(director_ctor_code, " result = (%s *)new %s(%s);\n", ctype, ctype, args);
|
||||
Printf(director_ctor_code, " %s = (%s *)new %s(%s);\n", Swig_cresult_name(), ctype, ctype, args);
|
||||
Printf(director_prot_ctor_code, " SWIG_PHP_Error(E_ERROR, \"accessing abstract class or protected constructor\");\n", name, name, args);
|
||||
if (i) {
|
||||
Insert(args, 0, ", ");
|
||||
}
|
||||
Printf(director_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s);\n}\n", ctype, sname, args);
|
||||
Printf(director_prot_ctor_code, "} else {\n result = (%s *)new SwigDirector_%s(arg0%s);\n}\n", ctype, sname, args);
|
||||
Printf(director_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||
Printf(director_prot_ctor_code, "} else {\n %s = (%s *)new SwigDirector_%s(arg0%s TSRMLS_CC);\n}\n", Swig_cresult_name(), ctype, sname, args);
|
||||
Delete(args);
|
||||
|
||||
wrapperType = directorconstructor;
|
||||
|
|
@ -2291,10 +2321,11 @@ done:
|
|||
|
||||
Append(f->code, "return;\n");
|
||||
Append(f->code, "fail:\n");
|
||||
Append(f->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
|
||||
Append(f->code, "SWIG_FAIL();\n");
|
||||
Printf(f->code, "}\n");
|
||||
|
||||
Wrapper_print(f, s_wrappers);
|
||||
DelWrapper(f);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -2347,8 +2378,13 @@ done:
|
|||
String *call;
|
||||
String *basetype = Getattr(parent, "classtype");
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 0);
|
||||
if (((const char *)Char(target))[Len(target) - 2] == '(') {
|
||||
Insert(target, Len(target) - 1, "TSRMLS_D");
|
||||
} else {
|
||||
Insert(target, Len(target) - 1, " TSRMLS_DC");
|
||||
}
|
||||
call = Swig_csuperclass_call(0, basetype, superparms);
|
||||
Printf(w->def, "%s::%s: %s, Swig::Director(self) {", classname, target, call);
|
||||
Printf(w->def, "%s::%s: %s, Swig::Director(self TSRMLS_CC) {", classname, target, call);
|
||||
Append(w->def, "}");
|
||||
Delete(target);
|
||||
Wrapper_print(w, f_directors);
|
||||
|
|
@ -2359,6 +2395,11 @@ done:
|
|||
/* constructor header */
|
||||
{
|
||||
String *target = Swig_method_decl(0, decl, classname, parms, 0, 1);
|
||||
if (((const char *)Char(target))[Len(target) - 2] == '(') {
|
||||
Insert(target, Len(target) - 1, "TSRMLS_D");
|
||||
} else {
|
||||
Insert(target, Len(target) - 1, " TSRMLS_DC");
|
||||
}
|
||||
Printf(f_directors_h, " %s;\n", target);
|
||||
Delete(target);
|
||||
}
|
||||
|
|
@ -2369,17 +2410,17 @@ done:
|
|||
int classDirectorMethod(Node *n, Node *parent, String *super) {
|
||||
int is_void = 0;
|
||||
int is_pointer = 0;
|
||||
String *decl;
|
||||
String *type;
|
||||
String *name;
|
||||
String *classname;
|
||||
String *decl = Getattr(n, "decl");
|
||||
String *returntype = Getattr(n, "type");
|
||||
String *name = Getattr(n, "name");
|
||||
String *classname = Getattr(parent, "sym:name");
|
||||
String *c_classname = Getattr(parent, "name");
|
||||
String *declaration;
|
||||
ParmList *l;
|
||||
Wrapper *w;
|
||||
String *symname = Getattr(n, "sym:name");
|
||||
String *declaration = NewStringEmpty();
|
||||
ParmList *l = Getattr(n, "parms");
|
||||
Wrapper *w = NewWrapper();
|
||||
String *tm;
|
||||
String *wrap_args = NewStringEmpty();
|
||||
String *return_type;
|
||||
String *value = Getattr(n, "value");
|
||||
String *storage = Getattr(n, "storage");
|
||||
bool pure_virtual = false;
|
||||
|
|
@ -2393,34 +2434,15 @@ done:
|
|||
}
|
||||
}
|
||||
|
||||
classname = Getattr(parent, "sym:name");
|
||||
type = Getattr(n, "type");
|
||||
name = Getattr(n, "name");
|
||||
|
||||
w = NewWrapper();
|
||||
declaration = NewStringEmpty();
|
||||
|
||||
/* determine if the method returns a pointer */
|
||||
decl = Getattr(n, "decl");
|
||||
is_pointer = SwigType_ispointer_return(decl);
|
||||
is_void = (Cmp(type, "void") == 0 && !is_pointer);
|
||||
|
||||
/* form complete return type */
|
||||
return_type = Copy(type);
|
||||
{
|
||||
SwigType *t = Copy(decl);
|
||||
SwigType *f = SwigType_pop_function(t);
|
||||
SwigType_push(return_type, t);
|
||||
Delete(f);
|
||||
Delete(t);
|
||||
}
|
||||
is_void = (Cmp(returntype, "void") == 0 && !is_pointer);
|
||||
|
||||
/* virtual method definition */
|
||||
l = Getattr(n, "parms");
|
||||
String *target;
|
||||
String *pclassname = NewStringf("SwigDirector_%s", classname);
|
||||
String *qualified_name = NewStringf("%s::%s", pclassname, name);
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : type;
|
||||
SwigType *rtype = Getattr(n, "conversion_operator") ? 0 : Getattr(n, "classDirectorMethods:type");
|
||||
target = Swig_method_decl(rtype, decl, qualified_name, l, 0, 0);
|
||||
Printf(w->def, "%s", target);
|
||||
Delete(qualified_name);
|
||||
|
|
@ -2443,7 +2465,7 @@ done:
|
|||
if (throw_parm_list)
|
||||
Swig_typemap_attach_parms("throws", throw_parm_list, 0);
|
||||
for (p = throw_parm_list; p; p = nextSibling(p)) {
|
||||
if ((tm = Getattr(p, "tmap:throws"))) {
|
||||
if (Getattr(p, "tmap:throws")) {
|
||||
if (gencomma++) {
|
||||
Append(w->def, ", ");
|
||||
Append(declaration, ", ");
|
||||
|
|
@ -2462,13 +2484,15 @@ done:
|
|||
Append(w->def, " {");
|
||||
Append(declaration, ";\n");
|
||||
|
||||
Printf(w->code, "TSRMLS_FETCH_FROM_CTX(swig_zts_ctx);\n");
|
||||
|
||||
/* declare method return value
|
||||
* if the return value is a reference or const reference, a specialized typemap must
|
||||
* handle it, including declaration of c_result ($result).
|
||||
*/
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
String *cres = SwigType_lstr(return_type, "c_result");
|
||||
String *cres = SwigType_lstr(returntype, "c_result");
|
||||
Printf(w->code, "%s;\n", cres);
|
||||
Delete(cres);
|
||||
}
|
||||
|
|
@ -2482,13 +2506,15 @@ done:
|
|||
Printf(w->code, "%s;\n", super_call);
|
||||
Delete(super_call);
|
||||
} else {
|
||||
Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\");\n", SwigType_namestr(c_classname),
|
||||
Printf(w->code, "Swig::DirectorPureVirtualException::raise(\"Attempted to invoke pure virtual method %s::%s\" TSRMLS_CC);\n", SwigType_namestr(c_classname),
|
||||
SwigType_namestr(name));
|
||||
}
|
||||
} else {
|
||||
/* attach typemaps to arguments (C/C++ -> PHP) */
|
||||
String *parse_args = NewStringEmpty();
|
||||
|
||||
Swig_director_parms_fixup(l);
|
||||
|
||||
/* remove the wrapper 'w' since it was producing spurious temps */
|
||||
Swig_typemap_attach_parms("in", l, 0);
|
||||
Swig_typemap_attach_parms("directorin", l, 0);
|
||||
|
|
@ -2504,7 +2530,6 @@ done:
|
|||
/* build argument list and type conversion string */
|
||||
idx = 0;
|
||||
p = l;
|
||||
int use_parse = 0;
|
||||
while (p) {
|
||||
if (checkAttribute(p, "tmap:in:numinputs", "0")) {
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
|
|
@ -2522,17 +2547,19 @@ done:
|
|||
if (!parse) {
|
||||
sprintf(source, "obj%d", idx++);
|
||||
String *input = NewStringf("&%s", source);
|
||||
Setattr(p, "emit:directorinput", input);
|
||||
Replaceall(tm, "$input", input);
|
||||
Delete(input);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
Printv(wrap_args, "zval ", source, ";\n", NIL);
|
||||
Printf(wrap_args, "args[%d] = &%s;\n", idx - 1, source);
|
||||
Printv(wrap_args, "INIT_ZVAL(", source, ");\n", NIL);
|
||||
|
||||
Printv(wrap_args, tm, "\n", NIL);
|
||||
Putc('O', parse_args);
|
||||
} else {
|
||||
use_parse = 1;
|
||||
Append(parse_args, parse);
|
||||
Setattr(p, "emit:directorinput", pname);
|
||||
Replaceall(tm, "$input", pname);
|
||||
Replaceall(tm, "$owner", "0");
|
||||
if (Len(tm) == 0)
|
||||
|
|
@ -2551,7 +2578,7 @@ done:
|
|||
}
|
||||
|
||||
/* exception handling */
|
||||
tm = Swig_typemap_lookup("director:except", n, "result", 0);
|
||||
tm = Swig_typemap_lookup("director:except", n, Swig_cresult_name(), 0);
|
||||
if (!tm) {
|
||||
tm = Getattr(n, "feature:director:except");
|
||||
if (tm)
|
||||
|
|
@ -2572,8 +2599,8 @@ done:
|
|||
} else {
|
||||
Printf(w->code, "zval *args[%d];\n", idx);
|
||||
}
|
||||
Append(w->code, "zval *result, funcname;\n");
|
||||
Append(w->code, "MAKE_STD_ZVAL(result);\n");
|
||||
Printf(w->code, "zval *%s, funcname;\n", Swig_cresult_name());
|
||||
Printf(w->code, "MAKE_STD_ZVAL(%s);\n", Swig_cresult_name());
|
||||
Printf(w->code, "ZVAL_STRING(&funcname, (char *)\"%s\", 0);\n", GetChar(n, "sym:name"));
|
||||
Append(w->code, "if (!swig_self) {\n");
|
||||
Append(w->code, " SWIG_PHP_Error(E_ERROR, \"this pointer is NULL\");");
|
||||
|
|
@ -2583,7 +2610,7 @@ done:
|
|||
Printv(w->code, wrap_args, NIL);
|
||||
|
||||
Append(w->code, "call_user_function(EG(function_table), (zval**)&swig_self, &funcname,\n");
|
||||
Printf(w->code, " result, %d, args TSRMLS_CC);\n", idx);
|
||||
Printf(w->code, " %s, %d, args TSRMLS_CC);\n", Swig_cresult_name(), idx);
|
||||
|
||||
if (tm) {
|
||||
Printv(w->code, Str(tm), "\n", NIL);
|
||||
|
|
@ -2599,18 +2626,10 @@ done:
|
|||
|
||||
/* marshal return value */
|
||||
if (!is_void) {
|
||||
/* this seems really silly. the node's type excludes
|
||||
* qualifier/pointer/reference markers, which have to be retrieved
|
||||
* from the decl field to construct return_type. but the typemap
|
||||
* lookup routine uses the node's type, so we have to swap in and
|
||||
* out the correct type. it's not just me, similar silliness also
|
||||
* occurs in Language::cDeclaration().
|
||||
*/
|
||||
Setattr(n, "type", return_type);
|
||||
tm = Swig_typemap_lookup("directorout", n, "result", w);
|
||||
Setattr(n, "type", type);
|
||||
tm = Swig_typemap_lookup("directorout", n, Swig_cresult_name(), w);
|
||||
if (tm != 0) {
|
||||
Replaceall(tm, "$input", "&result");
|
||||
static const String *amp_result = NewStringf("&%s", Swig_cresult_name());
|
||||
Replaceall(tm, "$input", amp_result);
|
||||
char temp[24];
|
||||
sprintf(temp, "%d", idx);
|
||||
Replaceall(tm, "$argnum", temp);
|
||||
|
|
@ -2626,7 +2645,7 @@ done:
|
|||
Delete(tm);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPEMAP_DIRECTOROUT_UNDEF, input_file, line_number,
|
||||
"Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(return_type, 0), SwigType_namestr(c_classname),
|
||||
"Unable to use return type %s in director method %s::%s (skipping method).\n", SwigType_str(returntype, 0), SwigType_namestr(c_classname),
|
||||
SwigType_namestr(name));
|
||||
status = SWIG_ERROR;
|
||||
}
|
||||
|
|
@ -2635,8 +2654,8 @@ done:
|
|||
/* marshal outputs */
|
||||
for (p = l; p;) {
|
||||
if ((tm = Getattr(p, "tmap:directorargout")) != 0) {
|
||||
Replaceall(tm, "$input", "result");
|
||||
Replaceall(tm, "$result", Getattr(p, "name"));
|
||||
Replaceall(tm, "$result", Swig_cresult_name());
|
||||
Replaceall(tm, "$input", Getattr(p, "emit:directorinput"));
|
||||
Printv(w->code, tm, "\n", NIL);
|
||||
p = Getattr(p, "tmap:directorargout:next");
|
||||
} else {
|
||||
|
|
@ -2644,7 +2663,7 @@ done:
|
|||
}
|
||||
}
|
||||
|
||||
Append(w->code, "FREE_ZVAL(result);\n");
|
||||
Printf(w->code, "FREE_ZVAL(%s);\n", Swig_cresult_name());
|
||||
|
||||
Delete(parse_args);
|
||||
Delete(cleanup);
|
||||
|
|
@ -2653,8 +2672,8 @@ done:
|
|||
|
||||
if (!is_void) {
|
||||
if (!(ignored_method && !pure_virtual)) {
|
||||
String *rettype = SwigType_str(return_type, 0);
|
||||
if (!SwigType_isreference(return_type)) {
|
||||
String *rettype = SwigType_str(returntype, 0);
|
||||
if (!SwigType_isreference(returntype)) {
|
||||
Printf(w->code, "return (%s) c_result;\n", rettype);
|
||||
} else {
|
||||
Printf(w->code, "return (%s) *c_result;\n", rettype);
|
||||
|
|
@ -2666,7 +2685,7 @@ done:
|
|||
}
|
||||
|
||||
Append(w->code, "fail:\n");
|
||||
Append(w->code, "zend_error_noreturn(SWIG_ErrorCode(),\"%s\",SWIG_ErrorMsg());\n");
|
||||
Append(w->code, "SWIG_FAIL();\n");
|
||||
Append(w->code, "}\n");
|
||||
|
||||
// We expose protected methods via an extra public inline method which makes a straight call to the wrapped class' method
|
||||
|
|
@ -2687,6 +2706,7 @@ done:
|
|||
/* emit the director method */
|
||||
if (status == SWIG_OK) {
|
||||
if (!Getattr(n, "defaultargs")) {
|
||||
Replaceall(w->code, "$symname", symname);
|
||||
Wrapper_print(w, f_directors);
|
||||
Printv(f_directors_h, declaration, NIL);
|
||||
Printv(f_directors_h, inline_extra_method, NIL);
|
||||
|
|
@ -2695,7 +2715,6 @@ done:
|
|||
|
||||
/* clean up */
|
||||
Delete(wrap_args);
|
||||
Delete(return_type);
|
||||
Delete(pclassname);
|
||||
DelWrapper(w);
|
||||
return status;
|
||||
|
|
@ -2711,7 +2730,7 @@ static PHP *maininstance = 0;
|
|||
// We use this function to be able to write out zend_register_list_destructor_ex
|
||||
// lines for most things in the type table
|
||||
// NOTE: it's a function NOT A PHP::METHOD
|
||||
extern "C" void typetrace(SwigType *ty, String *mangled, String *clientdata) {
|
||||
extern "C" void typetrace(const SwigType *ty, String *mangled, String *clientdata) {
|
||||
Node *class_node;
|
||||
if (!zend_types) {
|
||||
zend_types = NewHash();
|
||||
|
|
|
|||
|
|
@ -29,15 +29,13 @@
|
|||
*
|
||||
*/
|
||||
|
||||
char cvsroot_pike_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#include <ctype.h> // for isalnum()
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
Pike Options (available with -pike)\n\
|
||||
[None]\n\
|
||||
[no additional options]\n\
|
||||
\n";
|
||||
|
||||
class PIKE:public Language {
|
||||
|
|
@ -182,8 +180,6 @@ public:
|
|||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Delete(f_classInit);
|
||||
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -421,15 +417,15 @@ public:
|
|||
|
||||
/* Return the function value */
|
||||
if (current == CONSTRUCTOR) {
|
||||
Printv(actioncode, "THIS = (void *) result;\n", NIL);
|
||||
Printv(actioncode, "THIS = (void *) ", Swig_cresult_name(), ";\n", NIL);
|
||||
Printv(description, ", tVoid", NIL);
|
||||
} else if (current == DESTRUCTOR) {
|
||||
Printv(description, ", tVoid", NIL);
|
||||
} else {
|
||||
Printv(description, ", ", NIL);
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
actioncode = 0;
|
||||
Replaceall(tm, "$source", "result");
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Replaceall(tm, "$target", "resultobj");
|
||||
Replaceall(tm, "$result", "resultobj");
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
|
|
@ -460,15 +456,15 @@ public:
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
/* See if there is any return cleanup code */
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
|
||||
|
|
@ -578,12 +574,16 @@ public:
|
|||
String *symname = Getattr(n, "sym:name");
|
||||
SwigType *type = Getattr(n, "type");
|
||||
String *value = Getattr(n, "value");
|
||||
bool is_enum_item = (Cmp(nodeType(n), "enumitem") == 0);
|
||||
|
||||
/* Special hook for member pointer */
|
||||
if (SwigType_type(type) == T_MPOINTER) {
|
||||
/* Special hook for member pointer */
|
||||
String *wname = Swig_name_wrapper(symname);
|
||||
Printf(f_header, "static %s = %s;\n", SwigType_str(type, wname), value);
|
||||
value = wname;
|
||||
} else if (SwigType_type(type) == T_CHAR && is_enum_item) {
|
||||
type = NewSwigType(T_INT);
|
||||
Setattr(n, "type", type);
|
||||
}
|
||||
|
||||
/* Perform constant typemap substitution */
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -11,12 +11,8 @@
|
|||
* R language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_r_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
#define UNUSED(a) (void)a
|
||||
|
||||
static const double DEFAULT_NUMBER = .0000123456712312312323;
|
||||
static const int MAX_OVERLOAD_ARGS = 5;
|
||||
|
||||
|
|
@ -41,10 +37,10 @@ static String * getRTypeName(SwigType *t, int *outCount = NULL) {
|
|||
if(Strncmp(b, "struct ", 7) == 0)
|
||||
Replace(b, "struct ", "", DOH_REPLACE_FIRST);
|
||||
|
||||
/* Printf(stderr, "<getRTypeName> %s,base = %s\n", t, b);
|
||||
/* Printf(stdout, "<getRTypeName> %s,base = %s\n", t, b);
|
||||
for(i = 0; i < Len(els); i++)
|
||||
Printf(stderr, "%d) %s, ", i, Getitem(els,i));
|
||||
Printf(stderr, "\n"); */
|
||||
Printf(stdout, "%d) %s, ", i, Getitem(els,i));
|
||||
Printf(stdout, "\n"); */
|
||||
|
||||
for(i = 0; i < Len(els); i++) {
|
||||
String *el = Getitem(els, i);
|
||||
|
|
@ -94,7 +90,7 @@ static String *getRClassName(String *retType, int /*addRef*/ = 1, int upRef=0) {
|
|||
if(!l || n == 0) {
|
||||
#ifdef R_SWIG_VERBOSE
|
||||
if (debugMode)
|
||||
Printf(stderr, "SwigType_split return an empty list for %s\n",
|
||||
Printf(stdout, "SwigType_split return an empty list for %s\n",
|
||||
retType);
|
||||
#endif
|
||||
return(tmp);
|
||||
|
|
@ -150,7 +146,7 @@ static String * getRClassNameCopyStruct(String *retType, int addRef) {
|
|||
int n = Len(l);
|
||||
if(!l || n == 0) {
|
||||
#ifdef R_SWIG_VERBOSE
|
||||
Printf(stderr, "SwigType_split return an empty list for %s\n", retType);
|
||||
Printf(stdout, "SwigType_split return an empty list for %s\n", retType);
|
||||
#endif
|
||||
return(tmp);
|
||||
}
|
||||
|
|
@ -215,12 +211,15 @@ R Options (available with -r)\n\
|
|||
-copystruct - Emit R code to copy C structs (on by default)\n\
|
||||
-cppcast - Enable C++ casting operators (default) \n\
|
||||
-debug - Output debug\n\
|
||||
-dll <name> - Name of the DLL (without the .dll or .so suffix). Default is the module name.\n\
|
||||
-dll <name> - Name of the DLL (without the .dll or .so suffix).\n\
|
||||
Default is the module name.\n\
|
||||
-gc - Aggressive garbage collection\n\
|
||||
-memoryprof - Add memory profile\n\
|
||||
-namespace - Output NAMESPACE file\n\
|
||||
-no-init-code - Turn off the generation of the R_init_<pkgname> code (registration information still generated)\n\
|
||||
-package <name> - Package name for the PACKAGE argument of the R .Call() invocations. Default is the module name.\n\
|
||||
-no-init-code - Turn off the generation of the R_init_<pkgname> code\n\
|
||||
(registration information still generated)\n\
|
||||
-package <name> - Package name for the PACKAGE argument of the R .Call()\n\
|
||||
invocations. Default is the module name.\n\
|
||||
";
|
||||
|
||||
|
||||
|
|
@ -265,12 +264,9 @@ static void replaceRClass(String *tm, SwigType *type) {
|
|||
Delete(tmp); Delete(tmp_base); Delete(tmp_ref);
|
||||
}
|
||||
|
||||
static double getNumber(String *value, String *type) {
|
||||
UNUSED(type);
|
||||
|
||||
static double getNumber(String *value) {
|
||||
double d = DEFAULT_NUMBER;
|
||||
if(Char(value)) {
|
||||
// Printf(stderr, "getNumber %s %s\n", Char(value), type);
|
||||
if(sscanf(Char(value), "%lf", &d) != 1)
|
||||
return(DEFAULT_NUMBER);
|
||||
}
|
||||
|
|
@ -294,13 +290,15 @@ public:
|
|||
int membervariableHandler(Node *n);
|
||||
|
||||
int typedefHandler(Node *n);
|
||||
static List *Swig_overload_rank(Node *n,
|
||||
bool script_lang_wrapping);
|
||||
|
||||
int memberfunctionHandler(Node *n) {
|
||||
if (debugMode)
|
||||
Printf(stderr, "<memberfunctionHandler> %s %s\n",
|
||||
Printf(stdout, "<memberfunctionHandler> %s %s\n",
|
||||
Getattr(n, "name"),
|
||||
Getattr(n, "type"));
|
||||
member_name = Getattr(n, "name");
|
||||
member_name = Getattr(n, "sym:name");
|
||||
processing_class_member_function = 1;
|
||||
int status = Language::memberfunctionHandler(n);
|
||||
processing_class_member_function = 0;
|
||||
|
|
@ -499,11 +497,11 @@ int R::getFunctionPointerNumArgs(Node *n, SwigType *tt) {
|
|||
(void) tt;
|
||||
n = Getattr(n, "type");
|
||||
if (debugMode)
|
||||
Printf(stderr, "type: %s\n", n);
|
||||
Printf(stdout, "type: %s\n", n);
|
||||
|
||||
ParmList *parms = Getattr(n, "parms");
|
||||
if (debugMode)
|
||||
Printf(stderr, "parms = %p\n", parms);
|
||||
Printf(stdout, "parms = %p\n", parms);
|
||||
return ParmList_len(parms);
|
||||
}
|
||||
|
||||
|
|
@ -514,7 +512,7 @@ void R::addSMethodInfo(String *name, String *argType, int nargs) {
|
|||
if(!SMethodInfo)
|
||||
SMethodInfo = NewHash();
|
||||
if (debugMode)
|
||||
Printf(stderr, "[addMethodInfo] %s\n", name);
|
||||
Printf(stdout, "[addMethodInfo] %s\n", name);
|
||||
|
||||
Hash *tb = Getattr(SMethodInfo, name);
|
||||
|
||||
|
|
@ -545,7 +543,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
return funName;
|
||||
|
||||
if (debugMode)
|
||||
Printf(stderr, "<createFunctionPointerHandler> Defining %s\n", t);
|
||||
Printf(stdout, "<createFunctionPointerHandler> Defining %s\n", t);
|
||||
|
||||
SwigType *rettype = Copy(Getattr(n, "type"));
|
||||
SwigType *funcparams = SwigType_functionpointer_decompose(rettype);
|
||||
|
|
@ -557,13 +555,13 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
|
||||
|
||||
if (debugMode) {
|
||||
Printf(stderr, "Type: %s\n", t);
|
||||
Printf(stderr, "Return type: %s\n", SwigType_base(t));
|
||||
Printf(stdout, "Type: %s\n", t);
|
||||
Printf(stdout, "Return type: %s\n", SwigType_base(t));
|
||||
}
|
||||
|
||||
bool isVoidType = Strcmp(rettype, "void") == 0;
|
||||
if (debugMode)
|
||||
Printf(stderr, "%s is void ? %s (%s)\n", funName, isVoidType ? "yes" : "no", rettype);
|
||||
Printf(stdout, "%s is void ? %s (%s)\n", funName, isVoidType ? "yes" : "no", rettype);
|
||||
|
||||
Wrapper *f = NewWrapper();
|
||||
|
||||
|
|
@ -572,7 +570,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
Parm *p = parms;
|
||||
for (i = 0; p; p = nextSibling(p), ++i) {
|
||||
String *arg = Getattr(p, "name");
|
||||
String *lname = NewString("");
|
||||
String *lname;
|
||||
|
||||
if (!arg && Cmp(Getattr(p, "type"), "void")) {
|
||||
lname = NewStringf("s_arg%d", i+1);
|
||||
|
|
@ -610,7 +608,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
if(numArgs) {
|
||||
*numArgs = nargs;
|
||||
if (debugMode)
|
||||
Printf(stderr, "Setting number of parameters to %d\n", *numArgs);
|
||||
Printf(stdout, "Setting number of parameters to %d\n", *numArgs);
|
||||
}
|
||||
String *setExprElements = NewString("");
|
||||
|
||||
|
|
@ -618,11 +616,16 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
for(i = 0; p; i++) {
|
||||
SwigType *tt = Getattr(p, "type");
|
||||
SwigType *name = Getattr(p, "name");
|
||||
// String *lname = Getattr(p,"lname");
|
||||
Printf(f->def, "%s %s", SwigType_str(tt, 0), name);
|
||||
String *tm = Getattr(p, "tmap:out");
|
||||
if(tm) {
|
||||
Printf(f->def, "%s %s", SwigType_str(tt, 0), name);
|
||||
if(tm) {
|
||||
Replaceall(tm, "$1", name);
|
||||
if (SwigType_isreference(tt)) {
|
||||
String *tmp = NewString("");
|
||||
Append(tmp, "*");
|
||||
Append(tmp, name);
|
||||
Replaceall(tm, tmp, name);
|
||||
}
|
||||
Replaceall(tm, "$result", "r_tmp");
|
||||
replaceRClass(tm, Getattr(p,"type"));
|
||||
Replaceall(tm,"$owner", "R_SWIG_EXTERNAL");
|
||||
|
|
@ -677,12 +680,12 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
XXX Have to be a little more clever so that we can deal with struct A * - the * is getting lost.
|
||||
Is this still true? If so, will a SwigType_push() solve things?
|
||||
*/
|
||||
Parm *bbase = NewParm(rettype, "result", n);
|
||||
String *returnTM = Swig_typemap_lookup("in", bbase, "result", f);
|
||||
Parm *bbase = NewParmNode(rettype, n);
|
||||
String *returnTM = Swig_typemap_lookup("in", bbase, Swig_cresult_name(), f);
|
||||
if(returnTM) {
|
||||
String *tm = returnTM;
|
||||
Replaceall(tm,"$input", "r_swig_cb_data->retValue");
|
||||
Replaceall(tm,"$target", "result");
|
||||
Replaceall(tm,"$target", Swig_cresult_name());
|
||||
replaceRClass(tm, rettype);
|
||||
Replaceall(tm,"$owner", "R_SWIG_EXTERNAL");
|
||||
Replaceall(tm,"$disown","0");
|
||||
|
|
@ -693,11 +696,14 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
|
||||
Printv(f->code, "R_SWIG_popCallbackFunctionData(1);\n", NIL);
|
||||
Printv(f->code, "\n", UnProtectWrapupCode, NIL);
|
||||
|
||||
if(!isVoidType)
|
||||
Printv(f->code, "return result;\n", NIL);
|
||||
|
||||
if (SwigType_isreference(rettype)) {
|
||||
Printv(f->code, "return *", Swig_cresult_name(), ";\n", NIL);
|
||||
} else if(!isVoidType)
|
||||
Printv(f->code, "return ", Swig_cresult_name(), ";\n", NIL);
|
||||
|
||||
Printv(f->code, "\n}\n", NIL);
|
||||
Replaceall(f->code, "SWIG_exception_fail", "SWIG_exception_noreturn");
|
||||
|
||||
/* To coerce correctly in S, we really want to have an extra/intermediate
|
||||
function that handles the scoerceout.
|
||||
|
|
@ -718,6 +724,7 @@ String * R::createFunctionPointerHandler(SwigType *t, Node *n, int *numArgs) {
|
|||
Delete(rtype);
|
||||
Delete(rettype);
|
||||
Delete(funcparams);
|
||||
DelWrapper(f);
|
||||
|
||||
return funName;
|
||||
}
|
||||
|
|
@ -746,7 +753,7 @@ int R::cDeclaration(Node *n) {
|
|||
SwigType *t = Getattr(n, "type");
|
||||
SwigType *name = Getattr(n, "name");
|
||||
if (debugMode)
|
||||
Printf(stderr, "cDeclaration (%s): %s\n", name, SwigType_lstr(t, 0));
|
||||
Printf(stdout, "cDeclaration (%s): %s\n", name, SwigType_lstr(t, 0));
|
||||
return Language::cDeclaration(n);
|
||||
}
|
||||
#endif
|
||||
|
|
@ -829,7 +836,6 @@ int R::top(Node *n) {
|
|||
Delete(f_init);
|
||||
|
||||
Delete(s_header);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
|
||||
|
|
@ -848,7 +854,7 @@ int R::DumpCode(Node *n) {
|
|||
Printf(output_filename, "%s%s.R", SWIG_output_directory(), Rpackage);
|
||||
|
||||
#ifdef R_SWIG_VERBOSE
|
||||
Printf(stderr, "Writing S code to %s\n", output_filename);
|
||||
Printf(stdout, "Writing S code to %s\n", output_filename);
|
||||
#endif
|
||||
|
||||
File *scode = NewFile(output_filename, "w", SWIG_output_files());
|
||||
|
|
@ -863,8 +869,7 @@ int R::DumpCode(Node *n) {
|
|||
Printf(scode, "%s\n\n", s_classes);
|
||||
Printf(scode, "%s\n", sfile);
|
||||
|
||||
Close(scode);
|
||||
// Delete(scode);
|
||||
Delete(scode);
|
||||
String *outfile = Getattr(n,"outfile");
|
||||
File *runtime = NewFile(outfile,"w", SWIG_output_files());
|
||||
if (!runtime) {
|
||||
|
|
@ -878,7 +883,6 @@ int R::DumpCode(Node *n) {
|
|||
Printf(runtime, "%s\n", f_wrapper);
|
||||
Printf(runtime, "%s\n", f_init);
|
||||
|
||||
Close(runtime);
|
||||
Delete(runtime);
|
||||
|
||||
if(outputNamespaceInfo) {
|
||||
|
|
@ -899,7 +903,6 @@ int R::DumpCode(Node *n) {
|
|||
Printf(ns, "\nexportMethods(\n");
|
||||
writeListByLine(namespaceFunctions, ns, 1);
|
||||
Printf(ns, ")\n");
|
||||
Close(ns);
|
||||
Delete(ns);
|
||||
Delete(s_namespace);
|
||||
}
|
||||
|
|
@ -937,15 +940,15 @@ int R::OutputClassMethodsTable(File *) {
|
|||
if (debugMode) {
|
||||
for(i = 0; i < n ; i++ ) {
|
||||
key = Getitem(keys, i);
|
||||
Printf(stderr, "%d) %s\n", i, key);
|
||||
Printf(stdout, "%d) %s\n", i, key);
|
||||
List *els = Getattr(tb, key);
|
||||
int nels = Len(els);
|
||||
Printf(stderr, "\t");
|
||||
Printf(stdout, "\t");
|
||||
for(int j = 0; j < nels; j+=2) {
|
||||
Printf(stderr, "%s%s", Getitem(els, j), j < nels - 1 ? ", " : "");
|
||||
Printf(stderr, "%s\n", Getitem(els, j+1));
|
||||
Printf(stdout, "%s%s", Getitem(els, j), j < nels - 1 ? ", " : "");
|
||||
Printf(stdout, "%s\n", Getitem(els, j+1));
|
||||
}
|
||||
Printf(stderr, "\n");
|
||||
Printf(stdout, "\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1013,7 +1016,6 @@ int R::OutputClassMemberTable(Hash *tb, File *out) {
|
|||
int R::OutputMemberReferenceMethod(String *className, int isSet,
|
||||
List *el, File *out) {
|
||||
int numMems = Len(el), j;
|
||||
int has_getitem = 0, has_setitem = 0, has_str = 0;
|
||||
int varaccessor = 0;
|
||||
if (numMems == 0)
|
||||
return SWIG_OK;
|
||||
|
|
@ -1033,9 +1035,6 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
|
|||
if (Getattr(itemList, item))
|
||||
continue;
|
||||
Setattr(itemList, item, "1");
|
||||
if (!Strcmp(item, "__getitem__")) has_getitem = 1;
|
||||
if (!Strcmp(item, "__setitem__")) has_setitem = 1;
|
||||
if (!Strcmp(item, "__str__")) has_str = 1;
|
||||
|
||||
String *dup = Getitem(el, j + 1);
|
||||
char *ptr = Char(dup);
|
||||
|
|
@ -1103,12 +1102,11 @@ int R::OutputMemberReferenceMethod(String *className, int isSet,
|
|||
Printv(f->code, tab8, "f(x, value);\n", NIL);
|
||||
Printv(f->code, tab8, "x;\n", NIL); // make certain to return the S value.
|
||||
} else {
|
||||
Printv(f->code, tab8, "formals(f)[[1]] = x;\n", NIL);
|
||||
if (varaccessor) {
|
||||
Printv(f->code, tab8,
|
||||
"if (is.na(match(name, vaccessors))) f else f(x);\n", NIL);
|
||||
"if (is.na(match(name, vaccessors))) function(...){f(x, ...)} else f(x);\n", NIL);
|
||||
} else {
|
||||
Printv(f->code, tab8, "f;\n", NIL);
|
||||
Printv(f->code, tab8, "function(...){f(x, ...)};\n", NIL);
|
||||
}
|
||||
}
|
||||
Printf(f->code, "}\n");
|
||||
|
|
@ -1209,10 +1207,9 @@ int R::enumDeclaration(Node *n) {
|
|||
// const char *tag = Char(nodeType(c));
|
||||
// if (Strcmp(tag,"cdecl") == 0) {
|
||||
name = Getattr(c, "name");
|
||||
String *type = Getattr(c, "type");
|
||||
String *val = Getattr(c, "enumvalue");
|
||||
if(val && Char(val)) {
|
||||
int inval = (int) getNumber(val, type);
|
||||
int inval = (int) getNumber(val);
|
||||
if(inval == DEFAULT_NUMBER)
|
||||
value++;
|
||||
else
|
||||
|
|
@ -1296,11 +1293,9 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name,
|
|||
Append(l, tmp);
|
||||
// if we could put the wrapper in directly: Append(l, Copy(sfun));
|
||||
if (debugMode)
|
||||
Printf(stderr, "Adding accessor: %s (%s) => %s\n", memberName, name, tmp);
|
||||
Printf(stdout, "Adding accessor: %s (%s) => %s\n", memberName, name, tmp);
|
||||
}
|
||||
|
||||
#define Swig_overload_rank R_swig_overload_rank
|
||||
|
||||
#define MAX_OVERLOAD 256
|
||||
|
||||
struct Overloaded {
|
||||
|
|
@ -1311,7 +1306,7 @@ struct Overloaded {
|
|||
};
|
||||
|
||||
|
||||
static List * Swig_overload_rank(Node *n,
|
||||
List * R::Swig_overload_rank(Node *n,
|
||||
bool script_lang_wrapping) {
|
||||
Overloaded nodes[MAX_OVERLOAD];
|
||||
int nnodes = 0;
|
||||
|
|
@ -1369,7 +1364,9 @@ static List * Swig_overload_rank(Node *n,
|
|||
int differ = 0;
|
||||
int num_checked = 0;
|
||||
while (p1 && p2 && (num_checked < nodes[i].argc)) {
|
||||
// Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type"));
|
||||
if (debugMode) {
|
||||
Printf(stdout,"p1 = '%s', p2 = '%s'\n", Getattr(p1,"type"), Getattr(p2,"type"));
|
||||
}
|
||||
if (checkAttribute(p1,"tmap:in:numinputs","0")) {
|
||||
p1 = Getattr(p1,"tmap:in:next");
|
||||
continue;
|
||||
|
|
@ -1380,6 +1377,9 @@ static List * Swig_overload_rank(Node *n,
|
|||
}
|
||||
String *t1 = Getattr(p1,"tmap:typecheck:precedence");
|
||||
String *t2 = Getattr(p2,"tmap:typecheck:precedence");
|
||||
if (debugMode) {
|
||||
Printf(stdout,"t1 = '%s', t2 = '%s'\n", t1, t2);
|
||||
}
|
||||
if ((!t1) && (!nodes[i].error)) {
|
||||
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"Overloaded method %s not supported (no type checking rule for '%s').\n",
|
||||
|
|
@ -1560,6 +1560,9 @@ void R::dispatchFunction(Node *n) {
|
|||
|
||||
Printf(f->def,
|
||||
"`%s` <- function(...) {", sfname);
|
||||
if (debugMode) {
|
||||
Swig_print_node(n);
|
||||
}
|
||||
List *dispatch = Swig_overload_rank(n, true);
|
||||
int nfunc = Len(dispatch);
|
||||
Printv(f->code,
|
||||
|
|
@ -1594,20 +1597,59 @@ void R::dispatchFunction(Node *n) {
|
|||
}
|
||||
Printv(f->code, "if (", NIL);
|
||||
for (p =pi, j = 0 ; j < num_arguments ; j++) {
|
||||
if (debugMode) {
|
||||
Swig_print_node(p);
|
||||
}
|
||||
String *tm = Swig_typemap_lookup("rtype", p, "", 0);
|
||||
if(tm) {
|
||||
replaceRClass(tm, Getattr(p, "type"));
|
||||
}
|
||||
if (DohStrcmp(tm,"numeric")==0) {
|
||||
Printf(f->code, "%sis.numeric(argv[[%d]])",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1);
|
||||
|
||||
String *tmcheck = Swig_typemap_lookup("rtypecheck", p, "", 0);
|
||||
if (tmcheck) {
|
||||
String *tmp = NewString("");
|
||||
Printf(tmp, "argv[[%d]]", j+1);
|
||||
Replaceall(tmcheck, "$arg", tmp);
|
||||
Printf(tmp, "argtype[%d]", j+1);
|
||||
Replaceall(tmcheck, "$argtype", tmp);
|
||||
if (tm) {
|
||||
Replaceall(tmcheck, "$rtype", tm);
|
||||
}
|
||||
if (debugMode) {
|
||||
Printf(stdout, "<rtypecheck>%s\n", tmcheck);
|
||||
}
|
||||
Printf(f->code, "%s(%s)",
|
||||
j == 0? "" : " && ",
|
||||
tmcheck);
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
continue;
|
||||
}
|
||||
else {
|
||||
Printf(f->code, "%sextends(argtypes[%d], '%s')",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1,
|
||||
tm);
|
||||
if (tm) {
|
||||
if (Strcmp(tm,"numeric")==0) {
|
||||
Printf(f->code, "%sis.numeric(argv[[%d]])",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1);
|
||||
}
|
||||
else if (Strcmp(tm,"integer")==0) {
|
||||
Printf(f->code, "%s(is.integer(argv[[%d]]) || is.numeric(argv[[%d]]))",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1, j+1);
|
||||
}
|
||||
else if (Strcmp(tm,"character")==0) {
|
||||
Printf(f->code, "%sis.character(argv[[%d]])",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1);
|
||||
}
|
||||
else {
|
||||
Printf(f->code, "%sextends(argtypes[%d], '%s')",
|
||||
j == 0 ? "" : " && ",
|
||||
j+1,
|
||||
tm);
|
||||
}
|
||||
}
|
||||
if (!SwigType_ispointer(Getattr(p, "type"))) {
|
||||
Printf(f->code, " && length(argv[[%d]]) == 1",
|
||||
j+1);
|
||||
}
|
||||
p = Getattr(p, "tmap:in:next");
|
||||
}
|
||||
|
|
@ -1617,7 +1659,10 @@ void R::dispatchFunction(Node *n) {
|
|||
}
|
||||
}
|
||||
if (cur_args != -1) {
|
||||
Printv(f->code, "}", NIL);
|
||||
Printf(f->code, "} else {\n"
|
||||
"stop(\"cannot find overloaded function for %s with argtypes (\","
|
||||
"toString(argtypes),\")\");\n"
|
||||
"}", sfname);
|
||||
}
|
||||
Printv(f->code, ";\nf(...)", NIL);
|
||||
Printv(f->code, ";\n}", NIL);
|
||||
|
|
@ -1635,7 +1680,7 @@ int R::functionWrapper(Node *n) {
|
|||
String *type = Getattr(n, "type");
|
||||
|
||||
if (debugMode) {
|
||||
Printf(stderr,
|
||||
Printf(stdout,
|
||||
"<functionWrapper> %s %s %s\n", fname, iname, type);
|
||||
}
|
||||
String *overname = 0;
|
||||
|
|
@ -1654,7 +1699,7 @@ int R::functionWrapper(Node *n) {
|
|||
}
|
||||
|
||||
if (debugMode)
|
||||
Printf(stderr,
|
||||
Printf(stdout,
|
||||
"<functionWrapper> processing parameters\n");
|
||||
|
||||
|
||||
|
|
@ -1688,11 +1733,11 @@ int R::functionWrapper(Node *n) {
|
|||
}
|
||||
}
|
||||
if (debugMode)
|
||||
Printf(stderr, "<functionWrapper> unresolved_return_type %s\n",
|
||||
Printf(stdout, "<functionWrapper> unresolved_return_type %s\n",
|
||||
unresolved_return_type);
|
||||
if(processing_member_access_function) {
|
||||
if (debugMode)
|
||||
Printf(stderr, "<functionWrapper memberAccess> '%s' '%s' '%s' '%s'\n",
|
||||
Printf(stdout, "<functionWrapper memberAccess> '%s' '%s' '%s' '%s'\n",
|
||||
fname, iname, member_name, class_name);
|
||||
|
||||
if(opaqueClassDeclaration)
|
||||
|
|
@ -1722,8 +1767,7 @@ int R::functionWrapper(Node *n) {
|
|||
}
|
||||
|
||||
int i;
|
||||
int nargs, num_required, varargs;
|
||||
UNUSED(varargs);
|
||||
int nargs;
|
||||
|
||||
String *wname = Swig_name_wrapper(iname);
|
||||
Replace(wname, "_wrap", "R_swig", DOH_REPLACE_FIRST);
|
||||
|
|
@ -1752,7 +1796,7 @@ int R::functionWrapper(Node *n) {
|
|||
|
||||
// if(addCopyParam)
|
||||
if (debugMode)
|
||||
Printf(stderr, "Adding a .copy argument to %s for %s = %s\n",
|
||||
Printf(stdout, "Adding a .copy argument to %s for %s = %s\n",
|
||||
iname, type, addCopyParam ? "yes" : "no");
|
||||
|
||||
Printv(f->def, "SWIGEXPORT SEXP\n", wname, " ( ", NIL);
|
||||
|
|
@ -1772,8 +1816,6 @@ int R::functionWrapper(Node *n) {
|
|||
Setattr(n,"wrap:parms",l);
|
||||
|
||||
nargs = emit_num_arguments(l);
|
||||
num_required = emit_num_required(l);
|
||||
varargs = emit_isvarargs(l);
|
||||
|
||||
Wrapper_add_local(f, "r_nprotect", "unsigned int r_nprotect = 0");
|
||||
Wrapper_add_localv(f, "r_ans", "SEXP", "r_ans = R_NilValue", NIL);
|
||||
|
|
@ -1802,18 +1844,21 @@ int R::functionWrapper(Node *n) {
|
|||
String *lname = Getattr(p,"lname");
|
||||
|
||||
// R keyword renaming
|
||||
if (name && Swig_name_warning(p, 0, name, 0))
|
||||
name = 0;
|
||||
|
||||
/* If we have a :: in the parameter name because we are accessing a static member of a class, say, then
|
||||
we need to remove that prefix. */
|
||||
while (Strstr(name, "::")) {
|
||||
//XXX need to free.
|
||||
name = NewStringf("%s", Strchr(name, ':') + 2);
|
||||
if (debugMode)
|
||||
Printf(stderr, "+++ parameter name with :: in it %s\n", name);
|
||||
if (name) {
|
||||
if (Swig_name_warning(p, 0, name, 0)) {
|
||||
name = 0;
|
||||
} else {
|
||||
/* If we have a :: in the parameter name because we are accessing a static member of a class, say, then
|
||||
we need to remove that prefix. */
|
||||
while (Strstr(name, "::")) {
|
||||
//XXX need to free.
|
||||
name = NewStringf("%s", Strchr(name, ':') + 2);
|
||||
if (debugMode)
|
||||
Printf(stdout, "+++ parameter name with :: in it %s\n", name);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Len(name) == 0)
|
||||
if (!name || Len(name) == 0)
|
||||
name = NewStringf("s_arg%d", i+1);
|
||||
|
||||
name = replaceInitialDash(name);
|
||||
|
|
@ -1857,6 +1902,8 @@ int R::functionWrapper(Node *n) {
|
|||
"\n};\n",
|
||||
"if(is(", name, ", \"NativeSymbolInfo\")) {\n",
|
||||
name, " = ", name, "$address", ";\n}\n",
|
||||
"if(is(", name, ", \"ExternalReference\")) {\n",
|
||||
name, " = ", name, "@ref;\n}\n",
|
||||
"}; \n",
|
||||
NIL);
|
||||
} else {
|
||||
|
|
@ -1972,15 +2019,15 @@ int R::functionWrapper(Node *n) {
|
|||
String *actioncode = emit_action(n);
|
||||
|
||||
/* Deal with the explicit return value. */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
SwigType *retType = Getattr(n, "type");
|
||||
//Printf(stderr, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no");
|
||||
//Printf(stdout, "Return Value for %s, array? %s\n", retType, SwigType_isarray(retType) ? "yes" : "no");
|
||||
/* if(SwigType_isarray(retType)) {
|
||||
defineArrayAccessors(retType);
|
||||
} */
|
||||
|
||||
|
||||
Replaceall(tm,"$1", "result");
|
||||
Replaceall(tm,"$1", Swig_cresult_name());
|
||||
Replaceall(tm,"$result", "r_ans");
|
||||
replaceRClass(tm, retType);
|
||||
|
||||
|
|
@ -2040,8 +2087,8 @@ int R::functionWrapper(Node *n) {
|
|||
|
||||
/* Look to see if there is any newfree cleanup code */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result"); /* deprecated */
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name()); /* deprecated */
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
|
@ -2049,8 +2096,7 @@ int R::functionWrapper(Node *n) {
|
|||
Printv(f->code, UnProtectWrapupCode, NIL);
|
||||
|
||||
/*If the user gave us something to convert the result in */
|
||||
if ((tm = Swig_typemap_lookup("scoerceout", n,
|
||||
"result", sfun))) {
|
||||
if ((tm = Swig_typemap_lookup("scoerceout", n, Swig_cresult_name(), sfun))) {
|
||||
Replaceall(tm,"$source","ans");
|
||||
Replaceall(tm,"$result","ans");
|
||||
replaceRClass(tm, Getattr(n, "type"));
|
||||
|
|
@ -2067,7 +2113,7 @@ int R::functionWrapper(Node *n) {
|
|||
{
|
||||
String *finalizer = NewString(iname);
|
||||
Replace(finalizer, "new_", "", DOH_REPLACE_FIRST);
|
||||
Printf(sfun->code, "reg.finalizer(ans, delete_%s)\n", finalizer);
|
||||
Printf(sfun->code, "reg.finalizer(ans@ref, delete_%s)\n", finalizer);
|
||||
}
|
||||
Printf(sfun->code, "ans\n");
|
||||
}
|
||||
|
|
@ -2118,11 +2164,6 @@ int R::functionWrapper(Node *n) {
|
|||
Would like to be able to do this so that we can potentialy insert
|
||||
*/
|
||||
if(processing_member_access_function || processing_class_member_function) {
|
||||
String *tmp;
|
||||
if(member_name)
|
||||
tmp = member_name;
|
||||
else
|
||||
tmp = Getattr(n, "memberfunctionHandler:name");
|
||||
addAccessor(member_name, sfun, iname);
|
||||
}
|
||||
|
||||
|
|
@ -2261,7 +2302,7 @@ int R::classDeclaration(Node *n) {
|
|||
if(Getattr(n, "unnamed") && Strcmp(Getattr(n, "storage"), "typedef") == 0
|
||||
&& Getattr(n, "tdname") && Strcmp(Getattr(n, "tdname"), name) == 0) {
|
||||
if (debugMode)
|
||||
Printf(stderr, "Typedef in the class declaration for %s\n", name);
|
||||
Printf(stdout, "Typedef in the class declaration for %s\n", name);
|
||||
// typedefHandler(n);
|
||||
}
|
||||
|
||||
|
|
@ -2308,7 +2349,7 @@ int R::classDeclaration(Node *n) {
|
|||
elName = Getattr(c, "name");
|
||||
|
||||
String *elKind = Getattr(c, "kind");
|
||||
if (Strcmp(elKind, "variable") != 0) {
|
||||
if (!Equal(elKind, "variable")) {
|
||||
c = nextSibling(c);
|
||||
continue;
|
||||
}
|
||||
|
|
@ -2343,7 +2384,7 @@ int R::classDeclaration(Node *n) {
|
|||
|
||||
|
||||
// returns "" tp = processType(elType, c, NULL);
|
||||
// Printf(stderr, "<classDeclaration> elType %p\n", elType);
|
||||
// Printf(stdout, "<classDeclaration> elType %p\n", elType);
|
||||
// tp = getRClassNameCopyStruct(Getattr(c, "type"), 1);
|
||||
#endif
|
||||
String *elNameT = replaceInitialDash(elName);
|
||||
|
|
@ -2395,7 +2436,7 @@ int R::generateCopyRoutines(Node *n) {
|
|||
String *mangledName = SwigType_manglestr(name);
|
||||
|
||||
if (debugMode)
|
||||
Printf(stderr, "generateCopyRoutines: name = %s, %s\n", name, type);
|
||||
Printf(stdout, "generateCopyRoutines: name = %s, %s\n", name, type);
|
||||
|
||||
Printf(copyToR->def, "CopyToR%s = function(value, obj = new(\"%s\"))\n{\n",
|
||||
mangledName, name);
|
||||
|
|
@ -2410,8 +2451,7 @@ int R::generateCopyRoutines(Node *n) {
|
|||
continue;
|
||||
}
|
||||
String *elKind = Getattr(c, "kind");
|
||||
if (Strcmp(elKind, "variable") != 0) {
|
||||
Delete(elKind);
|
||||
if (!Equal(elKind, "variable")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -2478,7 +2518,7 @@ int R::typedefHandler(Node *n) {
|
|||
SwigType *tp = Getattr(n, "type");
|
||||
String *type = Getattr(n, "type");
|
||||
if (debugMode)
|
||||
Printf(stderr, "<typedefHandler> %s\n", Getattr(n, "name"));
|
||||
Printf(stdout, "<typedefHandler> %s\n", Getattr(n, "name"));
|
||||
|
||||
processType(tp, n);
|
||||
|
||||
|
|
@ -2487,7 +2527,7 @@ int R::typedefHandler(Node *n) {
|
|||
char *trueName = Char(type);
|
||||
trueName += 7;
|
||||
if (debugMode)
|
||||
Printf(stderr, "<typedefHandler> Defining S class %s\n", trueName);
|
||||
Printf(stdout, "<typedefHandler> Defining S class %s\n", trueName);
|
||||
Printf(s_classes, "setClass('_p%s', contains = 'ExternalReference')\n",
|
||||
SwigType_manglestr(name));
|
||||
}
|
||||
|
|
@ -2509,13 +2549,13 @@ int R::membervariableHandler(Node *n) {
|
|||
processing_member_access_function = 1;
|
||||
member_name = Getattr(n,"sym:name");
|
||||
if (debugMode)
|
||||
Printf(stderr, "<membervariableHandler> name = %s, sym:name = %s\n",
|
||||
Printf(stdout, "<membervariableHandler> name = %s, sym:name = %s\n",
|
||||
Getattr(n, "name"), member_name);
|
||||
|
||||
int status(Language::membervariableHandler(n));
|
||||
|
||||
if(!opaqueClassDeclaration && debugMode)
|
||||
Printf(stderr, "<membervariableHandler> %s %s\n", Getattr(n, "name"), Getattr(n, "type"));
|
||||
Printf(stdout, "<membervariableHandler> %s %s\n", Getattr(n, "name"), Getattr(n, "type"));
|
||||
|
||||
processing_member_access_function = 0;
|
||||
member_name = NULL;
|
||||
|
|
@ -2530,7 +2570,7 @@ int R::membervariableHandler(Node *n) {
|
|||
String * R::runtimeCode() {
|
||||
String *s = Swig_include_sys("rrun.swg");
|
||||
if (!s) {
|
||||
Printf(stderr, "*** Unable to open 'rrun.swg'\n");
|
||||
Printf(stdout, "*** Unable to open 'rrun.swg'\n");
|
||||
s = NewString("");
|
||||
}
|
||||
return s;
|
||||
|
|
@ -2617,6 +2657,13 @@ void R::main(int argc, char *argv[]) {
|
|||
if (cppcast) {
|
||||
Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0);
|
||||
}
|
||||
|
||||
if (debugMode) {
|
||||
Swig_typemap_search_debug_set();
|
||||
Swig_typemap_used_debug_set();
|
||||
Swig_typemap_register_debug_set();
|
||||
Swig_file_debug_set();
|
||||
}
|
||||
/// copyToR copyToC functions.
|
||||
|
||||
}
|
||||
|
|
@ -2662,7 +2709,7 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
|
|||
|
||||
SwigType *tmp = Getattr(n, "tdname");
|
||||
if (debugMode)
|
||||
Printf(stderr, "processType %s (tdname = %s)\n", Getattr(n, "name"), tmp);
|
||||
Printf(stdout, "processType %s (tdname = %s)\n", Getattr(n, "name"), tmp);
|
||||
|
||||
SwigType *td = t;
|
||||
if (expandTypedef(t) &&
|
||||
|
|
@ -2679,7 +2726,7 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
|
|||
String *b = getRTypeName(t, &count);
|
||||
if(count && b && !Getattr(SClassDefs, b)) {
|
||||
if (debugMode)
|
||||
Printf(stderr, "<processType> Defining class %s\n", b);
|
||||
Printf(stdout, "<processType> Defining class %s\n", b);
|
||||
|
||||
Printf(s_classes, "setClass('%s', contains = 'ExternalReference')\n", b);
|
||||
Setattr(SClassDefs, b, b);
|
||||
|
|
@ -2693,7 +2740,7 @@ String * R::processType(SwigType *t, Node *n, int *nargs) {
|
|||
|
||||
if(SwigType_isfunctionpointer(t)) {
|
||||
if (debugMode)
|
||||
Printf(stderr,
|
||||
Printf(stdout,
|
||||
"<processType> Defining pointer handler %s\n", t);
|
||||
|
||||
String *tmp = createFunctionPointerHandler(t, n, nargs);
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -11,8 +11,6 @@
|
|||
* A parse tree represented as Lisp s-expressions.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_s_exp_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "dohint.h"
|
||||
|
||||
|
|
@ -24,9 +22,21 @@ S-Exp Options (available with -sexp)\n\
|
|||
static File *out = 0;
|
||||
|
||||
class Sexp:public Language {
|
||||
public:
|
||||
int indent_level;
|
||||
Sexp():indent_level(0) {
|
||||
DOHHash *print_circle_hash;
|
||||
int print_circle_count;
|
||||
int hanging_parens;
|
||||
bool need_whitespace;
|
||||
bool need_newline;
|
||||
|
||||
public:
|
||||
Sexp():
|
||||
indent_level(0),
|
||||
print_circle_hash(0),
|
||||
print_circle_count(0),
|
||||
hanging_parens(0),
|
||||
need_whitespace(0),
|
||||
need_newline(0) {
|
||||
}
|
||||
|
||||
virtual ~ Sexp() {
|
||||
|
|
@ -51,12 +61,6 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
DOHHash *print_circle_hash;
|
||||
int print_circle_count;
|
||||
int hanging_parens;
|
||||
bool need_whitespace;
|
||||
bool need_newline;
|
||||
|
||||
/* Top of the parse tree */
|
||||
virtual int top(Node *n) {
|
||||
if (out == 0) {
|
||||
|
|
@ -81,7 +85,7 @@ public:
|
|||
Language::top(n);
|
||||
Printf(out, "\n");
|
||||
Printf(out, ";;; Lisp parse tree produced by SWIG\n");
|
||||
print_circle_hash = DohNewHash();
|
||||
print_circle_hash = NewHash();
|
||||
print_circle_count = 0;
|
||||
hanging_parens = 0;
|
||||
need_whitespace = 0;
|
||||
|
|
@ -310,7 +314,7 @@ public:
|
|||
close_paren();
|
||||
} else {
|
||||
// What is it?
|
||||
Printf(out, "#<DOH %s %x>", ObjType(obj)->objname, obj);
|
||||
Printf(out, "#<DOH %s %p>", ObjType(obj)->objname, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
* to SWIG, you would modify this file.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_swigmain_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include <ctype.h>
|
||||
|
||||
|
|
@ -52,6 +50,7 @@ extern "C" {
|
|||
Language *swig_uffi(void);
|
||||
Language *swig_r(void);
|
||||
Language *swig_go(void);
|
||||
Language *swig_d(void);
|
||||
}
|
||||
|
||||
struct swig_module {
|
||||
|
|
@ -70,6 +69,7 @@ static swig_module modules[] = {
|
|||
{"-clisp", swig_clisp, "CLISP"},
|
||||
{"-cffi", swig_cffi, "CFFI"},
|
||||
{"-csharp", swig_csharp, "C#"},
|
||||
{"-d", swig_d, "D"},
|
||||
{"-go", swig_go, "Go"},
|
||||
{"-guile", swig_guile, "Guile"},
|
||||
{"-java", swig_java, "Java"},
|
||||
|
|
|
|||
|
|
@ -120,6 +120,8 @@ public:
|
|||
virtual ~Language();
|
||||
virtual int emit_one(Node *n);
|
||||
|
||||
String *directorClassName(Node *n);
|
||||
|
||||
/* Parse command line options */
|
||||
|
||||
virtual void main(int argc, char *argv[]);
|
||||
|
|
@ -213,7 +215,7 @@ public:
|
|||
virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = ""); /* Add symbol */
|
||||
virtual void dumpSymbols();
|
||||
virtual Node *symbolLookup(String *s, const_String_or_char_ptr scope = ""); /* Symbol lookup */
|
||||
virtual Node *classLookup(SwigType *s); /* Class lookup */
|
||||
virtual Node *classLookup(const SwigType *s); /* Class lookup */
|
||||
virtual Node *enumLookup(SwigType *s); /* Enum lookup */
|
||||
virtual int abstractClassTest(Node *n); /* Is class really abstract? */
|
||||
virtual int is_assignable(Node *n); /* Is variable assignable? */
|
||||
|
|
@ -294,6 +296,10 @@ protected:
|
|||
/* Some language modules require additional wrappers for virtual methods not declared in sub-classes */
|
||||
virtual bool extraDirectorProtectedCPPMethodsRequired() const;
|
||||
|
||||
/* Identifies if a protected members that are generated when the allprotected option is used.
|
||||
This does not include protected virtual methods as they are turned on with the dirprot option. */
|
||||
bool isNonVirtualProtectedAccess(Node *n) const;
|
||||
|
||||
/* Director subclass comparison test */
|
||||
String *none_comparison;
|
||||
|
||||
|
|
@ -355,6 +361,7 @@ String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms);
|
|||
String *Swig_method_decl(SwigType *rtype, SwigType *decl, const_String_or_char_ptr id, List *args, int strip, int values);
|
||||
String *Swig_director_declaration(Node *n);
|
||||
void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f);
|
||||
void Swig_director_parms_fixup(ParmList *parms);
|
||||
/* directors.cxx end */
|
||||
|
||||
extern "C" {
|
||||
|
|
@ -380,9 +387,15 @@ void Wrapper_fast_dispatch_mode_set(int);
|
|||
void Wrapper_cast_dispatch_mode_set(int);
|
||||
void Wrapper_naturalvar_mode_set(int);
|
||||
|
||||
|
||||
void clean_overloaded(Node *n);
|
||||
|
||||
extern "C" {
|
||||
const char *Swig_to_string(DOH *object, int count = -1);
|
||||
const char *Swig_to_string_with_location(DOH *object, int count = -1);
|
||||
void Swig_print(DOH *object, int count = -1);
|
||||
void Swig_print_with_location(DOH *object, int count = -1);
|
||||
}
|
||||
|
||||
/* Contracts */
|
||||
|
||||
void Swig_contracts(Node *n);
|
||||
|
|
@ -395,5 +408,4 @@ void Swig_browser(Node *n, int);
|
|||
void Swig_default_allocators(Node *n);
|
||||
void Swig_process_types(Node *n);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Tcl8 language module for SWIG.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_tcl8_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
static int treduce = SWIG_cparse_template_reduce(0);
|
||||
|
|
@ -185,7 +183,7 @@ public:
|
|||
/* If shadow classing is enabled, we're going to change the module name to "_module" */
|
||||
if (itcl) {
|
||||
String *filen;
|
||||
filen = NewStringf("%s%s.itcl", Swig_file_dirname(outfile), module);
|
||||
filen = NewStringf("%s%s.itcl", SWIG_output_directory(), module);
|
||||
|
||||
Insert(module, 0, "_");
|
||||
|
||||
|
|
@ -248,7 +246,6 @@ public:
|
|||
|
||||
if (itcl) {
|
||||
Printv(f_shadow, f_shadow_stubs, "\n", NIL);
|
||||
Close(f_shadow);
|
||||
Delete(f_shadow);
|
||||
}
|
||||
|
||||
|
|
@ -259,7 +256,6 @@ public:
|
|||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Close(f_begin);
|
||||
Delete(f_runtime);
|
||||
Delete(f_begin);
|
||||
return SWIG_OK;
|
||||
|
|
@ -460,8 +456,8 @@ public:
|
|||
/* Need to redo all of this code (eventually) */
|
||||
|
||||
/* Return value if necessary */
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, "result", f, actioncode))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup_out("out", n, Swig_cresult_name(), f, actioncode))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
#ifdef SWIG_USE_RESULTOBJ
|
||||
Replaceall(tm, "$target", "resultobj");
|
||||
Replaceall(tm, "$result", "resultobj");
|
||||
|
|
@ -488,14 +484,14 @@ public:
|
|||
|
||||
/* Look for any remaining cleanup */
|
||||
if (GetFlag(n, "feature:new")) {
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("newfree", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
}
|
||||
|
||||
if ((tm = Swig_typemap_lookup("ret", n, "result", 0))) {
|
||||
Replaceall(tm, "$source", "result");
|
||||
if ((tm = Swig_typemap_lookup("ret", n, Swig_cresult_name(), 0))) {
|
||||
Replaceall(tm, "$source", Swig_cresult_name());
|
||||
Printf(f->code, "%s\n", tm);
|
||||
}
|
||||
#ifdef SWIG_USE_RESULTOBJ
|
||||
|
|
@ -531,7 +527,19 @@ public:
|
|||
Printf(df->code, "Tcl_Obj *CONST *argv = objv+1;\n");
|
||||
Printf(df->code, "int argc = objc-1;\n");
|
||||
Printv(df->code, dispatch, "\n", NIL);
|
||||
Printf(df->code, "Tcl_SetResult(interp,(char *) \"No matching function for overloaded '%s'\", TCL_STATIC);\n", iname);
|
||||
Node *sibl = n;
|
||||
while (Getattr(sibl, "sym:previousSibling"))
|
||||
sibl = Getattr(sibl, "sym:previousSibling"); // go all the way up
|
||||
String *protoTypes = NewString("");
|
||||
do {
|
||||
String *fulldecl = Swig_name_decl(sibl);
|
||||
Printf(protoTypes, "\n\" %s\\n\"", fulldecl);
|
||||
Delete(fulldecl);
|
||||
} while ((sibl = Getattr(sibl, "sym:nextSibling")));
|
||||
Printf(df->code, "Tcl_SetResult(interp,(char *) "
|
||||
"\"Wrong number or type of arguments for overloaded function '%s'.\\n\""
|
||||
"\n\" Possible C/C++ prototypes are:\\n\"%s, TCL_STATIC);\n", iname, protoTypes);
|
||||
Delete(protoTypes);
|
||||
Printf(df->code, "return TCL_ERROR;\n");
|
||||
Printv(df->code, "}\n", NIL);
|
||||
Wrapper_print(df, f_wrappers);
|
||||
|
|
@ -783,10 +791,7 @@ public:
|
|||
String *wrap_class = NewStringf("&_wrap_class_%s", mangled_classname);
|
||||
SwigType_remember_clientdata(t, wrap_class);
|
||||
|
||||
// t = Copy(Getattr(n,"classtype"));
|
||||
// SwigType_add_pointer(t);
|
||||
|
||||
String *rt = Copy(Getattr(n, "classtype"));
|
||||
String *rt = Copy(getClassType());
|
||||
SwigType_add_pointer(rt);
|
||||
|
||||
// Register the class structure with the type checker
|
||||
|
|
@ -935,7 +940,7 @@ public:
|
|||
Printv(f_shadow, " constructor { } {\n", NIL);
|
||||
Printv(f_shadow, " # This constructor will fail if called directly\n", NIL);
|
||||
Printv(f_shadow, " if { [info class] == \"::", class_name, "\" } {\n", NIL);
|
||||
Printv(f_shadow, " error \"No constructor for class ", class_name, (Getattr(n, "abstract") ? " - class is abstract" : ""), "\"\n", NIL);
|
||||
Printv(f_shadow, " error \"No constructor for class ", class_name, (Getattr(n, "abstracts") ? " - class is abstract" : ""), "\"\n", NIL);
|
||||
Printv(f_shadow, " }\n", NIL);
|
||||
Printv(f_shadow, " }\n", NIL);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
* and other information needed for compilation.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_typepass_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
|
||||
|
|
@ -40,7 +38,14 @@ class TypePass:private Dispatcher {
|
|||
Hash *classhash;
|
||||
List *normalize;
|
||||
|
||||
TypePass() {
|
||||
TypePass() :
|
||||
inclass(0),
|
||||
module(0),
|
||||
importmode(0),
|
||||
nsname(0),
|
||||
nssymname(0),
|
||||
classhash(0),
|
||||
normalize(0) {
|
||||
}
|
||||
|
||||
/* Normalize a type. Replaces type with fully qualified version */
|
||||
|
|
@ -175,21 +180,26 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
}
|
||||
if (Strcmp(nodeType(bcls), "classforward") != 0) {
|
||||
Swig_error(Getfile(cls), Getline(cls), "'%s' does not have a valid base class.\n", Getattr(cls, "name"));
|
||||
Swig_error(Getfile(bcls), Getline(bcls), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
|
||||
Swig_error(Getfile(bname), Getline(bname), "'%s' is not a valid base class.\n", SwigType_namestr(bname));
|
||||
Swig_error(Getfile(bcls), Getline(bcls), "See definition of '%s'.\n", SwigType_namestr(bname));
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(cls), Getline(cls), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bname), Getline(bname), "Base class '%s' is incomplete.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_INCOMPLETE, Getfile(bcls), Getline(bcls), "Only forward declaration '%s' was found.\n", SwigType_namestr(bname));
|
||||
clsforward = 1;
|
||||
}
|
||||
bcls = 0;
|
||||
} else {
|
||||
if (Getattr(bcls, "typepass:visit")) {
|
||||
if (!ilist)
|
||||
ilist = alist = NewList();
|
||||
Append(ilist, bcls);
|
||||
if (!Getattr(bcls, "feature:onlychildren")) {
|
||||
if (!ilist)
|
||||
ilist = alist = NewList();
|
||||
Append(ilist, bcls);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' has no name as it is an empty template instantiated with '%%template()'. Ignored.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "The %%template directive must be written before '%s' is used as a base class and be declared with a name.\n", SwigType_namestr(bname));
|
||||
}
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Base class '%s' undefined.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Base class '%s' undefined.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bcls), Getline(bcls), "'%s' must be defined before it is used as a base class.\n", SwigType_namestr(bname));
|
||||
}
|
||||
}
|
||||
|
|
@ -202,10 +212,9 @@ class TypePass:private Dispatcher {
|
|||
if (!bcls) {
|
||||
if (!clsforward) {
|
||||
if (ispublic && !Getmeta(bname, "already_warned")) {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Nothing known about base class '%s'. Ignored.\n", SwigType_namestr(bname));
|
||||
if (Strchr(bname, '<')) {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(cls), Getline(cls), "Maybe you forgot to instantiate '%s' using %%template.\n",
|
||||
SwigType_namestr(bname));
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS, Getfile(bname), Getline(bname), "Maybe you forgot to instantiate '%s' using %%template.\n", SwigType_namestr(bname));
|
||||
}
|
||||
Setmeta(bname, "already_warned", "1");
|
||||
}
|
||||
|
|
@ -255,12 +264,17 @@ class TypePass:private Dispatcher {
|
|||
Delete(smartnamestr);
|
||||
/* setup inheritance relationship between smart pointer templates */
|
||||
SwigType_inherit(smart, bsmart, 0, convcode);
|
||||
if (!GetFlag(bclass, "feature:smartptr"))
|
||||
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Base class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(bclass, "name")), SwigType_namestr(Getattr(first, "name")));
|
||||
Delete(convcode);
|
||||
Delete(bsmart);
|
||||
Delete(smart);
|
||||
} else {
|
||||
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", smartptr, clsname);
|
||||
Swig_error(Getfile(first), Getline(first), "Invalid type (%s) in 'smartptr' feature for class %s.\n", SwigType_namestr(smartptr), SwigType_namestr(clsname));
|
||||
}
|
||||
} else {
|
||||
if (GetFlag(bclass, "feature:smartptr"))
|
||||
Swig_warning(WARN_LANG_SMARTPTR_MISSING, Getfile(first), Getline(first), "Derived class '%s' of '%s' is not similarly marked as a smart pointer.\n", SwigType_namestr(Getattr(first, "name")), SwigType_namestr(Getattr(bclass, "name")));
|
||||
}
|
||||
if (!importmode) {
|
||||
String *btype = Copy(bname);
|
||||
|
|
@ -275,7 +289,7 @@ class TypePass:private Dispatcher {
|
|||
Symtab *st = Getattr(cls, "symtab");
|
||||
Symtab *bst = Getattr(bclass, "symtab");
|
||||
if (st == bst) {
|
||||
Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", Getattr(cls, "name"));
|
||||
Swig_warning(WARN_PARSE_REC_INHERITANCE, Getfile(cls), Getline(cls), "Recursive scope inheritance of '%s'.\n", SwigType_namestr(Getattr(cls, "name")));
|
||||
continue;
|
||||
}
|
||||
Symtab *s = Swig_symbol_current();
|
||||
|
|
@ -395,20 +409,27 @@ class TypePass:private Dispatcher {
|
|||
String *nname = 0;
|
||||
String *fname = 0;
|
||||
String *scopename = 0;
|
||||
String *template_default_expanded = 0;
|
||||
|
||||
normalize = NewList();
|
||||
|
||||
if (name) {
|
||||
if (SwigType_istemplate(name)) {
|
||||
// We need to fully resolve the name to make templates work correctly */
|
||||
// We need to fully resolve the name and expand default template parameters to make templates work correctly */
|
||||
Node *cn;
|
||||
fname = SwigType_typedef_resolve_all(name);
|
||||
if (Strcmp(fname, name) != 0 && (cn = Swig_symbol_clookup_local(fname, 0))) {
|
||||
SwigType *resolved_name = SwigType_typedef_resolve_all(name);
|
||||
SwigType *deftype_name = Swig_symbol_template_deftype(resolved_name, 0);
|
||||
fname = Copy(resolved_name);
|
||||
if (!Equal(resolved_name, deftype_name))
|
||||
template_default_expanded = Copy(deftype_name);
|
||||
if (!Equal(fname, name) && (cn = Swig_symbol_clookup_local(fname, 0))) {
|
||||
if ((n == cn)
|
||||
|| (Strcmp(nodeType(cn), "template") == 0)
|
||||
|| (Getattr(cn, "feature:onlychildren") != 0)
|
||||
|| (Getattr(n, "feature:onlychildren") != 0)) {
|
||||
Swig_symbol_cadd(fname, n);
|
||||
if (template_default_expanded)
|
||||
Swig_symbol_cadd(template_default_expanded, n);
|
||||
SwigType_typedef_class(fname);
|
||||
scopename = Copy(fname);
|
||||
} else {
|
||||
|
|
@ -421,6 +442,8 @@ class TypePass:private Dispatcher {
|
|||
SwigType_typedef_class(fname);
|
||||
scopename = Copy(fname);
|
||||
}
|
||||
Delete(deftype_name);
|
||||
Delete(resolved_name);
|
||||
} else {
|
||||
if ((CPlusPlus) || (unnamed)) {
|
||||
SwigType_typedef_class(name);
|
||||
|
|
@ -440,7 +463,7 @@ class TypePass:private Dispatcher {
|
|||
SwigType_typedef(unnamed, tdname);
|
||||
}
|
||||
|
||||
if (nsname) {
|
||||
if (nsname && name) {
|
||||
nname = NewStringf("%s::%s", nsname, name);
|
||||
String *tdname = Getattr(n, "tdname");
|
||||
if (tdname) {
|
||||
|
|
@ -470,6 +493,13 @@ class TypePass:private Dispatcher {
|
|||
Delete(ts);
|
||||
Setattr(n, "module", module);
|
||||
|
||||
// When a fully qualified templated type with default parameters is used in the parsed code,
|
||||
// the following additional symbols and scopes are needed for successful lookups
|
||||
if (template_default_expanded) {
|
||||
Swig_symbol_alias(template_default_expanded, Getattr(n, "symtab"));
|
||||
SwigType_scope_alias(template_default_expanded, Getattr(n, "typescope"));
|
||||
}
|
||||
|
||||
/* Normalize deferred types */
|
||||
{
|
||||
normal_node *nn = new normal_node();
|
||||
|
|
@ -489,6 +519,7 @@ class TypePass:private Dispatcher {
|
|||
Setattr(n, "name", nname);
|
||||
Delete(nname);
|
||||
}
|
||||
Delete(fname);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -518,18 +549,10 @@ class TypePass:private Dispatcher {
|
|||
|
||||
virtual int classforwardDeclaration(Node *n) {
|
||||
|
||||
/* Temporary hack. Can't do inside a class because it breaks
|
||||
C nested structure wrapping */
|
||||
|
||||
/* Can't do inside a C struct because it breaks C nested structure wrapping */
|
||||
if ((!inclass) || (CPlusPlus)) {
|
||||
String *name = Getattr(n, "name");
|
||||
String *nname;
|
||||
SwigType_typedef_class(name);
|
||||
if (nsname) {
|
||||
nname = NewStringf("%s::%s", nsname, name);
|
||||
Setattr(n, "name", nname);
|
||||
}
|
||||
|
||||
}
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -547,12 +570,9 @@ class TypePass:private Dispatcher {
|
|||
if (alias) {
|
||||
Typetab *ts = Getattr(n, "typescope");
|
||||
if (!ts) {
|
||||
Node *ns;
|
||||
/* Create a empty scope for the alias */
|
||||
ns = Getattr(n, "namespace");
|
||||
if (ns) {
|
||||
SwigType_scope_alias(name, Getattr(ns, "typescope"));
|
||||
}
|
||||
/* Create an empty scope for the alias */
|
||||
Node *ns = Getattr(n, "namespace");
|
||||
SwigType_scope_alias(name, Getattr(ns, "typescope"));
|
||||
ts = Getattr(ns, "typescope");
|
||||
Setattr(n, "typescope", ts);
|
||||
}
|
||||
|
|
@ -684,11 +704,6 @@ class TypePass:private Dispatcher {
|
|||
normalize_parms(Getattr(n, "parms"));
|
||||
normalize_parms(Getattr(n, "throws"));
|
||||
|
||||
/* If in a namespace, patch the class name */
|
||||
if (nsname) {
|
||||
String *nname = NewStringf("%s::%s", nsname, Getattr(n, "name"));
|
||||
Setattr(n, "name", nname);
|
||||
}
|
||||
clean_overloaded(n);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
|
@ -697,12 +712,7 @@ class TypePass:private Dispatcher {
|
|||
* destructorDeclaration()
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
virtual int destructorDeclaration(Node *n) {
|
||||
/* If in a namespace, patch the class name */
|
||||
if (nsname) {
|
||||
String *nname = NewStringf("%s::%s", nsname, Getattr(n, "name"));
|
||||
Setattr(n, "name", nname);
|
||||
}
|
||||
virtual int destructorDeclaration(Node *) {
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -874,7 +884,22 @@ class TypePass:private Dispatcher {
|
|||
|
||||
// Use enumDeclaration() to do all the hard work.
|
||||
// Note that no children can be emitted in a forward declaration as there aren't any.
|
||||
return enumDeclaration(n);
|
||||
int result = enumDeclaration(n);
|
||||
if (result == SWIG_OK) {
|
||||
// Detect when the real enum matching the forward enum declaration has not been parsed/declared
|
||||
SwigType *ty = SwigType_typedef_resolve_all(Getattr(n, "type"));
|
||||
Replaceall(ty, "enum ", "");
|
||||
Node *nn = Swig_symbol_clookup(ty, 0);
|
||||
|
||||
String *nodetype = nn ? nodeType(nn) : 0;
|
||||
if (nodetype) {
|
||||
if (Equal(nodetype, "enumforward")) {
|
||||
SetFlag(nn, "enumMissing");
|
||||
} // if a real enum was declared this would be an "enum" node type
|
||||
}
|
||||
Delete(ty);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
|
|
@ -996,6 +1021,7 @@ class TypePass:private Dispatcher {
|
|||
}
|
||||
Node *nn = copyNode(c);
|
||||
Delattr(nn, "access"); // access might be different from the method in the base class
|
||||
Setattr(nn, "access", Getattr(n, "access"));
|
||||
if (!Getattr(nn, "sym:name"))
|
||||
Setattr(nn, "sym:name", symname);
|
||||
|
||||
|
|
@ -1058,11 +1084,11 @@ class TypePass:private Dispatcher {
|
|||
* which is hacked. */
|
||||
if (Getattr(n, "sym:overloaded"))
|
||||
{
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
show_overloaded(n);
|
||||
#endif
|
||||
int cnt = 0;
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
Node *debugnode = n;
|
||||
show_overloaded(n);
|
||||
#endif
|
||||
if (!firstChild(n)) {
|
||||
// Remove from overloaded list ('using' node does not actually end up adding in any methods)
|
||||
Node *ps = Getattr(n, "sym:previousSibling");
|
||||
|
|
@ -1109,14 +1135,16 @@ show_overloaded(n);
|
|||
Setattr(ns, "sym:previousSibling", pp);
|
||||
Setattr(pp, "sym:nextSibling", ns);
|
||||
}
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
debugnode = firstoverloaded;
|
||||
#endif
|
||||
}
|
||||
Delattr(n, "sym:previousSibling");
|
||||
Delattr(n, "sym:nextSibling");
|
||||
Delattr(n, "sym:overloaded");
|
||||
Delattr(n, "sym:overname");
|
||||
#ifdef DEBUG_OVERLOADED
|
||||
show_overloaded(debugnode);
|
||||
show_overloaded(debugnode);
|
||||
#endif
|
||||
clean_overloaded(n); // Needed?
|
||||
}
|
||||
|
|
@ -1129,6 +1157,11 @@ show_overloaded(debugnode);
|
|||
SwigType_typedef_using(uname);
|
||||
} else if (Strcmp(ntype, "enum") == 0) {
|
||||
SwigType_typedef_using(Getattr(n, "uname"));
|
||||
} else if (Strcmp(ntype, "template") == 0) {
|
||||
/*
|
||||
Printf(stdout, "usingDeclaration template %s --- %s\n", Getattr(n, "name"), Getattr(n, "uname"));
|
||||
SwigType_typedef_using(Getattr(n, "uname"));
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,10 +13,19 @@
|
|||
|
||||
// TODO: remove remnants of lisptype
|
||||
|
||||
char cvsroot_uffi_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
static const char *usage = (char *) "\
|
||||
UFFI Options (available with -uffi)\n\
|
||||
-identifier-converter <type or funcname> - \n\
|
||||
Specifies the type of conversion to do on C identifiers\n\
|
||||
to convert them to symbols. There are two built-in\n\
|
||||
converters: 'null' and 'lispify'. The default is\n\
|
||||
'null'. If you supply a name other than one of the\n\
|
||||
built-ins, then a function by that name will be\n\
|
||||
called to convert identifiers to symbols.\n\
|
||||
";
|
||||
|
||||
class UFFI:public Language {
|
||||
public:
|
||||
|
||||
|
|
@ -36,7 +45,7 @@ static struct {
|
|||
String **entries;
|
||||
} defined_foreign_types;
|
||||
|
||||
static const char *identifier_converter = "identifier-convert-null";
|
||||
static String *identifier_converter = NewString("identifier-convert-null");
|
||||
|
||||
static int any_varargs(ParmList *pl) {
|
||||
Parm *p;
|
||||
|
|
@ -210,26 +219,20 @@ void UFFI::main(int argc, char *argv[]) {
|
|||
|
||||
/* check for built-ins */
|
||||
if (!strcmp(conv, "lispify")) {
|
||||
identifier_converter = "identifier-convert-lispify";
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString("identifier-convert-lispify");
|
||||
} else if (!strcmp(conv, "null")) {
|
||||
identifier_converter = "identifier-convert-null";
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString("identifier-convert-null");
|
||||
} else {
|
||||
/* Must be user defined */
|
||||
char *idconv = new char[strlen(conv) + 1];
|
||||
strcpy(idconv, conv);
|
||||
identifier_converter = idconv;
|
||||
Delete(identifier_converter);
|
||||
identifier_converter = NewString(conv);
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(argv[i], "-help")) {
|
||||
fprintf(stdout, "UFFI Options (available with -uffi)\n");
|
||||
fprintf(stdout,
|
||||
" -identifier-converter <type or funcname>\n"
|
||||
"\tSpecifies the type of conversion to do on C identifiers to convert\n"
|
||||
"\tthem to symbols. There are two built-in converters: 'null' and\n"
|
||||
"\t 'lispify'. The default is 'null'. If you supply a name other\n"
|
||||
"\tthan one of the built-ins, then a function by that name will be\n"
|
||||
"\tcalled to convert identifiers to symbols.\n");
|
||||
Printf(stdout, "%s\n", usage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -262,9 +265,7 @@ int UFFI::top(Node *n) {
|
|||
|
||||
Language::top(n);
|
||||
|
||||
Close(f_cl);
|
||||
Delete(f_cl); // Delete the handle, not the file
|
||||
Close(f_null);
|
||||
Delete(f_null);
|
||||
|
||||
return SWIG_OK;
|
||||
|
|
@ -274,7 +275,8 @@ int UFFI::functionWrapper(Node *n) {
|
|||
String *funcname = Getattr(n, "sym:name");
|
||||
ParmList *pl = Getattr(n, "parms");
|
||||
Parm *p;
|
||||
int argnum = 0, first = 1, varargs = 0;
|
||||
int argnum = 0, first = 1;
|
||||
// int varargs = 0;
|
||||
|
||||
//Language::functionWrapper(n);
|
||||
|
||||
|
|
@ -287,7 +289,7 @@ int UFFI::functionWrapper(Node *n) {
|
|||
Printf(f_cl, ":void");
|
||||
} else if (any_varargs(pl)) {
|
||||
Printf(f_cl, "#| varargs |#");
|
||||
varargs = 1;
|
||||
// varargs = 1;
|
||||
} else {
|
||||
for (p = pl; p; p = nextSibling(p), argnum++) {
|
||||
String *argname = Getattr(p, "name");
|
||||
|
|
@ -319,7 +321,7 @@ int UFFI::functionWrapper(Node *n) {
|
|||
//" :strings-convert t\n"
|
||||
//" :call-direct %s\n"
|
||||
//" :optimize-for-space t"
|
||||
")\n", get_ffi_type(n, Getattr(n, "type"), "result")
|
||||
")\n", get_ffi_type(n, Getattr(n, "type"), Swig_cresult_name())
|
||||
//,varargs ? "nil" : "t"
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Various utility functions.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_utils_cxx[] = "$Id$";
|
||||
|
||||
#include <swigmod.h>
|
||||
|
||||
int is_public(Node *n) {
|
||||
|
|
@ -57,7 +55,12 @@ int is_member_director(Node *member) {
|
|||
int is_non_virtual_protected_access(Node *n) {
|
||||
int result = 0;
|
||||
if (Swig_director_mode() && Swig_director_protected_mode() && Swig_all_protected_mode() && is_protected(n) && !checkAttribute(n, "storage", "virtual")) {
|
||||
if (is_member_director_helper(Getattr(n, "parentNode"), n))
|
||||
Node *parentNode = Getattr(n, "parentNode");
|
||||
// When vtable is empty, the director class does not get emitted, so a check for an empty vtable should be done.
|
||||
// However, vtable is set in Language and so is not yet set when methods in Typepass call clean_overloaded()
|
||||
// which calls is_non_virtual_protected_access. So commented out below.
|
||||
// Moving the director vtable creation into into Typepass should solve this problem.
|
||||
if (is_member_director_helper(parentNode, n) /* && Getattr(parentNode, "vtable")*/)
|
||||
result = 1;
|
||||
}
|
||||
return result;
|
||||
|
|
@ -100,3 +103,116 @@ void clean_overloaded(Node *n) {
|
|||
Delattr(n, "sym:overloaded");
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_set_max_hash_expand()
|
||||
*
|
||||
* Controls how many Hash objects are displayed when displaying nested Hash objects.
|
||||
* Makes DohSetMaxHashExpand an externally callable function (for debugger).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_set_max_hash_expand(int count) {
|
||||
SetMaxHashExpand(count);
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_get_max_hash_expand()
|
||||
*
|
||||
* Returns how many Hash objects are displayed when displaying nested Hash objects.
|
||||
* Makes DohGetMaxHashExpand an externally callable function (for debugger).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_get_max_hash_expand() {
|
||||
return GetMaxHashExpand();
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_to_doh_string()
|
||||
*
|
||||
* DOH version of Swig_to_string()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static String *Swig_to_doh_string(DOH *object, int count) {
|
||||
int old_count = Swig_get_max_hash_expand();
|
||||
if (count >= 0)
|
||||
Swig_set_max_hash_expand(count);
|
||||
|
||||
String *debug_string = object ? NewStringf("%s", object) : NewString("NULL");
|
||||
|
||||
Swig_set_max_hash_expand(old_count);
|
||||
return debug_string;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_to_doh_string_with_location()
|
||||
*
|
||||
* DOH version of Swig_to_string_with_location()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static String *Swig_to_doh_string_with_location(DOH *object, int count) {
|
||||
int old_count = Swig_get_max_hash_expand();
|
||||
if (count >= 0)
|
||||
Swig_set_max_hash_expand(count);
|
||||
|
||||
String *debug_string = Swig_stringify_with_location(object);
|
||||
|
||||
Swig_set_max_hash_expand(old_count);
|
||||
return debug_string;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_to_string()
|
||||
*
|
||||
* Swig debug - return C string representation of any DOH type.
|
||||
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
|
||||
* Note: leaks memory.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const char *Swig_to_string(DOH *object, int count) {
|
||||
return Char(Swig_to_doh_string(object, count));
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_to_string_with_location()
|
||||
*
|
||||
* Swig debug - return C string representation of any DOH type, within [] brackets
|
||||
* for Hash and List types, prefixed by line and file information.
|
||||
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
|
||||
* Note: leaks memory.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const char *Swig_to_string_with_location(DOH *object, int count) {
|
||||
return Char(Swig_to_doh_string_with_location(object, count));
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_print()
|
||||
*
|
||||
* Swig debug - display string representation of any DOH type.
|
||||
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_print(DOH *object, int count) {
|
||||
String *output = Swig_to_doh_string(object, count);
|
||||
Printf(stdout, "%s\n", output);
|
||||
Delete(output);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_to_string_with_location()
|
||||
*
|
||||
* Swig debug - display string representation of any DOH type, within [] brackets
|
||||
* for Hash and List types, prefixed by line and file information.
|
||||
* Nested Hash types expand count is value of Swig_get_max_hash_expand when count<0
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_print_with_location(DOH *object, int count) {
|
||||
String *output = Swig_to_doh_string_with_location(object, count);
|
||||
Printf(stdout, "%s\n", output);
|
||||
Delete(output);
|
||||
}
|
||||
|
||||
} // extern "C"
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* An Xml parse tree generator.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_xml_cxx[] = "$Id$";
|
||||
|
||||
#include "swigmod.h"
|
||||
|
||||
static const char *usage = "\
|
||||
|
|
@ -118,7 +116,7 @@ public:
|
|||
String *k;
|
||||
indent_level += 4;
|
||||
print_indent(0);
|
||||
Printf(out, "<attributelist id=\"%ld\" addr=\"%x\" >\n", ++id, obj);
|
||||
Printf(out, "<attributelist id=\"%ld\" addr=\"%p\" >\n", ++id, obj);
|
||||
indent_level += 4;
|
||||
Iterator ki;
|
||||
ki = First(obj);
|
||||
|
|
@ -144,6 +142,8 @@ public:
|
|||
Xml_print_kwargs(Getattr(obj, k));
|
||||
} else if (Cmp(k, "parms") == 0 || Cmp(k, "pattern") == 0) {
|
||||
Xml_print_parmlist(Getattr(obj, k));
|
||||
} else if (Cmp(k, "catchlist") == 0) {
|
||||
Xml_print_parmlist(Getattr(obj, k), "catchlist");
|
||||
} else {
|
||||
DOH *o;
|
||||
print_indent(0);
|
||||
|
|
@ -158,14 +158,14 @@ public:
|
|||
Replaceall(o, "\"", """);
|
||||
Replaceall(o, "\\", "\\\\");
|
||||
Replaceall(o, "\n", " ");
|
||||
Printf(out, "<attribute name=\"%s\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o);
|
||||
Printf(out, "<attribute name=\"%s\" value=\"%s\" id=\"%ld\" addr=\"%p\" />\n", ck, o, ++id, o);
|
||||
Delete(o);
|
||||
Delete(ck);
|
||||
} else {
|
||||
o = Getattr(obj, k);
|
||||
String *ck = NewString(k);
|
||||
Replaceall(ck, ":", "_");
|
||||
Printf(out, "<attribute name=\"%s\" value=\"%x\" id=\"%ld\" addr=\"%x\" />\n", ck, o, ++id, o);
|
||||
Printf(out, "<attribute name=\"%s\" value=\"%p\" id=\"%ld\" addr=\"%p\" />\n", ck, o, ++id, o);
|
||||
Delete(ck);
|
||||
}
|
||||
}
|
||||
|
|
@ -181,7 +181,7 @@ public:
|
|||
Node *cobj;
|
||||
|
||||
print_indent(0);
|
||||
Printf(out, "<%s id=\"%ld\" addr=\"%x\" >\n", nodeType(obj), ++id, obj);
|
||||
Printf(out, "<%s id=\"%ld\" addr=\"%p\" >\n", nodeType(obj), ++id, obj);
|
||||
Xml_print_attributes(obj);
|
||||
cobj = firstChild(obj);
|
||||
if (cobj) {
|
||||
|
|
@ -198,10 +198,10 @@ public:
|
|||
}
|
||||
|
||||
|
||||
void Xml_print_parmlist(ParmList *p) {
|
||||
void Xml_print_parmlist(ParmList *p, const char* markup = "parmlist") {
|
||||
|
||||
print_indent(0);
|
||||
Printf(out, "<parmlist id=\"%ld\" addr=\"%x\" >\n", ++id, p);
|
||||
Printf(out, "<%s id=\"%ld\" addr=\"%p\" >\n", markup, ++id, p);
|
||||
indent_level += 4;
|
||||
while (p) {
|
||||
print_indent(0);
|
||||
|
|
@ -213,19 +213,19 @@ public:
|
|||
}
|
||||
indent_level -= 4;
|
||||
print_indent(0);
|
||||
Printf(out, "</parmlist >\n");
|
||||
Printf(out, "</%s >\n", markup);
|
||||
}
|
||||
|
||||
void Xml_print_baselist(List *p) {
|
||||
|
||||
print_indent(0);
|
||||
Printf(out, "<baselist id=\"%ld\" addr=\"%x\" >\n", ++id, p);
|
||||
Printf(out, "<baselist id=\"%ld\" addr=\"%p\" >\n", ++id, p);
|
||||
indent_level += 4;
|
||||
Iterator s;
|
||||
for (s = First(p); s.item; s = Next(s)) {
|
||||
print_indent(0);
|
||||
String *item_name = Xml_escape_string(s.item);
|
||||
Printf(out, "<base name=\"%s\" id=\"%ld\" addr=\"%x\" />\n", item_name, ++id, s.item);
|
||||
Printf(out, "<base name=\"%s\" id=\"%ld\" addr=\"%p\" />\n", item_name, ++id, s.item);
|
||||
Delete(item_name);
|
||||
}
|
||||
indent_level -= 4;
|
||||
|
|
@ -249,7 +249,7 @@ public:
|
|||
void Xml_print_module(Node *p) {
|
||||
|
||||
print_indent(0);
|
||||
Printf(out, "<attribute name=\"module\" value=\"%s\" id=\"%ld\" addr=\"%x\" />\n", Getattr(p, "name"), ++id, p);
|
||||
Printf(out, "<attribute name=\"module\" value=\"%s\" id=\"%ld\" addr=\"%p\" />\n", Getattr(p, "name"), ++id, p);
|
||||
}
|
||||
|
||||
void Xml_print_kwargs(Hash *p) {
|
||||
|
|
@ -270,13 +270,13 @@ public:
|
|||
void Xml_print_hash(Hash *p, const char *markup) {
|
||||
|
||||
print_indent(0);
|
||||
Printf(out, "<%s id=\"%ld\" addr=\"%x\" >\n", markup, ++id, p);
|
||||
Printf(out, "<%s id=\"%ld\" addr=\"%p\" >\n", markup, ++id, p);
|
||||
Xml_print_attributes(p);
|
||||
indent_level += 4;
|
||||
Iterator n = First(p);
|
||||
while (n.key) {
|
||||
print_indent(0);
|
||||
Printf(out, "<%ssitem id=\"%ld\" addr=\"%x\" >\n", markup, ++id, n.item);
|
||||
Printf(out, "<%ssitem id=\"%ld\" addr=\"%p\" >\n", markup, ++id, n.item);
|
||||
Xml_print_attributes(n.item);
|
||||
print_indent(0);
|
||||
Printf(out, "</%ssitem >\n", markup);
|
||||
|
|
|
|||
|
|
@ -17,8 +17,6 @@
|
|||
* - Lines beginning with %# are stripped down to #... and passed through.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_cpp_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include "preprocessor.h"
|
||||
#include <ctype.h>
|
||||
|
|
@ -33,6 +31,10 @@ static Hash *included_files = 0;
|
|||
static List *dependencies = 0;
|
||||
static Scanner *id_scan = 0;
|
||||
static int error_as_warning = 0; /* Understand the cpp #error directive as a special #warning */
|
||||
static int expand_defined_operator = 0;
|
||||
static int macro_level = 0;
|
||||
static int macro_start_line = 0;
|
||||
static const String * macro_start_file = 0;
|
||||
|
||||
/* Test a character to see if it starts an identifier */
|
||||
#define isidentifier(c) ((isalpha(c)) || (c == '_') || (c == '$'))
|
||||
|
|
@ -40,7 +42,7 @@ static int error_as_warning = 0; /* Understand the cpp #error directive as a spe
|
|||
/* Test a character to see if it valid in an identifier (after the first letter) */
|
||||
#define isidchar(c) ((isalnum(c)) || (c == '_') || (c == '$'))
|
||||
|
||||
DOH *Preprocessor_replace(DOH *);
|
||||
static DOH *Preprocessor_replace(DOH *);
|
||||
|
||||
/* Skip whitespace */
|
||||
static void skip_whitespace(String *s, String *out) {
|
||||
|
|
@ -89,8 +91,6 @@ static String *cpp_include(const_String_or_char_ptr fn, int sysfile) {
|
|||
Setattr(included_files, file, file);
|
||||
}
|
||||
if (!s) {
|
||||
/* XXX(bhy) may not need the seek */
|
||||
/* Seek(fn, 0, SEEK_SET); */
|
||||
if (ignore_missing) {
|
||||
Swig_warning(WARN_PP_MISSING_FILE, Getfile(fn), Getline(fn), "Unable to find '%s'\n", fn);
|
||||
} else {
|
||||
|
|
@ -143,11 +143,15 @@ static String *kpp_dline = 0;
|
|||
static String *kpp_ddefine = 0;
|
||||
static String *kpp_dinclude = 0;
|
||||
static String *kpp_dimport = 0;
|
||||
static String *kpp_dbeginfile = 0;
|
||||
static String *kpp_dextern = 0;
|
||||
|
||||
static String *kpp_LINE = 0;
|
||||
static String *kpp_FILE = 0;
|
||||
|
||||
static String *kpp_hash_if = 0;
|
||||
static String *kpp_hash_elif = 0;
|
||||
|
||||
void Preprocessor_init(void) {
|
||||
Hash *s;
|
||||
|
||||
|
|
@ -176,6 +180,7 @@ void Preprocessor_init(void) {
|
|||
|
||||
kpp_dinclude = NewString("%include");
|
||||
kpp_dimport = NewString("%import");
|
||||
kpp_dbeginfile = NewString("%beginfile");
|
||||
kpp_dextern = NewString("%extern");
|
||||
kpp_ddefine = NewString("%define");
|
||||
kpp_dline = NewString("%line");
|
||||
|
|
@ -184,6 +189,9 @@ void Preprocessor_init(void) {
|
|||
kpp_LINE = NewString("__LINE__");
|
||||
kpp_FILE = NewString("__FILE__");
|
||||
|
||||
kpp_hash_if = NewString("#if");
|
||||
kpp_hash_elif = NewString("#elif");
|
||||
|
||||
cpp = NewHash();
|
||||
s = NewHash();
|
||||
Setattr(cpp, kpp_symbols, s);
|
||||
|
|
@ -221,13 +229,17 @@ void Preprocessor_delete(void) {
|
|||
|
||||
Delete(kpp_dinclude);
|
||||
Delete(kpp_dimport);
|
||||
Delete(kpp_dbeginfile);
|
||||
Delete(kpp_dextern);
|
||||
Delete(kpp_ddefine);
|
||||
Delete(kpp_dline);
|
||||
|
||||
|
||||
Delete(kpp_LINE);
|
||||
Delete(kpp_FILE);
|
||||
|
||||
Delete(kpp_hash_if);
|
||||
Delete(kpp_hash_elif);
|
||||
|
||||
Delete(cpp);
|
||||
Delete(included_files);
|
||||
Preprocessor_expr_delete();
|
||||
|
|
@ -322,6 +334,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
|
|||
|
||||
/* Now look for a macro name */
|
||||
macroname = NewStringEmpty();
|
||||
copy_location(str, macroname);
|
||||
while ((c = Getc(str)) != EOF) {
|
||||
if (c == '(') {
|
||||
argstr = NewStringEmpty();
|
||||
|
|
@ -334,7 +347,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
|
|||
Putc(c, argstr);
|
||||
}
|
||||
if (c != ')') {
|
||||
Swig_error(Getfile(str), Getline(str), "Missing \')\' in macro parameters\n");
|
||||
Swig_error(Getfile(argstr), Getline(argstr), "Missing \')\' in macro parameters\n");
|
||||
goto macro_error;
|
||||
}
|
||||
break;
|
||||
|
|
@ -350,8 +363,6 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
/*Swig_error(Getfile(str),Getline(str),"Illegal character in macro name\n");
|
||||
goto macro_error; */
|
||||
Ungetc(c, str);
|
||||
break;
|
||||
}
|
||||
|
|
@ -359,6 +370,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
|
|||
if (!swigmacro)
|
||||
skip_whitespace(str, 0);
|
||||
macrovalue = NewStringEmpty();
|
||||
copy_location(str, macrovalue);
|
||||
while ((c = Getc(str)) != EOF) {
|
||||
Putc(c, macrovalue);
|
||||
}
|
||||
|
|
@ -371,10 +383,10 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
|
|||
argname = NewStringEmpty();
|
||||
while ((c = Getc(argstr)) != EOF) {
|
||||
if (c == ',') {
|
||||
varargname = Macro_vararg_name(argname, str);
|
||||
varargname = Macro_vararg_name(argname, argstr);
|
||||
if (varargname) {
|
||||
Delete(varargname);
|
||||
Swig_error(Getfile(str), Getline(str), "Variable-length macro argument must be last parameter\n");
|
||||
Swig_error(Getfile(argstr), Getline(argstr), "Variable length macro argument must be last parameter\n");
|
||||
} else {
|
||||
Append(arglist, argname);
|
||||
}
|
||||
|
|
@ -384,13 +396,13 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
|
|||
Putc(c, argname);
|
||||
} else if (!(isspace(c) || (c == '\\'))) {
|
||||
Delete(argname);
|
||||
Swig_error(Getfile(str), Getline(str), "Illegal character in macro argument name\n");
|
||||
Swig_error(Getfile(argstr), Getline(argstr), "Illegal character in macro argument name\n");
|
||||
goto macro_error;
|
||||
}
|
||||
}
|
||||
if (Len(argname)) {
|
||||
/* Check for varargs */
|
||||
varargname = Macro_vararg_name(argname, str);
|
||||
varargname = Macro_vararg_name(argname, argstr);
|
||||
if (varargname) {
|
||||
Append(arglist, varargname);
|
||||
Delete(varargname);
|
||||
|
|
@ -508,7 +520,7 @@ Hash *Preprocessor_define(const_String_or_char_ptr _str, int swigmacro) {
|
|||
symbols = Getattr(cpp, kpp_symbols);
|
||||
if ((m1 = Getattr(symbols, macroname))) {
|
||||
if (!Checkattr(m1, kpp_value, macrovalue)) {
|
||||
Swig_error(Getfile(str), Getline(str), "Macro '%s' redefined,\n", macroname);
|
||||
Swig_error(Getfile(macroname), Getline(macroname), "Macro '%s' redefined,\n", macroname);
|
||||
Swig_error(Getfile(m1), Getline(m1), "previous definition of '%s'.\n", macroname);
|
||||
goto macro_error;
|
||||
}
|
||||
|
|
@ -551,7 +563,7 @@ void Preprocessor_undef(const_String_or_char_ptr str) {
|
|||
* Isolates macro arguments and returns them in a list. For each argument,
|
||||
* leading and trailing whitespace is stripped (ala K&R, pg. 230).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
static List *find_args(String *s) {
|
||||
static List *find_args(String *s, int ismacro, String *macro_name) {
|
||||
List *args;
|
||||
String *str;
|
||||
int c, level;
|
||||
|
|
@ -569,7 +581,8 @@ static List *find_args(String *s) {
|
|||
c = Getc(s);
|
||||
if (c != '(') {
|
||||
/* Not a macro, bail out now! */
|
||||
Seek(s, pos, SEEK_SET);
|
||||
assert(pos != -1);
|
||||
(void)Seek(s, pos, SEEK_SET);
|
||||
Delete(args);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -622,12 +635,15 @@ static List *find_args(String *s) {
|
|||
c = Getc(s);
|
||||
}
|
||||
unterm:
|
||||
Swig_error(Getfile(args), Getline(args), "Unterminated macro call.\n");
|
||||
if (ismacro)
|
||||
Swig_error(Getfile(args), Getline(args), "Unterminated call invoking macro '%s'\n", macro_name);
|
||||
else
|
||||
Swig_error(Getfile(args), Getline(args), "Unterminated call to '%s'\n", macro_name);
|
||||
return args;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* DOH *get_filename(DOH *str)
|
||||
* DOH *get_filename()
|
||||
*
|
||||
* Read a filename from str. A filename can be enclosed in quotes, angle brackets,
|
||||
* or bare.
|
||||
|
|
@ -637,7 +653,6 @@ static String *get_filename(String *str, int *sysfile) {
|
|||
String *fn;
|
||||
int c;
|
||||
|
||||
skip_whitespace(str, 0);
|
||||
fn = NewStringEmpty();
|
||||
copy_location(str, fn);
|
||||
c = Getc(str);
|
||||
|
|
@ -650,11 +665,30 @@ static String *get_filename(String *str, int *sysfile) {
|
|||
while (((c = Getc(str)) != EOF) && (c != '>'))
|
||||
Putc(c, fn);
|
||||
} else {
|
||||
String *preprocessed_str;
|
||||
Putc(c, fn);
|
||||
while (((c = Getc(str)) != EOF) && (!isspace(c)))
|
||||
Putc(c, fn);
|
||||
if (isspace(c))
|
||||
Ungetc(c, str);
|
||||
preprocessed_str = Preprocessor_replace(fn);
|
||||
Seek(preprocessed_str, 0, SEEK_SET);
|
||||
Delete(fn);
|
||||
|
||||
fn = NewStringEmpty();
|
||||
copy_location(preprocessed_str, fn);
|
||||
c = Getc(preprocessed_str);
|
||||
if (c == '\"') {
|
||||
while (((c = Getc(preprocessed_str)) != EOF) && (c != '\"'))
|
||||
Putc(c, fn);
|
||||
} else if (c == '<') {
|
||||
*sysfile = 1;
|
||||
while (((c = Getc(preprocessed_str)) != EOF) && (c != '>'))
|
||||
Putc(c, fn);
|
||||
} else {
|
||||
fn = Copy(preprocessed_str);
|
||||
}
|
||||
Delete(preprocessed_str);
|
||||
}
|
||||
Swig_filename_unescape(fn);
|
||||
Swig_filename_correct(fn);
|
||||
|
|
@ -663,9 +697,7 @@ static String *get_filename(String *str, int *sysfile) {
|
|||
}
|
||||
|
||||
static String *get_options(String *str) {
|
||||
|
||||
int c;
|
||||
skip_whitespace(str, 0);
|
||||
c = Getc(str);
|
||||
if (c == '(') {
|
||||
String *opt;
|
||||
|
|
@ -694,9 +726,12 @@ static String *get_options(String *str) {
|
|||
*
|
||||
* Perform macro expansion and return a new string. Returns NULL if some sort
|
||||
* of error occurred.
|
||||
* name - name of the macro
|
||||
* args - arguments passed to the macro
|
||||
* line_file - only used for line/file name when reporting errors
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static String *expand_macro(String *name, List *args) {
|
||||
static String *expand_macro(String *name, List *args, String *line_file) {
|
||||
String *ns;
|
||||
DOH *symbols, *macro, *margs, *mvalue, *temp, *tempa, *e;
|
||||
int i, l;
|
||||
|
|
@ -710,6 +745,14 @@ static String *expand_macro(String *name, List *args) {
|
|||
macro = Getattr(symbols, name);
|
||||
if (!macro)
|
||||
return 0;
|
||||
|
||||
if (macro_level == 0) {
|
||||
/* Store the start of the macro should the macro contain __LINE__ and __FILE__ for expansion */
|
||||
macro_start_line = Getline(args ? args : line_file);
|
||||
macro_start_file = Getfile(args ? args : line_file);
|
||||
}
|
||||
macro_level++;
|
||||
|
||||
if (Getattr(macro, kpp_expanded)) {
|
||||
ns = NewStringEmpty();
|
||||
Append(ns, name);
|
||||
|
|
@ -725,6 +768,7 @@ static String *expand_macro(String *name, List *args) {
|
|||
if (i)
|
||||
Putc(')', ns);
|
||||
}
|
||||
macro_level--;
|
||||
return ns;
|
||||
}
|
||||
|
||||
|
|
@ -759,16 +803,18 @@ static String *expand_macro(String *name, List *args) {
|
|||
/* If there are arguments, see if they match what we were given */
|
||||
if (args && (margs) && (Len(margs) != Len(args))) {
|
||||
if (Len(margs) > (1 + isvarargs))
|
||||
Swig_error(Getfile(args), Getline(args), "Macro '%s' expects %d arguments\n", name, Len(margs) - isvarargs);
|
||||
Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects %d arguments\n", name, Len(margs) - isvarargs);
|
||||
else if (Len(margs) == (1 + isvarargs))
|
||||
Swig_error(Getfile(args), Getline(args), "Macro '%s' expects 1 argument\n", name);
|
||||
Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects 1 argument\n", name);
|
||||
else
|
||||
Swig_error(Getfile(args), Getline(args), "Macro '%s' expects no arguments\n", name);
|
||||
Swig_error(macro_start_file, macro_start_line, "Macro '%s' expects no arguments\n", name);
|
||||
macro_level--;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* If the macro expects arguments, but none were supplied, we leave it in place */
|
||||
if (!args && (margs) && Len(margs) > 0) {
|
||||
macro_level--;
|
||||
return NewString(name);
|
||||
}
|
||||
|
||||
|
|
@ -922,27 +968,12 @@ static String *expand_macro(String *name, List *args) {
|
|||
Delete(e);
|
||||
e = f;
|
||||
}
|
||||
macro_level--;
|
||||
Delete(temp);
|
||||
Delete(tempa);
|
||||
return e;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* evaluate_args()
|
||||
*
|
||||
* Evaluate the arguments of a macro
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
List *evaluate_args(List *x) {
|
||||
Iterator i;
|
||||
List *nl = NewList();
|
||||
|
||||
for (i = First(x); i.item; i = Next(i)) {
|
||||
Append(nl, Preprocessor_replace(i.item));
|
||||
}
|
||||
return nl;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* DOH *Preprocessor_replace(DOH *s)
|
||||
*
|
||||
|
|
@ -954,10 +985,9 @@ List *evaluate_args(List *x) {
|
|||
|
||||
/* #define SWIG_PUT_BUFF */
|
||||
|
||||
DOH *Preprocessor_replace(DOH *s) {
|
||||
static DOH *Preprocessor_replace(DOH *s) {
|
||||
DOH *ns, *symbols, *m;
|
||||
int c, i, state = 0;
|
||||
|
||||
String *id = NewStringEmpty();
|
||||
|
||||
assert(cpp);
|
||||
|
|
@ -971,10 +1001,18 @@ DOH *Preprocessor_replace(DOH *s) {
|
|||
while ((c = Getc(s)) != EOF) {
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (isidentifier(c) || (c == '%')) {
|
||||
if (isidentifier(c)) {
|
||||
Clear(id);
|
||||
Putc(c, id);
|
||||
state = 1;
|
||||
state = 4;
|
||||
} else if (c == '%') {
|
||||
Clear(id);
|
||||
Putc(c, id);
|
||||
state = 2;
|
||||
} else if (c == '#') {
|
||||
Clear(id);
|
||||
Putc(c, id);
|
||||
state = 4;
|
||||
} else if (c == '\"') {
|
||||
Putc(c, ns);
|
||||
skip_tochar(s, '\"', ns);
|
||||
|
|
@ -984,86 +1022,123 @@ DOH *Preprocessor_replace(DOH *s) {
|
|||
} else if (c == '/') {
|
||||
Putc(c, ns);
|
||||
state = 10;
|
||||
} else if (c == '\\') {
|
||||
Putc(c, ns);
|
||||
c = Getc(s);
|
||||
if (c == '\n') {
|
||||
Putc(c, ns);
|
||||
} else {
|
||||
Ungetc(c, s);
|
||||
}
|
||||
} else if (c == '\n') {
|
||||
Putc(c, ns);
|
||||
expand_defined_operator = 0;
|
||||
} else {
|
||||
Putc(c, ns);
|
||||
}
|
||||
break;
|
||||
case 1: /* An identifier */
|
||||
case 2:
|
||||
/* Found '%#' */
|
||||
if (c == '#') {
|
||||
Putc(c, id);
|
||||
state = 4;
|
||||
} else {
|
||||
Ungetc(c, s);
|
||||
state = 4;
|
||||
}
|
||||
break;
|
||||
case 4: /* An identifier */
|
||||
if (isidchar(c)) {
|
||||
Putc(c, id);
|
||||
state = 1;
|
||||
state = 4;
|
||||
} else {
|
||||
/* We found the end of a valid identifier */
|
||||
Ungetc(c, s);
|
||||
/* See if this is the special "defined" macro */
|
||||
if (Equal(kpp_defined, id)) {
|
||||
int lenargs = 0;
|
||||
DOH *args = 0;
|
||||
/* See whether or not a paranthesis has been used */
|
||||
skip_whitespace(s, 0);
|
||||
c = Getc(s);
|
||||
if (c == '(') {
|
||||
Ungetc(c, s);
|
||||
args = find_args(s);
|
||||
} else if (isidchar(c)) {
|
||||
DOH *arg = NewStringEmpty();
|
||||
args = NewList();
|
||||
Putc(c, arg);
|
||||
while (((c = Getc(s)) != EOF)) {
|
||||
if (!isidchar(c)) {
|
||||
Ungetc(c, s);
|
||||
break;
|
||||
}
|
||||
/* See if this is the special "defined" operator */
|
||||
if (Equal(kpp_defined, id)) {
|
||||
if (expand_defined_operator) {
|
||||
int lenargs = 0;
|
||||
DOH *args = 0;
|
||||
/* See whether or not a parenthesis has been used */
|
||||
skip_whitespace(s, 0);
|
||||
c = Getc(s);
|
||||
if (c == '(') {
|
||||
Ungetc(c, s);
|
||||
args = find_args(s, 0, kpp_defined);
|
||||
} else if (isidchar(c)) {
|
||||
DOH *arg = NewStringEmpty();
|
||||
args = NewList();
|
||||
Putc(c, arg);
|
||||
while (((c = Getc(s)) != EOF)) {
|
||||
if (!isidchar(c)) {
|
||||
Ungetc(c, s);
|
||||
break;
|
||||
}
|
||||
Putc(c, arg);
|
||||
}
|
||||
if (Len(arg))
|
||||
Append(args, arg);
|
||||
Delete(arg);
|
||||
} else {
|
||||
Seek(s, -1, SEEK_CUR);
|
||||
}
|
||||
if (Len(arg))
|
||||
Append(args, arg);
|
||||
Delete(arg);
|
||||
} else {
|
||||
Seek(s, -1, SEEK_CUR);
|
||||
}
|
||||
lenargs = Len(args);
|
||||
if ((!args) || (!lenargs)) {
|
||||
/* This is not a defined() macro. */
|
||||
Append(ns, id);
|
||||
state = 0;
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < lenargs; i++) {
|
||||
DOH *o = Getitem(args, i);
|
||||
if (!Getattr(symbols, o)) {
|
||||
lenargs = Len(args);
|
||||
if ((!args) || (!lenargs)) {
|
||||
/* This is not a defined() operator. */
|
||||
Append(ns, id);
|
||||
state = 0;
|
||||
break;
|
||||
}
|
||||
for (i = 0; i < lenargs; i++) {
|
||||
DOH *o = Getitem(args, i);
|
||||
if (!Getattr(symbols, o)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i < lenargs)
|
||||
Putc('0', ns);
|
||||
else
|
||||
Putc('1', ns);
|
||||
Delete(args);
|
||||
} else {
|
||||
Append(ns, id);
|
||||
}
|
||||
if (i < lenargs)
|
||||
Putc('0', ns);
|
||||
else
|
||||
Putc('1', ns);
|
||||
Delete(args);
|
||||
state = 0;
|
||||
break;
|
||||
}
|
||||
if (Equal(kpp_LINE, id)) {
|
||||
Printf(ns, "%d", Getline(s));
|
||||
} else if (Equal(kpp_LINE, id)) {
|
||||
Printf(ns, "%d", macro_level > 0 ? macro_start_line : Getline(s));
|
||||
state = 0;
|
||||
break;
|
||||
}
|
||||
if (Equal(kpp_FILE, id)) {
|
||||
String *fn = Copy(Getfile(s));
|
||||
} else if (Equal(kpp_FILE, id)) {
|
||||
String *fn = Copy(macro_level > 0 ? macro_start_file : Getfile(s));
|
||||
Replaceall(fn, "\\", "\\\\");
|
||||
Printf(ns, "\"%s\"", fn);
|
||||
Delete(fn);
|
||||
state = 0;
|
||||
break;
|
||||
}
|
||||
/* See if the macro is defined in the preprocessor symbol table */
|
||||
if ((m = Getattr(symbols, id))) {
|
||||
} else if (Equal(kpp_hash_if, id) || Equal(kpp_hash_elif, id)) {
|
||||
expand_defined_operator = 1;
|
||||
Append(ns, id);
|
||||
/*
|
||||
} else if (Equal("%#if", id) || Equal("%#ifdef", id)) {
|
||||
Swig_warning(998, Getfile(s), Getline(s), "Found: %s preprocessor directive.\n", id);
|
||||
Append(ns, id);
|
||||
} else if (Equal("#ifdef", id) || Equal("#ifndef", id)) {
|
||||
Swig_warning(998, Getfile(s), Getline(s), "The %s preprocessor directive does not work in macros, try #if instead.\n", id);
|
||||
Append(ns, id);
|
||||
*/
|
||||
} else if ((m = Getattr(symbols, id))) {
|
||||
/* See if the macro is defined in the preprocessor symbol table */
|
||||
DOH *args = 0;
|
||||
DOH *e;
|
||||
int macro_additional_lines = 0;
|
||||
/* See if the macro expects arguments */
|
||||
if (Getattr(m, kpp_args)) {
|
||||
/* Yep. We need to go find the arguments and do a substitution */
|
||||
args = find_args(s);
|
||||
int line = Getline(s);
|
||||
args = find_args(s, 1, id);
|
||||
macro_additional_lines = Getline(s) - line;
|
||||
assert(macro_additional_lines >= 0);
|
||||
if (!Len(args)) {
|
||||
Delete(args);
|
||||
args = 0;
|
||||
|
|
@ -1071,10 +1146,13 @@ DOH *Preprocessor_replace(DOH *s) {
|
|||
} else {
|
||||
args = 0;
|
||||
}
|
||||
e = expand_macro(id, args);
|
||||
e = expand_macro(id, args, s);
|
||||
if (e) {
|
||||
Append(ns, e);
|
||||
}
|
||||
while (macro_additional_lines--) {
|
||||
Putc('\n', ns);
|
||||
}
|
||||
Delete(e);
|
||||
Delete(args);
|
||||
} else {
|
||||
|
|
@ -1096,11 +1174,15 @@ DOH *Preprocessor_replace(DOH *s) {
|
|||
Putc(c, ns);
|
||||
break;
|
||||
case 11:
|
||||
/* in C++ comment */
|
||||
Putc(c, ns);
|
||||
if (c == '\n')
|
||||
if (c == '\n') {
|
||||
expand_defined_operator = 0;
|
||||
state = 0;
|
||||
}
|
||||
break;
|
||||
case 12:
|
||||
/* in C comment */
|
||||
Putc(c, ns);
|
||||
if (c == '*')
|
||||
state = 13;
|
||||
|
|
@ -1119,19 +1201,24 @@ DOH *Preprocessor_replace(DOH *s) {
|
|||
}
|
||||
|
||||
/* Identifier at the end */
|
||||
if (state == 1) {
|
||||
/* See if this is the special "defined" macro */
|
||||
if (state == 2 || state == 4) {
|
||||
/* See if this is the special "defined" operator */
|
||||
if (Equal(kpp_defined, id)) {
|
||||
Swig_error(Getfile(s), Getline(s), "No arguments given to defined()\n");
|
||||
} else if ((m = Getattr(symbols, id))) {
|
||||
} else if (Equal(kpp_LINE, id)) {
|
||||
Printf(ns, "%d", macro_level > 0 ? macro_start_line : Getline(s));
|
||||
} else if (Equal(kpp_FILE, id)) {
|
||||
String *fn = Copy(macro_level > 0 ? macro_start_file : Getfile(s));
|
||||
Replaceall(fn, "\\", "\\\\");
|
||||
Printf(ns, "\"%s\"", fn);
|
||||
Delete(fn);
|
||||
} else if (Getattr(symbols, id)) {
|
||||
DOH *e;
|
||||
/* Yes. There is a macro here */
|
||||
/* See if the macro expects arguments */
|
||||
/* if (Getattr(m,"args")) {
|
||||
Swig_error(Getfile(id),Getline(id),"Macro arguments expected.\n");
|
||||
} */
|
||||
e = expand_macro(id, 0);
|
||||
Append(ns, e);
|
||||
e = expand_macro(id, 0, s);
|
||||
if (e)
|
||||
Append(ns, e);
|
||||
Delete(e);
|
||||
} else {
|
||||
Append(ns, id);
|
||||
|
|
@ -1239,6 +1326,7 @@ String *Preprocessor_parse(String *s) {
|
|||
int allow = 1;
|
||||
int level = 0;
|
||||
int dlevel = 0;
|
||||
int filelevel = 0;
|
||||
int mask = 0;
|
||||
int start_level = 0;
|
||||
int cpp_lines = 0;
|
||||
|
|
@ -1264,8 +1352,8 @@ String *Preprocessor_parse(String *s) {
|
|||
case 0: /* Initial state - in first column */
|
||||
/* Look for C preprocessor directives. Otherwise, go directly to state 1 */
|
||||
if (c == '#') {
|
||||
add_chunk(ns, chunk, allow);
|
||||
copy_location(s, chunk);
|
||||
add_chunk(ns, chunk, allow);
|
||||
cpp_lines = 1;
|
||||
state = 40;
|
||||
} else if (isspace(c)) {
|
||||
|
|
@ -1414,7 +1502,6 @@ String *Preprocessor_parse(String *s) {
|
|||
else if (c == '\n') {
|
||||
Putc('/', value);
|
||||
Ungetc(c, s);
|
||||
cpp_lines++;
|
||||
state = 50;
|
||||
} else {
|
||||
Putc('/', value);
|
||||
|
|
@ -1422,15 +1509,14 @@ String *Preprocessor_parse(String *s) {
|
|||
state = 43;
|
||||
}
|
||||
break;
|
||||
case 46:
|
||||
case 46: /* in C++ comment */
|
||||
if (c == '\n') {
|
||||
Ungetc(c, s);
|
||||
cpp_lines++;
|
||||
state = 50;
|
||||
} else
|
||||
Putc(c, comment);
|
||||
break;
|
||||
case 47:
|
||||
case 47: /* in C comment */
|
||||
if (c == '*')
|
||||
state = 48;
|
||||
else
|
||||
|
|
@ -1457,6 +1543,7 @@ String *Preprocessor_parse(String *s) {
|
|||
m = Preprocessor_define(value, 0);
|
||||
if ((m) && !(Getattr(m, kpp_args))) {
|
||||
v = Copy(Getattr(m, kpp_value));
|
||||
copy_location(m, v);
|
||||
if (Len(v)) {
|
||||
Swig_error_silent(1);
|
||||
v1 = Preprocessor_replace(v);
|
||||
|
|
@ -1482,9 +1569,14 @@ String *Preprocessor_parse(String *s) {
|
|||
level++;
|
||||
if (allow) {
|
||||
start_level = level;
|
||||
/* See if the identifier is in the hash table */
|
||||
if (!Getattr(symbols, value))
|
||||
if (Len(value) > 0) {
|
||||
/* See if the identifier is in the hash table */
|
||||
if (!Getattr(symbols, value))
|
||||
allow = 0;
|
||||
} else {
|
||||
Swig_error(Getfile(s), Getline(id), "Missing identifier for #ifdef.\n");
|
||||
allow = 0;
|
||||
}
|
||||
mask = 1;
|
||||
}
|
||||
} else if (Equal(id, kpp_ifndef)) {
|
||||
|
|
@ -1492,9 +1584,14 @@ String *Preprocessor_parse(String *s) {
|
|||
level++;
|
||||
if (allow) {
|
||||
start_level = level;
|
||||
/* See if the identifier is in the hash table */
|
||||
if (Getattr(symbols, value))
|
||||
if (Len(value) > 0) {
|
||||
/* See if the identifier is in the hash table */
|
||||
if (Getattr(symbols, value))
|
||||
allow = 0;
|
||||
} else {
|
||||
Swig_error(Getfile(s), Getline(id), "Missing identifier for #ifndef.\n");
|
||||
allow = 0;
|
||||
}
|
||||
mask = 1;
|
||||
}
|
||||
} else if (Equal(id, kpp_else)) {
|
||||
|
|
@ -1502,6 +1599,8 @@ String *Preprocessor_parse(String *s) {
|
|||
Swig_error(Getfile(s), Getline(id), "Misplaced #else.\n");
|
||||
} else {
|
||||
cond_lines[level - 1] = Getline(id);
|
||||
if (Len(value) != 0)
|
||||
Swig_warning(WARN_PP_UNEXPECTED_TOKENS, Getfile(s), Getline(id), "Unexpected tokens after #else directive.\n");
|
||||
if (allow) {
|
||||
allow = 0;
|
||||
mask = 0;
|
||||
|
|
@ -1516,6 +1615,8 @@ String *Preprocessor_parse(String *s) {
|
|||
level = 0;
|
||||
} else {
|
||||
if (level < start_level) {
|
||||
if (Len(value) != 0)
|
||||
Swig_warning(WARN_PP_UNEXPECTED_TOKENS, Getfile(s), Getline(id), "Unexpected tokens after #endif directive.\n");
|
||||
allow = 1;
|
||||
start_level--;
|
||||
}
|
||||
|
|
@ -1525,22 +1626,30 @@ String *Preprocessor_parse(String *s) {
|
|||
level++;
|
||||
if (allow) {
|
||||
int val;
|
||||
String *sval = Preprocessor_replace(value);
|
||||
String *sval;
|
||||
expand_defined_operator = 1;
|
||||
sval = Preprocessor_replace(value);
|
||||
start_level = level;
|
||||
Seek(sval, 0, SEEK_SET);
|
||||
/* Printf(stdout,"Evaluating '%s'\n", sval); */
|
||||
val = Preprocessor_expr(sval, &e);
|
||||
if (e) {
|
||||
char *msg = Preprocessor_expr_error();
|
||||
Seek(value, 0, SEEK_SET);
|
||||
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Could not evaluate '%s'\n", value);
|
||||
if (msg)
|
||||
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Error: '%s'\n", msg);
|
||||
allow = 0;
|
||||
} else {
|
||||
if (val == 0)
|
||||
if (Len(sval) > 0) {
|
||||
val = Preprocessor_expr(sval, &e);
|
||||
if (e) {
|
||||
const char *msg = Preprocessor_expr_error();
|
||||
Seek(value, 0, SEEK_SET);
|
||||
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Could not evaluate expression '%s'\n", value);
|
||||
if (msg)
|
||||
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Error: '%s'\n", msg);
|
||||
allow = 0;
|
||||
} else {
|
||||
if (val == 0)
|
||||
allow = 0;
|
||||
}
|
||||
} else {
|
||||
Swig_error(Getfile(s), Getline(id), "Missing expression for #if.\n");
|
||||
allow = 0;
|
||||
}
|
||||
expand_defined_operator = 0;
|
||||
mask = 1;
|
||||
}
|
||||
} else if (Equal(id, kpp_elif)) {
|
||||
|
|
@ -1553,27 +1662,35 @@ String *Preprocessor_parse(String *s) {
|
|||
mask = 0;
|
||||
} else if (level == start_level) {
|
||||
int val;
|
||||
String *sval = Preprocessor_replace(value);
|
||||
String *sval;
|
||||
expand_defined_operator = 1;
|
||||
sval = Preprocessor_replace(value);
|
||||
Seek(sval, 0, SEEK_SET);
|
||||
val = Preprocessor_expr(sval, &e);
|
||||
if (e) {
|
||||
char *msg = Preprocessor_expr_error();
|
||||
Seek(value, 0, SEEK_SET);
|
||||
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Could not evaluate '%s'\n", value);
|
||||
if (msg)
|
||||
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Error: '%s'\n", msg);
|
||||
allow = 0;
|
||||
} else {
|
||||
if (val)
|
||||
allow = 1 * mask;
|
||||
else
|
||||
if (Len(sval) > 0) {
|
||||
val = Preprocessor_expr(sval, &e);
|
||||
if (e) {
|
||||
const char *msg = Preprocessor_expr_error();
|
||||
Seek(value, 0, SEEK_SET);
|
||||
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Could not evaluate expression '%s'\n", value);
|
||||
if (msg)
|
||||
Swig_warning(WARN_PP_EVALUATION, Getfile(value), Getline(value), "Error: '%s'\n", msg);
|
||||
allow = 0;
|
||||
} else {
|
||||
if (val)
|
||||
allow = 1 * mask;
|
||||
else
|
||||
allow = 0;
|
||||
}
|
||||
} else {
|
||||
Swig_error(Getfile(s), Getline(id), "Missing expression for #elif.\n");
|
||||
allow = 0;
|
||||
}
|
||||
expand_defined_operator = 0;
|
||||
}
|
||||
}
|
||||
} else if (Equal(id, kpp_warning)) {
|
||||
if (allow) {
|
||||
Swig_warning(WARN_PP_CPP_WARNING, Getfile(s), Getline(id), "CPP #warning, %s\n", value);
|
||||
Swig_warning(WARN_PP_CPP_WARNING, Getfile(s), Getline(id), "CPP #warning, \"%s\".\n", value);
|
||||
}
|
||||
} else if (Equal(id, kpp_error)) {
|
||||
if (allow) {
|
||||
|
|
@ -1587,10 +1704,10 @@ String *Preprocessor_parse(String *s) {
|
|||
} else if (Equal(id, kpp_include)) {
|
||||
if (((include_all) || (import_all)) && (allow)) {
|
||||
String *s1, *s2, *fn;
|
||||
char *dirname;
|
||||
String *dirname;
|
||||
int sysfile = 0;
|
||||
if (include_all && import_all) {
|
||||
Swig_warning(WARN_PP_INCLUDEALL_IMPORTALL, Getfile(s), Getline(id), "Both includeall and importall are defined: using includeall\n");
|
||||
Swig_warning(WARN_PP_INCLUDEALL_IMPORTALL, Getfile(s), Getline(id), "Both includeall and importall are defined: using includeall.\n");
|
||||
import_all = 0;
|
||||
}
|
||||
Seek(value, 0, SEEK_SET);
|
||||
|
|
@ -1598,23 +1715,26 @@ String *Preprocessor_parse(String *s) {
|
|||
s1 = cpp_include(fn, sysfile);
|
||||
if (s1) {
|
||||
if (include_all)
|
||||
Printf(ns, "%%includefile \"%s\" [\n", Swig_filename_escape(Swig_last_file()));
|
||||
Printf(ns, "%%includefile \"%s\" %%beginfile\n", Swig_filename_escape(Swig_last_file()));
|
||||
else if (import_all) {
|
||||
Printf(ns, "%%importfile \"%s\" [\n", Swig_filename_escape(Swig_last_file()));
|
||||
Printf(ns, "%%importfile \"%s\" %%beginfile\n", Swig_filename_escape(Swig_last_file()));
|
||||
push_imported();
|
||||
}
|
||||
|
||||
/* See if the filename has a directory component */
|
||||
dirname = Swig_file_dirname(Swig_last_file());
|
||||
if (sysfile || !strlen(dirname))
|
||||
if (sysfile || !Len(dirname)) {
|
||||
Delete(dirname);
|
||||
dirname = 0;
|
||||
}
|
||||
if (dirname) {
|
||||
dirname[strlen(dirname) - 1] = 0; /* Kill trailing directory delimiter */
|
||||
int len = Len(dirname);
|
||||
Delslice(dirname, len - 1, len); /* Kill trailing directory delimiter */
|
||||
Swig_push_directory(dirname);
|
||||
}
|
||||
s2 = Preprocessor_parse(s1);
|
||||
addline(ns, s2, allow);
|
||||
Append(ns, "\n]");
|
||||
Append(ns, "%endoffile");
|
||||
if (dirname) {
|
||||
Swig_pop_directory();
|
||||
}
|
||||
|
|
@ -1622,8 +1742,9 @@ String *Preprocessor_parse(String *s) {
|
|||
pop_imported();
|
||||
}
|
||||
Delete(s2);
|
||||
Delete(dirname);
|
||||
Delete(s1);
|
||||
}
|
||||
Delete(s1);
|
||||
Delete(fn);
|
||||
}
|
||||
} else if (Equal(id, kpp_pragma)) {
|
||||
|
|
@ -1658,8 +1779,8 @@ String *Preprocessor_parse(String *s) {
|
|||
/* %{,%} block */
|
||||
if (c == '{') {
|
||||
start_line = Getline(s);
|
||||
add_chunk(ns, chunk, allow);
|
||||
copy_location(s, chunk);
|
||||
add_chunk(ns, chunk, allow);
|
||||
Putc('%', chunk);
|
||||
Putc(c, chunk);
|
||||
state = 105;
|
||||
|
|
@ -1720,9 +1841,11 @@ String *Preprocessor_parse(String *s) {
|
|||
Ungetc(c, s);
|
||||
/* Look for common SWIG directives */
|
||||
if (Equal(decl, kpp_dinclude) || Equal(decl, kpp_dimport) || Equal(decl, kpp_dextern)) {
|
||||
/* Got some kind of file inclusion directive */
|
||||
/* Got some kind of file inclusion directive, eg: %import(option1="value1") "filename" */
|
||||
if (allow) {
|
||||
DOH *s1, *s2, *fn, *opt;
|
||||
String *options_whitespace = NewStringEmpty();
|
||||
String *filename_whitespace = NewStringEmpty();
|
||||
int sysfile = 0;
|
||||
|
||||
if (Equal(decl, kpp_dextern)) {
|
||||
|
|
@ -1730,22 +1853,28 @@ String *Preprocessor_parse(String *s) {
|
|||
Clear(decl);
|
||||
Append(decl, "%%import");
|
||||
}
|
||||
skip_whitespace(s, options_whitespace);
|
||||
opt = get_options(s);
|
||||
|
||||
skip_whitespace(s, filename_whitespace);
|
||||
fn = get_filename(s, &sysfile);
|
||||
s1 = cpp_include(fn, sysfile);
|
||||
if (s1) {
|
||||
char *dirname;
|
||||
add_chunk(ns, chunk, allow);
|
||||
String *dirname;
|
||||
copy_location(s, chunk);
|
||||
Printf(ns, "%sfile%s \"%s\" [\n", decl, opt, Swig_filename_escape(Swig_last_file()));
|
||||
add_chunk(ns, chunk, allow);
|
||||
Printf(ns, "%sfile%s%s%s\"%s\" %%beginfile\n", decl, options_whitespace, opt, filename_whitespace, Swig_filename_escape(Swig_last_file()));
|
||||
if (Equal(decl, kpp_dimport)) {
|
||||
push_imported();
|
||||
}
|
||||
dirname = Swig_file_dirname(Swig_last_file());
|
||||
if (sysfile || !strlen(dirname))
|
||||
if (sysfile || !Len(dirname)) {
|
||||
Delete(dirname);
|
||||
dirname = 0;
|
||||
}
|
||||
if (dirname) {
|
||||
dirname[strlen(dirname) - 1] = 0; /* Kill trailing directory delimiter */
|
||||
int len = Len(dirname);
|
||||
Delslice(dirname, len - 1, len); /* Kill trailing directory delimiter */
|
||||
Swig_push_directory(dirname);
|
||||
}
|
||||
s2 = Preprocessor_parse(s1);
|
||||
|
|
@ -1756,21 +1885,32 @@ String *Preprocessor_parse(String *s) {
|
|||
pop_imported();
|
||||
}
|
||||
addline(ns, s2, allow);
|
||||
Append(ns, "\n]");
|
||||
Append(ns, "%endoffile");
|
||||
Delete(s2);
|
||||
Delete(dirname);
|
||||
Delete(s1);
|
||||
}
|
||||
Delete(fn);
|
||||
Delete(filename_whitespace);
|
||||
Delete(options_whitespace);
|
||||
}
|
||||
state = 1;
|
||||
} else if (Equal(decl, kpp_dbeginfile)) {
|
||||
/* Got an internal directive marking the beginning of an included file: %beginfile ... %endoffile */
|
||||
filelevel++;
|
||||
start_line = Getline(s);
|
||||
copy_location(s, chunk);
|
||||
add_chunk(ns, chunk, allow);
|
||||
Append(chunk, decl);
|
||||
state = 120;
|
||||
} else if (Equal(decl, kpp_dline)) {
|
||||
/* Got a line directive */
|
||||
state = 1;
|
||||
} else if (Equal(decl, kpp_ddefine)) {
|
||||
/* Got a define directive */
|
||||
dlevel++;
|
||||
add_chunk(ns, chunk, allow);
|
||||
copy_location(s, chunk);
|
||||
add_chunk(ns, chunk, allow);
|
||||
Clear(value);
|
||||
copy_location(s, value);
|
||||
state = 150;
|
||||
|
|
@ -1783,6 +1923,40 @@ String *Preprocessor_parse(String *s) {
|
|||
}
|
||||
break;
|
||||
|
||||
/* Searching for the end of a %beginfile block */
|
||||
case 120:
|
||||
Putc(c, chunk);
|
||||
if (c == '%') {
|
||||
const char *bf = "beginfile";
|
||||
const char *ef = "endoffile";
|
||||
char statement[10];
|
||||
int i = 0;
|
||||
for (i = 0; i < 9;) {
|
||||
c = Getc(s);
|
||||
Putc(c, chunk);
|
||||
statement[i++] = (char)c;
|
||||
if (strncmp(statement, bf, i) && strncmp(statement, ef, i))
|
||||
break;
|
||||
}
|
||||
c = Getc(s);
|
||||
Ungetc(c, s);
|
||||
if ((i == 9) && (isspace(c))) {
|
||||
if (strncmp(statement, bf, i) == 0) {
|
||||
++filelevel;
|
||||
} else if (strncmp(statement, ef, i) == 0) {
|
||||
--filelevel;
|
||||
if (!filelevel) {
|
||||
/* Reached end of included file */
|
||||
addline(ns, chunk, allow);
|
||||
Clear(chunk);
|
||||
copy_location(s, chunk);
|
||||
state = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* Searching for the end of a %define statement */
|
||||
case 150:
|
||||
Putc(c, value);
|
||||
|
|
@ -1815,7 +1989,6 @@ String *Preprocessor_parse(String *s) {
|
|||
Seek(value, 0, SEEK_SET);
|
||||
Preprocessor_define(value, 1);
|
||||
}
|
||||
/* Putc('\n',ns); */
|
||||
addline(ns, value, 0);
|
||||
state = 0;
|
||||
}
|
||||
|
|
@ -1834,6 +2007,9 @@ String *Preprocessor_parse(String *s) {
|
|||
Swig_error(Getfile(s), -1, "Missing #endif for conditional starting on line %d\n", cond_lines[level - 1]);
|
||||
level--;
|
||||
}
|
||||
if (state == 120) {
|
||||
Swig_error(Getfile(s), -1, "Missing %%endoffile for file inclusion block starting on line %d\n", start_line);
|
||||
}
|
||||
if (state == 150) {
|
||||
Seek(value, 0, SEEK_SET);
|
||||
Swig_error(Getfile(s), -1, "Missing %%enddef for macro starting on line %d\n", Getline(value));
|
||||
|
|
@ -1844,8 +2020,9 @@ String *Preprocessor_parse(String *s) {
|
|||
if ((state >= 30) && (state < 40)) {
|
||||
Swig_error(Getfile(s), -1, "Unterminated comment starting on line %d\n", start_line);
|
||||
}
|
||||
add_chunk(ns, chunk, allow);
|
||||
|
||||
copy_location(s, chunk);
|
||||
add_chunk(ns, chunk, allow);
|
||||
|
||||
/* DelScope(scp); */
|
||||
Delete(decl);
|
||||
|
|
@ -1854,6 +2031,5 @@ String *Preprocessor_parse(String *s) {
|
|||
Delete(comment);
|
||||
Delete(chunk);
|
||||
|
||||
/* fprintf(stderr,"cpp: %d\n", Len(Getattr(cpp,"symbols"))); */
|
||||
return ns;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
* encountered during preprocessing.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_expr_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include "preprocessor.h"
|
||||
|
||||
|
|
@ -35,7 +33,7 @@ static exprval stack[256]; /* Parsing stack */
|
|||
static int sp = 0; /* Stack pointer */
|
||||
static int prec[256]; /* Precedence rules */
|
||||
static int expr_init = 0; /* Initialization flag */
|
||||
static char *errmsg = 0; /* Parsing error */
|
||||
static const char *errmsg = 0; /* Parsing error */
|
||||
|
||||
/* Initialize the precedence table for various operators. Low values have higher precedence */
|
||||
static void init_precedence() {
|
||||
|
|
@ -298,16 +296,16 @@ int Preprocessor_expr(DOH *s, int *error) {
|
|||
stack[sp++].op = EXPR_OP;
|
||||
stack[sp].op = EXPR_TOP;
|
||||
stack[sp].svalue = 0;
|
||||
} else if ((token == SWIG_TOKEN_LPAREN)) {
|
||||
} else if (token == SWIG_TOKEN_LPAREN) {
|
||||
stack[sp++].op = EXPR_GROUP;
|
||||
stack[sp].op = EXPR_TOP;
|
||||
stack[sp].value = 0;
|
||||
stack[sp].svalue = 0;
|
||||
} else if (token == SWIG_TOKEN_ENDLINE) {
|
||||
} else if ((token == SWIG_TOKEN_STRING)) {
|
||||
} else if (token == SWIG_TOKEN_STRING) {
|
||||
stack[sp].svalue = NewString(Scanner_text(scan));
|
||||
stack[sp].op = EXPR_VALUE;
|
||||
} else if ((token == SWIG_TOKEN_ID)) {
|
||||
} else if (token == SWIG_TOKEN_ID) {
|
||||
stack[sp].value = 0;
|
||||
stack[sp].svalue = 0;
|
||||
stack[sp].op = EXPR_VALUE;
|
||||
|
|
@ -435,6 +433,6 @@ extra_rparen:
|
|||
* Return error message set by the evaluator (if any)
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char *Preprocessor_expr_error() {
|
||||
const char *Preprocessor_expr_error() {
|
||||
return errmsg;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
extern int Preprocessor_expr(String *s, int *error);
|
||||
extern char *Preprocessor_expr_error(void);
|
||||
extern const char *Preprocessor_expr_error(void);
|
||||
extern Hash *Preprocessor_define(const_String_or_char_ptr str, int swigmacro);
|
||||
extern void Preprocessor_undef(const_String_or_char_ptr name);
|
||||
extern void Preprocessor_init(void);
|
||||
|
|
|
|||
|
|
@ -12,11 +12,10 @@
|
|||
* the naming of local variables, calling conventions, and so forth.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_cwrap_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
|
||||
extern int cparse_cplusplus;
|
||||
static const char *cresult_variable_name = "result";
|
||||
|
||||
static Parm *nonvoid_parms(Parm *p) {
|
||||
if (p) {
|
||||
|
|
@ -28,7 +27,28 @@ static Parm *nonvoid_parms(Parm *p) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_parm_name()
|
||||
* Swig_cresult_name_set()
|
||||
*
|
||||
* Change the name of the variable used to hold the return value from C/C++ wrapper functions
|
||||
* from the default "result".
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_cresult_name_set(const char *new_name) {
|
||||
cresult_variable_name = new_name;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_cresult_name()
|
||||
*
|
||||
* Get the name of the variable used to hold the return value from C/C++ wrapper functions
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const char *Swig_cresult_name(void) {
|
||||
return cresult_variable_name;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_cparm_name()
|
||||
*
|
||||
* Generates a name for the ith argument in an argument list
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -229,7 +249,7 @@ int Swig_cargs(Wrapper *w, ParmList *p) {
|
|||
SwigType_del_reference(tvalue);
|
||||
tycode = SwigType_type(tvalue);
|
||||
if (tycode != T_USER) {
|
||||
/* plain primitive type, we copy the the def value */
|
||||
/* plain primitive type, we copy the def value */
|
||||
String *lstr = SwigType_lstr(tvalue, defname);
|
||||
defvalue = NewStringf("%s = %s", lstr, qvalue);
|
||||
Delete(lstr);
|
||||
|
|
@ -316,12 +336,13 @@ String *Swig_cresult(SwigType *t, const_String_or_char_ptr name, const_String_or
|
|||
break;
|
||||
case T_RVALUE_REFERENCE:
|
||||
{
|
||||
String *const_lvalue_str;
|
||||
String *lstr = SwigType_lstr(t, 0);
|
||||
SwigType *tt = Copy(t);
|
||||
SwigType_del_rvalue_reference(tt);
|
||||
SwigType_add_qualifier(tt, "const");
|
||||
SwigType_add_reference(tt);
|
||||
String *const_lvalue_str = SwigType_rcaststr(tt, 0);
|
||||
const_lvalue_str = SwigType_rcaststr(tt, 0);
|
||||
|
||||
Printf(fcall, "%s = (%s) &%s", name, lstr, const_lvalue_str);
|
||||
|
||||
|
|
@ -603,7 +624,7 @@ String *Swig_cppconstructor_director_call(const_String_or_char_ptr name, ParmLis
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_rflag_search()
|
||||
* recursive_flag_search()
|
||||
*
|
||||
* This function searches for the class attribute 'attr' in the class
|
||||
* 'n' or recursively in its bases.
|
||||
|
|
@ -624,7 +645,7 @@ String *Swig_cppconstructor_director_call(const_String_or_char_ptr name, ParmLis
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* #define SWIG_FAST_REC_SEARCH 1 */
|
||||
String *Swig_rflag_search(Node *n, const String *attr, const String *noattr) {
|
||||
static String *recursive_flag_search(Node *n, const String *attr, const String *noattr) {
|
||||
String *f = 0;
|
||||
n = Swig_methodclass(n);
|
||||
if (GetFlag(n, noattr)) {
|
||||
|
|
@ -638,7 +659,7 @@ String *Swig_rflag_search(Node *n, const String *attr, const String *noattr) {
|
|||
if (bl) {
|
||||
Iterator bi;
|
||||
for (bi = First(bl); bi.item; bi = Next(bi)) {
|
||||
f = Swig_rflag_search(bi.item, attr, noattr);
|
||||
f = recursive_flag_search(bi.item, attr, noattr);
|
||||
if (f) {
|
||||
#ifdef SWIG_FAST_REC_SEARCH
|
||||
SetFlagAttr(n, attr, f);
|
||||
|
|
@ -657,12 +678,11 @@ String *Swig_rflag_search(Node *n, const String *attr, const String *noattr) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Swig_unref_call()
|
||||
*
|
||||
* find the unref call, if any.
|
||||
* Find the "feature:unref" call, if any.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_unref_call(Node *n) {
|
||||
Node *cn = Swig_methodclass(n);
|
||||
String *unref = Swig_rflag_search(cn, "feature:unref", "feature:nounref");
|
||||
String *unref = recursive_flag_search(n, "feature:unref", "feature:nounref");
|
||||
if (unref) {
|
||||
String *pname = Swig_cparm_name(0, 0);
|
||||
unref = NewString(unref);
|
||||
|
|
@ -676,12 +696,11 @@ String *Swig_unref_call(Node *n) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Swig_ref_call()
|
||||
*
|
||||
* find the ref call, if any.
|
||||
* Find the "feature:ref" call, if any.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_ref_call(Node *n, const String *lname) {
|
||||
Node *cn = Swig_methodclass(n);
|
||||
String *ref = Swig_rflag_search(cn, "feature:ref", "feature:noref");
|
||||
String *ref = recursive_flag_search(n, "feature:ref", "feature:noref");
|
||||
if (ref) {
|
||||
ref = NewString(ref);
|
||||
Replaceall(ref, "$this", lname);
|
||||
|
|
@ -699,7 +718,8 @@ String *Swig_ref_call(Node *n, const String *lname) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_cdestructor_call(Node *n) {
|
||||
String *unref = Swig_unref_call(n);
|
||||
Node *cn = Swig_methodclass(n);
|
||||
String *unref = Swig_unref_call(cn);
|
||||
|
||||
if (unref) {
|
||||
return unref;
|
||||
|
|
@ -721,7 +741,8 @@ String *Swig_cdestructor_call(Node *n) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_cppdestructor_call(Node *n) {
|
||||
String *unref = Swig_unref_call(n);
|
||||
Node *cn = Swig_methodclass(n);
|
||||
String *unref = Swig_unref_call(cn);
|
||||
if (unref) {
|
||||
return unref;
|
||||
} else {
|
||||
|
|
@ -794,6 +815,46 @@ String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String
|
|||
return func;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_replace_special_variables()
|
||||
*
|
||||
* Replaces special variables with a value from the supplied node
|
||||
* ----------------------------------------------------------------------------- */
|
||||
void Swig_replace_special_variables(Node *n, Node *parentnode, String *code) {
|
||||
Node *parentclass = parentnode;
|
||||
String *overloaded = Getattr(n, "sym:overloaded");
|
||||
Replaceall(code, "$name", Getattr(n, "name"));
|
||||
Replaceall(code, "$symname", Getattr(n, "sym:name"));
|
||||
Replaceall(code, "$wrapname", Getattr(n, "wrap:name"));
|
||||
Replaceall(code, "$overname", overloaded ? Char(Getattr(n, "sym:overname")) : "");
|
||||
|
||||
if (Strstr(code, "$decl")) {
|
||||
String *decl = Swig_name_decl(n);
|
||||
Replaceall(code, "$decl", decl);
|
||||
Delete(decl);
|
||||
}
|
||||
if (Strstr(code, "$fulldecl")) {
|
||||
String *fulldecl = Swig_name_fulldecl(n);
|
||||
Replaceall(code, "$fulldecl", fulldecl);
|
||||
Delete(fulldecl);
|
||||
}
|
||||
|
||||
if (parentclass && !Equal(nodeType(parentclass), "class"))
|
||||
parentclass = 0;
|
||||
if (Strstr(code, "$parentclasssymname")) {
|
||||
String *parentclasssymname = 0;
|
||||
if (parentclass)
|
||||
parentclasssymname = Getattr(parentclass, "sym:name");
|
||||
Replaceall(code, "$parentclasssymname", parentclasssymname ? parentclasssymname : "");
|
||||
}
|
||||
if (Strstr(code, "$parentclassname")) {
|
||||
String *parentclassname = 0;
|
||||
if (parentclass)
|
||||
parentclassname = Getattr(parentclass, "name");
|
||||
Replaceall(code, "$parentclassname", parentclassname ? parentclassname : "");
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* extension_code()
|
||||
*
|
||||
|
|
@ -802,14 +863,17 @@ String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String
|
|||
* return_type function_name(parms) code
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
static String *extension_code(const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self) {
|
||||
static String *extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self) {
|
||||
String *parms_str = cplusplus ? ParmList_str_defaultargs(parms) : ParmList_str(parms);
|
||||
String *sig = NewStringf("%s(%s)", function_name, parms_str);
|
||||
String *rt_sig = SwigType_str(return_type, sig);
|
||||
String *body = NewStringf("SWIGINTERN %s", rt_sig);
|
||||
Printv(body, code, "\n", NIL);
|
||||
if (self)
|
||||
Replaceall(body, "$self", self);
|
||||
if (Strstr(body, "$")) {
|
||||
Swig_replace_special_variables(n, parentNode(parentNode(n)), body);
|
||||
if (self)
|
||||
Replaceall(body, "$self", self);
|
||||
}
|
||||
Delete(parms_str);
|
||||
Delete(sig);
|
||||
Delete(rt_sig);
|
||||
|
|
@ -826,7 +890,7 @@ static String *extension_code(const String *function_name, ParmList *parms, Swig
|
|||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self) {
|
||||
String *body = extension_code(function_name, parms, return_type, code, cplusplus, self);
|
||||
String *body = extension_code(n, function_name, parms, return_type, code, cplusplus, self);
|
||||
Setattr(n, "wrap:code", body);
|
||||
Delete(body);
|
||||
return SWIG_OK;
|
||||
|
|
@ -840,15 +904,37 @@ int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parm
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *classname, int flags, SwigType *director_type, int is_director) {
|
||||
String *name, *qualifier;
|
||||
String *name;
|
||||
ParmList *parms;
|
||||
SwigType *type;
|
||||
Parm *p;
|
||||
String *self = 0;
|
||||
int is_smart_pointer_overload = 0;
|
||||
String *qualifier = Getattr(n, "qualifier");
|
||||
String *directorScope = NewString(nspace);
|
||||
|
||||
/* If smart pointer, change self dereferencing */
|
||||
Replace(directorScope, NSPACE_SEPARATOR, "_", DOH_REPLACE_ANY);
|
||||
|
||||
/* If smart pointer without const overload or mutable method, change self dereferencing */
|
||||
if (flags & CWRAP_SMART_POINTER) {
|
||||
self = NewString("(*this)->");
|
||||
if (flags & CWRAP_SMART_POINTER_OVERLOAD) {
|
||||
if (qualifier && strncmp(Char(qualifier), "q(const)", 8) == 0) {
|
||||
self = NewString("(*(this))->");
|
||||
is_smart_pointer_overload = 1;
|
||||
}
|
||||
else if (Cmp(Getattr(n, "storage"), "static") == 0) {
|
||||
String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : classname;
|
||||
String *ctname = SwigType_namestr(cname);
|
||||
self = NewStringf("(*(%s const *)this)->", ctname);
|
||||
is_smart_pointer_overload = 1;
|
||||
Delete(ctname);
|
||||
}
|
||||
else {
|
||||
self = NewString("(*this)->");
|
||||
}
|
||||
} else {
|
||||
self = NewString("(*this)->");
|
||||
}
|
||||
}
|
||||
|
||||
/* If node is a member template expansion, we don't allow added code */
|
||||
|
|
@ -856,7 +942,6 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
|
|||
flags &= ~(CWRAP_EXTEND);
|
||||
|
||||
name = Getattr(n, "name");
|
||||
qualifier = Getattr(n, "qualifier");
|
||||
parms = CopyParmList(nonvoid_parms(Getattr(n, "parms")));
|
||||
|
||||
type = NewString(classname);
|
||||
|
|
@ -911,7 +996,10 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
|
|||
/* If protected access (can only be if a director method) then call the extra public accessor method (language module must provide this) */
|
||||
String *explicit_qualifier_tmp = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), "qname"));
|
||||
explicitcall_name = NewStringf("%sSwigPublic", name);
|
||||
explicit_qualifier = NewStringf("SwigDirector_%s", explicit_qualifier_tmp);
|
||||
if (Len(directorScope) > 0)
|
||||
explicit_qualifier = NewStringf("SwigDirector_%s_%s", directorScope, explicit_qualifier_tmp);
|
||||
else
|
||||
explicit_qualifier = NewStringf("SwigDirector_%s", explicit_qualifier_tmp);
|
||||
Delete(explicit_qualifier_tmp);
|
||||
} else {
|
||||
explicit_qualifier = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), "qname"));
|
||||
|
|
@ -919,7 +1007,7 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
|
|||
}
|
||||
|
||||
call = Swig_cmethod_call(explicitcall_name ? explicitcall_name : name, p, self, explicit_qualifier, director_type);
|
||||
cres = Swig_cresult(Getattr(n, "type"), "result", call);
|
||||
cres = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), call);
|
||||
|
||||
if (pure_virtual && is_director && (flags & CWRAP_DIRECTOR_TWO_CALLS)) {
|
||||
String *qualifier = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), "qname"));
|
||||
|
|
@ -932,7 +1020,7 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
|
|||
/* Create two method calls, one to call the explicit method, the other a normal polymorphic function call */
|
||||
String *cres_both_calls = NewStringf("");
|
||||
String *call_extra = Swig_cmethod_call(name, p, self, 0, director_type);
|
||||
String *cres_extra = Swig_cresult(Getattr(n, "type"), "result", call_extra);
|
||||
String *cres_extra = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), call_extra);
|
||||
Printv(cres_both_calls, "if (upcall) {\n", cres, "\n", "} else {", cres_extra, "\n}", NIL);
|
||||
Setattr(n, "wrap:action", cres_both_calls);
|
||||
Delete(cres_extra);
|
||||
|
|
@ -978,10 +1066,18 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
|
|||
|
||||
if (Cmp(Getattr(n, "storage"), "static") != 0) {
|
||||
String *pname = Swig_cparm_name(pp, i);
|
||||
String *ctname = SwigType_namestr(cname);
|
||||
String *fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname);
|
||||
String *ctname = SwigType_namestr(cname);
|
||||
String *fadd = 0;
|
||||
if (is_smart_pointer_overload) {
|
||||
String *nclassname = SwigType_namestr(classname);
|
||||
fadd = NewStringf("(%s const *)((%s const *)%s)->operator ->()", ctname, nclassname, pname);
|
||||
Delete(nclassname);
|
||||
}
|
||||
else {
|
||||
fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname);
|
||||
}
|
||||
Append(func, fadd);
|
||||
Delete(ctname);
|
||||
Delete(ctname);
|
||||
Delete(fadd);
|
||||
Delete(pname);
|
||||
pp = nextSibling(pp);
|
||||
|
|
@ -1005,12 +1101,12 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
|
|||
}
|
||||
}
|
||||
Append(func, ")");
|
||||
cres = Swig_cresult(Getattr(n, "type"), "result", func);
|
||||
cres = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), func);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(cres);
|
||||
} else {
|
||||
String *call = Swig_cfunction_call(mangled, p);
|
||||
String *cres = Swig_cresult(Getattr(n, "type"), "result", call);
|
||||
String *cres = Swig_cresult(Getattr(n, "type"), Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(call);
|
||||
Delete(cres);
|
||||
|
|
@ -1023,6 +1119,7 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
|
|||
Delete(p);
|
||||
Delete(self);
|
||||
Delete(parms);
|
||||
Delete(directorScope);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1072,10 +1169,11 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String
|
|||
Parm *p;
|
||||
ParmList *directorparms;
|
||||
SwigType *type;
|
||||
Node *classNode;
|
||||
int use_director;
|
||||
String *directorScope = NewString(nspace);
|
||||
|
||||
Replace(directorScope, NSPACE_SEPARATOR, "_", DOH_REPLACE_ANY);
|
||||
|
||||
classNode = Swig_methodclass(n);
|
||||
use_director = Swig_directorclass(n);
|
||||
|
||||
parms = CopyParmList(nonvoid_parms(Getattr(n, "parms")));
|
||||
|
|
@ -1122,7 +1220,7 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String
|
|||
}
|
||||
|
||||
call = Swig_cfunction_call(mangled, parms);
|
||||
cres = Swig_cresult(type, "result", call);
|
||||
cres = Swig_cresult(type, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
|
|
@ -1133,14 +1231,19 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String
|
|||
/* if a C++ director class exists, create it rather than the original class */
|
||||
if (use_director) {
|
||||
Node *parent = Swig_methodclass(n);
|
||||
int abstract = Getattr(parent, "abstract") != 0;
|
||||
int abstract = Getattr(parent, "abstracts") != 0;
|
||||
String *name = Getattr(parent, "sym:name");
|
||||
String *directorname = NewStringf("SwigDirector_%s", name);
|
||||
String *directorname;
|
||||
String *action = NewStringEmpty();
|
||||
String *tmp_none_comparison = Copy(none_comparison);
|
||||
String *director_call;
|
||||
String *nodirector_call;
|
||||
|
||||
if (Len(directorScope) > 0)
|
||||
directorname = NewStringf("SwigDirector_%s_%s", directorScope, name);
|
||||
else
|
||||
directorname = NewStringf("SwigDirector_%s", name);
|
||||
|
||||
Replaceall(tmp_none_comparison, "$arg", "arg1");
|
||||
|
||||
director_call = Swig_cppconstructor_director_call(directorname, directorparms);
|
||||
|
|
@ -1153,7 +1256,7 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String
|
|||
* implemented in the target language, calls to those methods will
|
||||
* generate Swig::DirectorPureVirtualException exceptions.
|
||||
*/
|
||||
String *cres = Swig_cresult(type, "result", director_call);
|
||||
String *cres = Swig_cresult(type, Swig_cresult_name(), director_call);
|
||||
Append(action, cres);
|
||||
Delete(cres);
|
||||
} else {
|
||||
|
|
@ -1168,11 +1271,11 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String
|
|||
Append(action, director_ctor);
|
||||
Replaceall(action, "$comparison", tmp_none_comparison);
|
||||
|
||||
cres = Swig_cresult(type, "result", director_call);
|
||||
cres = Swig_cresult(type, Swig_cresult_name(), director_call);
|
||||
Replaceall(action, "$director_new", cres);
|
||||
Delete(cres);
|
||||
|
||||
cres = Swig_cresult(type, "result", nodirector_call);
|
||||
cres = Swig_cresult(type, Swig_cresult_name(), nodirector_call);
|
||||
Replaceall(action, "$nondirector_new", cres);
|
||||
Delete(cres);
|
||||
}
|
||||
|
|
@ -1182,14 +1285,14 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String
|
|||
Delete(directorname);
|
||||
} else {
|
||||
String *call = Swig_cppconstructor_call(classname, parms);
|
||||
String *cres = Swig_cresult(type, "result", call);
|
||||
String *cres = Swig_cresult(type, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
}
|
||||
} else {
|
||||
String *call = Swig_cconstructor_call(classname);
|
||||
String *cres = Swig_cresult(type, "result", call);
|
||||
String *cres = Swig_cresult(type, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
|
|
@ -1201,6 +1304,7 @@ int Swig_ConstructorToFunction(Node *n, const_String_or_char_ptr nspace, String
|
|||
if (directorparms != parms)
|
||||
Delete(directorparms);
|
||||
Delete(parms);
|
||||
Delete(directorScope);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -1367,6 +1471,10 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
Node *sn = Getattr(n, "cplus:staticbase");
|
||||
String *base = Getattr(sn, "name");
|
||||
self = NewStringf("%s::", base);
|
||||
} else if (flags & CWRAP_SMART_POINTER_OVERLOAD) {
|
||||
String *nclassname = SwigType_namestr(classname);
|
||||
self = NewStringf("(*(%s const *)this)->", nclassname);
|
||||
Delete(nclassname);
|
||||
} else {
|
||||
self = NewString("(*this)->");
|
||||
}
|
||||
|
|
@ -1400,7 +1508,7 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
Swig_add_extension_code(n, mangled, parms, ty, code, cparse_cplusplus, "self");
|
||||
}
|
||||
call = Swig_cfunction_call(mangled, parms);
|
||||
cres = Swig_cresult(ty, "result", call);
|
||||
cres = Swig_cresult(ty, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
|
||||
Delete(cres);
|
||||
|
|
@ -1410,7 +1518,7 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
|||
Delete(gname);
|
||||
} else {
|
||||
String *call = Swig_cmemberget_call(name, type, self, varcref);
|
||||
String *cres = Swig_cresult(ty, "result", call);
|
||||
String *cres = Swig_cresult(ty, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(call);
|
||||
Delete(cres);
|
||||
|
|
@ -1501,14 +1609,14 @@ int Swig_VargetToFunction(Node *n, int flags) {
|
|||
String *sname = Swig_name_get(0, name);
|
||||
String *mangled = Swig_name_mangle(sname);
|
||||
call = Swig_cfunction_call(mangled, 0);
|
||||
cres = Swig_cresult(ty, "result", call);
|
||||
cres = Swig_cresult(ty, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(mangled);
|
||||
Delete(sname);
|
||||
} else {
|
||||
String *nname = SwigType_namestr(name);
|
||||
call = Swig_wrapped_var_assign(type, nname, varcref);
|
||||
cres = Swig_cresult(ty, "result", call);
|
||||
cres = Swig_cresult(ty, Swig_cresult_name(), call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(nname);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@
|
|||
* that the function and/or API needs to be changed in some future release.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_deprecate_c[] = "$Id: parms.c 9630 2007-01-02 21:17:19Z beazley $";
|
||||
|
||||
#include "swig.h"
|
||||
|
||||
/* ---------------------------------------------------------------------
|
||||
|
|
@ -77,7 +75,7 @@ int ParmList_is_compactdefargs(ParmList *p) {
|
|||
* ParmList_errorstr()
|
||||
*
|
||||
* Generate a prototype string suitable for use in error/warning messages.
|
||||
* This function is aware of hidden parameters.
|
||||
* Similar to ParmList_protostr() but is also aware of hidden parameters.
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
/* Discussion. This function is used to generate error messages, but take
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
* error messages.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_error_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include <stdarg.h>
|
||||
#include <ctype.h>
|
||||
|
|
@ -284,6 +282,41 @@ static String *format_filename(const_String_or_char_ptr filename) {
|
|||
return formatted_filename;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_stringify_with_location()
|
||||
*
|
||||
* Return a string representation of any DOH object with line and file location
|
||||
* information in the appropriate error message format. The string representation
|
||||
* is enclosed within [] brackets after the line and file information.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_stringify_with_location(DOH *object) {
|
||||
String *str = NewStringEmpty();
|
||||
|
||||
if (!init_fmt)
|
||||
Swig_error_msg_format(DEFAULT_ERROR_MSG_FORMAT);
|
||||
|
||||
if (object) {
|
||||
int line = Getline(object);
|
||||
String *formatted_filename = format_filename(Getfile(object));
|
||||
if (line > 0) {
|
||||
Printf(str, diag_line_fmt, formatted_filename, line);
|
||||
} else {
|
||||
Printf(str, diag_eof_fmt, formatted_filename);
|
||||
}
|
||||
if (Len(object) == 0) {
|
||||
Printf(str, "[EMPTY]");
|
||||
} else {
|
||||
Printf(str, "[%s]", object);
|
||||
}
|
||||
Delete(formatted_filename);
|
||||
} else {
|
||||
Printf(str, "[NULL]");
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_diagnostic()
|
||||
*
|
||||
|
|
|
|||
|
|
@ -16,8 +16,6 @@
|
|||
* wrapper code and to generate cleaner wrapper files.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_fragment_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include "swigwarn.h"
|
||||
|
||||
|
|
@ -60,6 +58,8 @@ void Swig_fragment_register(Node *fragment) {
|
|||
if (kwargs) {
|
||||
Setmeta(ccode, "kwargs", kwargs);
|
||||
}
|
||||
Setfile(ccode, Getfile(fragment));
|
||||
Setline(ccode, Getline(fragment));
|
||||
Setattr(fragments, name, ccode);
|
||||
if (debug)
|
||||
Printf(stdout, "registering fragment %s %s\n", name, section);
|
||||
|
|
@ -142,7 +142,7 @@ void Swig_fragment_emit(Node *n) {
|
|||
if (section) {
|
||||
File *f = Swig_filebyname(section);
|
||||
if (!f) {
|
||||
Swig_error(Getfile(code), Getline(code), "Bad section '%s' for code fragment '%s'\n", section, name);
|
||||
Swig_error(Getfile(code), Getline(code), "Bad section '%s' in %%fragment declaration for code fragment '%s'\n", section, name);
|
||||
} else {
|
||||
if (debug)
|
||||
Printf(stdout, "emitting subfragment %s %s\n", name, section);
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@
|
|||
* Should have cleaner error handling in general.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_getopt_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
|
||||
static char **args;
|
||||
|
|
|
|||
|
|
@ -13,14 +13,13 @@
|
|||
* are provided.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_include_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
|
||||
static List *directories = 0; /* List of include directories */
|
||||
static String *lastpath = 0; /* Last file that was included */
|
||||
static List *pdirectories = 0; /* List of pushed directories */
|
||||
static int dopush = 1; /* Whether to push directories */
|
||||
static int file_debug = 0;
|
||||
|
||||
/* This functions determine whether to push/pop dirs in the preprocessor */
|
||||
void Swig_set_push_dir(int push) {
|
||||
|
|
@ -173,6 +172,9 @@ static FILE *Swig_open_file(const_String_or_char_ptr name, int sysfile, int use_
|
|||
cname = Char(name);
|
||||
filename = NewString(cname);
|
||||
assert(filename);
|
||||
if (file_debug) {
|
||||
Printf(stdout, " Open: %s\n", filename);
|
||||
}
|
||||
f = fopen(Char(filename), "r");
|
||||
if (!f && use_include_path) {
|
||||
spath = Swig_search_path_any(sysfile);
|
||||
|
|
@ -221,6 +223,8 @@ String *Swig_read_file(FILE *f) {
|
|||
Append(str, buffer);
|
||||
}
|
||||
len = Len(str);
|
||||
/* Add a newline if not present on last line -- the preprocessor seems to
|
||||
* rely on \n and not EOF terminating lines */
|
||||
if (len) {
|
||||
char *cstr = Char(str);
|
||||
if (cstr[len - 1] != '\n') {
|
||||
|
|
@ -311,58 +315,41 @@ File *Swig_filebyname(const_String_or_char_ptr filename) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_file_suffix()
|
||||
* Swig_file_extension()
|
||||
*
|
||||
* Returns the suffix of a file
|
||||
* Returns the extension of a file
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char *Swig_file_suffix(const_String_or_char_ptr filename) {
|
||||
char *d;
|
||||
char *c = Char(filename);
|
||||
int len = Len(filename);
|
||||
if (strlen(c)) {
|
||||
d = c + len - 1;
|
||||
while (d != c) {
|
||||
if (*d == '.')
|
||||
return d;
|
||||
d--;
|
||||
}
|
||||
return c + len;
|
||||
}
|
||||
return c;
|
||||
String *Swig_file_extension(const_String_or_char_ptr filename) {
|
||||
String *name = Swig_file_filename(filename);
|
||||
const char *c = strrchr(Char(name), '.');
|
||||
String *extension = c ? NewString(c) : NewString("");
|
||||
Delete(name);
|
||||
return extension;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_file_basename()
|
||||
*
|
||||
* Returns the filename with no suffix attached.
|
||||
* Returns the filename with the extension removed.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char *Swig_file_basename(const_String_or_char_ptr filename) {
|
||||
static char tmp[1024];
|
||||
char *c;
|
||||
strcpy(tmp, Char(filename));
|
||||
c = Swig_file_suffix(tmp);
|
||||
*c = 0;
|
||||
return tmp;
|
||||
String *Swig_file_basename(const_String_or_char_ptr filename) {
|
||||
String *extension = Swig_file_extension(filename);
|
||||
String *basename = NewStringWithSize(filename, Len(filename) - Len(extension));
|
||||
Delete(extension);
|
||||
return basename;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_file_filename()
|
||||
*
|
||||
* Return the file with any leading path stripped off
|
||||
* Return the file name with any leading path stripped off
|
||||
* ----------------------------------------------------------------------------- */
|
||||
char *Swig_file_filename(const_String_or_char_ptr filename) {
|
||||
static char tmp[1024];
|
||||
String *Swig_file_filename(const_String_or_char_ptr filename) {
|
||||
const char *delim = SWIG_FILE_DELIMITER;
|
||||
char *c;
|
||||
|
||||
strcpy(tmp, Char(filename));
|
||||
c = strrchr(tmp, *delim);
|
||||
if (c)
|
||||
return c + 1;
|
||||
else
|
||||
return tmp;
|
||||
const char *c = strrchr(Char(filename), *delim);
|
||||
return c ? NewString(c + 1) : NewString(filename);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -370,17 +357,15 @@ char *Swig_file_filename(const_String_or_char_ptr filename) {
|
|||
*
|
||||
* Return the name of the directory associated with a file
|
||||
* ----------------------------------------------------------------------------- */
|
||||
char *Swig_file_dirname(const_String_or_char_ptr filename) {
|
||||
static char tmp[1024];
|
||||
String *Swig_file_dirname(const_String_or_char_ptr filename) {
|
||||
const char *delim = SWIG_FILE_DELIMITER;
|
||||
char *c;
|
||||
strcpy(tmp, Char(filename));
|
||||
if (!strstr(tmp, delim)) {
|
||||
return "";
|
||||
}
|
||||
c = tmp + strlen(tmp) - 1;
|
||||
while (*c != *delim)
|
||||
c--;
|
||||
*(++c) = 0;
|
||||
return tmp;
|
||||
const char *c = strrchr(Char(filename), *delim);
|
||||
return c ? NewStringWithSize(filename, c - Char(filename) + 1) : NewString("");
|
||||
}
|
||||
|
||||
/*
|
||||
* Swig_file_debug()
|
||||
*/
|
||||
void Swig_file_debug_set() {
|
||||
file_debug = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* Miscellaneous functions that don't really fit anywhere else.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_misc_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include <errno.h>
|
||||
#include <ctype.h>
|
||||
|
|
@ -167,44 +165,36 @@ static int is_directory(String *directory) {
|
|||
* Swig_new_subdirectory()
|
||||
*
|
||||
* Create the subdirectory only if the basedirectory already exists as a directory.
|
||||
* basedirectory can be NULL or empty to indicate current directory.
|
||||
* basedirectory can be empty to indicate current directory but not NULL.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) {
|
||||
String *error = 0;
|
||||
struct stat st;
|
||||
int current_directory = basedirectory ? (Len(basedirectory) == 0 ? 1 : 0) : 0;
|
||||
int current_directory = Len(basedirectory) == 0;
|
||||
|
||||
if (current_directory || is_directory(basedirectory)) {
|
||||
Iterator it;
|
||||
String *dir = basedirectory ? NewString(basedirectory) : NewString("");
|
||||
String *dir = NewString(basedirectory);
|
||||
List *subdirs = Split(subdirectory, SWIG_FILE_DELIMITER[0], INT_MAX);
|
||||
|
||||
for (it = First(subdirs); it.item; it = Next(it)) {
|
||||
int statdir;
|
||||
int result;
|
||||
String *subdirectory = it.item;
|
||||
Printf(dir, "%s", subdirectory);
|
||||
statdir = stat(Char(dir), &st);
|
||||
if (statdir == 0) {
|
||||
Printf(dir, SWIG_FILE_DELIMITER);
|
||||
if (S_ISDIR(st.st_mode)) {
|
||||
continue;
|
||||
} else {
|
||||
error = NewStringf("Cannot create directory %s", dir);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
int result = _mkdir(Char(dir));
|
||||
result = _mkdir(Char(dir));
|
||||
#else
|
||||
int result = mkdir(Char(dir), 0777);
|
||||
result = mkdir(Char(dir), 0777);
|
||||
#endif
|
||||
Printf(dir, SWIG_FILE_DELIMITER);
|
||||
if (result != 0 && errno != EEXIST) {
|
||||
error = NewStringf("Cannot create directory %s", dir);
|
||||
break;
|
||||
}
|
||||
if (result != 0 && errno != EEXIST) {
|
||||
error = NewStringf("Cannot create directory %s: %s", dir, strerror(errno));
|
||||
break;
|
||||
}
|
||||
if (!is_directory(dir)) {
|
||||
error = NewStringf("Cannot create directory %s: it may already exist but not be a directory", dir);
|
||||
break;
|
||||
}
|
||||
Printf(dir, SWIG_FILE_DELIMITER);
|
||||
}
|
||||
} else {
|
||||
error = NewStringf("Cannot create subdirectory %s under the base directory %s. Either the base does not exist as a directory or it is not readable.", subdirectory, basedirectory);
|
||||
|
|
@ -220,7 +210,14 @@ String *Swig_new_subdirectory(String *basedirectory, String *subdirectory) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_filename_correct(String *filename) {
|
||||
(void)filename;
|
||||
int network_path = 0;
|
||||
if (Len(filename) >= 2) {
|
||||
const char *fname = Char(filename);
|
||||
if (fname[0] == '\\' && fname[1] == '\\')
|
||||
network_path = 1;
|
||||
if (fname[0] == '/' && fname[1] == '/')
|
||||
network_path = 1;
|
||||
}
|
||||
#if defined(_WIN32) || defined(MACSWIG)
|
||||
/* accept Unix path separator on non-Unix systems */
|
||||
Replaceall(filename, "/", SWIG_FILE_DELIMITER);
|
||||
|
|
@ -232,6 +229,9 @@ void Swig_filename_correct(String *filename) {
|
|||
/* remove all duplicate file name delimiters */
|
||||
while (Replaceall(filename, SWIG_FILE_DELIMITER SWIG_FILE_DELIMITER, SWIG_FILE_DELIMITER)) {
|
||||
}
|
||||
/* Network paths can start with a double slash on Windows - unremove the duplicate slash we just removed */
|
||||
if (network_path)
|
||||
Insert(filename, 0, SWIG_FILE_DELIMITER);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -242,13 +242,11 @@ void Swig_filename_correct(String *filename) {
|
|||
|
||||
String *Swig_filename_escape(String *filename) {
|
||||
String *adjusted_filename = Copy(filename);
|
||||
Swig_filename_correct(adjusted_filename);
|
||||
#if defined(_WIN32) /* Note not on Cygwin else filename is displayed with double '/' */
|
||||
/* remove all double '\' in case any already present */
|
||||
while (Replaceall(adjusted_filename, "\\\\", "\\")) {
|
||||
}
|
||||
Replaceall(adjusted_filename, "\\", "\\\\");
|
||||
#endif
|
||||
return adjusted_filename;
|
||||
return adjusted_filename;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -527,7 +525,6 @@ String *Swig_string_schemify(String *s) {
|
|||
return ns;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_typecode()
|
||||
*
|
||||
|
|
@ -873,8 +870,8 @@ String *Swig_scopename_last(const String *s) {
|
|||
|
||||
while (*c) {
|
||||
if ((*c == ':') && (*(c + 1) == ':')) {
|
||||
cc = c;
|
||||
c += 2;
|
||||
cc = c;
|
||||
} else {
|
||||
if (*c == '<') {
|
||||
int level = 1;
|
||||
|
|
@ -891,7 +888,7 @@ String *Swig_scopename_last(const String *s) {
|
|||
}
|
||||
}
|
||||
}
|
||||
return NewString(cc + 2);
|
||||
return NewString(cc);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -1108,112 +1105,132 @@ String *Swig_string_strip(String *s) {
|
|||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_rxspencer()
|
||||
*
|
||||
* Executes a regexp substitution via the RxSpencer library. For example:
|
||||
*
|
||||
* Printf(stderr,"gsl%(rxspencer:[GSL_.*_][@1])s","GSL_Hello_") -> gslHello
|
||||
* ----------------------------------------------------------------------------- */
|
||||
#if defined(HAVE_RXSPENCER)
|
||||
#include <sys/types.h>
|
||||
#include <rxspencer/regex.h>
|
||||
#define USE_RXSPENCER
|
||||
#endif
|
||||
#ifdef HAVE_PCRE
|
||||
#include <pcre.h>
|
||||
|
||||
const char *skip_delim(char pb, char pe, const char *ce) {
|
||||
int end = 0;
|
||||
int lb = 0;
|
||||
while (!end && *ce != '\0') {
|
||||
if (*ce == pb) {
|
||||
++lb;
|
||||
}
|
||||
if (*ce == pe) {
|
||||
if (!lb) {
|
||||
end = 1;
|
||||
--ce;
|
||||
} else {
|
||||
--lb;
|
||||
}
|
||||
}
|
||||
++ce;
|
||||
}
|
||||
return end ? ce : 0;
|
||||
static int split_regex_pattern_subst(String *s, String **pattern, String **subst, const char **input)
|
||||
{
|
||||
const char *pats, *pate;
|
||||
const char *subs, *sube;
|
||||
|
||||
/* Locate the search pattern */
|
||||
const char *p = Char(s);
|
||||
if (*p++ != '/') goto err_out;
|
||||
pats = p;
|
||||
p = strchr(p, '/');
|
||||
if (!p) goto err_out;
|
||||
pate = p;
|
||||
|
||||
/* Locate the substitution string */
|
||||
subs = ++p;
|
||||
p = strchr(p, '/');
|
||||
if (!p) goto err_out;
|
||||
sube = p;
|
||||
|
||||
*pattern = NewStringWithSize(pats, pate - pats);
|
||||
*subst = NewStringWithSize(subs, sube - subs);
|
||||
*input = p + 1;
|
||||
return 1;
|
||||
|
||||
err_out:
|
||||
Swig_error("SWIG", Getline(s), "Invalid regex substitution: '%s'.\n", s);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
String *replace_captures(int num_captures, const char *input, String *subst, int captures[], String *pattern, String *s)
|
||||
{
|
||||
String *result = NewStringEmpty();
|
||||
const char *p = Char(subst);
|
||||
|
||||
#if defined(USE_RXSPENCER)
|
||||
String *Swig_string_rxspencer(String *s) {
|
||||
String *res = 0;
|
||||
if (Len(s)) {
|
||||
const char *cs = Char(s);
|
||||
const char *cb;
|
||||
const char *ce;
|
||||
if (*cs == '[') {
|
||||
int retval;
|
||||
regex_t compiled;
|
||||
cb = ++cs;
|
||||
ce = skip_delim('[', ']', cb);
|
||||
if (ce) {
|
||||
char bregexp[512];
|
||||
strncpy(bregexp, cb, ce - cb);
|
||||
bregexp[ce - cb] = '\0';
|
||||
++ce;
|
||||
retval = regcomp(&compiled, bregexp, REG_EXTENDED);
|
||||
if (retval == 0) {
|
||||
cs = ce;
|
||||
if (*cs == '[') {
|
||||
cb = ++cs;
|
||||
ce = skip_delim('[', ']', cb);
|
||||
if (ce) {
|
||||
const char *cvalue = ce + 1;
|
||||
int nsub = (int) compiled.re_nsub + 1;
|
||||
regmatch_t *pmatch = (regmatch_t *) malloc(sizeof(regmatch_t) * (nsub));
|
||||
retval = regexec(&compiled, cvalue, nsub, pmatch, 0);
|
||||
if (retval != REG_NOMATCH) {
|
||||
char *spos = 0;
|
||||
res = NewStringWithSize(cb, ce - cb);
|
||||
spos = Strchr(res, '@');
|
||||
while (spos) {
|
||||
char cd = *(++spos);
|
||||
if (isdigit(cd)) {
|
||||
char arg[8];
|
||||
size_t len;
|
||||
int i = cd - '0';
|
||||
sprintf(arg, "@%d", i);
|
||||
if (i < nsub && (len = pmatch[i].rm_eo - pmatch[i].rm_so)) {
|
||||
char value[256];
|
||||
strncpy(value, cvalue + pmatch[i].rm_so, len);
|
||||
value[len] = 0;
|
||||
Replaceall(res, arg, value);
|
||||
} else {
|
||||
Replaceall(res, arg, "");
|
||||
}
|
||||
spos = Strchr(res, '@');
|
||||
} else if (cd == '@') {
|
||||
spos = strchr(spos + 1, '@');
|
||||
}
|
||||
}
|
||||
}
|
||||
free(pmatch);
|
||||
}
|
||||
}
|
||||
while (*p) {
|
||||
/* Copy part without substitutions */
|
||||
const char *q = strchr(p, '\\');
|
||||
if (!q) {
|
||||
Write(result, p, strlen(p));
|
||||
break;
|
||||
}
|
||||
Write(result, p, q - p);
|
||||
p = q + 1;
|
||||
|
||||
/* Handle substitution */
|
||||
if (*p == '\0') {
|
||||
Putc('\\', result);
|
||||
} else if (isdigit((unsigned char)*p)) {
|
||||
int group = *p++ - '0';
|
||||
if (group < num_captures) {
|
||||
int l = captures[group*2], r = captures[group*2 + 1];
|
||||
if (l != -1) {
|
||||
Write(result, input + l, r - l);
|
||||
}
|
||||
regfree(&compiled);
|
||||
} else {
|
||||
Swig_error("SWIG", Getline(s), "PCRE capture replacement failed while matching \"%s\" using \"%s\" - request for group %d is greater than the number of captures %d.\n",
|
||||
Char(pattern), input, group, num_captures-1);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!res)
|
||||
res = NewStringEmpty();
|
||||
return res;
|
||||
}
|
||||
#else
|
||||
String *Swig_string_rxspencer(String *s) {
|
||||
(void) s;
|
||||
return NewStringEmpty();
|
||||
}
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_regex()
|
||||
*
|
||||
* Executes a regular expression substitution. For example:
|
||||
*
|
||||
* Printf(stderr,"gsl%(regex:/GSL_.*_/\\1/)s","GSL_Hello_") -> gslHello
|
||||
* ----------------------------------------------------------------------------- */
|
||||
String *Swig_string_regex(String *s) {
|
||||
const int pcre_options = 0;
|
||||
|
||||
String *res = 0;
|
||||
pcre *compiled_pat = 0;
|
||||
const char *pcre_error, *input;
|
||||
int pcre_errorpos;
|
||||
String *pattern = 0, *subst = 0;
|
||||
int captures[30];
|
||||
|
||||
if (split_regex_pattern_subst(s, &pattern, &subst, &input)) {
|
||||
int rc;
|
||||
|
||||
compiled_pat = pcre_compile(
|
||||
Char(pattern), pcre_options, &pcre_error, &pcre_errorpos, NULL);
|
||||
if (!compiled_pat) {
|
||||
Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n",
|
||||
pcre_error, Char(pattern), pcre_errorpos);
|
||||
exit(1);
|
||||
}
|
||||
rc = pcre_exec(compiled_pat, NULL, input, strlen(input), 0, 0, captures, 30);
|
||||
if (rc >= 0) {
|
||||
res = replace_captures(rc, input, subst, captures, pattern, s);
|
||||
} else if (rc != PCRE_ERROR_NOMATCH) {
|
||||
Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" using \"%s\".\n",
|
||||
rc, Char(pattern), input);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
DohDelete(pattern);
|
||||
DohDelete(subst);
|
||||
pcre_free(compiled_pat);
|
||||
return res ? res : NewStringEmpty();
|
||||
}
|
||||
|
||||
String *Swig_pcre_version(void) {
|
||||
return NewStringf("PCRE Version: %s", pcre_version());
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
String *Swig_string_regex(String *s) {
|
||||
Swig_error("SWIG", Getline(s), "PCRE regex support not enabled in this SWIG build.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
String *Swig_pcre_version(void) {
|
||||
return NewStringf("PCRE not used");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_init()
|
||||
|
|
@ -1233,9 +1250,9 @@ void Swig_init() {
|
|||
DohEncoding("typecode", Swig_string_typecode);
|
||||
DohEncoding("mangle", Swig_string_emangle);
|
||||
DohEncoding("command", Swig_string_command);
|
||||
DohEncoding("rxspencer", Swig_string_rxspencer);
|
||||
DohEncoding("schemify", Swig_string_schemify);
|
||||
DohEncoding("strip", Swig_string_strip);
|
||||
DohEncoding("regex", Swig_string_regex);
|
||||
|
||||
/* aliases for the case encoders */
|
||||
DohEncoding("uppercase", Swig_string_upper);
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@
|
|||
* %v - variable name is substituted
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_naming_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include "cparse.h"
|
||||
#include <ctype.h>
|
||||
|
|
@ -565,6 +563,7 @@ DOH *Swig_name_object_get(Hash *namehash, String *prefix, String *name, SwigType
|
|||
|
||||
void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
|
||||
Iterator ki;
|
||||
Hash *derh;
|
||||
String *bprefix;
|
||||
String *dprefix;
|
||||
char *cbprefix;
|
||||
|
|
@ -573,6 +572,9 @@ void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
|
|||
if (!namehash)
|
||||
return;
|
||||
|
||||
/* Temporary hash holding all the entries we add while we iterate over
|
||||
namehash itself as we can't modify the latter while iterating over it. */
|
||||
derh = NULL;
|
||||
bprefix = NewStringf("%s::", base);
|
||||
dprefix = NewStringf("%s::", derived);
|
||||
cbprefix = Char(bprefix);
|
||||
|
|
@ -580,13 +582,20 @@ void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
|
|||
for (ki = First(namehash); ki.key; ki = Next(ki)) {
|
||||
char *k = Char(ki.key);
|
||||
if (strncmp(k, cbprefix, plen) == 0) {
|
||||
/* Copy, adjusting name, this element to the derived hash. */
|
||||
Iterator oi;
|
||||
String *nkey = NewStringf("%s%s", dprefix, k + plen);
|
||||
Hash *n = ki.item;
|
||||
Hash *newh = Getattr(namehash, nkey);
|
||||
Hash *newh;
|
||||
|
||||
/* Don't overwrite an existing value for the derived class, if any. */
|
||||
newh = Getattr(namehash, nkey);
|
||||
if (!newh) {
|
||||
if (!derh)
|
||||
derh = NewHash();
|
||||
|
||||
newh = NewHash();
|
||||
Setattr(namehash, nkey, newh);
|
||||
Setattr(derh, nkey, newh);
|
||||
Delete(newh);
|
||||
}
|
||||
for (oi = First(n); oi.key; oi = Next(oi)) {
|
||||
|
|
@ -599,8 +608,17 @@ void Swig_name_object_inherit(Hash *namehash, String *base, String *derived) {
|
|||
Delete(nkey);
|
||||
}
|
||||
}
|
||||
|
||||
/* Merge the contents of derived hash into the main hash. */
|
||||
if (derh) {
|
||||
for (ki = First(derh); ki.key; ki = Next(ki)) {
|
||||
Setattr(namehash, ki.key, ki.item);
|
||||
}
|
||||
}
|
||||
|
||||
Delete(bprefix);
|
||||
Delete(dprefix);
|
||||
Delete(derh);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -863,13 +881,16 @@ List *Swig_name_rename_list() {
|
|||
int Swig_need_name_warning(Node *n) {
|
||||
int need = 1;
|
||||
/*
|
||||
we don't use name warnings for:
|
||||
We don't use name warnings for:
|
||||
- class forwards, no symbol is generated at the target language.
|
||||
- template declarations, only for real instances using %template(name).
|
||||
- typedefs, they have no effect at the target language.
|
||||
- typedefs, have no effect at the target language.
|
||||
- using declarations and using directives, have no effect at the target language.
|
||||
*/
|
||||
if (checkAttribute(n, "nodeType", "classforward")) {
|
||||
need = 0;
|
||||
} else if (checkAttribute(n, "nodeType", "using")) {
|
||||
need = 0;
|
||||
} else if (checkAttribute(n, "storage", "typedef")) {
|
||||
need = 0;
|
||||
} else if (Getattr(n, "hidden")) {
|
||||
|
|
@ -893,11 +914,14 @@ static int nodes_are_equivalent(Node *a, Node *b, int a_inclass) {
|
|||
/* they must have the same type */
|
||||
String *ta = nodeType(a);
|
||||
String *tb = nodeType(b);
|
||||
if (Cmp(ta, tb) != 0)
|
||||
return 0;
|
||||
if (!Equal(ta, tb)) {
|
||||
if (!(Equal(ta, "using") && Equal(tb, "cdecl"))) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* cdecl case */
|
||||
if (Cmp(ta, "cdecl") == 0) {
|
||||
/* both cdecl case */
|
||||
/* typedef */
|
||||
String *a_storage = Getattr(a, "storage");
|
||||
String *b_storage = Getattr(b, "storage");
|
||||
|
|
@ -956,8 +980,17 @@ static int nodes_are_equivalent(Node *a, Node *b, int a_inclass) {
|
|||
}
|
||||
}
|
||||
}
|
||||
} else if (Equal(ta, "using")) {
|
||||
/* using and cdecl case */
|
||||
String *b_storage = Getattr(b, "storage");
|
||||
if (Equal(b_storage, "typedef")) {
|
||||
String *a_name = Getattr(a, "name");
|
||||
String *b_name = Getattr(b, "name");
|
||||
if (Equal(a_name, b_name))
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
/* %constant case */
|
||||
/* both %constant case */
|
||||
String *a_storage = Getattr(a, "storage");
|
||||
String *b_storage = Getattr(b, "storage");
|
||||
if ((Cmp(a_storage, "%constant") == 0)
|
||||
|
|
@ -1000,7 +1033,7 @@ int Swig_need_redefined_warn(Node *a, Node *b, int InClass) {
|
|||
* This is basically any protected members when the allprotected mode is set.
|
||||
* Otherwise we take just the protected virtual methods and non-static methods
|
||||
* (potentially virtual methods) as well as constructors/destructors.
|
||||
*
|
||||
* Also any "using" statements in a class may potentially be virtual.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_need_protected(Node *n) {
|
||||
|
|
@ -1017,6 +1050,8 @@ int Swig_need_protected(Node *n) {
|
|||
}
|
||||
} else if (Equal(nodetype, "constructor") || Equal(nodetype, "destructor")) {
|
||||
return 1;
|
||||
} else if (Equal(nodetype, "using") && !Getattr(n, "namespace")) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
@ -1061,25 +1096,21 @@ static void Swig_name_object_attach_keys(const char *keys[], Hash *nameobj) {
|
|||
if (ckey) {
|
||||
const char **rkey;
|
||||
int isnotmatch = 0;
|
||||
int isrxsmatch = 0;
|
||||
int isregexmatch = 0;
|
||||
if ((strncmp(ckey, "match", 5) == 0)
|
||||
|| (isnotmatch = (strncmp(ckey, "notmatch", 8) == 0))
|
||||
|| (isrxsmatch = (strncmp(ckey, "rxsmatch", 8) == 0))
|
||||
|| (isnotmatch = isrxsmatch = (strncmp(ckey, "notrxsmatch", 11) == 0))) {
|
||||
|| (isregexmatch = (strncmp(ckey, "regexmatch", 10) == 0))
|
||||
|| (isnotmatch = isregexmatch = (strncmp(ckey, "notregexmatch", 13) == 0))) {
|
||||
Hash *mi = NewHash();
|
||||
List *attrlist = Swig_make_attrlist(ckey);
|
||||
if (!matchlist)
|
||||
matchlist = NewList();
|
||||
Setattr(mi, "value", Getattr(kw, "value"));
|
||||
Setattr(mi, "attrlist", attrlist);
|
||||
#ifdef SWIG_DEBUG
|
||||
if (isrxsmatch)
|
||||
Printf(stdout, "rxsmatch to use: %s %s %s\n", ckey, Getattr(kw, "value"), attrlist);
|
||||
#endif
|
||||
if (isnotmatch)
|
||||
SetFlag(mi, "notmatch");
|
||||
if (isrxsmatch)
|
||||
SetFlag(mi, "rxsmatch");
|
||||
if (isregexmatch)
|
||||
SetFlag(mi, "regexmatch");
|
||||
Delete(attrlist);
|
||||
Append(matchlist, mi);
|
||||
Delete(mi);
|
||||
|
|
@ -1114,7 +1145,7 @@ void Swig_name_nameobj_add(Hash *name_hash, List *name_list, String *prefix, Str
|
|||
}
|
||||
|
||||
if (!nname || !Len(nname) || Getattr(nameobj, "fullname") || /* any of these options trigger a 'list' nameobj */
|
||||
Getattr(nameobj, "sourcefmt") || Getattr(nameobj, "matchlist")) {
|
||||
Getattr(nameobj, "sourcefmt") || Getattr(nameobj, "matchlist") || Getattr(nameobj, "regextarget")) {
|
||||
if (decl)
|
||||
Setattr(nameobj, "decl", decl);
|
||||
if (nname && Len(nname))
|
||||
|
|
@ -1155,36 +1186,50 @@ static DOH *Swig_get_lattr(Node *n, List *lattr) {
|
|||
return res;
|
||||
}
|
||||
|
||||
#if defined(HAVE_RXSPENCER)
|
||||
#include <sys/types.h>
|
||||
#include <rxspencer/regex.h>
|
||||
#define USE_RXSPENCER
|
||||
#endif
|
||||
#ifdef HAVE_PCRE
|
||||
#include <pcre.h>
|
||||
|
||||
#if defined(USE_RXSPENCER)
|
||||
int Swig_name_rxsmatch_value(String *mvalue, String *value) {
|
||||
int match = 0;
|
||||
char *cvalue = Char(value);
|
||||
char *cmvalue = Char(mvalue);
|
||||
regex_t compiled;
|
||||
int retval = regcomp(&compiled, cmvalue, REG_EXTENDED | REG_NOSUB);
|
||||
if (retval != 0)
|
||||
int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
|
||||
pcre *compiled_pat;
|
||||
const char *err;
|
||||
int errpos;
|
||||
int rc;
|
||||
|
||||
compiled_pat = pcre_compile(Char(pattern), 0, &err, &errpos, NULL);
|
||||
if (!compiled_pat) {
|
||||
Swig_error("SWIG", Getline(n),
|
||||
"Invalid regex \"%s\": compilation failed at %d: %s\n",
|
||||
Char(pattern), errpos, err);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
rc = pcre_exec(compiled_pat, NULL, Char(s), Len(s), 0, 0, NULL, 0);
|
||||
pcre_free(compiled_pat);
|
||||
|
||||
if (rc == PCRE_ERROR_NOMATCH)
|
||||
return 0;
|
||||
retval = regexec(&compiled, cvalue, 0, 0, 0);
|
||||
match = (retval == REG_NOMATCH) ? 0 : 1;
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "rxsmatch_value: %s %s %d\n", cvalue, cmvalue, match);
|
||||
#endif
|
||||
regfree(&compiled);
|
||||
return match;
|
||||
|
||||
if (rc < 0 ) {
|
||||
Swig_error("SWIG", Getline(n),
|
||||
"Matching \"%s\" against regex \"%s\" failed: %d\n",
|
||||
Char(s), Char(pattern), rc);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
int Swig_name_rxsmatch_value(String *mvalue, String *value) {
|
||||
(void) mvalue;
|
||||
(void) value;
|
||||
return 0;
|
||||
|
||||
#else /* !HAVE_PCRE */
|
||||
|
||||
int Swig_name_regexmatch_value(Node *n, String *pattern, String *s) {
|
||||
(void)pattern;
|
||||
(void)s;
|
||||
Swig_error("SWIG", Getline(n),
|
||||
"PCRE regex matching is not available in this SWIG build.\n");
|
||||
exit(1);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* HAVE_PCRE/!HAVE_PCRE */
|
||||
|
||||
int Swig_name_match_value(String *mvalue, String *value) {
|
||||
#if defined(SWIG_USE_SIMPLE_MATCHOR)
|
||||
|
|
@ -1227,17 +1272,11 @@ int Swig_name_match_nameobj(Hash *rn, Node *n) {
|
|||
List *lattr = Getattr(mi, "attrlist");
|
||||
String *nval = Swig_get_lattr(n, lattr);
|
||||
int notmatch = GetFlag(mi, "notmatch");
|
||||
int rxsmatch = GetFlag(mi, "rxsmatch");
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "mi %d %s re %d not %d \n", i, nval, notmatch, rxsmatch);
|
||||
if (rxsmatch) {
|
||||
Printf(stdout, "rxsmatch %s\n", lattr);
|
||||
}
|
||||
#endif
|
||||
int regexmatch = GetFlag(mi, "regexmatch");
|
||||
match = 0;
|
||||
if (nval) {
|
||||
String *kwval = Getattr(mi, "value");
|
||||
match = rxsmatch ? Swig_name_rxsmatch_value(kwval, nval)
|
||||
match = regexmatch ? Swig_name_regexmatch_value(n, kwval, nval)
|
||||
: Swig_name_match_value(kwval, nval);
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "val %s %s %d %d \n", nval, kwval, match, ilen);
|
||||
|
|
@ -1277,7 +1316,7 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
|
|||
String *sfmt = Getattr(rn, "sourcefmt");
|
||||
String *sname = 0;
|
||||
int fullname = GetFlag(rn, "fullname");
|
||||
int rxstarget = GetFlag(rn, "rxstarget");
|
||||
int regextarget = GetFlag(rn, "regextarget");
|
||||
if (sfmt) {
|
||||
if (fullname && prefix) {
|
||||
String *pname = NewStringf("%s::%s", prefix, name);
|
||||
|
|
@ -1294,10 +1333,17 @@ Hash *Swig_name_nameobj_lget(List *namelist, Node *n, String *prefix, String *na
|
|||
DohIncref(name);
|
||||
}
|
||||
}
|
||||
match = rxstarget ? Swig_name_rxsmatch_value(tname, sname) : Swig_name_match_value(tname, sname);
|
||||
match = regextarget ? Swig_name_regexmatch_value(n, tname, sname)
|
||||
: Swig_name_match_value(tname, sname);
|
||||
Delete(sname);
|
||||
} else {
|
||||
match = 1;
|
||||
/* Applying the renaming rule may fail if it contains a %(regex)s expression that doesn't match the given name. */
|
||||
String *sname = NewStringf(Getattr(rn, "name"), name);
|
||||
if (sname) {
|
||||
if (Len(sname))
|
||||
match = 1;
|
||||
Delete(sname);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (match) {
|
||||
|
|
@ -1393,7 +1439,7 @@ void Swig_name_rename_add(String *prefix, String *name, SwigType *decl, Hash *ne
|
|||
|
||||
ParmList *declparms = declaratorparms;
|
||||
|
||||
const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "rxstarget", 0 };
|
||||
const char *rename_keys[] = { "fullname", "sourcefmt", "targetfmt", "continue", "regextarget", 0 };
|
||||
Swig_name_object_attach_keys(rename_keys, newname);
|
||||
|
||||
/* Add the name */
|
||||
|
|
@ -1604,19 +1650,20 @@ void Swig_name_inherit(String *base, String *derived) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Swig_name_decl()
|
||||
* void Swig_name_str()
|
||||
*
|
||||
* Return a stringified version of a C/C++ declaration without the return type.
|
||||
* The node passed in is expected to be a function. Some example return values:
|
||||
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate()"
|
||||
* "MyNameSpace::ABC::ABC(int,double)"
|
||||
* "MyNameSpace::ABC::constmethod(int) const"
|
||||
* Return a stringified version of a C/C++ symbol from a node.
|
||||
* The node passed in is expected to be a function, constructor, destructor or
|
||||
* variable. Some example return values:
|
||||
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate"
|
||||
* "MyNameSpace::ABC::ABC"
|
||||
* "MyNameSpace::ABC::constmethod"
|
||||
* "MyNameSpace::ABC::variablename"
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_decl(Node *n) {
|
||||
String *Swig_name_str(Node *n) {
|
||||
String *qname;
|
||||
String *decl;
|
||||
String *qualifier = Swig_symbol_qualified(n);
|
||||
String *name = Swig_scopename_last(Getattr(n, "name"));
|
||||
if (qualifier)
|
||||
|
|
@ -1642,10 +1689,36 @@ String *Swig_name_decl(Node *n) {
|
|||
Printf(qname, "%s::", qualifier);
|
||||
Printf(qname, "%s", SwigType_str(name, 0));
|
||||
|
||||
decl = NewStringf("%s(%s)%s", qname, ParmList_errorstr(Getattr(n, "parms")), SwigType_isconst(Getattr(n, "decl")) ? " const" : "");
|
||||
|
||||
Delete(name);
|
||||
Delete(qualifier);
|
||||
|
||||
return qname;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* void Swig_name_decl()
|
||||
*
|
||||
* Return a stringified version of a C/C++ declaration without the return type.
|
||||
* The node passed in is expected to be a function, constructor, destructor or
|
||||
* variable. Some example return values:
|
||||
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate()"
|
||||
* "MyNameSpace::ABC::ABC(int,double)"
|
||||
* "MyNameSpace::ABC::constmethod(int) const"
|
||||
* "MyNameSpace::ABC::variablename"
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *Swig_name_decl(Node *n) {
|
||||
String *qname;
|
||||
String *decl;
|
||||
|
||||
qname = Swig_name_str(n);
|
||||
|
||||
if (checkAttribute(n, "kind", "variable"))
|
||||
decl = NewStringf("%s", qname);
|
||||
else
|
||||
decl = NewStringf("%s(%s)%s", qname, ParmList_errorstr(Getattr(n, "parms")), SwigType_isconst(Getattr(n, "decl")) ? " const" : "");
|
||||
|
||||
Delete(qname);
|
||||
|
||||
return decl;
|
||||
|
|
@ -1655,7 +1728,8 @@ String *Swig_name_decl(Node *n) {
|
|||
* void Swig_name_fulldecl()
|
||||
*
|
||||
* Return a stringified version of a C/C++ declaration including the return type.
|
||||
* The node passed in is expected to be a function. Some example return values:
|
||||
* The node passed in is expected to be a function, constructor or destructor.
|
||||
* Some example return values:
|
||||
* "MyNameSpace::MyTemplate<MyNameSpace::ABC >::~MyTemplate()"
|
||||
* "MyNameSpace::ABC::ABC(int,double)"
|
||||
* "int * MyNameSpace::ABC::constmethod(int) const"
|
||||
|
|
|
|||
|
|
@ -11,21 +11,19 @@
|
|||
* Parameter list class.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_parms_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* NewParm()
|
||||
*
|
||||
* Create a new parameter from datatype 'type' and name 'name' copying
|
||||
* the file and line number from the Node file_line_node.
|
||||
* the file and line number from the Node from_node.
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
Parm *NewParm(SwigType *type, const_String_or_char_ptr name, Node *file_line_node) {
|
||||
Parm *NewParm(SwigType *type, const_String_or_char_ptr name, Node *from_node) {
|
||||
Parm *p = NewParmWithoutFileLineInfo(type, name);
|
||||
Setfile(p, Getfile(file_line_node));
|
||||
Setline(p, Getline(file_line_node));
|
||||
Setfile(p, Getfile(from_node));
|
||||
Setline(p, Getline(from_node));
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
@ -48,6 +46,20 @@ Parm *NewParmWithoutFileLineInfo(SwigType *type, const_String_or_char_ptr name)
|
|||
return p;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* NewParmNode()
|
||||
*
|
||||
* Create a new parameter from datatype 'type' and name and symbol table as
|
||||
* well as file and line number from the 'from_node'.
|
||||
* The resulting Parm will be similar to a Node used for typemap lookups.
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
||||
Parm *NewParmNode(SwigType *type, Node *from_node) {
|
||||
Parm *p = NewParm(type, Getattr(from_node, "name"), from_node);
|
||||
Setattr(p, "sym:symtab", Getattr(from_node, "sym:symtab"));
|
||||
return p;
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* CopyParm()
|
||||
* ------------------------------------------------------------------------ */
|
||||
|
|
|
|||
|
|
@ -14,12 +14,11 @@
|
|||
* to easily construct yacc-compatible scanners.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_scanner_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include <ctype.h>
|
||||
|
||||
extern String *cparse_file;
|
||||
extern int cparse_line;
|
||||
extern int cparse_cplusplus;
|
||||
extern int cparse_start_line;
|
||||
|
||||
|
|
@ -39,6 +38,13 @@ struct Scanner {
|
|||
List *brackets; /* Current level of < > brackets on each level */
|
||||
};
|
||||
|
||||
typedef struct Locator {
|
||||
String *filename;
|
||||
int line_number;
|
||||
struct Locator *next;
|
||||
} Locator;
|
||||
static int follow_locators = 0;
|
||||
|
||||
void Scanner_push_brackets(Scanner*);
|
||||
void Scanner_clear_brackets(Scanner*);
|
||||
|
||||
|
|
@ -61,6 +67,7 @@ Scanner *NewScanner(void) {
|
|||
s->text = NewStringEmpty();
|
||||
s->str = 0;
|
||||
s->error = 0;
|
||||
s->error_line = 0;
|
||||
s->freeze_line = 0;
|
||||
s->brackets = NewList();
|
||||
Scanner_push_brackets(s);
|
||||
|
|
@ -104,6 +111,12 @@ void Scanner_clear(Scanner * s) {
|
|||
s->nexttoken = -1;
|
||||
s->start_line = 0;
|
||||
s->yylen = 0;
|
||||
/* Should these be cleared too?
|
||||
s->idstart;
|
||||
s->file;
|
||||
s->error_line;
|
||||
s->freeze_line;
|
||||
*/
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -209,10 +222,8 @@ static char nextchar(Scanner * s) {
|
|||
if (Len(s->scanobjs) == 0)
|
||||
return 0;
|
||||
s->str = Getitem(s->scanobjs, 0);
|
||||
if (s->str) {
|
||||
s->line = Getline(s->str);
|
||||
DohIncref(s->str);
|
||||
}
|
||||
s->line = Getline(s->str);
|
||||
DohIncref(s->str);
|
||||
}
|
||||
if ((nc == '\n') && (!s->freeze_line))
|
||||
s->line++;
|
||||
|
|
@ -238,8 +249,7 @@ static void set_error(Scanner *s, int line, const_String_or_char_ptr msg) {
|
|||
* Returns error information (if any)
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *
|
||||
Scanner_errmsg(Scanner *s) {
|
||||
String *Scanner_errmsg(Scanner *s) {
|
||||
return s->error;
|
||||
}
|
||||
|
||||
|
|
@ -249,13 +259,12 @@ Scanner_errline(Scanner *s) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Scanner_freeze_line()
|
||||
* freeze_line()
|
||||
*
|
||||
* Freezes the current line number.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
Scanner_freeze_line(Scanner *s, int val) {
|
||||
static void freeze_line(Scanner *s, int val) {
|
||||
s->freeze_line = val;
|
||||
}
|
||||
|
||||
|
|
@ -343,7 +352,7 @@ static void retract(Scanner * s, int n) {
|
|||
if (str[l - 1] == '\n') {
|
||||
if (!s->freeze_line) s->line--;
|
||||
}
|
||||
Seek(s->str, -1, SEEK_CUR);
|
||||
(void)Seek(s->str, -1, SEEK_CUR);
|
||||
Delitem(s->text, DOH_END);
|
||||
}
|
||||
}
|
||||
|
|
@ -1414,10 +1423,9 @@ void Scanner_skip_line(Scanner * s) {
|
|||
int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
|
||||
char c;
|
||||
int num_levels = 1;
|
||||
int l;
|
||||
int state = 0;
|
||||
char temp[2] = { 0, 0 };
|
||||
l = s->line;
|
||||
String *locator = 0;
|
||||
temp[0] = (char) startchar;
|
||||
Clear(s->text);
|
||||
Setfile(s->text, Getfile(s->str));
|
||||
|
|
@ -1426,6 +1434,7 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
|
|||
Append(s->text, temp);
|
||||
while (num_levels > 0) {
|
||||
if ((c = nextchar(s)) == 0) {
|
||||
Delete(locator);
|
||||
return -1;
|
||||
}
|
||||
switch (state) {
|
||||
|
|
@ -1459,17 +1468,25 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
|
|||
else
|
||||
state = 11;
|
||||
break;
|
||||
case 12:
|
||||
case 12: /* first character inside C comment */
|
||||
if (c == '*')
|
||||
state = 14;
|
||||
else if (c == '@')
|
||||
state = 40;
|
||||
else
|
||||
state = 13;
|
||||
break;
|
||||
case 13:
|
||||
if (c == '*')
|
||||
state = 13;
|
||||
state = 14;
|
||||
break;
|
||||
case 14: /* possible end of C comment */
|
||||
if (c == '*')
|
||||
state = 14;
|
||||
else if (c == '/')
|
||||
state = 0;
|
||||
else
|
||||
state = 12;
|
||||
state = 13;
|
||||
break;
|
||||
case 20:
|
||||
if (c == '\"')
|
||||
|
|
@ -1489,10 +1506,43 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
|
|||
case 31:
|
||||
state = 30;
|
||||
break;
|
||||
/* 40-45 SWIG locator checks - a C comment with contents starting: @SWIG */
|
||||
case 40:
|
||||
state = (c == 'S') ? 41 : (c == '*') ? 14 : 13;
|
||||
break;
|
||||
case 41:
|
||||
state = (c == 'W') ? 42 : (c == '*') ? 14 : 13;
|
||||
break;
|
||||
case 42:
|
||||
state = (c == 'I') ? 43 : (c == '*') ? 14 : 13;
|
||||
break;
|
||||
case 43:
|
||||
state = (c == 'G') ? 44 : (c == '*') ? 14 : 13;
|
||||
if (c == 'G') {
|
||||
Delete(locator);
|
||||
locator = NewString("/*@SWIG");
|
||||
}
|
||||
break;
|
||||
case 44:
|
||||
if (c == '*')
|
||||
state = 45;
|
||||
Putc(c, locator);
|
||||
break;
|
||||
case 45: /* end of SWIG locator in C comment */
|
||||
if (c == '/') {
|
||||
state = 0;
|
||||
Putc(c, locator);
|
||||
Scanner_locator(s, locator);
|
||||
} else {
|
||||
/* malformed locator */
|
||||
state = (c == '*') ? 14 : 13;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
Delete(locator);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1503,8 +1553,98 @@ int Scanner_skip_balanced(Scanner * s, int startchar, int endchar) {
|
|||
* operator.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
Scanner_isoperator(int tokval) {
|
||||
int Scanner_isoperator(int tokval) {
|
||||
if (tokval >= 100) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* locator()
|
||||
*
|
||||
* Support for locator strings. These are strings of the form
|
||||
* @SWIG:filename,line,id@ emitted by the SWIG preprocessor. They
|
||||
* are primarily used for macro line number reporting.
|
||||
* We just use the locator to mark when to activate/deactivate linecounting.
|
||||
* ---------------------------------------------------------------------- */
|
||||
|
||||
|
||||
void Scanner_locator(Scanner *s, String *loc) {
|
||||
static Locator *locs = 0;
|
||||
static int expanding_macro = 0;
|
||||
|
||||
if (!follow_locators) {
|
||||
if (Equal(loc, "/*@SWIG@*/")) {
|
||||
/* End locator. */
|
||||
if (expanding_macro)
|
||||
--expanding_macro;
|
||||
} else {
|
||||
/* Begin locator. */
|
||||
++expanding_macro;
|
||||
}
|
||||
/* Freeze line number processing in Scanner */
|
||||
freeze_line(s,expanding_macro);
|
||||
} else {
|
||||
int c;
|
||||
Locator *l;
|
||||
(void)Seek(loc, 7, SEEK_SET);
|
||||
c = Getc(loc);
|
||||
if (c == '@') {
|
||||
/* Empty locator. We pop the last location off */
|
||||
if (locs) {
|
||||
Scanner_set_location(s, locs->filename, locs->line_number);
|
||||
cparse_file = locs->filename;
|
||||
cparse_line = locs->line_number;
|
||||
l = locs->next;
|
||||
free(locs);
|
||||
locs = l;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* We're going to push a new location */
|
||||
l = (Locator *) malloc(sizeof(Locator));
|
||||
l->filename = cparse_file;
|
||||
l->line_number = cparse_line;
|
||||
l->next = locs;
|
||||
locs = l;
|
||||
|
||||
/* Now, parse the new location out of the locator string */
|
||||
{
|
||||
String *fn = NewStringEmpty();
|
||||
/* Putc(c, fn); */
|
||||
|
||||
while ((c = Getc(loc)) != EOF) {
|
||||
if ((c == '@') || (c == ','))
|
||||
break;
|
||||
Putc(c, fn);
|
||||
}
|
||||
cparse_file = Swig_copy_string(Char(fn));
|
||||
Clear(fn);
|
||||
cparse_line = 1;
|
||||
/* Get the line number */
|
||||
while ((c = Getc(loc)) != EOF) {
|
||||
if ((c == '@') || (c == ','))
|
||||
break;
|
||||
Putc(c, fn);
|
||||
}
|
||||
cparse_line = atoi(Char(fn));
|
||||
Clear(fn);
|
||||
|
||||
/* Get the rest of it */
|
||||
while ((c = Getc(loc)) != EOF) {
|
||||
if (c == '@')
|
||||
break;
|
||||
Putc(c, fn);
|
||||
}
|
||||
/* Swig_diagnostic(cparse_file, cparse_line, "Scanner_set_location\n"); */
|
||||
Scanner_set_location(s, cparse_file, cparse_line);
|
||||
Delete(fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Swig_cparse_follow_locators(int v) {
|
||||
follow_locators = v;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
* the form of simple strings.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_stype_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include "cparse.h"
|
||||
#include <ctype.h>
|
||||
|
|
@ -190,7 +188,7 @@ void SwigType_push(SwigType *t, String *cons) {
|
|||
* Testing functions for querying a raw datatype
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_ispointer_return(SwigType *t) {
|
||||
int SwigType_ispointer_return(const SwigType *t) {
|
||||
char *c;
|
||||
int idx;
|
||||
if (!t)
|
||||
|
|
@ -203,7 +201,7 @@ int SwigType_ispointer_return(SwigType *t) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SwigType_isreference_return(SwigType *t) {
|
||||
int SwigType_isreference_return(const SwigType *t) {
|
||||
char *c;
|
||||
int idx;
|
||||
if (!t)
|
||||
|
|
@ -216,7 +214,7 @@ int SwigType_isreference_return(SwigType *t) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SwigType_isconst(SwigType *t) {
|
||||
int SwigType_isconst(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -242,7 +240,7 @@ int SwigType_isconst(SwigType *t) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SwigType_ismutable(SwigType *t) {
|
||||
int SwigType_ismutable(const SwigType *t) {
|
||||
int r;
|
||||
SwigType *qt = SwigType_typedef_resolve_all(t);
|
||||
if (SwigType_isreference(qt) || SwigType_isrvalue_reference(qt) || SwigType_isarray(qt)) {
|
||||
|
|
@ -253,7 +251,7 @@ int SwigType_ismutable(SwigType *t) {
|
|||
return r ? 0 : 1;
|
||||
}
|
||||
|
||||
int SwigType_isenum(SwigType *t) {
|
||||
int SwigType_isenum(const SwigType *t) {
|
||||
char *c = Char(t);
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -263,7 +261,7 @@ int SwigType_isenum(SwigType *t) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int SwigType_issimple(SwigType *t) {
|
||||
int SwigType_issimple(const SwigType *t) {
|
||||
char *c = Char(t);
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -321,7 +319,7 @@ int SwigType_issimple(SwigType *t) {
|
|||
* r.q(const).enum SWIGTYPE
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_default_create(SwigType *ty) {
|
||||
SwigType *SwigType_default_create(const SwigType *ty) {
|
||||
SwigType *r = 0;
|
||||
List *l;
|
||||
Iterator it;
|
||||
|
|
@ -379,7 +377,7 @@ SwigType *SwigType_default_create(SwigType *ty) {
|
|||
* SwigType_default_create() before calling this function.
|
||||
*
|
||||
* Example deductions (matching the examples described in SwigType_default_create),
|
||||
* where the the most specialized matches are highest in the list:
|
||||
* where the most specialized matches are highest in the list:
|
||||
*
|
||||
* a(ANY).a(ANY).SWIGTYPE
|
||||
* a(ANY).a().SWIGTYPE
|
||||
|
|
@ -400,7 +398,7 @@ SwigType *SwigType_default_create(SwigType *ty) {
|
|||
* SWIGTYPE
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_default_deduce(SwigType *t) {
|
||||
SwigType *SwigType_default_deduce(const SwigType *t) {
|
||||
SwigType *r = NewStringEmpty();
|
||||
List *l;
|
||||
Iterator it;
|
||||
|
|
@ -524,9 +522,11 @@ String *SwigType_namestr(const SwigType *t) {
|
|||
* Create a C string representation of a datatype.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
|
||||
String *SwigType_str(const SwigType *s, const_String_or_char_ptr id) {
|
||||
String *result;
|
||||
String *element = 0, *nextelement;
|
||||
String *element = 0;
|
||||
String *nextelement;
|
||||
String *forwardelement;
|
||||
List *elements;
|
||||
int nelements, i;
|
||||
|
||||
|
|
@ -549,8 +549,14 @@ String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
|
|||
for (i = 0; i < nelements; i++) {
|
||||
if (i < (nelements - 1)) {
|
||||
nextelement = Getitem(elements, i + 1);
|
||||
forwardelement = nextelement;
|
||||
if (SwigType_isqualifier(nextelement)) {
|
||||
if (i < (nelements - 2))
|
||||
forwardelement = Getitem(elements, i + 2);
|
||||
}
|
||||
} else {
|
||||
nextelement = 0;
|
||||
forwardelement = 0;
|
||||
}
|
||||
if (SwigType_isqualifier(element)) {
|
||||
DOH *q = 0;
|
||||
|
|
@ -560,7 +566,7 @@ String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
|
|||
Delete(q);
|
||||
} else if (SwigType_ispointer(element)) {
|
||||
Insert(result, 0, "*");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
|
|
@ -569,14 +575,14 @@ String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
|
|||
q = SwigType_parm(element);
|
||||
Insert(result, 0, "::*");
|
||||
Insert(result, 0, q);
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
Delete(q);
|
||||
} else if (SwigType_isreference(element)) {
|
||||
Insert(result, 0, "&");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
|
|
@ -625,12 +631,12 @@ String *SwigType_str(SwigType *s, const_String_or_char_ptr id) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_ltype(SwigType *ty)
|
||||
* SwigType_ltype(const SwigType *ty)
|
||||
*
|
||||
* Create a locally assignable type
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_ltype(SwigType *s) {
|
||||
SwigType *SwigType_ltype(const SwigType *s) {
|
||||
String *result;
|
||||
String *element;
|
||||
SwigType *td, *tc = 0;
|
||||
|
|
@ -735,7 +741,7 @@ SwigType *SwigType_ltype(SwigType *s) {
|
|||
* with an equivalent assignable version.
|
||||
* -------------------------------------------------------------------- */
|
||||
|
||||
String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id) {
|
||||
String *SwigType_lstr(const SwigType *s, const_String_or_char_ptr id) {
|
||||
String *result;
|
||||
SwigType *tc;
|
||||
|
||||
|
|
@ -752,17 +758,19 @@ String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id) {
|
|||
* datatype printed by str().
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
|
||||
String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr name) {
|
||||
String *result, *cast;
|
||||
String *element = 0, *nextelement;
|
||||
SwigType *td, *rs, *tc = 0;
|
||||
String *element = 0;
|
||||
String *nextelement;
|
||||
String *forwardelement;
|
||||
SwigType *td, *tc = 0;
|
||||
const SwigType *rs;
|
||||
List *elements;
|
||||
int nelements, i;
|
||||
int clear = 1;
|
||||
int firstarray = 1;
|
||||
int isreference = 0;
|
||||
int isfunction = 0;
|
||||
int isarray = 0;
|
||||
|
||||
result = NewStringEmpty();
|
||||
|
||||
|
|
@ -798,8 +806,14 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
|
|||
for (i = 0; i < nelements; i++) {
|
||||
if (i < (nelements - 1)) {
|
||||
nextelement = Getitem(elements, i + 1);
|
||||
forwardelement = nextelement;
|
||||
if (SwigType_isqualifier(nextelement)) {
|
||||
if (i < (nelements - 2))
|
||||
forwardelement = Getitem(elements, i + 2);
|
||||
}
|
||||
} else {
|
||||
nextelement = 0;
|
||||
forwardelement = 0;
|
||||
}
|
||||
if (SwigType_isqualifier(element)) {
|
||||
DOH *q = 0;
|
||||
|
|
@ -810,7 +824,7 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
|
|||
clear = 0;
|
||||
} else if (SwigType_ispointer(element)) {
|
||||
Insert(result, 0, "*");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
|
|
@ -821,25 +835,27 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
|
|||
q = SwigType_parm(element);
|
||||
Insert(result, 0, q);
|
||||
Delete(q);
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
firstarray = 0;
|
||||
} else if (SwigType_isreference(element)) {
|
||||
Insert(result, 0, "&");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
isreference = 1;
|
||||
if (!isfunction)
|
||||
isreference = 1;
|
||||
} else if (SwigType_isrvalue_reference(element)) {
|
||||
Insert(result, 0, "&&");
|
||||
if ((nextelement) && ((SwigType_isfunction(nextelement) || (SwigType_isarray(nextelement))))) {
|
||||
if ((forwardelement) && ((SwigType_isfunction(forwardelement) || (SwigType_isarray(forwardelement))))) {
|
||||
Insert(result, 0, "(");
|
||||
Append(result, ")");
|
||||
}
|
||||
isreference = 1;
|
||||
if (!isfunction)
|
||||
isreference = 1;
|
||||
clear = 0;
|
||||
} else if (SwigType_isarray(element)) {
|
||||
DOH *size;
|
||||
|
|
@ -854,7 +870,6 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
|
|||
Delete(size);
|
||||
clear = 0;
|
||||
}
|
||||
isarray = 1;
|
||||
} else if (SwigType_isfunction(element)) {
|
||||
DOH *parms, *p;
|
||||
int j, plen;
|
||||
|
|
@ -886,12 +901,8 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
|
|||
cast = NewStringf("(%s)", result);
|
||||
}
|
||||
if (name) {
|
||||
if (!isfunction) {
|
||||
if (isreference) {
|
||||
if (isarray)
|
||||
Clear(cast);
|
||||
Append(cast, "*");
|
||||
}
|
||||
if (isreference) {
|
||||
Append(cast, "*");
|
||||
}
|
||||
Append(cast, name);
|
||||
}
|
||||
|
|
@ -907,7 +918,7 @@ String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr name) {
|
|||
* Casts a variable from the real type to the local datatype.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr name) {
|
||||
String *SwigType_lcaststr(const SwigType *s, const_String_or_char_ptr name) {
|
||||
String *result;
|
||||
|
||||
result = NewStringEmpty();
|
||||
|
|
@ -939,27 +950,163 @@ String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr name) {
|
|||
return result;
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* Alternative implementation for manglestr_default. Mangling is similar to the original
|
||||
except for a few subtle differences for example in templates:
|
||||
namespace foo {
|
||||
template<class T> class bar {};
|
||||
typedef int Integer;
|
||||
void test2(bar<Integer *> *x);
|
||||
}
|
||||
Mangling is more consistent and changes from
|
||||
_p_foo__barT_int_p_t to
|
||||
_p_foo__barT_p_int_t.
|
||||
*/
|
||||
static void mangle_stringcopy(String *destination, const char *source, int count) {
|
||||
while (count-- > 0) {
|
||||
char newc = '_';
|
||||
if (!(*source == '.' || *source == ':' || *source == ' '))
|
||||
newc = *source;
|
||||
/* TODO: occasionally '*' or numerics need converting to '_', eg in array dimensions and template expressions */
|
||||
Putc(newc, destination);
|
||||
source++;
|
||||
}
|
||||
}
|
||||
|
||||
/* keep old mangling since Java codes need it */
|
||||
String *SwigType_manglestr_default(SwigType *s) {
|
||||
char *c;
|
||||
String *result = 0;
|
||||
String *base = 0;
|
||||
static void mangle_subtype(String *mangled, SwigType *s);
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* mangle_namestr()
|
||||
*
|
||||
* Mangles a type taking care of template expansions. Similar to SwigType_namestr().
|
||||
* The type may include a trailing '.', for example "p."
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void mangle_namestr(String *mangled, SwigType *t) {
|
||||
int length = Len(t);
|
||||
if (SwigType_isqualifier(t)) {
|
||||
Append(mangled, "q_");
|
||||
mangle_stringcopy(mangled, Char(t)+2, length-4);
|
||||
Append(mangled, "__");
|
||||
} else if (SwigType_ismemberpointer(t)) {
|
||||
Append(mangled, "m_");
|
||||
mangle_stringcopy(mangled, Char(t)+2, length-4);
|
||||
Append(mangled, "__");
|
||||
} else if (SwigType_isarray(t)) {
|
||||
Append(mangled, "a_");
|
||||
mangle_stringcopy(mangled, Char(t)+2, length-4);
|
||||
Append(mangled, "__");
|
||||
} else if (SwigType_isfunction(t)) {
|
||||
List *p = SwigType_parmlist(t);
|
||||
int sz = Len(p);
|
||||
int i;
|
||||
Append(mangled, "f_");
|
||||
for (i = 0; i < sz; i++) {
|
||||
mangle_subtype(mangled, Getitem(p, i));
|
||||
Putc('_', mangled);
|
||||
}
|
||||
Append(mangled, (sz > 0) ? "_" : "__");
|
||||
} else if (SwigType_isvarargs(t)) {
|
||||
Append(mangled, "___");
|
||||
} else {
|
||||
char *d = Char(t);
|
||||
char *c = strstr(d, "<(");
|
||||
if (!c || !strstr(c + 2, ")>")) {
|
||||
/* not a template type */
|
||||
mangle_stringcopy(mangled, Char(t), Len(t));
|
||||
} else {
|
||||
/* a template type */
|
||||
String *suffix;
|
||||
List *p;
|
||||
int i, sz;
|
||||
mangle_stringcopy(mangled, d, c-d);
|
||||
Putc('T', mangled);
|
||||
Putc('_', mangled);
|
||||
|
||||
p = SwigType_parmlist(c + 1);
|
||||
sz = Len(p);
|
||||
for (i = 0; i < sz; i++) {
|
||||
mangle_subtype(mangled, Getitem(p, i));
|
||||
Putc('_', mangled);
|
||||
}
|
||||
Putc('t', mangled);
|
||||
suffix = SwigType_templatesuffix(t);
|
||||
if (Len(suffix) > 0) {
|
||||
mangle_namestr(mangled, suffix);
|
||||
} else {
|
||||
Append(mangled, suffix);
|
||||
}
|
||||
Delete(suffix);
|
||||
Delete(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void mangle_subtype(String *mangled, SwigType *s) {
|
||||
List *elements;
|
||||
int nelements, i;
|
||||
|
||||
assert(s);
|
||||
elements = SwigType_split(s);
|
||||
nelements = Len(elements);
|
||||
for (i = 0; i < nelements; i++) {
|
||||
SwigType *element = Getitem(elements, i);
|
||||
mangle_namestr(mangled, element);
|
||||
}
|
||||
Delete(elements);
|
||||
}
|
||||
|
||||
static String *manglestr_default(const SwigType *s) {
|
||||
String *mangled = NewString("_");
|
||||
SwigType *sr = SwigType_typedef_resolve_all(s);
|
||||
SwigType *sq = SwigType_typedef_qualified(sr);
|
||||
SwigType *ss = SwigType_remove_global_scope_prefix(sq);
|
||||
SwigType *type = ss;
|
||||
SwigType *lt;
|
||||
SwigType *sr = SwigType_typedef_qualified(s);
|
||||
SwigType *ss = SwigType_typedef_resolve_all(sr);
|
||||
|
||||
s = ss;
|
||||
|
||||
if (SwigType_istemplate(ss)) {
|
||||
SwigType *ty = Swig_symbol_template_deftype(ss, 0);
|
||||
Delete(ss);
|
||||
ss = ty;
|
||||
s = ss;
|
||||
type = ss;
|
||||
}
|
||||
|
||||
lt = SwigType_ltype(type);
|
||||
|
||||
Replace(lt, "struct ", "", DOH_REPLACE_ANY);
|
||||
Replace(lt, "class ", "", DOH_REPLACE_ANY);
|
||||
Replace(lt, "union ", "", DOH_REPLACE_ANY);
|
||||
Replace(lt, "enum ", "", DOH_REPLACE_ANY);
|
||||
|
||||
mangle_subtype(mangled, lt);
|
||||
|
||||
Delete(ss);
|
||||
Delete(sq);
|
||||
Delete(sr);
|
||||
|
||||
lt = SwigType_ltype(s);
|
||||
return mangled;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static String *manglestr_default(const SwigType *s) {
|
||||
char *c;
|
||||
String *result = 0;
|
||||
String *base = 0;
|
||||
SwigType *lt;
|
||||
SwigType *sr = SwigType_typedef_resolve_all(s);
|
||||
SwigType *sq = SwigType_typedef_qualified(sr);
|
||||
SwigType *ss = SwigType_remove_global_scope_prefix(sq);
|
||||
SwigType *type = ss;
|
||||
|
||||
if (SwigType_istemplate(ss)) {
|
||||
SwigType *ty = Swig_symbol_template_deftype(ss, 0);
|
||||
Delete(ss);
|
||||
ss = ty;
|
||||
type = ss;
|
||||
}
|
||||
|
||||
lt = SwigType_ltype(type);
|
||||
result = SwigType_prefix(lt);
|
||||
base = SwigType_base(lt);
|
||||
|
||||
|
|
@ -1006,13 +1153,23 @@ String *SwigType_manglestr_default(SwigType *s) {
|
|||
Insert(result, 0, "_");
|
||||
Delete(lt);
|
||||
Delete(base);
|
||||
if (ss)
|
||||
Delete(ss);
|
||||
Delete(ss);
|
||||
Delete(sq);
|
||||
Delete(sr);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
String *SwigType_manglestr(SwigType *s) {
|
||||
return SwigType_manglestr_default(s);
|
||||
String *SwigType_manglestr(const SwigType *s) {
|
||||
#if 0
|
||||
/* Debugging checks to ensure a proper SwigType is passed in and not a stringified type */
|
||||
String *angle = Strstr(s, "<");
|
||||
if (angle && Strncmp(angle, "<(", 2) != 0)
|
||||
Printf(stderr, "SwigType_manglestr error: %s\n", s);
|
||||
else if (Strstr(s, "*") || Strstr(s, "&") || Strstr(s, "["))
|
||||
Printf(stderr, "SwigType_manglestr error: %s\n", s);
|
||||
#endif
|
||||
return manglestr_default(s);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -1131,7 +1288,7 @@ SwigType *SwigType_remove_global_scope_prefix(const SwigType *t) {
|
|||
* Checks type declarators for a match
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_check_decl(SwigType *ty, const SwigType *decl) {
|
||||
int SwigType_check_decl(const SwigType *ty, const SwigType *decl) {
|
||||
SwigType *t, *t1, *t2;
|
||||
int r;
|
||||
t = SwigType_typedef_resolve_all(ty);
|
||||
|
|
|
|||
|
|
@ -136,86 +136,83 @@ extern "C" {
|
|||
extern SwigType *SwigType_add_function(SwigType *t, ParmList *parms);
|
||||
extern SwigType *SwigType_add_template(SwigType *t, ParmList *parms);
|
||||
extern SwigType *SwigType_pop_function(SwigType *t);
|
||||
extern ParmList *SwigType_function_parms(SwigType *t, Node *file_line_node);
|
||||
extern ParmList *SwigType_function_parms(const SwigType *t, Node *file_line_node);
|
||||
extern List *SwigType_split(const SwigType *t);
|
||||
extern String *SwigType_pop(SwigType *t);
|
||||
extern void SwigType_push(SwigType *t, SwigType *s);
|
||||
extern void SwigType_push(SwigType *t, String *s);
|
||||
extern List *SwigType_parmlist(const SwigType *p);
|
||||
extern String *SwigType_parm(String *p);
|
||||
extern String *SwigType_str(SwigType *s, const_String_or_char_ptr id);
|
||||
extern String *SwigType_lstr(SwigType *s, const_String_or_char_ptr id);
|
||||
extern String *SwigType_rcaststr(SwigType *s, const_String_or_char_ptr id);
|
||||
extern String *SwigType_lcaststr(SwigType *s, const_String_or_char_ptr id);
|
||||
extern String *SwigType_manglestr(SwigType *t);
|
||||
extern SwigType *SwigType_ltype(SwigType *t);
|
||||
extern int SwigType_ispointer(SwigType *t);
|
||||
extern int SwigType_ispointer_return(SwigType *t);
|
||||
extern int SwigType_isfunctionpointer(SwigType *t);
|
||||
extern int SwigType_ismemberpointer(SwigType *t);
|
||||
extern int SwigType_isreference(SwigType *t);
|
||||
extern int SwigType_isreference_return(SwigType *t);
|
||||
extern int SwigType_isrvalue_reference(SwigType *t);
|
||||
extern int SwigType_isarray(SwigType *t);
|
||||
extern int SwigType_prefix_is_simple_1D_array(SwigType *t);
|
||||
extern int SwigType_isfunction(SwigType *t);
|
||||
extern int SwigType_isqualifier(SwigType *t);
|
||||
extern int SwigType_isconst(SwigType *t);
|
||||
extern int SwigType_issimple(SwigType *t);
|
||||
extern int SwigType_ismutable(SwigType *t);
|
||||
extern String *SwigType_parm(const SwigType *p);
|
||||
extern String *SwigType_str(const SwigType *s, const_String_or_char_ptr id);
|
||||
extern String *SwigType_lstr(const SwigType *s, const_String_or_char_ptr id);
|
||||
extern String *SwigType_rcaststr(const SwigType *s, const_String_or_char_ptr id);
|
||||
extern String *SwigType_lcaststr(const SwigType *s, const_String_or_char_ptr id);
|
||||
extern String *SwigType_manglestr(const SwigType *t);
|
||||
extern SwigType *SwigType_ltype(const SwigType *t);
|
||||
extern int SwigType_ispointer(const SwigType *t);
|
||||
extern int SwigType_ispointer_return(const SwigType *t);
|
||||
extern int SwigType_isfunctionpointer(const SwigType *t);
|
||||
extern int SwigType_ismemberpointer(const SwigType *t);
|
||||
extern int SwigType_isreference(const SwigType *t);
|
||||
extern int SwigType_isreference_return(const SwigType *t);
|
||||
extern int SwigType_isrvalue_reference(const SwigType *t);
|
||||
extern int SwigType_isarray(const SwigType *t);
|
||||
extern int SwigType_prefix_is_simple_1D_array(const SwigType *t);
|
||||
extern int SwigType_isfunction(const SwigType *t);
|
||||
extern int SwigType_isqualifier(const SwigType *t);
|
||||
extern int SwigType_isconst(const SwigType *t);
|
||||
extern int SwigType_issimple(const SwigType *t);
|
||||
extern int SwigType_ismutable(const SwigType *t);
|
||||
extern int SwigType_isvarargs(const SwigType *t);
|
||||
extern int SwigType_istemplate(const SwigType *t);
|
||||
extern int SwigType_isenum(SwigType *t);
|
||||
extern int SwigType_check_decl(SwigType *t, const_String_or_char_ptr decl);
|
||||
extern SwigType *SwigType_strip_qualifiers(SwigType *t);
|
||||
extern SwigType *SwigType_strip_single_qualifier(SwigType *t);
|
||||
extern int SwigType_isenum(const SwigType *t);
|
||||
extern int SwigType_check_decl(const SwigType *t, const_String_or_char_ptr decl);
|
||||
extern SwigType *SwigType_strip_qualifiers(const SwigType *t);
|
||||
extern SwigType *SwigType_strip_single_qualifier(const SwigType *t);
|
||||
extern SwigType *SwigType_functionpointer_decompose(SwigType *t);
|
||||
extern String *SwigType_base(const SwigType *t);
|
||||
extern String *SwigType_namestr(const SwigType *t);
|
||||
extern String *SwigType_templateprefix(const SwigType *t);
|
||||
extern String *SwigType_templatesuffix(const SwigType *t);
|
||||
extern String *SwigType_istemplate_templateprefix(const SwigType *t);
|
||||
extern String *SwigType_istemplate_only_templateprefix(const SwigType *t);
|
||||
extern String *SwigType_templateargs(const SwigType *t);
|
||||
extern String *SwigType_prefix(const SwigType *t);
|
||||
extern int SwigType_array_ndim(SwigType *t);
|
||||
extern String *SwigType_array_getdim(SwigType *t, int n);
|
||||
extern int SwigType_array_ndim(const SwigType *t);
|
||||
extern String *SwigType_array_getdim(const SwigType *t, int n);
|
||||
extern void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep);
|
||||
extern SwigType *SwigType_array_type(SwigType *t);
|
||||
extern String *SwigType_default(SwigType *t);
|
||||
extern SwigType *SwigType_default_create(SwigType *ty);
|
||||
extern SwigType *SwigType_default_deduce(SwigType *t);
|
||||
extern SwigType *SwigType_array_type(const SwigType *t);
|
||||
extern SwigType *SwigType_default_create(const SwigType *ty);
|
||||
extern SwigType *SwigType_default_deduce(const SwigType *t);
|
||||
extern void SwigType_typename_replace(SwigType *t, String *pat, String *rep);
|
||||
extern SwigType *SwigType_remove_global_scope_prefix(const SwigType *t);
|
||||
extern SwigType *SwigType_alttype(SwigType *t, int ltmap);
|
||||
|
||||
extern void SwigType_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
|
||||
extern SwigType *SwigType_template_deftype(const SwigType *type, Symtab *tscope);
|
||||
extern SwigType *SwigType_alttype(const SwigType *t, int ltmap);
|
||||
|
||||
/* --- Type-system managment --- */
|
||||
extern void SwigType_typesystem_init(void);
|
||||
extern int SwigType_typedef(SwigType *type, const_String_or_char_ptr name);
|
||||
extern int SwigType_typedef(const SwigType *type, const_String_or_char_ptr name);
|
||||
extern int SwigType_typedef_class(const_String_or_char_ptr name);
|
||||
extern int SwigType_typedef_using(const_String_or_char_ptr qname);
|
||||
extern void SwigType_inherit(String *subclass, String *baseclass, String *cast, String *conversioncode);
|
||||
extern int SwigType_issubtype(SwigType *subtype, SwigType *basetype);
|
||||
extern int SwigType_issubtype(const SwigType *subtype, const SwigType *basetype);
|
||||
extern void SwigType_scope_alias(String *aliasname, Typetab *t);
|
||||
extern void SwigType_using_scope(Typetab *t);
|
||||
extern void SwigType_new_scope(const_String_or_char_ptr name);
|
||||
extern void SwigType_inherit_scope(Typetab *scope);
|
||||
extern Typetab *SwigType_pop_scope(void);
|
||||
extern Typetab *SwigType_set_scope(Typetab *h);
|
||||
extern void SwigType_print_scope(Typetab *t);
|
||||
extern void SwigType_print_scope(void);
|
||||
extern SwigType *SwigType_typedef_resolve(const SwigType *t);
|
||||
extern SwigType *SwigType_typedef_resolve_all(SwigType *t);
|
||||
extern SwigType *SwigType_typedef_qualified(SwigType *t);
|
||||
extern int SwigType_istypedef(SwigType *t);
|
||||
extern int SwigType_isclass(SwigType *t);
|
||||
extern SwigType *SwigType_typedef_resolve_all(const SwigType *t);
|
||||
extern SwigType *SwigType_typedef_qualified(const SwigType *t);
|
||||
extern int SwigType_istypedef(const SwigType *t);
|
||||
extern int SwigType_isclass(const SwigType *t);
|
||||
extern void SwigType_attach_symtab(Symtab *syms);
|
||||
extern void SwigType_remember(SwigType *t);
|
||||
extern void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientdata);
|
||||
extern void SwigType_remember(const SwigType *t);
|
||||
extern void SwigType_remember_clientdata(const SwigType *t, const_String_or_char_ptr clientdata);
|
||||
extern void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata);
|
||||
extern void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *);
|
||||
extern void (*SwigType_remember_trace(void (*tf) (const SwigType *, String *, String *))) (const SwigType *, String *, String *);
|
||||
extern void SwigType_emit_type_table(File *f_headers, File *f_table);
|
||||
extern int SwigType_type(SwigType *t);
|
||||
extern int SwigType_type(const SwigType *t);
|
||||
|
||||
/* --- Symbol table module --- */
|
||||
|
||||
|
|
@ -238,6 +235,7 @@ extern "C" {
|
|||
extern void Swig_symbol_cadd(const_String_or_char_ptr symname, Node *node);
|
||||
extern Node *Swig_symbol_clookup(const_String_or_char_ptr symname, Symtab *tab);
|
||||
extern Node *Swig_symbol_clookup_check(const_String_or_char_ptr symname, Symtab *tab, int (*check) (Node *));
|
||||
extern Node *Swig_symbol_clookup_no_inherit(const_String_or_char_ptr name, Symtab *n);
|
||||
extern Symtab *Swig_symbol_cscope(const_String_or_char_ptr symname, Symtab *tab);
|
||||
extern Node *Swig_symbol_clookup_local(const_String_or_char_ptr symname, Symtab *tab);
|
||||
extern Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr symname, Symtab *tab, int (*check) (Node *));
|
||||
|
|
@ -248,7 +246,7 @@ extern "C" {
|
|||
extern void Swig_symbol_inherit(Symtab *tab);
|
||||
extern SwigType *Swig_symbol_type_qualify(const SwigType *ty, Symtab *tab);
|
||||
extern String *Swig_symbol_string_qualify(String *s, Symtab *tab);
|
||||
extern SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab);
|
||||
extern SwigType *Swig_symbol_typedef_reduce(const SwigType *ty, Symtab *tab);
|
||||
|
||||
extern ParmList *Swig_symbol_template_defargs(Parm *parms, Parm *targs, Symtab *tscope, Symtab *tsdecl);
|
||||
extern SwigType *Swig_symbol_template_deftype(const SwigType *type, Symtab *tscope);
|
||||
|
|
@ -294,6 +292,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
|
||||
extern String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname, SwigType *decl, String *oldname);
|
||||
extern String *Swig_name_warning(Node *n, String *prefix, String *name, SwigType *decl);
|
||||
extern String *Swig_name_str(Node *n);
|
||||
extern String *Swig_name_decl(Node *n);
|
||||
extern String *Swig_name_fulldecl(Node *n);
|
||||
|
||||
|
|
@ -327,7 +326,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern String *Swig_string_lower(String *s);
|
||||
extern String *Swig_string_upper(String *s);
|
||||
extern String *Swig_string_title(String *s);
|
||||
|
||||
extern String *Swig_pcre_version(void);
|
||||
extern void Swig_init(void);
|
||||
extern int Swig_value_wrapper_mode(int mode);
|
||||
|
||||
|
|
@ -342,8 +341,11 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern int Swig_warn_count(void);
|
||||
extern void Swig_error_msg_format(ErrorMessageFormat format);
|
||||
extern void Swig_diagnostic(const_String_or_char_ptr filename, int line, const char *fmt, ...);
|
||||
extern String *Swig_stringify_with_location(DOH *object);
|
||||
|
||||
/* --- C Wrappers --- */
|
||||
extern void Swig_cresult_name_set(const char *new_name);
|
||||
extern const char *Swig_cresult_name(void);
|
||||
extern String *Swig_cparm_name(Parm *p, int i);
|
||||
extern String *Swig_wrapped_var_type(SwigType *t, int varcref);
|
||||
extern int Swig_cargs(Wrapper *w, ParmList *l);
|
||||
|
|
@ -360,6 +362,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern String *Swig_cmemberget_call(const_String_or_char_ptr name, SwigType *t, String *self, int varcref);
|
||||
|
||||
extern int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self);
|
||||
extern void Swig_replace_special_variables(Node *n, Node *parentnode, String *code);
|
||||
|
||||
/* --- Transformations --- */
|
||||
|
||||
|
|
@ -377,6 +380,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
#define CWRAP_DIRECTOR_ONE_CALL 0x08
|
||||
#define CWRAP_DIRECTOR_TWO_CALLS 0x10
|
||||
#define CWRAP_ALL_PROTECTED_ACCESS 0x20
|
||||
#define CWRAP_SMART_POINTER_OVERLOAD 0x40
|
||||
|
||||
/* --- Director Helpers --- */
|
||||
extern Node *Swig_methodclass(Node *n);
|
||||
|
|
@ -394,6 +398,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern void Swig_typemap_debug(void);
|
||||
extern void Swig_typemap_search_debug_set(void);
|
||||
extern void Swig_typemap_used_debug_set(void);
|
||||
extern void Swig_typemap_register_debug_set(void);
|
||||
|
||||
extern String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f);
|
||||
extern String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode);
|
||||
|
|
@ -416,6 +421,8 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern void Wrapper_director_protected_mode_set(int);
|
||||
extern void Wrapper_all_protected_mode_set(int);
|
||||
extern void Language_replace_special_variables(String *method, String *tm, Parm *parm);
|
||||
extern void Swig_print(DOH *object, int count);
|
||||
extern void Swig_print_with_location(DOH *object, int count);
|
||||
|
||||
|
||||
/* -- template init -- */
|
||||
|
|
|
|||
|
|
@ -26,10 +26,11 @@ extern void Swig_set_push_dir(int dopush);
|
|||
extern int Swig_get_push_dir(void);
|
||||
extern void Swig_register_filebyname(const_String_or_char_ptr filename, File *outfile);
|
||||
extern File *Swig_filebyname(const_String_or_char_ptr filename);
|
||||
extern char *Swig_file_suffix(const_String_or_char_ptr filename);
|
||||
extern char *Swig_file_basename(const_String_or_char_ptr filename);
|
||||
extern char *Swig_file_filename(const_String_or_char_ptr filename);
|
||||
extern char *Swig_file_dirname(const_String_or_char_ptr filename);
|
||||
extern String *Swig_file_extension(const_String_or_char_ptr filename);
|
||||
extern String *Swig_file_basename(const_String_or_char_ptr filename);
|
||||
extern String *Swig_file_filename(const_String_or_char_ptr filename);
|
||||
extern String *Swig_file_dirname(const_String_or_char_ptr filename);
|
||||
extern void Swig_file_debug_set();
|
||||
|
||||
/* Delimiter used in accessing files and directories */
|
||||
|
||||
|
|
|
|||
|
|
@ -13,8 +13,9 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* Individual parameters */
|
||||
extern Parm *NewParm(SwigType *type, const_String_or_char_ptr name, Node *file_line_node);
|
||||
extern Parm *NewParm(SwigType *type, const_String_or_char_ptr name, Node *from_node);
|
||||
extern Parm *NewParmWithoutFileLineInfo(SwigType *type, const_String_or_char_ptr name);
|
||||
extern Parm *NewParmNode(SwigType *type, Node *from_node);
|
||||
extern Parm *CopyParm(Parm *p);
|
||||
|
||||
/* Parameter lists */
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ extern void Scanner_idstart(Scanner *, const char *idchar);
|
|||
extern String *Scanner_errmsg(Scanner *);
|
||||
extern int Scanner_errline(Scanner *);
|
||||
extern int Scanner_isoperator(int tokval);
|
||||
extern void Scanner_freeze_line(Scanner *s, int val);
|
||||
extern void Scanner_locator(Scanner *, String *loc);
|
||||
|
||||
/* Note: Tokens in range 100+ are for C/C++ operators */
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* This file implements the SWIG symbol table. See details below.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_symbol_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include "swigwarn.h"
|
||||
#include <ctype.h>
|
||||
|
|
@ -176,6 +174,8 @@ static Hash *current_symtab = 0; /* Current symbol table node */
|
|||
static Hash *symtabs = 0; /* Hash of all symbol tables by fully-qualified name */
|
||||
static Hash *global_scope = 0; /* Global scope */
|
||||
|
||||
static int use_inherit = 1;
|
||||
|
||||
/* common attribute keys, to avoid calling find_key all the times */
|
||||
|
||||
|
||||
|
|
@ -222,7 +222,10 @@ static void symbol_print_symbols(const char *symboltabletype) {
|
|||
Iterator it = First(symtab);
|
||||
while (it.key) {
|
||||
String *symname = it.key;
|
||||
Printf(stdout, " %s\n", symname);
|
||||
Printf(stdout, " %s (%s)\n", symname, nodeType(it.item));
|
||||
/*
|
||||
Printf(stdout, " %s - %p (%s)\n", symname, it.item, Getattr(it.item, "name"));
|
||||
*/
|
||||
it = Next(it);
|
||||
}
|
||||
}
|
||||
|
|
@ -460,6 +463,7 @@ Symtab *Swig_symbol_current(void) {
|
|||
* Swig_symbol_alias()
|
||||
*
|
||||
* Makes an alias for a symbol in the global symbol table.
|
||||
* Primarily for namespace aliases such as 'namespace X = Y;'.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_symbol_alias(const_String_or_char_ptr aliasname, Symtab *s) {
|
||||
|
|
@ -478,7 +482,9 @@ void Swig_symbol_alias(const_String_or_char_ptr aliasname, Symtab *s) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_inherit()
|
||||
*
|
||||
* Inherit symbols from another scope.
|
||||
* Inherit symbols from another scope. Primarily for C++ inheritance and
|
||||
* for using directives, such as 'using namespace X;'
|
||||
* but not for using declarations, such as 'using A;'.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_symbol_inherit(Symtab *s) {
|
||||
|
|
@ -532,6 +538,7 @@ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) {
|
|||
|
||||
if (!name)
|
||||
return;
|
||||
|
||||
if (SwigType_istemplate(name)) {
|
||||
String *cname = NewString(name);
|
||||
String *dname = Swig_symbol_template_deftype(cname, 0);
|
||||
|
|
@ -542,7 +549,7 @@ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) {
|
|||
Delete(cname);
|
||||
}
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stderr, "symbol_cadd %s %x\n", name, n);
|
||||
Printf(stderr, "symbol_cadd %s %p\n", name, n);
|
||||
#endif
|
||||
cn = Getattr(ccurrent, name);
|
||||
|
||||
|
|
@ -877,7 +884,7 @@ Node *Swig_symbol_add(const_String_or_char_ptr symname, Node *n) {
|
|||
/* Well, we made it this far. Guess we can drop the symbol in place */
|
||||
Setattr(n, "sym:symtab", current_symtab);
|
||||
Setattr(n, "sym:name", symname);
|
||||
/* Printf(stdout,"%s %x\n", Getattr(n,"sym:overname"), current_symtab); */
|
||||
/* Printf(stdout,"%s %p\n", Getattr(n,"sym:overname"), current_symtab); */
|
||||
assert(!Getattr(n, "sym:overname"));
|
||||
overname = NewStringf("__SWIG_%d", pn);
|
||||
Setattr(n, "sym:overname", overname);
|
||||
|
|
@ -924,11 +931,10 @@ static Node *_symbol_lookup(const String *name, Symtab *symtab, int (*check) (No
|
|||
return 0;
|
||||
Setmark(symtab, 1);
|
||||
|
||||
|
||||
n = Getattr(sym, name);
|
||||
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stderr, "symbol_look %s %x %x %s\n", name, n, symtab, Getattr(symtab, "name"));
|
||||
Printf(stderr, "symbol_look %s %p %p %s\n", name, n, symtab, Getattr(symtab, "name"));
|
||||
#endif
|
||||
|
||||
if (n) {
|
||||
|
|
@ -960,10 +966,11 @@ static Node *_symbol_lookup(const String *name, Symtab *symtab, int (*check) (No
|
|||
Delete(dname);
|
||||
if (n)
|
||||
return n;
|
||||
Setmark(symtab, 1);
|
||||
}
|
||||
|
||||
inherit = Getattr(symtab, "inherit");
|
||||
if (inherit) {
|
||||
if (inherit && use_inherit) {
|
||||
int i, len;
|
||||
len = Len(inherit);
|
||||
for (i = 0; i < len; i++) {
|
||||
|
|
@ -1049,6 +1056,25 @@ static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symt
|
|||
Node *pn = Getattr(symtab, "parentNode");
|
||||
if (pn)
|
||||
n = symbol_lookup_qualified(name, pn, prefix, local, checkfunc);
|
||||
|
||||
/* Check inherited scopes */
|
||||
if (!n) {
|
||||
List *inherit = Getattr(symtab, "inherit");
|
||||
if (inherit && use_inherit) {
|
||||
int i, len;
|
||||
len = Len(inherit);
|
||||
for (i = 0; i < len; i++) {
|
||||
Node *prefix_node = symbol_lookup(prefix, Getitem(inherit, i), checkfunc);
|
||||
if (prefix_node) {
|
||||
Node *prefix_symtab = Getattr(prefix_node, "symtab");
|
||||
if (prefix_symtab) {
|
||||
n = symbol_lookup(name, prefix_symtab, checkfunc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
n = 0;
|
||||
}
|
||||
|
|
@ -1061,8 +1087,9 @@ static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symt
|
|||
* Swig_symbol_clookup()
|
||||
*
|
||||
* Look up a symbol in the symbol table. This uses the C name, not scripting
|
||||
* names. Note: If we come across a using a directive, we follow it to
|
||||
* to get the real node.
|
||||
* names. Note: If we come across a using declaration, we follow it to
|
||||
* to get the real node. Any using directives are also followed (but this is
|
||||
* implemented in symbol_lookup()).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Node *Swig_symbol_clookup(const_String_or_char_ptr name, Symtab *n) {
|
||||
|
|
@ -1203,22 +1230,23 @@ Node *Swig_symbol_clookup_check(const_String_or_char_ptr name, Symtab *n, int (*
|
|||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_clookup_local()
|
||||
*
|
||||
* Same as Swig_symbol_clookup but parent nodes are not searched, that is, just
|
||||
* this symbol table is searched.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) {
|
||||
Hash *h, *hsym;
|
||||
Hash *hsym;
|
||||
Node *s = 0;
|
||||
|
||||
if (!n) {
|
||||
hsym = current_symtab;
|
||||
h = ccurrent;
|
||||
} else {
|
||||
if (!Checkattr(n, "nodeType", "symboltable")) {
|
||||
n = Getattr(n, "sym:symtab");
|
||||
}
|
||||
assert(n);
|
||||
hsym = n;
|
||||
h = Getattr(n, "csymtab");
|
||||
}
|
||||
|
||||
if (Swig_scopename_check(name)) {
|
||||
|
|
@ -1256,19 +1284,17 @@ Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n, int (*checkfunc) (Node *)) {
|
||||
Hash *h, *hsym;
|
||||
Hash *hsym;
|
||||
Node *s = 0;
|
||||
|
||||
if (!n) {
|
||||
hsym = current_symtab;
|
||||
h = ccurrent;
|
||||
} else {
|
||||
if (!Checkattr(n, "nodeType", "symboltable")) {
|
||||
n = Getattr(n, "sym:symtab");
|
||||
}
|
||||
assert(n);
|
||||
hsym = n;
|
||||
h = Getattr(n, "csymtab");
|
||||
}
|
||||
|
||||
if (Swig_scopename_check(name)) {
|
||||
|
|
@ -1301,6 +1327,20 @@ Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n,
|
|||
return s;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_clookup_no_inherit()
|
||||
*
|
||||
* Symbol lookup like Swig_symbol_clookup but does not follow using declarations.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
Node *Swig_symbol_clookup_no_inherit(const_String_or_char_ptr name, Symtab *n) {
|
||||
Node *s = 0;
|
||||
assert(use_inherit==1);
|
||||
use_inherit = 0;
|
||||
s = Swig_symbol_clookup(name, n);
|
||||
use_inherit = 1;
|
||||
return s;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_cscope()
|
||||
|
|
@ -1411,7 +1451,7 @@ String *Swig_symbol_qualified(Node *n) {
|
|||
if (!symtab)
|
||||
return NewStringEmpty();
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stderr, "symbol_qscope %s %x %s\n", Getattr(n, "name"), symtab, Getattr(symtab, "name"));
|
||||
Printf(stderr, "symbol_qscope %s %p %s\n", Getattr(n, "name"), symtab, Getattr(symtab, "name"));
|
||||
#endif
|
||||
return Swig_symbol_qualifiedscopename(symtab);
|
||||
}
|
||||
|
|
@ -1427,14 +1467,14 @@ Node *Swig_symbol_isoverloaded(Node *n) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_type_qualify()
|
||||
* symbol_template_qualify()
|
||||
*
|
||||
* Create a fully qualified type name
|
||||
* Internal function to create a fully qualified type name for templates
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* This cache produces problems with OSS, don't active it */
|
||||
/* #define SWIG_TEMPLATE_QUALIFY_CACHE */
|
||||
static SwigType *Swig_symbol_template_qualify(const SwigType *e, Symtab *st) {
|
||||
static SwigType *symbol_template_qualify(const SwigType *e, Symtab *st) {
|
||||
String *tprefix, *tsuffix;
|
||||
SwigType *qprefix;
|
||||
List *targs;
|
||||
|
|
@ -1499,10 +1539,17 @@ static SwigType *Swig_symbol_template_qualify(const SwigType *e, Symtab *st) {
|
|||
}
|
||||
|
||||
|
||||
static int no_constructor(Node *n) {
|
||||
static int symbol_no_constructor(Node *n) {
|
||||
return !Checkattr(n, "nodeType", "constructor");
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_type_qualify()
|
||||
*
|
||||
* Create a fully qualified type name
|
||||
* Note: Does not resolve a constructor if passed in as the 'type'.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *Swig_symbol_type_qualify(const SwigType *t, Symtab *st) {
|
||||
List *elements;
|
||||
String *result = NewStringEmpty();
|
||||
|
|
@ -1519,13 +1566,14 @@ SwigType *Swig_symbol_type_qualify(const SwigType *t, Symtab *st) {
|
|||
for (i = 0; i < len; i++) {
|
||||
String *e = Getitem(elements, i);
|
||||
if (SwigType_issimple(e)) {
|
||||
Node *n = Swig_symbol_clookup_check(e, st, no_constructor);
|
||||
/* Note: the unary scope operator (::) is being removed from the template parameters here. */
|
||||
Node *n = Swig_symbol_clookup_check(e, st, symbol_no_constructor);
|
||||
if (n) {
|
||||
String *name = Getattr(n, "name");
|
||||
Clear(e);
|
||||
Append(e, name);
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stderr, "symbol_qual_ei %d %s %s %x\n", i, name, e, st);
|
||||
Printf(stderr, "symbol_qual_ei %d %s %s %p\n", i, name, e, st);
|
||||
#endif
|
||||
if (!Swig_scopename_check(name)) {
|
||||
String *qname = Swig_symbol_qualified(n);
|
||||
|
|
@ -1534,12 +1582,12 @@ SwigType *Swig_symbol_type_qualify(const SwigType *t, Symtab *st) {
|
|||
Insert(e, 0, qname);
|
||||
}
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stderr, "symbol_qual_sc %d %s %s %x\n", i, qname, e, st);
|
||||
Printf(stderr, "symbol_qual_sc %d %s %s %p\n", i, qname, e, st);
|
||||
#endif
|
||||
Delete(qname);
|
||||
}
|
||||
} else if (SwigType_istemplate(e)) {
|
||||
SwigType *ty = Swig_symbol_template_qualify(e, st);
|
||||
SwigType *ty = symbol_template_qualify(e, st);
|
||||
Clear(e);
|
||||
Append(e, ty);
|
||||
Delete(ty);
|
||||
|
|
@ -1572,7 +1620,7 @@ SwigType *Swig_symbol_type_qualify(const SwigType *t, Symtab *st) {
|
|||
}
|
||||
Delete(elements);
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stderr, "symbol_qualify %s %s %x %s\n", t, result, st, st ? Getattr(st, "name") : 0);
|
||||
Printf(stderr, "symbol_qualify %s %s %p %s\n", t, result, st, st ? Getattr(st, "name") : 0);
|
||||
#endif
|
||||
|
||||
return result;
|
||||
|
|
@ -1642,7 +1690,7 @@ SwigType *Swig_symbol_template_reduce(SwigType *qt, Symtab *ntab) {
|
|||
* Chase a typedef through symbol tables looking for a match.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab) {
|
||||
SwigType *Swig_symbol_typedef_reduce(const SwigType *ty, Symtab *tab) {
|
||||
SwigType *prefix, *base;
|
||||
Node *n;
|
||||
String *nt;
|
||||
|
|
@ -1749,8 +1797,9 @@ String *Swig_symbol_string_qualify(String *s, Symtab *st) {
|
|||
String *id = NewStringEmpty();
|
||||
String *r = NewStringEmpty();
|
||||
char *c = Char(s);
|
||||
int first_char = 1;
|
||||
while (*c) {
|
||||
if (isalpha((int) *c) || (*c == '_') || (*c == ':')) {
|
||||
if (isalpha((int) *c) || (*c == '_') || (*c == ':') || (*c == '~' && first_char) || (isdigit((int) *c) && !first_char)) {
|
||||
Putc(*c, id);
|
||||
have_id = 1;
|
||||
} else {
|
||||
|
|
@ -1763,6 +1812,7 @@ String *Swig_symbol_string_qualify(String *s, Symtab *st) {
|
|||
}
|
||||
Putc(*c, r);
|
||||
}
|
||||
first_char = (*c == ':');
|
||||
c++;
|
||||
}
|
||||
if (have_id) {
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@
|
|||
* parse trees.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_tree_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
|
|
@ -77,12 +75,12 @@ void Swig_print_node(Node *obj) {
|
|||
if ((Cmp(k, "nodeType") == 0) || (Cmp(k, "firstChild") == 0) || (Cmp(k, "lastChild") == 0) ||
|
||||
(Cmp(k, "parentNode") == 0) || (Cmp(k, "nextSibling") == 0) || (Cmp(k, "previousSibling") == 0) || (*(Char(k)) == '$')) {
|
||||
/* Do nothing */
|
||||
} else if (Cmp(k, "parms") == 0) {
|
||||
} else if (Cmp(k, "parms") == 0 || Cmp(k, "wrap:parms") == 0) {
|
||||
print_indent(2);
|
||||
Printf(stdout, "%-12s - %s\n", k, ParmList_protostr(Getattr(obj, k)));
|
||||
Printf(stdout, "%-12s - %s\n", k, ParmList_str_defaultargs(Getattr(obj, k)));
|
||||
} else {
|
||||
DOH *o;
|
||||
char *trunc = "";
|
||||
const char *trunc = "";
|
||||
print_indent(2);
|
||||
if (DohIsString(Getattr(obj, k))) {
|
||||
o = Str(Getattr(obj, k));
|
||||
|
|
@ -92,7 +90,7 @@ void Swig_print_node(Node *obj) {
|
|||
Printf(stdout, "%-12s - \"%(escape)-0.80s%s\"\n", k, o, trunc);
|
||||
Delete(o);
|
||||
} else {
|
||||
Printf(stdout, "%-12s - 0x%x\n", k, Getattr(obj, k));
|
||||
Printf(stdout, "%-12s - %p\n", k, Getattr(obj, k));
|
||||
}
|
||||
}
|
||||
ki = Next(ki);
|
||||
|
|
@ -291,10 +289,10 @@ void Swig_require(const char *ns, Node *n, ...) {
|
|||
if (view) {
|
||||
if (Strcmp(view, ns) != 0) {
|
||||
Setattr(n, NewStringf("%s:view", ns), view);
|
||||
Setattr(n, "view", ns);
|
||||
Setattr(n, "view", NewString(ns));
|
||||
}
|
||||
} else {
|
||||
Setattr(n, "view", ns);
|
||||
Setattr(n, "view", NewString(ns));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -337,10 +335,10 @@ void Swig_save(const char *ns, Node *n, ...) {
|
|||
if (view) {
|
||||
if (Strcmp(view, ns) != 0) {
|
||||
Setattr(n, NewStringf("%s:view", ns), view);
|
||||
Setattr(n, "view", ns);
|
||||
Setattr(n, "view", NewString(ns));
|
||||
}
|
||||
} else {
|
||||
Setattr(n, "view", ns);
|
||||
Setattr(n, "view", NewString(ns));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,6 @@
|
|||
* A somewhat generalized implementation of SWIG1.1 typemaps.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_typemap_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include "cparse.h"
|
||||
#include <ctype.h>
|
||||
|
|
@ -23,6 +21,7 @@ char cvsroot_typemap_c[] = "$Id$";
|
|||
|
||||
static int typemap_search_debug = 0;
|
||||
static int typemaps_used_debug = 0;
|
||||
static int typemap_register_debug = 0;
|
||||
static int in_typemap_search_multi = 0;
|
||||
|
||||
static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f, Node *file_line_node);
|
||||
|
|
@ -88,22 +87,34 @@ static Hash *get_typemap(int tm_scope, const SwigType *type) {
|
|||
return tm;
|
||||
}
|
||||
|
||||
static void set_typemap(int tm_scope, const SwigType *type, Hash *tm) {
|
||||
static void set_typemap(int tm_scope, const SwigType *type, Hash **tmhash) {
|
||||
SwigType *hashtype = 0;
|
||||
Hash *new_tm = 0;
|
||||
assert(*tmhash == 0);
|
||||
if (SwigType_istemplate(type)) {
|
||||
String *ty = Swig_symbol_template_deftype(type, 0);
|
||||
SwigType *rty = SwigType_typedef_resolve_all(type);
|
||||
String *ty = Swig_symbol_template_deftype(rty, 0);
|
||||
String *tyq = Swig_symbol_type_qualify(ty, 0);
|
||||
hashtype = SwigType_remove_global_scope_prefix(tyq);
|
||||
*tmhash = Getattr(typemaps[tm_scope], hashtype);
|
||||
Delete(rty);
|
||||
Delete(tyq);
|
||||
Delete(ty);
|
||||
} else {
|
||||
hashtype = SwigType_remove_global_scope_prefix(type);
|
||||
}
|
||||
|
||||
if (!*tmhash) {
|
||||
/* this type has not been seen before even after resolving template parameter types */
|
||||
new_tm = NewHash();
|
||||
*tmhash = new_tm;
|
||||
}
|
||||
|
||||
/* note that the unary scope operator (::) prefix indicating global scope has been removed from the type */
|
||||
Setattr(typemaps[tm_scope], hashtype, tm);
|
||||
Setattr(typemaps[tm_scope], hashtype, *tmhash);
|
||||
|
||||
Delete(hashtype);
|
||||
Delete(new_tm);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -189,9 +200,14 @@ static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *par
|
|||
String *tm_method;
|
||||
SwigType *type;
|
||||
String *pname;
|
||||
|
||||
if (!parms)
|
||||
return;
|
||||
|
||||
if (typemap_register_debug) {
|
||||
Printf(stdout, "Registering - %s\n", tmap_method);
|
||||
Swig_print_node(parms);
|
||||
}
|
||||
|
||||
tm_method = typemap_method_name(tmap_method);
|
||||
|
||||
/* Register the first type in the parameter list */
|
||||
|
|
@ -202,9 +218,7 @@ static void typemap_register(const_String_or_char_ptr tmap_method, ParmList *par
|
|||
/* See if this type has been seen before */
|
||||
tm = get_typemap(tm_scope, type);
|
||||
if (!tm) {
|
||||
tm = NewHash();
|
||||
set_typemap(tm_scope, type, tm);
|
||||
Delete(tm);
|
||||
set_typemap(tm_scope, type, &tm);
|
||||
}
|
||||
if (pname) {
|
||||
/* See if parameter has been seen before */
|
||||
|
|
@ -468,9 +482,7 @@ int Swig_typemap_apply(ParmList *src, ParmList *dest) {
|
|||
type = Getattr(lastdp, "type");
|
||||
tm = get_typemap(tm_scope, type);
|
||||
if (!tm) {
|
||||
tm = NewHash();
|
||||
set_typemap(tm_scope, type, tm);
|
||||
Delete(tm);
|
||||
set_typemap(tm_scope, type, &tm);
|
||||
}
|
||||
name = Getattr(lastdp, "name");
|
||||
if (name) {
|
||||
|
|
@ -728,8 +740,8 @@ static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type
|
|||
goto ret_result;
|
||||
|
||||
{
|
||||
/* Look for the type reduced to just the template prefix */
|
||||
SwigType *template_prefix = SwigType_istemplate_templateprefix(ctype);
|
||||
/* Look for the type reduced to just the template prefix - for templated types without the template parameter list being specified */
|
||||
SwigType *template_prefix = SwigType_istemplate_only_templateprefix(ctype);
|
||||
if (template_prefix) {
|
||||
tm = get_typemap(ts, template_prefix);
|
||||
result = typemap_search_helper(debug_display, tm, tm_method, template_prefix, cqualifiedname, cname, &backup);
|
||||
|
|
@ -963,7 +975,7 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
|
|||
{
|
||||
SwigType *star_type, *amp_type, *base_type, *lex_type;
|
||||
SwigType *ltype, *star_ltype, *amp_ltype;
|
||||
String *mangle, *star_mangle, *amp_mangle, *base_mangle, *base_name;
|
||||
String *mangle, *star_mangle, *amp_mangle, *base_mangle, *base_name, *base_type_str;
|
||||
String *descriptor, *star_descriptor, *amp_descriptor;
|
||||
String *ts;
|
||||
char *sc;
|
||||
|
|
@ -1132,21 +1144,20 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
|
|||
|
||||
/* Base type */
|
||||
if (SwigType_isarray(type)) {
|
||||
SwigType *bt = Copy(type);
|
||||
Delete(SwigType_pop_arrays(bt));
|
||||
base_type = SwigType_str(bt, 0);
|
||||
Delete(bt);
|
||||
base_type = Copy(type);
|
||||
Delete(SwigType_pop_arrays(base_type));
|
||||
} else {
|
||||
base_type = SwigType_base(type);
|
||||
}
|
||||
|
||||
base_name = SwigType_namestr(base_type);
|
||||
base_type_str = SwigType_str(base_type, 0);
|
||||
base_name = SwigType_namestr(base_type_str);
|
||||
if (index == 1) {
|
||||
Replace(s, "$basetype", base_name, DOH_REPLACE_ANY);
|
||||
replace_local_types(locals, "$basetype", base_name);
|
||||
}
|
||||
strcpy(varname, "basetype");
|
||||
Replace(s, var, base_type, DOH_REPLACE_ANY);
|
||||
Replace(s, var, base_type_str, DOH_REPLACE_ANY);
|
||||
replace_local_types(locals, var, base_name);
|
||||
|
||||
base_mangle = SwigType_manglestr(base_type);
|
||||
|
|
@ -1155,8 +1166,9 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
|
|||
strcpy(varname, "basemangle");
|
||||
Replace(s, var, base_mangle, DOH_REPLACE_ANY);
|
||||
Delete(base_mangle);
|
||||
Delete(base_type);
|
||||
Delete(base_name);
|
||||
Delete(base_type_str);
|
||||
Delete(base_type);
|
||||
|
||||
lex_type = SwigType_base(rtype);
|
||||
if (index == 1)
|
||||
|
|
@ -1176,7 +1188,7 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
|
|||
|
||||
/* Replace the bare $n variable */
|
||||
sprintf(var, "$%d", index);
|
||||
bare_substitution_count = Replace(s, var, lname, DOH_REPLACE_ANY);
|
||||
bare_substitution_count = Replace(s, var, lname, DOH_REPLACE_NUMBER_END);
|
||||
Delete(ftype);
|
||||
return bare_substitution_count;
|
||||
}
|
||||
|
|
@ -1252,16 +1264,15 @@ static void typemap_locals(DOHString * s, ParmList *l, Wrapper *f, int argnum) {
|
|||
* typemap_warn()
|
||||
*
|
||||
* If any warning message is attached to this parameter's "tmap:<method>:warning"
|
||||
* attribute, print that warning message.
|
||||
* attribute, return the warning message (special variables will need expanding
|
||||
* before displaying the warning).
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void typemap_warn(const_String_or_char_ptr tmap_method, Parm *p) {
|
||||
static String *typemap_warn(const_String_or_char_ptr tmap_method, Parm *p) {
|
||||
String *temp = NewStringf("%s:warning", tmap_method);
|
||||
String *w = Getattr(p, typemap_method_name(temp));
|
||||
Delete(temp);
|
||||
if (w) {
|
||||
Swig_warning(0, Getfile(p), Getline(p), "%s\n", w);
|
||||
}
|
||||
return w ? Copy(w) : 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -1293,9 +1304,11 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
|||
SwigType *mtype = 0;
|
||||
String *pname;
|
||||
String *qpname = 0;
|
||||
String *noscope_pname = 0;
|
||||
Hash *tm = 0;
|
||||
String *s = 0;
|
||||
String *sdef = 0;
|
||||
String *warning = 0;
|
||||
ParmList *locals;
|
||||
ParmList *kw;
|
||||
char temp[256];
|
||||
|
|
@ -1306,32 +1319,50 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
|||
int optimal_attribute = 0;
|
||||
int optimal_substitution = 0;
|
||||
int num_substitutions = 0;
|
||||
|
||||
/* special case, we need to check for 'ref' call and set the default code 'sdef' */
|
||||
if (node && Cmp(tmap_method, "newfree") == 0) {
|
||||
sdef = Swig_ref_call(node, lname);
|
||||
}
|
||||
SwigType *matchtype = 0;
|
||||
|
||||
type = Getattr(node, "type");
|
||||
if (!type)
|
||||
return sdef;
|
||||
|
||||
pname = Getattr(node, "name");
|
||||
|
||||
if (pname && node && checkAttribute(node, "kind", "function")) {
|
||||
/*
|
||||
For functions, add on a qualified name search, for example
|
||||
struct Foo {
|
||||
int *foo(int bar) -> Foo::foo
|
||||
};
|
||||
*/
|
||||
Symtab *st = Getattr(node, "sym:symtab");
|
||||
String *qsn = st ? Swig_symbol_string_qualify(pname, st) : 0;
|
||||
if (qsn && Len(qsn) && !Equal(qsn, pname))
|
||||
qpname = qsn;
|
||||
/* Special hook (hack!). Check for the 'ref' feature and add code it contains to any 'newfree' typemap code.
|
||||
* We could choose to put this hook into a number of different typemaps, not necessarily 'newfree'...
|
||||
* Rather confusingly 'newfree' is used to release memory and the 'ref' feature is used to add in memory references - yuck! */
|
||||
if (Cmp(tmap_method, "newfree") == 0) {
|
||||
String *base = SwigType_base(type);
|
||||
Node *typenode = Swig_symbol_clookup(base, 0);
|
||||
if (typenode)
|
||||
sdef = Swig_ref_call(typenode, lname);
|
||||
Delete(base);
|
||||
}
|
||||
|
||||
tm = typemap_search(tmap_method, type, pname, qpname, &mtype, node);
|
||||
pname = Getattr(node, "name");
|
||||
noscope_pname = Copy(pname);
|
||||
|
||||
if (pname && Getattr(node, "sym:symtab")) {
|
||||
/* Add on a qualified name search for any symbol in the symbol table, for example:
|
||||
* struct Foo {
|
||||
* int *foo(int bar) -> Foo::foo
|
||||
* };
|
||||
* Note that if node is a parameter (Parm *) then there will be no symbol table attached to the Parm *.
|
||||
*/
|
||||
String *qsn;
|
||||
if (Swig_scopename_check(pname)) {
|
||||
/* sometimes pname is qualified, so we remove all the scope for the lookup */
|
||||
Delete(noscope_pname);
|
||||
noscope_pname = Swig_scopename_last(pname);
|
||||
/*
|
||||
Printf(stdout, "Removed scope: %s => %s\n", pname, noscope_pname);
|
||||
*/
|
||||
}
|
||||
qsn = Swig_symbol_qualified(node);
|
||||
if (qsn && Len(qsn)) {
|
||||
qpname = NewStringf("%s::%s", qsn, noscope_pname);
|
||||
Delete(qsn);
|
||||
}
|
||||
}
|
||||
|
||||
tm = typemap_search(tmap_method, type, noscope_pname, qpname, &mtype, node);
|
||||
if (typemap_search_debug)
|
||||
debug_search_result_display(tm);
|
||||
if (typemaps_used_debug && tm) {
|
||||
|
|
@ -1344,6 +1375,8 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
|||
|
||||
Delete(qpname);
|
||||
qpname = 0;
|
||||
Delete(noscope_pname);
|
||||
noscope_pname = 0;
|
||||
|
||||
if (!tm)
|
||||
return sdef;
|
||||
|
|
@ -1382,6 +1415,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
|||
* If f and actioncode are NULL, then the caller is just looking to attach the "out" attributes
|
||||
* ie, not use the typemap code, otherwise both f and actioncode must be non null. */
|
||||
if (actioncode) {
|
||||
const String *result_equals = NewStringf("%s = ", Swig_cresult_name());
|
||||
clname = Copy(actioncode);
|
||||
/* check that the code in the typemap can be used in this optimal way.
|
||||
* The code should be in the form "result = ...;\n". We need to extract
|
||||
|
|
@ -1390,8 +1424,8 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
|||
* hack and circumvents the normal requirement for a temporary variable
|
||||
* to hold the result returned from a wrapped function call.
|
||||
*/
|
||||
if (Strncmp(clname, "result = ", 9) == 0) {
|
||||
int numreplacements = Replace(clname, "result = ", "", DOH_REPLACE_ID_BEGIN);
|
||||
if (Strncmp(clname, result_equals, 9) == 0) {
|
||||
int numreplacements = Replace(clname, result_equals, "", DOH_REPLACE_ID_BEGIN);
|
||||
if (numreplacements == 1) {
|
||||
numreplacements = Replace(clname, ";\n", "", DOH_REPLACE_ID_END);
|
||||
if (numreplacements == 1) {
|
||||
|
|
@ -1434,14 +1468,11 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
|||
lname = clname;
|
||||
}
|
||||
|
||||
if (mtype && SwigType_isarray(mtype)) {
|
||||
num_substitutions = typemap_replace_vars(s, locals, mtype, type, pname, (char *) lname, 1);
|
||||
} else {
|
||||
num_substitutions = typemap_replace_vars(s, locals, type, type, pname, (char *) lname, 1);
|
||||
}
|
||||
matchtype = mtype && SwigType_isarray(mtype) ? mtype : type;
|
||||
num_substitutions = typemap_replace_vars(s, locals, matchtype, type, pname, (char *) lname, 1);
|
||||
if (optimal_substitution && num_substitutions > 1) {
|
||||
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to optimal attribute usage in\n", Swig_name_decl(node));
|
||||
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(s), Getline(s), "the out typemap.\n");
|
||||
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(node), Getline(node), "Multiple calls to %s might be generated due to\n", Swig_name_decl(node));
|
||||
Swig_warning(WARN_TYPEMAP_OUT_OPTIMAL_MULTIPLE, Getfile(s), Getline(s), "optimal attribute usage in the out typemap.\n");
|
||||
}
|
||||
|
||||
if (locals && f) {
|
||||
|
|
@ -1458,9 +1489,8 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
|||
Replace(s, "$name", pname, DOH_REPLACE_ANY);
|
||||
|
||||
symname = Getattr(node, "sym:name");
|
||||
if (symname) {
|
||||
if (symname)
|
||||
Replace(s, "$symname", symname, DOH_REPLACE_ANY);
|
||||
}
|
||||
|
||||
Setattr(node, typemap_method_name(tmap_method), s);
|
||||
if (locals) {
|
||||
|
|
@ -1475,7 +1505,15 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
|||
}
|
||||
|
||||
/* Print warnings, if any */
|
||||
typemap_warn(cmethod, node);
|
||||
warning = typemap_warn(cmethod, node);
|
||||
if (warning) {
|
||||
typemap_replace_vars(warning, 0, matchtype, type, pname, (char *) lname, 1);
|
||||
Replace(warning, "$name", pname, DOH_REPLACE_ANY);
|
||||
if (symname)
|
||||
Replace(warning, "$symname", symname, DOH_REPLACE_ANY);
|
||||
Swig_warning(0, Getfile(node), Getline(node), "%s\n", warning);
|
||||
Delete(warning);
|
||||
}
|
||||
|
||||
/* Look for code fragments */
|
||||
{
|
||||
|
|
@ -1597,6 +1635,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p
|
|||
int nmatch = 0;
|
||||
int i;
|
||||
String *s;
|
||||
String *warning = 0;
|
||||
ParmList *locals;
|
||||
int argnum = 0;
|
||||
char temp[256];
|
||||
|
|
@ -1700,23 +1739,15 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p
|
|||
Printf(stdout, "nmatch: %d\n", nmatch);
|
||||
#endif
|
||||
for (i = 0; i < nmatch; i++) {
|
||||
SwigType *type;
|
||||
String *pname;
|
||||
String *lname;
|
||||
SwigType *mtype;
|
||||
SwigType *type = Getattr(p, "type");
|
||||
String *pname = Getattr(p, "name");
|
||||
String *lname = Getattr(p, "lname");
|
||||
SwigType *mtype = Getattr(p, "tmap:match");
|
||||
SwigType *matchtype = mtype ? mtype : type;
|
||||
|
||||
|
||||
type = Getattr(p, "type");
|
||||
pname = Getattr(p, "name");
|
||||
lname = Getattr(p, "lname");
|
||||
mtype = Getattr(p, "tmap:match");
|
||||
|
||||
if (mtype) {
|
||||
typemap_replace_vars(s, locals, mtype, type, pname, lname, i + 1);
|
||||
typemap_replace_vars(s, locals, matchtype, type, pname, lname, i + 1);
|
||||
if (mtype)
|
||||
Delattr(p, "tmap:match");
|
||||
} else {
|
||||
typemap_replace_vars(s, locals, type, type, pname, lname, i + 1);
|
||||
}
|
||||
|
||||
if (Checkattr(tm, "type", "SWIGTYPE")) {
|
||||
sprintf(temp, "%s:SWIGTYPE", cmethod);
|
||||
|
|
@ -1731,10 +1762,6 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p
|
|||
|
||||
replace_embedded_typemap(s, firstp, f, tm);
|
||||
|
||||
/* Replace the argument number */
|
||||
sprintf(temp, "%d", argnum);
|
||||
Replace(s, "$argnum", temp, DOH_REPLACE_ANY);
|
||||
|
||||
/* Attach attributes to object */
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "attach: %s %s %s\n", Getattr(firstp, "name"), typemap_method_name(tmap_method), s);
|
||||
|
|
@ -1754,8 +1781,23 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *p
|
|||
/* Attach kwargs */
|
||||
typemap_attach_kwargs(tm, tmap_method, firstp);
|
||||
|
||||
/* Replace the argument number */
|
||||
sprintf(temp, "%d", argnum);
|
||||
Replace(s, "$argnum", temp, DOH_REPLACE_ANY);
|
||||
|
||||
/* Print warnings, if any */
|
||||
typemap_warn(tmap_method, firstp);
|
||||
warning = typemap_warn(tmap_method, firstp);
|
||||
if (warning) {
|
||||
SwigType *type = Getattr(firstp, "type");
|
||||
String *pname = Getattr(firstp, "name");
|
||||
String *lname = Getattr(firstp, "lname");
|
||||
SwigType *mtype = Getattr(firstp, "tmap:match");
|
||||
SwigType *matchtype = mtype ? mtype : type;
|
||||
typemap_replace_vars(warning, 0, matchtype, type, pname, lname, 1);
|
||||
Replace(warning, "$argnum", temp, DOH_REPLACE_ANY);
|
||||
Swig_warning(0, Getfile(firstp), Getline(firstp), "%s\n", warning);
|
||||
Delete(warning);
|
||||
}
|
||||
|
||||
/* Look for code fragments */
|
||||
typemap_emit_code_fragments(tmap_method, firstp);
|
||||
|
|
@ -2013,12 +2055,13 @@ static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper
|
|||
|
||||
void Swig_typemap_debug() {
|
||||
int ts;
|
||||
int nesting_level = 2;
|
||||
Printf(stdout, "---[ typemaps ]--------------------------------------------------------------\n");
|
||||
|
||||
ts = tm_scope;
|
||||
while (ts >= 0) {
|
||||
Printf(stdout, "::: scope %d\n\n", ts);
|
||||
Printf(stdout, "%s\n", typemaps[ts]);
|
||||
Swig_print(typemaps[ts], nesting_level);
|
||||
ts--;
|
||||
}
|
||||
Printf(stdout, "-----------------------------------------------------------------------------\n");
|
||||
|
|
@ -2045,3 +2088,13 @@ void Swig_typemap_used_debug_set(void) {
|
|||
typemaps_used_debug = 1;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_typemap_register_debug_set()
|
||||
*
|
||||
* Turn on typemaps used debug display
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_typemap_register_debug_set(void) {
|
||||
typemap_register_debug = 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@
|
|||
* like typedef, namespaces, etc.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_typeobj_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include <ctype.h>
|
||||
|
||||
|
|
@ -214,7 +212,7 @@ SwigType *SwigType_pop(SwigType *t) {
|
|||
* Returns the parameter of an operator as a string
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *SwigType_parm(SwigType *t) {
|
||||
String *SwigType_parm(const SwigType *t) {
|
||||
char *start, *c;
|
||||
int nparens = 0;
|
||||
|
||||
|
|
@ -366,7 +364,7 @@ SwigType *SwigType_del_pointer(SwigType *t) {
|
|||
return t;
|
||||
}
|
||||
|
||||
int SwigType_ispointer(SwigType *t) {
|
||||
int SwigType_ispointer(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -408,7 +406,7 @@ SwigType *SwigType_del_reference(SwigType *t) {
|
|||
return t;
|
||||
}
|
||||
|
||||
int SwigType_isreference(SwigType *t) {
|
||||
int SwigType_isreference(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -443,7 +441,7 @@ SwigType *SwigType_del_rvalue_reference(SwigType *t) {
|
|||
return t;
|
||||
}
|
||||
|
||||
int SwigType_isrvalue_reference(SwigType *t) {
|
||||
int SwigType_isrvalue_reference(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -469,7 +467,7 @@ int SwigType_isrvalue_reference(SwigType *t) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) {
|
||||
char temp[256], newq[256];
|
||||
String *newq;
|
||||
int sz, added = 0;
|
||||
char *q, *cqual;
|
||||
|
||||
|
|
@ -477,8 +475,9 @@ SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) {
|
|||
cqual = Char(qual);
|
||||
|
||||
if (!(strncmp(c, "q(", 2) == 0)) {
|
||||
sprintf(temp, "q(%s).", cqual);
|
||||
String *temp = NewStringf("q(%s).", cqual);
|
||||
Insert(t, 0, temp);
|
||||
Delete(temp);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
|
@ -488,40 +487,40 @@ SwigType *SwigType_add_qualifier(SwigType *t, const_String_or_char_ptr qual) {
|
|||
order */
|
||||
|
||||
sz = element_size(c);
|
||||
strncpy(temp, c, (sz < 256) ? sz : 256);
|
||||
|
||||
if (strstr(temp, cqual)) {
|
||||
if (strstr(c, cqual)) {
|
||||
/* Qualifier already added */
|
||||
return t;
|
||||
}
|
||||
|
||||
/* Add the qualifier to the existing list. */
|
||||
|
||||
strcpy(newq, "q(");
|
||||
q = temp + 2;
|
||||
newq = NewString("q(");
|
||||
q = c + 2;
|
||||
q = strtok(q, " ).");
|
||||
while (q) {
|
||||
if (strcmp(cqual, q) < 0) {
|
||||
/* New qualifier is less that current qualifier. We need to insert it */
|
||||
strcat(newq, cqual);
|
||||
strcat(newq, " ");
|
||||
strcat(newq, q);
|
||||
Append(newq, cqual);
|
||||
Append(newq, " ");
|
||||
Append(newq, q);
|
||||
added = 1;
|
||||
} else {
|
||||
strcat(newq, q);
|
||||
Append(newq, q);
|
||||
}
|
||||
q = strtok(NULL, " ).");
|
||||
if (q) {
|
||||
strcat(newq, " ");
|
||||
Append(newq, " ");
|
||||
}
|
||||
}
|
||||
if (!added) {
|
||||
strcat(newq, " ");
|
||||
strcat(newq, cqual);
|
||||
Append(newq, " ");
|
||||
Append(newq, cqual);
|
||||
}
|
||||
strcat(newq, ").");
|
||||
Append(newq, ").");
|
||||
Delslice(t, 0, sz);
|
||||
Insert(t, 0, newq);
|
||||
Delete(newq);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
|
@ -533,7 +532,7 @@ SwigType *SwigType_del_qualifier(SwigType *t) {
|
|||
return t;
|
||||
}
|
||||
|
||||
int SwigType_isqualifier(SwigType *t) {
|
||||
int SwigType_isqualifier(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -548,7 +547,7 @@ int SwigType_isqualifier(SwigType *t) {
|
|||
* Function Pointers
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_isfunctionpointer(SwigType *t) {
|
||||
int SwigType_isfunctionpointer(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -601,7 +600,7 @@ SwigType *SwigType_del_memberpointer(SwigType *t) {
|
|||
return t;
|
||||
}
|
||||
|
||||
int SwigType_ismemberpointer(SwigType *t) {
|
||||
int SwigType_ismemberpointer(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -629,11 +628,11 @@ int SwigType_ismemberpointer(SwigType *t) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_add_array(SwigType *t, const_String_or_char_ptr size) {
|
||||
char temp[512];
|
||||
strcpy(temp, "a(");
|
||||
strcat(temp, Char(size));
|
||||
strcat(temp, ").");
|
||||
String *temp = NewString("a(");
|
||||
Append(temp, size);
|
||||
Append(temp, ").");
|
||||
Insert(t, 0, temp);
|
||||
Delete(temp);
|
||||
return t;
|
||||
}
|
||||
|
||||
|
|
@ -645,7 +644,7 @@ SwigType *SwigType_del_array(SwigType *t) {
|
|||
return t;
|
||||
}
|
||||
|
||||
int SwigType_isarray(SwigType *t) {
|
||||
int SwigType_isarray(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t)
|
||||
return 0;
|
||||
|
|
@ -661,13 +660,13 @@ int SwigType_isarray(SwigType *t) {
|
|||
* Determine if the type is a 1D array type that is treated as a pointer within SWIG
|
||||
* eg Foo[], Foo[3] return true, but Foo[3][3], Foo*[], Foo*[3], Foo**[] return false
|
||||
*/
|
||||
int SwigType_prefix_is_simple_1D_array(SwigType *t) {
|
||||
int SwigType_prefix_is_simple_1D_array(const SwigType *t) {
|
||||
char *c = Char(t);
|
||||
|
||||
if (c && (strncmp(c, "a(", 2) == 0)) {
|
||||
c = strchr(c, '.');
|
||||
c++;
|
||||
return (*c == 0);
|
||||
if (c)
|
||||
return (*(++c) == 0);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -687,25 +686,29 @@ SwigType *SwigType_pop_arrays(SwigType *t) {
|
|||
}
|
||||
|
||||
/* Return number of array dimensions */
|
||||
int SwigType_array_ndim(SwigType *t) {
|
||||
int SwigType_array_ndim(const SwigType *t) {
|
||||
int ndim = 0;
|
||||
char *c = Char(t);
|
||||
|
||||
while (c && (strncmp(c, "a(", 2) == 0)) {
|
||||
c = strchr(c, '.');
|
||||
c++;
|
||||
ndim++;
|
||||
if (c) {
|
||||
c++;
|
||||
ndim++;
|
||||
}
|
||||
}
|
||||
return ndim;
|
||||
}
|
||||
|
||||
/* Get nth array dimension */
|
||||
String *SwigType_array_getdim(SwigType *t, int n) {
|
||||
String *SwigType_array_getdim(const SwigType *t, int n) {
|
||||
char *c = Char(t);
|
||||
while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) {
|
||||
c = strchr(c, '.');
|
||||
c++;
|
||||
n--;
|
||||
if (c) {
|
||||
c++;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
if (n == 0) {
|
||||
String *dim = SwigType_parm(c);
|
||||
|
|
@ -734,8 +737,10 @@ void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep) {
|
|||
|
||||
while (c && (strncmp(c, "a(", 2) == 0) && (n > 0)) {
|
||||
c = strchr(c, '.');
|
||||
c++;
|
||||
n--;
|
||||
if (c) {
|
||||
c++;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
if (n == 0) {
|
||||
temp = *c;
|
||||
|
|
@ -752,7 +757,7 @@ void SwigType_array_setdim(SwigType *t, int n, const_String_or_char_ptr rep) {
|
|||
}
|
||||
|
||||
/* Return base type of an array */
|
||||
SwigType *SwigType_array_type(SwigType *ty) {
|
||||
SwigType *SwigType_array_type(const SwigType *ty) {
|
||||
SwigType *t;
|
||||
t = Copy(ty);
|
||||
while (SwigType_isarray(t)) {
|
||||
|
|
@ -810,7 +815,7 @@ SwigType *SwigType_pop_function(SwigType *t) {
|
|||
return g;
|
||||
}
|
||||
|
||||
int SwigType_isfunction(SwigType *t) {
|
||||
int SwigType_isfunction(const SwigType *t) {
|
||||
char *c;
|
||||
if (!t) {
|
||||
return 0;
|
||||
|
|
@ -832,7 +837,7 @@ int SwigType_isfunction(SwigType *t) {
|
|||
|
||||
/* Create a list of parameters from the type t, using the file_line_node Node for
|
||||
* file and line numbering for the parameters */
|
||||
ParmList *SwigType_function_parms(SwigType *t, Node *file_line_node) {
|
||||
ParmList *SwigType_function_parms(const SwigType *t, Node *file_line_node) {
|
||||
List *l = SwigType_parmlist(t);
|
||||
Hash *p, *pp = 0, *firstp = 0;
|
||||
Iterator o;
|
||||
|
|
@ -966,6 +971,32 @@ String *SwigType_istemplate_templateprefix(const SwigType *t) {
|
|||
return c ? NewStringWithSize(s, c - s) : 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_istemplate_only_templateprefix()
|
||||
*
|
||||
* Similar to SwigType_istemplate_templateprefix() but only returns the template
|
||||
* prefix if the type is just the template and not a subtype/symbol within the template.
|
||||
* Returns NULL if not a template or is a template with a symbol within the template.
|
||||
* For example:
|
||||
*
|
||||
* Foo<(p.int)> => Foo
|
||||
* Foo<(p.int)>::bar => NULL
|
||||
* r.q(const).Foo<(p.int)> => r.q(const).Foo
|
||||
* r.q(const).Foo<(p.int)>::bar => NULL
|
||||
* Foo => NULL
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *SwigType_istemplate_only_templateprefix(const SwigType *t) {
|
||||
int len = Len(t);
|
||||
const char *s = Char(t);
|
||||
if (len >= 4 && strcmp(s + len - 2, ")>") == 0) {
|
||||
const char *c = strstr(s, "<(");
|
||||
return c ? NewStringWithSize(s, c - s) : 0;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_templateargs()
|
||||
*
|
||||
|
|
@ -1133,7 +1164,7 @@ String *SwigType_prefix(const SwigType *t) {
|
|||
* Strip all qualifiers from a type and return a new type
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_strip_qualifiers(SwigType *t) {
|
||||
SwigType *SwigType_strip_qualifiers(const SwigType *t) {
|
||||
static Hash *memoize_stripped = 0;
|
||||
SwigType *r;
|
||||
List *l;
|
||||
|
|
@ -1177,7 +1208,7 @@ SwigType *SwigType_strip_qualifiers(SwigType *t) {
|
|||
* r.p.int => r.p.int
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_strip_single_qualifier(SwigType *t) {
|
||||
SwigType *SwigType_strip_single_qualifier(const SwigType *t) {
|
||||
static Hash *memoize_stripped = 0;
|
||||
SwigType *r = 0;
|
||||
List *l;
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@
|
|||
* run-time type checker is also handled here.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_typesys_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include "cparse.h"
|
||||
|
||||
|
|
@ -107,12 +105,12 @@ static Typetab *global_scope = 0; /* The global scope
|
|||
static Hash *scopes = 0; /* Hash table containing fully qualified scopes */
|
||||
|
||||
/* Performance optimization */
|
||||
#define SWIG_TYPEDEF_RESOLVE_CACHE
|
||||
#define SWIG_TYPEDEF_RESOLVE_CACHE
|
||||
static Hash *typedef_resolve_cache = 0;
|
||||
static Hash *typedef_all_cache = 0;
|
||||
static Hash *typedef_qualified_cache = 0;
|
||||
|
||||
static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix);
|
||||
static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix);
|
||||
|
||||
/* common attribute keys, to avoid calling find_key all the times */
|
||||
|
||||
|
|
@ -167,7 +165,7 @@ void SwigType_typesystem_init() {
|
|||
* already defined.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_typedef(SwigType *type, const_String_or_char_ptr name) {
|
||||
int SwigType_typedef(const SwigType *type, const_String_or_char_ptr name) {
|
||||
if (Getattr(current_typetab, name))
|
||||
return -1; /* Already defined */
|
||||
if (Strcmp(type, name) == 0) { /* Can't typedef a name to itself */
|
||||
|
|
@ -297,7 +295,7 @@ void SwigType_inherit_scope(Typetab *scope) {
|
|||
|
||||
void SwigType_scope_alias(String *aliasname, Typetab *ttab) {
|
||||
String *q;
|
||||
/* Printf(stdout,"alias: '%s' '%x'\n", aliasname, ttab); */
|
||||
/* Printf(stdout,"alias: '%s' '%p'\n", aliasname, ttab); */
|
||||
q = SwigType_scope_name(current_scope);
|
||||
if (Len(q)) {
|
||||
Append(q, "::");
|
||||
|
|
@ -389,37 +387,41 @@ void SwigType_attach_symtab(Symtab *sym) {
|
|||
* Debugging function for printing out current scope
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void SwigType_print_scope(Typetab *t) {
|
||||
void SwigType_print_scope(void) {
|
||||
Hash *ttab;
|
||||
Iterator i, j;
|
||||
|
||||
Printf(stdout, "SCOPES start =======================================\n");
|
||||
for (i = First(scopes); i.key; i = Next(i)) {
|
||||
t = i.item;
|
||||
Printf(stdout, "-------------------------------------------------------------\n");
|
||||
ttab = Getattr(i.item, "typetab");
|
||||
|
||||
Printf(stdout, "Type scope '%s' (%x)\n", i.key, i.item);
|
||||
Printf(stdout, "Type scope '%s' (%p)\n", i.key, i.item);
|
||||
{
|
||||
List *inherit = Getattr(i.item, "inherit");
|
||||
if (inherit) {
|
||||
Iterator j;
|
||||
for (j = First(inherit); j.item; j = Next(j)) {
|
||||
Printf(stdout, " Inherits from '%s' (%x)\n", Getattr(j.item, "qname"), j.item);
|
||||
Printf(stdout, " Inherits from '%s' (%p)\n", Getattr(j.item, "qname"), j.item);
|
||||
}
|
||||
}
|
||||
}
|
||||
Printf(stdout, "-------------------------------------------------------------\n");
|
||||
for (j = First(ttab); j.key; j = Next(j)) {
|
||||
Printf(stdout, "%40s -> %s\n", j.key, j.item);
|
||||
}
|
||||
}
|
||||
Printf(stdout, "SCOPES finish =======================================\n");
|
||||
}
|
||||
|
||||
static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
|
||||
static Typetab *SwigType_find_scope(Typetab *s, const SwigType *nameprefix) {
|
||||
Typetab *ss;
|
||||
Typetab *s_orig = s;
|
||||
String *nnameprefix = 0;
|
||||
static int check_parent = 1;
|
||||
|
||||
/* Printf(stdout,"find_scope: %x(%s) '%s'\n", s, Getattr(s,"name"), nameprefix); */
|
||||
if (Getmark(s))
|
||||
return 0;
|
||||
Setmark(s, 1);
|
||||
|
||||
if (SwigType_istemplate(nameprefix)) {
|
||||
nnameprefix = SwigType_typedef_resolve_all(nameprefix);
|
||||
|
|
@ -444,6 +446,7 @@ static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
|
|||
if (s) {
|
||||
if (nnameprefix)
|
||||
Delete(nnameprefix);
|
||||
Setmark(s_orig, 0);
|
||||
return s;
|
||||
}
|
||||
if (!s) {
|
||||
|
|
@ -463,6 +466,7 @@ static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
|
|||
if (s) {
|
||||
if (nnameprefix)
|
||||
Delete(nnameprefix);
|
||||
Setmark(s_orig, 0);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
|
@ -474,6 +478,7 @@ static Typetab *SwigType_find_scope(Typetab *s, String *nameprefix) {
|
|||
}
|
||||
if (nnameprefix)
|
||||
Delete(nnameprefix);
|
||||
Setmark(s_orig, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -533,6 +538,53 @@ static SwigType *_typedef_resolve(Typetab *s, String *base, int look_parent) {
|
|||
return type;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* template_parameters_resolve()
|
||||
*
|
||||
* For use with templates only. The template parameters are resolved. If none
|
||||
* of the parameters can be resolved, zero is returned.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static String *template_parameters_resolve(const String *base) {
|
||||
List *tparms;
|
||||
String *suffix;
|
||||
String *type;
|
||||
int i, sz;
|
||||
int rep = 0;
|
||||
type = SwigType_templateprefix(base);
|
||||
suffix = SwigType_templatesuffix(base);
|
||||
Append(type, "<(");
|
||||
tparms = SwigType_parmlist(base);
|
||||
sz = Len(tparms);
|
||||
for (i = 0; i < sz; i++) {
|
||||
SwigType *tpr;
|
||||
SwigType *tp = Getitem(tparms, i);
|
||||
if (!rep) {
|
||||
tpr = SwigType_typedef_resolve(tp);
|
||||
} else {
|
||||
tpr = 0;
|
||||
}
|
||||
if (tpr) {
|
||||
Append(type, tpr);
|
||||
Delete(tpr);
|
||||
rep = 1;
|
||||
} else {
|
||||
Append(type, tp);
|
||||
}
|
||||
if ((i + 1) < sz)
|
||||
Append(type, ",");
|
||||
}
|
||||
Append(type, ")>");
|
||||
Append(type, suffix);
|
||||
Delete(suffix);
|
||||
Delete(tparms);
|
||||
if (!rep) {
|
||||
Delete(type);
|
||||
type = 0;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
static SwigType *typedef_resolve(Typetab *s, String *base) {
|
||||
return _typedef_resolve(s, base, 1);
|
||||
}
|
||||
|
|
@ -553,12 +605,6 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) {
|
|||
String *nameprefix = 0;
|
||||
int newtype = 0;
|
||||
|
||||
/*
|
||||
if (!noscope) {
|
||||
noscope = NewStringEmpty();
|
||||
}
|
||||
*/
|
||||
|
||||
resolved_scope = 0;
|
||||
|
||||
#ifdef SWIG_TYPEDEF_RESOLVE_CACHE
|
||||
|
|
@ -602,6 +648,9 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) {
|
|||
#endif
|
||||
if (nameprefix) {
|
||||
/* Name had a prefix on it. See if we can locate the proper scope for it */
|
||||
String *rnameprefix = template_parameters_resolve(nameprefix);
|
||||
nameprefix = rnameprefix ? Copy(rnameprefix) : nameprefix;
|
||||
Delete(rnameprefix);
|
||||
s = SwigType_find_scope(s, nameprefix);
|
||||
|
||||
/* Couldn't locate a scope for the type. */
|
||||
|
|
@ -617,7 +666,7 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) {
|
|||
Printf(stdout, "namebase = '%s'\n", namebase);
|
||||
#endif
|
||||
type = typedef_resolve(s, namebase);
|
||||
if (type) {
|
||||
if (type && resolved_scope) {
|
||||
/* we need to look for the resolved type, this will also
|
||||
fix the resolved_scope if 'type' and 'namebase' are
|
||||
declared in different scopes */
|
||||
|
|
@ -629,7 +678,7 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) {
|
|||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "%s type = '%s'\n", Getattr(s, "name"), type);
|
||||
#endif
|
||||
if ((type) && (!Swig_scopename_check(type)) && resolved_scope) {
|
||||
if (type && (!Swig_scopename_check(type)) && resolved_scope) {
|
||||
Typetab *rtab = resolved_scope;
|
||||
String *qname = Getattr(resolved_scope, "qname");
|
||||
/* If qualified *and* the typename is defined from the resolved scope, we qualify */
|
||||
|
|
@ -668,42 +717,8 @@ SwigType *SwigType_typedef_resolve(const SwigType *t) {
|
|||
template arguments one by one to see if they can be resolved. */
|
||||
|
||||
if (!type && SwigType_istemplate(base)) {
|
||||
List *tparms;
|
||||
String *suffix;
|
||||
int i, sz;
|
||||
int rep = 0;
|
||||
type = SwigType_templateprefix(base);
|
||||
newtype = 1;
|
||||
suffix = SwigType_templatesuffix(base);
|
||||
Append(type, "<(");
|
||||
tparms = SwigType_parmlist(base);
|
||||
sz = Len(tparms);
|
||||
for (i = 0; i < sz; i++) {
|
||||
SwigType *tpr;
|
||||
SwigType *tp = Getitem(tparms, i);
|
||||
if (!rep) {
|
||||
tpr = SwigType_typedef_resolve(tp);
|
||||
} else {
|
||||
tpr = 0;
|
||||
}
|
||||
if (tpr) {
|
||||
Append(type, tpr);
|
||||
Delete(tpr);
|
||||
rep = 1;
|
||||
} else {
|
||||
Append(type, tp);
|
||||
}
|
||||
if ((i + 1) < sz)
|
||||
Append(type, ",");
|
||||
}
|
||||
Append(type, ")>");
|
||||
Append(type, suffix);
|
||||
Delete(suffix);
|
||||
Delete(tparms);
|
||||
if (!rep) {
|
||||
Delete(type);
|
||||
type = 0;
|
||||
}
|
||||
type = template_parameters_resolve(base);
|
||||
}
|
||||
if (namebase)
|
||||
Delete(namebase);
|
||||
|
|
@ -806,9 +821,10 @@ return_result:
|
|||
* Fully resolve a type down to its most basic datatype
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_typedef_resolve_all(SwigType *t) {
|
||||
SwigType *SwigType_typedef_resolve_all(const SwigType *t) {
|
||||
SwigType *n;
|
||||
SwigType *r;
|
||||
int count = 0;
|
||||
|
||||
/* Check to see if the typedef resolve has been done before by checking the cache */
|
||||
if (!typedef_all_cache) {
|
||||
|
|
@ -824,6 +840,10 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) {
|
|||
while ((n = SwigType_typedef_resolve(r))) {
|
||||
Delete(r);
|
||||
r = n;
|
||||
if (++count >= 512) {
|
||||
Swig_error(Getfile(t), Getline(t), "Recursive typedef detected resolving '%s' to '%s' to '%s' and so on...\n", SwigType_str(t, 0), SwigType_str(SwigType_typedef_resolve(t), 0), SwigType_str(SwigType_typedef_resolve(SwigType_typedef_resolve(t)), 0));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* Add the typedef to the cache for next time it is looked up */
|
||||
|
|
@ -848,7 +868,7 @@ SwigType *SwigType_typedef_resolve_all(SwigType *t) {
|
|||
* scope, it is left in place.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_typedef_qualified(SwigType *t) {
|
||||
SwigType *SwigType_typedef_qualified(const SwigType *t) {
|
||||
List *elements;
|
||||
String *result;
|
||||
int i, len;
|
||||
|
|
@ -876,7 +896,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t) {
|
|||
e = ty;
|
||||
}
|
||||
resolved_scope = 0;
|
||||
if (typedef_resolve(current_scope, e)) {
|
||||
if (typedef_resolve(current_scope, e) && resolved_scope) {
|
||||
/* resolved_scope contains the scope that actually resolved the symbol */
|
||||
String *qname = Getattr(resolved_scope, "qname");
|
||||
if (qname) {
|
||||
|
|
@ -933,6 +953,10 @@ SwigType *SwigType_typedef_qualified(SwigType *t) {
|
|||
Parm *p;
|
||||
List *parms;
|
||||
ty = Swig_symbol_template_deftype(e, current_symtab);
|
||||
/*
|
||||
String *dt = Swig_symbol_template_deftype(e, current_symtab);
|
||||
ty = Swig_symbol_type_qualify(dt, 0);
|
||||
*/
|
||||
e = ty;
|
||||
parms = SwigType_parmlist(e);
|
||||
tprefix = SwigType_templateprefix(e);
|
||||
|
|
@ -999,6 +1023,9 @@ SwigType *SwigType_typedef_qualified(SwigType *t) {
|
|||
Delete(tprefix);
|
||||
Delete(qprefix);
|
||||
Delete(parms);
|
||||
/*
|
||||
Delete(dt);
|
||||
*/
|
||||
}
|
||||
Append(result, e);
|
||||
Delete(ty);
|
||||
|
|
@ -1049,7 +1076,7 @@ SwigType *SwigType_typedef_qualified(SwigType *t) {
|
|||
* Checks a typename to see if it is a typedef.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_istypedef(SwigType *t) {
|
||||
int SwigType_istypedef(const SwigType *t) {
|
||||
String *type;
|
||||
|
||||
type = SwigType_typedef_resolve(t);
|
||||
|
|
@ -1092,14 +1119,14 @@ int SwigType_typedef_using(const_String_or_char_ptr name) {
|
|||
|
||||
/* See if the using name is a scope */
|
||||
/* tt = SwigType_find_scope(current_scope,name);
|
||||
Printf(stdout,"tt = %x, name = '%s'\n", tt, name); */
|
||||
Printf(stdout,"tt = %p, name = '%s'\n", tt, name); */
|
||||
|
||||
/* We set up a typedef B --> A::B */
|
||||
Setattr(current_typetab, base, name);
|
||||
|
||||
/* Find the scope name where the symbol is defined */
|
||||
td = SwigType_typedef_resolve(name);
|
||||
/* Printf(stdout,"td = '%s' %x\n", td, resolved_scope); */
|
||||
/* Printf(stdout,"td = '%s' %p\n", td, resolved_scope); */
|
||||
if (resolved_scope) {
|
||||
defined_name = Getattr(resolved_scope, "qname");
|
||||
if (defined_name) {
|
||||
|
|
@ -1150,7 +1177,7 @@ int SwigType_typedef_using(const_String_or_char_ptr name) {
|
|||
* a class.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_isclass(SwigType *t) {
|
||||
int SwigType_isclass(const SwigType *t) {
|
||||
SwigType *qty, *qtys;
|
||||
int isclass = 0;
|
||||
|
||||
|
|
@ -1186,7 +1213,7 @@ int SwigType_isclass(SwigType *t) {
|
|||
* everything is based on typemaps.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_type(SwigType *t) {
|
||||
int SwigType_type(const SwigType *t) {
|
||||
char *c;
|
||||
/* Check for the obvious stuff */
|
||||
c = Char(t);
|
||||
|
|
@ -1303,7 +1330,7 @@ int SwigType_type(SwigType *t) {
|
|||
* %feature("valuewrapper").
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *SwigType_alttype(SwigType *t, int local_tmap) {
|
||||
SwigType *SwigType_alttype(const SwigType *t, int local_tmap) {
|
||||
Node *n;
|
||||
SwigType *w = 0;
|
||||
int use_wrapper = 0;
|
||||
|
|
@ -1421,7 +1448,7 @@ static Hash *r_clientdata = 0; /* Hash mapping resolved types to client data
|
|||
static Hash *r_mangleddata = 0; /* Hash mapping mangled types to client data */
|
||||
static Hash *r_remembered = 0; /* Hash of types we remembered already */
|
||||
|
||||
static void (*r_tracefunc) (SwigType *t, String *mangled, String *clientdata) = 0;
|
||||
static void (*r_tracefunc) (const SwigType *t, String *mangled, String *clientdata) = 0;
|
||||
|
||||
void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr clientdata) {
|
||||
if (!r_mangleddata) {
|
||||
|
|
@ -1431,7 +1458,7 @@ void SwigType_remember_mangleddata(String *mangled, const_String_or_char_ptr cli
|
|||
}
|
||||
|
||||
|
||||
void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientdata) {
|
||||
void SwigType_remember_clientdata(const SwigType *t, const_String_or_char_ptr clientdata) {
|
||||
String *mt;
|
||||
SwigType *lt;
|
||||
Hash *h;
|
||||
|
|
@ -1549,12 +1576,12 @@ void SwigType_remember_clientdata(SwigType *t, const_String_or_char_ptr clientda
|
|||
}
|
||||
}
|
||||
|
||||
void SwigType_remember(SwigType *ty) {
|
||||
void SwigType_remember(const SwigType *ty) {
|
||||
SwigType_remember_clientdata(ty, 0);
|
||||
}
|
||||
|
||||
void (*SwigType_remember_trace(void (*tf) (SwigType *, String *, String *))) (SwigType *, String *, String *) {
|
||||
void (*o) (SwigType *, String *, String *) = r_tracefunc;
|
||||
void (*SwigType_remember_trace(void (*tf) (const SwigType *, String *, String *))) (const SwigType *, String *, String *) {
|
||||
void (*o) (const SwigType *, String *, String *) = r_tracefunc;
|
||||
r_tracefunc = tf;
|
||||
return o;
|
||||
}
|
||||
|
|
@ -1726,7 +1753,7 @@ void SwigType_inherit(String *derived, String *base, String *cast, String *conve
|
|||
* Determines if a t1 is a subtype of t2, ie, is t1 derived from t2
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int SwigType_issubtype(SwigType *t1, SwigType *t2) {
|
||||
int SwigType_issubtype(const SwigType *t1, const SwigType *t2) {
|
||||
SwigType *ft1, *ft2;
|
||||
String *b1, *b2;
|
||||
Hash *h;
|
||||
|
|
@ -1794,13 +1821,13 @@ void SwigType_inherit_equiv(File *out) {
|
|||
Append(rlist, ck.key);
|
||||
}
|
||||
/* Printf(stdout,"rk.key = '%s'\n", rk.key);
|
||||
Printf(stdout,"rh = %x '%s'\n", rh,rh); */
|
||||
Printf(stdout,"rh = %p '%s'\n", rh,rh); */
|
||||
|
||||
bk = First(sub);
|
||||
while (bk.key) {
|
||||
prefix = SwigType_prefix(rk.key);
|
||||
Append(prefix, bk.key);
|
||||
/* Printf(stdout,"set %x = '%s' : '%s'\n", rh, SwigType_manglestr(prefix),prefix); */
|
||||
/* Printf(stdout,"set %p = '%s' : '%s'\n", rh, SwigType_manglestr(prefix),prefix); */
|
||||
mprefix = SwigType_manglestr(prefix);
|
||||
Setattr(rh, mprefix, prefix);
|
||||
mkey = SwigType_manglestr(rk.key);
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@
|
|||
* to be created in a piecemeal manner.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
char cvsroot_wrapfunc_c[] = "$Id$";
|
||||
|
||||
#include "swig.h"
|
||||
#include <ctype.h>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue