Skip to content
This repository was archived by the owner on Feb 6, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 8 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
{
"name": "cocoascript-class",
"version": "0.1.0",
"description": "Lets you create real ObjC classes in cocoascript so you can implement delegates, subclass builtin types, etc",
"name": "cocoascript-class-babel-safe",
"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/darknoon/cocoascript-class",
"repository": "https://github.com/atlassian/cocoascript-class",
"author": "Andrew Pouliot <andrew@darknoon.com>",
"contributors": [
"Tim Pettersen <tim@atlassian.com>"
],
"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"
}
}
7 changes: 5 additions & 2 deletions src/runtime.js
Original file line number Diff line number Diff line change
@@ -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(', ')})`)
};
}

Expand Down