RUNTIME: laucher uses runtime API for registering and running out initializers
This commit is contained in:
committed by
vvlevchenko
parent
5f097350ac
commit
801953ec56
@@ -3,33 +3,6 @@
|
||||
#include "Natives.h"
|
||||
#include "Types.h"
|
||||
|
||||
//--- Init global variables ---------------------------------------------------//
|
||||
|
||||
typedef void (*Initializer)();
|
||||
struct InitNode;
|
||||
|
||||
struct InitNode {
|
||||
Initializer init;
|
||||
struct InitNode* next;
|
||||
};
|
||||
|
||||
static struct InitNode initHeadNode;
|
||||
static struct InitNode* initTailNode = &initHeadNode;
|
||||
|
||||
|
||||
void InitGlobalVariables() {
|
||||
struct InitNode *currNode = initHeadNode.next;
|
||||
while(currNode) {
|
||||
currNode->init();
|
||||
currNode = currNode->next;
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void appendToInitializersTail(struct InitNode *next) {
|
||||
initTailNode->next = next;
|
||||
initTailNode = next;
|
||||
}
|
||||
|
||||
//--- Setup args --------------------------------------------------------------//
|
||||
|
||||
ObjHeader* setupArgs(int argc, char** argv) {
|
||||
|
||||
@@ -31,6 +31,25 @@ void CheckInstance(const ObjHeader* obj, const TypeInfo* type_info) {
|
||||
ThrowClassCastException();
|
||||
}
|
||||
|
||||
static struct InitNode* initHeadNode = nullptr;
|
||||
static struct InitNode* initTailNode = nullptr;
|
||||
|
||||
void AppendToInitializersTail(struct InitNode *next) {
|
||||
if (initHeadNode == nullptr) {
|
||||
initHeadNode = next;
|
||||
} else {
|
||||
initTailNode->next = next;
|
||||
}
|
||||
initTailNode = next;
|
||||
}
|
||||
|
||||
void InitGlobalVariables() {
|
||||
struct InitNode *currNode = initHeadNode;
|
||||
while(currNode != nullptr) {
|
||||
currNode->init();
|
||||
currNode = currNode->next;
|
||||
}
|
||||
}
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -39,6 +39,15 @@ extern const TypeInfo* theThrowableTypeInfo;
|
||||
KBoolean IsInstance(const ObjHeader* obj, const TypeInfo* type_info);
|
||||
void CheckCast(const ObjHeader* obj, const TypeInfo* type_info);
|
||||
|
||||
typedef void (*Initializer)();
|
||||
struct InitNode {
|
||||
Initializer init;
|
||||
struct InitNode* next;
|
||||
};
|
||||
|
||||
void AppendToInitializersTail(struct InitNode*);
|
||||
void InitGlobalVariables();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user