Normalize class names that have template components. This allows the
simple scheme I use for templating to work (at least in the test cases so far). I probably need to come up with a better scheme for associating the class closure creator with the typemaps. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4323 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a8ef2143b0
commit
9c3c115a11
1 changed files with 20 additions and 2 deletions
|
|
@ -74,6 +74,8 @@ public:
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
prefix = 0;
|
||||||
|
|
||||||
SWIG_library_directory(ocaml_path);
|
SWIG_library_directory(ocaml_path);
|
||||||
|
|
||||||
// Look for certain command line options
|
// Look for certain command line options
|
||||||
|
|
@ -286,6 +288,7 @@ public:
|
||||||
virtual int functionWrapper(Node *n) {
|
virtual int functionWrapper(Node *n) {
|
||||||
char *iname = GetChar(n,"sym:name");
|
char *iname = GetChar(n,"sym:name");
|
||||||
SwigType *d = Getattr(n,"type");
|
SwigType *d = Getattr(n,"type");
|
||||||
|
String *return_type_normalized = normalizeTemplatedClassName(d);
|
||||||
ParmList *l = Getattr(n,"parms");
|
ParmList *l = Getattr(n,"parms");
|
||||||
Parm *p;
|
Parm *p;
|
||||||
|
|
||||||
|
|
@ -474,6 +477,7 @@ public:
|
||||||
Replaceall(tm,"$target",Getattr(p,"lname")); /* Deprecated */
|
Replaceall(tm,"$target",Getattr(p,"lname")); /* Deprecated */
|
||||||
Replaceall(tm,"$arg",Getattr(p,"emit:input"));
|
Replaceall(tm,"$arg",Getattr(p,"emit:input"));
|
||||||
Replaceall(tm,"$input",Getattr(p,"emit:input"));
|
Replaceall(tm,"$input",Getattr(p,"emit:input"));
|
||||||
|
Replaceall(tm,"$ntype",return_type_normalized);
|
||||||
Printv(outarg,tm,"\n",NIL);
|
Printv(outarg,tm,"\n",NIL);
|
||||||
p = Getattr(p,"tmap:argout:next");
|
p = Getattr(p,"tmap:argout:next");
|
||||||
argout_set = 1;
|
argout_set = 1;
|
||||||
|
|
@ -505,6 +509,7 @@ public:
|
||||||
Replaceall(tm,"$source","result");
|
Replaceall(tm,"$source","result");
|
||||||
Replaceall(tm,"$target","rv");
|
Replaceall(tm,"$target","rv");
|
||||||
Replaceall(tm,"$result","rv");
|
Replaceall(tm,"$result","rv");
|
||||||
|
Replaceall(tm,"$ntype",return_type_normalized);
|
||||||
Printv(f->code, tm, "\n",NIL);
|
Printv(f->code, tm, "\n",NIL);
|
||||||
} else {
|
} else {
|
||||||
throw_unhandled_ocaml_type_error (d);
|
throw_unhandled_ocaml_type_error (d);
|
||||||
|
|
@ -995,16 +1000,29 @@ public:
|
||||||
" end\n"
|
" end\n"
|
||||||
" | e -> raise e))\n",
|
" | e -> raise e))\n",
|
||||||
name );
|
name );
|
||||||
|
|
||||||
|
String *name_normalized = normalizeTemplatedClassName(name);
|
||||||
|
|
||||||
Printf( f_class_ctors,
|
Printf( f_class_ctors,
|
||||||
"let _ = Callback.register \"create_%s_from_ptr\" "
|
"let _ = Callback.register \"create_%s_from_ptr\" "
|
||||||
"create_%s_from_ptr\n",
|
"create_%s_from_ptr\n",
|
||||||
classname, classname );
|
name_normalized, classname );
|
||||||
|
|
||||||
Setattr(n,"ocaml:ctor",classname);
|
Setattr(n,"ocaml:ctor",classname);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String *normalizeTemplatedClassName( String *name ) {
|
||||||
|
String *name_normalized = Copy(name);
|
||||||
|
|
||||||
|
if( is_a_pointer(name_normalized) )
|
||||||
|
SwigType_del_pointer( name_normalized );
|
||||||
|
|
||||||
|
Replaceall(name_normalized,"(","");
|
||||||
|
Replaceall(name_normalized,")","");
|
||||||
|
return name_normalized;
|
||||||
|
}
|
||||||
|
|
||||||
String *mangleNameForCaml( String *s ) {
|
String *mangleNameForCaml( String *s ) {
|
||||||
String *out = Copy(s);
|
String *out = Copy(s);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue