Skip to content

Commit c19934a

Browse files
committed
Misc cleanup
1 parent f74a301 commit c19934a

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/runtime.js

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
const objc_super_typeEncoding = '{objc_super="receiver"@"super_class"#}';
2+
13
// You can store this to call your function. this must be bound to the current instance.
24
export function SuperCall(selector, argTypes, returnType) {
35
const func = CFunc("objc_msgSendSuper", [{type: '^' + objc_super_typeEncoding}, {type: ":"}, ...argTypes], returnType);
@@ -25,12 +27,11 @@ function makeStruct(def) {
2527
return structure;
2628
}
2729

28-
const objc_super_typeEncoding = '{objc_super="receiver"@"super_class"#}';
2930
function make_objc_super(self, cls) {
3031
return makeStruct({
3132
objc_super:{
32-
receiver:self,
33-
super_class: cls,
33+
receiver:self,
34+
super_class: cls,
3435
},
3536
});
3637
}
@@ -75,16 +76,16 @@ function addStructToBridgeSupport(key, structDef) {
7576
// OK, so this is probably the nastiest hack in this file.
7677
// We go modify MOBridgeSupportController behind its back and use kvc to add our own definition
7778
// There isn't another API for this though. So the only other way would be to make a real bridgesupport file.
79+
const symbols = MOBridgeSupportController.sharedController().valueForKey('symbols');
80+
if (!symbols) throw Error("Something has changed within bridge support so we can't add our definitions");
81+
// If someone already added this definition, don't re-register it.
82+
if (symbols[key] !== null) return;
7883
const def = MOBridgeSupportStruct.alloc().init();
7984
setKeys(def, {
80-
name: key,
81-
type: structDef.type,
85+
name: key,
86+
type: structDef.type,
8287
});
83-
log("adding def: " + def);
84-
85-
const symbols = MOBridgeSupportController.sharedController().valueForKey('symbols');
86-
if (!symbols) throw Error("Something has changed within bridge support so we can't add our definitions");
87-
symbols[NSString.stringWithString(key)] = def;
88+
symbols[key] = def;
8889
};
8990

9091
// This assumes the ivar is an object type. Return value is pretty useless.

0 commit comments

Comments
 (0)