@@ -48,10 +48,6 @@ extern const size_t LUA_INIT_SCRIPT_SIZE;
48
48
HGDN_PRINT_ERROR(prefix ": %s", lua_tostring(L, -1)); \
49
49
lua_pop(L, 1)
50
50
51
- #ifdef LUAJIT_DYNAMICALLY_LINKED
52
- // Active shared library path, for loading symbols in FFI
53
- static hgdn_string lps_active_library_path ;
54
- #endif
55
51
static bool lps_in_editor ;
56
52
static int lps_pcall_error_handler_index ;
57
53
static lua_State * lps_L ;
@@ -136,12 +132,12 @@ static godot_pluginscript_language_data *lps_language_init() {
136
132
lua_setfield (L , LUA_REGISTRYINDEX , PLUGINSCRIPT_CALLBACKS_KEY );
137
133
138
134
lua_pushboolean (L , lps_in_editor );
139
- #ifdef LUAJIT_DYNAMICALLY_LINKED
140
- lua_pushlstring (L , lps_active_library_path . ptr , lps_active_library_path . length );
141
- #else
142
- lua_pushnil ( L );
143
- #endif
144
- if (lua_pcall (L , 3 , 0 , lps_pcall_error_handler_index ) != LUA_OK ) {
135
+ lua_pushlightuserdata ( L , ( void * ) hgdn_core_api );
136
+ lua_pushlightuserdata (L , ( void * ) hgdn_core_1_1_api );
137
+ lua_pushlightuserdata ( L , ( void * ) hgdn_core_1_2_api );
138
+ lua_pushlightuserdata ( L , ( void * ) hgdn_core_1_3_api );
139
+ lua_pushlightuserdata ( L , ( void * ) hgdn_library );
140
+ if (lua_pcall (L , 7 , 0 , lps_pcall_error_handler_index ) != LUA_OK ) {
145
141
LPS_PCALL_CONSUME_ERROR (L , "Error in Lua language initialization script" );
146
142
}
147
143
return L ;
@@ -276,7 +272,7 @@ static void lps_instance_notification(godot_pluginscript_instance_data *data, in
276
272
}
277
273
278
274
// In-editor callbacks
279
- godot_string lps_get_template_source_code (godot_pluginscript_language_data * data , const godot_string * class_name , const godot_string * base_class_name ) {
275
+ static godot_string lps_get_template_source_code (godot_pluginscript_language_data * data , const godot_string * class_name , const godot_string * base_class_name ) {
280
276
godot_string ret ;
281
277
hgdn_core_api -> godot_string_new (& ret );
282
278
LPS_PUSH_CALLBACK (lps_L , "get_template_source_code" );
@@ -289,7 +285,7 @@ godot_string lps_get_template_source_code(godot_pluginscript_language_data *data
289
285
return ret ;
290
286
}
291
287
292
- godot_bool lps_validate (godot_pluginscript_language_data * data , const godot_string * script , int * line_error , int * col_error , godot_string * test_error , const godot_string * path , godot_pool_string_array * functions ) {
288
+ static godot_bool lps_validate (godot_pluginscript_language_data * data , const godot_string * script , int * line_error , int * col_error , godot_string * test_error , const godot_string * path , godot_pool_string_array * functions ) {
293
289
LPS_PUSH_CALLBACK (lps_L , "validate" );
294
290
lua_pushlightuserdata (lps_L , (void * ) script );
295
291
lua_pushlightuserdata (lps_L , (void * ) line_error );
@@ -306,7 +302,7 @@ godot_bool lps_validate(godot_pluginscript_language_data *data, const godot_stri
306
302
return success ;
307
303
}
308
304
309
- godot_string lps_make_function (godot_pluginscript_language_data * data , const godot_string * class_name , const godot_string * name , const godot_pool_string_array * args ) {
305
+ static godot_string lps_make_function (godot_pluginscript_language_data * data , const godot_string * class_name , const godot_string * name , const godot_pool_string_array * args ) {
310
306
godot_string ret ;
311
307
hgdn_core_api -> godot_string_new (& ret );
312
308
LPS_PUSH_CALLBACK (lps_L , "make_function" );
@@ -320,7 +316,7 @@ godot_string lps_make_function(godot_pluginscript_language_data *data, const god
320
316
return ret ;
321
317
}
322
318
323
- void lps_register_in_editor_callbacks (godot_pluginscript_language_desc * desc ) {
319
+ static void lps_register_in_editor_callbacks (godot_pluginscript_language_desc * desc ) {
324
320
desc -> get_template_source_code = & lps_get_template_source_code ;
325
321
desc -> validate = & lps_validate ;
326
322
desc -> make_function = & lps_make_function ;
@@ -384,31 +380,10 @@ GDN_EXPORT void PREFIX_SYMBOL(gdnative_init)(godot_gdnative_init_options *option
384
380
lps_register_in_editor_callbacks (& lps_language_desc );
385
381
}
386
382
387
- #ifdef LUAJIT_DYNAMICALLY_LINKED
388
- godot_object * OS = hgdn_core_api -> godot_global_get_singleton ("OS" );
389
- if (hgdn_variant_get_bool_own (hgdn_object_call (OS , "has_feature" , "standalone" ))) {
390
- godot_variant exepath_var = hgdn_object_callv (OS , "get_executable_path" , NULL );
391
- godot_string exepath = hgdn_core_api -> godot_variant_as_string (& exepath_var );
392
- godot_string exedir = hgdn_core_api -> godot_string_get_base_dir (& exepath );
393
- godot_string library_filepath = hgdn_core_api -> godot_string_get_file (options -> active_library_path );
394
- lps_active_library_path = hgdn_string_get_own (hgdn_core_api -> godot_string_plus_file (& exedir , & library_filepath ));
395
- hgdn_core_api -> godot_string_destroy (& library_filepath );
396
- hgdn_core_api -> godot_string_destroy (& exedir );
397
- hgdn_core_api -> godot_string_destroy (& exepath );
398
- hgdn_core_api -> godot_variant_destroy (& exepath_var );
399
- }
400
- else {
401
- lps_active_library_path = hgdn_string_get (options -> active_library_path );
402
- }
403
- #endif
404
-
405
383
hgdn_pluginscript_api -> godot_pluginscript_register_language (& lps_language_desc );
406
384
}
407
385
408
386
GDN_EXPORT void PREFIX_SYMBOL (gdnative_terminate )(godot_gdnative_terminate_options * options ) {
409
- #ifdef LUAJIT_DYNAMICALLY_LINKED
410
- hgdn_string_destroy (& lps_active_library_path );
411
- #endif
412
387
hgdn_gdnative_terminate (options );
413
388
}
414
389
0 commit comments