List Info

Thread: "ocaml_beginners"::[] finding an external function




"ocaml_beginners"::[] finding an external function
country flaguser name
United States
2007-05-04 22:10:26

So far I've done...
ocamlc test.mli
cc -c -I/opt/local/lib/ocaml test.m (* This is an Objective C file *)
ocamlmklib test.o -o test.cma
ocaml test.cma test-test.ml

This results in "The external function `string_to_NSString' is not
available".

Source:

(*test.mli*)
type nsstring
external string_to_nsstring : string -> nsstring = "string_to_NSString"
external nsstring_to_string : nsstring -> string = "NSString_to_string"

(*test.m*)
#import <Foundation/NSString.h>

#ifndef CAMLHEADERS
#define CAMLHEADERS
#include <caml/mlvalues.h&gt;
#include <caml/alloc.h>
#include <caml/memory.h>;
#include <caml/fail.h>
#include <caml/callback.h&gt;
#include <caml/custom.h>;
#include <caml/intext.h>;
#endif

NSString* string_to_NSString(value s)
{
NSString *ns;
[ns initWithUTF8String: String_val(s)];
CAMLreturn(ns);
}

value NSString_to_string(NSString *ns)
{
char *s = [ns UTF8String];
value camls = copy_string(s);
CAMLreturn(camls);
}

(*test-test.ml*)
open Test;;

let s = "hello";;

print_endline s;;

let ns = string_to_nsstring s;;

let origs = nsstring_to_string ns;;

print_endline origs;;

(* end files *)

Yes, I'm playing with mixing Mac OS X's Objective C libraries with
ocaml.

Any ideas about how to get ocaml to see my c functions?

__._,_.___
.

__,_._,___
"ocaml_beginners"::[] Re: finding an external function
country flaguser name
United States
2007-05-05 15:19:21

Never mind, I figured out how to make it work.

Now the problem is that I don't know how to get NSAutoReleasePool to
play well with ocaml.

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )