gdjn  Diff

Differences From Artifact [f8bd0edc4d]:

To Artifact [65eb39af07]:


3
4
5
6
7
8
9

10
11











12
13
14
15
16
17
18
19
20
21
22




23
24
25
26
27
28
29
..
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
..
75
76
77
78
79
80
81

82
83
84
85
86
87
88
..
99
100
101
102
103
104
105


106
107
108
109
110
111
112
 *  🄯 AGPLv3
 *  ? gdjn entry point
 */

#include "gdjn.h"
#include "janet-lang.h"
#include "janet-rsrc.h"


gdjn* gdjn_ctx = nullptr;












static void
gdjn_init
(	void*                          data,
	GDExtensionInitializationLevel lvl
) {
	if (lvl != GDEXTENSION_INITIALIZATION_SCENE) return;
	gdjn_types_fetch(&gdjn_ctx -> gd.t, gdjn_ctx -> gd.getProc);

	const gdjn_typeDB* c = &gdjn_ctx -> gd.t;





	gdjn_unit_janetLang_load();
	gdjn_unit_janetRsrc_load();

	gdjn_ctx -> gd.janetLang_inst = gdjn_class_JanetLang_new() -> self;

	auto e = gd_engine_registerScriptLanguage(
		c -> objects.engine,
................................................................................
		false
	);
	gd_resourceSaver_addResourceFormatSaver(
		gdjn_ctx -> gd.t.objects.resourceSaver,
		gdjn_ctx -> gd.janetSaver_inst,
		false
	);
		/*
	gd_variant ret;
	c -> gd_object.methodBindPtrcall(
		c -> gd_m_engine.registerScriptLanguage_ptr,
		c -> objects.engine,
		(GDExtensionConstTypePtr[]) {
			&gdjn_ctx -> gd.janetLang_inst,
		}, &ret
	);
	*/

	_t(array).empty(&gdjn_ctx -> gd.dox, nullptr);
	gd_stringName empty = {};
	_t(stringName).empty(&empty, nullptr);
	_t(array).setTyped(&gdjn_ctx -> gd.dox,
			GDEXTENSION_VARIANT_TYPE_DICTIONARY, &empty, &empty);

................................................................................
(	void*                          data,
	GDExtensionInitializationLevel lvl
) {
	if (lvl != GDEXTENSION_INITIALIZATION_SCENE) return;
	/* we get double frees otherwise */

	const gdjn_typeDB* c = &gdjn_ctx -> gd.t;


	gd_engine_unregisterScriptLanguage(
		c -> objects.engine,
		gdjn_ctx -> gd.janetLang_inst
	);
	/*
	GDExtensionTypePtr ret;
................................................................................
	gd_resourceSaver_removeResourceFormatSaver(
		gdjn_ctx -> gd.t.objects.resourceSaver,
		gdjn_ctx -> gd.janetSaver_inst
	);
	/* gd_refCounted_unreference(gdjn_ctx -> gd.janetLoader_inst); */
	/* gd_refCounted_unreference(gdjn_ctx -> gd.janetSaver_inst); */
	gdjn_class_JanetLang_del(nullptr, gdjn_ctx -> gd.janetLang_inst);



	gdjn_ctx -> gd.free(gdjn_ctx);
	gdjn_ctx = nullptr;
}


gdBool







>


>
>
>
>
>
>
>
>
>
>
>











>
>
>
>







 







<
<
<
<
<
<
<
<
<
<







 







>







 







>
>







3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
..
62
63
64
65
66
67
68










69
70
71
72
73
74
75
..
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
...
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
 *  🄯 AGPLv3
 *  ? gdjn entry point
 */

#include "gdjn.h"
#include "janet-lang.h"
#include "janet-rsrc.h"
#include "vm.h"

gdjn* gdjn_ctx = nullptr;

void* gdjn_janet_malloc (size_t sz) { return _alloc(char, sz); }
void  gdjn_janet_free   (void* ptr) { _free(ptr); }
void* gdjn_janet_realloc(void* ptr, size_t sz)
	{ return _realloc(ptr, char, sz); }
void* gdjn_janet_calloc (size_t n, size_t esz) {
	const size_t sz = esz*n;
	void* v = _alloc(char, sz);
	memset(v, 0, sz);
	return v;
}

static void
gdjn_init
(	void*                          data,
	GDExtensionInitializationLevel lvl
) {
	if (lvl != GDEXTENSION_INITIALIZATION_SCENE) return;
	gdjn_types_fetch(&gdjn_ctx -> gd.t, gdjn_ctx -> gd.getProc);

	const gdjn_typeDB* c = &gdjn_ctx -> gd.t;

	janet_init();
	gdjn_ctx -> jn.api = gdjn_vm_api_build_core();
	janet_gcroot(janet_wrap_table(gdjn_ctx -> jn.api));

	gdjn_unit_janetLang_load();
	gdjn_unit_janetRsrc_load();

	gdjn_ctx -> gd.janetLang_inst = gdjn_class_JanetLang_new() -> self;

	auto e = gd_engine_registerScriptLanguage(
		c -> objects.engine,
................................................................................
		false
	);
	gd_resourceSaver_addResourceFormatSaver(
		gdjn_ctx -> gd.t.objects.resourceSaver,
		gdjn_ctx -> gd.janetSaver_inst,
		false
	);











	_t(array).empty(&gdjn_ctx -> gd.dox, nullptr);
	gd_stringName empty = {};
	_t(stringName).empty(&empty, nullptr);
	_t(array).setTyped(&gdjn_ctx -> gd.dox,
			GDEXTENSION_VARIANT_TYPE_DICTIONARY, &empty, &empty);

................................................................................
(	void*                          data,
	GDExtensionInitializationLevel lvl
) {
	if (lvl != GDEXTENSION_INITIALIZATION_SCENE) return;
	/* we get double frees otherwise */

	const gdjn_typeDB* c = &gdjn_ctx -> gd.t;
	janet_gcunroot(janet_wrap_table(gdjn_ctx -> jn.api));

	gd_engine_unregisterScriptLanguage(
		c -> objects.engine,
		gdjn_ctx -> gd.janetLang_inst
	);
	/*
	GDExtensionTypePtr ret;
................................................................................
	gd_resourceSaver_removeResourceFormatSaver(
		gdjn_ctx -> gd.t.objects.resourceSaver,
		gdjn_ctx -> gd.janetSaver_inst
	);
	/* gd_refCounted_unreference(gdjn_ctx -> gd.janetLoader_inst); */
	/* gd_refCounted_unreference(gdjn_ctx -> gd.janetSaver_inst); */
	gdjn_class_JanetLang_del(nullptr, gdjn_ctx -> gd.janetLang_inst);

	janet_deinit();

	gdjn_ctx -> gd.free(gdjn_ctx);
	gdjn_ctx = nullptr;
}


gdBool