[K/N][runtime] Extracted compiler interface from native runtime
This commit is contained in:
@@ -113,6 +113,10 @@ bitcode {
|
|||||||
onlyIf { targetSupportsLibBacktrace(target.name) }
|
onlyIf { targetSupportsLibBacktrace(target.name) }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module("compiler_interface") {
|
||||||
|
headersDirs.from(files("src/main/cpp"))
|
||||||
|
}
|
||||||
|
|
||||||
module("launcher") {
|
module("launcher") {
|
||||||
headersDirs.from(files("src/main/cpp"))
|
headersDirs.from(files("src/main/cpp"))
|
||||||
}
|
}
|
||||||
@@ -344,7 +348,7 @@ targetList.forEach { targetName ->
|
|||||||
|
|
||||||
from(project.buildDir.resolve("stdlib/${hostName}/stdlib"))
|
from(project.buildDir.resolve("stdlib/${hostName}/stdlib"))
|
||||||
from(project.buildDir.resolve("bitcode/main/$targetName")) {
|
from(project.buildDir.resolve("bitcode/main/$targetName")) {
|
||||||
include("runtime.bc")
|
include("runtime.bc", "compiler_interface.bc")
|
||||||
into("default/targets/$targetName/native")
|
into("default/targets/$targetName/native")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "TypeInfo.h"
|
||||||
|
#include "Memory.h"
|
||||||
|
#include "Types.h"
|
||||||
|
#include "Runtime.h"
|
||||||
|
#include "Exceptions.h"
|
||||||
|
#include "MemorySharedRefs.hpp"
|
||||||
|
|
||||||
|
#define touchType(type) void touch##type(type*) {}
|
||||||
|
#define touchFunction(function) void* touch##function() { return reinterpret_cast<void*>(&::function); }
|
||||||
|
|
||||||
|
// Types and functions used by the compiler (at Runtime.kt and ContextUtils.kt)
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
touchType(TypeInfo)
|
||||||
|
touchType(ExtendedTypeInfo)
|
||||||
|
touchType(InterfaceTableRecord)
|
||||||
|
touchType(AssociatedObjectTableRecord)
|
||||||
|
|
||||||
|
touchType(ObjHeader)
|
||||||
|
touchType(ArrayHeader)
|
||||||
|
touchType(FrameOverlay)
|
||||||
|
|
||||||
|
touchType(KRefSharedHolder)
|
||||||
|
|
||||||
|
touchFunction(AllocInstance)
|
||||||
|
touchFunction(AllocArrayInstance)
|
||||||
|
touchFunction(InitThreadLocalSingleton)
|
||||||
|
touchFunction(InitSingleton)
|
||||||
|
touchFunction(InitAndRegisterGlobal)
|
||||||
|
touchFunction(UpdateHeapRef)
|
||||||
|
touchFunction(UpdateStackRef)
|
||||||
|
touchFunction(UpdateReturnRef)
|
||||||
|
touchFunction(ZeroHeapRef)
|
||||||
|
touchFunction(ZeroArrayRefs)
|
||||||
|
|
||||||
|
touchFunction(EnterFrame)
|
||||||
|
touchFunction(LeaveFrame)
|
||||||
|
touchFunction(SetCurrentFrame)
|
||||||
|
touchFunction(CheckCurrentFrame)
|
||||||
|
|
||||||
|
touchFunction(MutationCheck)
|
||||||
|
touchFunction(CheckLifetimesConstraint)
|
||||||
|
touchFunction(FreezeSubgraph)
|
||||||
|
touchFunction(CheckGlobalsAccessible)
|
||||||
|
|
||||||
|
touchFunction(LookupInterfaceTableRecord)
|
||||||
|
touchFunction(IsInstance)
|
||||||
|
touchFunction(IsInstanceOfClassFast)
|
||||||
|
|
||||||
|
touchFunction(ThrowException)
|
||||||
|
touchFunction(Kotlin_getExceptionObject)
|
||||||
|
|
||||||
|
touchFunction(AppendToInitializersTail)
|
||||||
|
touchFunction(CallInitGlobalPossiblyLock)
|
||||||
|
touchFunction(CallInitThreadLocal)
|
||||||
|
|
||||||
|
touchFunction(AddTLSRecord)
|
||||||
|
touchFunction(LookupTLS)
|
||||||
|
|
||||||
|
touchFunction(Kotlin_initRuntimeIfNeeded)
|
||||||
|
|
||||||
|
touchFunction(KRefSharedHolder_initLocal)
|
||||||
|
touchFunction(KRefSharedHolder_init)
|
||||||
|
touchFunction(KRefSharedHolder_dispose)
|
||||||
|
touchFunction(KRefSharedHolder_ref)
|
||||||
|
|
||||||
|
touchFunction(Kotlin_mm_switchThreadStateNative)
|
||||||
|
touchFunction(Kotlin_mm_switchThreadStateRunnable)
|
||||||
|
touchFunction(Kotlin_mm_safePointFunctionPrologue)
|
||||||
|
touchFunction(Kotlin_mm_safePointWhileLoopBody)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} // extern "C"
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if KONAN_OBJC_INTEROP
|
||||||
|
|
||||||
|
#include "ObjCInterop.h"
|
||||||
|
#include "ObjCInteropUtils.h"
|
||||||
|
#include "ObjCExport.h"
|
||||||
|
#include "ObjCExportErrors.h"
|
||||||
|
#include "ObjCExportCoroutines.h"
|
||||||
|
|
||||||
|
#define touchType(type) void touch##type(type*) {}
|
||||||
|
#define touchFunction(function) void* touch##function() { return reinterpret_cast<void*>(&::function); }
|
||||||
|
|
||||||
|
// Types and functions used by the compiler (at Runtime.kt and ContextUtils.kt)
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
touchType(WritableTypeInfo)
|
||||||
|
touchType(KotlinObjCClassData)
|
||||||
|
touchType(KotlinObjCClassInfo)
|
||||||
|
touchType(ObjCMethodDescription)
|
||||||
|
touchType(ObjCTypeAdapter)
|
||||||
|
touchType(ObjCToKotlinMethodAdapter)
|
||||||
|
touchType(KotlinToObjCMethodAdapter)
|
||||||
|
touchType(TypeInfoObjCExportAddition)
|
||||||
|
|
||||||
|
touchType(Block_literal_1)
|
||||||
|
touchType(Block_descriptor_1)
|
||||||
|
|
||||||
|
NSString* touchNSString() { return [[NSString alloc] init]; }
|
||||||
|
|
||||||
|
touchFunction(CreateKotlinObjCClass)
|
||||||
|
touchFunction(GetObjCKotlinTypeInfo)
|
||||||
|
touchFunction(MissingInitImp)
|
||||||
|
|
||||||
|
touchFunction(Kotlin_Interop_DoesObjectConformToProtocol)
|
||||||
|
touchFunction(Kotlin_Interop_IsObjectKindOfClass)
|
||||||
|
|
||||||
|
touchFunction(Kotlin_ObjCExport_refToLocalObjC)
|
||||||
|
touchFunction(Kotlin_ObjCExport_refToRetainedObjC)
|
||||||
|
touchFunction(Kotlin_ObjCExport_refFromObjC)
|
||||||
|
touchFunction(Kotlin_ObjCExport_CreateRetainedNSStringFromKString)
|
||||||
|
touchFunction(Kotlin_ObjCExport_convertUnitToRetained)
|
||||||
|
touchFunction(Kotlin_ObjCExport_GetAssociatedObject)
|
||||||
|
touchFunction(Kotlin_ObjCExport_AbstractMethodCalled)
|
||||||
|
touchFunction(Kotlin_ObjCExport_AbstractClassConstructorCalled)
|
||||||
|
touchFunction(Kotlin_ObjCExport_RethrowExceptionAsNSError)
|
||||||
|
touchFunction(Kotlin_ObjCExport_WrapExceptionToNSError)
|
||||||
|
touchFunction(Kotlin_ObjCExport_NSErrorAsException)
|
||||||
|
touchFunction(Kotlin_ObjCExport_AllocInstanceWithAssociatedObject)
|
||||||
|
touchFunction(Kotlin_ObjCExport_createContinuationArgument)
|
||||||
|
touchFunction(Kotlin_ObjCExport_createUnitContinuationArgument)
|
||||||
|
touchFunction(Kotlin_ObjCExport_resumeContinuation)
|
||||||
|
touchFunction(Kotlin_ObjCExport_NSIntegerTypeProvider)
|
||||||
|
touchFunction(Kotlin_longTypeProvider)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // KONAN_OBJC_INTEROP
|
||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
*
|
* that can be found in the LICENSE file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef RUNTIME_EXCEPTIONS_H
|
#ifndef RUNTIME_EXCEPTIONS_H
|
||||||
@@ -24,7 +13,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Throws arbitrary exception.
|
// Throws arbitrary exception.
|
||||||
void ThrowException(KRef exception);
|
void RUNTIME_NORETURN ThrowException(KRef exception);
|
||||||
|
|
||||||
void SetKonanTerminateHandler();
|
void SetKonanTerminateHandler();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -75,4 +75,11 @@ static_assert(
|
|||||||
std::is_trivially_destructible_v<BackRefFromAssociatedObject>,
|
std::is_trivially_destructible_v<BackRefFromAssociatedObject>,
|
||||||
"BackRefFromAssociatedObject destructor is not guaranteed to be called.");
|
"BackRefFromAssociatedObject destructor is not guaranteed to be called.");
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
RUNTIME_NOTHROW void KRefSharedHolder_initLocal(KRefSharedHolder* holder, ObjHeader* obj);
|
||||||
|
RUNTIME_NOTHROW void KRefSharedHolder_init(KRefSharedHolder* holder, ObjHeader* obj);
|
||||||
|
RUNTIME_NOTHROW void KRefSharedHolder_dispose(const KRefSharedHolder* holder);
|
||||||
|
RUNTIME_NOTHROW ObjHeader* KRefSharedHolder_ref(const KRefSharedHolder* holder);
|
||||||
|
} // extern "C"
|
||||||
|
|
||||||
#endif // RUNTIME_MEMORYSHAREDREFS_HPP
|
#endif // RUNTIME_MEMORYSHAREDREFS_HPP
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
#ifndef RUNTIME_OBJCEXPORT_H
|
#ifndef RUNTIME_OBJCEXPORT_H
|
||||||
#define RUNTIME_OBJCEXPORT_H
|
#define RUNTIME_OBJCEXPORT_H
|
||||||
|
|
||||||
@@ -9,9 +14,116 @@
|
|||||||
#import "Types.h"
|
#import "Types.h"
|
||||||
#import "Memory.h"
|
#import "Memory.h"
|
||||||
|
|
||||||
extern "C" id objc_retain(id self);
|
extern "C" {
|
||||||
extern "C" id objc_retainBlock(id self);
|
|
||||||
extern "C" void objc_release(id self);
|
struct ObjCToKotlinMethodAdapter {
|
||||||
|
const char* selector;
|
||||||
|
const char* encoding;
|
||||||
|
IMP imp;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct KotlinToObjCMethodAdapter {
|
||||||
|
const char* selector;
|
||||||
|
ClassId interfaceId;
|
||||||
|
int itableSize;
|
||||||
|
int itableIndex;
|
||||||
|
int vtableIndex;
|
||||||
|
const void* kotlinImpl;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ObjCTypeAdapter {
|
||||||
|
const TypeInfo* kotlinTypeInfo;
|
||||||
|
|
||||||
|
const void * const * kotlinVtable;
|
||||||
|
int kotlinVtableSize;
|
||||||
|
|
||||||
|
const InterfaceTableRecord* kotlinItable;
|
||||||
|
int kotlinItableSize;
|
||||||
|
|
||||||
|
const char* objCName;
|
||||||
|
|
||||||
|
const ObjCToKotlinMethodAdapter* directAdapters;
|
||||||
|
int directAdapterNum;
|
||||||
|
|
||||||
|
const ObjCToKotlinMethodAdapter* classAdapters;
|
||||||
|
int classAdapterNum;
|
||||||
|
|
||||||
|
const ObjCToKotlinMethodAdapter* virtualAdapters;
|
||||||
|
int virtualAdapterNum;
|
||||||
|
|
||||||
|
const KotlinToObjCMethodAdapter* reverseAdapters;
|
||||||
|
int reverseAdapterNum;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TypeInfoObjCExportAddition {
|
||||||
|
/*convertReferenceToRetainedObjC*/ void* convertToRetained;
|
||||||
|
Class objCClass;
|
||||||
|
const ObjCTypeAdapter* typeAdapter;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct WritableTypeInfo {
|
||||||
|
TypeInfoObjCExportAddition objCExport;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Block_descriptor_1;
|
||||||
|
|
||||||
|
// Based on https://clang.llvm.org/docs/Block-ABI-Apple.html and libclosure source.
|
||||||
|
struct Block_literal_1 {
|
||||||
|
void *isa; // initialized to &_NSConcreteStackBlock or &_NSConcreteGlobalBlock
|
||||||
|
int flags;
|
||||||
|
int reserved;
|
||||||
|
void (*invoke)(void *, ...);
|
||||||
|
struct Block_descriptor_1 *descriptor; // IFF (1<<25)
|
||||||
|
// Or:
|
||||||
|
// struct Block_descriptor_1_without_helpers* descriptor // if hasn't (1<<25).
|
||||||
|
|
||||||
|
// imported variables
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Block_descriptor_1 {
|
||||||
|
unsigned long int reserved; // NULL
|
||||||
|
unsigned long int size; // sizeof(struct Block_literal_1)
|
||||||
|
|
||||||
|
// optional helper functions
|
||||||
|
void (*copy_helper)(void *dst, void *src);
|
||||||
|
void (*dispose_helper)(void *src);
|
||||||
|
// required ABI.2010.3.16
|
||||||
|
const char *signature; // IFF (1<<30)
|
||||||
|
const void* layout; // IFF (1<<31)
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Block_descriptor_1_without_helpers {
|
||||||
|
unsigned long int reserved; // NULL
|
||||||
|
unsigned long int size; // sizeof(struct Block_literal_1)
|
||||||
|
|
||||||
|
// required ABI.2010.3.16
|
||||||
|
const char *signature; // IFF (1<<30)
|
||||||
|
const void* layout; // IFF (1<<31)
|
||||||
|
};
|
||||||
|
|
||||||
|
id objc_retain(id self);
|
||||||
|
id objc_retainBlock(id self);
|
||||||
|
void objc_release(id self);
|
||||||
|
|
||||||
|
id Kotlin_ObjCExport_refToObjC(ObjHeader* obj);
|
||||||
|
id Kotlin_ObjCExport_refToLocalObjC(ObjHeader* obj);
|
||||||
|
id Kotlin_ObjCExport_refToRetainedObjC(ObjHeader* obj);
|
||||||
|
id Kotlin_ObjCExport_CreateRetainedNSStringFromKString(ObjHeader* str);
|
||||||
|
id Kotlin_ObjCExport_convertUnitToRetained(ObjHeader* unitInstance);
|
||||||
|
id Kotlin_ObjCExport_GetAssociatedObject(ObjHeader* obj);
|
||||||
|
void Kotlin_ObjCExport_AbstractMethodCalled(id self, SEL selector);
|
||||||
|
void Kotlin_ObjCExport_AbstractClassConstructorCalled(id self, const TypeInfo *clazz);
|
||||||
|
OBJ_GETTER(Kotlin_ObjCExport_refFromObjC, id obj);
|
||||||
|
RUNTIME_NOTHROW OBJ_GETTER(Kotlin_ObjCExport_AllocInstanceWithAssociatedObject,
|
||||||
|
const TypeInfo* typeInfo, id associatedObject);
|
||||||
|
|
||||||
|
id Kotlin_Interop_CreateNSStringFromKString(KRef str);
|
||||||
|
OBJ_GETTER(Kotlin_Interop_CreateKStringFromNSString, NSString* str);
|
||||||
|
|
||||||
|
/// Utility function that is used to determine NSInteger size in compile time.
|
||||||
|
NSInteger Kotlin_ObjCExport_NSIntegerTypeProvider();
|
||||||
|
|
||||||
|
} // extern "C"
|
||||||
|
|
||||||
inline static id GetAssociatedObject(ObjHeader* obj) {
|
inline static id GetAssociatedObject(ObjHeader* obj) {
|
||||||
return (id)obj->GetAssociatedObject();
|
return (id)obj->GetAssociatedObject();
|
||||||
@@ -32,16 +144,6 @@ inline static OBJ_GETTER(AllocInstanceWithAssociatedObject, const TypeInfo* type
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" id Kotlin_ObjCExport_refToObjC(ObjHeader* obj);
|
|
||||||
extern "C" id Kotlin_ObjCExport_refToLocalObjC(ObjHeader* obj);
|
|
||||||
extern "C" OBJ_GETTER(Kotlin_ObjCExport_refFromObjC, id obj);
|
|
||||||
|
|
||||||
extern "C" id Kotlin_Interop_CreateNSStringFromKString(KRef str);
|
|
||||||
extern "C" OBJ_GETTER(Kotlin_Interop_CreateKStringFromNSString, NSString* str);
|
|
||||||
|
|
||||||
/// Utility function that is used to determine NSInteger size in compile time.
|
|
||||||
extern "C" NSInteger Kotlin_ObjCExport_NSIntegerTypeProvider();
|
|
||||||
|
|
||||||
#endif // KONAN_OBJC_INTEROP
|
#endif // KONAN_OBJC_INTEROP
|
||||||
|
|
||||||
#endif // RUNTIME_OBJCEXPORT_H
|
#endif // RUNTIME_OBJCEXPORT_H
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
*
|
* that can be found in the LICENSE file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "Types.h"
|
#import "Types.h"
|
||||||
@@ -61,58 +50,9 @@ inline T* konanAllocArray(size_t length) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ObjCToKotlinMethodAdapter {
|
|
||||||
const char* selector;
|
|
||||||
const char* encoding;
|
|
||||||
IMP imp;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct KotlinToObjCMethodAdapter {
|
|
||||||
const char* selector;
|
|
||||||
ClassId interfaceId;
|
|
||||||
int itableSize;
|
|
||||||
int itableIndex;
|
|
||||||
int vtableIndex;
|
|
||||||
const void* kotlinImpl;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ObjCTypeAdapter {
|
|
||||||
const TypeInfo* kotlinTypeInfo;
|
|
||||||
|
|
||||||
const void * const * kotlinVtable;
|
|
||||||
int kotlinVtableSize;
|
|
||||||
|
|
||||||
const InterfaceTableRecord* kotlinItable;
|
|
||||||
int kotlinItableSize;
|
|
||||||
|
|
||||||
const char* objCName;
|
|
||||||
|
|
||||||
const ObjCToKotlinMethodAdapter* directAdapters;
|
|
||||||
int directAdapterNum;
|
|
||||||
|
|
||||||
const ObjCToKotlinMethodAdapter* classAdapters;
|
|
||||||
int classAdapterNum;
|
|
||||||
|
|
||||||
const ObjCToKotlinMethodAdapter* virtualAdapters;
|
|
||||||
int virtualAdapterNum;
|
|
||||||
|
|
||||||
const KotlinToObjCMethodAdapter* reverseAdapters;
|
|
||||||
int reverseAdapterNum;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef id (*convertReferenceToRetainedObjC)(ObjHeader* obj);
|
typedef id (*convertReferenceToRetainedObjC)(ObjHeader* obj);
|
||||||
typedef OBJ_GETTER((*convertReferenceFromObjC), id obj);
|
typedef OBJ_GETTER((*convertReferenceFromObjC), id obj);
|
||||||
|
|
||||||
struct TypeInfoObjCExportAddition {
|
|
||||||
/*convertReferenceToRetainedObjC*/ void* convertToRetained;
|
|
||||||
Class objCClass;
|
|
||||||
const ObjCTypeAdapter* typeAdapter;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct WritableTypeInfo {
|
|
||||||
TypeInfoObjCExportAddition objCExport;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
static char associatedTypeInfoKey;
|
static char associatedTypeInfoKey;
|
||||||
|
|
||||||
@@ -454,44 +394,8 @@ static OBJ_GETTER(boxedBooleanToKotlinImp, NSNumber* self, SEL cmd) {
|
|||||||
RETURN_RESULT_OF(Kotlin_boxBoolean, self.boolValue);
|
RETURN_RESULT_OF(Kotlin_boxBoolean, self.boolValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Block_descriptor_1;
|
|
||||||
|
|
||||||
// Based on https://clang.llvm.org/docs/Block-ABI-Apple.html and libclosure source.
|
|
||||||
struct Block_literal_1 {
|
|
||||||
void *isa; // initialized to &_NSConcreteStackBlock or &_NSConcreteGlobalBlock
|
|
||||||
int flags;
|
|
||||||
int reserved;
|
|
||||||
void (*invoke)(void *, ...);
|
|
||||||
struct Block_descriptor_1 *descriptor; // IFF (1<<25)
|
|
||||||
// Or:
|
|
||||||
// struct Block_descriptor_1_without_helpers* descriptor // if hasn't (1<<25).
|
|
||||||
|
|
||||||
// imported variables
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Block_literal_1 exportBlockLiteral;
|
struct Block_literal_1 exportBlockLiteral;
|
||||||
|
|
||||||
struct Block_descriptor_1 {
|
|
||||||
unsigned long int reserved; // NULL
|
|
||||||
unsigned long int size; // sizeof(struct Block_literal_1)
|
|
||||||
|
|
||||||
// optional helper functions
|
|
||||||
void (*copy_helper)(void *dst, void *src);
|
|
||||||
void (*dispose_helper)(void *src);
|
|
||||||
// required ABI.2010.3.16
|
|
||||||
const char *signature; // IFF (1<<30)
|
|
||||||
const void* layout; // IFF (1<<31)
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Block_descriptor_1_without_helpers {
|
|
||||||
unsigned long int reserved; // NULL
|
|
||||||
unsigned long int size; // sizeof(struct Block_literal_1)
|
|
||||||
|
|
||||||
// required ABI.2010.3.16
|
|
||||||
const char *signature; // IFF (1<<30)
|
|
||||||
const void* layout; // IFF (1<<31)
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char* getBlockEncoding(id block) {
|
static const char* getBlockEncoding(id block) {
|
||||||
Block_literal_1* literal = reinterpret_cast<Block_literal_1*>(block);
|
Block_literal_1* literal = reinterpret_cast<Block_literal_1*>(block);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Types.h"
|
||||||
|
|
||||||
|
extern "C" OBJ_GETTER(Kotlin_ObjCExport_createContinuationArgument, id completion, const TypeInfo** exceptionTypes);
|
||||||
|
extern "C" OBJ_GETTER(Kotlin_ObjCExport_createUnitContinuationArgument, id completion, const TypeInfo** exceptionTypes);
|
||||||
|
extern "C" void Kotlin_ObjCExport_resumeContinuation(KRef continuation, KRef result, id error);
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#import "Types.h"
|
#import "Types.h"
|
||||||
|
|
||||||
extern "C" id Kotlin_ObjCExport_ExceptionAsNSError(KRef exception, const TypeInfo** types);
|
extern "C" id Kotlin_ObjCExport_ExceptionAsNSError(KRef exception, const TypeInfo** types);
|
||||||
|
extern "C" void Kotlin_ObjCExport_RethrowExceptionAsNSError(KRef exception, id* outError, const TypeInfo** types);
|
||||||
extern "C" id Kotlin_ObjCExport_WrapExceptionToNSError(KRef exception);
|
extern "C" id Kotlin_ObjCExport_WrapExceptionToNSError(KRef exception);
|
||||||
extern "C" OBJ_GETTER(Kotlin_ObjCExport_NSErrorAsException, id error);
|
extern "C" OBJ_GETTER(Kotlin_ObjCExport_NSErrorAsException, id error);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -8,6 +8,58 @@
|
|||||||
|
|
||||||
#if KONAN_OBJC_INTEROP
|
#if KONAN_OBJC_INTEROP
|
||||||
|
|
||||||
|
#include <Foundation/NSString.h>
|
||||||
|
#include <Foundation/NSException.h>
|
||||||
|
#include <objc/objc-exception.h>
|
||||||
|
|
||||||
|
#include <objc/objc.h>
|
||||||
|
#include <objc/runtime.h>
|
||||||
|
#include <objc/message.h>
|
||||||
|
|
||||||
|
#include "TypeInfo.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
struct KotlinObjCClassData {
|
||||||
|
const TypeInfo* typeInfo;
|
||||||
|
Class objcClass;
|
||||||
|
int32_t bodyOffset;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ObjCMethodDescription {
|
||||||
|
void* (*imp)(void*, void*, ...);
|
||||||
|
const char* selector;
|
||||||
|
const char* encoding;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct KotlinObjCClassInfo {
|
||||||
|
const char* name;
|
||||||
|
int exported;
|
||||||
|
|
||||||
|
const char* superclassName;
|
||||||
|
const char** protocolNames;
|
||||||
|
|
||||||
|
const struct ObjCMethodDescription* instanceMethods;
|
||||||
|
int32_t instanceMethodsNum;
|
||||||
|
|
||||||
|
const struct ObjCMethodDescription* classMethods;
|
||||||
|
int32_t classMethodsNum;
|
||||||
|
|
||||||
|
int32_t* bodyOffset;
|
||||||
|
|
||||||
|
const TypeInfo* typeInfo;
|
||||||
|
const TypeInfo* metaTypeInfo;
|
||||||
|
|
||||||
|
void** createdClass;
|
||||||
|
|
||||||
|
KotlinObjCClassData* (*classDataImp)(void*, void*);
|
||||||
|
};
|
||||||
|
|
||||||
|
void* CreateKotlinObjCClass(const KotlinObjCClassInfo* info);
|
||||||
|
RUNTIME_NOTHROW const TypeInfo* GetObjCKotlinTypeInfo(ObjHeader* obj);
|
||||||
|
|
||||||
|
} // extern "C"
|
||||||
|
|
||||||
const char* Kotlin_ObjCInterop_getUniquePrefix();
|
const char* Kotlin_ObjCInterop_getUniquePrefix();
|
||||||
|
|
||||||
#endif // KONAN_OBJC_INTEROP
|
#endif // KONAN_OBJC_INTEROP
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
*
|
* that can be found in the LICENSE file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if KONAN_OBJC_INTEROP
|
#if KONAN_OBJC_INTEROP
|
||||||
@@ -51,12 +40,6 @@ const char* Kotlin_ObjCInterop_getUniquePrefix() {
|
|||||||
|
|
||||||
extern "C" id objc_msgSendSuper2(struct objc_super *super, SEL op, ...);
|
extern "C" id objc_msgSendSuper2(struct objc_super *super, SEL op, ...);
|
||||||
|
|
||||||
struct KotlinObjCClassData {
|
|
||||||
const TypeInfo* typeInfo;
|
|
||||||
Class objcClass;
|
|
||||||
int32_t bodyOffset;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Acts only as container for the method, not actually applied to any class.
|
// Acts only as container for the method, not actually applied to any class.
|
||||||
@protocol HasKotlinObjCClassData
|
@protocol HasKotlinObjCClassData
|
||||||
@required
|
@required
|
||||||
@@ -179,8 +162,6 @@ Class Kotlin_Interop_getObjCClass(const char* name) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TypeInfo* GetObjCKotlinTypeInfo(ObjHeader* obj) RUNTIME_NOTHROW;
|
|
||||||
|
|
||||||
RUNTIME_NOTHROW const TypeInfo* GetObjCKotlinTypeInfo(ObjHeader* obj) {
|
RUNTIME_NOTHROW const TypeInfo* GetObjCKotlinTypeInfo(ObjHeader* obj) {
|
||||||
void* objcPtr = obj->GetAssociatedObject();
|
void* objcPtr = obj->GetAssociatedObject();
|
||||||
RuntimeAssert(objcPtr != nullptr, "");
|
RuntimeAssert(objcPtr != nullptr, "");
|
||||||
@@ -223,35 +204,6 @@ static void AddKotlinClassData(bool isClassMethod, Class clazz, void* imp) {
|
|||||||
RuntimeCheck(added, "Unable to add method to Objective-C class");
|
RuntimeCheck(added, "Unable to add method to Objective-C class");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ObjCMethodDescription {
|
|
||||||
void* (*imp)(void*, void*, ...);
|
|
||||||
const char* selector;
|
|
||||||
const char* encoding;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct KotlinObjCClassInfo {
|
|
||||||
const char* name;
|
|
||||||
int exported;
|
|
||||||
|
|
||||||
const char* superclassName;
|
|
||||||
const char** protocolNames;
|
|
||||||
|
|
||||||
const struct ObjCMethodDescription* instanceMethods;
|
|
||||||
int32_t instanceMethodsNum;
|
|
||||||
|
|
||||||
const struct ObjCMethodDescription* classMethods;
|
|
||||||
int32_t classMethodsNum;
|
|
||||||
|
|
||||||
int32_t* bodyOffset;
|
|
||||||
|
|
||||||
const TypeInfo* typeInfo;
|
|
||||||
const TypeInfo* metaTypeInfo;
|
|
||||||
|
|
||||||
void** createdClass;
|
|
||||||
|
|
||||||
KotlinObjCClassData* (*classDataImp)(void*, void*);
|
|
||||||
};
|
|
||||||
|
|
||||||
static void AddMethods(Class clazz, const struct ObjCMethodDescription* methods, int32_t methodsNum) {
|
static void AddMethods(Class clazz, const struct ObjCMethodDescription* methods, int32_t methodsNum) {
|
||||||
for (int32_t i = 0; i < methodsNum; ++i) {
|
for (int32_t i = 0; i < methodsNum; ++i) {
|
||||||
const struct ObjCMethodDescription* method = &methods[i];
|
const struct ObjCMethodDescription* method = &methods[i];
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
|
* that can be found in the LICENSE file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RUNTIME_OBJCINTEROPUTILS_H
|
||||||
|
#define RUNTIME_OBJCINTEROPUTILS_H
|
||||||
|
|
||||||
|
#if KONAN_OBJC_INTEROP
|
||||||
|
|
||||||
|
#import <objc/runtime.h>
|
||||||
|
#import "Types.h"
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
id MissingInitImp(id self, SEL _cmd);
|
||||||
|
KBoolean Kotlin_Interop_DoesObjectConformToProtocol(id obj, void* prot, KBoolean isMeta);
|
||||||
|
KBoolean Kotlin_Interop_IsObjectKindOfClass(id obj, void* cls);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // KONAN_OBJC_INTEROP
|
||||||
|
|
||||||
|
#endif // RUNTIME_OBJCINTEROPUTILS_H
|
||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
*
|
* that can be found in the LICENSE file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Natives.h"
|
#include "Natives.h"
|
||||||
@@ -23,6 +12,7 @@
|
|||||||
#import <Foundation/NSException.h>
|
#import <Foundation/NSException.h>
|
||||||
#import <Foundation/NSString.h>
|
#import <Foundation/NSString.h>
|
||||||
#import "Memory.h"
|
#import "Memory.h"
|
||||||
|
#import "ObjCInteropUtils.h"
|
||||||
#import "ObjCInteropUtilsPrivate.h"
|
#import "ObjCInteropUtilsPrivate.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
* that can be found in the LICENSE file.
|
* that can be found in the LICENSE file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
#import "Types.h"
|
#import "Types.h"
|
||||||
#import "Memory.h"
|
#import "Memory.h"
|
||||||
|
|
||||||
|
extern "C" id MissingInitImp(id self, SEL _cmd);
|
||||||
extern "C" id (*Kotlin_Interop_createKotlinObjectHolder_ptr)(KRef any);
|
extern "C" id (*Kotlin_Interop_createKotlinObjectHolder_ptr)(KRef any);
|
||||||
extern "C" KRef (*Kotlin_Interop_unwrapKotlinObjectHolder_ptr)(id holder);
|
extern "C" KRef (*Kotlin_Interop_unwrapKotlinObjectHolder_ptr)(id holder);
|
||||||
extern "C" OBJ_GETTER((*Konan_ObjCInterop_getWeakReference_ptr), KRef ref);
|
extern "C" OBJ_GETTER((*Konan_ObjCInterop_getWeakReference_ptr), KRef ref);
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
*
|
* that can be found in the LICENSE file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Atomic.h"
|
#include "Atomic.h"
|
||||||
@@ -41,12 +30,6 @@ using kotlin::internal::FILE_BEING_INITIALIZED;
|
|||||||
using kotlin::internal::FILE_INITIALIZED;
|
using kotlin::internal::FILE_INITIALIZED;
|
||||||
using kotlin::internal::FILE_FAILED_TO_INITIALIZE;
|
using kotlin::internal::FILE_FAILED_TO_INITIALIZE;
|
||||||
|
|
||||||
typedef void (*Initializer)(int initialize, MemoryState* memory);
|
|
||||||
struct InitNode {
|
|
||||||
Initializer init;
|
|
||||||
InitNode* next;
|
|
||||||
};
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
InitNode* initHeadNode = nullptr;
|
InitNode* initHeadNode = nullptr;
|
||||||
@@ -209,7 +192,7 @@ void Kotlin_deinitRuntimeCallback(void* argument) {
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
void AppendToInitializersTail(InitNode *next) {
|
RUNTIME_NOTHROW void AppendToInitializersTail(InitNode *next) {
|
||||||
// TODO: use RuntimeState.
|
// TODO: use RuntimeState.
|
||||||
if (initHeadNode == nullptr) {
|
if (initHeadNode == nullptr) {
|
||||||
initHeadNode = next;
|
initHeadNode = next;
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
*
|
* that can be found in the LICENSE file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef RUNTIME_RUNTIME_H
|
#ifndef RUNTIME_RUNTIME_H
|
||||||
@@ -19,12 +8,16 @@
|
|||||||
|
|
||||||
#include "Porting.h"
|
#include "Porting.h"
|
||||||
|
|
||||||
struct InitNode;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
typedef void (*Initializer)(int initialize, MemoryState* memory);
|
||||||
|
struct InitNode {
|
||||||
|
Initializer init;
|
||||||
|
InitNode* next;
|
||||||
|
};
|
||||||
|
|
||||||
// For experimental MM, if runtime gets initialized, it will be in the native state after this.
|
// For experimental MM, if runtime gets initialized, it will be in the native state after this.
|
||||||
RUNTIME_NOTHROW void Kotlin_initRuntimeIfNeeded();
|
RUNTIME_NOTHROW void Kotlin_initRuntimeIfNeeded();
|
||||||
void Kotlin_deinitRuntimeIfNeeded();
|
void Kotlin_deinitRuntimeIfNeeded();
|
||||||
@@ -36,7 +29,7 @@ void Kotlin_deinitRuntimeIfNeeded();
|
|||||||
void Kotlin_shutdownRuntime();
|
void Kotlin_shutdownRuntime();
|
||||||
|
|
||||||
// Appends given node to an initializer list.
|
// Appends given node to an initializer list.
|
||||||
void AppendToInitializersTail(struct InitNode*);
|
RUNTIME_NOTHROW void AppendToInitializersTail(struct InitNode*);
|
||||||
|
|
||||||
void CallInitGlobalPossiblyLock(int* state, void (*init)());
|
void CallInitGlobalPossiblyLock(int* state, void (*init)());
|
||||||
void CallInitThreadLocal(int volatile* globalState, int* localState, void (*init)());
|
void CallInitThreadLocal(int volatile* globalState, int* localState, void (*init)());
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
*
|
* that can be found in the LICENSE file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef RUNTIME_TYPEINFO_H
|
#ifndef RUNTIME_TYPEINFO_H
|
||||||
@@ -27,7 +16,12 @@ struct WritableTypeInfo;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct ObjHeader;
|
struct ObjHeader;
|
||||||
struct AssociatedObjectTableRecord;
|
struct TypeInfo;
|
||||||
|
|
||||||
|
struct AssociatedObjectTableRecord {
|
||||||
|
const TypeInfo* key;
|
||||||
|
ObjHeader* (*getAssociatedObjectInstance)(ObjHeader**);
|
||||||
|
};
|
||||||
|
|
||||||
// Type for runtime representation of Konan object.
|
// Type for runtime representation of Konan object.
|
||||||
// Keep in sync with runtimeTypeMap in RTTIGenerator.
|
// Keep in sync with runtimeTypeMap in RTTIGenerator.
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2022 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
*
|
* that can be found in the LICENSE file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Types.h"
|
#include "Types.h"
|
||||||
@@ -73,11 +62,6 @@ OBJ_GETTER(Kotlin_TypeInfo_getRelativeName, KNativePtr typeInfo, KBoolean checkF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AssociatedObjectTableRecord {
|
|
||||||
const TypeInfo* key;
|
|
||||||
OBJ_GETTER0((*getAssociatedObjectInstance));
|
|
||||||
};
|
|
||||||
|
|
||||||
OBJ_GETTER(Kotlin_TypeInfo_findAssociatedObject, KNativePtr typeInfo, KNativePtr key) {
|
OBJ_GETTER(Kotlin_TypeInfo_findAssociatedObject, KNativePtr typeInfo, KNativePtr key) {
|
||||||
const AssociatedObjectTableRecord* associatedObjects = reinterpret_cast<const TypeInfo*>(typeInfo)->associatedObjects;
|
const AssociatedObjectTableRecord* associatedObjects = reinterpret_cast<const TypeInfo*>(typeInfo)->associatedObjects;
|
||||||
if (associatedObjects == nullptr) {
|
if (associatedObjects == nullptr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user