141
141
if ((Strcmp(key,"parms") == 0) || (Strcmp(key,"pattern") == 0) || (Strcmp(key,"throws") == 0)
142
142
|| (Strcmp(key,"kwargs") == 0)) {
143
Setattr(nn,key,CopyParmList(k.item));
143
ParmList *pl = CopyParmList(k.item);
146
148
/* Looks okay. Just copy the data using Copy */
434
439
if (strncmp(Char(symname),"$ignore",7) == 0) {
435
440
char *c = Char(symname)+7;
436
Setattr(n,"feature:ignore","1");
441
SetFlag(n,"feature:ignore");
438
443
SWIG_WARN_NODE_BEGIN(n);
439
444
Swig_warning(0,Getfile(n), Getline(n), "%s\n",c+1);
445
450
if ((wrn) && (Len(wrn))) {
446
SWIG_WARN_NODE_BEGIN(n);
447
Swig_warning(0,Getfile(n),Getline(n), "%s\n", wrn);
448
SWIG_WARN_NODE_END(n);
451
String *metaname = symname;
452
if (!Getmeta(metaname,"already_warned")) {
453
SWIG_WARN_NODE_BEGIN(n);
454
Swig_warning(0,Getfile(n),Getline(n), "%s\n", wrn);
455
SWIG_WARN_NODE_END(n);
456
Setmeta(metaname,"already_warned","1");
450
459
c = Swig_symbol_add(symname,n);
1070
1079
Swig_feature_set(features_hash, name, decl, fname, val, featureattribs);
1072
1082
} else if (SwigType_ispointer(t)) {
1073
1083
String *nname = NewStringf("*%s",name);
1074
1084
Swig_feature_set(features_hash,nname,0,fname,val, featureattribs);
1130
1140
static void default_arguments(Node *n) {
1131
1141
Node *function = n;
1133
/* Do not add in functions if kwargs is being used or if user wants old default argument wrapping
1134
(one wrapped method per function irrespective of number of default arguments) */
1135
1143
if (function) {
1144
ParmList *varargs = Getattr(function,"feature:varargs");
1146
/* Handles the %varargs directive by looking for "feature:varargs" and
1147
* substituting ... with an alternative set of arguments. */
1148
Parm *p = Getattr(function,"parms");
1151
SwigType *t = Getattr(p,"type");
1152
if (Strcmp(t,"v(...)") == 0) {
1154
set_nextSibling(pp,Copy(varargs));
1156
Setattr(function,"parms", Copy(varargs));
1165
/* Do not add in functions if kwargs is being used or if user wants old default argument wrapping
1166
(one wrapped method per function irrespective of number of default arguments) */
1136
1167
if (compact_default_args
1137
1168
|| is_cfunction(function)
1138
|| Getattr(function,"feature:compactdefaultargs")
1139
|| Getattr(function,"feature:kwargs")) {
1169
|| GetFlag(function,"feature:compactdefaultargs")
1170
|| GetFlag(function,"feature:kwargs")) {
1140
1171
ParmList *p = Getattr(function,"parms");
1142
1173
Setattr(p,"compactdefargs", "1"); /* mark parameters for special handling */
1175
1206
Node *throws = Getattr(function,"throws");
1176
if (throws) Setattr(new_function,"throws",CopyParmList(throws));
1207
ParmList *pl = CopyParmList(throws);
1208
if (throws) Setattr(new_function,"throws",pl);
1179
1212
/* copy specific attributes for global (or in a namespace) template functions - these are not templated class methods */
1184
1217
if (templatetype) Setattr(new_function,"templatetype",Copy(templatetype));
1185
1218
if (symtypename) Setattr(new_function,"sym:typename",Copy(symtypename));
1186
1219
if (templateparms) Setattr(new_function,"templateparms",CopyParmList(templateparms));
1220
} else if (Strcmp(nodeType(function),"constructor") == 0) {
1221
/* only copied for constructors as this is not a user defined feature - it is hard coded in the parser */
1222
if (GetFlag(function,"feature:new")) SetFlag(new_function,"feature:new");
1189
1225
add_symbols(new_function);
1254
1290
%token <str> CHARCONST
1255
1291
%token <dtype> NUM_INT NUM_FLOAT NUM_UNSIGNED NUM_LONG NUM_ULONG NUM_LONGLONG NUM_ULONGLONG
1256
1292
%token <ivalue> TYPEDEF
1257
%token <type> TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW
1293
%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
1258
1294
%token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD
1259
1295
%token CONST_QUAL VOLATILE REGISTER STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET
1260
1296
%token ILLEGAL CONSTANT
1394
1430
if (!Swig_error_count()) {
1395
1431
static int last_error_line = -1;
1396
1432
if (last_error_line != cparse_line) {
1397
Swig_error(cparse_file, cparse_line,"Syntax error in input.\n");
1433
Swig_error(cparse_file, cparse_line,"Syntax error in input(1).\n");
1398
1434
last_error_line = cparse_line;
1555
1591
Setattr($$,"value",$4.val);
1556
1592
if ($4.rawval) Setattr($$,"rawval", $4.rawval);
1557
1593
Setattr($$,"storage","%constant");
1558
Setattr($$,"feature:immutable","1");
1594
SetFlag($$,"feature:immutable");
1559
1595
add_symbols($$);
1561
1597
if ($4.type == T_ERROR) {
1579
1615
Setattr($$,"value",$4.val);
1580
1616
if ($4.rawval) Setattr($$,"rawval", $4.rawval);
1581
1617
Setattr($$,"storage","%constant");
1582
Setattr($$,"feature:immutable","1");
1618
SetFlag($$,"feature:immutable");
1583
1619
add_symbols($$);
1585
1621
if ($4.type == T_ERROR) {
1655
1691
------------------------------------------------------------ */
1657
1693
/* fragment keyword arguments */
1658
stringtype : string LBRACE type RBRACE {
1694
stringtype : string LBRACE parm RBRACE {
1659
1695
$$ = NewHash();
1660
1696
Setattr($$,"value",$1);
1661
Setattr($$,"type",$3);
1697
Setattr($$,"type",Getattr($3,"type"));
1711
1747
cparse_file = Swig_copy_string($3);
1712
1748
cparse_line = 0;
1713
1749
} interface RBRACKET {
1715
1752
cparse_file = $1.filename;
1716
1753
cparse_line = $1.line;
1717
1754
if (strcmp($1.type,"include") == 0) set_nodeType($$,"include");
1718
if (strcmp($1.type,"import") == 0) set_nodeType($$,"import");
1755
if (strcmp($1.type,"import") == 0) {
1756
mname = $2 ? Getattr($2,"module") : 0;
1757
set_nodeType($$,"import");
1758
if (import_mode) --import_mode;
1719
1761
Setattr($$,"name",$3);
1720
1762
/* Search for the module (if any) */
1722
1764
Node *n = firstChild($$);
1724
1766
if (Strcmp(nodeType(n),"module") == 0) {
1768
Setattr(n,"name", mname);
1725
1771
Setattr($$,"module",Getattr(n,"name"));
1728
1774
n = nextSibling(n);
1777
/* There is no module node in the import
1778
node, ie, you imported a .h file
1779
directly. We are forced then to create
1780
a new import node with a module node.
1782
Node *nint = new_node("import");
1783
Node *mnode = new_node("module");
1784
Setattr(mnode,"name", mname);
1785
appendChild(nint,mnode);
1786
appendChild(nint,firstChild($$));
1788
Setattr($$,"module",mname);
1731
1791
Setattr($$,"options",$2);
1735
1795
includetype : INCLUDE { $$.type = (char *) "include"; }
1736
| IMPORT { $$.type = (char *) "import"; }
1796
| IMPORT { $$.type = (char *) "import"; ++import_mode;}
1739
1799
/* ------------------------------------------------------------
1841
1900
if (!ModuleName) ModuleName = NewString($3);
1902
/* first module included, we apply global
1903
ModuleName, which can be modify by -module */
1904
Setattr($$,"name",Copy(ModuleName));
1906
/* import mode, we just pass the idstring */
1907
Setattr($$,"name",$3);
1842
1909
if (!module_node) module_node = $$;
1960
2027
namewarn_add(Char(fixname),decl,$3);
1963
2031
} else if (SwigType_ispointer(t)) {
1964
2032
String *nname = NewStringf("*%s",fixname);
2109
2177
Swig_feature_set(features_hash, name, decl, "feature:varargs", val, 0);
2111
2180
} else if (SwigType_ispointer(t)) {
2112
2181
String *nname = NewStringf("*%s",name);
2113
2182
Swig_feature_set(features_hash,nname,0,"feature:varargs",val, 0);
2153
2222
typemap_directive : TYPEMAP LPAREN typemap_type RPAREN tm_list stringbrace {
2156
2226
$$ = new_node("typemap");
2157
2227
Setattr($$,"method",$3.op);
2158
Setattr($$,"code",NewString($6));
2159
2228
if ($3.kwargs) {
2229
Parm *kw = $3.kwargs;
2230
/* check for 'noblock' option, which remove the block braces */
2232
String *name = Getattr(kw,"name");
2233
if (name && (Cmp(name,"noblock") == 0)) {
2234
char *cstr = Char($6);
2235
size_t len = Len($6);
2236
if (len && cstr[0] == '{') {
2238
if (len && cstr[len - 1] == '}') { --len; }
2239
/* we now remove the extra spaces */
2240
while (len && isspace(cstr[0])) { --len; ++cstr; }
2241
while (len && isspace(cstr[len - 1])) { --len; }
2242
code = NewStringWithSize(cstr, len);
2245
kw = nextSibling(kw);
2160
2247
Setattr($$,"kwargs", $3.kwargs);
2249
Setattr($$,"code", code ? code : NewString($6));
2162
2250
appendChild($$,$5);
2387
2475
String *nname = NewStringf("__dummy_%d__", cnt++);
2388
2476
Swig_cparse_template_expand(templnode,nname,temparms,tscope);
2389
2477
Setattr(templnode,"sym:name",nname);
2390
if (!Swig_template_extmode()) {
2391
Setattr(templnode,"feature:ignore","1");
2393
Setattr(templnode,"feature:onlychildren",
2394
"typemap,typemapitem,typemapcopy,typedef,types,fragment");
2478
Setattr(templnode,"feature:onlychildren",
2479
"typemap,typemapitem,typemapcopy,typedef,types,fragment");
2397
2481
Delattr(templnode,"templatetype");
2398
2482
Setattr(templnode,"template",nn);
2975
3059
appendChild($$,dump_nested(Char(name)));
3062
if (cplus_mode != CPLUS_PUBLIC) {
3063
/* we 'open' the class at the end, to allow %template
3064
to add new members */
3065
Node *pa = new_node("access");
3066
Setattr(pa,"kind","public");
3067
cplus_mode = CPLUS_PUBLIC;
2977
3071
Setattr($$,"symtab",Swig_symbol_popscope());
2979
3073
Classprefix = 0;
3323
3419
/* Need to resolve exact specialization name */
3324
3420
/* add default args from generic template */
3325
String *fname = Swig_cparse_template_deftype(tname,0);
3421
String *ty = Swig_symbol_template_deftype(tname,0);
3422
String *fname = Swig_symbol_type_qualify(ty,0);
3326
3423
Swig_symbol_cadd(fname,$$);
3328
3427
} else if ($$) {
3329
3428
Setattr($$,"templatetype",nodeType($6));
3551
3650
static int last_error_line = -1;
3552
3651
if (last_error_line != cparse_line) {
3553
Swig_error(cparse_file, cparse_line,"Syntax error in input.\n");
3652
Swig_error(cparse_file, cparse_line,"Syntax error in input(3).\n");
3554
3653
last_error_line = cparse_line;
3618
3717
if (Len(scanner_ccode)) {
3619
3718
Setattr($$,"code",Copy(scanner_ccode));
3621
Setattr($$,"feature:new","1");
3720
SetFlag($$,"feature:new");
3839
3938
Swig_warning(WARN_PARSE_NESTED_CLASS,cparse_file, cparse_line,"Nested class not currently supported (ignored)\n");
3942
| TEMPLATE LESSTHAN template_parms GREATERTHAN cpptype idcolon LBRACE { cparse_start_line = cparse_line; skip_balanced('{','}');
3945
if (cplus_mode == CPLUS_PUBLIC) {
3946
Swig_warning(WARN_PARSE_NESTED_CLASS,cparse_file, cparse_line,"Nested class not currently supported (ignored)\n");
3844
3952
nested_decl : declarator { $$ = $1;}
4838
4950
$$ = new_node("enumitem");
4839
4951
Setattr($$,"name",$1);
4840
4952
Setattr($$,"type",NewSwigType(T_INT));
4841
Setattr($$,"feature:immutable","1");
4953
SetFlag($$,"feature:immutable");
4843
4955
| ID EQUAL etype {
4844
4956
$$ = new_node("enumitem");
4851
4963
Setattr($$,"value",$1);
4852
4964
Setattr($$,"type",NewSwigType(T_INT));
4854
Setattr($$,"feature:immutable","1");
4966
SetFlag($$,"feature:immutable");
4856
4968
| empty { $$ = 0; }