├── .gitmodules ├── ExampleBridge.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ ├── xcshareddata │ │ └── ExampleBridge.xcscmblueprint │ └── xcuserdata │ │ └── xamd.xcuserdatad │ │ └── UserInterfaceState.xcuserstate └── xcuserdata │ └── xamd.xcuserdatad │ └── xcschemes │ ├── ExampleBridge.xcscheme │ └── xcschememanagement.plist └── ExampleBridge ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets └── AppIcon.appiconset │ └── Contents.json ├── EBUIManager.h ├── EBUIManager.m ├── Info.plist ├── MainMenu.xib ├── Source ├── ChakraProxy.h ├── ChakraProxy.mm ├── ChakraUtils.cpp ├── ChakraUtils.hpp ├── EBWindow.h └── EBWindow.m ├── main.js └── main.m /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "modules/ChakraCore"] 2 | path = modules/ChakraCore 3 | url = https://github.com/Microsoft/ChakraCore 4 | -------------------------------------------------------------------------------- /ExampleBridge.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A676F6AD1DB666F600992CEF /* libChakra.Jsrt.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A676F6AC1DB666F600992CEF /* libChakra.Jsrt.a */; }; 11 | A676F6AF1DB6672E00992CEF /* libChakra.Common.Core.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A676F6AE1DB6672E00992CEF /* libChakra.Common.Core.a */; }; 12 | A676F6B11DB6675500992CEF /* libChakra.Pal.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A676F6B01DB6675500992CEF /* libChakra.Pal.a */; }; 13 | A676F6B51DB667BD00992CEF /* libicudata.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A676F6B21DB667BD00992CEF /* libicudata.a */; }; 14 | A676F6B61DB667BD00992CEF /* libicui18n.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A676F6B31DB667BD00992CEF /* libicui18n.a */; }; 15 | A676F6BA1DB66E5700992CEF /* EBWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = A676F6B91DB66E5700992CEF /* EBWindow.m */; }; 16 | A676F6BD1DB66FBB00992CEF /* ChakraUtils.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A676F6BB1DB66FBB00992CEF /* ChakraUtils.cpp */; }; 17 | A676F6BF1DB7D05900992CEF /* libicuuc.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A676F6BE1DB7D05900992CEF /* libicuuc.a */; }; 18 | A676F6C21DB8077500992CEF /* main.js in Resources */ = {isa = PBXBuildFile; fileRef = A676F6C11DB8077500992CEF /* main.js */; }; 19 | A676F6C51DB8127E00992CEF /* EBUIManager.m in Sources */ = {isa = PBXBuildFile; fileRef = A676F6C41DB8127E00992CEF /* EBUIManager.m */; }; 20 | A6F463B41D99D0BF007E3240 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A6F463B31D99D0BF007E3240 /* AppDelegate.m */; }; 21 | A6F463B71D99D0BF007E3240 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A6F463B61D99D0BF007E3240 /* main.m */; }; 22 | A6F463C61D9C0757007E3240 /* ChakraProxy.mm in Sources */ = {isa = PBXBuildFile; fileRef = A6F463C51D9C0757007E3240 /* ChakraProxy.mm */; }; 23 | A6F463C81D9C085E007E3240 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = A6F463C71D9C085E007E3240 /* MainMenu.xib */; }; 24 | /* End PBXBuildFile section */ 25 | 26 | /* Begin PBXFileReference section */ 27 | A676F6AC1DB666F600992CEF /* libChakra.Jsrt.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libChakra.Jsrt.a; path = modules/ChakraCore/BuildLinux/Test/lib/Jsrt/libChakra.Jsrt.a; sourceTree = ""; }; 28 | A676F6AE1DB6672E00992CEF /* libChakra.Common.Core.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libChakra.Common.Core.a; path = modules/ChakraCore/BuildLinux/Test/lib/Common/Core/libChakra.Common.Core.a; sourceTree = ""; }; 29 | A676F6B01DB6675500992CEF /* libChakra.Pal.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libChakra.Pal.a; path = modules/ChakraCore/BuildLinux/Test/pal/src/libChakra.Pal.a; sourceTree = ""; }; 30 | A676F6B21DB667BD00992CEF /* libicudata.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libicudata.a; path = ../../../../usr/local/Cellar/icu4c/57.1/lib/libicudata.a; sourceTree = ""; }; 31 | A676F6B31DB667BD00992CEF /* libicui18n.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libicui18n.a; path = ../../../../usr/local/Cellar/icu4c/57.1/lib/libicui18n.a; sourceTree = ""; }; 32 | A676F6B41DB667BD00992CEF /* libicutu.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libicutu.a; path = ../../../../usr/local/Cellar/icu4c/57.1/lib/libicutu.a; sourceTree = ""; }; 33 | A676F6B81DB66E5700992CEF /* EBWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = EBWindow.h; path = Source/EBWindow.h; sourceTree = ""; }; 34 | A676F6B91DB66E5700992CEF /* EBWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = EBWindow.m; path = Source/EBWindow.m; sourceTree = ""; }; 35 | A676F6BB1DB66FBB00992CEF /* ChakraUtils.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ChakraUtils.cpp; path = Source/ChakraUtils.cpp; sourceTree = ""; }; 36 | A676F6BC1DB66FBB00992CEF /* ChakraUtils.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ChakraUtils.hpp; path = Source/ChakraUtils.hpp; sourceTree = ""; }; 37 | A676F6BE1DB7D05900992CEF /* libicuuc.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libicuuc.a; path = ../../../../usr/local/Cellar/icu4c/57.1/lib/libicuuc.a; sourceTree = ""; }; 38 | A676F6C11DB8077500992CEF /* main.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = main.js; path = ExampleBridge/main.js; sourceTree = ""; }; 39 | A676F6C31DB8127E00992CEF /* EBUIManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EBUIManager.h; sourceTree = ""; }; 40 | A676F6C41DB8127E00992CEF /* EBUIManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EBUIManager.m; sourceTree = ""; }; 41 | A6F463AF1D99D0BE007E3240 /* ExampleBridge.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ExampleBridge.app; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | A6F463B21D99D0BE007E3240 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 43 | A6F463B31D99D0BF007E3240 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 44 | A6F463B61D99D0BF007E3240 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 45 | A6F463BD1D99D0BF007E3240 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 46 | A6F463C41D9C0757007E3240 /* ChakraProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ChakraProxy.h; path = Source/ChakraProxy.h; sourceTree = ""; }; 47 | A6F463C51D9C0757007E3240 /* ChakraProxy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ChakraProxy.mm; path = Source/ChakraProxy.mm; sourceTree = ""; }; 48 | A6F463C71D9C085E007E3240 /* MainMenu.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MainMenu.xib; sourceTree = ""; }; 49 | /* End PBXFileReference section */ 50 | 51 | /* Begin PBXFrameworksBuildPhase section */ 52 | A6F463AC1D99D0BE007E3240 /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | A676F6B11DB6675500992CEF /* libChakra.Pal.a in Frameworks */, 57 | A676F6AF1DB6672E00992CEF /* libChakra.Common.Core.a in Frameworks */, 58 | A676F6AD1DB666F600992CEF /* libChakra.Jsrt.a in Frameworks */, 59 | A676F6B51DB667BD00992CEF /* libicudata.a in Frameworks */, 60 | A676F6B61DB667BD00992CEF /* libicui18n.a in Frameworks */, 61 | A676F6BF1DB7D05900992CEF /* libicuuc.a in Frameworks */, 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | /* End PBXFrameworksBuildPhase section */ 66 | 67 | /* Begin PBXGroup section */ 68 | A676F6AB1DB666F500992CEF /* Frameworks */ = { 69 | isa = PBXGroup; 70 | children = ( 71 | A676F6BE1DB7D05900992CEF /* libicuuc.a */, 72 | A676F6B21DB667BD00992CEF /* libicudata.a */, 73 | A676F6B31DB667BD00992CEF /* libicui18n.a */, 74 | A676F6B41DB667BD00992CEF /* libicutu.a */, 75 | A676F6B01DB6675500992CEF /* libChakra.Pal.a */, 76 | A676F6AE1DB6672E00992CEF /* libChakra.Common.Core.a */, 77 | A676F6AC1DB666F600992CEF /* libChakra.Jsrt.a */, 78 | ); 79 | name = Frameworks; 80 | sourceTree = ""; 81 | }; 82 | A676F6C01DB8075100992CEF /* Assets */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | A676F6C11DB8077500992CEF /* main.js */, 86 | ); 87 | name = Assets; 88 | sourceTree = ""; 89 | }; 90 | A6F463A61D99D0BE007E3240 = { 91 | isa = PBXGroup; 92 | children = ( 93 | A676F6C01DB8075100992CEF /* Assets */, 94 | A6F463B11D99D0BE007E3240 /* ExampleBridge */, 95 | A6F463B01D99D0BE007E3240 /* Products */, 96 | A676F6AB1DB666F500992CEF /* Frameworks */, 97 | ); 98 | sourceTree = ""; 99 | }; 100 | A6F463B01D99D0BE007E3240 /* Products */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | A6F463AF1D99D0BE007E3240 /* ExampleBridge.app */, 104 | ); 105 | name = Products; 106 | sourceTree = ""; 107 | }; 108 | A6F463B11D99D0BE007E3240 /* ExampleBridge */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | A6F463C31D9C073D007E3240 /* Source */, 112 | A6F463B21D99D0BE007E3240 /* AppDelegate.h */, 113 | A6F463B31D99D0BF007E3240 /* AppDelegate.m */, 114 | A6F463C71D9C085E007E3240 /* MainMenu.xib */, 115 | A6F463BD1D99D0BF007E3240 /* Info.plist */, 116 | A6F463B51D99D0BF007E3240 /* Supporting Files */, 117 | ); 118 | path = ExampleBridge; 119 | sourceTree = ""; 120 | }; 121 | A6F463B51D99D0BF007E3240 /* Supporting Files */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | A6F463B61D99D0BF007E3240 /* main.m */, 125 | ); 126 | name = "Supporting Files"; 127 | sourceTree = ""; 128 | }; 129 | A6F463C31D9C073D007E3240 /* Source */ = { 130 | isa = PBXGroup; 131 | children = ( 132 | A6F463C41D9C0757007E3240 /* ChakraProxy.h */, 133 | A6F463C51D9C0757007E3240 /* ChakraProxy.mm */, 134 | A676F6B81DB66E5700992CEF /* EBWindow.h */, 135 | A676F6B91DB66E5700992CEF /* EBWindow.m */, 136 | A676F6BB1DB66FBB00992CEF /* ChakraUtils.cpp */, 137 | A676F6BC1DB66FBB00992CEF /* ChakraUtils.hpp */, 138 | A676F6C31DB8127E00992CEF /* EBUIManager.h */, 139 | A676F6C41DB8127E00992CEF /* EBUIManager.m */, 140 | ); 141 | name = Source; 142 | sourceTree = ""; 143 | }; 144 | /* End PBXGroup section */ 145 | 146 | /* Begin PBXNativeTarget section */ 147 | A6F463AE1D99D0BE007E3240 /* ExampleBridge */ = { 148 | isa = PBXNativeTarget; 149 | buildConfigurationList = A6F463C01D99D0BF007E3240 /* Build configuration list for PBXNativeTarget "ExampleBridge" */; 150 | buildPhases = ( 151 | A6F463AB1D99D0BE007E3240 /* Sources */, 152 | A6F463AC1D99D0BE007E3240 /* Frameworks */, 153 | A6F463AD1D99D0BE007E3240 /* Resources */, 154 | ); 155 | buildRules = ( 156 | ); 157 | dependencies = ( 158 | ); 159 | name = ExampleBridge; 160 | productName = ExampleBridge; 161 | productReference = A6F463AF1D99D0BE007E3240 /* ExampleBridge.app */; 162 | productType = "com.apple.product-type.application"; 163 | }; 164 | /* End PBXNativeTarget section */ 165 | 166 | /* Begin PBXProject section */ 167 | A6F463A71D99D0BE007E3240 /* Project object */ = { 168 | isa = PBXProject; 169 | attributes = { 170 | LastUpgradeCheck = 0800; 171 | ORGANIZATIONNAME = oss; 172 | TargetAttributes = { 173 | A6F463AE1D99D0BE007E3240 = { 174 | CreatedOnToolsVersion = 8.0; 175 | ProvisioningStyle = Automatic; 176 | }; 177 | }; 178 | }; 179 | buildConfigurationList = A6F463AA1D99D0BE007E3240 /* Build configuration list for PBXProject "ExampleBridge" */; 180 | compatibilityVersion = "Xcode 3.2"; 181 | developmentRegion = English; 182 | hasScannedForEncodings = 0; 183 | knownRegions = ( 184 | en, 185 | Base, 186 | ); 187 | mainGroup = A6F463A61D99D0BE007E3240; 188 | productRefGroup = A6F463B01D99D0BE007E3240 /* Products */; 189 | projectDirPath = ""; 190 | projectRoot = ""; 191 | targets = ( 192 | A6F463AE1D99D0BE007E3240 /* ExampleBridge */, 193 | ); 194 | }; 195 | /* End PBXProject section */ 196 | 197 | /* Begin PBXResourcesBuildPhase section */ 198 | A6F463AD1D99D0BE007E3240 /* Resources */ = { 199 | isa = PBXResourcesBuildPhase; 200 | buildActionMask = 2147483647; 201 | files = ( 202 | A6F463C81D9C085E007E3240 /* MainMenu.xib in Resources */, 203 | A676F6C21DB8077500992CEF /* main.js in Resources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXResourcesBuildPhase section */ 208 | 209 | /* Begin PBXSourcesBuildPhase section */ 210 | A6F463AB1D99D0BE007E3240 /* Sources */ = { 211 | isa = PBXSourcesBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | A676F6BA1DB66E5700992CEF /* EBWindow.m in Sources */, 215 | A6F463C61D9C0757007E3240 /* ChakraProxy.mm in Sources */, 216 | A676F6C51DB8127E00992CEF /* EBUIManager.m in Sources */, 217 | A6F463B71D99D0BF007E3240 /* main.m in Sources */, 218 | A6F463B41D99D0BF007E3240 /* AppDelegate.m in Sources */, 219 | A676F6BD1DB66FBB00992CEF /* ChakraUtils.cpp in Sources */, 220 | ); 221 | runOnlyForDeploymentPostprocessing = 0; 222 | }; 223 | /* End PBXSourcesBuildPhase section */ 224 | 225 | /* Begin XCBuildConfiguration section */ 226 | A6F463BE1D99D0BF007E3240 /* Debug */ = { 227 | isa = XCBuildConfiguration; 228 | buildSettings = { 229 | ALWAYS_SEARCH_USER_PATHS = NO; 230 | CLANG_ANALYZER_NONNULL = YES; 231 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 232 | CLANG_CXX_LIBRARY = "libc++"; 233 | CLANG_ENABLE_MODULES = YES; 234 | CLANG_ENABLE_OBJC_ARC = YES; 235 | CLANG_WARN_BOOL_CONVERSION = YES; 236 | CLANG_WARN_CONSTANT_CONVERSION = YES; 237 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 238 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 239 | CLANG_WARN_EMPTY_BODY = YES; 240 | CLANG_WARN_ENUM_CONVERSION = YES; 241 | CLANG_WARN_INFINITE_RECURSION = YES; 242 | CLANG_WARN_INT_CONVERSION = YES; 243 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 244 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 245 | CLANG_WARN_UNREACHABLE_CODE = YES; 246 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 247 | CODE_SIGN_IDENTITY = "-"; 248 | COPY_PHASE_STRIP = NO; 249 | DEBUG_INFORMATION_FORMAT = dwarf; 250 | ENABLE_STRICT_OBJC_MSGSEND = YES; 251 | ENABLE_TESTABILITY = YES; 252 | GCC_C_LANGUAGE_STANDARD = gnu99; 253 | GCC_DYNAMIC_NO_PIC = NO; 254 | GCC_NO_COMMON_BLOCKS = YES; 255 | GCC_OPTIMIZATION_LEVEL = 0; 256 | GCC_PREPROCESSOR_DEFINITIONS = ( 257 | "DEBUG=1", 258 | "$(inherited)", 259 | ); 260 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 261 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 262 | GCC_WARN_UNDECLARED_SELECTOR = YES; 263 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 264 | GCC_WARN_UNUSED_FUNCTION = YES; 265 | GCC_WARN_UNUSED_VARIABLE = YES; 266 | MACOSX_DEPLOYMENT_TARGET = 10.12; 267 | MTL_ENABLE_DEBUG_INFO = YES; 268 | ONLY_ACTIVE_ARCH = YES; 269 | SDKROOT = macosx; 270 | }; 271 | name = Debug; 272 | }; 273 | A6F463BF1D99D0BF007E3240 /* Release */ = { 274 | isa = XCBuildConfiguration; 275 | buildSettings = { 276 | ALWAYS_SEARCH_USER_PATHS = NO; 277 | CLANG_ANALYZER_NONNULL = YES; 278 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 279 | CLANG_CXX_LIBRARY = "libc++"; 280 | CLANG_ENABLE_MODULES = YES; 281 | CLANG_ENABLE_OBJC_ARC = YES; 282 | CLANG_WARN_BOOL_CONVERSION = YES; 283 | CLANG_WARN_CONSTANT_CONVERSION = YES; 284 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 285 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 286 | CLANG_WARN_EMPTY_BODY = YES; 287 | CLANG_WARN_ENUM_CONVERSION = YES; 288 | CLANG_WARN_INFINITE_RECURSION = YES; 289 | CLANG_WARN_INT_CONVERSION = YES; 290 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 291 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 292 | CLANG_WARN_UNREACHABLE_CODE = YES; 293 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 294 | CODE_SIGN_IDENTITY = "-"; 295 | COPY_PHASE_STRIP = NO; 296 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 297 | ENABLE_NS_ASSERTIONS = NO; 298 | ENABLE_STRICT_OBJC_MSGSEND = YES; 299 | GCC_C_LANGUAGE_STANDARD = gnu99; 300 | GCC_NO_COMMON_BLOCKS = YES; 301 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 302 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 303 | GCC_WARN_UNDECLARED_SELECTOR = YES; 304 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 305 | GCC_WARN_UNUSED_FUNCTION = YES; 306 | GCC_WARN_UNUSED_VARIABLE = YES; 307 | MACOSX_DEPLOYMENT_TARGET = 10.12; 308 | MTL_ENABLE_DEBUG_INFO = NO; 309 | SDKROOT = macosx; 310 | }; 311 | name = Release; 312 | }; 313 | A6F463C11D99D0BF007E3240 /* Debug */ = { 314 | isa = XCBuildConfiguration; 315 | buildSettings = { 316 | COMBINE_HIDPI_IMAGES = YES; 317 | HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/modules/ChakraCore/lib/Jsrt/**"; 318 | INFOPLIST_FILE = ExampleBridge/Info.plist; 319 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 320 | LIBRARY_SEARCH_PATHS = ( 321 | /usr/local/Cellar/icu4c/57.1/lib, 322 | /usr/local/opt/icu4c/lib, 323 | "$(PROJECT_DIR)/modules/ChakraCore/BuildLinux/Test/lib/Common/Core", 324 | "$(PROJECT_DIR)/modules/ChakraCore/BuildLinux/Test/lib/Jsrt", 325 | "$(PROJECT_DIR)/modules/ChakraCore/BuildLinux/Test/pal/src", 326 | ); 327 | PRODUCT_BUNDLE_IDENTIFIER = com.oss.ExampleBridge; 328 | PRODUCT_NAME = "$(TARGET_NAME)"; 329 | }; 330 | name = Debug; 331 | }; 332 | A6F463C21D99D0BF007E3240 /* Release */ = { 333 | isa = XCBuildConfiguration; 334 | buildSettings = { 335 | COMBINE_HIDPI_IMAGES = YES; 336 | HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/modules/ChakraCore/lib/Jsrt/**"; 337 | INFOPLIST_FILE = ExampleBridge/Info.plist; 338 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 339 | LIBRARY_SEARCH_PATHS = ( 340 | /usr/local/Cellar/icu4c/57.1/lib, 341 | /usr/local/opt/icu4c/lib, 342 | "$(PROJECT_DIR)/modules/ChakraCore/BuildLinux/Test/lib/Common/Core", 343 | "$(PROJECT_DIR)/modules/ChakraCore/BuildLinux/Test/lib/Jsrt", 344 | "$(PROJECT_DIR)/modules/ChakraCore/BuildLinux/Test/pal/src", 345 | ); 346 | PRODUCT_BUNDLE_IDENTIFIER = com.oss.ExampleBridge; 347 | PRODUCT_NAME = "$(TARGET_NAME)"; 348 | }; 349 | name = Release; 350 | }; 351 | /* End XCBuildConfiguration section */ 352 | 353 | /* Begin XCConfigurationList section */ 354 | A6F463AA1D99D0BE007E3240 /* Build configuration list for PBXProject "ExampleBridge" */ = { 355 | isa = XCConfigurationList; 356 | buildConfigurations = ( 357 | A6F463BE1D99D0BF007E3240 /* Debug */, 358 | A6F463BF1D99D0BF007E3240 /* Release */, 359 | ); 360 | defaultConfigurationIsVisible = 0; 361 | defaultConfigurationName = Release; 362 | }; 363 | A6F463C01D99D0BF007E3240 /* Build configuration list for PBXNativeTarget "ExampleBridge" */ = { 364 | isa = XCConfigurationList; 365 | buildConfigurations = ( 366 | A6F463C11D99D0BF007E3240 /* Debug */, 367 | A6F463C21D99D0BF007E3240 /* Release */, 368 | ); 369 | defaultConfigurationIsVisible = 0; 370 | defaultConfigurationName = Release; 371 | }; 372 | /* End XCConfigurationList section */ 373 | }; 374 | rootObject = A6F463A71D99D0BE007E3240 /* Project object */; 375 | } 376 | -------------------------------------------------------------------------------- /ExampleBridge.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ExampleBridge.xcodeproj/project.xcworkspace/xcshareddata/ExampleBridge.xcscmblueprint: -------------------------------------------------------------------------------- 1 | { 2 | "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "EC289E135D3E8762FCC0F816F606056C745CF5EC", 3 | "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : { 4 | 5 | }, 6 | "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : { 7 | "67F632D3CD46CA427A558600235E35D8E67DE6FA" : 9223372036854775807, 8 | "EC289E135D3E8762FCC0F816F606056C745CF5EC" : 9223372036854775807 9 | }, 10 | "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "A3E12499-7E09-4C15-A18C-8A54E877C0F4", 11 | "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : { 12 | "67F632D3CD46CA427A558600235E35D8E67DE6FA" : "ExampleBridge\/modules\/ChakraCore\/", 13 | "EC289E135D3E8762FCC0F816F606056C745CF5EC" : "ExampleBridge\/" 14 | }, 15 | "DVTSourceControlWorkspaceBlueprintNameKey" : "ExampleBridge", 16 | "DVTSourceControlWorkspaceBlueprintVersion" : 204, 17 | "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "ExampleBridge.xcodeproj", 18 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [ 19 | { 20 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Microsoft\/ChakraCore", 21 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 22 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "67F632D3CD46CA427A558600235E35D8E67DE6FA" 23 | }, 24 | { 25 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Kureev\/ExampleBridge", 26 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git", 27 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "EC289E135D3E8762FCC0F816F606056C745CF5EC" 28 | } 29 | ] 30 | } -------------------------------------------------------------------------------- /ExampleBridge.xcodeproj/project.xcworkspace/xcuserdata/xamd.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kureev/ExampleBridge/9a08d7b6d59fde39329c7ff7f7494757f504694f/ExampleBridge.xcodeproj/project.xcworkspace/xcuserdata/xamd.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /ExampleBridge.xcodeproj/xcuserdata/xamd.xcuserdatad/xcschemes/ExampleBridge.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /ExampleBridge.xcodeproj/xcuserdata/xamd.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ExampleBridge.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | A6F463AE1D99D0BE007E3240 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /ExampleBridge/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // ExampleBridge 4 | // 5 | // Created by Alexey Kureev on 26/09/2016. 6 | // Copyright © 2016 oss. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "ChakraProxy.h" 11 | #import "EBWindow.h" 12 | 13 | @interface AppDelegate : NSObject 14 | 15 | @property (nonatomic, retain) NSThread *jsvmThread; 16 | 17 | - (void)renderElementOfType:(NSString *)name size:(NSSize)size; 18 | 19 | @end 20 | 21 | -------------------------------------------------------------------------------- /ExampleBridge/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // ExampleBridge 4 | // 5 | // Created by Alexey Kureev on 26/09/2016. 6 | // Copyright © 2016 oss. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "EBUImanager.h" 11 | 12 | @interface AppDelegate () 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { 18 | _jsvmThread = [[NSThread alloc] initWithTarget:self 19 | selector:@selector(runJSVMThread) 20 | object:nil]; 21 | [_jsvmThread start]; 22 | } 23 | 24 | - (void)runJSVMThread { 25 | [[[ChakraProxy alloc] init] run]; 26 | 27 | NSRunLoop *runloop = [NSRunLoop currentRunLoop]; 28 | 29 | while (true) { 30 | [runloop runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]; 31 | } 32 | } 33 | 34 | - (void)renderElementOfType:(NSString *)name size:(NSSize)size { 35 | EBWindow *window = [[EBWindow alloc] init]; 36 | EBUIManager *manager = [EBUIManager sharedInstance]; 37 | [window openWithSize:NSMakeSize((CGFloat)size.width, (CGFloat)size.height)]; 38 | NSString *uuid = [[NSUUID UUID] UUIDString]; 39 | [manager addValue:window forKey:uuid]; 40 | } 41 | 42 | - (void)applicationWillTerminate:(NSNotification *)aNotification { 43 | // Insert code here to tear down your application 44 | } 45 | 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /ExampleBridge/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /ExampleBridge/EBUIManager.h: -------------------------------------------------------------------------------- 1 | // 2 | // EBUIManager.h 3 | // ExampleBridge 4 | // 5 | // Created by Alexey Kureev on 19/10/2016. 6 | // Copyright © 2016 oss. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface EBUIManager : NSObject 12 | 13 | + (instancetype)sharedInstance; 14 | - (void)addValue:(id)value forKey:(NSString *)key; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ExampleBridge/EBUIManager.m: -------------------------------------------------------------------------------- 1 | // 2 | // EBUIManager.m 3 | // ExampleBridge 4 | // 5 | // Created by Alexey Kureev on 19/10/2016. 6 | // Copyright © 2016 oss. All rights reserved. 7 | // 8 | 9 | #import "EBUIManager.h" 10 | 11 | @implementation EBUIManager 12 | 13 | NSMutableDictionary *registry; 14 | 15 | + (instancetype)sharedInstance { 16 | static EBUIManager *sharedInstance = nil; 17 | @synchronized (self) { 18 | if (!sharedInstance) { 19 | sharedInstance = [[self alloc] init]; 20 | registry = [NSMutableDictionary new]; 21 | } 22 | } 23 | return sharedInstance; 24 | } 25 | 26 | - (void)addValue:(id)value forKey:(NSString *)key { 27 | [registry setValue:value forKey:key]; 28 | } 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /ExampleBridge/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | Copyright © 2016 oss. All rights reserved. 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /ExampleBridge/MainMenu.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 312 | 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | 321 | 322 | 323 | 324 | 325 | 326 | 327 | 328 | 329 | 330 | 331 | 332 | 333 | 334 | 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | 344 | 345 | 346 | 347 | 348 | 349 | 350 | 351 | 352 | 353 | 354 | 355 | 356 | 357 | 358 | 359 | 360 | 361 | 362 | 363 | 364 | 365 | 366 | 367 | 368 | 369 | 370 | 371 | 372 | 373 | 374 | 375 | 376 | 377 | 378 | 379 | 380 | 381 | 382 | 383 | 384 | 385 | 386 | 387 | 388 | 389 | 390 | 391 | 392 | 393 | 394 | 395 | 396 | 397 | 398 | 399 | 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 | 448 | 449 | 450 | 451 | 452 | 453 | 454 | 455 | 456 | 457 | 458 | 459 | 460 | 461 | 462 | 463 | 464 | 465 | 466 | 467 | 468 | 469 | 470 | 471 | 472 | 473 | 474 | 475 | 476 | 477 | 478 | 479 | 480 | 481 | 482 | 483 | 484 | 485 | 486 | 487 | 488 | 489 | 490 | 491 | 492 | 493 | 494 | 495 | 496 | 497 | 498 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | 513 | 514 | 515 | 516 | 517 | 518 | 519 | 520 | 521 | 522 | 523 | 524 | 525 | 526 | 527 | 528 | 529 | 530 | 531 | 532 | 533 | 534 | Default 535 | 536 | 537 | 538 | 539 | 540 | 541 | Left to Right 542 | 543 | 544 | 545 | 546 | 547 | 548 | Right to Left 549 | 550 | 551 | 552 | 553 | 554 | 555 | 556 | 557 | 558 | 559 | Default 560 | 561 | 562 | 563 | 564 | 565 | 566 | Left to Right 567 | 568 | 569 | 570 | 571 | 572 | 573 | Right to Left 574 | 575 | 576 | 577 | 578 | 579 | 580 | 581 | 582 | 583 | 584 | 585 | 586 | 587 | 588 | 589 | 590 | 591 | 592 | 593 | 594 | 595 | 596 | 597 | 598 | 599 | 600 | 601 | 602 | 603 | 604 | 605 | 606 | 607 | 608 | 609 | 610 | 611 | 612 | 613 | 614 | 615 | 616 | 617 | 618 | 619 | 620 | 621 | 622 | 623 | 624 | 625 | 626 | 627 | 628 | 629 | 630 | 631 | 632 | 633 | 634 | 635 | 636 | 637 | 638 | 639 | 640 | 641 | 642 | 643 | 644 | 645 | 646 | 647 | 648 | 649 | 650 | 651 | 652 | 653 | 654 | 655 | 656 | 657 | 658 | 659 | 660 | 661 | 662 | 663 | 664 | 665 | 666 | 667 | 668 | 669 | 670 | 671 | 672 | 673 | 674 | 675 | 676 | 677 | 678 | 679 | 680 | -------------------------------------------------------------------------------- /ExampleBridge/Source/ChakraProxy.h: -------------------------------------------------------------------------------- 1 | // 2 | // ChakraProxy.h 3 | // ExampleBridge 4 | // 5 | // Created by Alexey Kureev on 28/09/2016. 6 | // Copyright © 2016 oss. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ChakraProxy : NSObject 12 | 13 | -(void)run; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ExampleBridge/Source/ChakraProxy.mm: -------------------------------------------------------------------------------- 1 | // 2 | // ChakraProxy.m 3 | // ExampleBridge 4 | // 5 | // Created by Alexey Kureev on 28/09/2016. 6 | // Copyright © 2016 oss. All rights reserved. 7 | // 8 | 9 | #import "ChakraProxy.h" 10 | #import "ChakraCore.h" 11 | #import "iostream" 12 | #import "EBWindow.h" 13 | #import "AppDelegate.h" 14 | #import "ChakraUtils.hpp" 15 | 16 | static JsRuntimeHandle runtime; 17 | static JsContextRef context; 18 | 19 | JsValueRef render(JsValueRef callee, bool isConstructCall, JsValueRef *arguments, unsigned short argumentCount, void *callbackState) { 20 | NSString *type = [NSString stringWithUTF8String:ChakraUtils::toString(arguments[1])]; 21 | double w {ChakraUtils::toDouble(arguments[2])}; 22 | double h {ChakraUtils::toDouble(arguments[3])}; 23 | 24 | dispatch_async(dispatch_get_main_queue(), ^{ 25 | id delegate = [[NSApplication sharedApplication] delegate]; 26 | 27 | [delegate renderElementOfType:type size:NSMakeSize((CGFloat)w, (CGFloat)h)]; 28 | }); 29 | 30 | return JS_INVALID_REFERENCE; 31 | } 32 | 33 | JsErrorCode SetupGlobalEnvironment() { 34 | JsValueRef globalObject; 35 | JsGetGlobalObject(&globalObject); 36 | 37 | JsValueRef bridgeObject; 38 | JsCreateObject(&bridgeObject); 39 | 40 | ChakraUtils::setObjectProperty(globalObject, "bridge", bridgeObject); 41 | ChakraUtils::setObjectFunctionProperty(bridgeObject, "render", render); 42 | 43 | return JsNoError; 44 | } 45 | 46 | @implementation ChakraProxy 47 | 48 | -(void)run { 49 | unsigned currentSourceContext = 0; 50 | 51 | // Read file from the bundle 52 | NSString *filepath = [[NSBundle mainBundle] pathForResource:@"main" ofType:@"js"]; 53 | NSError *error; 54 | NSString *fileContents = [NSString stringWithContentsOfFile:filepath encoding:NSUTF8StringEncoding error:&error]; 55 | 56 | if (error) 57 | NSLog(@"Error reading file: %@", error.localizedDescription); 58 | 59 | // Your script; try replace hello-world with something else 60 | const char *script = [fileContents cStringUsingEncoding:NSASCIIStringEncoding]; 61 | 62 | // Create a runtime 63 | JsCreateRuntime(JsRuntimeAttributeNone, nullptr, &runtime); 64 | 65 | // Create a context 66 | JsCreateContext(runtime, &context); 67 | JsSetCurrentContext(context); 68 | 69 | // Add global environment to runtime and patch it by "bridge" hosted object 70 | SetupGlobalEnvironment(); 71 | 72 | // Run the script. 73 | JsRunScriptUtf8(script, currentSourceContext++, "", nullptr); 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /ExampleBridge/Source/ChakraUtils.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // ChakraUtils.cpp 3 | // ExampleBridge 4 | // 5 | // Created by Alexey Kureev on 18/10/2016. 6 | // Copyright © 2016 oss. All rights reserved. 7 | // 8 | 9 | #include "ChakraUtils.hpp" 10 | // 11 | // ChakraUtils.cpp 12 | // GoldenGate 13 | // 14 | // Created by Alexey Kureev on 19/09/16. 15 | // Copyright © 2016 oss. All rights reserved. 16 | // 17 | 18 | #include "ChakraUtils.hpp" 19 | 20 | namespace ChakraUtils { 21 | int getObjectIntProperty(const JsValueRef &object, const char *name) { 22 | JsPropertyIdRef valueIR; 23 | JsGetPropertyIdFromNameUtf8(name, &valueIR); 24 | JsValueRef valueVR; 25 | int value; 26 | JsGetProperty(object, valueIR, &valueVR); 27 | JsNumberToInt(valueVR, &value); 28 | return value; 29 | } 30 | 31 | const char *toString(JsValueRef ref) { 32 | JsValueRef msg; 33 | JsConvertValueToString(ref, &msg); 34 | char *msg_str; 35 | size_t length; 36 | JsStringToPointerUtf8Copy(msg, &msg_str, &length); 37 | return msg_str; 38 | } 39 | 40 | double toDouble(JsValueRef ref) { 41 | double value; 42 | JsNumberToDouble(ref, &value); 43 | return value; 44 | } 45 | 46 | JsValueRef toObject(JsValueRef ref) { 47 | JsValueRef vref; 48 | JsConvertValueToObject(ref, &vref); 49 | return vref; 50 | } 51 | 52 | void setObjectProperty(const JsValueRef &object, const char *name, const JsValueRef &value) { 53 | JsPropertyIdRef propertyId; 54 | JsGetPropertyIdFromNameUtf8(name, &propertyId); 55 | JsSetProperty(object, propertyId, value, true); 56 | } 57 | 58 | void setObjectFunctionProperty(const JsValueRef &object, const char *name, JsNativeFunction fn) { 59 | JsValueRef vref; 60 | JsCreateFunction(fn, nullptr, &vref); 61 | 62 | JsPropertyIdRef propertyId; 63 | JsGetPropertyIdFromNameUtf8(name, &propertyId); 64 | JsSetProperty(object, propertyId, vref, true); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /ExampleBridge/Source/ChakraUtils.hpp: -------------------------------------------------------------------------------- 1 | // 2 | // ChakraUtils.hpp 3 | // ExampleBridge 4 | // 5 | // Created by Alexey Kureev on 18/10/2016. 6 | // Copyright © 2016 oss. All rights reserved. 7 | // 8 | 9 | #ifndef ChakraUtils_hpp 10 | #define ChakraUtils_hpp 11 | 12 | #include "ChakraCore.h" 13 | #include 14 | 15 | namespace ChakraUtils { 16 | int getObjectIntProperty(const JsValueRef &object, const char *name); 17 | void setObjectProperty(const JsValueRef &object, const char *name, const JsValueRef &value); 18 | void setObjectFunctionProperty(const JsValueRef &object, const char *name, JsNativeFunction fn); 19 | const char *toString(JsValueRef ref); 20 | double toDouble(JsValueRef ref); 21 | 22 | JsValueRef toObject(JsValueRef ref); 23 | }; 24 | 25 | #endif /* ChakraUtils_hpp */ 26 | -------------------------------------------------------------------------------- /ExampleBridge/Source/EBWindow.h: -------------------------------------------------------------------------------- 1 | // 2 | // EBWindow.h 3 | // ExampleBridge 4 | // 5 | // Created by Alexey Kureev on 18/10/2016. 6 | // Copyright © 2016 oss. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface EBWindow : NSObject 13 | 14 | @property (nonatomic, copy) NSWindow *window; 15 | 16 | -(void)openWithSize:(NSSize)dimensions; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ExampleBridge/Source/EBWindow.m: -------------------------------------------------------------------------------- 1 | // 2 | // EBWindow.m 3 | // ExampleBridge 4 | // 5 | // Created by Alexey Kureev on 18/10/2016. 6 | // Copyright © 2016 oss. All rights reserved. 7 | // 8 | 9 | #import "EBWindow.h" 10 | 11 | @implementation EBWindow 12 | 13 | -(void)openWithSize:(NSSize)dimensions { 14 | NSInteger mask = 0b1111; 15 | 16 | _window = [[NSWindow alloc] 17 | initWithContentRect:NSMakeRect(100, 100, dimensions.width, dimensions.height) 18 | styleMask:mask 19 | backing:NSBackingStoreBuffered 20 | defer:NO]; 21 | 22 | [_window makeKeyAndOrderFront:NSApp]; 23 | [NSApp activateIgnoringOtherApps:YES]; 24 | } 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /ExampleBridge/main.js: -------------------------------------------------------------------------------- 1 | bridge.render('Window', 400, 400); 2 | -------------------------------------------------------------------------------- /ExampleBridge/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ExampleBridge 4 | // 5 | // Created by Alexey Kureev on 26/09/2016. 6 | // Copyright © 2016 oss. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) { 12 | return NSApplicationMain(argc, argv); 13 | } 14 | --------------------------------------------------------------------------------