From d199a7097935842dc1f165724ac7f9b5e49291d0 Mon Sep 17 00:00:00 2001 From: Tim Pettersen Date: Wed, 13 Sep 2017 16:05:22 +1000 Subject: [PATCH 1/3] Replace spread operator with eval() to allow safe transpilation to ES5 --- src/runtime.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/runtime.js b/src/runtime.js index d3eeff4..072c304 100644 --- a/src/runtime.js +++ b/src/runtime.js @@ -1,10 +1,13 @@ // You can store this to call your function. this must be bound to the current instance. export function SuperCall(selector, argTypes, returnType) { const func = CFunc("objc_msgSendSuper", [{type: '^' + objc_super_typeEncoding}, {type: ":"}, ...argTypes], returnType); - return function(...args) { + return function() { const struct = make_objc_super(this, this.superclass()); const structPtr = MOPointer.alloc().initWithValue_(struct); - return func(structPtr, selector, ...args); + const params = ['structPtr', 'selector'].concat( + [].slice.apply(arguments).map((val, i) => `arguments[${i}]`) + ) + return eval(`func(${params.join(', ')})`) }; } From e5786fdc7ac8ea717959b69370e95c3c1e5b95ee Mon Sep 17 00:00:00 2001 From: Tim Pettersen Date: Thu, 14 Sep 2017 22:14:50 +1000 Subject: [PATCH 2/3] Update package.json for (hopefully temporary) fork --- package.json | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 4f347d5..0c80dd0 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,19 @@ { - "name": "cocoascript-class", + "name": "cocoascript-class-babel-safe", "version": "0.1.0", - "description": "Lets you create real ObjC classes in cocoascript so you can implement delegates, subclass builtin types, etc", + "description": "A fork of cocoascript-class that can be safely transpiled to ES5", "main": "lib/index.js", - "repository": "https://github.com/darknoon/cocoascript-class", + "repository": "https://github.com/atlassian/cocoascript-class", "author": "Andrew Pouliot ", + "contributors": [ + "Tim Pettersen " + ], "scripts": { "build": "babel src -d lib" }, "license": "MIT", "devDependencies": { - "babel": "^6.23.0", - "babel-cli": "^6.24.0", + "babel-cli": "^6.26.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.24.0" } } From 4940a623481a94421043b06281a4cd4a94e9d824 Mon Sep 17 00:00:00 2001 From: Tim Pettersen Date: Thu, 14 Sep 2017 22:20:13 +1000 Subject: [PATCH 3/3] Update README.md with reason for fork --- README.md | 5 ++++- package.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6ee9889..ccd7f81 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -# cocoascript-class +# cocoascript-class-babel-safe + +**This is a (hopefully temporary) fork of `cocoascript-class` that can be safely transpiled to ES5.** + Lets you create real ObjC classes in cocoascript so you can implement delegates, subclass builtin types, etc ## Installation diff --git a/package.json b/package.json index 0c80dd0..d5232d0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cocoascript-class-babel-safe", - "version": "0.1.0", + "version": "0.1.1", "description": "A fork of cocoascript-class that can be safely transpiled to ES5", "main": "lib/index.js", "repository": "https://github.com/atlassian/cocoascript-class",