I just reviewed your code. My suggestion is to implement a class
in JavaScript to wrap your C++ addon, then you can easily implement event
dispatcher in JavaScript with callback mechanism.

For low-level things that's like byte processing, it's better to do its all
jobs in C++.

How about this design:

var Wayland = require('wayland');
var wl = new Waylan();

// wl.init will do connect(), get_registry(), and initialize event emitter
wl.init(function() {
});

---

Wayland.Client Class:
connect()

Wayland.Display Class:
get_registry()
roundtrip()

Wayland.Registry Class:
on() // event listener
emit() // emitter

Cheers,
Fred




2013/4/11 Henri Tuhola <[email protected]>

> I were able to call wl_display_get_registry and get some stub listener
> calls back: https://github.com/cheery/node-wayland
>
> It looks like I need to process byte arrays at requests and events. I
> wonder how to do it properly.
>
> I also wonder what it should look like finally? Perhaps like this?
>
> wl = request "wayland/client"
> display = wl.connect()
> registry = display.get_registry()
> registry.listen {
>     global: (args...) ->
>         console.log(args)
> }
> display.roundtrip()
>
>
> keskiviikko, 10. huhtikuuta 2013 1.33.29 UTC+3 Henri Tuhola kirjoitti:
>
>> Since Wayland is becoming stable finally, it's the time to implement
>> bindings for several dynamic languages. As it can fertilize Linux for
>> large-scale GUI design&development efforts. I plan doing exactly this, but
>> I have forgotten several things about node.js bindings.
>>
>> There's several simple things I need to solve:
>>
>> I need to get a pointer to my wrappings that let me route events through
>> those proxies. I wonder how to get such pointer (that doesn't change at the
>> next garbage collect cycle), and how to turn all those proxies into event
>> dispatchers.. or is it okay that they call regular functions?
>>
>> As a second thing, I should pick up the known interface descriptors from
>> the libwayland and provide them to the generated functions name-by-name.
>>
>> As a third thing, I should hook the node.js event listener to the
>> display. I remember I'd have some reference code in node-udev, but this
>> needs to be verified.
>>
>> Fourth thing, I wonder if the generated code from IDL should be .js or
>> .cc.
>>
>> Fifth thing, once things are autogenerated, I should supply some
>> functions into them. I wonder how to do this.
>>
>> If you need some extra references to answer, they can be found from:
>> http://wayland.freedesktop.**org/docs/html/<http://wayland.freedesktop.org/docs/html/>
>> http://www.jlekstrand.net/**jason/wayland-language-**bindings-guide/<http://www.jlekstrand.net/jason/wayland-language-bindings-guide/>
>>
>> I plan getting this done within this weekend. Everything seems simple
>> enough so it won't probably need more time than that. If you have answers
>> to some of my problems, I guess I might get through it even faster.
>>
>  --
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to