Comments (7)
Additional probing yields I can map dispatch_queue_create as:
const c = new ffi.Library(null, {
dispatch_queue_create: ['pointer', ['string', 'pointer']]
});
Which seems more correct, as I need to pass it an objective c NULL when I use it, and NULL is a pointer to address 0, not just 0.
I read more about 'ref' and it looks like this call to use the function may be closer:
let queue = c.dispatch_queue_create(ref.allocCString('myQueue'), ref.NULL);
That call does not throw exceptions, but if I inspect 'queue' after it, it seems to have a type of 'void'"
queue.type
Object {size: 0, indirection: 1, get: , set: , name: "void", …}
ffi_type:Uint8Array(0) []
get:function get(buf, offset) { … }
indirection:1
name:"void"
set:function set(buf, offset, val) { … }
size:0
And of course, in the end, it doesn't appear to be working, so I still have something wrong.
from objc.
dispatch_queue_attr_t
is declared as
typedef NSObject<OS_dispatch_queue_attr> *dispatch_queue_attr_t;
so you'd probably need to make it a pointer
in the ffi declaration
from objc.
It seems as if this dispatch_queue_attr_t
parameter is my current blocking issue. If I follow the call I end up getting an NSInvalidArgumentException (see below), and spelunking around in the debugger leads to this happening when in instance.js when processing this parameter.
Is ref.NULL
the right way to pass NULL to an objective-c method?
Error: NSInvalidArgumentException *** -[__NSDictionaryM setObject:forKey:]: object cannot be nil (key: get)
instance.js:110
at Instance.call (/Users/jim/development/node/objc/test/node_modules/objc/src/instance.js:110:13)
at Object.apply (/Users/jim/development/node/objc/test/node_modules/objc/src/proxies.js:21:19)
at Function.ns (/Users/jim/development/node/objc/test/node_modules/objc/src/instance.js:249:20)
at argv.map (/Users/jim/development/node/objc/test/node_modules/objc/src/instance.js:90:31)
at Array.map (<anonymous>)
at Instance.call (/Users/jim/development/node/objc/test/node_modules/objc/src/instance.js:68:23)
at Object.apply (/Users/jim/development/node/objc/test/node_modules/objc/src/proxies.js:21:19)
at Function.ns (/Users/jim/development/node/objc/test/node_modules/objc/src/instance.js:249:20)
at argv.map (/Users/jim/development/node/objc/test/node_modules/objc/src/instance.js:90:31)
at Array.map (<anonymous>)
from objc.
as of right now, you should use javascript's null
instead of ref.NULL
if you want to pass nil
to an objc method.
i'll add support for ref.NULL
in a future release
from objc.
JS null
makes more sense. Would prefer to not have to invoke ref
directly, but I'm shooting in the dark a bit with this one.
Should I be using let ref.allocCString('myQueue')
for the string parameter?
let queue = c.dispatch_queue_create(ref.allocCString('myQueue'), null);
from objc.
that shouldn't be necessary, the ffi
module also accepts JavaScript strings for string
parameters
from objc.
Thanks. I'll close this issue as I think I've got clarification on how to call this function properly (and hopefully this isn't my issue). To summarize, the function I'm calling is:
dispatch_queue_t dispatch_queue_create(const char *label, dispatch_queue_attr_t attr);
I use ffi to access it:
const ffi = require('ffi');
const c = new ffi.Library(null, {
dispatch_queue_create: ['pointer', ['string', 'pointer']]
});
and call it thus:
let queue = c.dispatch_queue_create('myQueue', null);
from objc.
Related Issues (20)
- Ref conversions HOT 2
- Getting data out of a CVPixelBuffer HOT 18
- please update to node >10 version HOT 1
- Symbol not found with Node 10.11.0 and Electron 4.0 HOT 1
- Delegating HOT 5
- how convert nativeWindowHandle to NSView HOT 8
- how can i import custom framework?
- build fails on npm install --save objc HOT 3
- Support for Node 14.x ??? HOT 2
- How to get NSView or NSWindow? HOT 3
- How to use NSRange as a Block parameter? HOT 1
- Importing values from IOKit lib exceeds maximum call stack HOT 7
- Unhelpful error message when framework not found HOT 2
- xxxx.apply is not a function
- "Unexpected token 'o'" in type-encodings.js
- Can you use private frameworks with this?
- Can't introspect various symbols (e.g. require('objc').NSTitledWindowMask)
- Can we do an example for synchronizing documents in the icloud multiple devices?
- Install fails
- Support electron 21 / v8 memory cage
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from objc.