On Fri, Jul 13, 2012 at 12:36 PM, jas <[email protected]> wrote:
> I have been doing some research, reviewing existing material etc. Following
> the gtknotify module creation process found @
> http://syskall.com/how-to-write-your-own-native-nodejs-extension has allowed
> me to create my own module which compiles and includes without a problem.
>
> At this point I believe I simply need to add in some argument parsing to
> being adding the real meat and potatoes of the functionality...
>
> Can anyone tell me why there is a difference in using this method
>
>
>>
>> ExtensionName::persistent_function_template->InstanceTemplate()->SetAccessor(String::New("argument"),
>> GetArg, SetArg);
>
>
> And the other writing guides @ http://nodejs.org/api/addons.html which uses
> the traditional C/C++ args like so...
>
>
>> Handle<Value> Add(const Arguments& args)
>
>
> Is there a difference in wrapping them around an accessors object? My
> assumption (and have not had time to browse the v8 internals) is that some
> string manipulation is taking place in terms of sanitation and encoding. Any
> insights from someone with more experience with these libraries?

o->SetAccessor(name, GetArg, SetArg) creates a "magic" JS property
that calls your getter or setter whenever the user reads from or
writes to it, i.e.:

  console.log(obj.name); // prints whatever GetArg() returns
  obj.name = 42; // calls SetArg()

o->Set(name, FunctionTemplate(Add)->GetFunction()) creates a non-magic
JS property that is simply a function, i.e.:

  console.log(obj.name); // prints "[Function]"
  obj.name(42); // calls Add()

Both approaches have their merit but I believe most add-ons lean
towards functions.

-- 
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

Reply via email to