~ubuntu-branches/ubuntu/oneiric/swig1.3/oneiric

« back to all changes in this revision

Viewing changes to Source/Swig/cwrap.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-12-06 10:27:08 UTC
  • mfrom: (1.2.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20071206102708-t37t62i45n595w0e
Tags: 1.3.33-2ubuntu1
* Merge with Debian; remaining changes:
  - Drop support for pike.
  - Use python2.5 instead of python2.4.
  - Clean Runtime/ as well.
  - Force a few environment variables.
* debian/Rules (clean): Remove Lib/ocaml/swigp4.ml.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 * the naming of local variables, calling conventions, and so forth.
9
9
 * ----------------------------------------------------------------------------- */
10
10
 
11
 
char cvsroot_cwrap_c[] = "$Header: /cvsroot/swig/SWIG/Source/Swig/cwrap.c,v 1.92 2006/11/10 23:08:51 wsfulton Exp $";
 
11
char cvsroot_cwrap_c[] = "$Id: cwrap.c 9633 2007-01-10 23:43:07Z beazley $";
12
12
 
13
13
#include "swig.h"
14
 
#include "swigkeys.h"
15
14
 
16
15
extern int cparse_cplusplus;
17
16
 
18
17
static Parm *nonvoid_parms(Parm *p) {
19
18
  if (p) {
20
 
    SwigType *t = Getattr(p, k_type);
 
19
    SwigType *t = Getattr(p, "type");
21
20
    if (SwigType_type(t) == T_VOID)
22
21
      return 0;
23
22
  }
33
32
String *Swig_cparm_name(Parm *p, int i) {
34
33
  String *name = NewStringf("arg%d", i + 1);
35
34
  if (p) {
36
 
    Setattr(p, k_lname, name);
 
35
    Setattr(p, "lname", name);
37
36
  }
38
37
 
39
38
  return name;
190
189
 
191
190
  while (p != 0) {
192
191
    String *lname = Swig_cparm_name(p, i);
193
 
    SwigType *pt = Getattr(p, k_type);
 
192
    SwigType *pt = Getattr(p, "type");
194
193
    if ((SwigType_type(pt) != T_VOID)) {
195
194
      String *local = 0;
196
 
      String *type = Getattr(p, k_type);
 
195
      String *type = Getattr(p, "type");
197
196
      /* default values only emitted if in compact default args mode */
198
 
      String *pvalue = (compactdefargs) ? Getattr(p, k_value) : 0;
 
197
      String *pvalue = (compactdefargs) ? Getattr(p, "value") : 0;
199
198
      SwigType *altty = SwigType_alttype(type, 0);
200
199
      int tycode = SwigType_type(type);
201
200
      if (tycode == T_REFERENCE) {
342
341
  Delete(nname);
343
342
 
344
343
  while (p) {
345
 
    SwigType *pt = Getattr(p, k_type);
 
344
    SwigType *pt = Getattr(p, "type");
346
345
    if ((SwigType_type(pt) != T_VOID)) {
347
346
      SwigType *rpt = SwigType_typedef_resolve_all(pt);
348
347
      String *pname = Swig_cparm_name(p, i);
406
405
    Replaceall(func, "this", rcaststr);
407
406
    Delete(rcaststr);
408
407
  } else {
409
 
    pt = Getattr(p, k_type);
 
408
    pt = Getattr(p, "type");
410
409
 
411
410
    /* If the method is invoked through a dereferenced pointer, we don't add any casts
412
411
       (needed for smart pointers).  Otherwise, we cast to the appropriate type */
442
441
  i++;
443
442
  p = nextSibling(p);
444
443
  while (p) {
445
 
    pt = Getattr(p, k_type);
 
444
    pt = Getattr(p, "type");
446
445
    if ((SwigType_type(pt) != T_VOID)) {
447
446
      String *pname = Swig_cparm_name(p, i);
448
447
      String *rcaststr = SwigType_rcaststr(pt, pname);
504
503
  func = NewStringEmpty();
505
504
  Printf(func, "new %s(", nname);
506
505
  while (p) {
507
 
    pt = Getattr(p, k_type);
 
506
    pt = Getattr(p, "type");
508
507
    if ((SwigType_type(pt) != T_VOID)) {
509
508
      String *rcaststr = 0;
510
509
      String *pname = 0;
511
510
      if (comma)
512
511
        Append(func, ",");
513
 
      if (!Getattr(p, k_argbyname)) {
 
512
      if (!Getattr(p, "arg:byname")) {
514
513
        pname = Swig_cparm_name(p, i);
515
514
        i++;
516
515
      } else {
517
 
        if ((pname = Getattr(p, k_value)))
 
516
        if ((pname = Getattr(p, "value")))
518
517
          pname = Copy(pname);
519
518
        else
520
 
          pname = Copy(Getattr(p, k_name));
 
519
          pname = Copy(Getattr(p, "name"));
521
520
      }
522
521
      rcaststr = SwigType_rcaststr(pt, pname);
523
522
      Append(func, rcaststr);
576
575
  if (f) {
577
576
    return f;
578
577
  } else {
579
 
    List *bl = Getattr(n, k_bases);
 
578
    List *bl = Getattr(n, "bases");
580
579
    if (bl) {
581
580
      Iterator bi;
582
581
      for (bi = First(bl); bi.item; bi = Next(bi)) {
769
768
 * ----------------------------------------------------------------------------- */
770
769
int Swig_add_extension_code(Node *n, const String *function_name, ParmList *parms, SwigType *return_type, const String *code, int cplusplus, const String *self) {
771
770
  String *body = extension_code(function_name, parms, return_type, code, cplusplus, self);
772
 
  Setattr(n, k_wrapcode, body);
 
771
  Setattr(n, "wrap:code", body);
773
772
  Delete(body);
774
773
  return SWIG_OK;
775
774
}
794
793
  }
795
794
 
796
795
  /* If node is a member template expansion, we don't allow added code */
797
 
  if (Getattr(n, k_templatetype))
 
796
  if (Getattr(n, "templatetype"))
798
797
    flags &= ~(CWRAP_EXTEND);
799
798
 
800
 
  name = Getattr(n, k_name);
801
 
  qualifier = Getattr(n, k_qualifier);
802
 
  parms = CopyParmList(nonvoid_parms(Getattr(n, k_parms)));
 
799
  name = Getattr(n, "name");
 
800
  qualifier = Getattr(n, "qualifier");
 
801
  parms = CopyParmList(nonvoid_parms(Getattr(n, "parms")));
803
802
 
804
803
  type = NewString(classname);
805
804
  if (qualifier) {
806
805
    SwigType_push(type, qualifier);
807
806
  }
808
807
  SwigType_add_pointer(type);
809
 
  p = NewParm(type, k_self);
810
 
  Setattr(p, k_self, "1");
811
 
  Setattr(p, k_hidden, "1");
 
808
  p = NewParm(type, "self");
 
809
  Setattr(p, "self", "1");
 
810
  Setattr(p, "hidden","1");
812
811
  /*
813
812
     Disable the 'this' ownership in 'self' to manage inplace
814
813
     operations like:
833
832
     languages.
834
833
   */
835
834
  if (GetFlag(n, "feature:self:disown")) {
836
 
    Setattr(p, k_wrapdisown, "1");
 
835
    Setattr(p, "wrap:disown", "1");
837
836
  }
838
837
  set_nextSibling(p, parms);
839
838
  Delete(type);
844
843
    String *call = 0;
845
844
    String *cres = 0;
846
845
    String *explicitcall_name = 0;
847
 
    int pure_virtual = !(Cmp(Getattr(n, k_storage), "virtual")) && !(Cmp(Getattr(n, k_value), "0"));
 
846
    int pure_virtual = !(Cmp(Getattr(n, "storage"), "virtual")) && !(Cmp(Getattr(n, "value"), "0"));
848
847
 
849
848
    /* Call the explicit method rather than allow for a polymorphic call */
850
849
    if ((flags & CWRAP_DIRECTOR_TWO_CALLS) || (flags & CWRAP_DIRECTOR_ONE_CALL)) {
851
850
      String *access = Getattr(n, "access");
852
851
      if (access && (Cmp(access, "protected") == 0)) {
853
852
        /* If protected access (can only be if a director method) then call the extra public accessor method (language module must provide this) */
854
 
        String *explicit_qualifier_tmp = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), k_qname));
 
853
        String *explicit_qualifier_tmp = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), "qname"));
855
854
        explicitcall_name = NewStringf("%sSwigPublic", name);
856
855
        explicit_qualifier = NewStringf("SwigDirector_%s", explicit_qualifier_tmp);
857
856
        Delete(explicit_qualifier_tmp);
858
857
      } else {
859
 
        explicit_qualifier = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), k_qname));
 
858
        explicit_qualifier = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), "qname"));
860
859
      }
861
860
    }
862
861
 
863
862
    call = Swig_cmethod_call(explicitcall_name ? explicitcall_name : name, p, self, explicit_qualifier, director_type);
864
 
    cres = Swig_cresult(Getattr(n, k_type), k_result, call);
 
863
    cres = Swig_cresult(Getattr(n, "type"), "result", call);
865
864
 
866
865
    if (pure_virtual && is_director && (flags & CWRAP_DIRECTOR_TWO_CALLS)) {
867
 
      String *qualifier = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), k_qname));
 
866
      String *qualifier = SwigType_namestr(Getattr(Getattr(parentNode(n), "typescope"), "qname"));
868
867
      Delete(cres);
869
868
      cres = NewStringf("Swig::DirectorPureVirtualException::raise(\"%s::%s\");", qualifier, name);
870
869
      Delete(qualifier);
874
873
      /* Create two method calls, one to call the explicit method, the other a normal polymorphic function call */
875
874
      String *cres_both_calls = NewStringf("");
876
875
      String *call_extra = Swig_cmethod_call(name, p, self, 0, director_type);
877
 
      String *cres_extra = Swig_cresult(Getattr(n, k_type), k_result, call_extra);
 
876
      String *cres_extra = Swig_cresult(Getattr(n, "type"), "result", call_extra);
878
877
      Printv(cres_both_calls, "if (upcall) {\n", cres, "\n", "} else {", cres_extra, "\n}", NIL);
879
 
      Setattr(n, k_wrapaction, cres_both_calls);
 
878
      Setattr(n, "wrap:action", cres_both_calls);
880
879
      Delete(cres_extra);
881
880
      Delete(call_extra);
882
881
      Delete(cres_both_calls);
883
882
    } else {
884
 
      Setattr(n, k_wrapaction, cres);
 
883
      Setattr(n, "wrap:action", cres);
885
884
    }
886
885
 
887
886
    Delete(explicitcall_name);
892
891
    /* Methods with default arguments are wrapped with additional methods for each default argument,
893
892
     * however, only one extra %extend method is generated. */
894
893
 
895
 
    String *defaultargs = Getattr(n, k_defaultargs);
896
 
    String *code = Getattr(n, k_code);
897
 
    String *cname = Getattr(n, k_classname) ? Getattr(n, k_classname) : classname;
 
894
    String *defaultargs = Getattr(n, "defaultargs");
 
895
    String *code = Getattr(n, "code");
 
896
    String *cname = Getattr(n, "classname") ? Getattr(n, "classname") : classname;
898
897
    String *membername = Swig_name_member(cname, name);
899
898
    String *mangled = Swig_name_mangle(membername);
900
899
    int is_smart_pointer = flags & CWRAP_SMART_POINTER;
901
900
 
902
 
    type = Getattr(n, k_type);
 
901
    type = Getattr(n, "type");
903
902
 
904
903
    /* Check if the method is overloaded.   If so, and it has code attached, we append an extra suffix
905
904
       to avoid a name-clash in the generated wrappers.  This allows overloaded methods to be defined
906
905
       in C. */
907
 
    if (Getattr(n, k_symoverloaded) && code) {
908
 
      Append(mangled, Getattr(defaultargs ? defaultargs : n, k_symovername));
 
906
    if (Getattr(n, "sym:overloaded") && code) {
 
907
      Append(mangled, Getattr(defaultargs ? defaultargs : n, "sym:overname"));
909
908
    }
910
909
 
911
910
    /* See if there is any code that we need to emit */
912
911
    if (!defaultargs && code && !is_smart_pointer) {
913
 
      Swig_add_extension_code(n, mangled, p, type, code, cparse_cplusplus, k_self);
 
912
      Swig_add_extension_code(n, mangled, p, type, code, cparse_cplusplus, "self");
914
913
    }
915
914
    if (is_smart_pointer) {
916
915
      int i = 0;
918
917
      String *func = NewStringf("%s(", mangled);
919
918
      String *cres;
920
919
 
921
 
      if (Cmp(Getattr(n, k_storage), k_static) != 0) {
 
920
      if (Cmp(Getattr(n, "storage"), "static") != 0) {
922
921
        String *pname = Swig_cparm_name(pp, i);
923
922
        String *ctname = SwigType_namestr(cname);
924
923
        String *fadd = NewStringf("(%s*)(%s)->operator ->()", ctname, pname);
934
933
      }
935
934
      ++i;
936
935
      while (pp) {
937
 
        SwigType *pt = Getattr(pp, k_type);
 
936
        SwigType *pt = Getattr(pp, "type");
938
937
        if ((SwigType_type(pt) != T_VOID)) {
939
938
          String *pname = Swig_cparm_name(pp, i++);
940
939
          String *rcaststr = SwigType_rcaststr(pt, pname);
947
946
        }
948
947
      }
949
948
      Append(func, ")");
950
 
      cres = Swig_cresult(Getattr(n, k_type), k_result, func);
951
 
      Setattr(n, k_wrapaction, cres);
 
949
      cres = Swig_cresult(Getattr(n, "type"), "result", func);
 
950
      Setattr(n, "wrap:action", cres);
952
951
      Delete(cres);
953
952
    } else {
954
953
      String *call = Swig_cfunction_call(mangled, p);
955
 
      String *cres = Swig_cresult(Getattr(n, k_type), k_result, call);
956
 
      Setattr(n, k_wrapaction, cres);
 
954
      String *cres = Swig_cresult(Getattr(n, "type"), "result", call);
 
955
      Setattr(n, "wrap:action", cres);
957
956
      Delete(call);
958
957
      Delete(cres);
959
958
    }
961
960
    Delete(membername);
962
961
    Delete(mangled);
963
962
  }
964
 
  Setattr(n, k_parms, p);
 
963
  Setattr(n, "parms", p);
965
964
  Delete(p);
966
965
  Delete(self);
967
966
  Delete(parms);
975
974
 * ----------------------------------------------------------------------------- */
976
975
 
977
976
Node *Swig_methodclass(Node *n) {
978
 
  Node *nodetype = Getattr(n, k_nodetype);
 
977
  Node *nodetype = nodeType(n);
979
978
  if (!Cmp(nodetype, "class"))
980
979
    return n;
981
 
  return GetFlag(n, "feature:extend") ? Getattr(Getattr(n, k_parentnode), k_parentnode) : Getattr(n, k_parentnode);
 
980
  return GetFlag(n, "feature:extend") ? parentNode(parentNode(n)) : parentNode(n);
982
981
}
983
982
 
984
983
int Swig_directorclass(Node *n) {
985
984
  Node *classNode = Swig_methodclass(n);
986
985
  assert(classNode != 0);
987
 
  return (Getattr(classNode, k_vtable) != 0);
 
986
  return (Getattr(classNode, "vtable") != 0);
988
987
}
989
988
 
990
989
Node *Swig_directormap(Node *module, String *type) {
994
993
 
995
994
    String *base = SwigType_base(type);
996
995
 
997
 
    Node *directormap = Getattr(module, k_wrapdirectormap);
 
996
    Node *directormap = Getattr(module, "wrap:directormap");
998
997
    if (directormap)
999
998
      return Getattr(directormap, base);
1000
999
  }
1020
1019
  classNode = Swig_methodclass(n);
1021
1020
  use_director = Swig_directorclass(n);
1022
1021
 
1023
 
  parms = CopyParmList(nonvoid_parms(Getattr(n, k_parms)));
 
1022
  parms = CopyParmList(nonvoid_parms(Getattr(n, "parms")));
1024
1023
 
1025
1024
  /* Prepend the list of prefix_args (if any) */
1026
 
  prefix_args = Getattr(n, k_directorprefixargs);
 
1025
  prefix_args = Getattr(n, "director:prefix_args");
1027
1026
  if (prefix_args != NIL) {
1028
1027
    Parm *p2, *p3;
1029
1028
 
1046
1045
     * however, only one extra %extend method is generated. */
1047
1046
    String *call;
1048
1047
    String *cres;
1049
 
    String *defaultargs = Getattr(n, k_defaultargs);
1050
 
    String *code = Getattr(n, k_code);
 
1048
    String *defaultargs = Getattr(n, "defaultargs");
 
1049
    String *code = Getattr(n, "code");
1051
1050
    String *membername = Swig_name_construct(classname);
1052
1051
    String *mangled = Swig_name_mangle(membername);
1053
1052
 
1054
1053
    /* Check if the constructor is overloaded.   If so, and it has code attached, we append an extra suffix
1055
1054
       to avoid a name-clash in the generated wrappers.  This allows overloaded constructors to be defined
1056
1055
       in C. */
1057
 
    if (Getattr(n, k_symoverloaded) && code) {
1058
 
      Append(mangled, Getattr(defaultargs ? defaultargs : n, k_symovername));
 
1056
    if (Getattr(n, "sym:overloaded") && code) {
 
1057
      Append(mangled, Getattr(defaultargs ? defaultargs : n, "sym:overname"));
1059
1058
    }
1060
1059
 
1061
1060
    /* See if there is any code that we need to emit */
1062
1061
    if (!defaultargs && code) {
1063
 
      Swig_add_extension_code(n, mangled, parms, type, code, cparse_cplusplus, k_self);
 
1062
      Swig_add_extension_code(n, mangled, parms, type, code, cparse_cplusplus, "self");
1064
1063
    }
1065
1064
 
1066
1065
    call = Swig_cfunction_call(mangled, parms);
1067
 
    cres = Swig_cresult(type, k_result, call);
1068
 
    Setattr(n, k_wrapaction, cres);
 
1066
    cres = Swig_cresult(type, "result", call);
 
1067
    Setattr(n, "wrap:action", cres);
1069
1068
    Delete(cres);
1070
1069
    Delete(call);
1071
1070
    Delete(membername);
1075
1074
      /* if a C++ director class exists, create it rather than the original class */
1076
1075
      if (use_director) {
1077
1076
        Node *parent = Swig_methodclass(n);
1078
 
        int abstract = Getattr(parent, k_abstract) != 0;
1079
 
        String *name = Getattr(parent, k_symname);
 
1077
        int abstract = Getattr(parent, "abstract") != 0;
 
1078
        String *name = Getattr(parent, "sym:name");
1080
1079
        String *directorname = NewStringf("SwigDirector_%s", name);
1081
1080
        String *action = NewStringEmpty();
1082
1081
        String *tmp_none_comparison = Copy(none_comparison);
1095
1094
           * implemented in the target language, calls to those methods will
1096
1095
           * generate Swig::DirectorPureVirtualException exceptions.
1097
1096
           */
1098
 
          String *cres = Swig_cresult(type, k_result, director_call);
 
1097
          String *cres = Swig_cresult(type, "result", director_call);
1099
1098
          Append(action, cres);
1100
1099
          Delete(cres);
1101
1100
        } else {
1110
1109
          Append(action, director_ctor);
1111
1110
          Replaceall(action, "$comparison", tmp_none_comparison);
1112
1111
 
1113
 
          cres = Swig_cresult(type, k_result, director_call);
 
1112
          cres = Swig_cresult(type, "result", director_call);
1114
1113
          Replaceall(action, "$director_new", cres);
1115
1114
          Delete(cres);
1116
1115
 
1117
 
          cres = Swig_cresult(type, k_result, nodirector_call);
 
1116
          cres = Swig_cresult(type, "result", nodirector_call);
1118
1117
          Replaceall(action, "$nondirector_new", cres);
1119
1118
          Delete(cres);
1120
1119
        }
1121
 
        Setattr(n, k_wrapaction, action);
 
1120
        Setattr(n, "wrap:action", action);
1122
1121
        Delete(tmp_none_comparison);
1123
1122
        Delete(action);
1124
1123
        Delete(directorname);
1125
1124
      } else {
1126
1125
        String *call = Swig_cppconstructor_call(classname, parms);
1127
 
        String *cres = Swig_cresult(type, k_result, call);
1128
 
        Setattr(n, k_wrapaction, cres);
 
1126
        String *cres = Swig_cresult(type, "result", call);
 
1127
        Setattr(n, "wrap:action", cres);
1129
1128
        Delete(cres);
1130
1129
        Delete(call);
1131
1130
      }
1132
1131
    } else {
1133
1132
      String *call = Swig_cconstructor_call(classname);
1134
 
      String *cres = Swig_cresult(type, k_result, call);
1135
 
      Setattr(n, k_wrapaction, cres);
 
1133
      String *cres = Swig_cresult(type, "result", call);
 
1134
      Setattr(n, "wrap:action", cres);
1136
1135
      Delete(cres);
1137
1136
      Delete(call);
1138
1137
    }
1139
1138
  }
1140
 
  Setattr(n, k_type, type);
1141
 
  Setattr(n, k_parms, parms);
 
1139
  Setattr(n, "type", type);
 
1140
  Setattr(n, "parms", parms);
1142
1141
  Delete(type);
1143
1142
  if (directorparms != parms)
1144
1143
    Delete(directorparms);
1158
1157
 
1159
1158
  type = NewString(classname);
1160
1159
  SwigType_add_pointer(type);
1161
 
  p = NewParm(type, k_self);
1162
 
  Setattr(p, k_self, "1");
1163
 
  Setattr(p, k_hidden, "1");
1164
 
  Setattr(p, k_wrapdisown, "1");
 
1160
  p = NewParm(type, "self");
 
1161
  Setattr(p, "self", "1");
 
1162
  Setattr(p, "hidden", "1");
 
1163
  Setattr(p, "wrap:disown", "1");
1165
1164
  Delete(type);
1166
1165
  type = NewString("void");
1167
1166
 
1171
1170
    String *membername, *mangled, *code;
1172
1171
    membername = Swig_name_destroy(classname);
1173
1172
    mangled = Swig_name_mangle(membername);
1174
 
    code = Getattr(n, k_code);
 
1173
    code = Getattr(n, "code");
1175
1174
    if (code) {
1176
 
      Swig_add_extension_code(n, mangled, p, type, code, cparse_cplusplus, k_self);
 
1175
      Swig_add_extension_code(n, mangled, p, type, code, cparse_cplusplus, "self");
1177
1176
    }
1178
1177
    call = Swig_cfunction_call(mangled, p);
1179
1178
    cres = NewStringf("%s;\n", call);
1180
 
    Setattr(n, k_wrapaction, cres);
 
1179
    Setattr(n, "wrap:action", cres);
1181
1180
    Delete(membername);
1182
1181
    Delete(mangled);
1183
1182
    Delete(call);
1186
1185
    if (cplus) {
1187
1186
      String *call = Swig_cppdestructor_call(n);
1188
1187
      String *cres = NewStringf("%s\n", call);
1189
 
      Setattr(n, k_wrapaction, cres);
 
1188
      Setattr(n, "wrap:action", cres);
1190
1189
      Delete(call);
1191
1190
      Delete(cres);
1192
1191
    } else {
1193
1192
      String *call = Swig_cdestructor_call(n);
1194
1193
      String *cres = NewStringf("%s\n", call);
1195
 
      Setattr(n, k_wrapaction, cres);
 
1194
      Setattr(n, "wrap:action", cres);
1196
1195
      Delete(call);
1197
1196
      Delete(cres);
1198
1197
    }
1199
1198
  }
1200
 
  Setattr(n, k_type, type);
1201
 
  Setattr(n, k_parms, p);
 
1199
  Setattr(n, "type", type);
 
1200
  Setattr(n, "parms", p);
1202
1201
  Delete(type);
1203
1202
  Delete(p);
1204
1203
  return SWIG_OK;
1229
1228
    self = NewString("(*this)->");
1230
1229
  }
1231
1230
 
1232
 
  name = Getattr(n, k_name);
1233
 
  type = Getattr(n, k_type);
 
1231
  name = Getattr(n, "name");
 
1232
  type = Getattr(n, "type");
1234
1233
 
1235
1234
  sname = Swig_name_set(name);
1236
1235
  membername = Swig_name_member(classname, sname);
1238
1237
 
1239
1238
  t = NewString(classname);
1240
1239
  SwigType_add_pointer(t);
1241
 
  parms = NewParm(t, k_self);
1242
 
  Setattr(parms, k_self, "1");
1243
 
  Setattr(parms, k_hidden, "1");
 
1240
  parms = NewParm(t, "self");
 
1241
  Setattr(parms, "self", "1");
 
1242
  Setattr(parms, "hidden","1");
1244
1243
  Delete(t);
1245
1244
 
1246
1245
  ty = Swig_wrapped_member_var_type(type, varcref);
1247
1246
  p = NewParm(ty, name);
1248
 
  Setattr(parms, k_hidden, "1");
 
1247
  Setattr(parms, "hidden", "1");
1249
1248
  set_nextSibling(parms, p);
1250
1249
 
1251
1250
  /* If the type is a pointer or reference.  We mark it with a special wrap:disown attribute */
1252
1251
  if (SwigType_check_decl(type, "p.")) {
1253
 
    Setattr(p, k_wrapdisown, "1");
 
1252
    Setattr(p, "wrap:disown", "1");
1254
1253
  }
1255
1254
  Delete(p);
1256
1255
 
1257
1256
  if (flags & CWRAP_EXTEND) {
1258
1257
    String *call;
1259
1258
    String *cres;
1260
 
    String *code = Getattr(n, k_code);
 
1259
    String *code = Getattr(n, "code");
1261
1260
    if (code) {
1262
 
      Swig_add_extension_code(n, mangled, parms, void_type, code, cparse_cplusplus, k_self);
 
1261
      /* I don't think this ever gets run - WSF */
 
1262
      Swig_add_extension_code(n, mangled, parms, void_type, code, cparse_cplusplus, "self");
1263
1263
    }
1264
1264
    call = Swig_cfunction_call(mangled, parms);
1265
1265
    cres = NewStringf("%s;\n", call);
1266
 
    Setattr(n, k_wrapaction, cres);
 
1266
    Setattr(n, "wrap:action", cres);
1267
1267
    Delete(call);
1268
1268
    Delete(cres);
1269
1269
  } else {
1270
1270
    String *call = Swig_cmemberset_call(name, type, self, varcref);
1271
1271
    String *cres = NewStringf("%s;\n", call);
1272
 
    Setattr(n, k_wrapaction, cres);
 
1272
    Setattr(n, "wrap:action", cres);
1273
1273
    Delete(call);
1274
1274
    Delete(cres);
1275
1275
  }
1276
 
  Setattr(n, k_type, void_type);
1277
 
  Setattr(n, k_parms, parms);
 
1276
  Setattr(n, "type", void_type);
 
1277
  Setattr(n, "parms", parms);
1278
1278
  Delete(parms);
1279
1279
  Delete(ty);
1280
1280
  Delete(void_type);
1305
1305
  int varcref = flags & CWRAP_NATURAL_VAR;
1306
1306
 
1307
1307
  if (flags & CWRAP_SMART_POINTER) {
1308
 
    if (checkAttribute(n, k_storage, k_static)) {
1309
 
      Node *sn = Getattr(n, k_cplusstaticbase);
1310
 
      String *base = Getattr(sn, k_name);
 
1308
    if (checkAttribute(n, "storage", "static")) {
 
1309
      Node *sn = Getattr(n, "cplus:staticbase");
 
1310
      String *base = Getattr(sn, "name");
1311
1311
      self = NewStringf("%s::", base);
1312
1312
    } else {
1313
1313
      self = NewString("(*this)->");
1314
1314
    }
1315
1315
  }
1316
1316
 
1317
 
  name = Getattr(n, k_name);
1318
 
  type = Getattr(n, k_type);
 
1317
  name = Getattr(n, "name");
 
1318
  type = Getattr(n, "type");
1319
1319
 
1320
1320
  gname = Swig_name_get(name);
1321
1321
  membername = Swig_name_member(classname, gname);
1323
1323
 
1324
1324
  t = NewString(classname);
1325
1325
  SwigType_add_pointer(t);
1326
 
  parms = NewParm(t, k_self);
1327
 
  Setattr(parms, k_self, "1");
1328
 
  Setattr(parms, k_hidden, "1");
 
1326
  parms = NewParm(t, "self");
 
1327
  Setattr(parms, "self", "1");
 
1328
  Setattr(parms, "hidden","1");
1329
1329
  Delete(t);
1330
1330
 
1331
1331
  ty = Swig_wrapped_member_var_type(type, varcref);
1333
1333
    String *call;
1334
1334
    String *cres;
1335
1335
 
1336
 
    String *code = Getattr(n, k_code);
 
1336
    String *code = Getattr(n, "code");
1337
1337
    if (code) {
1338
 
      Swig_add_extension_code(n, mangled, parms, ty, code, cparse_cplusplus, k_self);
 
1338
      /* I don't think this ever gets run - WSF */
 
1339
      Swig_add_extension_code(n, mangled, parms, ty, code, cparse_cplusplus, "self");
1339
1340
    }
1340
1341
    call = Swig_cfunction_call(mangled, parms);
1341
 
    cres = Swig_cresult(ty, k_result, call);
1342
 
    Setattr(n, k_wrapaction, cres);
 
1342
    cres = Swig_cresult(ty, "result", call);
 
1343
    Setattr(n, "wrap:action", cres);
1343
1344
    Delete(cres);
1344
1345
    Delete(call);
1345
1346
  } else {
1346
1347
    String *call = Swig_cmemberget_call(name, type, self, varcref);
1347
 
    String *cres = Swig_cresult(ty, k_result, call);
1348
 
    Setattr(n, k_wrapaction, cres);
 
1348
    String *cres = Swig_cresult(ty, "result", call);
 
1349
    Setattr(n, "wrap:action", cres);
1349
1350
    Delete(call);
1350
1351
    Delete(cres);
1351
1352
  }
1352
 
  Setattr(n, k_type, ty);
1353
 
  Setattr(n, k_parms, parms);
 
1353
  Setattr(n, "type", ty);
 
1354
  Setattr(n, "parms", parms);
1354
1355
  Delete(parms);
1355
1356
  Delete(ty);
1356
1357
  Delete(membername);
1363
1364
/* -----------------------------------------------------------------------------
1364
1365
 * Swig_VarsetToFunction()
1365
1366
 *
1366
 
 * This function creates a C wrapper for setting a global variable.
 
1367
 * This function creates a C wrapper for setting a global variable or static member
 
1368
 * variable.
1367
1369
 * ----------------------------------------------------------------------------- */
1368
1370
 
1369
1371
int Swig_VarsetToFunction(Node *n, int flags) {
1373
1375
 
1374
1376
  int varcref = flags & CWRAP_NATURAL_VAR;
1375
1377
 
1376
 
  name = Getattr(n, k_name);
1377
 
  type = Getattr(n, k_type);
1378
 
 
 
1378
  name = Getattr(n, "name");
 
1379
  type = Getattr(n, "type");
1379
1380
  nname = SwigType_namestr(name);
1380
 
 
1381
1381
  ty = Swig_wrapped_var_type(type, varcref);
1382
1382
  parms = NewParm(ty, name);
1383
 
  Delete(ty);
1384
1383
 
1385
 
  if (!Strstr(type, "enum $unnamed")) {
1386
 
    String *pname = Swig_cparm_name(0, 0);
1387
 
    String *dref = Swig_wrapped_var_deref(type, pname, varcref);
1388
 
    String *call = NewStringf("%s = %s;\n", nname, dref);
1389
 
    Setattr(n, k_wrapaction, call);
 
1384
  if (flags & CWRAP_EXTEND) {
 
1385
    String *sname = Swig_name_set(name);
 
1386
    String *mangled = Swig_name_mangle(sname);
 
1387
    String *call = Swig_cfunction_call(mangled, parms);
 
1388
    String *cres = NewStringf("%s;\n", call);
 
1389
    Setattr(n, "wrap:action", cres);
 
1390
    Delete(cres);
1390
1391
    Delete(call);
1391
 
    Delete(dref);
1392
 
    Delete(pname);
 
1392
    Delete(mangled);
 
1393
    Delete(sname);
1393
1394
  } else {
1394
 
    String *pname = Swig_cparm_name(0, 0);
1395
 
    String *call = NewStringf("if (sizeof(int) == sizeof(%s)) *(int*)(void*)&(%s) = %s;\n", nname, nname, pname);
1396
 
    Setattr(n, k_wrapaction, call);
1397
 
    Delete(call);
 
1395
    if (!Strstr(type, "enum $unnamed")) {
 
1396
      String *pname = Swig_cparm_name(0, 0);
 
1397
      String *dref = Swig_wrapped_var_deref(type, pname, varcref);
 
1398
      String *call = NewStringf("%s = %s;\n", nname, dref);
 
1399
      Setattr(n, "wrap:action", call);
 
1400
      Delete(call);
 
1401
      Delete(dref);
 
1402
      Delete(pname);
 
1403
    } else {
 
1404
      String *pname = Swig_cparm_name(0, 0);
 
1405
      String *call = NewStringf("if (sizeof(int) == sizeof(%s)) *(int*)(void*)&(%s) = %s;\n", nname, nname, pname);
 
1406
      Setattr(n, "wrap:action", call);
 
1407
      Delete(pname);
 
1408
      Delete(call);
 
1409
    }
1398
1410
  }
1399
 
  Setattr(n, k_type, "void");
1400
 
  Setattr(n, k_parms, parms);
 
1411
  Setattr(n, "type", "void");
 
1412
  Setattr(n, "parms", parms);
1401
1413
  Delete(parms);
 
1414
  Delete(ty);
1402
1415
  Delete(nname);
1403
1416
  return SWIG_OK;
1404
1417
}
1406
1419
/* -----------------------------------------------------------------------------
1407
1420
 * Swig_VargetToFunction()
1408
1421
 *
1409
 
 * This function creates a C wrapper for getting a global variable.
 
1422
 * This function creates a C wrapper for getting a global variable or static member
 
1423
 * variable.
1410
1424
 * ----------------------------------------------------------------------------- */
1411
1425
 
1412
1426
int Swig_VargetToFunction(Node *n, int flags) {
1413
1427
  String *cres, *call;
1414
 
  String *name, *nname;
1415
 
  SwigType *type, *ty;
 
1428
  String *name;
 
1429
  SwigType *type;
 
1430
  SwigType *ty = 0;
1416
1431
 
1417
1432
  int varcref = flags & CWRAP_NATURAL_VAR;
1418
1433
 
1419
 
  name = Getattr(n, k_name);
1420
 
  type = Getattr(n, k_type);
1421
 
 
1422
 
  nname = SwigType_namestr(name);
 
1434
  name = Getattr(n, "name");
 
1435
  type = Getattr(n, "type");
1423
1436
  ty = Swig_wrapped_var_type(type, varcref);
1424
 
  call = Swig_wrapped_var_assign(type, nname, varcref);
1425
 
  cres = Swig_cresult(ty, k_result, call);
1426
 
  Setattr(n, k_wrapaction, cres);
 
1437
 
 
1438
  if (flags & CWRAP_EXTEND) {
 
1439
    String *sname = Swig_name_get(name);
 
1440
    String *mangled = Swig_name_mangle(sname);
 
1441
    call = Swig_cfunction_call(mangled, 0);
 
1442
    cres = Swig_cresult(ty, "result", call);
 
1443
    Setattr(n, "wrap:action", cres);
 
1444
    Delete(mangled);
 
1445
    Delete(sname);
 
1446
  } else {
 
1447
    String *nname = SwigType_namestr(name);
 
1448
    call = Swig_wrapped_var_assign(type, nname, varcref);
 
1449
    cres = Swig_cresult(ty, "result", call);
 
1450
    Setattr(n, "wrap:action", cres);
 
1451
    Delete(nname);
 
1452
  }
 
1453
 
 
1454
  Setattr(n, "type", ty);
 
1455
  Delattr(n, "parms");
1427
1456
  Delete(cres);
1428
1457
  Delete(call);
1429
 
  Setattr(n, k_type, ty);
1430
 
  Delattr(n, k_parms);
1431
 
  Delete(nname);
1432
1458
  Delete(ty);
1433
1459
  return SWIG_OK;
1434
1460
}