summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxant <xant@xant.net>2013-09-26 20:37:59 (GMT)
committer xant <xant@xant.net>2013-09-26 20:37:59 (GMT)
commit55b7afafc41d6cfd0244b7ee251d5f323ffbf5b5 (patch)
tree981e20197e3102a53efb0bf6a528eac3de16efa4
parent6e08268419d0353e6b9fa938714749d6b5f6e2ea (diff)
cosmetics
-rw-r--r--core/JMXApplication.m2
-rw-r--r--core/JMXContext.m3
-rw-r--r--core/JMXScript.mm13
-rw-r--r--core/NSXMLNode+V8.mm12
-rw-r--r--entities/JMXScriptEntity.mm5
-rw-r--r--gui/JMXBoardViewController.m4
-rw-r--r--gui/JMXEntityLayer.m6
-rw-r--r--jmx/main.m9
8 files changed, 25 insertions, 29 deletions
diff --git a/core/JMXApplication.m b/core/JMXApplication.m
index 2c3d8c3..5b105a6 100644
--- a/core/JMXApplication.m
+++ b/core/JMXApplication.m
@@ -87,7 +87,7 @@ int verbose = LOG_INFO;
// // or the application will crash when the user tries accessing them
// [sharedContext registerClass:[JMXPhidgetEncoderEntity class]];
// }
- INFO("Registered %ul entities", (unsigned int)[[sharedContext registeredClasses] count]);
+// INFO("Registered %u entities", (unsigned int)[[sharedContext registeredClasses] count]);
}
- (void)applicationDidFinishLaunching:(NSNotification *)notification
diff --git a/core/JMXContext.m b/core/JMXContext.m
index 108b585..6aac599 100644
--- a/core/JMXContext.m
+++ b/core/JMXContext.m
@@ -140,6 +140,9 @@ static BOOL initialized = NO;
if (!entity.parent && ![entity isProxy]) {
NSValue *value = [NSValue valueWithNonretainedObject:entity];
[entities setObject:value forKey:[NSString stringWithFormat:@"%d", (int)entity]];
+ @synchronized(dom.rootElement) {
+ [dom.rootElement addChild:entity];
+ }
}
}
}
diff --git a/core/JMXScript.mm b/core/JMXScript.mm
index c8d67f1..12bbea6 100644
--- a/core/JMXScript.mm
+++ b/core/JMXScript.mm
@@ -639,15 +639,17 @@ static char *argv[2] = { NULL, NULL };
NSMutableArray *toRemove = [NSMutableArray array];
@synchronized(timersThread) {
for (JMXScriptTimer *scriptTimer in runloopTimers) {
+ NSDate *now = [NSDate date];
if (!scriptTimer.timer.isValid) {
[toRemove addObject:scriptTimer];
} else if ([scriptTimer.timer.fireDate
compare:[NSDate dateWithTimeInterval:0.001
- sinceDate:[NSDate date]]] == NSOrderedAscending)
+ sinceDate:now]] == NSOrderedAscending)
{
[scriptTimer.timer fire];
if (scriptTimer.repeats) {
- scriptTimer.timer.fireDate = [NSDate dateWithTimeInterval:scriptTimer.timer.timeInterval sinceDate:[NSDate date]];
+ scriptTimer.timer.fireDate = [NSDate dateWithTimeInterval:scriptTimer.timer.timeInterval
+ sinceDate:now];
}
}
}
@@ -919,16 +921,13 @@ static Persistent<ObjectTemplate> ctxTemplate;
- (BOOL)clearTimers
{
- BOOL ret = YES;
@synchronized(timersThread) {
for (JMXScriptTimer *t in runloopTimers) {
[t invalidate];
- if (t.timer.isValid)
- ret = NO;
}
[runloopTimers removeAllObjects];
}
- return (ret && !runloopTimers.count);
+ return (runloopTimers.count);
//[self execCode:@"clearAllTimers()"];
}
@@ -1154,7 +1153,7 @@ static Persistent<ObjectTemplate> ctxTemplate;
Handle<Value> args[1];
args[0] = [anEvent jsObj];
for (JMXEventListener *listener in listeners) {
- //Unlocker unlocker;
+ Unlocker unlocker;
[self execFunction:listener.function withArguments:args count:1];
}
[pool release];
diff --git a/core/NSXMLNode+V8.mm b/core/NSXMLNode+V8.mm
index 09793f9..9eee714 100644
--- a/core/NSXMLNode+V8.mm
+++ b/core/NSXMLNode+V8.mm
@@ -271,10 +271,14 @@ static v8::Handle<Value> RemoveChild(const Arguments& args)
id holder = (id)args.Holder()->GetPointerFromInternalField(0);
if ([holder isKindOfClass:[NSXMLElement class]]) {
NSXMLElement *node = (NSXMLElement *)holder;
- NSXMLNode *child = (NSXMLNode *)args[0]->ToObject()->GetPointerFromInternalField(0);
- if (child) {
- [node removeChildAtIndex:[child index]];
- return handleScope.Close(args[0]->ToObject());
+ if (!args[0].IsEmpty() && args[0]->IsObject()) {
+ NSXMLNode *child = (NSXMLNode *)args[0]->ToObject()->GetPointerFromInternalField(0);
+ if (child) {
+ [node removeChildAtIndex:[child index]];
+ return handleScope.Close(args[0]->ToObject());
+ } else {
+ // TODO - Error Messages
+ }
} else {
// TODO - Error Messages
}
diff --git a/entities/JMXScriptEntity.mm b/entities/JMXScriptEntity.mm
index f9383e9..0a642c8 100644
--- a/entities/JMXScriptEntity.mm
+++ b/entities/JMXScriptEntity.mm
@@ -150,7 +150,10 @@ using namespace v8;
holder = [[[JMXGraphFragment alloc] initWithName:@"Entities"] autorelease];
[self addChild:holder];
}
+ [entity retain];
+ [entity detach];
[holder addChild:entity];
+ [entity release];
}
- (void)destroyEntity:(JMXEntity *)entity
@@ -200,8 +203,8 @@ using namespace v8;
- (JMXScriptFile *)load:(NSString *)path
{
JMXScriptFile *script = [[JMXScriptFile alloc] init];
- script.path = path;
[self hookEntity:script];
+ script.path = path;
return script;
}
diff --git a/gui/JMXBoardViewController.m b/gui/JMXBoardViewController.m
index d0795e3..73411a6 100644
--- a/gui/JMXBoardViewController.m
+++ b/gui/JMXBoardViewController.m
@@ -72,10 +72,6 @@
entities = [[NSMutableArray alloc] init];
entitiesController = [[JMXEntitiesController alloc] init];
scriptController = [[JMXScriptEntity alloc] init];//:@"scriptController"];
- NSXMLElement *rootElement = [[[JMXContext sharedContext] dom] rootElement];
- @synchronized(rootElement) {
- [rootElement addChild:scriptController];
- }
jsInput.target = self;
jsInput.action = @selector(execStatement);
jsInput.delegate = self;
diff --git a/gui/JMXEntityLayer.m b/gui/JMXEntityLayer.m
index b6a3d22..1387a55 100644
--- a/gui/JMXEntityLayer.m
+++ b/gui/JMXEntityLayer.m
@@ -73,12 +73,6 @@
selector:@selector(outputPinRemoved:)
name:@"JMXEntityOutputPinRemoved"
object:self.entity];
-
- // attach the new entity to the main document
- NSXMLElement *rootElement = [[[JMXContext sharedContext] dom] rootElement];
- @synchronized(rootElement) {
- [rootElement addChild:anEntity];
- }
}
return self;
}
diff --git a/jmx/main.m b/jmx/main.m
index 940913e..c3e174d 100644
--- a/jmx/main.m
+++ b/jmx/main.m
@@ -29,13 +29,11 @@ int main(int argc, const char * argv[])
scriptController = [[JMXScriptEntity alloc] init];
scriptController.name = @"scriptController";
- NSXMLElement *rootElement = [[[JMXContext sharedContext] dom] rootElement];
- @synchronized(rootElement) {
- [rootElement addChild:scriptController];
- }
+
scriptController.active = YES;
[scriptController exec:@""];
-
+
+ // create a menubar and an invisible (main) window to make NSApplication happy
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
NSMenu *menubar = [NSMenu new];
@@ -55,7 +53,6 @@ int main(int argc, const char * argv[])
NSWindow *window = [[NSWindow alloc] initWithContentRect:NSZeroRect
styleMask:NSTitledWindowMask
backing:NSBackingStoreBuffered defer:NO];
- //[window cascadeTopLeftFromPoint:NSMakePoint(20,20)];
window.title = app.appName;
window.isVisible = NO;
[window makeKeyAndOrderFront:nil];