Java directors implementation contributed by Scott Michel.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5076 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a2734b3f71
commit
a562a53bcb
4 changed files with 75 additions and 22 deletions
|
|
@ -176,6 +176,10 @@
|
||||||
#define WARN_JAVA_TYPEMAP_PTRCONSTMOD_UNDEF 816
|
#define WARN_JAVA_TYPEMAP_PTRCONSTMOD_UNDEF 816
|
||||||
#define WARN_JAVA_TYPEMAP_JAVAOUT_UNDEF 817
|
#define WARN_JAVA_TYPEMAP_JAVAOUT_UNDEF 817
|
||||||
#define WARN_JAVA_TYPEMAP_JAVAIN_UNDEF 818
|
#define WARN_JAVA_TYPEMAP_JAVAIN_UNDEF 818
|
||||||
|
#define WARN_JAVA_TYPEMAP_JNIDESC_UNDEF 819
|
||||||
|
#define WARN_JAVA_TYPEMAP_DIRECTORIN_UNDEF 820
|
||||||
|
#define WARN_JAVA_TYPEMAP_DIRECTOROUT_UNDEF 821
|
||||||
|
#define WARN_JAVA_TYPEMAP_NODIRECTOR_CODE 822
|
||||||
|
|
||||||
/* please leave 810-829 free for Java */
|
/* please leave 810-829 free for Java */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ Swig_cparm_name(Parm *p, int i) {
|
||||||
if (p) {
|
if (p) {
|
||||||
Setattr(p,"lname",name);
|
Setattr(p,"lname",name);
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -341,7 +342,7 @@ Swig_cconstructor_call(String_or_char *name) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *
|
String *
|
||||||
Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int skip_self, int disown) {
|
Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int skip_self) {
|
||||||
String *func;
|
String *func;
|
||||||
String *nname;
|
String *nname;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
@ -360,17 +361,20 @@ Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int skip_se
|
||||||
pt = Getattr(p,"type");
|
pt = Getattr(p,"type");
|
||||||
if ((SwigType_type(pt) != T_VOID)) {
|
if ((SwigType_type(pt) != T_VOID)) {
|
||||||
if (comma) Printf(func,",");
|
if (comma) Printf(func,",");
|
||||||
pname = Swig_cparm_name(p,i);
|
if (!Getattr(p, "arg:byname")) {
|
||||||
|
pname = Swig_cparm_name(p,i);
|
||||||
|
i++;
|
||||||
|
} else {
|
||||||
|
if ((pname = Getattr(p, "value")))
|
||||||
|
pname = Copy(pname);
|
||||||
|
else
|
||||||
|
pname = Copy(Getattr(p, "name"));
|
||||||
|
}
|
||||||
Printf(func,"%s", SwigType_rcaststr(pt, pname));
|
Printf(func,"%s", SwigType_rcaststr(pt, pname));
|
||||||
comma = 1;
|
comma = 1;
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
}
|
}
|
||||||
if (disown >= 0) {
|
|
||||||
if (comma) Printf(func, ",");
|
|
||||||
Printf(func, "%d", disown);
|
|
||||||
}
|
|
||||||
Printf(func,")");
|
Printf(func,")");
|
||||||
Delete(nname);
|
Delete(nname);
|
||||||
return func;
|
return func;
|
||||||
|
|
@ -378,17 +382,17 @@ Swig_cppconstructor_base_call(String_or_char *name, ParmList *parms, int skip_se
|
||||||
|
|
||||||
String *
|
String *
|
||||||
Swig_cppconstructor_call(String_or_char *name, ParmList *parms) {
|
Swig_cppconstructor_call(String_or_char *name, ParmList *parms) {
|
||||||
return Swig_cppconstructor_base_call(name, parms, 0, -1);
|
return Swig_cppconstructor_base_call(name, parms, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
String *
|
String *
|
||||||
Swig_cppconstructor_nodirector_call(String_or_char *name, ParmList *parms) {
|
Swig_cppconstructor_nodirector_call(String_or_char *name, ParmList *parms) {
|
||||||
return Swig_cppconstructor_base_call(name, parms, 1, -1);
|
return Swig_cppconstructor_base_call(name, parms, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
String *
|
String *
|
||||||
Swig_cppconstructor_director_call(String_or_char *name, ParmList *parms) {
|
Swig_cppconstructor_director_call(String_or_char *name, ParmList *parms) {
|
||||||
return Swig_cppconstructor_base_call(name, parms, 0, 0);
|
return Swig_cppconstructor_base_call(name, parms, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -----------------------------------------------------------------------------
|
/* -----------------------------------------------------------------------------
|
||||||
|
|
@ -595,9 +599,13 @@ Node *
|
||||||
Swig_directormap(Node *module, String *type) {
|
Swig_directormap(Node *module, String *type) {
|
||||||
int is_void = !Cmp(type, "void");
|
int is_void = !Cmp(type, "void");
|
||||||
if (!is_void && module) {
|
if (!is_void && module) {
|
||||||
|
/* ?? follow the inheritance hierarchy? */
|
||||||
|
|
||||||
String* base = SwigType_base(type);
|
String* base = SwigType_base(type);
|
||||||
|
|
||||||
Node *directormap = Getattr(module, "wrap:directormap");
|
Node *directormap = Getattr(module, "wrap:directormap");
|
||||||
if (directormap) return Getattr(directormap, base);
|
if (directormap)
|
||||||
|
return Getattr(directormap, base);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -611,9 +619,11 @@ Swig_directormap(Node *module, String *type) {
|
||||||
|
|
||||||
int
|
int
|
||||||
Swig_ConstructorToFunction(Node *n, String *classname,
|
Swig_ConstructorToFunction(Node *n, String *classname,
|
||||||
String *none_comparison, int cplus, int flags)
|
String *none_comparison, String *director_ctor, int cplus, int flags)
|
||||||
{
|
{
|
||||||
ParmList *parms;
|
ParmList *parms;
|
||||||
|
Parm *p;
|
||||||
|
ParmList *directorparms;
|
||||||
SwigType *type;
|
SwigType *type;
|
||||||
String *membername;
|
String *membername;
|
||||||
String *mangled;
|
String *mangled;
|
||||||
|
|
@ -627,6 +637,32 @@ Swig_ConstructorToFunction(Node *n, String *classname,
|
||||||
mangled = Swig_name_mangle(membername);
|
mangled = Swig_name_mangle(membername);
|
||||||
|
|
||||||
parms = CopyParmList(nonvoid_parms(Getattr(n,"parms")));
|
parms = CopyParmList(nonvoid_parms(Getattr(n,"parms")));
|
||||||
|
if ((p = Getattr(n,"director:prefix_args")) != NULL) {
|
||||||
|
Parm *p2, *p3;
|
||||||
|
|
||||||
|
directorparms = CopyParmList(p);
|
||||||
|
for (p = directorparms; nextSibling(p); p = nextSibling(p));
|
||||||
|
for (p2 = parms; p2; p2 = nextSibling(p2)) {
|
||||||
|
p3 = CopyParm(p2);
|
||||||
|
set_nextSibling(p, p3);
|
||||||
|
p = p3;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
directorparms = parms;
|
||||||
|
|
||||||
|
if ((p = Getattr(n,"director:postfix_args")) != NULL) {
|
||||||
|
Parm *p2, *p3, *p4;
|
||||||
|
|
||||||
|
if (directorparms == parms) /* no prefix args from above. */
|
||||||
|
directorparms = CopyParmList(parms);
|
||||||
|
|
||||||
|
for (p2 = directorparms; nextSibling(p2); p2 = nextSibling(p2));
|
||||||
|
for (p3 = p; p3; p3 = nextSibling(p)) {
|
||||||
|
p4 = CopyParm(p3);
|
||||||
|
set_nextSibling(p2, p4);
|
||||||
|
p2 = p4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type = NewString(classname);
|
type = NewString(classname);
|
||||||
SwigType_add_pointer(type);
|
SwigType_add_pointer(type);
|
||||||
|
|
@ -661,8 +697,9 @@ Swig_ConstructorToFunction(Node *n, String *classname,
|
||||||
|
|
||||||
Replaceall( tmp_none_comparison, "$arg", "arg1" );
|
Replaceall( tmp_none_comparison, "$arg", "arg1" );
|
||||||
|
|
||||||
director_call = Swig_cppconstructor_director_call(directorname, parms);
|
director_call = Swig_cppconstructor_director_call(directorname, directorparms);
|
||||||
nodirector_call = Swig_cppconstructor_nodirector_call(classname, parms);
|
nodirector_call = Swig_cppconstructor_nodirector_call(classname, parms);
|
||||||
|
|
||||||
if (abstract) {
|
if (abstract) {
|
||||||
/* whether or not the abstract class has been subclassed in python,
|
/* whether or not the abstract class has been subclassed in python,
|
||||||
* create a director instance (there's no way to create a normal
|
* create a director instance (there's no way to create a normal
|
||||||
|
|
@ -672,15 +709,19 @@ Swig_ConstructorToFunction(Node *n, String *classname,
|
||||||
*/
|
*/
|
||||||
Printv(action, Swig_cresult(type, "result", director_call), NULL);
|
Printv(action, Swig_cresult(type, "result", director_call), NULL);
|
||||||
} else {
|
} else {
|
||||||
/* if the proxy class has been subclassed, create a director instance.
|
/* (scottm): The code for creating a new director is now a string
|
||||||
* otherwise, just create a normal instance.
|
template that gets passed in via the director_ctor argument.
|
||||||
*/
|
|
||||||
Printv(action,
|
$comparison : an 'if' comparison from none_comparison
|
||||||
"if (",tmp_none_comparison,") {/* subclassed */\n",
|
$director_new: Call new for director class
|
||||||
Swig_cresult(type, "result", director_call),
|
$nondirector_new: Call new for non-director class
|
||||||
"} else {\n",
|
*/
|
||||||
Swig_cresult(type, "result", nodirector_call),
|
Printv(action, director_ctor, NIL);
|
||||||
"}\n", NULL);
|
Replaceall( action, "$comparison", tmp_none_comparison);
|
||||||
|
Replaceall( action, "$director_new",
|
||||||
|
Swig_cresult(type, "result", director_call) );
|
||||||
|
Replaceall( action, "$nondirector_new",
|
||||||
|
Swig_cresult(type, "result", nodirector_call) );
|
||||||
}
|
}
|
||||||
Setattr(n, "wrap:action", action);
|
Setattr(n, "wrap:action", action);
|
||||||
Delete(tmp_none_comparison);
|
Delete(tmp_none_comparison);
|
||||||
|
|
@ -696,6 +737,8 @@ Swig_ConstructorToFunction(Node *n, String *classname,
|
||||||
Setattr(n,"type",type);
|
Setattr(n,"type",type);
|
||||||
Setattr(n,"parms", parms);
|
Setattr(n,"parms", parms);
|
||||||
Delete(type);
|
Delete(type);
|
||||||
|
if (directorparms != parms)
|
||||||
|
Delete(directorparms);
|
||||||
Delete(parms);
|
Delete(parms);
|
||||||
Delete(mangled);
|
Delete(mangled);
|
||||||
Delete(membername);
|
Delete(membername);
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ Parm *CopyParm(Parm *p) {
|
||||||
String *value;
|
String *value;
|
||||||
String *ignore;
|
String *ignore;
|
||||||
String *alttype;
|
String *alttype;
|
||||||
|
String *byname;
|
||||||
|
|
||||||
Parm *np = NewHash();
|
Parm *np = NewHash();
|
||||||
t = Getattr(p,"type");
|
t = Getattr(p,"type");
|
||||||
|
|
@ -55,6 +56,7 @@ Parm *CopyParm(Parm *p) {
|
||||||
value = Getattr(p,"value");
|
value = Getattr(p,"value");
|
||||||
ignore = Getattr(p,"ignore");
|
ignore = Getattr(p,"ignore");
|
||||||
alttype = Getattr(p,"alttype");
|
alttype = Getattr(p,"alttype");
|
||||||
|
byname = Getattr(p, "arg:byname");
|
||||||
|
|
||||||
if (t)
|
if (t)
|
||||||
Setattr(np,"type",Copy(t));
|
Setattr(np,"type",Copy(t));
|
||||||
|
|
@ -68,6 +70,8 @@ Parm *CopyParm(Parm *p) {
|
||||||
Setattr(np,"ignore", Copy(ignore));
|
Setattr(np,"ignore", Copy(ignore));
|
||||||
if (alttype)
|
if (alttype)
|
||||||
Setattr(np,"alttype", Copy(alttype));
|
Setattr(np,"alttype", Copy(alttype));
|
||||||
|
if (byname)
|
||||||
|
Setattr(np, "arg:byname", Copy(byname));
|
||||||
|
|
||||||
Setfile(np,Getfile(p));
|
Setfile(np,Getfile(p));
|
||||||
Setline(np,Getline(p));
|
Setline(np,Getline(p));
|
||||||
|
|
|
||||||
|
|
@ -201,6 +201,7 @@ extern SwigType *SwigType_pop_arrays(SwigType *t);
|
||||||
extern void SwigType_add_reference(SwigType *t);
|
extern void SwigType_add_reference(SwigType *t);
|
||||||
extern void SwigType_del_reference(SwigType *t);
|
extern void SwigType_del_reference(SwigType *t);
|
||||||
extern void SwigType_add_qualifier(SwigType *t, String_or_char *qual);
|
extern void SwigType_add_qualifier(SwigType *t, String_or_char *qual);
|
||||||
|
extern void SwigType_del_qualifier(SwigType *t);
|
||||||
extern void SwigType_add_function(SwigType *t, ParmList *parms);
|
extern void SwigType_add_function(SwigType *t, ParmList *parms);
|
||||||
extern void SwigType_add_template(SwigType *t, ParmList *parms);
|
extern void SwigType_add_template(SwigType *t, ParmList *parms);
|
||||||
extern SwigType *SwigType_pop_function(SwigType *t);
|
extern SwigType *SwigType_pop_function(SwigType *t);
|
||||||
|
|
@ -442,6 +443,7 @@ extern String *Swig_cmemberget_call(String_or_char *name, SwigType *t, String
|
||||||
extern int Swig_MethodToFunction(Node *n, String *classname, int flags);
|
extern int Swig_MethodToFunction(Node *n, String *classname, int flags);
|
||||||
extern int Swig_ConstructorToFunction(Node *n, String *classname,
|
extern int Swig_ConstructorToFunction(Node *n, String *classname,
|
||||||
String *none_comparison,
|
String *none_comparison,
|
||||||
|
String *director_ctor,
|
||||||
int cplus, int flags);
|
int cplus, int flags);
|
||||||
extern int Swig_DestructorToFunction(Node *n, String *classname, 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);
|
extern int Swig_MembersetToFunction(Node *n, String *classname, int flags);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue