* Initialising caml values from C
@ 2005-04-19 8:55 Jonathan Roewen
2005-04-19 9:37 ` [Caml-list] " Olivier Andrieu
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Roewen @ 2005-04-19 8:55 UTC (permalink / raw)
To: caml-list
Hi,
I'm building an ocaml-native program (actually an OS). Anyways, I
initialise the ocaml runtime from C, but the problem I have is that I
want a couple of caml values to be initialised by calling into C-land.
Something like: (lfb is a linear frame buffer)
external get_lfb: unit -> (int32, Bigarray.int32_elt,
Bigarray.c_layout) Bigarray.Array2.t = "get_lfb"
(* the part that doesn't seem to work *)
(* create a cairo instance for drawing into the LFB *)
let cairo = Cairo.create ()
(* gets the LFB, makes it into a cairo image, then sets it as surface
for cairo to draw into *)
let _ = Cairo.set_target_image cairo (of_bigarr_32 true (get_lfb ()))
If I instead call some initialiser functions to set up the cairo
instances, it seems to be okay... but it'd make life a lot easier if
the above would work correctly. It'd especially help with other parts
of the code that use the above (and other functions/values).
Jon
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Initialising caml values from C
2005-04-19 8:55 Initialising caml values from C Jonathan Roewen
@ 2005-04-19 9:37 ` Olivier Andrieu
2005-04-19 22:09 ` Jonathan Roewen
0 siblings, 1 reply; 3+ messages in thread
From: Olivier Andrieu @ 2005-04-19 9:37 UTC (permalink / raw)
To: jonathan.roewen; +Cc: caml-list
Jonathan Roewen [Tue, 19 Apr 2005]:
> I'm building an ocaml-native program (actually an OS). Anyways, I
> initialise the ocaml runtime from C, but the problem I have is that I
> want a couple of caml values to be initialised by calling into C-land.
>
> Something like: (lfb is a linear frame buffer)
>
> external get_lfb: unit -> (int32, Bigarray.int32_elt,
> Bigarray.c_layout) Bigarray.Array2.t = "get_lfb"
>
> (* the part that doesn't seem to work *)
>
> (* create a cairo instance for drawing into the LFB *)
> let cairo = Cairo.create ()
> (* gets the LFB, makes it into a cairo image, then sets it as surface
> for cairo to draw into *)
> let _ = Cairo.set_target_image cairo (of_bigarr_32 true (get_lfb
> ()))
>
> If I instead call some initialiser functions to set up the cairo
> instances, it seems to be okay... but it'd make life a lot easier
> if the above would work correctly. It'd especially help with other
> parts of the code that use the above (and other functions/values).
I don't quite understand your problem.
Is it that the code (with Cairo) isn't working ? (and if yes,
what exactly isn't working ?)
Or you want help on how to write the get_lfb function ?
--
Olivier
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] Initialising caml values from C
2005-04-19 9:37 ` [Caml-list] " Olivier Andrieu
@ 2005-04-19 22:09 ` Jonathan Roewen
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Roewen @ 2005-04-19 22:09 UTC (permalink / raw)
To: Olivier Andrieu; +Cc: caml-list
> I don't quite understand your problem.
>
> Is it that the code (with Cairo) isn't working ? (and if yes,
> what exactly isn't working ?)
Yes, cairo doesn't draw anything if I try initialise the values that way.
The problem is initialising the global values. They don't seem to work
if initialising them requires calling an external function.
like:
let height = get_lfb_height () (* where that is an external function *)
Basically, I want to avoid creating global refs, especially to more
complex structures.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-04-19 22:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-19 8:55 Initialising caml values from C Jonathan Roewen
2005-04-19 9:37 ` [Caml-list] " Olivier Andrieu
2005-04-19 22:09 ` Jonathan Roewen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox