[K/N][runtime] Extracted compiler interface from native runtime
This commit is contained in:
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
* 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_EXCEPTIONS_H
|
||||
@@ -24,7 +13,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
// Throws arbitrary exception.
|
||||
void ThrowException(KRef exception);
|
||||
void RUNTIME_NORETURN ThrowException(KRef exception);
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -75,4 +75,11 @@ static_assert(
|
||||
std::is_trivially_destructible_v<BackRefFromAssociatedObject>,
|
||||
"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
|
||||
|
||||
@@ -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
|
||||
#define RUNTIME_OBJCEXPORT_H
|
||||
|
||||
@@ -9,9 +14,116 @@
|
||||
#import "Types.h"
|
||||
#import "Memory.h"
|
||||
|
||||
extern "C" id objc_retain(id self);
|
||||
extern "C" id objc_retainBlock(id self);
|
||||
extern "C" void objc_release(id self);
|
||||
extern "C" {
|
||||
|
||||
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) {
|
||||
return (id)obj->GetAssociatedObject();
|
||||
@@ -32,16 +144,6 @@ inline static OBJ_GETTER(AllocInstanceWithAssociatedObject, const TypeInfo* type
|
||||
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 // RUNTIME_OBJCEXPORT_H
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#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 OBJ_GETTER((*convertReferenceFromObjC), id obj);
|
||||
|
||||
struct TypeInfoObjCExportAddition {
|
||||
/*convertReferenceToRetainedObjC*/ void* convertToRetained;
|
||||
Class objCClass;
|
||||
const ObjCTypeAdapter* typeAdapter;
|
||||
};
|
||||
|
||||
struct WritableTypeInfo {
|
||||
TypeInfoObjCExportAddition objCExport;
|
||||
};
|
||||
|
||||
|
||||
static char associatedTypeInfoKey;
|
||||
|
||||
@@ -454,44 +394,8 @@ static OBJ_GETTER(boxedBooleanToKotlinImp, NSNumber* self, SEL cmd) {
|
||||
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_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) {
|
||||
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.
|
||||
*/
|
||||
|
||||
#import "Types.h"
|
||||
|
||||
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" 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.
|
||||
*/
|
||||
|
||||
@@ -8,6 +8,58 @@
|
||||
|
||||
#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();
|
||||
|
||||
#endif // KONAN_OBJC_INTEROP
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
* 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
|
||||
@@ -51,12 +40,6 @@ const char* Kotlin_ObjCInterop_getUniquePrefix() {
|
||||
|
||||
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.
|
||||
@protocol HasKotlinObjCClassData
|
||||
@required
|
||||
@@ -179,8 +162,6 @@ Class Kotlin_Interop_getObjCClass(const char* name) {
|
||||
return result;
|
||||
}
|
||||
|
||||
const TypeInfo* GetObjCKotlinTypeInfo(ObjHeader* obj) RUNTIME_NOTHROW;
|
||||
|
||||
RUNTIME_NOTHROW const TypeInfo* GetObjCKotlinTypeInfo(ObjHeader* obj) {
|
||||
void* objcPtr = obj->GetAssociatedObject();
|
||||
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");
|
||||
}
|
||||
|
||||
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) {
|
||||
for (int32_t i = 0; i < methodsNum; ++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.
|
||||
*
|
||||
* 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.
|
||||
* 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 "Natives.h"
|
||||
@@ -23,6 +12,7 @@
|
||||
#import <Foundation/NSException.h>
|
||||
#import <Foundation/NSString.h>
|
||||
#import "Memory.h"
|
||||
#import "ObjCInteropUtils.h"
|
||||
#import "ObjCInteropUtilsPrivate.h"
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#import "Types.h"
|
||||
#import "Memory.h"
|
||||
|
||||
extern "C" id MissingInitImp(id self, SEL _cmd);
|
||||
extern "C" id (*Kotlin_Interop_createKotlinObjectHolder_ptr)(KRef any);
|
||||
extern "C" KRef (*Kotlin_Interop_unwrapKotlinObjectHolder_ptr)(id holder);
|
||||
extern "C" OBJ_GETTER((*Konan_ObjCInterop_getWeakReference_ptr), KRef ref);
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
* 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 "Atomic.h"
|
||||
@@ -41,12 +30,6 @@ using kotlin::internal::FILE_BEING_INITIALIZED;
|
||||
using kotlin::internal::FILE_INITIALIZED;
|
||||
using kotlin::internal::FILE_FAILED_TO_INITIALIZE;
|
||||
|
||||
typedef void (*Initializer)(int initialize, MemoryState* memory);
|
||||
struct InitNode {
|
||||
Initializer init;
|
||||
InitNode* next;
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
InitNode* initHeadNode = nullptr;
|
||||
@@ -209,7 +192,7 @@ void Kotlin_deinitRuntimeCallback(void* argument) {
|
||||
|
||||
extern "C" {
|
||||
|
||||
void AppendToInitializersTail(InitNode *next) {
|
||||
RUNTIME_NOTHROW void AppendToInitializersTail(InitNode *next) {
|
||||
// TODO: use RuntimeState.
|
||||
if (initHeadNode == nullptr) {
|
||||
initHeadNode = next;
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
* 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_RUNTIME_H
|
||||
@@ -19,12 +8,16 @@
|
||||
|
||||
#include "Porting.h"
|
||||
|
||||
struct InitNode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#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.
|
||||
RUNTIME_NOTHROW void Kotlin_initRuntimeIfNeeded();
|
||||
void Kotlin_deinitRuntimeIfNeeded();
|
||||
@@ -36,7 +29,7 @@ void Kotlin_deinitRuntimeIfNeeded();
|
||||
void Kotlin_shutdownRuntime();
|
||||
|
||||
// Appends given node to an initializer list.
|
||||
void AppendToInitializersTail(struct InitNode*);
|
||||
RUNTIME_NOTHROW void AppendToInitializersTail(struct InitNode*);
|
||||
|
||||
void CallInitGlobalPossiblyLock(int* state, void (*init)());
|
||||
void CallInitThreadLocal(int volatile* globalState, int* localState, void (*init)());
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
* 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_TYPEINFO_H
|
||||
@@ -27,7 +16,12 @@ struct WritableTypeInfo;
|
||||
#endif
|
||||
|
||||
struct ObjHeader;
|
||||
struct AssociatedObjectTableRecord;
|
||||
struct TypeInfo;
|
||||
|
||||
struct AssociatedObjectTableRecord {
|
||||
const TypeInfo* key;
|
||||
ObjHeader* (*getAssociatedObjectInstance)(ObjHeader**);
|
||||
};
|
||||
|
||||
// Type for runtime representation of Konan object.
|
||||
// Keep in sync with runtimeTypeMap in RTTIGenerator.
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* 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.
|
||||
* 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"
|
||||
@@ -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) {
|
||||
const AssociatedObjectTableRecord* associatedObjects = reinterpret_cast<const TypeInfo*>(typeInfo)->associatedObjects;
|
||||
if (associatedObjects == nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user