Proper handling of arrays finally in the works, no special typemaps needed.
Some corrections for use with -small. git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4420 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
cba4b57a64
commit
67ab95ab49
4 changed files with 25 additions and 42 deletions
|
|
@ -19,18 +19,4 @@ private:
|
||||||
int owned;
|
int owned;
|
||||||
};
|
};
|
||||||
|
|
||||||
%typemap(ocaml,out) SWIGTYPE [ANY] {
|
%apply SWIGTYPE [ANY] {SWIG_OCAML_ARRAY_WRAPPER};
|
||||||
$result = new SWIG_OCAML_ARRAY_WRAPPER($1);
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(ocaml,varout) SWIGTYPE [ANY] {
|
|
||||||
$result = new SWIG_OCAML_ARRAY_WRAPPER($1);
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(ocaml,in) SWIGTYPE [ANY] {
|
|
||||||
$1 = (SWIG_OCAML_ARRAY_WRAPPER<$ltype> *)$input;
|
|
||||||
}
|
|
||||||
|
|
||||||
%typemap(ocaml,varin) SWIGTYPE [ANY] {
|
|
||||||
$1 = (SWIG_OCAML_ARRAY_WRAPPER<$ltype> *)$input;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,10 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
#define SWIGEXT extern "C"
|
||||||
|
SWIGEXT {
|
||||||
|
#else
|
||||||
|
#define SWIGEXT
|
||||||
#endif
|
#endif
|
||||||
#define alloc caml_alloc
|
#define alloc caml_alloc
|
||||||
#include <caml/alloc.h>
|
#include <caml/alloc.h>
|
||||||
|
|
|
||||||
|
|
@ -160,12 +160,18 @@
|
||||||
%typemap(varin) C_NAME {
|
%typemap(varin) C_NAME {
|
||||||
$1 = MZ_TO_C($input);
|
$1 = MZ_TO_C($input);
|
||||||
}
|
}
|
||||||
|
%typemap(memberin) C_NAME {
|
||||||
|
$1 = MZ_TO_C($input);
|
||||||
|
}
|
||||||
%typemap(out) C_NAME {
|
%typemap(out) C_NAME {
|
||||||
$result = C_TO_MZ($1);
|
$result = C_TO_MZ($1);
|
||||||
}
|
}
|
||||||
%typemap(varout) C_NAME {
|
%typemap(varout) C_NAME {
|
||||||
$result = C_TO_MZ($1);
|
$result = C_TO_MZ($1);
|
||||||
}
|
}
|
||||||
|
%typemap(memberout) C_NAME {
|
||||||
|
$resunt = C_TO_MZ($1);
|
||||||
|
}
|
||||||
%typemap(in) C_NAME *INPUT (C_NAME temp) {
|
%typemap(in) C_NAME *INPUT (C_NAME temp) {
|
||||||
temp = (C_NAME) MZ_TO_C($input);
|
temp = (C_NAME) MZ_TO_C($input);
|
||||||
$1 = &temp;
|
$1 = &temp;
|
||||||
|
|
@ -185,8 +191,8 @@
|
||||||
}
|
}
|
||||||
%enddef
|
%enddef
|
||||||
|
|
||||||
SIMPLE_MAP(oc_bool, caml_val_bool, caml_long_val);
|
|
||||||
SIMPLE_MAP(bool, caml_val_bool, caml_long_val);
|
SIMPLE_MAP(bool, caml_val_bool, caml_long_val);
|
||||||
|
SIMPLE_MAP(oc_bool, caml_val_bool, caml_long_val);
|
||||||
SIMPLE_MAP(char, caml_val_char, caml_long_val);
|
SIMPLE_MAP(char, caml_val_char, caml_long_val);
|
||||||
SIMPLE_MAP(unsigned char, caml_val_uchar, caml_long_val);
|
SIMPLE_MAP(unsigned char, caml_val_uchar, caml_long_val);
|
||||||
SIMPLE_MAP(int, caml_val_int, caml_long_val);
|
SIMPLE_MAP(int, caml_val_int, caml_long_val);
|
||||||
|
|
|
||||||
|
|
@ -232,15 +232,12 @@ public:
|
||||||
Printf( f_mlibody,
|
Printf( f_mlibody,
|
||||||
"val int_to_enum : c_enum_type -> int -> c_obj\n" );
|
"val int_to_enum : c_enum_type -> int -> c_obj\n" );
|
||||||
Printf( f_wrappers,
|
Printf( f_wrappers,
|
||||||
"#ifdef __cplusplus\n"
|
"SWIGEXT void f_%s_init() {\n"
|
||||||
"extern \"C\"\n"
|
|
||||||
"#endif\n"
|
|
||||||
"void f_%s_init() {\n"
|
|
||||||
"%s"
|
"%s"
|
||||||
"}\n",
|
"}\n",
|
||||||
module, init_func_def );
|
module, init_func_def );
|
||||||
Printf( f_mlbody,
|
Printf( f_mlbody,
|
||||||
"external f_init : unit -> unit = \"f_%s_init\"\n"
|
"external f_init : unit -> unit = \"f_%s_init\" ;;\n"
|
||||||
"let _ = f_init ()\n",
|
"let _ = f_init ()\n",
|
||||||
module, module );
|
module, module );
|
||||||
Printf( f_enumtypes_type, "]\n" );
|
Printf( f_enumtypes_type, "]\n" );
|
||||||
|
|
@ -414,16 +411,13 @@ public:
|
||||||
|
|
||||||
// writing the function wrapper function
|
// writing the function wrapper function
|
||||||
Printv(f->def,
|
Printv(f->def,
|
||||||
"#ifdef __cplusplus\n"
|
"SWIGEXT value ", wname, " (", NIL);
|
||||||
"extern \"C\"\n"
|
|
||||||
"#endif\n"
|
|
||||||
"value ", wname, " (", NIL);
|
|
||||||
Printv(f->def, "value args", NIL);
|
Printv(f->def, "value args", NIL);
|
||||||
Printv(f->def, ")\n{", NIL);
|
Printv(f->def, ")\n{", NIL);
|
||||||
|
|
||||||
/* Define the scheme name in C. This define is used by several
|
/* Define the scheme name in C. This define is used by several
|
||||||
macros. */
|
macros. */
|
||||||
Printv(f->def, "#define FUNC_NAME \"", mangled_name, "\"", NIL);
|
//Printv(f->def, "#define FUNC_NAME \"", mangled_name, "\"", NIL);
|
||||||
|
|
||||||
// adds local variables
|
// adds local variables
|
||||||
Wrapper_add_local(f, "args", "CAMLparam1(args)");
|
Wrapper_add_local(f, "args", "CAMLparam1(args)");
|
||||||
|
|
@ -516,7 +510,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);
|
Replaceall(tm,"$ntype",normalizeTemplatedClassName(Getattr(p,"type")));
|
||||||
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;
|
||||||
|
|
@ -607,10 +601,7 @@ public:
|
||||||
Wrapper_add_local(df, "argv", "value *argv");
|
Wrapper_add_local(df, "argv", "value *argv");
|
||||||
|
|
||||||
Printv(df->def,
|
Printv(df->def,
|
||||||
"#ifdef __cplusplus\n"
|
"SWIGEXT value ",dname,"(value args) {\n"
|
||||||
"extern \"C\"\n"
|
|
||||||
"#endif\n"
|
|
||||||
"value ",dname,"(value args) {\n"
|
|
||||||
" CAMLparam1(args);\n"
|
" CAMLparam1(args);\n"
|
||||||
" int i;\n"
|
" int i;\n"
|
||||||
" int argc = caml_list_length(args);\n",NIL);
|
" int argc = caml_list_length(args);\n",NIL);
|
||||||
|
|
@ -625,7 +616,7 @@ public:
|
||||||
Wrapper_print(df,f_wrappers);
|
Wrapper_print(df,f_wrappers);
|
||||||
|
|
||||||
Printf(f_mlbody,
|
Printf(f_mlbody,
|
||||||
"external %s_f : c_obj list -> c_obj list = \"%s\"\n"
|
"external %s_f : c_obj list -> c_obj list = \"%s\" ;;\n"
|
||||||
"let %s = fnhelper %s %s_f\n",
|
"let %s = fnhelper %s %s_f\n",
|
||||||
mangled_name, dname, mangled_name,
|
mangled_name, dname, mangled_name,
|
||||||
newobj ? "true" : "false",
|
newobj ? "true" : "false",
|
||||||
|
|
@ -642,7 +633,7 @@ public:
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Printf(f_mlbody,
|
Printf(f_mlbody,
|
||||||
"external %s_f : c_obj list -> c_obj list = \"%s\"\n"
|
"external %s_f : c_obj list -> c_obj list = \"%s\" ;;\n"
|
||||||
"let %s = fnhelper %s %s_f\n",
|
"let %s = fnhelper %s %s_f\n",
|
||||||
mangled_name, wname, mangled_name, newobj ? "true" : "false",
|
mangled_name, wname, mangled_name, newobj ? "true" : "false",
|
||||||
mangled_name );
|
mangled_name );
|
||||||
|
|
@ -703,11 +694,8 @@ public:
|
||||||
if ((SwigType_type(t) != T_USER) || (is_a_pointer(t))) {
|
if ((SwigType_type(t) != T_USER) || (is_a_pointer(t))) {
|
||||||
|
|
||||||
Printf (f->def,
|
Printf (f->def,
|
||||||
"#ifdef __cplusplus\n"
|
"SWIGEXT value %s(value args) {\n", var_name);
|
||||||
"extern \"C\"\n"
|
// Printv(f->def, "#define FUNC_NAME \"", proc_name, "\"", NIL);
|
||||||
"#endif\n"
|
|
||||||
"value %s(value args) {\n", var_name);
|
|
||||||
Printv(f->def, "#define FUNC_NAME \"", proc_name, "\"", NIL);
|
|
||||||
|
|
||||||
Wrapper_add_local (f, "swig_result", "value swig_result");
|
Wrapper_add_local (f, "swig_result", "value swig_result");
|
||||||
|
|
||||||
|
|
@ -747,7 +735,7 @@ public:
|
||||||
|
|
||||||
if( Getattr( n, "feature:immutable" ) ) {
|
if( Getattr( n, "feature:immutable" ) ) {
|
||||||
Printf( f_mlbody,
|
Printf( f_mlbody,
|
||||||
"external __%s : c_obj -> c_obj = \"%s\"\n"
|
"external __%s : c_obj -> c_obj = \"%s\" ;;\n"
|
||||||
"let _%s = __%s C_void\n",
|
"let _%s = __%s C_void\n",
|
||||||
mname, var_name, mname, mname );
|
mname, var_name, mname, mname );
|
||||||
Printf( f_mlibody, "val _%s : c_obj\n", iname );
|
Printf( f_mlibody, "val _%s : c_obj\n", iname );
|
||||||
|
|
@ -760,9 +748,9 @@ public:
|
||||||
mname, mname );
|
mname, mname );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Printf( f_mlbody, "external _%s : c_obj -> c_obj = \"%s\"\n",
|
Printf( f_mlbody, "external _%s : c_obj -> c_obj = \"%s\" ;;\n",
|
||||||
mname, var_name );
|
mname, var_name );
|
||||||
Printf( f_mlibody, "external _%s : c_obj -> c_obj = \"%s\"\n",
|
Printf( f_mlibody, "external _%s : c_obj -> c_obj = \"%s\" ;;\n",
|
||||||
mname, var_name );
|
mname, var_name );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue