PageRenderTime 51ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/ttn-post-libtool-1-4-3-upgrade/SWIG/Source/Swig/cwrap.c

#
C | 794 lines | 536 code | 101 blank | 157 comment | 83 complexity | fee1fc76b2cddfcecc9a989d5f1c41fd MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
  1. /* -----------------------------------------------------------------------------
  2. * cwrap.c
  3. *
  4. * This file defines a variety of wrapping rules for C/C++ handling including
  5. * the naming of local variables, calling conventions, and so forth.
  6. *
  7. * Author(s) : David Beazley (beazley@cs.uchicago.edu)
  8. *
  9. * Copyright (C) 1998-2000. The University of Chicago
  10. * Copyright (C) 1995-1998. The University of Utah and The Regents of the
  11. * University of California.
  12. *
  13. * See the file LICENSE for information on usage and redistribution.
  14. * ----------------------------------------------------------------------------- */
  15. static char cvsroot[] = "$Header$";
  16. #include "swig.h"
  17. static Parm *nonvoid_parms(Parm *p) {
  18. if (p) {
  19. SwigType *t = Getattr(p,"type");
  20. if (SwigType_type(t) == T_VOID) return 0;
  21. }
  22. return p;
  23. }
  24. /* -----------------------------------------------------------------------------
  25. * Swig_parm_name()
  26. *
  27. * Generates a name for the ith argument in an argument list
  28. * ----------------------------------------------------------------------------- */
  29. String *
  30. Swig_cparm_name(Parm *p, int i) {
  31. String *name = NewStringf("arg%d",i+1);
  32. if (p) {
  33. Setattr(p,"lname",name);
  34. }
  35. return name;
  36. }
  37. /* -----------------------------------------------------------------------------
  38. * Swig_clocal()
  39. *
  40. * Creates a string that declares a C local variable type. Converts references
  41. * and user defined types to pointers.
  42. * ----------------------------------------------------------------------------- */
  43. String *
  44. Swig_clocal(SwigType *t, String_or_char *name, String_or_char *value) {
  45. String *decl;
  46. decl = NewString("");
  47. switch(SwigType_type(t)) {
  48. case T_REFERENCE:
  49. if (value) {
  50. Printf(decl,"%s = (%s) &%s_defvalue", SwigType_lstr(t,name), SwigType_lstr(t,0), name);
  51. } else {
  52. Printf(decl,"%s = 0", SwigType_lstr(t,name));
  53. }
  54. break;
  55. case T_VOID:
  56. break;
  57. case T_VARARGS:
  58. Printf(decl,"void *%s = 0", name);
  59. break;
  60. default:
  61. if (value) {
  62. Printf(decl,"%s = (%s) %s", SwigType_lstr(t,name), SwigType_lstr(t,0), SwigType_lcaststr(t,value));
  63. } else {
  64. Printf(decl,"%s", SwigType_lstr(t,name));
  65. }
  66. }
  67. return decl;
  68. }
  69. /* -----------------------------------------------------------------------------
  70. * Swig_wrapped_var_convert()
  71. *
  72. * Converts a member variable for use in the get and set wrapper methods.
  73. * This function only converts user defined types to pointers.
  74. * ----------------------------------------------------------------------------- */
  75. String *
  76. Swig_wrapped_var_type(SwigType *t) {
  77. SwigType *ty;
  78. ty = Copy(t);
  79. if (SwigType_isclass(t)) {
  80. SwigType_add_pointer(ty);
  81. }
  82. return ty;
  83. }
  84. String *
  85. Swig_wrapped_var_deref(SwigType *t, String_or_char *name) {
  86. if (SwigType_isclass(t)) {
  87. return NewStringf("*%s",name);
  88. } else {
  89. return SwigType_rcaststr(t,name);
  90. }
  91. }
  92. String *
  93. Swig_wrapped_var_assign(SwigType *t, String_or_char *name) {
  94. if (SwigType_isclass(t)) {
  95. return NewStringf("&%s",name);
  96. } else {
  97. return SwigType_lcaststr(t,name);
  98. }
  99. }
  100. /* -----------------------------------------------------------------------------
  101. * Swig_cargs()
  102. *
  103. * Emit all of the local variables for a list of parameters. Returns the
  104. * number of parameters.
  105. * ----------------------------------------------------------------------------- */
  106. int Swig_cargs(Wrapper *w, ParmList *p) {
  107. int i;
  108. SwigType *pt;
  109. String *pvalue;
  110. String *pname;
  111. String *local;
  112. String *lname;
  113. SwigType *altty;
  114. String *type;
  115. int tycode;
  116. i = 0;
  117. while (p != 0) {
  118. lname = Swig_cparm_name(p,i);
  119. pt = Getattr(p,"type");
  120. if ((SwigType_type(pt) != T_VOID)) {
  121. pname = Getattr(p,"name");
  122. pvalue = Getattr(p,"value");
  123. altty = Getattr(p,"alttype");
  124. type = Getattr(p,"type");
  125. tycode = SwigType_type(type);
  126. if (tycode == T_REFERENCE) {
  127. if (pvalue) {
  128. String *defname, *defvalue;
  129. defname = NewStringf("%s_defvalue", lname);
  130. defvalue = NewStringf("%s = %s", SwigType_str(type,defname), pvalue);
  131. Wrapper_add_localv(w,defname, defvalue, NIL);
  132. Delete(defname);
  133. Delete(defvalue);
  134. }
  135. } else if (!pvalue && (tycode == T_POINTER)) {
  136. pvalue = (String *) "0";
  137. }
  138. if (!altty) {
  139. local = Swig_clocal(pt,lname,pvalue);
  140. } else {
  141. local = Swig_clocal(altty,lname, pvalue);
  142. }
  143. Wrapper_add_localv(w,lname,local,NIL);
  144. i++;
  145. }
  146. p = nextSibling(p);
  147. }
  148. return(i);
  149. }
  150. /* -----------------------------------------------------------------------------
  151. * Swig_cresult()
  152. *
  153. * This function generates the C code needed to set the result of a C
  154. * function call.
  155. * ----------------------------------------------------------------------------- */
  156. String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl) {
  157. String *fcall;
  158. fcall = NewString("");
  159. switch(SwigType_type(t)) {
  160. case T_VOID:
  161. break;
  162. case T_REFERENCE:
  163. Printf(fcall,"{\n");
  164. Printf(fcall,"%s = ", SwigType_str(t,"_result_ref"));
  165. break;
  166. case T_USER:
  167. Printf(fcall,"%s = ", name);
  168. break;
  169. default:
  170. /* Normal return value */
  171. Printf(fcall,"%s = (%s)", name, SwigType_lstr(t,0));
  172. break;
  173. }
  174. /* Now print out function call */
  175. Printv(fcall,decl,NIL);
  176. /* A sick hack */
  177. {
  178. char *c = Char(decl) + Len(decl) - 1;
  179. if (!((*c == ';') || (*c == '}')))
  180. Printf(fcall, ";");
  181. }
  182. Printf(fcall,"\n");
  183. if (SwigType_type(t) == T_REFERENCE) {
  184. Printf(fcall,"%s = (%s) &_result_ref;\n", name, SwigType_lstr(t,0));
  185. Printf(fcall,"}\n");
  186. }
  187. return fcall;
  188. }
  189. /* -----------------------------------------------------------------------------
  190. * Swig_cfunction_call()
  191. *
  192. * Creates a string that calls a C function using the local variable rules
  193. * defined above.
  194. *
  195. * name(arg0, arg1, arg2, ... argn)
  196. *
  197. * ----------------------------------------------------------------------------- */
  198. String *
  199. Swig_cfunction_call(String_or_char *name, ParmList *parms) {
  200. String *func;
  201. int i = 0;
  202. int comma = 0;
  203. Parm *p = parms;
  204. SwigType *pt;
  205. String *nname;
  206. func = NewString("");
  207. nname = SwigType_namestr(name);
  208. Printf(func,"%s(", nname);
  209. while (p) {
  210. String *pname;
  211. pt = Getattr(p,"type");
  212. if ((SwigType_type(pt) != T_VOID)) {
  213. if (comma) Printf(func,",");
  214. pname = Swig_cparm_name(p,i);
  215. Printf(func,"%s", SwigType_rcaststr(pt, pname));
  216. comma = 1;
  217. i++;
  218. }
  219. p = nextSibling(p);
  220. }
  221. Printf(func,")");
  222. return func;
  223. }
  224. /* -----------------------------------------------------------------------------
  225. * Swig_cmethod_call()
  226. *
  227. * Generates a string that calls a C++ method from a list of parameters.
  228. *
  229. * arg0->name(arg1, arg2, arg3, ..., argn)
  230. *
  231. * self is an argument that defines how to handle the first argument. Normally,
  232. * it should be set to "this->". With C++ proxy classes enabled, it could be
  233. * set to "(*this)->" or some similar sequence.
  234. * ----------------------------------------------------------------------------- */
  235. String *
  236. Swig_cmethod_call(String_or_char *name, ParmList *parms, String_or_char *self) {
  237. String *func, *nname;
  238. int i = 0;
  239. Parm *p = parms;
  240. SwigType *pt;
  241. int comma = 0;
  242. if (!self) self = (char *) "(this)->";
  243. func = NewString("");
  244. nname = SwigType_namestr(name);
  245. if (!p) return func;
  246. Append(func,self);
  247. pt = Getattr(p,"type");
  248. /* If the method is invoked through a dereferenced pointer, we don't add any casts
  249. (needed for smart pointers). Otherwise, we cast to the appropriate type */
  250. if (Strstr(func,"*this")) {
  251. Replaceall(func,"this", Swig_cparm_name(p,0));
  252. } else {
  253. Replaceall(func,"this", SwigType_rcaststr(pt, Swig_cparm_name(p,0)));
  254. }
  255. if (SwigType_istemplate(name)) {
  256. Printf(func,"template %s(", nname);
  257. } else {
  258. Printf(func,"%s(", nname);
  259. }
  260. i++;
  261. p = nextSibling(p);
  262. while (p) {
  263. String *pname;
  264. pt = Getattr(p,"type");
  265. if ((SwigType_type(pt) != T_VOID)) {
  266. if (comma) Printf(func,",");
  267. pname = Swig_cparm_name(p,i);
  268. Printf(func,"%s", SwigType_rcaststr(pt, pname));
  269. comma = 1;
  270. i++;
  271. }
  272. p = nextSibling(p);
  273. }
  274. Printf(func,")");
  275. Delete(nname);
  276. return func;
  277. }
  278. /* -----------------------------------------------------------------------------
  279. * Swig_cconstructor_call()
  280. *
  281. * Creates a string that calls a C constructor function.
  282. *
  283. * (name *) calloc(1,sizeof(name));
  284. * ----------------------------------------------------------------------------- */
  285. String *
  286. Swig_cconstructor_call(String_or_char *name) {
  287. DOH *func;
  288. func = NewString("");
  289. Printf(func,"(%s *) calloc(1, sizeof(%s))", name, name);
  290. return func;
  291. }
  292. /* -----------------------------------------------------------------------------
  293. * Swig_cppconstructor_call()
  294. *
  295. * Creates a string that calls a C function using the local variable rules
  296. * defined above.
  297. *
  298. * name(arg0, arg1, arg2, ... argn)
  299. *
  300. * ----------------------------------------------------------------------------- */
  301. String *
  302. Swig_cppconstructor_call(String_or_char *name, ParmList *parms) {
  303. String *func;
  304. String *nname;
  305. int i = 0;
  306. int comma = 0;
  307. Parm *p = parms;
  308. SwigType *pt;
  309. nname = SwigType_namestr(name);
  310. func = NewString("");
  311. Printf(func,"new %s(", nname);
  312. while (p) {
  313. String *pname;
  314. pt = Getattr(p,"type");
  315. if ((SwigType_type(pt) != T_VOID)) {
  316. if (comma) Printf(func,",");
  317. pname = Swig_cparm_name(p,i);
  318. Printf(func,"%s", SwigType_rcaststr(pt, pname));
  319. comma = 1;
  320. i++;
  321. }
  322. p = nextSibling(p);
  323. }
  324. Printf(func,")");
  325. Delete(nname);
  326. return func;
  327. }
  328. /* -----------------------------------------------------------------------------
  329. * Swig_cdestructor_call()
  330. *
  331. * Creates a string that calls a C constructor function.
  332. *
  333. * free((char *) arg0);
  334. * ----------------------------------------------------------------------------- */
  335. String *
  336. Swig_cdestructor_call() {
  337. String *func;
  338. func = NewString("");
  339. Printf(func,"free((char *) %s)", Swig_cparm_name(0,0));
  340. return func;
  341. }
  342. /* -----------------------------------------------------------------------------
  343. * Swig_cppdestructor_call()
  344. *
  345. * Creates a string that calls a C constructor function.
  346. *
  347. * delete arg0;
  348. * ----------------------------------------------------------------------------- */
  349. String *
  350. Swig_cppdestructor_call() {
  351. String *func;
  352. func = NewString("");
  353. Printf(func,"delete %s", Swig_cparm_name(0,0));
  354. return func;
  355. }
  356. /* -----------------------------------------------------------------------------
  357. * Swig_cmemberset_call()
  358. *
  359. * Generates a string that sets the name of a member in a C++ class or C struct.
  360. *
  361. * arg0->name = arg1
  362. *
  363. * ----------------------------------------------------------------------------- */
  364. String *
  365. Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self) {
  366. String *func;
  367. func = NewString("");
  368. if (!self) self = NewString("(this)->");
  369. else self = NewString(self);
  370. Replaceall(self,"this",Swig_cparm_name(0,0));
  371. if (SwigType_type(type) != T_ARRAY) {
  372. Printf(func,"if (%s) %s%s = %s",Swig_cparm_name(0,0), self,name, Swig_wrapped_var_deref(type, Swig_cparm_name(0,1)));
  373. }
  374. Delete(self);
  375. return(func);
  376. }
  377. /* -----------------------------------------------------------------------------
  378. * Swig_cmemberget_call()
  379. *
  380. * Generates a string that sets the name of a member in a C++ class or C struct.
  381. *
  382. * arg0->name
  383. *
  384. * ----------------------------------------------------------------------------- */
  385. String *
  386. Swig_cmemberget_call(String_or_char *name, SwigType *t, String_or_char *self) {
  387. String *func;
  388. if (!self) self = NewString("(this)->");
  389. else self = NewString(self);
  390. Replaceall(self,"this",Swig_cparm_name(0,0));
  391. func = NewString("");
  392. Printf(func,"%s (%s%s)", Swig_wrapped_var_assign(t,""),self, name);
  393. Delete(self);
  394. return func;
  395. }
  396. /* -----------------------------------------------------------------------------
  397. * Swig_MethodToFunction(Node *n)
  398. *
  399. * Converts a C++ method node to a function accessor function.
  400. * ----------------------------------------------------------------------------- */
  401. int
  402. Swig_MethodToFunction(Node *n, String *classname, int flags) {
  403. String *name, *qualifier;
  404. ParmList *parms;
  405. SwigType *type;
  406. Parm *p;
  407. String *self = 0;
  408. /* If smart pointer, change self derefencing */
  409. if (flags & CWRAP_SMART_POINTER) {
  410. self = NewString("(*this)->");
  411. }
  412. /* If node is a member template expansion, we don't allow added code */
  413. if (Getattr(n,"templatetype")) flags &= ~(CWRAP_EXTEND);
  414. name = Getattr(n,"name");
  415. qualifier = Getattr(n,"qualifier");
  416. parms = CopyParmList(nonvoid_parms(Getattr(n,"parms")));
  417. type = NewString(classname);
  418. if (qualifier) {
  419. SwigType_push(type,qualifier);
  420. }
  421. SwigType_add_pointer(type);
  422. p = NewParm(type,"self");
  423. Setattr(p,"hidden","1");
  424. set_nextSibling(p,parms);
  425. Delete(type);
  426. /* Generate action code for the access */
  427. if (!(flags & CWRAP_EXTEND)) {
  428. Setattr(n,"wrap:action", Swig_cresult(Getattr(n,"type"),"result", Swig_cmethod_call(name,p,self)));
  429. } else {
  430. String *code;
  431. String *mangled;
  432. String *membername = Swig_name_member(classname, name);
  433. mangled = Swig_name_mangle(membername);
  434. code = Getattr(n,"code");
  435. type = Getattr(n,"type");
  436. /* Check if the method is overloaded. If so, and it has code attached, we append an extra suffix
  437. to avoid a name-clash in the generated wrappers. This allows overloaded methods to be defined
  438. in C. */
  439. if (Getattr(n,"sym:overloaded") && code) {
  440. Append(mangled,Getattr(n,"sym:overname"));
  441. }
  442. Setattr(n,"wrap:action", Swig_cresult(Getattr(n,"type"),"result", Swig_cfunction_call(mangled,p)));
  443. /* See if there is any code that we need to emit */
  444. if (code) {
  445. String *body;
  446. String *tmp = NewStringf("%s(%s)", mangled, ParmList_str(p));
  447. body = SwigType_str(type,tmp);
  448. Delete(tmp);
  449. Printv(body,code,"\n",NIL);
  450. Setattr(n,"wrap:code",body);
  451. }
  452. Delete(membername);
  453. Delete(mangled);
  454. }
  455. Setattr(n,"parms",p);
  456. Delete(p);
  457. Delete(self);
  458. return SWIG_OK;
  459. }
  460. /* -----------------------------------------------------------------------------
  461. * Swig_ConstructorToFunction()
  462. *
  463. * This function creates a C wrapper for a C constructor function.
  464. * ----------------------------------------------------------------------------- */
  465. int
  466. Swig_ConstructorToFunction(Node *n, String *classname, int cplus, int flags)
  467. {
  468. ParmList *parms;
  469. SwigType *type;
  470. String *membername;
  471. String *mangled;
  472. membername = Swig_name_construct(classname);
  473. mangled = Swig_name_mangle(membername);
  474. parms = CopyParmList(nonvoid_parms(Getattr(n,"parms")));
  475. type = NewString(classname);
  476. SwigType_add_pointer(type);
  477. if (flags & CWRAP_EXTEND) {
  478. String *code = Getattr(n,"code");
  479. if (code) {
  480. String *wrap;
  481. String *s = NewStringf("%s(%s)", mangled, ParmList_str(parms));
  482. wrap = SwigType_str(type,s);
  483. Delete(s);
  484. Printv(wrap,code,"\n",NIL);
  485. Setattr(n,"wrap:code",wrap);
  486. Delete(wrap);
  487. }
  488. Setattr(n,"wrap:action", Swig_cresult(type,"result", Swig_cfunction_call(mangled,parms)));
  489. } else {
  490. if (cplus) {
  491. Setattr(n,"wrap:action", Swig_cresult(type,"result", Swig_cppconstructor_call(classname,parms)));
  492. } else {
  493. Setattr(n,"wrap:action", Swig_cresult(type,"result", Swig_cconstructor_call(classname)));
  494. }
  495. }
  496. Setattr(n,"type",type);
  497. Setattr(n,"parms", parms);
  498. Delete(type);
  499. Delete(parms);
  500. Delete(mangled);
  501. Delete(membername);
  502. return SWIG_OK;
  503. }
  504. /* -----------------------------------------------------------------------------
  505. * Swig_DestructorToFunction()
  506. *
  507. * This function creates a C wrapper for a destructor function.
  508. * ----------------------------------------------------------------------------- */
  509. int
  510. Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags)
  511. {
  512. SwigType *type;
  513. Parm *p;
  514. type = NewString(classname);
  515. SwigType_add_pointer(type);
  516. p = NewParm(type,"self");
  517. Delete(type);
  518. type = NewString("void");
  519. if (flags & CWRAP_EXTEND) {
  520. String *membername, *mangled, *code;
  521. membername = Swig_name_destroy(classname);
  522. mangled = Swig_name_mangle(membername);
  523. code = Getattr(n,"code");
  524. if (code) {
  525. String *s = NewStringf("void %s(%s)", mangled, ParmList_str(p));
  526. Printv(s,code,"\n",NIL);
  527. Setattr(n,"wrap:code",s);
  528. Delete(s);
  529. }
  530. Setattr(n,"wrap:action", NewStringf("%s;\n", Swig_cfunction_call(mangled,p)));
  531. Delete(membername);
  532. Delete(mangled);
  533. } else {
  534. if (cplus) {
  535. Setattr(n,"wrap:action", NewStringf("%s;\n", Swig_cppdestructor_call()));
  536. } else {
  537. Setattr(n,"wrap:action", NewStringf("%s;\n", Swig_cdestructor_call()));
  538. }
  539. }
  540. Setattr(n,"type",type);
  541. Setattr(n,"parms", p);
  542. Delete(type);
  543. Delete(p);
  544. return SWIG_OK;
  545. }
  546. /* -----------------------------------------------------------------------------
  547. * Swig_MembersetToFunction()
  548. *
  549. * This function creates a C wrapper for setting a structure member.
  550. * ----------------------------------------------------------------------------- */
  551. int
  552. Swig_MembersetToFunction(Node *n, String *classname, int flags) {
  553. String *name;
  554. ParmList *parms;
  555. Parm *p;
  556. SwigType *t;
  557. SwigType *ty;
  558. SwigType *type;
  559. String *membername;
  560. String *mangled;
  561. String *self= 0;
  562. if (flags & CWRAP_SMART_POINTER) {
  563. self = NewString("(*this)->");
  564. }
  565. name = Getattr(n,"name");
  566. type = Getattr(n,"type");
  567. membername = Swig_name_member(classname, Swig_name_set(name));
  568. mangled = Swig_name_mangle(membername);
  569. t = NewString(classname);
  570. SwigType_add_pointer(t);
  571. parms = NewParm(t,"self");
  572. Delete(t);
  573. ty = Swig_wrapped_var_type(type);
  574. p = NewParm(ty,name);
  575. set_nextSibling(parms,p);
  576. /* If the type is a pointer or reference. We mark it with a special wrap:disown attribute */
  577. if (SwigType_check_decl(type,"p.")) {
  578. Setattr(p,"wrap:disown","1");
  579. }
  580. Delete(p);
  581. if (flags & CWRAP_EXTEND) {
  582. String *code = Getattr(n,"code");
  583. if (code) {
  584. String *s = NewStringf("void %s(%s)", mangled, ParmList_str(parms));
  585. Printv(s,code,"\n",NIL);
  586. Setattr(n,"wrap:code",s);
  587. Delete(s);
  588. }
  589. Setattr(n,"wrap:action", NewStringf("%s;\n", Swig_cfunction_call(mangled,parms)));
  590. } else {
  591. Setattr(n,"wrap:action", NewStringf("%s;\n", Swig_cmemberset_call(name,type,self)));
  592. }
  593. Setattr(n,"type","void");
  594. Setattr(n,"parms", parms);
  595. Delete(parms);
  596. Delete(ty);
  597. Delete(membername);
  598. Delete(mangled);
  599. Delete(self);
  600. return SWIG_OK;
  601. }
  602. /* -----------------------------------------------------------------------------
  603. * Swig_MembergetToFunction()
  604. *
  605. * This function creates a C wrapper for setting a structure member.
  606. * ----------------------------------------------------------------------------- */
  607. int
  608. Swig_MembergetToFunction(Node *n, String *classname, int flags) {
  609. String *name;
  610. ParmList *parms;
  611. SwigType *t;
  612. SwigType *ty;
  613. SwigType *type;
  614. String *membername;
  615. String *mangled;
  616. String *self = 0;
  617. if (flags & CWRAP_SMART_POINTER) {
  618. self = NewString("(*this)->");
  619. }
  620. name = Getattr(n,"name");
  621. type = Getattr(n,"type");
  622. membername = Swig_name_member(classname, Swig_name_get(name));
  623. mangled = Swig_name_mangle(membername);
  624. t = NewString(classname);
  625. SwigType_add_pointer(t);
  626. parms = NewParm(t,"self");
  627. Delete(t);
  628. ty = Swig_wrapped_var_type(type);
  629. if (flags & CWRAP_EXTEND) {
  630. String *code = Getattr(n,"code");
  631. if (code) {
  632. String *tmp = NewStringf("%s(%s)", mangled, ParmList_str(parms));
  633. String *s = SwigType_str(ty,tmp);
  634. Delete(tmp);
  635. Printv(s,code,"\n",NIL);
  636. Setattr(n,"wrap:code",s);
  637. Delete(s);
  638. }
  639. Setattr(n,"wrap:action", Swig_cresult(ty,"result",Swig_cfunction_call(mangled,parms)));
  640. } else {
  641. Setattr(n,"wrap:action", Swig_cresult(ty,"result",Swig_cmemberget_call(name,type,self)));
  642. }
  643. Setattr(n,"type",ty);
  644. Setattr(n,"parms", parms);
  645. Delete(parms);
  646. Delete(ty);
  647. Delete(membername);
  648. Delete(mangled);
  649. return SWIG_OK;
  650. }
  651. /* -----------------------------------------------------------------------------
  652. * Swig_VarsetToFunction()
  653. *
  654. * This function creates a C wrapper for setting a global variable.
  655. * ----------------------------------------------------------------------------- */
  656. int
  657. Swig_VarsetToFunction(Node *n) {
  658. String *name,*nname;
  659. ParmList *parms;
  660. SwigType *type, *ty;
  661. name = Getattr(n,"name");
  662. type = Getattr(n,"type");
  663. nname = SwigType_namestr(name);
  664. ty = Swig_wrapped_var_type(type);
  665. parms = NewParm(ty,"value");
  666. Delete(ty);
  667. Setattr(n,"wrap:action", NewStringf("%s = %s;\n", nname, Swig_wrapped_var_deref(type,Swig_cparm_name(0,0))));
  668. Setattr(n,"type","void");
  669. Setattr(n,"parms",parms);
  670. Delete(parms);
  671. Delete(nname);
  672. return SWIG_OK;
  673. }
  674. /* -----------------------------------------------------------------------------
  675. * Swig_VargetToFunction()
  676. *
  677. * This function creates a C wrapper for getting a global variable.
  678. * ----------------------------------------------------------------------------- */
  679. int
  680. Swig_VargetToFunction(Node *n) {
  681. String *name, *nname;
  682. SwigType *type, *ty;
  683. name = Getattr(n,"name");
  684. type = Getattr(n,"type");
  685. nname = SwigType_namestr(name);
  686. ty = Swig_wrapped_var_type(type);
  687. Setattr(n,"wrap:action", Swig_cresult(ty,"result",Swig_wrapped_var_assign(type,nname)));
  688. Setattr(n,"type",ty);
  689. Delattr(n,"parms");
  690. Delete(nname);
  691. Delete(ty);
  692. return SWIG_OK;
  693. }