|
| 1 | +const objc_super_typeEncoding = '{objc_super="receiver"@"super_class"#}'; |
| 2 | + |
1 | 3 | // You can store this to call your function. this must be bound to the current instance. |
2 | 4 | export function SuperCall(selector, argTypes, returnType) { |
3 | 5 | const func = CFunc("objc_msgSendSuper", [{type: '^' + objc_super_typeEncoding}, {type: ":"}, ...argTypes], returnType); |
@@ -25,12 +27,11 @@ function makeStruct(def) { |
25 | 27 | return structure; |
26 | 28 | } |
27 | 29 |
|
28 | | -const objc_super_typeEncoding = '{objc_super="receiver"@"super_class"#}'; |
29 | 30 | function make_objc_super(self, cls) { |
30 | 31 | return makeStruct({ |
31 | 32 | objc_super:{ |
32 | | - receiver:self, |
33 | | - super_class: cls, |
| 33 | + receiver:self, |
| 34 | + super_class: cls, |
34 | 35 | }, |
35 | 36 | }); |
36 | 37 | } |
@@ -75,16 +76,16 @@ function addStructToBridgeSupport(key, structDef) { |
75 | 76 | // OK, so this is probably the nastiest hack in this file. |
76 | 77 | // We go modify MOBridgeSupportController behind its back and use kvc to add our own definition |
77 | 78 | // 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; |
78 | 83 | const def = MOBridgeSupportStruct.alloc().init(); |
79 | 84 | setKeys(def, { |
80 | | - name: key, |
81 | | - type: structDef.type, |
| 85 | + name: key, |
| 86 | + type: structDef.type, |
82 | 87 | }); |
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; |
88 | 89 | }; |
89 | 90 |
|
90 | 91 | // This assumes the ivar is an object type. Return value is pretty useless. |
|
0 commit comments