TooTallNate / NodObjC

The Node.js ⇆ Objective-C bridge

Home Page:http://tootallnate.github.io/NodObjC

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get a pointer to the native object in a C++ Node.js module

Ivshti opened this issue · comments

If an object form the nodobjc bridge was passed to a node.js C++ addon, how would it extract the raw pointer to the native object from a nodobjc wrapper?

console.log-ing gives us the pointer:

<NSView: 0x7fc338dcfee0>

The question is how to do it from a C++ node.js addon.

E.g.

var view = $.NSView('alloc')('init');
require("some-native-addon").create(view); // how would some-native-addon extract the raw pointer?

The instance of NSView seems to have a pointer property, which is a Buffer, for which there's information on how to get the raw address in C++ for. But sources that mention .pointer also say "TODO get rid of this" so there's still no stable way to do this.

I honestly don't remember why that TODO is there...