Re: [gdome]user_data and language bindings
- From: Claudio Sacerdoti Coen <sacerdot CS UniBO IT>
- To: Tobias Peters <tpeters uni-oldenburg de>
- Cc: gdome gnome org
- Subject: Re: [gdome]user_data and language bindings
- Date: Fri, 5 Apr 2002 17:40:06 +0200
Hi,
> And then, obj' and newChild are just two names for the same object,
> because of some feature in ocaml?
Not exactly. newChild is the OO wrapper, while obj' is the pre-method this.
If you want (roughly!!) newChild is the ocaml object while obj' is the
gdome "object".
> > To sum up, we have two "functions" (the constructor and as_node)
> > to map "this" of the pre-method level to objects at the OO-level.
> > A method M at the OO level is the composition of a constructor
> > with the pre-method M' with the as_node method.
>
> Ok, how is this mapping performed in the constructor? Using a per-document
> this-to-OO hash table or something?
Not at all. Simply, the constructor stores the "this" in a field of
the object. (Roughly: in Ocaml you don't have to store fields because
you have closures...) So, every time you call a method of the object,
the method implementation retrieves the "this" and calls the
pre-methods on the this and the arguments.
> First I wanted to write that I don't understand this paragraph, but having
> read it for the third time or so
;-))
> it becomes somewhat clear. You are in
> fact using a global or per-document hash to map the C pointers to gdome
> objects in OCaml. Well then prepare for the great programming language
> shootout :-)
;-)
> > Of course, this approach is probably not feasible for other languages.
>
> Ha! Ruby has hash tables, and so has Perl, and even C++! We could do the
> very same thing in these other languages :-)
Of course. My remark was just that to complete the binding I have no
need at all for the hash table, because of the "trick" of the
OO-objects remembering the "this" without need of any hash-table.
So I have not really implemented the hash-table stuff, but it can be
implemented if someone needs this (e.g. for subclassing Ocaml objects).
I don't know if you can do the same easily in other languages
(i.e. I don't know if you will need the hash table just to be able to
complete the binding.)
> It's just much more efficient to simply use the user_data pointer.
As I have said, for now it is already as efficiente as possible in the
"standard" usage model. The hash table stuff is just for real hackers.
And yes, I am sharing the same DOM from different languages. VERY unpolite
of myself ;-))
> Admit:
> I have not thought that people would want to use the same gdome tree from
> two different languages, and then still want to use the user_data
> themselves. Not really polite by these people.
Every time someone in my research group thinks something like that,
I am soon going to need that. Either it is Murphy or myself ;-D
Happy binding,
C.S.C.
--
----------------------------------------------------------------
Real name: Claudio Sacerdoti Coen
PhD Student in Computer Science at University of Bologna
E-mail: sacerdot cs unibo it
http://caristudenti.cs.unibo.it/~sacerdot
----------------------------------------------------------------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]