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:
Art Yerkes 2003-03-01 07:53:24 +00:00
commit 67ab95ab49
4 changed files with 25 additions and 42 deletions

View file

@ -19,18 +19,4 @@ private:
int owned;
};
%typemap(ocaml,out) SWIGTYPE [ANY] {
$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;
}
%apply SWIGTYPE [ANY] {SWIG_OCAML_ARRAY_WRAPPER};

View file

@ -11,7 +11,10 @@
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#define SWIGEXT extern "C"
SWIGEXT {
#else
#define SWIGEXT
#endif
#define alloc caml_alloc
#include <caml/alloc.h>

View file

@ -160,12 +160,18 @@
%typemap(varin) C_NAME {
$1 = MZ_TO_C($input);
}
%typemap(memberin) C_NAME {
$1 = MZ_TO_C($input);
}
%typemap(out) C_NAME {
$result = C_TO_MZ($1);
}
%typemap(varout) C_NAME {
$result = C_TO_MZ($1);
}
%typemap(memberout) C_NAME {
$resunt = C_TO_MZ($1);
}
%typemap(in) C_NAME *INPUT (C_NAME temp) {
temp = (C_NAME) MZ_TO_C($input);
$1 = &temp;
@ -185,8 +191,8 @@
}
%enddef
SIMPLE_MAP(oc_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(unsigned char, caml_val_uchar, caml_long_val);
SIMPLE_MAP(int, caml_val_int, caml_long_val);

View file

@ -232,15 +232,12 @@ public:
Printf( f_mlibody,
"val int_to_enum : c_enum_type -> int -> c_obj\n" );
Printf( f_wrappers,
"#ifdef __cplusplus\n"
"extern \"C\"\n"
"#endif\n"
"void f_%s_init() {\n"
"SWIGEXT void f_%s_init() {\n"
"%s"
"}\n",
module, init_func_def );
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",
module, module );
Printf( f_enumtypes_type, "]\n" );
@ -414,16 +411,13 @@ public:
// writing the function wrapper function
Printv(f->def,
"#ifdef __cplusplus\n"
"extern \"C\"\n"
"#endif\n"
"value ", wname, " (", NIL);
"SWIGEXT value ", wname, " (", NIL);
Printv(f->def, "value args", NIL);
Printv(f->def, ")\n{", NIL);
/* Define the scheme name in C. This define is used by several
macros. */
Printv(f->def, "#define FUNC_NAME \"", mangled_name, "\"", NIL);
//Printv(f->def, "#define FUNC_NAME \"", mangled_name, "\"", NIL);
// adds local variables
Wrapper_add_local(f, "args", "CAMLparam1(args)");
@ -516,7 +510,7 @@ public:
Replaceall(tm,"$target",Getattr(p,"lname")); /* Deprecated */
Replaceall(tm,"$arg",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);
p = Getattr(p,"tmap:argout:next");
argout_set = 1;
@ -607,10 +601,7 @@ public:
Wrapper_add_local(df, "argv", "value *argv");
Printv(df->def,
"#ifdef __cplusplus\n"
"extern \"C\"\n"
"#endif\n"
"value ",dname,"(value args) {\n"
"SWIGEXT value ",dname,"(value args) {\n"
" CAMLparam1(args);\n"
" int i;\n"
" int argc = caml_list_length(args);\n",NIL);
@ -625,7 +616,7 @@ public:
Wrapper_print(df,f_wrappers);
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",
mangled_name, dname, mangled_name,
newobj ? "true" : "false",
@ -642,7 +633,7 @@ public:
}
} else {
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",
mangled_name, wname, mangled_name, newobj ? "true" : "false",
mangled_name );
@ -703,11 +694,8 @@ public:
if ((SwigType_type(t) != T_USER) || (is_a_pointer(t))) {
Printf (f->def,
"#ifdef __cplusplus\n"
"extern \"C\"\n"
"#endif\n"
"value %s(value args) {\n", var_name);
Printv(f->def, "#define FUNC_NAME \"", proc_name, "\"", NIL);
"SWIGEXT 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");
@ -747,7 +735,7 @@ public:
if( Getattr( n, "feature:immutable" ) ) {
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",
mname, var_name, mname, mname );
Printf( f_mlibody, "val _%s : c_obj\n", iname );
@ -760,9 +748,9 @@ public:
mname, mname );
}
} 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 );
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 );
}
} else {