-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ivar("name") not working for imported frameworks #58
Comments
Do you have some code that I can reproduce the issue with? |
See https://github.com/bernhard-42/node-cocoa-http Without patch, calling via curl localhost:8080 -d '{"a":42}'
With patch:
|
Any idea whether this fix is correct or whether the issue sits deepr in import.js? - thanks |
@bernhard-42 I think the issue is deeper. @TooTallNate code that reproduces a similar issue, generating the wrapped value. In this case var $ = require('nodobjc');
$.framework('Foundation');
$.framework('Cocoa');
var pool = $.NSAutoreleasePool('alloc')('init');
var result = $.CGWindowListCopyWindowInfo($.kCGWindowListOptionAll, $.kCGNullWindowID);
var windowList = $.CFBridgingRelease(result);
var aWindow = windowList('objectAtIndex', 0);
console.log(aWindow.ancestors());
// ['__NSCFDictionary','NSMutableDictionary','NSDictionary','NSObject' ]
console.log(aWindow.toString())
/* example:
{
kCGWindowAlpha = 1;
kCGWindowBounds = {
Height = 1440;
Width = 2560;
X = 1440;
Y = "-540";
};
kCGWindowIsOnscreen = 1;
kCGWindowLayer = 20;
kCGWindowMemoryUsage = 1008;
kCGWindowNumber = 14764;
kCGWindowOwnerName = Dock;
kCGWindowOwnerPID = 354;
kCGWindowSharingState = 1;
kCGWindowStoreType = 1;
}
*/
pool('drain'); Trying to access a property aWindow('kCGWindowOwnerName'); produces the following error:
using aWindow.ivar('kCGWindowOwnerName');
For sanity I enumerated over the var keys = aWindow('keyEnumerator');
var key;
while(key = keys('nextObject')){
console.log(key);
}
/*
kCGWindowLayer
kCGWindowName
kCGWindowMemoryUsage
kCGWindowIsOnscreen
kCGWindowSharingState
kCGWindowOwnerPID
kCGWindowNumber
kCGWindowOwnerName
kCGWindowStoreType
kCGWindowBounds
kCGWindowAlpha
*/ Worth noting: numIvars does not exist in this code |
I imported a framework (CocoaHTTPServer) and needed to access an instance variable.
To get it working I had to add
to
in core.js line 183
Reason: The instance variable came back with type '@"HTTPMessage"' and not only with '@'
By checking only character 0 for '@', I could force to call 'createObject' with basetype "@"
Not sure this is correct, but it worked for me ...
The text was updated successfully, but these errors were encountered: