Open dcharkes opened 4 months ago
That might be possible, but it's not just a matter of name mangling. In C++, a static method in a class is really just a top-level function under the hood (with exactly the same signature). But in ObjC, a static method in a class is really an instance method in the class object.
So whether it's possible depends on details of the ObjC ABI that I haven't investigated yet. The question is, what's the signature of the C function backing + (instancetype)newWithCounter:(int32_t*) _counter;
? I could plausibly see it being any of:
StaticFuncTestObj *newWithCounter(int32_t* _counter);
StaticFuncTestObj *newWithCounter(Class* receiver, int32_t* _counter);
StaticFuncTestObj *newWithCounter(Class* receiver, SEL selector, int32_t* _counter);
When using
With toplevel methods in Objective-C we directly invoke via an
@Native
But if I change it to a static method on an interface we get a reflective implementation, that does dynamic symbol lookup.
@liamappelbe Is it needed that we do something reflective here? Or can we use a
@Native
here as well? If we'd want to do that, we'd have to deal with the name mangling?Or are there other reasons why we can't do this?
This would be mostly for performance reasons. For tree-shaking, we would generate different annotations anyway (https://github.com/dart-lang/native/issues/1099).