Fix %extend for static member variables
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9584 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
22af54f188
commit
9910dff87a
2 changed files with 57 additions and 26 deletions
|
|
@ -2789,6 +2789,9 @@ int Language::variableWrapper(Node *n) {
|
||||||
/* If no way to set variables. We simply create functions */
|
/* If no way to set variables. We simply create functions */
|
||||||
int assignable = is_assignable(n);
|
int assignable = is_assignable(n);
|
||||||
int flags = use_naturalvar_mode(n);
|
int flags = use_naturalvar_mode(n);
|
||||||
|
if (!GetFlag(n, "wrappedasconstant"))
|
||||||
|
flags = flags | Extend;
|
||||||
|
|
||||||
if (assignable) {
|
if (assignable) {
|
||||||
int make_set_wrapper = 1;
|
int make_set_wrapper = 1;
|
||||||
String *tm = Swig_typemap_lookup_new("globalin", n, name, 0);
|
String *tm = Swig_typemap_lookup_new("globalin", n, name, 0);
|
||||||
|
|
@ -2829,6 +2832,7 @@ int Language::variableWrapper(Node *n) {
|
||||||
Delattr(n, ki.key);
|
Delattr(n, ki.key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Swig_VargetToFunction(n, flags);
|
Swig_VargetToFunction(n, flags);
|
||||||
String *gname = Swig_name_get(symname);
|
String *gname = Swig_name_get(symname);
|
||||||
Setattr(n, "sym:name", gname);
|
Setattr(n, "sym:name", gname);
|
||||||
|
|
|
||||||
|
|
@ -1259,6 +1259,7 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
||||||
String *cres;
|
String *cres;
|
||||||
String *code = Getattr(n, k_code);
|
String *code = Getattr(n, k_code);
|
||||||
if (code) {
|
if (code) {
|
||||||
|
/* I don't think this ever gets run - WSF */
|
||||||
Swig_add_extension_code(n, mangled, parms, void_type, code, cparse_cplusplus, k_self);
|
Swig_add_extension_code(n, mangled, parms, void_type, code, cparse_cplusplus, k_self);
|
||||||
}
|
}
|
||||||
call = Swig_cfunction_call(mangled, parms);
|
call = Swig_cfunction_call(mangled, parms);
|
||||||
|
|
@ -1335,6 +1336,7 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
||||||
|
|
||||||
String *code = Getattr(n, k_code);
|
String *code = Getattr(n, k_code);
|
||||||
if (code) {
|
if (code) {
|
||||||
|
/* I don't think this ever gets run - WSF */
|
||||||
Swig_add_extension_code(n, mangled, parms, ty, code, cparse_cplusplus, k_self);
|
Swig_add_extension_code(n, mangled, parms, ty, code, cparse_cplusplus, k_self);
|
||||||
}
|
}
|
||||||
call = Swig_cfunction_call(mangled, parms);
|
call = Swig_cfunction_call(mangled, parms);
|
||||||
|
|
@ -1363,7 +1365,8 @@ int Swig_MembergetToFunction(Node *n, String *classname, int flags) {
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Swig_VarsetToFunction()
|
* Swig_VarsetToFunction()
|
||||||
*
|
*
|
||||||
* This function creates a C wrapper for setting a global variable.
|
* This function creates a C wrapper for setting a global variable or static member
|
||||||
|
* variable.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int Swig_VarsetToFunction(Node *n, int flags) {
|
int Swig_VarsetToFunction(Node *n, int flags) {
|
||||||
|
|
@ -1375,13 +1378,21 @@ int Swig_VarsetToFunction(Node *n, int flags) {
|
||||||
|
|
||||||
name = Getattr(n, k_name);
|
name = Getattr(n, k_name);
|
||||||
type = Getattr(n, k_type);
|
type = Getattr(n, k_type);
|
||||||
|
|
||||||
nname = SwigType_namestr(name);
|
nname = SwigType_namestr(name);
|
||||||
|
|
||||||
ty = Swig_wrapped_var_type(type, varcref);
|
ty = Swig_wrapped_var_type(type, varcref);
|
||||||
parms = NewParm(ty, name);
|
parms = NewParm(ty, name);
|
||||||
Delete(ty);
|
|
||||||
|
|
||||||
|
if (flags & CWRAP_EXTEND) {
|
||||||
|
String *sname = Swig_name_set(name);
|
||||||
|
String *mangled = Swig_name_mangle(sname);
|
||||||
|
String *call = Swig_cfunction_call(mangled, parms);
|
||||||
|
String *cres = NewStringf("%s;\n", call);
|
||||||
|
Setattr(n, k_wrapaction, cres);
|
||||||
|
Delete(cres);
|
||||||
|
Delete(call);
|
||||||
|
Delete(mangled);
|
||||||
|
Delete(sname);
|
||||||
|
} else {
|
||||||
if (!Strstr(type, "enum $unnamed")) {
|
if (!Strstr(type, "enum $unnamed")) {
|
||||||
String *pname = Swig_cparm_name(0, 0);
|
String *pname = Swig_cparm_name(0, 0);
|
||||||
String *dref = Swig_wrapped_var_deref(type, pname, varcref);
|
String *dref = Swig_wrapped_var_deref(type, pname, varcref);
|
||||||
|
|
@ -1394,11 +1405,14 @@ int Swig_VarsetToFunction(Node *n, int flags) {
|
||||||
String *pname = Swig_cparm_name(0, 0);
|
String *pname = Swig_cparm_name(0, 0);
|
||||||
String *call = NewStringf("if (sizeof(int) == sizeof(%s)) *(int*)(void*)&(%s) = %s;\n", nname, nname, pname);
|
String *call = NewStringf("if (sizeof(int) == sizeof(%s)) *(int*)(void*)&(%s) = %s;\n", nname, nname, pname);
|
||||||
Setattr(n, k_wrapaction, call);
|
Setattr(n, k_wrapaction, call);
|
||||||
|
Delete(pname);
|
||||||
Delete(call);
|
Delete(call);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Setattr(n, k_type, "void");
|
Setattr(n, k_type, "void");
|
||||||
Setattr(n, k_parms, parms);
|
Setattr(n, k_parms, parms);
|
||||||
Delete(parms);
|
Delete(parms);
|
||||||
|
Delete(ty);
|
||||||
Delete(nname);
|
Delete(nname);
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
@ -1406,29 +1420,42 @@ int Swig_VarsetToFunction(Node *n, int flags) {
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
* Swig_VargetToFunction()
|
* Swig_VargetToFunction()
|
||||||
*
|
*
|
||||||
* This function creates a C wrapper for getting a global variable.
|
* This function creates a C wrapper for getting a global variable or static member
|
||||||
|
* variable.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
int Swig_VargetToFunction(Node *n, int flags) {
|
int Swig_VargetToFunction(Node *n, int flags) {
|
||||||
String *cres, *call;
|
String *cres, *call;
|
||||||
String *name, *nname;
|
String *name;
|
||||||
SwigType *type, *ty;
|
SwigType *type;
|
||||||
|
SwigType *ty = 0;
|
||||||
|
|
||||||
int varcref = flags & CWRAP_NATURAL_VAR;
|
int varcref = flags & CWRAP_NATURAL_VAR;
|
||||||
|
|
||||||
name = Getattr(n, k_name);
|
name = Getattr(n, k_name);
|
||||||
type = Getattr(n, k_type);
|
type = Getattr(n, k_type);
|
||||||
|
|
||||||
nname = SwigType_namestr(name);
|
|
||||||
ty = Swig_wrapped_var_type(type, varcref);
|
ty = Swig_wrapped_var_type(type, varcref);
|
||||||
|
|
||||||
|
if (flags & CWRAP_EXTEND) {
|
||||||
|
String *sname = Swig_name_get(name);
|
||||||
|
String *mangled = Swig_name_mangle(sname);
|
||||||
|
call = Swig_cfunction_call(mangled, 0);
|
||||||
|
cres = Swig_cresult(ty, k_result, call);
|
||||||
|
Setattr(n, k_wrapaction, cres);
|
||||||
|
Delete(mangled);
|
||||||
|
Delete(sname);
|
||||||
|
} else {
|
||||||
|
String *nname = SwigType_namestr(name);
|
||||||
call = Swig_wrapped_var_assign(type, nname, varcref);
|
call = Swig_wrapped_var_assign(type, nname, varcref);
|
||||||
cres = Swig_cresult(ty, k_result, call);
|
cres = Swig_cresult(ty, k_result, call);
|
||||||
Setattr(n, k_wrapaction, cres);
|
Setattr(n, k_wrapaction, cres);
|
||||||
Delete(cres);
|
Delete(nname);
|
||||||
Delete(call);
|
}
|
||||||
|
|
||||||
Setattr(n, k_type, ty);
|
Setattr(n, k_type, ty);
|
||||||
Delattr(n, k_parms);
|
Delattr(n, k_parms);
|
||||||
Delete(nname);
|
Delete(cres);
|
||||||
|
Delete(call);
|
||||||
Delete(ty);
|
Delete(ty);
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue