summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Guzzo <andrea.guzzo@booking.com>2013-09-25 14:28:15 (GMT)
committer Andrea Guzzo <andrea.guzzo@booking.com>2013-09-25 14:28:15 (GMT)
commitefa3d59e8d8846e0b37ffa33749fd011068900ac (patch)
tree66f01fb4127b198c9436d031f3b9def77128ddb9
parent49fadf8a0d5d3e2baecc9a3c6ec4a956fbedf958 (diff)
WIP on the cli tool
-rw-r--r--JMX.xcodeproj/project.pbxproj173
-rw-r--r--core/JMXScript.mm62
-rw-r--r--core/NSColor+V8.mm25
-rw-r--r--jmx/jmx-Prefix.pch9
-rw-r--r--jmx/jmx.179
-rw-r--r--jmx/main.m32
-rw-r--r--node.js/lib/_third_party_main.js35
7 files changed, 398 insertions, 17 deletions
diff --git a/JMX.xcodeproj/project.pbxproj b/JMX.xcodeproj/project.pbxproj
index a8fbb4e..d6b26da 100644
--- a/JMX.xcodeproj/project.pbxproj
+++ b/JMX.xcodeproj/project.pbxproj
@@ -28,6 +28,11 @@
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
AA08D33B14B5AA4500D19015 /* JMXCodePanel.m in Sources */ = {isa = PBXBuildFile; fileRef = AA08D33A14B5AA4400D19015 /* JMXCodePanel.m */; };
AA37E05214FA318500CBA0AE /* JMXDOMBrowser.m in Sources */ = {isa = PBXBuildFile; fileRef = AA37E05114FA318500CBA0AE /* JMXDOMBrowser.m */; };
+ AA417D5517F2D34B00A705DF /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA70C830178AACF700190C38 /* Foundation.framework */; };
+ AA417D5817F2D34B00A705DF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = AA417D5717F2D34B00A705DF /* main.m */; };
+ AA417D5C17F2D34B00A705DF /* jmx.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = AA417D5B17F2D34B00A705DF /* jmx.1 */; };
+ AA417D6317F2D47F00A705DF /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA417D6217F2D47F00A705DF /* Cocoa.framework */; };
+ AA417D6417F2D69200A705DF /* JMXCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AA9BFA5F178F0FB2003673D9 /* JMXCore.framework */; };
AA490DD214CC5F8E00407C0D /* draw_pixels.js in Deploy JS examples */ = {isa = PBXBuildFile; fileRef = AA490DC314CC5F4900407C0D /* draw_pixels.js */; };
AA490DD314CC5F8E00407C0D /* filter_videofile.js in Deploy JS examples */ = {isa = PBXBuildFile; fileRef = AA490DC414CC5F4900407C0D /* filter_videofile.js */; };
AA490DD414CC5F8E00407C0D /* play_mp3dir.js in Deploy JS examples */ = {isa = PBXBuildFile; fileRef = AA490DC514CC5F4900407C0D /* play_mp3dir.js */; };
@@ -269,6 +274,13 @@
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
+ AA417D6017F2D36400A705DF /* PBXContainerItemProxy */ = {
+ isa = PBXContainerItemProxy;
+ containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
+ proxyType = 1;
+ remoteGlobalIDString = AA9BFA5E178F0FB2003673D9;
+ remoteInfo = JMXCore;
+ };
AA9BFAEA178F13EC003673D9 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 29B97313FDCFA39411CA2CEA /* Project object */;
@@ -286,6 +298,16 @@
/* End PBXContainerItemProxy section */
/* Begin PBXCopyFilesBuildPhase section */
+ AA417D5217F2D34B00A705DF /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = /usr/share/man/man1/;
+ dstSubfolderSpec = 0;
+ files = (
+ AA417D5C17F2D34B00A705DF /* jmx.1 in CopyFiles */,
+ );
+ runOnlyForDeploymentPostprocessing = 1;
+ };
AA490DD114CC5F7C00407C0D /* Deploy JS examples */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 12;
@@ -468,6 +490,11 @@
AA37E05014FA318400CBA0AE /* JMXDOMBrowser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JMXDOMBrowser.h; sourceTree = "<group>"; };
AA37E05114FA318500CBA0AE /* JMXDOMBrowser.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JMXDOMBrowser.m; sourceTree = "<group>"; };
AA38D1CB12DCC29D00208826 /* jquery.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = jquery.js; sourceTree = "<group>"; };
+ AA417D5417F2D34B00A705DF /* jmx */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = jmx; sourceTree = BUILT_PRODUCTS_DIR; };
+ AA417D5717F2D34B00A705DF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ AA417D5A17F2D34B00A705DF /* jmx-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "jmx-Prefix.pch"; sourceTree = "<group>"; };
+ AA417D5B17F2D34B00A705DF /* jmx.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = jmx.1; sourceTree = "<group>"; };
+ AA417D6217F2D47F00A705DF /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
AA447A9C178D7CE500DA8700 /* libnode.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libnode.a; path = node.js/out/Release/libnode.a; sourceTree = "<group>"; };
AA447A9D178D7CE500DA8700 /* libchrome_zlib.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libchrome_zlib.a; path = node.js/out/Release/libchrome_zlib.a; sourceTree = "<group>"; };
AA447A9E178D7CE500DA8700 /* libv8_nosnapshot.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libv8_nosnapshot.a; path = node.js/out/Release/libv8_nosnapshot.a; sourceTree = "<group>"; };
@@ -678,6 +705,16 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ AA417D5117F2D34B00A705DF /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ AA417D6417F2D69200A705DF /* JMXCore.framework in Frameworks */,
+ AA417D6317F2D47F00A705DF /* Cocoa.framework in Frameworks */,
+ AA417D5517F2D34B00A705DF /* Foundation.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
AA9BFA5B178F0FB2003673D9 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -728,6 +765,7 @@
children = (
8D1107320486CEB800E47090 /* JMX.app */,
AA9BFA5F178F0FB2003673D9 /* JMXCore.framework */,
+ AA417D5417F2D34B00A705DF /* jmx */,
);
name = Products;
sourceTree = "<group>";
@@ -741,6 +779,7 @@
29B97315FDCFA39411CA2CEA /* Supporting Files */,
29B97317FDCFA39411CA2CEA /* Resources */,
AA9BFA65178F0FB2003673D9 /* JMXCore */,
+ AA417D5617F2D34B00A705DF /* jmx */,
29B97323FDCFA39411CA2CEA /* Frameworks */,
19C28FACFE9D520D11CA2CBB /* Products */,
);
@@ -771,6 +810,7 @@
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
isa = PBXGroup;
children = (
+ AA417D6217F2D47F00A705DF /* Cocoa.framework */,
AA447ACD178D803900DA8700 /* libc++.dylib */,
AA447ACA178D7F2900DA8700 /* libv8_base.a */,
AA447A9C178D7CE500DA8700 /* libnode.a */,
@@ -913,6 +953,24 @@
path = video_outputs;
sourceTree = "<group>";
};
+ AA417D5617F2D34B00A705DF /* jmx */ = {
+ isa = PBXGroup;
+ children = (
+ AA417D5717F2D34B00A705DF /* main.m */,
+ AA417D5B17F2D34B00A705DF /* jmx.1 */,
+ AA417D5917F2D34B00A705DF /* Supporting Files */,
+ );
+ path = jmx;
+ sourceTree = "<group>";
+ };
+ AA417D5917F2D34B00A705DF /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ AA417D5A17F2D34B00A705DF /* jmx-Prefix.pch */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
AA490DD914CC5F9C00407C0D /* Javascript Examples */ = {
isa = PBXGroup;
children = (
@@ -1457,6 +1515,24 @@
productReference = 8D1107320486CEB800E47090 /* JMX.app */;
productType = "com.apple.product-type.application";
};
+ AA417D5317F2D34B00A705DF /* jmx */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = AA417D5F17F2D34B00A705DF /* Build configuration list for PBXNativeTarget "jmx" */;
+ buildPhases = (
+ AA417D5017F2D34B00A705DF /* Sources */,
+ AA417D5117F2D34B00A705DF /* Frameworks */,
+ AA417D5217F2D34B00A705DF /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ AA417D6117F2D36400A705DF /* PBXTargetDependency */,
+ );
+ name = jmx;
+ productName = jmx;
+ productReference = AA417D5417F2D34B00A705DF /* jmx */;
+ productType = "com.apple.product-type.tool";
+ };
AA9BFA5E178F0FB2003673D9 /* JMXCore */ = {
isa = PBXNativeTarget;
buildConfigurationList = AA9BFA6F178F0FB2003673D9 /* Build configuration list for PBXNativeTarget "JMXCore" */;
@@ -1483,7 +1559,7 @@
29B97313FDCFA39411CA2CEA /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0460;
+ LastUpgradeCheck = 0500;
ORGANIZATIONNAME = Dyne.org;
};
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "JMX" */;
@@ -1504,6 +1580,7 @@
8D1107260486CEB800E47090 /* JMX */,
AA9BFA5E178F0FB2003673D9 /* JMXCore */,
AA9BFAE5178F12C1003673D9 /* node.js */,
+ AA417D5317F2D34B00A705DF /* jmx */,
);
};
/* End PBXProject section */
@@ -1577,6 +1654,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ AA417D5017F2D34B00A705DF /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ AA417D5817F2D34B00A705DF /* main.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
AA9BFA5A178F0FB2003673D9 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -1679,6 +1764,11 @@
/* End PBXSourcesBuildPhase section */
/* Begin PBXTargetDependency section */
+ AA417D6117F2D36400A705DF /* PBXTargetDependency */ = {
+ isa = PBXTargetDependency;
+ target = AA9BFA5E178F0FB2003673D9 /* JMXCore */;
+ targetProxy = AA417D6017F2D36400A705DF /* PBXContainerItemProxy */;
+ };
AA9BFAEB178F13EC003673D9 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = AA9BFAE5178F12C1003673D9 /* node.js */;
@@ -1719,11 +1809,74 @@
/* End PBXVariantGroup section */
/* Begin XCBuildConfiguration section */
+ AA417D5D17F2D34B00A705DF /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "jmx/jmx-Prefix.pch";
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.8;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ AA417D5E17F2D34B00A705DF /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_CXX_LIBRARY = "libc++";
+ CLANG_ENABLE_OBJC_ARC = YES;
+ CLANG_WARN_BOOL_CONVERSION = YES;
+ CLANG_WARN_CONSTANT_CONVERSION = YES;
+ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
+ CLANG_WARN_EMPTY_BODY = YES;
+ CLANG_WARN_ENUM_CONVERSION = YES;
+ CLANG_WARN_INT_CONVERSION = YES;
+ CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ ENABLE_NS_ASSERTIONS = NO;
+ GCC_ENABLE_OBJC_EXCEPTIONS = YES;
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "jmx/jmx-Prefix.pch";
+ GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
+ GCC_WARN_UNDECLARED_SELECTOR = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_FUNCTION = YES;
+ MACOSX_DEPLOYMENT_TARGET = 10.8;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
AA9BFA70178F0FB2003673D9 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
@@ -1762,7 +1915,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CONSTANT_CONVERSION = YES;
@@ -1794,7 +1946,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CONSTANT_CONVERSION = NO;
@@ -1827,7 +1978,6 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
- ARCHS = "$(ARCHS_STANDARD_64_BIT)";
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
CLANG_WARN_CONSTANT_CONVERSION = NO;
@@ -1956,7 +2106,6 @@
C01FCF4F08A954540054247B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ALTIVEC_EXTENSIONS = YES;
@@ -1989,7 +2138,6 @@
C01FCF5008A954540054247B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
COPY_PHASE_STRIP = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
GCC_ALTIVEC_EXTENSIONS = YES;
@@ -2023,6 +2171,15 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
+ AA417D5F17F2D34B00A705DF /* Build configuration list for PBXNativeTarget "jmx" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ AA417D5D17F2D34B00A705DF /* Debug */,
+ AA417D5E17F2D34B00A705DF /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
AA9BFA6F178F0FB2003673D9 /* Build configuration list for PBXNativeTarget "JMXCore" */ = {
isa = XCConfigurationList;
buildConfigurations = (
@@ -2030,6 +2187,7 @@
AA9BFA71178F0FB2003673D9 /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
AA9BFAE6178F12C1003673D9 /* Build configuration list for PBXLegacyTarget "node.js" */ = {
isa = XCConfigurationList;
@@ -2038,6 +2196,7 @@
AA9BFAE8178F12C1003673D9 /* Release */,
);
defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
};
C01FCF4A08A954540054247B /* Build configuration list for PBXNativeTarget "JMX" */ = {
isa = XCConfigurationList;
diff --git a/core/JMXScript.mm b/core/JMXScript.mm
index 90d0c31..d63e44e 100644
--- a/core/JMXScript.mm
+++ b/core/JMXScript.mm
@@ -573,6 +573,7 @@ static char *argv[2] = { (char *)"JMX", NULL };
// initialize node.js
node::Init(1, argv);
v8::V8::Initialize();
+ [self createDefaultContext];
}
+ (BOOL)runScript:(NSString *)source
@@ -660,7 +661,7 @@ static char *argv[2] = { (char *)"JMX", NULL };
}
}
-- (void)registerClasses:(v8::Handle<ObjectTemplate>)ctxTemplate;
++ (void)registerClasses:(v8::Handle<ObjectTemplate>)ctxTemplate;
{
// register all the core entities exposed to the javascript context.
// JMXPins are also exposed but those can't be created directly from
@@ -752,13 +753,15 @@ static char *argv[2] = { (char *)"JMX", NULL };
return YES;
}
-- (void)startWithEntity:(JMXScriptEntity *)entity
+static NSThread *nodejsThread = nil;
+static Persistent<ObjectTemplate> ctxTemplate;
+
++ (void)createDefaultContext
{
v8::Locker locker;
v8::HandleScope handle_scope;
- persistentInstances = [[NSMutableDictionary alloc] init];
- Local<ObjectTemplate>ctxTemplate = ObjectTemplate::New();
+ ctxTemplate = Persistent<ObjectTemplate>::New(ObjectTemplate::New());
ctxTemplate->Set(String::New("rand"), FunctionTemplate::New(Rand));
ctxTemplate->Set(String::New("frand"), FunctionTemplate::New(FRand));
@@ -770,8 +773,8 @@ static char *argv[2] = { (char *)"JMX", NULL };
ctxTemplate->Set(String::New("isdir"), FunctionTemplate::New(IsDir));
ctxTemplate->Set(String::New("exportPin"), FunctionTemplate::New(ExportPin));
ctxTemplate->Set(String::New("dumpDOM"), FunctionTemplate::New(DumpDOM));
-// ctxTemplate->Set(String::New("run"), FunctionTemplate::New(Run));
-// ctxTemplate->Set(String::New("quit"), FunctionTemplate::New(Quit));
+ // ctxTemplate->Set(String::New("run"), FunctionTemplate::New(Run));
+ // ctxTemplate->Set(String::New("quit"), FunctionTemplate::New(Quit));
ctxTemplate->Set(String::New("addToRunLoop"), FunctionTemplate::New(AddToRunLoop));
ctxTemplate->Set(String::New("removeFromRunLoop"), FunctionTemplate::New(RemoveFromRunLoop));
#if 1
@@ -788,6 +791,13 @@ static char *argv[2] = { (char *)"JMX", NULL };
ctxTemplate->Set(String::New("ListEntities"), FunctionTemplate::New(ListEntities));
*/
[self registerClasses:ctxTemplate];
+}
+- (void)startWithEntity:(JMXScriptEntity *)entity
+{
+ v8::Locker locker;
+ v8::HandleScope handle_scope;
+
+ persistentInstances = [[NSMutableDictionary alloc] init];
ctx = Persistent<Context>::New(Context::New(NULL, ctxTemplate));
v8::Context::Scope context_scope(ctx);
@@ -833,6 +843,46 @@ static char *argv[2] = { (char *)"JMX", NULL };
selector:@selector(jsRunTimers)
object:self];
[timersThread start];
+
+ if (!nodejsThread) {
+ nodejsThread = [[NSThread alloc] initWithTarget:[self class] selector:@selector(nodejsRun:) object:self];
+ [nodejsThread start];
+ }
+}
+
++ (void)nodejsRun:(JMXScript *)context
+{
+ Locker locker;
+ HandleScope handleScope;
+ v8::Context::Scope context_scope(context.ctx);
+
+ uint64_t maxDelta = 1e9 / 120.0; // max 120 ticks per seconds
+ while (![[NSThread currentThread] isCancelled]) {
+ @try {
+
+ uint64_t timeStamp = CVGetCurrentHostTime();
+
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ uv_run(uv_default_loop(), (uv_run_mode)(UV_RUN_ONCE | UV_RUN_NOWAIT));
+ uint64_t now = CVGetCurrentHostTime();
+ uint64_t delta = now - timeStamp;
+ uint64_t sleepTime = (delta && delta < maxDelta) ? maxDelta - delta : 0;
+
+ if (sleepTime) {
+ struct timespec time = { 0, 0 };
+ struct timespec remainder = { 0, static_cast<long>(sleepTime) };
+ do {
+ time.tv_sec = remainder.tv_sec;
+ time.tv_nsec = remainder.tv_nsec;
+ remainder.tv_nsec = 0;
+ nanosleep(&time, &remainder);
+ } while (remainder.tv_sec || remainder.tv_nsec);
+ }
+ }
+ @catch (NSException *exception) {
+ NSLog(@"%@", exception);
+ }
+ }
}
- (void)clearPersistentInstances
diff --git a/core/NSColor+V8.mm b/core/NSColor+V8.mm
index d8d264d..3014255 100644
--- a/core/NSColor+V8.mm
+++ b/core/NSColor+V8.mm
@@ -313,7 +313,24 @@ void ConvertHSLToRGB (const CGFloat *hslComponents, CGFloat *rgbComponents) {
- (CGFloat)w
{
- return [self whiteComponent];
+ return [[self colorUsingColorSpaceName:NSCalibratedWhiteColorSpace] whiteComponent];
+}
+
+v8::Handle<Value>GetWhiteComponent(Local<String> name, const AccessorInfo& info)
+{
+ Locker lock;
+ HandleScope handle_scope;
+ NSColor *obj = (NSColor *)info.Holder()->GetPointerFromInternalField(0);
+ return handle_scope.Close(Number::New([[obj colorUsingColorSpaceName:NSCalibratedWhiteColorSpace] whiteComponent]));
+}
+
+v8::Handle<Value>GetBlackComponent(Local<String> name, const AccessorInfo& info)
+{
+ Locker lock;
+ HandleScope handle_scope;
+ NSColor *obj = (NSColor *)info.Holder()->GetPointerFromInternalField(0);
+ CGFloat f = [[obj colorUsingColorSpaceName:NSCalibratedWhiteColorSpace] whiteComponent];
+ return handle_scope.Close(Number::New(1.0 - f));
}
static v8::Persistent<FunctionTemplate> objectTemplate;
@@ -340,15 +357,15 @@ static v8::Persistent<FunctionTemplate> objectTemplate;
instanceTemplate->SetAccessor(String::NewSymbol("redComponent"), GetDoubleProperty);
instanceTemplate->SetAccessor(String::NewSymbol("blueComponent"), GetDoubleProperty);
instanceTemplate->SetAccessor(String::NewSymbol("greenComponent"), GetDoubleProperty);
- instanceTemplate->SetAccessor(String::NewSymbol("whiteComponent"), GetDoubleProperty);
- instanceTemplate->SetAccessor(String::NewSymbol("blackComponent"), GetDoubleProperty);
+ instanceTemplate->SetAccessor(String::NewSymbol("whiteComponent"), GetWhiteComponent);
+ instanceTemplate->SetAccessor(String::NewSymbol("blackComponent"), GetBlackComponent);
instanceTemplate->SetAccessor(String::NewSymbol("alphaComponent"), GetDoubleProperty);
// ad shortcuts (just aliases)
instanceTemplate->SetAccessor(String::NewSymbol("r"), GetDoubleProperty);
instanceTemplate->SetAccessor(String::NewSymbol("b"), GetDoubleProperty);
instanceTemplate->SetAccessor(String::NewSymbol("g"), GetDoubleProperty);
- instanceTemplate->SetAccessor(String::NewSymbol("w"), GetDoubleProperty);
+ instanceTemplate->SetAccessor(String::NewSymbol("w"), GetWhiteComponent);
instanceTemplate->SetAccessor(String::NewSymbol("a"), GetDoubleProperty);
return objectTemplate;
}
diff --git a/jmx/jmx-Prefix.pch b/jmx/jmx-Prefix.pch
new file mode 100644
index 0000000..eb2007e
--- /dev/null
+++ b/jmx/jmx-Prefix.pch
@@ -0,0 +1,9 @@
+//
+// Prefix header
+//
+// The contents of this file are implicitly included at the beginning of every source file.
+//
+
+#ifdef __OBJC__
+ #import <Foundation/Foundation.h>
+#endif
diff --git a/jmx/jmx.1 b/jmx/jmx.1
new file mode 100644
index 0000000..6e8fd13
--- /dev/null
+++ b/jmx/jmx.1
@@ -0,0 +1,79 @@
+.\"Modified from man(1) of FreeBSD, the NetBSD mdoc.template, and mdoc.samples.
+.\"See Also:
+.\"man mdoc.samples for a complete listing of options
+.\"man mdoc for the short list of editing options
+.\"/usr/share/misc/mdoc.template
+.Dd 9/25/13 \" DATE
+.Dt jmx 1 \" Program name and manual section number
+.Os Darwin
+.Sh NAME \" Section Header - required - don't modify
+.Nm jmx,
+.\" The following lines are read in generating the apropos(man -k) database. Use only key
+.\" words here as the database is built based on the words here and in the .ND line.
+.Nm Other_name_for_same_program(),
+.Nm Yet another name for the same program.
+.\" Use .Nm macro to designate other names for the documented program.
+.Nd This line parsed for whatis database.
+.Sh SYNOPSIS \" Section Header - required - don't modify
+.Nm
+.Op Fl abcd \" [-abcd]
+.Op Fl a Ar path \" [-a path]
+.Op Ar file \" [file]
+.Op Ar \" [file ...]
+.Ar arg0 \" Underlined argument - use .Ar anywhere to underline
+arg2 ... \" Arguments
+.Sh DESCRIPTION \" Section Header - required - don't modify
+Use the .Nm macro to refer to your program throughout the man page like such:
+.Nm
+Underlining is accomplished with the .Ar macro like this:
+.Ar underlined text .
+.Pp \" Inserts a space
+A list of items with descriptions:
+.Bl -tag -width -indent \" Begins a tagged list
+.It item a \" Each item preceded by .It macro
+Description of item a
+.It item b
+Description of item b
+.El \" Ends the list
+.Pp
+A list of flags and their descriptions:
+.Bl -tag -width -indent \" Differs from above in tag removed
+.It Fl a \"-a flag as a list item
+Description of -a flag
+.It Fl b
+Description of -b flag
+.El \" Ends the list
+.Pp
+.\" .Sh ENVIRONMENT \" May not be needed
+.\" .Bl -tag -width "ENV_VAR_1" -indent \" ENV_VAR_1 is width of the string ENV_VAR_1
+.\" .It Ev ENV_VAR_1
+.\" Description of ENV_VAR_1
+.\" .It Ev ENV_VAR_2
+.\" Description of ENV_VAR_2
+.\" .El
+.Sh FILES \" File used or created by the topic of the man page
+.Bl -tag -width "/Users/joeuser/Library/really_long_file_name" -compact
+.It Pa /usr/share/file_name
+FILE_1 description
+.It Pa /Users/joeuser/Library/really_long_file_name
+FILE_2 description
+.El \" Ends the list
+.\" .Sh DIAGNOSTICS \" May not be needed
+.\" .Bl -diag
+.\" .It Diagnostic Tag
+.\" Diagnostic informtion here.
+.\" .It Diagnostic Tag
+.\" Diagnostic informtion here.
+.\" .El
+.Sh SEE ALSO
+.\" List links in ascending order by section, alphabetically within a section.
+.\" Please do not reference files that do not exist without filing a bug report
+.Xr a 1 ,
+.Xr b 1 ,
+.Xr c 1 ,
+.Xr a 2 ,
+.Xr b 2 ,
+.Xr a 3 ,
+.Xr b 3
+.\" .Sh BUGS \" Document known, unremedied bugs
+.\" .Sh HISTORY \" Document history if command behaves in a unique manner \ No newline at end of file
diff --git a/jmx/main.m b/jmx/main.m
new file mode 100644
index 0000000..6f0583f
--- /dev/null
+++ b/jmx/main.m
@@ -0,0 +1,32 @@
+//
+// main.m
+// jmx
+//
+// Created by Andrea Guzzo on 9/25/13.
+// Copyright (c) 2013 Dyne.org. All rights reserved.
+//
+
+#import <Cocoa/Cocoa.h>
+#import <JMXGlobals.h>
+#import <JMXApplication.h>
+#import <JMXScriptEntity.h>
+
+static JMXScriptEntity *scriptController = nil;
+
+int main(int argc, const char * argv[])
+{
+
+ @autoreleasepool {
+ JMXApplication *app =[[JMXApplication alloc] init];
+ openlog("JMX", LOG_PERROR, LOG_USER);
+ [app applicationWillFinishLaunching:[NSNotification notificationWithName:@"applicationWillFinishLaunching" object:nil]];
+ [app applicationDidFinishLaunching:[NSNotification notificationWithName:@"applicationDidFinishLaunching" object:nil]];
+ scriptController = [[JMXScriptEntity alloc] initWithName:@"scriptController"];
+ scriptController.active = YES;
+ [scriptController exec:@"echo('CIAO');"];
+ NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
+ [runLoop run];
+ }
+ return 0;
+}
+
diff --git a/node.js/lib/_third_party_main.js b/node.js/lib/_third_party_main.js
index 139597f..b5c718a 100644
--- a/node.js/lib/_third_party_main.js
+++ b/node.js/lib/_third_party_main.js
@@ -1,2 +1,37 @@
+var Module = require('module');
+
+// If -i or --interactive were passed, or stdin is a TTY.
+if (process._forceRepl || require('tty').isatty(0)) {
+ // REPL
+ var opts = {
+ useGlobal: true,
+ ignoreUndefined: false
+ };
+ if (parseInt(process.env['NODE_NO_READLINE'], 10)) {
+ opts.terminal = false;
+ }
+ if (parseInt(process.env['NODE_DISABLE_COLORS'], 10)) {
+ opts.useColors = false;
+ }
+ var repl = Module.requireRepl().start(opts);
+ repl.on('exit', function() {
+ process.exit();
+ });
+
+} else {
+ // Read all of stdin - execute it.
+ process.stdin.setEncoding('utf8');
+
+ var code = '';
+ process.stdin.on('data', function(d) {
+ code += d;
+ });
+
+ process.stdin.on('end', function() {
+ process._eval = code;
+ evalScript('[stdin]');
+ });
+}
+