Revert support for %extend and memberin typemaps added in swig-1.3.39. The memberin typemaps are ignored again for member variables within a %extend block. Documentation inconsistency reported by Torsten Landschoff.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11762 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b9817010fb
commit
2bd190dbf1
9 changed files with 85 additions and 38 deletions
|
|
@ -1,6 +1,11 @@
|
|||
Version 1.3.41 (in progress)
|
||||
============================
|
||||
|
||||
2009-12-01: wsfulton
|
||||
Revert support for %extend and memberin typemaps added in swig-1.3.39. The
|
||||
memberin typemaps are ignored again for member variables within a %extend block.
|
||||
Documentation inconsistency reported by Torsten Landschoff.
|
||||
|
||||
2009-11-29: wsfulton
|
||||
[Java, C#] Fix generated quoting when using %javaconst(1)/%csconst(1) for
|
||||
static const char member variables.
|
||||
|
|
|
|||
|
|
@ -2493,7 +2493,7 @@ instead of a method. To do this, you might write some code like this:
|
|||
// Now supply the implementation of the Vector_magnitude_get function
|
||||
%{
|
||||
const double Vector_magnitude_get(Vector *v) {
|
||||
return (const double) return sqrt(v->x*v->x+v->y*v->y+v->z*v->z);
|
||||
return (const double) sqrt(v->x*v->x+v->y*v->y+v->z*v->z);
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -2512,10 +2512,10 @@ For example, consider this interface:
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
struct Person {
|
||||
typedef struct {
|
||||
char name[50];
|
||||
...
|
||||
}
|
||||
} Person;
|
||||
</pre>
|
||||
</div>
|
||||
|
||||
|
|
@ -2527,12 +2527,12 @@ as follows to change this:
|
|||
|
||||
<div class="code">
|
||||
<pre>
|
||||
struct Person {
|
||||
typedef struct {
|
||||
%extend {
|
||||
char *name;
|
||||
}
|
||||
...
|
||||
}
|
||||
} Person;
|
||||
|
||||
// Specific implementation of set/get functions
|
||||
%{
|
||||
|
|
|
|||
|
|
@ -458,6 +458,7 @@ C_TEST_CASES += \
|
|||
li_cpointer \
|
||||
li_math \
|
||||
long_long \
|
||||
memberin_extend_c \
|
||||
name \
|
||||
nested \
|
||||
nested_structs \
|
||||
|
|
|
|||
|
|
@ -12,8 +12,19 @@ struct ExtendMe {
|
|||
%{
|
||||
#include <map>
|
||||
std::map<ExtendMe*, char *> ExtendMeStringMap;
|
||||
#define ExtendMe_thing_set(self_, val_) ExtendMeStringMap[self_]
|
||||
#define ExtendMe_thing_get(self_) ExtendMeStringMap[self_]
|
||||
void ExtendMe_thing_set(ExtendMe *self, const char *val) {
|
||||
char *old_val = ExtendMeStringMap[self];
|
||||
delete [] old_val;
|
||||
if (val) {
|
||||
ExtendMeStringMap[self] = new char[strlen(val)+1];
|
||||
strcpy(ExtendMeStringMap[self], val);
|
||||
} else {
|
||||
ExtendMeStringMap[self] = 0;
|
||||
}
|
||||
}
|
||||
char * ExtendMe_thing_get(ExtendMe *self) {
|
||||
return ExtendMeStringMap[self];
|
||||
}
|
||||
%}
|
||||
|
||||
%extend ExtendMe {
|
||||
|
|
|
|||
25
Examples/test-suite/memberin_extend_c.i
Normal file
25
Examples/test-suite/memberin_extend_c.i
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
%module memberin_extend_c
|
||||
|
||||
/* Example from the Manual, section 5.5.6: "Adding member functions to C structures" */
|
||||
|
||||
%{
|
||||
typedef struct {
|
||||
char name[50];
|
||||
} Person;
|
||||
%}
|
||||
|
||||
typedef struct {
|
||||
%extend {
|
||||
char *name;
|
||||
}
|
||||
} Person;
|
||||
|
||||
/* Specific implementation of set/get functions */
|
||||
%{
|
||||
char *Person_name_get(Person *p) {
|
||||
return p->name;
|
||||
}
|
||||
void Person_name_set(Person *p, char *val) {
|
||||
strncpy(p->name,val,50);
|
||||
}
|
||||
%}
|
||||
6
Examples/test-suite/python/memberin_extend_c_runme.py
Normal file
6
Examples/test-suite/python/memberin_extend_c_runme.py
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
import memberin_extend_c
|
||||
|
||||
t = memberin_extend_c.Person()
|
||||
t.name = "some name"
|
||||
if t.name != "some name":
|
||||
raise RuntimeError("some name wrong")
|
||||
|
|
@ -1407,39 +1407,36 @@ int Language::membervariableHandler(Node *n) {
|
|||
target = NewStringf("%s->%s", pname, name);
|
||||
Delete(pname);
|
||||
}
|
||||
} else {
|
||||
target = NewStringf("$extendgetcall"); // member variable access expanded later
|
||||
tm = Swig_typemap_lookup("memberin", n, target, 0);
|
||||
}
|
||||
tm = Swig_typemap_lookup("memberin", n, target, 0);
|
||||
int flags = Extend | SmartPointer | use_naturalvar_mode(n);
|
||||
if (is_non_virtual_protected_access(n))
|
||||
flags = flags | CWRAP_ALL_PROTECTED_ACCESS;
|
||||
|
||||
String *call = 0;
|
||||
Swig_MembersetToFunction(n, ClassType, flags, &call);
|
||||
Swig_MembersetToFunction(n, ClassType, flags);
|
||||
Setattr(n, "memberset", "1");
|
||||
if (!Extend) {
|
||||
/* Check for a member in typemap here */
|
||||
|
||||
if (!tm) {
|
||||
if (SwigType_isarray(type)) {
|
||||
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0));
|
||||
make_set_wrapper = 0;
|
||||
if (!tm) {
|
||||
if (SwigType_isarray(type)) {
|
||||
Swig_warning(WARN_TYPEMAP_VARIN_UNDEF, input_file, line_number, "Unable to set variable of type %s.\n", SwigType_str(type, 0));
|
||||
make_set_wrapper = 0;
|
||||
}
|
||||
} else {
|
||||
String *pname0 = Swig_cparm_name(0, 0);
|
||||
String *pname1 = Swig_cparm_name(0, 1);
|
||||
Replace(tm, "$source", pname1, DOH_REPLACE_ANY);
|
||||
Replace(tm, "$target", target, DOH_REPLACE_ANY);
|
||||
Replace(tm, "$input", pname1, DOH_REPLACE_ANY);
|
||||
Replace(tm, "$self", pname0, DOH_REPLACE_ANY);
|
||||
Setattr(n, "wrap:action", tm);
|
||||
Delete(tm);
|
||||
Delete(pname0);
|
||||
Delete(pname1);
|
||||
}
|
||||
} else {
|
||||
String *pname0 = Swig_cparm_name(0, 0);
|
||||
String *pname1 = Swig_cparm_name(0, 1);
|
||||
Replace(tm, "$source", pname1, DOH_REPLACE_ANY);
|
||||
Replace(tm, "$target", target, DOH_REPLACE_ANY);
|
||||
Replace(tm, "$input", pname1, DOH_REPLACE_ANY);
|
||||
Replace(tm, "$self", pname0, DOH_REPLACE_ANY);
|
||||
Replace(tm, "$extendgetcall", call, DOH_REPLACE_ANY);
|
||||
Setattr(n, "wrap:action", tm);
|
||||
Delete(tm);
|
||||
Delete(pname0);
|
||||
Delete(pname1);
|
||||
Delete(target);
|
||||
}
|
||||
Delete(call);
|
||||
Delete(target);
|
||||
|
||||
if (make_set_wrapper) {
|
||||
Setattr(n, "sym:name", mrename_set);
|
||||
functionWrapper(n);
|
||||
|
|
|
|||
|
|
@ -1207,7 +1207,7 @@ int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags)
|
|||
* This function creates a C wrapper for setting a structure member.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_MembersetToFunction(Node *n, String *classname, int flags, String **call) {
|
||||
int Swig_MembersetToFunction(Node *n, String *classname, int flags) {
|
||||
String *name;
|
||||
ParmList *parms;
|
||||
Parm *p;
|
||||
|
|
@ -1255,21 +1255,23 @@ int Swig_MembersetToFunction(Node *n, String *classname, int flags, String **cal
|
|||
Delete(p);
|
||||
|
||||
if (flags & CWRAP_EXTEND) {
|
||||
String *call;
|
||||
String *cres;
|
||||
String *code = Getattr(n, "code");
|
||||
if (code) {
|
||||
/* I don't think this ever gets run - WSF */
|
||||
Swig_add_extension_code(n, mangled, parms, void_type, code, cparse_cplusplus, "self");
|
||||
}
|
||||
*call = Swig_cfunction_call(mangled, parms);
|
||||
cres = NewStringf("%s;", *call);
|
||||
call = Swig_cfunction_call(mangled, parms);
|
||||
cres = NewStringf("%s;", call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(call);
|
||||
Delete(cres);
|
||||
} else {
|
||||
String *cres;
|
||||
*call = Swig_cmemberset_call(name, type, self, varcref);
|
||||
cres = NewStringf("%s;", *call);
|
||||
String *call = Swig_cmemberset_call(name, type, self, varcref);
|
||||
String *cres = NewStringf("%s;", call);
|
||||
Setattr(n, "wrap:action", cres);
|
||||
Delete(call);
|
||||
Delete(cres);
|
||||
}
|
||||
Setattr(n, "type", void_type);
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern int Swig_MethodToFunction(Node *n, String *classname, int flags, SwigType *director_type, int is_director);
|
||||
extern int Swig_ConstructorToFunction(Node *n, String *classname, String *none_comparison, String *director_ctor, int cplus, int flags);
|
||||
extern int Swig_DestructorToFunction(Node *n, String *classname, int cplus, int flags);
|
||||
extern int Swig_MembersetToFunction(Node *n, String *classname, int flags, String **call);
|
||||
extern int Swig_MembersetToFunction(Node *n, String *classname, int flags);
|
||||
extern int Swig_MembergetToFunction(Node *n, String *classname, int flags);
|
||||
extern int Swig_VargetToFunction(Node *n, int flags);
|
||||
extern int Swig_VarsetToFunction(Node *n, int flags);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue