Support importing string literal macros with cinterop
This commit is contained in:
committed by
SvyatoslavScherbina
parent
4335f891b7
commit
e035ac1022
@@ -0,0 +1,14 @@
|
||||
---
|
||||
#define ZERO 0
|
||||
#define ONE 1
|
||||
#define MAX_LONG 9223372036854775807
|
||||
#define FOO_STRING "foo"
|
||||
// This one should be ignored:
|
||||
#define WIDE_FOO_STRING L"foo"
|
||||
#define FOURTY_TWO 42
|
||||
#define SEVENTEEN ((long long) 17)
|
||||
#define ONE_POINT_ZERO 1.0
|
||||
#define ONE_POINT_FIVE 1.5f
|
||||
|
||||
#define BAD1 bar
|
||||
#define BAD2 5;
|
||||
@@ -0,0 +1,19 @@
|
||||
import kotlin.test.*
|
||||
import cmacros.*
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
assertEquals("foo", FOO_STRING)
|
||||
assertEquals(0, ZERO)
|
||||
assertEquals(1, ONE)
|
||||
assertEquals(Long.MAX_VALUE, MAX_LONG)
|
||||
assertEquals(42, FOURTY_TWO)
|
||||
|
||||
val seventeen: Long = SEVENTEEN
|
||||
assertEquals(17L, seventeen)
|
||||
|
||||
val onePointFive: Float = ONE_POINT_FIVE
|
||||
val onePointZero: Double = ONE_POINT_ZERO
|
||||
|
||||
assertEquals(1.5f, onePointFive)
|
||||
assertEquals(1.0, onePointZero)
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
#import <objc/NSObject.h>
|
||||
#import <CoreFoundation/CoreFoundation.h>
|
||||
|
||||
@class Foo;
|
||||
|
||||
@@ -57,3 +58,6 @@ extern NSString* globalString;
|
||||
extern NSObject* globalObject;
|
||||
|
||||
int formatStringLength(NSString* format, ...);
|
||||
|
||||
#define STRING_MACRO @"String macro"
|
||||
#define CFSTRING_MACRO CFSTR("CFString macro")
|
||||
|
||||
@@ -62,6 +62,9 @@ fun run() {
|
||||
println(globalObject)
|
||||
|
||||
println(formatStringLength("%d %d", 42, 17))
|
||||
|
||||
println(STRING_MACRO)
|
||||
println(CFSTRING_MACRO)
|
||||
}
|
||||
|
||||
fun MutablePairProtocol.swap() {
|
||||
|
||||
Reference in New Issue
Block a user