Support interop modularity

* Add list of included headers into the manifest
* Implement importing "foreign" type declarations
* Implement forward declarations more natively in the compiler
* Represent Objective-C categories as Kotlin extension methods and
  properties

Also:
* Do some refactoring in stub generation
* Call bridges directly in stubs for Objective-C properties
This commit is contained in:
Svyatoslav Scherbina
2017-09-04 16:14:32 +03:00
committed by SvyatoslavScherbina
parent 82b2b76c09
commit 79455c5161
28 changed files with 1410 additions and 390 deletions
+1 -1
View File
@@ -2,7 +2,7 @@ import sysstat.*
import kotlinx.cinterop.*
fun main(args: Array<String>) {
val statBuf = nativeHeap.alloc<statStruct>()
val statBuf = nativeHeap.alloc<stat>()
val res = stat("/", statBuf.ptr)
println(res)
println(statBuf.st_uid)
+4 -1
View File
@@ -7,10 +7,13 @@
@interface Foo : NSObject
@property NSString* name;
-(void)hello;
-(void)helloWithPrinter:(id <Printer>)printer;
@end;
@interface Foo (FooExtensions)
-(void)hello;
@end;
@protocol MutablePair
@required
@property (readonly) int first;
+8 -5
View File
@@ -24,11 +24,6 @@
return self;
}
-(void)hello {
CPrinter* printer = [[CPrinter alloc] init];
[self helloWithPrinter:printer];
}
-(void)helloWithPrinter:(id <Printer>)printer {
NSString* message = [NSString stringWithFormat:@"Hello, %@!", self.name];
[printer print:message.UTF8String];
@@ -40,6 +35,14 @@
@end;
@implementation Foo (FooExtensions)
-(void)hello {
CPrinter* printer = [[CPrinter alloc] init];
[self helloWithPrinter:printer];
}
@end;
void replacePairElements(id <MutablePair> pair, int first, int second) {
[pair update:0 add:(first - pair.first)];
[pair update:1 sub:(pair.second - second)];