Merge pull request #58925 from akien-mga/remove-unused-gdnative-code

This commit is contained in:
Rémi Verschelde 2022-03-09 15:57:30 +01:00 committed by GitHub
commit 922348f4c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
110 changed files with 13 additions and 19798 deletions

View File

@ -6,7 +6,7 @@
<description>
This audio stream does not play back sounds, but expects a script to generate audio data for it instead. See also [AudioStreamGeneratorPlayback].
See also [AudioEffectSpectrumAnalyzer] for performing real-time audio spectrum analysis.
[b]Note:[/b] Due to performance constraints, this class is best used from C# or from a compiled language via GDNative. If you still want to use this class from GDScript, consider using a lower [member mix_rate] such as 11,025 Hz or 22,050 Hz.
[b]Note:[/b] Due to performance constraints, this class is best used from C# or from a compiled language via GDExtension. If you still want to use this class from GDScript, consider using a lower [member mix_rate] such as 11,025 Hz or 22,050 Hz.
</description>
<tutorials>
<link title="Audio Generator Demo">https://godotengine.org/asset-library/asset/526</link>

View File

@ -39,14 +39,14 @@
<return type="bool" />
<argument index="0" name="frames" type="PackedVector2Array" />
<description>
Pushes several audio data frames to the buffer. This is usually more efficient than [method push_frame] in C# and compiled languages via GDNative, but [method push_buffer] may be [i]less[/i] efficient in GDScript.
Pushes several audio data frames to the buffer. This is usually more efficient than [method push_frame] in C# and compiled languages via GDExtension, but [method push_buffer] may be [i]less[/i] efficient in GDScript.
</description>
</method>
<method name="push_frame">
<return type="bool" />
<argument index="0" name="frame" type="Vector2" />
<description>
Pushes a single audio data frame to the buffer. This is usually less efficient than [method push_buffer] in C# and compiled languages via GDNative, but [method push_frame] may be [i]more[/i] efficient in GDScript.
Pushes a single audio data frame to the buffer. This is usually less efficient than [method push_buffer] in C# and compiled languages via GDExtension, but [method push_frame] may be [i]more[/i] efficient in GDScript.
</description>
</method>
</methods>

View File

@ -4,7 +4,7 @@
Version Control System (VCS) interface which reads and writes to the local VCS in use.
</brief_description>
<description>
Used by the editor to display VCS extracted information in the editor. The implementation of this API is included in VCS addons, which are essentially GDNative plugins that need to be put into the project folder. These VCS addons are scripts which are attached (on demand) to the object instance of [code]EditorVCSInterface[/code]. All the functions listed below, instead of performing the task themselves, they call the internally defined functions in the VCS addons to provide a plug-n-play experience.
Used by the editor to display VCS extracted information in the editor. The implementation of this API is included in VCS addons, which are essentially GDExtension plugins that need to be put into the project folder. These VCS addons are scripts which are attached (on demand) to the object instance of [code]EditorVCSInterface[/code]. All the functions listed below, instead of performing the task themselves, they call the internally defined functions in the VCS addons to provide a plug-n-play experience.
</description>
<tutorials>
</tutorials>

View File

@ -25,7 +25,6 @@
- GDScript automatically wrap values in them. It keeps all data in plain Variants by default and then optionally enforces custom static typing rules on variable types.
- VisualScript tracks properties inside Variants as well, but it also uses static typing. The GUI interface enforces that properties have a particular type that doesn't change over time.
- C# is statically typed, but uses the Mono [code]object[/code] type in place of Godot's Variant class when it needs to represent a dynamic value. [code]object[/code] is the Mono runtime's equivalent of the same concept.
- The statically-typed language NativeScript C++ does not define a built-in Variant-like class. Godot's GDNative bindings provide their own godot::Variant class for users; Any point at which the C++ code starts interacting with the Godot runtime is a place where you might have to start wrapping data inside Variant objects.
The global [method @GlobalScope.typeof] function returns the enumerated value of the Variant type stored in the current variable (see [enum Variant.Type]).
[codeblocks]
[gdscript]

View File

@ -5,7 +5,7 @@
</brief_description>
<description>
Control node for playing video streams using [VideoStream] resources.
Supported video formats are [url=https://www.theora.org/]Ogg Theora[/url] ([code].ogv[/code], [VideoStreamTheora]) and any format exposed via a GDNative plugin using [VideoStreamGDNative].
Supported video formats are [url=https://www.theora.org/]Ogg Theora[/url] ([code].ogv[/code], [VideoStreamTheora]) and any format exposed via a GDExtension plugin.
[b]Note:[/b] Due to a bug, VideoStreamPlayer does not support localization remapping yet.
[b]Warning:[/b] On HTML5, video playback [i]will[/i] perform poorly due to missing architecture-specific assembly optimizations.
</description>
@ -69,7 +69,7 @@
</member>
<member name="stream_position" type="float" setter="set_stream_position" getter="get_stream_position">
The current position of the stream, in seconds.
[b]Note:[/b] Changing this value won't have any effect as seeking is not implemented yet, except in video formats implemented by a GDNative add-on.
[b]Note:[/b] Changing this value won't have any effect as seeking is not implemented yet, except in video formats implemented by a GDExtension add-on.
</member>
<member name="volume" type="float" setter="set_volume" getter="get_volume">
Audio volume as a linear value.

View File

@ -4,7 +4,7 @@
Base class for an XR interface implementation.
</brief_description>
<description>
This class needs to be implemented to make an AR or VR platform available to Godot and these should be implemented as C++ modules or GDNative modules (note that for GDNative the subclass XRScriptInterface should be used). Part of the interface is exposed to GDScript so you can detect, enable and configure an AR or VR platform.
This class needs to be implemented to make an AR or VR platform available to Godot and these should be implemented as C++ modules or GDExtension modules. Part of the interface is exposed to GDScript so you can detect, enable and configure an AR or VR platform.
Interfaces should be written in such a way that simply enabling them will give us a working setup. You can query the available interfaces through [XRServer].
</description>
<tutorials>

View File

@ -439,12 +439,12 @@ Error OS_Unix::open_dynamic_library(const String p_path, void *&p_library_handle
}
if (!FileAccess::exists(path)) {
//this code exists so gdnative can load .so files from within the executable path
// This code exists so GDExtension can load .so files from within the executable path.
path = get_executable_path().get_base_dir().plus_file(p_path.get_file());
}
if (!FileAccess::exists(path)) {
//this code exists so gdnative can load .so files from a standard unix location
// This code exists so GDExtension can load .so files from a standard unix location.
path = get_executable_path().get_base_dir().plus_file("../lib").plus_file(p_path.get_file());
}

View File

@ -371,11 +371,6 @@ void Main::print_help(const char *p_binary) {
OS::get_singleton()->print(" --no-docbase Disallow dumping the base types (used with --doctool).\n");
OS::get_singleton()->print(" --build-solutions Build the scripting solutions (e.g. for C# projects). Implies --editor and requires a valid project to edit.\n");
OS::get_singleton()->print(" --dump-extension-api Generate JSON dump of the Godot API for GDExtension bindings named 'extension_api.json' in the current folder.\n");
#ifdef DEBUG_METHODS_ENABLED
// TODO: Should be removed together with nativescript eventually.
OS::get_singleton()->print(" --gdnative-generate-json-api <path> Generate JSON dump of the Godot API for GDNative bindings and save it on the file specified in <path>.\n");
OS::get_singleton()->print(" --gdnative-generate-json-builtin-api <path> Generate JSON dump of the Godot API of the builtin Variant types and utility functions for GDNative bindings and save it on the file specified in <path>.\n");
#endif
#ifdef TESTS_ENABLED
OS::get_singleton()->print(" --test [--help] Run unit tests. Use --test --help for more information.\n");
#endif
@ -946,15 +941,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
auto_build_solutions = true;
editor = true;
cmdline_tool = true;
#ifdef DEBUG_METHODS_ENABLED
} else if (I->get() == "--gdnative-generate-json-api" || I->get() == "--gdnative-generate-json-builtin-api") {
// Register as an editor instance to use low-end fallback if relevant.
editor = true;
cmdline_tool = true;
// We still pass it to the main arguments since the argument handling itself is not done in this function,
// it's done in nativescript init code.
main_args.push_back(I->get());
#endif
} else if (I->get() == "--dump-extension-api") {
// Register as an editor instance to use low-end fallback if relevant.
editor = true;

View File

@ -150,9 +150,6 @@ Disallow dumping the base types (used with \fB\-\-doctool\fR).
\fB\-\-build\-solutions\fR
Build the scripting solutions (e.g. for C# projects). Implies \-\-editor and requires a valid project to edit.
.TP
\fB\-\-gdnative\-generate\-json\-api\fR
Generate JSON dump of the Godot API for GDNative bindings.
.TP
\fB\-\-test\fR <test>
Run a unit test ('string', 'math', 'physics', 'physics_2d', 'render', 'oa_hash_map', 'gui', 'shaderlang', 'gd_tokenizer', 'gd_parser', 'gd_compiler', 'gd_bytecode', 'ordered_hash_map', 'astar').
.SH FILES

View File

@ -70,5 +70,4 @@ _arguments \
'--doctool[dump the engine API reference to the given path in XML format, merging if existing files are found]:path to base Godot build directory:_dirs' \
'--no-docbase[disallow dumping the base types (used with --doctool)]' \
'--build-solutions[build the scripting solutions (e.g. for C# projects)]' \
'--gdnative-generate-json-api[generate JSON dump of the Godot API for GDNative bindings]' \
'--test[run a unit test]:unit test name'

View File

@ -73,7 +73,6 @@ _complete_godot_options() {
--doctool
--no-docbase
--build-solutions
--gdnative-generate-json-api
--test
" -- "$1"))
}

View File

@ -84,5 +84,4 @@ complete -c godot -l export-pack -d "Same as --export, but only export the game
complete -c godot -l doctool -d "Dump the engine API reference to the given path in XML format, merging if existing files are found" -r
complete -c godot -l no-docbase -d "Disallow dumping the base types (used with --doctool)"
complete -c godot -l build-solutions -d "Build the scripting solutions (e.g. for C# projects)"
complete -c godot -l gdnative-generate-json-api -d "Generate JSON dump of the Godot API for GDNative bindings"
complete -c godot -l test -d "Run a unit test" -x

View File

@ -1,30 +0,0 @@
#!/usr/bin/env python
Import("env")
Import("env_modules")
env_gdnative = env_modules.Clone()
env_gdnative.add_source_files(env.modules_sources, "gdnative.cpp")
env_gdnative.add_source_files(env.modules_sources, "register_types.cpp")
env_gdnative.add_source_files(env.modules_sources, "android/*.cpp")
env_gdnative.add_source_files(env.modules_sources, "gdnative/*.cpp")
env_gdnative.add_source_files(env.modules_sources, "nativescript/*.cpp")
env_gdnative.add_source_files(env.modules_sources, "gdnative_library_singleton_editor.cpp")
env_gdnative.add_source_files(env.modules_sources, "gdnative_library_editor_plugin.cpp")
env_gdnative.Prepend(CPPPATH=["#modules/gdnative/include/"])
Export("env_gdnative")
SConscript("pluginscript/SCsub")
SConscript("videodecoder/SCsub")
import gdnative_builders
_, gensource = env_gdnative.CommandNoCache(
["include/gdnative_api_struct.gen.h", "gdnative_api_struct.gen.cpp"],
"gdnative_api.json",
env.Run(gdnative_builders.build_gdnative_api_struct, "Generating GDNative API."),
)
env_gdnative.add_source_files(env.modules_sources, [gensource])

View File

@ -1,86 +0,0 @@
/*************************************************************************/
/* android_gdn.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "modules/gdnative/gdnative.h"
// Code by Paritosh97 with minor tweaks by Mux213
// These entry points are only for the android platform and are simple stubs in all others.
#ifdef __ANDROID__
#include "platform/android/java_godot_wrapper.h"
#include "platform/android/os_android.h"
#include "platform/android/thread_jandroid.h"
#else
#define JNIEnv void
#define jobject void *
#endif
#ifdef __cplusplus
extern "C" {
#endif
JNIEnv *GDAPI godot_android_get_env() {
#ifdef __ANDROID__
return get_jni_env();
#else
return nullptr;
#endif
}
jobject GDAPI godot_android_get_activity() {
#ifdef __ANDROID__
OS_Android *os_android = (OS_Android *)OS::get_singleton();
return os_android->get_godot_java()->get_activity();
#else
return nullptr;
#endif
}
jobject GDAPI godot_android_get_surface() {
#ifdef __ANDROID__
OS_Android *os_android = (OS_Android *)OS::get_singleton();
return os_android->get_godot_java()->get_surface();
#else
return nullptr;
#endif
}
bool GDAPI godot_android_is_activity_resumed() {
#ifdef __ANDROID__
OS_Android *os_android = (OS_Android *)OS::get_singleton();
return os_android->get_godot_java()->is_activity_resumed();
#else
return false;
#endif
}
#ifdef __cplusplus
}
#endif

View File

@ -1,20 +0,0 @@
def can_build(env, platform):
return True
def configure(env):
pass
def get_doc_classes():
return [
"GDNative",
"GDNativeLibrary",
"NativeScript",
"PluginScript",
"VideoStreamGDNative",
]
def get_doc_path():
return "doc_classes"

View File

@ -1,33 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GDNative" inherits="RefCounted" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="call_native">
<return type="Variant" />
<argument index="0" name="calling_type" type="StringName" />
<argument index="1" name="procedure_name" type="StringName" />
<argument index="2" name="arguments" type="Array" />
<description>
</description>
</method>
<method name="initialize">
<return type="bool" />
<description>
</description>
</method>
<method name="terminate">
<return type="bool" />
<description>
</description>
</method>
</methods>
<members>
<member name="library" type="GDNativeLibrary" setter="set_library" getter="get_library">
</member>
</members>
</class>

View File

@ -1,48 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="GDNativeLibrary" inherits="Resource" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
An external library containing functions or script classes to use in Godot.
</brief_description>
<description>
A GDNative library can implement [NativeScript]s, global functions to call with the [GDNative] class, or low-level engine extensions through interfaces such as XRInterfaceGDNative. The library must be compiled for each platform and architecture that the project will run on.
</description>
<tutorials>
<link title="GDNative C example">$DOCS_URL/tutorials/scripting/gdnative/gdnative_c_example.html</link>
<link title="GDNative C++ example">$DOCS_URL/tutorials/scripting/gdnative/gdnative_cpp_example.html</link>
</tutorials>
<methods>
<method name="get_current_dependencies" qualifiers="const">
<return type="PackedStringArray" />
<description>
Returns paths to all dependency libraries for the current platform and architecture.
</description>
</method>
<method name="get_current_library_path" qualifiers="const">
<return type="String" />
<description>
Returns the path to the dynamic library file for the current platform and architecture.
</description>
</method>
</methods>
<members>
<member name="config_file" type="ConfigFile" setter="set_config_file" getter="get_config_file">
This resource in INI-style [ConfigFile] format, as in [code].gdnlib[/code] files.
</member>
<member name="load_once" type="bool" setter="set_load_once" getter="should_load_once" default="true">
If [code]true[/code], Godot loads only one copy of the library and each script that references the library will share static data like static or global variables.
If [code]false[/code], Godot loads a separate copy of the library into memory for each script that references it.
</member>
<member name="reloadable" type="bool" setter="set_reloadable" getter="is_reloadable" default="true">
If [code]true[/code], the editor will temporarily unload the library whenever the user switches away from the editor window, allowing the user to recompile the library without restarting Godot.
[b]Note:[/b] If the library defines tool scripts that run inside the editor, [code]reloadable[/code] must be [code]false[/code]. Otherwise, the editor will attempt to unload the tool scripts while they're in use and crash.
</member>
<member name="singleton" type="bool" setter="set_singleton" getter="is_singleton" default="false">
If [code]true[/code], Godot loads the library at startup rather than the first time a script uses the library, calling [code]{prefix}gdnative_singleton[/code] after initializing the library (where [code]{prefix}[/code] is the value of [member symbol_prefix]). The library remains loaded as long as Godot is running.
[b]Note:[/b] A singleton library cannot be [member reloadable].
</member>
<member name="symbol_prefix" type="String" setter="set_symbol_prefix" getter="get_symbol_prefix" default="&quot;godot_&quot;">
The prefix this library's entry point functions begin with. For example, a GDNativeLibrary would declare its [code]gdnative_init[/code] function as [code]godot_gdnative_init[/code] by default.
On platforms that require statically linking libraries (currently only iOS), each library must have a different [code]symbol_prefix[/code].
</member>
</members>
</class>

View File

@ -1,55 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="NativeScript" inherits="Script" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="get_class_documentation" qualifiers="const">
<return type="String" />
<description>
Returns the documentation string that was previously set with [code]godot_nativescript_set_class_documentation[/code].
</description>
</method>
<method name="get_method_documentation" qualifiers="const">
<return type="String" />
<argument index="0" name="method" type="StringName" />
<description>
Returns the documentation string that was previously set with [code]godot_nativescript_set_method_documentation[/code].
</description>
</method>
<method name="get_property_documentation" qualifiers="const">
<return type="String" />
<argument index="0" name="path" type="StringName" />
<description>
Returns the documentation string that was previously set with [code]godot_nativescript_set_property_documentation[/code].
</description>
</method>
<method name="get_signal_documentation" qualifiers="const">
<return type="String" />
<argument index="0" name="signal_name" type="StringName" />
<description>
Returns the documentation string that was previously set with [code]godot_nativescript_set_signal_documentation[/code].
</description>
</method>
<method name="new" qualifiers="vararg">
<return type="Variant" />
<description>
Constructs a new object of the base type with a script of this type already attached.
[b]Note:[/b] Any arguments passed to this function will be ignored and not passed to the native constructor function. This will change with in a future API extension.
</description>
</method>
</methods>
<members>
<member name="class_name" type="String" setter="set_class_name" getter="get_class_name" default="&quot;&quot;">
</member>
<member name="library" type="GDNativeLibrary" setter="set_library" getter="get_library">
</member>
<member name="script_class_icon_path" type="String" setter="set_script_class_icon_path" getter="get_script_class_icon_path" default="&quot;&quot;">
</member>
<member name="script_class_name" type="String" setter="set_script_class_name" getter="get_script_class_name" default="&quot;&quot;">
</member>
</members>
</class>

View File

@ -1,17 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PluginScript" inherits="Script" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
<method name="new" qualifiers="vararg">
<return type="Variant" />
<description>
Returns a new instance of the script.
</description>
</method>
</methods>
</class>

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="VideoStreamGDNative" inherits="VideoStream" version="4.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
<brief_description>
[VideoStream] resource for for video formats implemented via GDNative.
</brief_description>
<description>
[VideoStream] resource for for video formats implemented via GDNative.
It can be used via [url=https://github.com/KidRigger/godot-videodecoder]godot-videodecoder[/url] which uses the [url=https://ffmpeg.org]FFmpeg[/url] library.
</description>
<tutorials>
</tutorials>
<methods>
<method name="get_file">
<return type="String" />
<description>
Returns the video file handled by this [VideoStreamGDNative].
</description>
</method>
<method name="set_file">
<return type="void" />
<argument index="0" name="file" type="String" />
<description>
Sets the video file that this [VideoStreamGDNative] resource handles. The supported extensions depend on the GDNative plugins used to expose video formats.
</description>
</method>
</methods>
</class>

View File

@ -1,583 +0,0 @@
/*************************************************************************/
/* gdnative.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative.h"
#include "core/config/project_settings.h"
#include "core/core_constants.h"
#include "core/io/dir_access.h"
#include "core/io/file_access.h"
#include "core/io/file_access_encrypted.h"
#include "core/os/os.h"
#include "scene/main/scene_tree.h"
static const String init_symbol = "gdnative_init";
static const String terminate_symbol = "gdnative_terminate";
static const String default_symbol_prefix = "godot_";
static const bool default_singleton = false;
static const bool default_load_once = true;
static const bool default_reloadable = true;
// Defined in gdnative_api_struct.gen.cpp
extern const godot_gdnative_core_api_struct api_struct;
Map<String, Vector<Ref<GDNative>>> GDNativeLibrary::loaded_libraries;
GDNativeLibrary::GDNativeLibrary() {
config_file.instantiate();
symbol_prefix = default_symbol_prefix;
load_once = default_load_once;
singleton = default_singleton;
reloadable = default_reloadable;
}
GDNativeLibrary::~GDNativeLibrary() {
}
bool GDNativeLibrary::_set(const StringName &p_name, const Variant &p_property) {
String name = p_name;
if (name.begins_with("entry/")) {
String key = name.substr(6, name.length() - 6);
config_file->set_value("entry", key, p_property);
set_config_file(config_file);
return true;
}
if (name.begins_with("dependency/")) {
String key = name.substr(11, name.length() - 11);
config_file->set_value("dependencies", key, p_property);
set_config_file(config_file);
return true;
}
return false;
}
bool GDNativeLibrary::_get(const StringName &p_name, Variant &r_property) const {
String name = p_name;
if (name.begins_with("entry/")) {
String key = name.substr(6, name.length() - 6);
r_property = config_file->get_value("entry", key);
return true;
}
if (name.begins_with("dependency/")) {
String key = name.substr(11, name.length() - 11);
r_property = config_file->get_value("dependencies", key);
return true;
}
return false;
}
void GDNativeLibrary::reset_state() {
config_file.instantiate();
current_library_path = "";
current_dependencies.clear();
symbol_prefix = default_symbol_prefix;
load_once = default_load_once;
singleton = default_singleton;
reloadable = default_reloadable;
}
void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
// set entries
List<String> entry_key_list;
if (config_file->has_section("entry")) {
config_file->get_section_keys("entry", &entry_key_list);
}
for (const String &key : entry_key_list) {
PropertyInfo prop;
prop.type = Variant::STRING;
prop.name = "entry/" + key;
p_list->push_back(prop);
}
// set dependencies
List<String> dependency_key_list;
if (config_file->has_section("dependencies")) {
config_file->get_section_keys("dependencies", &dependency_key_list);
}
for (const String &key : dependency_key_list) {
PropertyInfo prop;
prop.type = Variant::STRING;
prop.name = "dependency/" + key;
p_list->push_back(prop);
}
}
void GDNativeLibrary::set_config_file(Ref<ConfigFile> p_config_file) {
ERR_FAIL_COND(p_config_file.is_null());
set_singleton(p_config_file->get_value("general", "singleton", default_singleton));
set_load_once(p_config_file->get_value("general", "load_once", default_load_once));
set_symbol_prefix(p_config_file->get_value("general", "symbol_prefix", default_symbol_prefix));
set_reloadable(p_config_file->get_value("general", "reloadable", default_reloadable));
String entry_lib_path;
{
List<String> entry_keys;
if (p_config_file->has_section("entry")) {
p_config_file->get_section_keys("entry", &entry_keys);
}
for (const String &key : entry_keys) {
Vector<String> tags = key.split(".");
bool skip = false;
for (int i = 0; i < tags.size(); i++) {
bool has_feature = OS::get_singleton()->has_feature(tags[i]);
if (!has_feature) {
skip = true;
break;
}
}
if (skip) {
continue;
}
entry_lib_path = p_config_file->get_value("entry", key);
break;
}
}
Vector<String> dependency_paths;
{
List<String> dependency_keys;
if (p_config_file->has_section("dependencies")) {
p_config_file->get_section_keys("dependencies", &dependency_keys);
}
for (const String &key : dependency_keys) {
Vector<String> tags = key.split(".");
bool skip = false;
for (int i = 0; i < tags.size(); i++) {
bool has_feature = OS::get_singleton()->has_feature(tags[i]);
if (!has_feature) {
skip = true;
break;
}
}
if (skip) {
continue;
}
dependency_paths = p_config_file->get_value("dependencies", key);
break;
}
}
current_library_path = entry_lib_path;
current_dependencies = dependency_paths;
}
void GDNativeLibrary::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_config_file"), &GDNativeLibrary::get_config_file);
ClassDB::bind_method(D_METHOD("set_config_file", "config_file"), &GDNativeLibrary::set_config_file);
ClassDB::bind_method(D_METHOD("get_current_library_path"), &GDNativeLibrary::get_current_library_path);
ClassDB::bind_method(D_METHOD("get_current_dependencies"), &GDNativeLibrary::get_current_dependencies);
ClassDB::bind_method(D_METHOD("should_load_once"), &GDNativeLibrary::should_load_once);
ClassDB::bind_method(D_METHOD("is_singleton"), &GDNativeLibrary::is_singleton);
ClassDB::bind_method(D_METHOD("get_symbol_prefix"), &GDNativeLibrary::get_symbol_prefix);
ClassDB::bind_method(D_METHOD("is_reloadable"), &GDNativeLibrary::is_reloadable);
ClassDB::bind_method(D_METHOD("set_load_once", "load_once"), &GDNativeLibrary::set_load_once);
ClassDB::bind_method(D_METHOD("set_singleton", "singleton"), &GDNativeLibrary::set_singleton);
ClassDB::bind_method(D_METHOD("set_symbol_prefix", "symbol_prefix"), &GDNativeLibrary::set_symbol_prefix);
ClassDB::bind_method(D_METHOD("set_reloadable", "reloadable"), &GDNativeLibrary::set_reloadable);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "config_file", PROPERTY_HINT_RESOURCE_TYPE, "ConfigFile", PROPERTY_USAGE_NONE), "set_config_file", "get_config_file");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "load_once"), "set_load_once", "should_load_once");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "singleton"), "set_singleton", "is_singleton");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "symbol_prefix"), "set_symbol_prefix", "get_symbol_prefix");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "reloadable"), "set_reloadable", "is_reloadable");
}
GDNative::GDNative() {
native_handle = nullptr;
initialized = false;
}
GDNative::~GDNative() {
}
void GDNative::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_library", "library"), &GDNative::set_library);
ClassDB::bind_method(D_METHOD("get_library"), &GDNative::get_library);
ClassDB::bind_method(D_METHOD("initialize"), &GDNative::initialize);
ClassDB::bind_method(D_METHOD("terminate"), &GDNative::terminate);
ClassDB::bind_method(D_METHOD("call_native", "calling_type", "procedure_name", "arguments"), &GDNative::call_native);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "library", PROPERTY_HINT_RESOURCE_TYPE, "GDNativeLibrary"), "set_library", "get_library");
}
void GDNative::set_library(Ref<GDNativeLibrary> p_library) {
ERR_FAIL_COND_MSG(library.is_valid(), "Tried to change library of GDNative when it is already set.");
library = p_library;
}
Ref<GDNativeLibrary> GDNative::get_library() const {
return library;
}
extern "C" void _gdnative_report_version_mismatch(const godot_object *p_library, const char *p_ext, godot_gdnative_api_version p_want, godot_gdnative_api_version p_have);
extern "C" void _gdnative_report_loading_error(const godot_object *p_library, const char *p_what);
bool GDNative::initialize() {
if (library.is_null()) {
ERR_PRINT("No library set, can't initialize GDNative object");
return false;
}
String lib_path = library->get_current_library_path();
if (lib_path.is_empty()) {
ERR_PRINT("No library set for this platform");
return false;
}
#ifdef IPHONE_ENABLED
// On iOS we use static linking by default.
String path = "";
// On iOS dylibs is not allowed, but can be replaced with .framework or .xcframework.
// If they are used, we can run dlopen on them.
// They should be located under Frameworks directory, so we need to replace library path.
if (!lib_path.ends_with(".a")) {
path = ProjectSettings::get_singleton()->globalize_path(lib_path);
if (!FileAccess::exists(path)) {
String lib_name = lib_path.get_basename().get_file();
String framework_path_format = "Frameworks/$name.framework/$name";
Dictionary format_dict;
format_dict["name"] = lib_name;
String framework_path = framework_path_format.format(format_dict, "$_");
path = OS::get_singleton()->get_executable_path().get_base_dir().plus_file(framework_path);
}
}
#elif defined(ANDROID_ENABLED)
// On Android dynamic libraries are located separately from resource assets,
// we should pass library name to dlopen(). The library name is flattened
// during export.
String path = lib_path.get_file();
#elif defined(UWP_ENABLED)
// On UWP we use a relative path from the app
String path = lib_path.replace("res://", "");
#elif defined(OSX_ENABLED)
// On OSX the exported libraries are located under the Frameworks directory.
// So we need to replace the library path.
String path = ProjectSettings::get_singleton()->globalize_path(lib_path);
DirAccess *da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
if (!da->file_exists(path) && !da->dir_exists(path)) {
path = OS::get_singleton()->get_executable_path().get_base_dir().plus_file("../Frameworks").plus_file(lib_path.get_file());
}
if (da->dir_exists(path)) { // Target library is a ".framework", add library base name to the path.
path = path.plus_file(path.get_file().get_basename());
}
memdelete(da);
#else
String path = ProjectSettings::get_singleton()->globalize_path(lib_path);
#endif
if (library->should_load_once()) {
if (GDNativeLibrary::loaded_libraries.has(lib_path)) {
// already loaded. Don't load again.
// copy some of the stuff instead
this->native_handle = GDNativeLibrary::loaded_libraries[lib_path][0]->native_handle;
initialized = true;
return true;
}
}
Error err = OS::get_singleton()->open_dynamic_library(path, native_handle, true);
if (err != OK) {
return false;
}
void *library_init;
// we cheat here a little bit. you saw nothing
initialized = true;
err = get_symbol(library->get_symbol_prefix() + init_symbol, library_init, false);
initialized = false;
if (err || !library_init) {
OS::get_singleton()->close_dynamic_library(native_handle);
native_handle = nullptr;
ERR_PRINT("Failed to obtain " + library->get_symbol_prefix() + "gdnative_init symbol");
return false;
}
godot_gdnative_init_fn library_init_fpointer;
library_init_fpointer = (godot_gdnative_init_fn)library_init;
static uint64_t core_api_hash = 0;
static uint64_t editor_api_hash = 0;
static uint64_t no_api_hash = 0;
if (!(core_api_hash || editor_api_hash || no_api_hash)) {
core_api_hash = ClassDB::get_api_hash(ClassDB::API_CORE);
editor_api_hash = ClassDB::get_api_hash(ClassDB::API_EDITOR);
no_api_hash = ClassDB::get_api_hash(ClassDB::API_NONE);
}
godot_gdnative_init_options options;
options.api_struct = &api_struct;
options.in_editor = Engine::get_singleton()->is_editor_hint();
options.core_api_hash = core_api_hash;
options.editor_api_hash = editor_api_hash;
options.no_api_hash = no_api_hash;
options.report_version_mismatch = &_gdnative_report_version_mismatch;
options.report_loading_error = &_gdnative_report_loading_error;
options.gd_native_library = (godot_object *)(get_library().ptr());
options.active_library_path = (godot_string *)&path;
library_init_fpointer(&options);
initialized = true;
if (library->should_load_once() && !GDNativeLibrary::loaded_libraries.has(lib_path)) {
Vector<Ref<GDNative>> gdnatives;
gdnatives.resize(1);
gdnatives.write[0] = Ref<GDNative>(this);
GDNativeLibrary::loaded_libraries.insert(lib_path, gdnatives);
}
return true;
}
bool GDNative::terminate() {
if (!initialized) {
ERR_PRINT("No valid library handle, can't terminate GDNative object");
return false;
}
if (library->should_load_once()) {
Vector<Ref<GDNative>> *gdnatives = &GDNativeLibrary::loaded_libraries[library->get_current_library_path()];
if (gdnatives->size() > 1) {
// there are other GDNative's still using this library, so we actually don't terminate
gdnatives->erase(Ref<GDNative>(this));
initialized = false;
return true;
} else if (gdnatives->size() == 1) {
// we're the last one, terminate!
gdnatives->clear();
// whew this looks scary, but all it does is remove the entry completely
GDNativeLibrary::loaded_libraries.erase(GDNativeLibrary::loaded_libraries.find(library->get_current_library_path()));
}
}
void *library_terminate;
Error error = get_symbol(library->get_symbol_prefix() + terminate_symbol, library_terminate);
if (error || !library_terminate) {
OS::get_singleton()->close_dynamic_library(native_handle);
native_handle = nullptr;
initialized = false;
return true;
}
godot_gdnative_terminate_fn library_terminate_pointer;
library_terminate_pointer = (godot_gdnative_terminate_fn)library_terminate;
godot_gdnative_terminate_options options;
options.in_editor = Engine::get_singleton()->is_editor_hint();
library_terminate_pointer(&options);
initialized = false;
// GDNativeScriptLanguage::get_singleton()->initialized_libraries.erase(p_native_lib->path);
OS::get_singleton()->close_dynamic_library(native_handle);
native_handle = nullptr;
return true;
}
bool GDNative::is_initialized() const {
return initialized;
}
void GDNativeCallRegistry::register_native_call_type(StringName p_call_type, native_call_cb p_callback) {
native_calls.insert(p_call_type, p_callback);
}
Vector<StringName> GDNativeCallRegistry::get_native_call_types() {
Vector<StringName> call_types;
call_types.resize(native_calls.size());
size_t idx = 0;
for (Map<StringName, native_call_cb>::Element *E = native_calls.front(); E; E = E->next(), idx++) {
call_types.write[idx] = E->key();
}
return call_types;
}
Variant GDNative::call_native(StringName p_native_call_type, StringName p_procedure_name, Array p_arguments) {
Map<StringName, native_call_cb>::Element *E = GDNativeCallRegistry::singleton->native_calls.find(p_native_call_type);
if (!E) {
ERR_PRINT((String("No handler for native call type \"" + p_native_call_type) + "\" found").utf8().get_data());
return Variant();
}
void *procedure_handle;
Error err = OS::get_singleton()->get_dynamic_library_symbol_handle(
native_handle,
p_procedure_name,
procedure_handle);
if (err != OK || procedure_handle == nullptr) {
return Variant();
}
godot_variant result = E->get()(procedure_handle, (godot_array *)&p_arguments);
Variant res = *(Variant *)&result;
godot_variant_destroy(&result);
return res;
}
Error GDNative::get_symbol(StringName p_procedure_name, void *&r_handle, bool p_optional) const {
if (!initialized) {
ERR_PRINT("No valid library handle, can't get symbol from GDNative object");
return ERR_CANT_OPEN;
}
Error result = OS::get_singleton()->get_dynamic_library_symbol_handle(
native_handle,
p_procedure_name,
r_handle,
p_optional);
return result;
}
RES GDNativeLibraryResourceLoader::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {
Ref<GDNativeLibrary> lib;
lib.instantiate();
Ref<ConfigFile> config = lib->get_config_file();
Error err = config->load(p_path);
if (r_error) {
*r_error = err;
}
lib->set_config_file(config);
return lib;
}
void GDNativeLibraryResourceLoader::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back("gdnlib");
}
bool GDNativeLibraryResourceLoader::handles_type(const String &p_type) const {
return p_type == "GDNativeLibrary";
}
String GDNativeLibraryResourceLoader::get_resource_type(const String &p_path) const {
String el = p_path.get_extension().to_lower();
if (el == "gdnlib") {
return "GDNativeLibrary";
}
return "";
}
Error GDNativeLibraryResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
Ref<GDNativeLibrary> lib = p_resource;
if (lib.is_null()) {
return ERR_INVALID_DATA;
}
Ref<ConfigFile> config = lib->get_config_file();
config->set_value("general", "singleton", lib->is_singleton());
config->set_value("general", "load_once", lib->should_load_once());
config->set_value("general", "symbol_prefix", lib->get_symbol_prefix());
config->set_value("general", "reloadable", lib->is_reloadable());
return config->save(p_path);
}
bool GDNativeLibraryResourceSaver::recognize(const RES &p_resource) const {
return Object::cast_to<GDNativeLibrary>(*p_resource) != nullptr;
}
void GDNativeLibraryResourceSaver::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
if (Object::cast_to<GDNativeLibrary>(*p_resource) != nullptr) {
p_extensions->push_back("gdnlib");
}
}

View File

@ -1,184 +0,0 @@
/*************************************************************************/
/* gdnative.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GDNATIVE_H
#define GDNATIVE_H
#include "core/io/resource.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/os/thread_safe.h"
#include "gdnative/gdnative.h"
#include "gdnative_api_struct.gen.h"
#include "core/io/config_file.h"
class GDNativeLibraryResourceLoader;
class GDNative;
class GDNativeLibrary : public Resource {
GDCLASS(GDNativeLibrary, Resource);
static Map<String, Vector<Ref<GDNative>>> loaded_libraries;
friend class GDNativeLibraryResourceLoader;
friend class GDNative;
Ref<ConfigFile> config_file;
String current_library_path;
Vector<String> current_dependencies;
bool singleton;
bool load_once;
String symbol_prefix;
bool reloadable;
public:
virtual void reset_state() override;
GDNativeLibrary();
~GDNativeLibrary();
virtual bool _set(const StringName &p_name, const Variant &p_property);
virtual bool _get(const StringName &p_name, Variant &r_property) const;
virtual void _get_property_list(List<PropertyInfo> *p_list) const;
_FORCE_INLINE_ Ref<ConfigFile> get_config_file() { return config_file; }
void set_config_file(Ref<ConfigFile> p_config_file);
// things that change per-platform
// so there are no setters for this
_FORCE_INLINE_ String get_current_library_path() const {
return current_library_path;
}
_FORCE_INLINE_ Vector<String> get_current_dependencies() const {
return current_dependencies;
}
// things that are a property of the library itself, not platform specific
_FORCE_INLINE_ bool should_load_once() const {
return load_once;
}
_FORCE_INLINE_ bool is_singleton() const {
return singleton;
}
_FORCE_INLINE_ String get_symbol_prefix() const {
return symbol_prefix;
}
_FORCE_INLINE_ bool is_reloadable() const {
return reloadable;
}
_FORCE_INLINE_ void set_load_once(bool p_load_once) {
config_file->set_value("general", "load_once", p_load_once);
load_once = p_load_once;
}
_FORCE_INLINE_ void set_singleton(bool p_singleton) {
config_file->set_value("general", "singleton", p_singleton);
singleton = p_singleton;
}
_FORCE_INLINE_ void set_symbol_prefix(String p_symbol_prefix) {
config_file->set_value("general", "symbol_prefix", p_symbol_prefix);
symbol_prefix = p_symbol_prefix;
}
_FORCE_INLINE_ void set_reloadable(bool p_reloadable) {
config_file->set_value("general", "reloadable", p_reloadable);
reloadable = p_reloadable;
}
static void _bind_methods();
};
struct GDNativeCallRegistry {
static GDNativeCallRegistry *singleton;
inline static GDNativeCallRegistry *get_singleton() {
return singleton;
}
inline GDNativeCallRegistry() :
native_calls() {}
Map<StringName, native_call_cb> native_calls;
void register_native_call_type(StringName p_call_type, native_call_cb p_callback);
Vector<StringName> get_native_call_types();
};
class GDNative : public RefCounted {
GDCLASS(GDNative, RefCounted);
Ref<GDNativeLibrary> library;
void *native_handle;
bool initialized;
public:
GDNative();
~GDNative();
static void _bind_methods();
void set_library(Ref<GDNativeLibrary> p_library);
Ref<GDNativeLibrary> get_library() const;
bool is_initialized() const;
bool initialize();
bool terminate();
Variant call_native(StringName p_native_call_type, StringName p_procedure_name, Array p_arguments = Array());
Error get_symbol(StringName p_procedure_name, void *&r_handle, bool p_optional = true) const;
};
class GDNativeLibraryResourceLoader : public ResourceFormatLoader {
public:
virtual RES load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
};
class GDNativeLibraryResourceSaver : public ResourceFormatSaver {
public:
virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags);
virtual bool recognize(const RES &p_resource) const;
virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
};
#endif // GDNATIVE_H

View File

@ -1,52 +0,0 @@
/*************************************************************************/
/* aabb.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/aabb.h"
#include "core/math/aabb.h"
#include "core/os/memory.h"
static_assert(sizeof(godot_aabb) == sizeof(AABB), "AABB size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_aabb_new(godot_aabb *p_self) {
memnew_placement(p_self, AABB);
}
void GDAPI godot_aabb_new_copy(godot_aabb *r_dest, const godot_aabb *p_src) {
memnew_placement(r_dest, AABB(*(AABB *)p_src));
}
#ifdef __cplusplus
}
#endif

View File

@ -1,66 +0,0 @@
/*************************************************************************/
/* array.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/array.h"
#include "core/os/memory.h"
#include "core/variant/array.h"
static_assert(sizeof(godot_array) == sizeof(Array), "Array size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_array_new(godot_array *p_self) {
memnew_placement(p_self, Array);
}
void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src) {
memnew_placement(r_dest, Array(*(Array *)p_src));
}
void GDAPI godot_array_destroy(godot_array *p_self) {
((Array *)p_self)->~Array();
}
godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, godot_int p_index) {
Array *self = (Array *)p_self;
return (godot_variant *)&self->operator[](p_index);
}
const godot_variant GDAPI *godot_array_operator_index_const(const godot_array *p_self, godot_int p_index) {
const Array *self = (const Array *)p_self;
return (const godot_variant *)&self->operator[](p_index);
}
#ifdef __cplusplus
}
#endif

View File

@ -1,61 +0,0 @@
/*************************************************************************/
/* basis.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/basis.h"
#include "core/math/basis.h"
static_assert(sizeof(godot_basis) == sizeof(Basis), "Basis size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_basis_new(godot_basis *p_self) {
memnew_placement(p_self, Basis);
}
void GDAPI godot_basis_new_copy(godot_basis *r_dest, const godot_basis *p_src) {
memnew_placement(r_dest, Basis(*(Basis *)p_src));
}
godot_vector3 GDAPI *godot_basis_operator_index(godot_basis *p_self, godot_int p_index) {
Basis *self = (Basis *)p_self;
return (godot_vector3 *)&self->operator[](p_index);
}
const godot_vector3 GDAPI *godot_basis_operator_index_const(const godot_basis *p_self, godot_int p_index) {
const Basis *self = (const Basis *)p_self;
return (const godot_vector3 *)&self->operator[](p_index);
}
#ifdef __cplusplus
}
#endif

View File

@ -1,57 +0,0 @@
/*************************************************************************/
/* callable.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/callable.h"
#include "core/variant/callable.h"
#include "core/variant/variant.h"
static_assert(sizeof(godot_callable) == sizeof(Callable), "Callable size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_callable_new(godot_callable *p_self) {
memnew_placement(p_self, Callable);
}
void GDAPI godot_callable_new_copy(godot_callable *r_dest, const godot_callable *p_src) {
memnew_placement(r_dest, Callable(*(Callable *)p_src));
}
void GDAPI godot_callable_destroy(godot_callable *p_self) {
Callable *self = (Callable *)p_self;
self->~Callable();
}
#ifdef __cplusplus
}
#endif

View File

@ -1,61 +0,0 @@
/*************************************************************************/
/* color.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/color.h"
#include "core/math/color.h"
static_assert(sizeof(godot_color) == sizeof(Color), "Color size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_color_new(godot_color *p_self) {
memnew_placement(p_self, Color);
}
void GDAPI godot_color_new_copy(godot_color *r_dest, const godot_color *p_src) {
memnew_placement(r_dest, Color(*(Color *)p_src));
}
float GDAPI *godot_color_operator_index(godot_color *p_self, godot_int p_index) {
Color *self = (Color *)p_self;
return (float *)&self->operator[](p_index);
}
const float GDAPI *godot_color_operator_index_const(const godot_color *p_self, godot_int p_index) {
const Color *self = (const Color *)p_self;
return (const float *)&self->operator[](p_index);
}
#ifdef __cplusplus
}
#endif

View File

@ -1,67 +0,0 @@
/*************************************************************************/
/* dictionary.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/dictionary.h"
#include "core/variant/dictionary.h"
#include "core/variant/variant.h"
static_assert(sizeof(godot_dictionary) == sizeof(Dictionary), "Dictionary size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_dictionary_new(godot_dictionary *p_self) {
memnew_placement(p_self, Dictionary);
}
void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src) {
memnew_placement(r_dest, Dictionary(*(Dictionary *)p_src));
}
void GDAPI godot_dictionary_destroy(godot_dictionary *p_self) {
Dictionary *self = (Dictionary *)p_self;
self->~Dictionary();
}
godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key) {
Dictionary *self = (Dictionary *)p_self;
return (godot_variant *)&self->operator[](*((const Variant *)p_key));
}
const godot_variant GDAPI *godot_dictionary_operator_index_const(const godot_dictionary *p_self, const godot_variant *p_key) {
const Dictionary *self = (const Dictionary *)p_self;
return (const godot_variant *)&self->operator[](*((const Variant *)p_key));
}
#ifdef __cplusplus
}
#endif

View File

@ -1,193 +0,0 @@
/*************************************************************************/
/* gdnative.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/gdnative.h"
#include "core/config/engine.h"
#include "core/core_constants.h"
#include "core/error/error_macros.h"
#include "core/object/class_db.h"
#include "core/os/os.h"
#include "core/variant/variant.h"
#include "modules/gdnative/gdnative.h"
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_object_destroy(godot_object *p_o) {
memdelete((Object *)p_o);
}
// Singleton API
godot_object GDAPI *godot_global_get_singleton(char *p_name) {
return (godot_object *)Engine::get_singleton()->get_singleton_object(String(p_name));
} // result shouldn't be freed
// MethodBind API
godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname) {
MethodBind *mb = ClassDB::get_method(StringName(p_classname), StringName(p_methodname));
// MethodBind *mb = ClassDB::get_method("Node", "get_name");
return (godot_method_bind *)mb;
}
void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_object *p_instance, const void **p_args, void *p_ret) {
MethodBind *mb = (MethodBind *)p_method_bind;
Object *o = (Object *)p_instance;
mb->ptrcall(o, p_args, p_ret);
}
godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, godot_object *p_instance, const godot_variant **p_args, const int p_arg_count, godot_variant_call_error *p_call_error) {
MethodBind *mb = (MethodBind *)p_method_bind;
Object *o = (Object *)p_instance;
const Variant **args = (const Variant **)p_args;
godot_variant ret;
godot_variant_new_nil(&ret);
Variant *ret_val = (Variant *)&ret;
Callable::CallError r_error;
*ret_val = mb->call(o, args, p_arg_count, r_error);
if (p_call_error) {
p_call_error->error = (godot_variant_call_error_error)r_error.error;
p_call_error->argument = r_error.argument;
p_call_error->expected = (godot_variant_type)r_error.expected;
}
return ret;
}
godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname) {
ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname));
if (class_info) {
return (godot_class_constructor)class_info->creation_func;
}
return nullptr;
}
godot_dictionary GDAPI godot_get_global_constants() {
godot_dictionary constants;
memnew_placement(&constants, Dictionary);
Dictionary *p_constants = (Dictionary *)&constants;
const int constants_count = CoreConstants::get_global_constant_count();
for (int i = 0; i < constants_count; ++i) {
const char *name = CoreConstants::get_global_constant_name(i);
int value = CoreConstants::get_global_constant_value(i);
(*p_constants)[name] = value;
}
return constants;
}
// System functions
void GDAPI godot_register_native_call_type(const char *p_call_type, native_call_cb p_callback) {
GDNativeCallRegistry::get_singleton()->register_native_call_type(StringName(p_call_type), p_callback);
}
void GDAPI *godot_alloc(int p_bytes) {
return memalloc(p_bytes);
}
void GDAPI *godot_realloc(void *p_ptr, int p_bytes) {
return memrealloc(p_ptr, p_bytes);
}
void GDAPI godot_free(void *p_ptr) {
memfree(p_ptr);
}
// Helper print functions.
void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line) {
_err_print_error(p_function, p_file, p_line, p_description, false, ERR_HANDLER_ERROR);
}
void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line) {
_err_print_error(p_function, p_file, p_line, p_description, false, ERR_HANDLER_WARNING);
}
void GDAPI godot_print_script_error(const char *p_description, const char *p_function, const char *p_file, int p_line) {
_err_print_error(p_function, p_file, p_line, p_description, false, ERR_HANDLER_SCRIPT);
}
void _gdnative_report_version_mismatch(const godot_object *p_library, const char *p_ext, godot_gdnative_api_version p_want, godot_gdnative_api_version p_have) {
String message = "Error loading GDNative file ";
GDNativeLibrary *library = (GDNativeLibrary *)p_library;
message += library->get_current_library_path() + ": Extension \"" + p_ext + "\" can't be loaded.\n";
Dictionary versions;
versions["have_major"] = p_have.major;
versions["have_minor"] = p_have.minor;
versions["want_major"] = p_want.major;
versions["want_minor"] = p_want.minor;
message += String("Got version {have_major}.{have_minor} but needs {want_major}.{want_minor}!").format(versions);
_err_print_error("gdnative_init", library->get_current_library_path().utf8().ptr(), 0, message.utf8().ptr());
}
void _gdnative_report_loading_error(const godot_object *p_library, const char *p_what) {
String message = "Error loading GDNative file ";
GDNativeLibrary *library = (GDNativeLibrary *)p_library;
message += library->get_current_library_path() + ": " + p_what;
_err_print_error("gdnative_init", library->get_current_library_path().utf8().ptr(), 0, message.utf8().ptr());
}
godot_object GDAPI *godot_instance_from_id(uint64_t p_instance_id) {
return (godot_object *)ObjectDB::get_instance(ObjectID(p_instance_id));
}
void *godot_get_class_tag(const godot_string_name *p_class) {
StringName class_name = *(StringName *)p_class;
ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(class_name);
return class_info ? class_info->class_ptr : nullptr;
}
godot_object *godot_object_cast_to(const godot_object *p_object, void *p_class_tag) {
if (!p_object) {
return nullptr;
}
Object *o = (Object *)p_object;
return o->is_class_ptr(p_class_tag) ? (godot_object *)o : nullptr;
}
uint64_t GDAPI godot_object_get_instance_id(const godot_object *p_object) {
const Object *o = (const Object *)p_object;
return (uint64_t)o->get_instance_id();
}
#ifdef __cplusplus
}
#endif

View File

@ -1,56 +0,0 @@
/*************************************************************************/
/* node_path.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/node_path.h"
#include "core/string/node_path.h"
static_assert(sizeof(godot_node_path) == sizeof(NodePath), "NodePath size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_node_path_new(godot_node_path *p_self) {
memnew_placement(p_self, NodePath);
}
void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src) {
memnew_placement(r_dest, NodePath(*(NodePath *)p_src));
}
void GDAPI godot_node_path_destroy(godot_node_path *p_self) {
NodePath *self = (NodePath *)p_self;
self->~NodePath();
}
#ifdef __cplusplus
}
#endif

View File

@ -1,320 +0,0 @@
/*************************************************************************/
/* packed_arrays.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/packed_arrays.h"
#include "core/variant/variant.h"
#include "core/math/vector2i.h"
#include "core/math/vector3i.h"
static_assert(sizeof(godot_packed_byte_array) == sizeof(PackedByteArray), "PackedByteArray size mismatch");
static_assert(sizeof(godot_packed_int32_array) == sizeof(PackedInt32Array), "PackedInt32Array size mismatch");
static_assert(sizeof(godot_packed_int64_array) == sizeof(PackedInt64Array), "PackedInt64Array size mismatch");
static_assert(sizeof(godot_packed_float32_array) == sizeof(PackedFloat32Array), "PackedFloat32Array size mismatch");
static_assert(sizeof(godot_packed_float64_array) == sizeof(PackedFloat64Array), "PackedFloat64Array size mismatch");
static_assert(sizeof(godot_packed_string_array) == sizeof(PackedStringArray), "PackedStringArray size mismatch");
static_assert(sizeof(godot_packed_vector2_array) == sizeof(PackedVector2Array), "PackedVector2Array size mismatch");
static_assert(sizeof(godot_packed_vector2i_array) == sizeof(Vector<Vector2i>), "Vector<Vector2i> size mismatch");
static_assert(sizeof(godot_packed_vector3_array) == sizeof(PackedVector3Array), "PackedVector3Array size mismatch");
static_assert(sizeof(godot_packed_vector3i_array) == sizeof(Vector<Vector3i>), "Vector<Vector3i> size mismatch");
static_assert(sizeof(godot_packed_color_array) == sizeof(PackedColorArray), "PackedColorArray size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
// byte
void GDAPI godot_packed_byte_array_new(godot_packed_byte_array *p_self) {
memnew_placement(p_self, PackedByteArray);
}
void GDAPI godot_packed_byte_array_new_copy(godot_packed_byte_array *r_dest, const godot_packed_byte_array *p_src) {
memnew_placement(r_dest, PackedByteArray(*(PackedByteArray *)p_src));
}
void GDAPI godot_packed_byte_array_destroy(godot_packed_byte_array *p_self) {
((PackedByteArray *)p_self)->~PackedByteArray();
}
uint8_t GDAPI *godot_packed_byte_array_operator_index(godot_packed_byte_array *p_self, godot_int p_index) {
PackedByteArray *self = (PackedByteArray *)p_self;
return (uint8_t *)&self->operator[](p_index);
}
const uint8_t GDAPI *godot_packed_byte_array_operator_index_const(const godot_packed_byte_array *p_self, godot_int p_index) {
const PackedByteArray *self = (const PackedByteArray *)p_self;
return (const uint8_t *)&self->operator[](p_index);
}
// int32
void GDAPI godot_packed_int32_array_new(godot_packed_int32_array *p_self) {
memnew_placement(p_self, PackedInt32Array);
}
void GDAPI godot_packed_int32_array_new_copy(godot_packed_int32_array *r_dest, const godot_packed_int32_array *p_src) {
memnew_placement(r_dest, PackedInt32Array(*(PackedInt32Array *)p_src));
}
void GDAPI godot_packed_int32_array_destroy(godot_packed_int32_array *p_self) {
((PackedInt32Array *)p_self)->~PackedInt32Array();
}
int32_t GDAPI *godot_packed_int32_array_operator_index(godot_packed_int32_array *p_self, godot_int p_index) {
PackedInt32Array *self = (PackedInt32Array *)p_self;
return (int32_t *)&self->operator[](p_index);
}
const int32_t GDAPI *godot_packed_int32_array_operator_index_const(const godot_packed_int32_array *p_self, godot_int p_index) {
const PackedInt32Array *self = (const PackedInt32Array *)p_self;
return (const int32_t *)&self->operator[](p_index);
}
// int64
void GDAPI godot_packed_int64_array_new(godot_packed_int64_array *p_self) {
memnew_placement(p_self, PackedInt64Array);
}
void GDAPI godot_packed_int64_array_new_copy(godot_packed_int64_array *r_dest, const godot_packed_int64_array *p_src) {
memnew_placement(r_dest, PackedInt64Array(*(PackedInt64Array *)p_src));
}
void GDAPI godot_packed_int64_array_destroy(godot_packed_int64_array *p_self) {
((PackedInt64Array *)p_self)->~PackedInt64Array();
}
int64_t GDAPI *godot_packed_int64_array_operator_index(godot_packed_int64_array *p_self, godot_int p_index) {
PackedInt64Array *self = (PackedInt64Array *)p_self;
return (int64_t *)&self->operator[](p_index);
}
const int64_t GDAPI *godot_packed_int64_array_operator_index_const(const godot_packed_int64_array *p_self, godot_int p_index) {
const PackedInt64Array *self = (const PackedInt64Array *)p_self;
return (const int64_t *)&self->operator[](p_index);
}
// float32
void GDAPI godot_packed_float32_array_new(godot_packed_float32_array *p_self) {
memnew_placement(p_self, PackedFloat32Array);
}
void GDAPI godot_packed_float32_array_new_copy(godot_packed_float32_array *r_dest, const godot_packed_float32_array *p_src) {
memnew_placement(r_dest, PackedFloat32Array(*(PackedFloat32Array *)p_src));
}
void GDAPI godot_packed_float32_array_destroy(godot_packed_float32_array *p_self) {
((PackedFloat32Array *)p_self)->~PackedFloat32Array();
}
float GDAPI *godot_packed_float32_array_operator_index(godot_packed_float32_array *p_self, godot_int p_index) {
PackedFloat32Array *self = (PackedFloat32Array *)p_self;
return (float *)&self->operator[](p_index);
}
const float GDAPI *godot_packed_float32_array_operator_index_const(const godot_packed_float32_array *p_self, godot_int p_index) {
const PackedFloat32Array *self = (const PackedFloat32Array *)p_self;
return (const float *)&self->operator[](p_index);
}
// float64
void GDAPI godot_packed_float64_array_new(godot_packed_float64_array *p_self) {
memnew_placement(p_self, PackedFloat64Array);
}
void GDAPI godot_packed_float64_array_new_copy(godot_packed_float64_array *r_dest, const godot_packed_float64_array *p_src) {
memnew_placement(r_dest, PackedFloat64Array(*(PackedFloat64Array *)p_src));
}
void GDAPI godot_packed_float64_array_destroy(godot_packed_float64_array *p_self) {
((PackedFloat64Array *)p_self)->~PackedFloat64Array();
}
double GDAPI *godot_packed_float64_array_operator_index(godot_packed_float64_array *p_self, godot_int p_index) {
PackedFloat64Array *self = (PackedFloat64Array *)p_self;
return (double *)&self->operator[](p_index);
}
const double GDAPI *godot_packed_float64_array_operator_index_const(const godot_packed_float64_array *p_self, godot_int p_index) {
const PackedFloat64Array *self = (const PackedFloat64Array *)p_self;
return (const double *)&self->operator[](p_index);
}
// string
void GDAPI godot_packed_string_array_new(godot_packed_string_array *p_self) {
memnew_placement(p_self, PackedStringArray);
}
void GDAPI godot_packed_string_array_new_copy(godot_packed_string_array *r_dest, const godot_packed_string_array *p_src) {
memnew_placement(r_dest, PackedStringArray(*(PackedStringArray *)p_src));
}
void GDAPI godot_packed_string_array_destroy(godot_packed_string_array *p_self) {
((PackedStringArray *)p_self)->~PackedStringArray();
}
godot_string GDAPI *godot_packed_string_array_operator_index(godot_packed_string_array *p_self, godot_int p_index) {
PackedStringArray *self = (PackedStringArray *)p_self;
return (godot_string *)&self->operator[](p_index);
}
const godot_string GDAPI *godot_packed_string_array_operator_index_const(const godot_packed_string_array *p_self, godot_int p_index) {
const PackedStringArray *self = (const PackedStringArray *)p_self;
return (const godot_string *)&self->operator[](p_index);
}
// vector2
void GDAPI godot_packed_vector2_array_new(godot_packed_vector2_array *p_self) {
memnew_placement(p_self, PackedVector2Array);
}
void GDAPI godot_packed_vector2_array_new_copy(godot_packed_vector2_array *r_dest, const godot_packed_vector2_array *p_src) {
memnew_placement(r_dest, PackedVector2Array(*(PackedVector2Array *)p_src));
}
void GDAPI godot_packed_vector2_array_destroy(godot_packed_vector2_array *p_self) {
((PackedVector2Array *)p_self)->~PackedVector2Array();
}
godot_vector2 GDAPI *godot_packed_vector2_array_operator_index(godot_packed_vector2_array *p_self, godot_int p_index) {
PackedVector2Array *self = (PackedVector2Array *)p_self;
return (godot_vector2 *)&self->operator[](p_index);
}
const godot_vector2 GDAPI *godot_packed_vector2_array_operator_index_const(const godot_packed_vector2_array *p_self, godot_int p_index) {
const PackedVector2Array *self = (const PackedVector2Array *)p_self;
return (const godot_vector2 *)&self->operator[](p_index);
}
// vector2i
void GDAPI godot_packed_vector2i_array_new(godot_packed_vector2i_array *p_self) {
memnew_placement(p_self, Vector<Vector2i>);
}
void GDAPI godot_packed_vector2i_array_new_copy(godot_packed_vector2i_array *r_dest, const godot_packed_vector2i_array *p_src) {
memnew_placement(r_dest, Vector<Vector2i>(*(Vector<Vector2i> *)p_src));
}
void GDAPI godot_packed_vector2i_array_destroy(godot_packed_vector2i_array *p_self) {
((Vector<Vector2i> *)p_self)->~Vector();
}
godot_vector2i GDAPI *godot_packed_vector2i_array_operator_index(godot_packed_vector2i_array *p_self, godot_int p_index) {
Vector<Vector2i> *self = (Vector<Vector2i> *)p_self;
return (godot_vector2i *)&self->operator[](p_index);
}
const godot_vector2i GDAPI *godot_packed_vector2i_array_operator_index_const(const godot_packed_vector2i_array *p_self, godot_int p_index) {
const Vector<Vector2i> *self = (const Vector<Vector2i> *)p_self;
return (const godot_vector2i *)&self->operator[](p_index);
}
// vector3
void GDAPI godot_packed_vector3_array_new(godot_packed_vector3_array *p_self) {
memnew_placement(p_self, PackedVector3Array);
}
void GDAPI godot_packed_vector3_array_new_copy(godot_packed_vector3_array *r_dest, const godot_packed_vector3_array *p_src) {
memnew_placement(r_dest, PackedVector3Array(*(PackedVector3Array *)p_src));
}
void GDAPI godot_packed_vector3_array_destroy(godot_packed_vector3_array *p_self) {
((PackedVector3Array *)p_self)->~PackedVector3Array();
}
godot_vector3 GDAPI *godot_packed_vector3_array_operator_index(godot_packed_vector3_array *p_self, godot_int p_index) {
PackedVector3Array *self = (PackedVector3Array *)p_self;
return (godot_vector3 *)&self->operator[](p_index);
}
const godot_vector3 GDAPI *godot_packed_vector3_array_operator_index_const(const godot_packed_vector3_array *p_self, godot_int p_index) {
const PackedVector3Array *self = (const PackedVector3Array *)p_self;
return (const godot_vector3 *)&self->operator[](p_index);
}
// vector3i
void GDAPI godot_packed_vector3i_array_new(godot_packed_vector3i_array *p_self) {
memnew_placement(p_self, Vector<Vector3i>);
}
void GDAPI godot_packed_vector3i_array_new_copy(godot_packed_vector3i_array *r_dest, const godot_packed_vector3i_array *p_src) {
memnew_placement(r_dest, Vector<Vector3i>(*(Vector<Vector3i> *)p_src));
}
void GDAPI godot_packed_vector3i_array_destroy(godot_packed_vector3i_array *p_self) {
((Vector<Vector3i> *)p_self)->~Vector();
}
godot_vector3i GDAPI *godot_packed_vector3i_array_operator_index(godot_packed_vector3i_array *p_self, godot_int p_index) {
Vector<Vector3i> *self = (Vector<Vector3i> *)p_self;
return (godot_vector3i *)&self->operator[](p_index);
}
const godot_vector3i GDAPI *godot_packed_vector3i_array_operator_index_const(const godot_packed_vector3i_array *p_self, godot_int p_index) {
const Vector<Vector3i> *self = (const Vector<Vector3i> *)p_self;
return (const godot_vector3i *)&self->operator[](p_index);
}
// color
void GDAPI godot_packed_color_array_new(godot_packed_color_array *p_self) {
memnew_placement(p_self, PackedColorArray);
}
void GDAPI godot_packed_color_array_new_copy(godot_packed_color_array *r_dest, const godot_packed_color_array *p_src) {
memnew_placement(r_dest, PackedColorArray(*(PackedColorArray *)p_src));
}
void GDAPI godot_packed_color_array_destroy(godot_packed_color_array *p_self) {
((PackedColorArray *)p_self)->~PackedColorArray();
}
godot_color GDAPI *godot_packed_color_array_operator_index(godot_packed_color_array *p_self, godot_int p_index) {
PackedColorArray *self = (PackedColorArray *)p_self;
return (godot_color *)&self->operator[](p_index);
}
const godot_color GDAPI *godot_packed_color_array_operator_index_const(const godot_packed_color_array *p_self, godot_int p_index) {
const PackedColorArray *self = (const PackedColorArray *)p_self;
return (const godot_color *)&self->operator[](p_index);
}
#ifdef __cplusplus
}
#endif

View File

@ -1,52 +0,0 @@
/*************************************************************************/
/* plane.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/plane.h"
#include "core/math/plane.h"
#include "core/os/memory.h"
static_assert(sizeof(godot_plane) == sizeof(Plane), "Plane size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_plane_new(godot_plane *p_self) {
memnew_placement(p_self, Plane);
}
void GDAPI godot_plane_new_copy(godot_plane *r_dest, const godot_plane *p_src) {
memnew_placement(r_dest, Plane(*(Plane *)p_src));
}
#ifdef __cplusplus
}
#endif

View File

@ -1,61 +0,0 @@
/*************************************************************************/
/* quaternion.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/quaternion.h"
#include "core/math/quaternion.h"
static_assert(sizeof(godot_quaternion) == sizeof(Quaternion), "Quaternion size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_quaternion_new(godot_quaternion *p_self) {
memnew_placement(p_self, Quaternion);
}
void GDAPI godot_quaternion_new_copy(godot_quaternion *r_dest, const godot_quaternion *p_src) {
memnew_placement(r_dest, Quaternion(*(Quaternion *)p_src));
}
godot_real_t GDAPI *godot_quaternion_operator_index(godot_quaternion *p_self, godot_int p_index) {
Quaternion *self = (Quaternion *)p_self;
return (godot_real_t *)&self->operator[](p_index);
}
const godot_real_t GDAPI *godot_quaternion_operator_index_const(const godot_quaternion *p_self, godot_int p_index) {
const Quaternion *self = (const Quaternion *)p_self;
return (const godot_real_t *)&self->operator[](p_index);
}
#ifdef __cplusplus
}
#endif

View File

@ -1,62 +0,0 @@
/*************************************************************************/
/* rect2.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/rect2.h"
#include "core/math/rect2.h"
#include "core/math/rect2i.h"
#include "core/os/memory.h"
static_assert(sizeof(godot_rect2) == sizeof(Rect2), "Rect2 size mismatch");
static_assert(sizeof(godot_rect2i) == sizeof(Rect2i), "Rect2i size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_rect2_new(godot_rect2 *p_self) {
memnew_placement(p_self, Rect2);
}
void GDAPI godot_rect2_new_copy(godot_rect2 *r_dest, const godot_rect2 *p_src) {
memnew_placement(r_dest, Rect2(*(Rect2 *)p_src));
}
void GDAPI godot_rect2i_new(godot_rect2i *p_self) {
memnew_placement(p_self, Rect2i);
}
void GDAPI godot_rect2i_new_copy(godot_rect2i *r_dest, const godot_rect2i *p_src) {
memnew_placement(r_dest, Rect2i(*(Rect2i *)p_src));
}
#ifdef __cplusplus
}
#endif

View File

@ -1,52 +0,0 @@
/*************************************************************************/
/* rid.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/rid.h"
#include "core/os/memory.h"
#include "core/templates/rid.h"
static_assert(sizeof(godot_rid) == sizeof(RID), "RID size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_rid_new(godot_rid *p_self) {
memnew_placement(p_self, RID);
}
void GDAPI godot_rid_new_copy(godot_rid *r_dest, const godot_rid *p_src) {
memnew_placement(r_dest, RID(*(RID *)p_src));
}
#ifdef __cplusplus
}
#endif

View File

@ -1,57 +0,0 @@
/*************************************************************************/
/* signal.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/signal.h"
#include "core/variant/callable.h"
#include "core/variant/variant.h"
static_assert(sizeof(godot_signal) == sizeof(Signal), "Signal size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_signal_new(godot_signal *p_self) {
memnew_placement(p_self, Signal);
}
void GDAPI godot_signal_new_copy(godot_signal *r_dest, const godot_signal *p_src) {
memnew_placement(r_dest, Signal(*(Signal *)p_src));
}
void GDAPI godot_signal_destroy(godot_signal *p_self) {
Signal *self = (Signal *)p_self;
self->~Signal();
}
#ifdef __cplusplus
}
#endif

View File

@ -1,171 +0,0 @@
/*************************************************************************/
/* string.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/string.h"
#include "core/string/ustring.h"
static_assert(sizeof(godot_string) == sizeof(String), "String size mismatch");
static_assert(sizeof(godot_char_type) == sizeof(char32_t), "char32_t size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_string_new(godot_string *r_dest) {
String *dest = (String *)r_dest;
memnew_placement(dest, String);
}
void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src) {
memnew_placement(r_dest, String(*(String *)p_src));
}
void GDAPI godot_string_new_with_latin1_chars(godot_string *r_dest, const char *p_contents) {
String *dest = (String *)r_dest;
memnew_placement(dest, String);
*dest = String(p_contents);
}
void GDAPI godot_string_new_with_utf8_chars(godot_string *r_dest, const char *p_contents) {
String *dest = (String *)r_dest;
memnew_placement(dest, String);
dest->parse_utf8(p_contents);
}
void GDAPI godot_string_new_with_utf16_chars(godot_string *r_dest, const char16_t *p_contents) {
String *dest = (String *)r_dest;
memnew_placement(dest, String);
dest->parse_utf16(p_contents);
}
void GDAPI godot_string_new_with_utf32_chars(godot_string *r_dest, const char32_t *p_contents) {
String *dest = (String *)r_dest;
memnew_placement(dest, String);
*dest = String((const char32_t *)p_contents);
}
void GDAPI godot_string_new_with_wide_chars(godot_string *r_dest, const wchar_t *p_contents) {
String *dest = (String *)r_dest;
if (sizeof(wchar_t) == 2) {
// wchar_t is 16 bit, parse.
memnew_placement(dest, String);
dest->parse_utf16((const char16_t *)p_contents);
} else {
// wchar_t is 32 bit, copy.
memnew_placement(dest, String);
*dest = String((const char32_t *)p_contents);
}
}
void GDAPI godot_string_new_with_latin1_chars_and_len(godot_string *r_dest, const char *p_contents, const int p_size) {
String *dest = (String *)r_dest;
memnew_placement(dest, String);
*dest = String(p_contents, p_size);
}
void GDAPI godot_string_new_with_utf8_chars_and_len(godot_string *r_dest, const char *p_contents, const int p_size) {
String *dest = (String *)r_dest;
memnew_placement(dest, String);
dest->parse_utf8(p_contents, p_size);
}
void GDAPI godot_string_new_with_utf16_chars_and_len(godot_string *r_dest, const char16_t *p_contents, const int p_size) {
String *dest = (String *)r_dest;
memnew_placement(dest, String);
dest->parse_utf16(p_contents, p_size);
}
void GDAPI godot_string_new_with_utf32_chars_and_len(godot_string *r_dest, const char32_t *p_contents, const int p_size) {
String *dest = (String *)r_dest;
memnew_placement(dest, String);
*dest = String((const char32_t *)p_contents, p_size);
}
void GDAPI godot_string_new_with_wide_chars_and_len(godot_string *r_dest, const wchar_t *p_contents, const int p_size) {
String *dest = (String *)r_dest;
if (sizeof(wchar_t) == 2) {
// wchar_t is 16 bit, parse.
memnew_placement(dest, String);
dest->parse_utf16((const char16_t *)p_contents, p_size);
} else {
// wchar_t is 32 bit, copy.
memnew_placement(dest, String);
*dest = String((const char32_t *)p_contents, p_size);
}
}
const char GDAPI *godot_string_to_latin1_chars(const godot_string *p_self) {
String *self = (String *)p_self;
return self->ascii(true).get_data();
}
const char GDAPI *godot_string_to_utf8_chars(const godot_string *p_self) {
String *self = (String *)p_self;
return self->utf8().get_data();
}
const char16_t GDAPI *godot_string_to_utf16_chars(const godot_string *p_self) {
String *self = (String *)p_self;
return self->utf16().get_data();
}
const char32_t GDAPI *godot_string_to_utf32_chars(const godot_string *p_self) {
String *self = (String *)p_self;
return self->get_data();
}
const wchar_t GDAPI *godot_string_to_wide_chars(const godot_string *p_self) {
String *self = (String *)p_self;
if (sizeof(wchar_t) == 2) {
return (const wchar_t *)self->utf16().get_data();
} else {
return (const wchar_t *)self->get_data();
}
}
char32_t GDAPI *godot_string_operator_index(godot_string *p_self, godot_int p_index) {
String *self = (String *)p_self;
return self->ptrw();
}
const char32_t GDAPI *godot_string_operator_index_const(const godot_string *p_self, godot_int p_index) {
const String *self = (const String *)p_self;
return self->ptr();
}
void GDAPI godot_string_destroy(godot_string *p_self) {
String *self = (String *)p_self;
self->~String();
}
#ifdef __cplusplus
}
#endif

View File

@ -1,62 +0,0 @@
/*************************************************************************/
/* string_name.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/string_name.h"
#include "core/string/string_name.h"
static_assert(sizeof(godot_string_name) == sizeof(StringName), "StringName size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_string_name_new(godot_string_name *r_dest) {
StringName *dest = (StringName *)r_dest;
memnew_placement(dest, StringName);
}
void GDAPI godot_string_name_new_copy(godot_string_name *r_dest, const godot_string_name *p_src) {
memnew_placement(r_dest, StringName(*(StringName *)p_src));
}
void GDAPI godot_string_name_new_with_latin1_chars(godot_string_name *r_dest, const char *p_contents) {
StringName *dest = (StringName *)r_dest;
memnew_placement(dest, StringName(p_contents));
}
void GDAPI godot_string_name_destroy(godot_string_name *p_self) {
StringName *self = (StringName *)p_self;
self->~StringName();
}
#ifdef __cplusplus
}
#endif

View File

@ -1,62 +0,0 @@
/*************************************************************************/
/* transform2d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/transform2d.h"
#include "core/math/transform_2d.h"
#include "core/os/memory.h"
static_assert(sizeof(godot_transform2d) == sizeof(Transform2D), "Transform2D size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_transform2d_new(godot_transform2d *p_self) {
memnew_placement(p_self, Transform2D);
}
void GDAPI godot_transform2d_new_copy(godot_transform2d *r_dest, const godot_transform2d *p_src) {
memnew_placement(r_dest, Transform2D(*(Transform2D *)p_src));
}
godot_vector2 GDAPI *godot_transform2d_operator_index(godot_transform2d *p_self, godot_int p_index) {
Transform2D *self = (Transform2D *)p_self;
return (godot_vector2 *)&self->operator[](p_index);
}
const godot_vector2 GDAPI *godot_transform2d_operator_index_const(const godot_transform2d *p_self, godot_int p_index) {
const Transform2D *self = (const Transform2D *)p_self;
return (const godot_vector2 *)&self->operator[](p_index);
}
#ifdef __cplusplus
}
#endif

View File

@ -1,51 +0,0 @@
/*************************************************************************/
/* transform_3d.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/transform_3d.h"
#include "core/math/transform_3d.h"
static_assert(sizeof(godot_transform3d) == sizeof(Transform3D), "Transform3D size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_transform3d_new(godot_transform3d *p_self) {
memnew_placement(p_self, Transform3D);
}
void GDAPI godot_transform3d_new_copy(godot_transform3d *r_dest, const godot_transform3d *p_src) {
memnew_placement(r_dest, Transform3D(*(Transform3D *)p_src));
}
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,82 +0,0 @@
/*************************************************************************/
/* vector2.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/vector2.h"
#include "core/math/vector2.h"
#include "core/math/vector2i.h"
#include "core/os/memory.h"
static_assert(sizeof(godot_vector2) == sizeof(Vector2), "Vector2 size mismatch");
static_assert(sizeof(godot_vector2i) == sizeof(Vector2i), "Vector2i size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_vector2_new(godot_vector2 *p_self) {
memnew_placement(p_self, Vector2);
}
void GDAPI godot_vector2_new_copy(godot_vector2 *r_dest, const godot_vector2 *p_src) {
memnew_placement(r_dest, Vector2(*(Vector2 *)p_src));
}
void GDAPI godot_vector2i_new(godot_vector2i *p_self) {
memnew_placement(p_self, Vector2i);
}
void GDAPI godot_vector2i_new_copy(godot_vector2i *r_dest, const godot_vector2i *p_src) {
memnew_placement(r_dest, Vector2i(*(Vector2i *)p_src));
}
godot_real_t GDAPI *godot_vector2_operator_index(godot_vector2 *p_self, godot_int p_index) {
Vector2 *self = (Vector2 *)p_self;
return (godot_real_t *)&self->operator[](p_index);
}
const godot_real_t GDAPI *godot_vector2_operator_index_const(const godot_vector2 *p_self, godot_int p_index) {
const Vector2 *self = (const Vector2 *)p_self;
return (const godot_real_t *)&self->operator[](p_index);
}
int32_t GDAPI *godot_vector2i_operator_index(godot_vector2i *p_self, godot_int p_index) {
Vector2i *self = (Vector2i *)p_self;
return (int32_t *)&self->operator[](p_index);
}
const int32_t GDAPI *godot_vector2i_operator_index_const(const godot_vector2i *p_self, godot_int p_index) {
const Vector2i *self = (const Vector2i *)p_self;
return (const int32_t *)&self->operator[](p_index);
}
#ifdef __cplusplus
}
#endif

View File

@ -1,82 +0,0 @@
/*************************************************************************/
/* vector3.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "gdnative/vector3.h"
#include "core/math/vector3.h"
#include "core/math/vector3i.h"
#include "core/os/memory.h"
static_assert(sizeof(godot_vector3) == sizeof(Vector3), "Vector3 size mismatch");
static_assert(sizeof(godot_vector3i) == sizeof(Vector3i), "Vector3i size mismatch");
#ifdef __cplusplus
extern "C" {
#endif
void GDAPI godot_vector3_new(godot_vector3 *p_self) {
memnew_placement(p_self, Vector3);
}
void GDAPI godot_vector3_new_copy(godot_vector3 *r_dest, const godot_vector3 *p_src) {
memnew_placement(r_dest, Vector3(*(Vector3 *)p_src));
}
void GDAPI godot_vector3i_new(godot_vector3i *p_self) {
memnew_placement(p_self, Vector3i);
}
void GDAPI godot_vector3i_new_copy(godot_vector3i *r_dest, const godot_vector3i *p_src) {
memnew_placement(r_dest, Vector3i(*(Vector3i *)p_src));
}
godot_real_t GDAPI *godot_vector3_operator_index(godot_vector3 *p_self, godot_int p_index) {
Vector3 *self = (Vector3 *)p_self;
return (godot_real_t *)&self->operator[](p_index);
}
const godot_real_t GDAPI *godot_vector3_operator_index_const(const godot_vector3 *p_self, godot_int p_index) {
const Vector3 *self = (const Vector3 *)p_self;
return (const godot_real_t *)&self->operator[](p_index);
}
int32_t GDAPI *godot_vector3i_operator_index(godot_vector3i *p_self, godot_int p_index) {
Vector3i *self = (Vector3i *)p_self;
return (int32_t *)&self->operator[](p_index);
}
const int32_t GDAPI *godot_vector3i_operator_index_const(const godot_vector3i *p_self, godot_int p_index) {
const Vector3i *self = (const Vector3i *)p_self;
return (const int32_t *)&self->operator[](p_index);
}
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,263 +0,0 @@
"""Functions used to generate source files during build time
All such functions are invoked in a subprocess on Windows to prevent build flakiness.
"""
import json
from platform_methods import subprocess_main
def _spaced(e):
return e if e[-1] == "*" else e + " "
def _build_gdnative_api_struct_header(api):
out = [
"/* THIS FILE IS GENERATED DO NOT EDIT */",
"#ifndef GODOT_GDNATIVE_API_STRUCT_H",
"#define GODOT_GDNATIVE_API_STRUCT_H",
"",
"#include <gdnative/gdnative.h>",
"#include <android/godot_android.h>",
"#include <nativescript/godot_nativescript.h>",
"#include <pluginscript/godot_pluginscript.h>",
"#include <videodecoder/godot_videodecoder.h>",
"",
"#ifdef __cplusplus",
'extern "C" {',
"#endif",
"",
"enum GDNATIVE_API_TYPES {",
"\tGDNATIVE_" + api["core"]["type"] + ",",
]
for ext in api["extensions"]:
out += ["\tGDNATIVE_EXT_" + ext["type"] + ","]
out += ["};", ""]
def generate_extension_struct(name, ext, include_version=True):
ret_val = []
if ext["next"]:
ret_val += generate_extension_struct(name, ext["next"])
ret_val += [
"typedef struct godot_gdnative_ext_"
+ name
+ ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"])))
+ "_api_struct {",
"\tunsigned int type;",
"\tgodot_gdnative_api_version version;",
"\tconst godot_gdnative_api_struct *next;",
]
for funcdef in ext["api"]:
args = ", ".join(["%s%s" % (_spaced(t), n) for t, n in funcdef["arguments"]])
ret_val.append("\t%s(*%s)(%s);" % (_spaced(funcdef["return_type"]), funcdef["name"], args))
ret_val += [
"} godot_gdnative_ext_"
+ name
+ ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"])))
+ "_api_struct;",
"",
]
return ret_val
def generate_core_extension_struct(core):
ret_val = []
if core["next"]:
ret_val += generate_core_extension_struct(core["next"])
ret_val += [
"typedef struct godot_gdnative_core_"
+ "{0}_{1}".format(core["version"]["major"], core["version"]["minor"])
+ "_api_struct {",
"\tunsigned int type;",
"\tgodot_gdnative_api_version version;",
"\tconst godot_gdnative_api_struct *next;",
]
for funcdef in core["api"]:
args = ", ".join(["%s%s" % (_spaced(t), n) for t, n in funcdef["arguments"]])
ret_val.append("\t%s(*%s)(%s);" % (_spaced(funcdef["return_type"]), funcdef["name"], args))
ret_val += [
"} godot_gdnative_core_"
+ "{0}_{1}".format(core["version"]["major"], core["version"]["minor"])
+ "_api_struct;",
"",
]
return ret_val
for ext in api["extensions"]:
name = ext["name"]
out += generate_extension_struct(name, ext, False)
if api["core"]["next"]:
out += generate_core_extension_struct(api["core"]["next"])
out += [
"typedef struct godot_gdnative_core_api_struct {",
"\tunsigned int type;",
"\tgodot_gdnative_api_version version;",
"\tconst godot_gdnative_api_struct *next;",
"\tunsigned int num_extensions;",
"\tconst godot_gdnative_api_struct **extensions;",
]
for funcdef in api["core"]["api"]:
args = ", ".join(["%s%s" % (_spaced(t), n) for t, n in funcdef["arguments"]])
out.append("\t%s(*%s)(%s);" % (_spaced(funcdef["return_type"]), funcdef["name"], args))
out += [
"} godot_gdnative_core_api_struct;",
"",
"#ifdef __cplusplus",
"}",
"#endif",
"",
"#endif // GODOT_GDNATIVE_API_STRUCT_H",
"",
]
return "\n".join(out)
def _build_gdnative_api_struct_source(api):
out = ["/* THIS FILE IS GENERATED DO NOT EDIT */", "", "#include <gdnative_api_struct.gen.h>", ""]
def get_extension_struct_name(name, ext, include_version=True):
return (
"godot_gdnative_ext_"
+ name
+ ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"])))
+ "_api_struct"
)
def get_extension_struct_instance_name(name, ext, include_version=True):
return (
"api_extension_"
+ name
+ ("" if not include_version else ("_{0}_{1}".format(ext["version"]["major"], ext["version"]["minor"])))
+ "_struct"
)
def get_extension_struct_definition(name, ext, include_version=True):
ret_val = []
if ext["next"]:
ret_val += get_extension_struct_definition(name, ext["next"])
ret_val += [
"extern const "
+ get_extension_struct_name(name, ext, include_version)
+ " "
+ get_extension_struct_instance_name(name, ext, include_version)
+ " = {",
"\tGDNATIVE_EXT_" + ext["type"] + ",",
"\t{" + str(ext["version"]["major"]) + ", " + str(ext["version"]["minor"]) + "},",
"\t"
+ (
"nullptr"
if not ext["next"]
else ("(const godot_gdnative_api_struct *)&" + get_extension_struct_instance_name(name, ext["next"]))
)
+ ",",
]
for funcdef in ext["api"]:
ret_val.append("\t%s," % funcdef["name"])
ret_val += ["};\n"]
return ret_val
def get_core_struct_definition(core):
ret_val = []
if core["next"]:
ret_val += get_core_struct_definition(core["next"])
ret_val += [
"extern const godot_gdnative_core_"
+ "{0}_{1}_api_struct api_{0}_{1}".format(core["version"]["major"], core["version"]["minor"])
+ " = {",
"\tGDNATIVE_" + core["type"] + ",",
"\t{" + str(core["version"]["major"]) + ", " + str(core["version"]["minor"]) + "},",
"\t"
+ (
"nullptr"
if not core["next"]
else (
"(const godot_gdnative_api_struct *)& api_{0}_{1}".format(
core["next"]["version"]["major"], core["next"]["version"]["minor"]
)
)
)
+ ",",
]
for funcdef in core["api"]:
ret_val.append("\t%s," % funcdef["name"])
ret_val += ["};\n"]
return ret_val
for ext in api["extensions"]:
name = ext["name"]
out += get_extension_struct_definition(name, ext, False)
out += ["", "const godot_gdnative_api_struct *gdnative_extensions_pointers[] = {"]
for ext in api["extensions"]:
name = ext["name"]
out += ["\t(godot_gdnative_api_struct *)&api_extension_" + name + "_struct,"]
out += ["};\n"]
if api["core"]["next"]:
out += get_core_struct_definition(api["core"]["next"])
out += [
"extern const godot_gdnative_core_api_struct api_struct = {",
"\tGDNATIVE_" + api["core"]["type"] + ",",
"\t{" + str(api["core"]["version"]["major"]) + ", " + str(api["core"]["version"]["minor"]) + "},",
"\t"
+ (
"nullptr, "
if not api["core"]["next"]
else (
"(const godot_gdnative_api_struct *)& api_{0}_{1},".format(
api["core"]["next"]["version"]["major"], api["core"]["next"]["version"]["minor"]
)
)
),
"\t" + str(len(api["extensions"])) + ",",
"\tgdnative_extensions_pointers,",
]
for funcdef in api["core"]["api"]:
out.append("\t%s," % funcdef["name"])
out.append("};\n")
return "\n".join(out)
def build_gdnative_api_struct(target, source, env):
with open(source[0], "r") as fd:
api = json.load(fd)
header, source = target
with open(header, "w") as fd:
fd.write(_build_gdnative_api_struct_header(api))
with open(source, "w") as fd:
fd.write(_build_gdnative_api_struct_source(api))
if __name__ == "__main__":
subprocess_main(globals())

View File

@ -1,420 +0,0 @@
/*************************************************************************/
/* gdnative_library_editor_plugin.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifdef TOOLS_ENABLED
#include "gdnative_library_editor_plugin.h"
#include "editor/editor_file_dialog.h"
#include "editor/editor_node.h"
#include "editor/editor_scale.h"
#include "gdnative.h"
void GDNativeLibraryEditor::edit(Ref<GDNativeLibrary> p_library) {
library = p_library;
Ref<ConfigFile> config = p_library->get_config_file();
for (KeyValue<String, NativePlatformConfig> &E : platforms) {
for (List<String>::Element *it = E.value.entries.front(); it; it = it->next()) {
String target = E.key + "." + it->get();
TargetConfig ecfg;
ecfg.library = config->get_value("entry", target, "");
ecfg.dependencies = config->get_value("dependencies", target, Array());
entry_configs[target] = ecfg;
}
}
_update_tree();
}
void GDNativeLibraryEditor::_bind_methods() {
}
void GDNativeLibraryEditor::_update_tree() {
tree->clear();
TreeItem *root = tree->create_item();
PopupMenu *filter_list = filter->get_popup();
String text = "";
for (int i = 0; i < filter_list->get_item_count(); i++) {
if (!filter_list->is_item_checked(i)) {
continue;
}
Map<String, NativePlatformConfig>::Element *E = platforms.find(filter_list->get_item_metadata(i));
if (!text.is_empty()) {
text += ", ";
}
text += E->get().name;
TreeItem *platform = tree->create_item(root);
platform->set_text(0, E->get().name);
platform->set_metadata(0, E->get().library_extension);
platform->set_custom_bg_color(0, get_theme_color(SNAME("prop_category"), SNAME("Editor")));
platform->set_custom_bg_color(1, get_theme_color(SNAME("prop_category"), SNAME("Editor")));
platform->set_custom_bg_color(2, get_theme_color(SNAME("prop_category"), SNAME("Editor")));
platform->set_selectable(0, false);
platform->set_expand_right(0, true);
for (List<String>::Element *it = E->value().entries.front(); it; it = it->next()) {
String target = E->key() + "." + it->get();
TreeItem *bit = tree->create_item(platform);
bit->set_text(0, it->get());
bit->set_metadata(0, target);
bit->set_selectable(0, false);
bit->set_custom_bg_color(0, get_theme_color(SNAME("prop_subsection"), SNAME("Editor")));
bit->add_button(1, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), BUTTON_SELECT_LIBRARY, false, TTR("Select the dynamic library for this entry"));
String file = entry_configs[target].library;
if (!file.is_empty()) {
bit->add_button(1, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), BUTTON_CLEAR_LIBRARY, false, TTR("Clear"));
}
bit->set_text(1, file);
bit->add_button(2, get_theme_icon(SNAME("Folder"), SNAME("EditorIcons")), BUTTON_SELECT_DEPENDENCES, false, TTR("Select dependencies of the library for this entry"));
Array files = entry_configs[target].dependencies;
if (files.size()) {
bit->add_button(2, get_theme_icon(SNAME("Clear"), SNAME("EditorIcons")), BUTTON_CLEAR_DEPENDENCES, false, TTR("Clear"));
}
bit->set_text(2, Variant(files));
bit->add_button(3, get_theme_icon(SNAME("MoveUp"), SNAME("EditorIcons")), BUTTON_MOVE_UP, false, TTR("Move Up"));
bit->add_button(3, get_theme_icon(SNAME("MoveDown"), SNAME("EditorIcons")), BUTTON_MOVE_DOWN, false, TTR("Move Down"));
bit->add_button(3, get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")), BUTTON_ERASE_ENTRY, false, TTR("Remove current entry"));
}
TreeItem *new_arch = tree->create_item(platform);
new_arch->set_text(0, TTR("Double click to create a new entry"));
new_arch->set_text_alignment(0, HORIZONTAL_ALIGNMENT_CENTER);
new_arch->set_custom_color(0, get_theme_color(SNAME("accent_color"), SNAME("Editor")));
new_arch->set_expand_right(0, true);
new_arch->set_metadata(1, E->key());
platform->set_collapsed(collapsed_items.find(E->get().name) != nullptr);
}
filter->set_text(text);
}
void GDNativeLibraryEditor::_on_item_button(Object *item, int column, int id) {
String target = Object::cast_to<TreeItem>(item)->get_metadata(0);
String platform = target.substr(0, target.find("."));
String entry = target.substr(platform.length() + 1, target.length());
String section = (id == BUTTON_SELECT_DEPENDENCES || id == BUTTON_CLEAR_DEPENDENCES) ? "dependencies" : "entry";
if (id == BUTTON_SELECT_LIBRARY || id == BUTTON_SELECT_DEPENDENCES) {
TreeItem *treeItem = Object::cast_to<TreeItem>(item)->get_parent();
EditorFileDialog::FileMode mode = EditorFileDialog::FILE_MODE_OPEN_FILE;
if (id == BUTTON_SELECT_DEPENDENCES) {
mode = EditorFileDialog::FILE_MODE_OPEN_FILES;
} else if (treeItem->get_text(0) == "iOS" || treeItem->get_text(0) == "macOS") {
mode = EditorFileDialog::FILE_MODE_OPEN_ANY;
}
file_dialog->set_meta("target", target);
file_dialog->set_meta("section", section);
file_dialog->clear_filters();
String filter_string = treeItem->get_metadata(0);
Vector<String> filters = filter_string.split(",", false, 0);
for (int i = 0; i < filters.size(); i++) {
file_dialog->add_filter(filters[i]);
}
file_dialog->set_file_mode(mode);
file_dialog->popup_file_dialog();
} else if (id == BUTTON_CLEAR_LIBRARY) {
_set_target_value(section, target, "");
} else if (id == BUTTON_CLEAR_DEPENDENCES) {
_set_target_value(section, target, Array());
} else if (id == BUTTON_ERASE_ENTRY) {
_erase_entry(platform, entry);
} else if (id == BUTTON_MOVE_UP || id == BUTTON_MOVE_DOWN) {
_move_entry(platform, entry, id);
}
}
void GDNativeLibraryEditor::_on_library_selected(const String &file) {
_set_target_value(file_dialog->get_meta("section"), file_dialog->get_meta("target"), file);
}
void GDNativeLibraryEditor::_on_dependencies_selected(const PackedStringArray &files) {
_set_target_value(file_dialog->get_meta("section"), file_dialog->get_meta("target"), files);
}
void GDNativeLibraryEditor::_on_filter_selected(int index) {
PopupMenu *filter_list = filter->get_popup();
filter_list->set_item_checked(index, !filter_list->is_item_checked(index));
_update_tree();
}
void GDNativeLibraryEditor::_on_item_collapsed(Object *p_item) {
TreeItem *item = Object::cast_to<TreeItem>(p_item);
String name = item->get_text(0);
if (item->is_collapsed()) {
collapsed_items.insert(name);
} else if (Set<String>::Element *e = collapsed_items.find(name)) {
collapsed_items.erase(e);
}
}
void GDNativeLibraryEditor::_on_item_activated() {
TreeItem *item = tree->get_selected();
if (item && tree->get_selected_column() == 0 && item->get_metadata(0).get_type() == Variant::NIL) {
new_architecture_dialog->set_meta("platform", item->get_metadata(1));
new_architecture_dialog->popup_centered();
}
}
void GDNativeLibraryEditor::_on_create_new_entry() {
String platform = new_architecture_dialog->get_meta("platform");
String entry = new_architecture_input->get_text().strip_edges();
if (!entry.is_empty()) {
platforms[platform].entries.push_back(entry);
_update_tree();
}
}
void GDNativeLibraryEditor::_set_target_value(const String &section, const String &target, Variant file) {
if (section == "entry") {
entry_configs[target].library = file;
} else if (section == "dependencies") {
entry_configs[target].dependencies = file;
}
_translate_to_config_file();
_update_tree();
}
void GDNativeLibraryEditor::_erase_entry(const String &platform, const String &entry) {
if (platforms.has(platform)) {
if (List<String>::Element *E = platforms[platform].entries.find(entry)) {
String target = platform + "." + entry;
platforms[platform].entries.erase(E);
_set_target_value("entry", target, "");
_set_target_value("dependencies", target, Array());
_translate_to_config_file();
_update_tree();
}
}
}
void GDNativeLibraryEditor::_move_entry(const String &platform, const String &entry, int dir) {
if (List<String>::Element *E = platforms[platform].entries.find(entry)) {
if (E->prev() && dir == BUTTON_MOVE_UP) {
platforms[platform].entries.insert_before(E->prev(), E->get());
platforms[platform].entries.erase(E);
} else if (E->next() && dir == BUTTON_MOVE_DOWN) {
platforms[platform].entries.insert_after(E->next(), E->get());
platforms[platform].entries.erase(E);
}
_translate_to_config_file();
_update_tree();
}
}
void GDNativeLibraryEditor::_translate_to_config_file() {
if (!library.is_null()) {
Ref<ConfigFile> config = library->get_config_file();
config->erase_section("entry");
config->erase_section("dependencies");
for (KeyValue<String, NativePlatformConfig> &E : platforms) {
for (List<String>::Element *it = E.value.entries.front(); it; it = it->next()) {
String target = E.key + "." + it->get();
if (entry_configs[target].library.is_empty() && entry_configs[target].dependencies.is_empty()) {
continue;
}
config->set_value("entry", target, entry_configs[target].library);
config->set_value("dependencies", target, entry_configs[target].dependencies);
}
}
library->notify_property_list_changed();
}
}
GDNativeLibraryEditor::GDNativeLibraryEditor() {
{ // Define platforms
NativePlatformConfig platform_windows;
platform_windows.name = "Windows";
platform_windows.entries.push_back("64");
platform_windows.entries.push_back("32");
platform_windows.library_extension = "*.dll";
platforms["Windows"] = platform_windows;
NativePlatformConfig platform_linux;
platform_linux.name = "Linux/X11";
platform_linux.entries.push_back("64");
platform_linux.entries.push_back("32");
platform_linux.library_extension = "*.so";
platforms["X11"] = platform_linux;
NativePlatformConfig platform_osx;
platform_osx.name = "macOS";
platform_osx.entries.push_back("64");
platform_osx.library_extension = "*.framework; Framework, *.dylib; Dynamic Library";
platforms["macOS"] = platform_osx;
NativePlatformConfig platform_haiku;
platform_haiku.name = "Haiku";
platform_haiku.entries.push_back("64");
platform_haiku.entries.push_back("32");
platform_haiku.library_extension = "*.so";
platforms["Haiku"] = platform_haiku;
NativePlatformConfig platform_uwp;
platform_uwp.name = "UWP";
platform_uwp.entries.push_back("arm");
platform_uwp.entries.push_back("32");
platform_uwp.entries.push_back("64");
platform_uwp.library_extension = "*.dll";
platforms["UWP"] = platform_uwp;
NativePlatformConfig platform_android;
platform_android.name = "Android";
platform_android.entries.push_back("armeabi-v7a");
platform_android.entries.push_back("arm64-v8a");
platform_android.entries.push_back("x86");
platform_android.entries.push_back("x86_64");
platform_android.library_extension = "*.so";
platforms["Android"] = platform_android;
NativePlatformConfig platform_html5;
platform_html5.name = "HTML5";
platform_html5.entries.push_back("wasm32");
platform_html5.library_extension = "*.wasm";
platforms["HTML5"] = platform_html5;
NativePlatformConfig platform_ios;
platform_ios.name = "iOS";
platform_ios.entries.push_back("arm64");
platform_ios.entries.push_back("x86_64");
// iOS can use both Static and Dynamic libraries.
// Frameworks is actually a folder with files.
platform_ios.library_extension = "*.framework; Framework, *.xcframework; Binary Framework, *.a; Static Library, *.dylib; Dynamic Library";
platforms["iOS"] = platform_ios;
}
VBoxContainer *container = memnew(VBoxContainer);
add_child(container);
container->set_anchors_and_offsets_preset(PRESET_WIDE);
HBoxContainer *hbox = memnew(HBoxContainer);
container->add_child(hbox);
Label *label = memnew(Label);
label->set_text(TTR("Platform:"));
hbox->add_child(label);
filter = memnew(MenuButton);
filter->set_h_size_flags(SIZE_EXPAND_FILL);
filter->set_text_alignment(HORIZONTAL_ALIGNMENT_LEFT);
hbox->add_child(filter);
PopupMenu *filter_list = filter->get_popup();
filter_list->set_hide_on_checkable_item_selection(false);
int idx = 0;
for (const KeyValue<String, NativePlatformConfig> &E : platforms) {
filter_list->add_check_item(E.value.name, idx);
filter_list->set_item_metadata(idx, E.key);
filter_list->set_item_checked(idx, true);
idx += 1;
}
filter_list->connect("index_pressed", callable_mp(this, &GDNativeLibraryEditor::_on_filter_selected));
tree = memnew(Tree);
container->add_child(tree);
tree->set_v_size_flags(SIZE_EXPAND_FILL);
tree->set_hide_root(true);
tree->set_column_titles_visible(true);
tree->set_columns(4);
tree->set_column_expand(0, false);
tree->set_column_custom_minimum_width(0, int(200 * EDSCALE));
tree->set_column_title(0, TTR("Platform"));
tree->set_column_title(1, TTR("Dynamic Library"));
tree->set_column_title(2, TTR("Dependencies"));
tree->set_column_expand(3, false);
tree->set_column_custom_minimum_width(3, int(110 * EDSCALE));
tree->connect("button_pressed", callable_mp(this, &GDNativeLibraryEditor::_on_item_button));
tree->connect("item_collapsed", callable_mp(this, &GDNativeLibraryEditor::_on_item_collapsed));
tree->connect("item_activated", callable_mp(this, &GDNativeLibraryEditor::_on_item_activated));
file_dialog = memnew(EditorFileDialog);
file_dialog->set_access(EditorFileDialog::ACCESS_RESOURCES);
//file_dialog->set_resizable(true);
add_child(file_dialog);
file_dialog->connect("file_selected", callable_mp(this, &GDNativeLibraryEditor::_on_library_selected));
file_dialog->connect("dir_selected", callable_mp(this, &GDNativeLibraryEditor::_on_library_selected));
file_dialog->connect("files_selected", callable_mp(this, &GDNativeLibraryEditor::_on_dependencies_selected));
new_architecture_dialog = memnew(ConfirmationDialog);
add_child(new_architecture_dialog);
new_architecture_dialog->set_title(TTR("Add an architecture entry"));
new_architecture_input = memnew(LineEdit);
new_architecture_dialog->add_child(new_architecture_input);
// new_architecture_dialog->set_custom_minimum_size(Vector2(300, 80) * EDSCALE);
new_architecture_input->set_anchors_and_offsets_preset(PRESET_HCENTER_WIDE, PRESET_MODE_MINSIZE, 5 * EDSCALE);
new_architecture_dialog->get_ok_button()->connect("pressed", callable_mp(this, &GDNativeLibraryEditor::_on_create_new_entry));
}
void GDNativeLibraryEditorPlugin::edit(Object *p_node) {
Ref<GDNativeLibrary> new_library = Object::cast_to<GDNativeLibrary>(p_node);
if (new_library.is_valid()) {
library_editor->edit(new_library);
}
}
bool GDNativeLibraryEditorPlugin::handles(Object *p_node) const {
return p_node->is_class("GDNativeLibrary");
}
void GDNativeLibraryEditorPlugin::make_visible(bool p_visible) {
if (p_visible) {
button->show();
EditorNode::get_singleton()->make_bottom_panel_item_visible(library_editor);
} else {
if (library_editor->is_visible_in_tree()) {
EditorNode::get_singleton()->hide_bottom_panel();
}
button->hide();
}
}
GDNativeLibraryEditorPlugin::GDNativeLibraryEditorPlugin() {
library_editor = memnew(GDNativeLibraryEditor);
library_editor->set_custom_minimum_size(Size2(0, 250 * EDSCALE));
button = EditorNode::get_singleton()->add_bottom_panel_item(TTR("GDNativeLibrary"), library_editor);
button->hide();
}
#endif

View File

@ -1,119 +0,0 @@
/*************************************************************************/
/* gdnative_library_editor_plugin.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GDNATIVE_LIBRARY_EDITOR_PLUGIN_H
#define GDNATIVE_LIBRARY_EDITOR_PLUGIN_H
#ifdef TOOLS_ENABLED
#include "editor/editor_plugin.h"
#include "gdnative.h"
#include "scene/gui/control.h"
#include "scene/gui/menu_button.h"
#include "scene/gui/tree.h"
class EditorFileDialog;
class GDNativeLibraryEditor : public Control {
GDCLASS(GDNativeLibraryEditor, Control);
struct NativePlatformConfig {
String name;
String library_extension;
List<String> entries;
};
struct TargetConfig {
String library;
Array dependencies;
};
enum ItemButton {
BUTTON_SELECT_LIBRARY,
BUTTON_CLEAR_LIBRARY,
BUTTON_SELECT_DEPENDENCES,
BUTTON_CLEAR_DEPENDENCES,
BUTTON_ERASE_ENTRY,
BUTTON_MOVE_UP,
BUTTON_MOVE_DOWN,
};
Tree *tree;
MenuButton *filter;
EditorFileDialog *file_dialog;
ConfirmationDialog *new_architecture_dialog;
LineEdit *new_architecture_input;
Set<String> collapsed_items;
String showing_platform;
Ref<GDNativeLibrary> library;
Map<String, NativePlatformConfig> platforms;
Map<String, TargetConfig> entry_configs;
protected:
static void _bind_methods();
void _update_tree();
void _on_item_button(Object *item, int column, int id);
void _on_library_selected(const String &file);
void _on_dependencies_selected(const PackedStringArray &files);
void _on_filter_selected(int id);
void _on_item_collapsed(Object *p_item);
void _on_item_activated();
void _on_create_new_entry();
void _set_target_value(const String &section, const String &target, Variant file);
void _erase_entry(const String &platform, const String &entry);
void _move_entry(const String &platform, const String &entry, int dir);
void _translate_to_config_file();
public:
void edit(Ref<GDNativeLibrary> p_library);
GDNativeLibraryEditor();
};
class GDNativeLibraryEditorPlugin : public EditorPlugin {
GDCLASS(GDNativeLibraryEditorPlugin, EditorPlugin);
GDNativeLibraryEditor *library_editor = nullptr;
Button *button = nullptr;
public:
virtual String get_name() const override { return "GDNativeLibrary"; }
bool has_main_screen() const override { return false; }
virtual void edit(Object *p_node) override;
virtual bool handles(Object *p_node) const override;
virtual void make_visible(bool p_visible) override;
GDNativeLibraryEditorPlugin();
};
#endif // TOOLS_ENABLED
#endif // GDNATIVE_LIBRARY_EDITOR_PLUGIN_H

View File

@ -1,213 +0,0 @@
/*************************************************************************/
/* gdnative_library_singleton_editor.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifdef TOOLS_ENABLED
#include "gdnative_library_singleton_editor.h"
#include "gdnative.h"
#include "core/config/project_settings.h"
#include "editor/editor_node.h"
Set<String> GDNativeLibrarySingletonEditor::_find_singletons_recursive(EditorFileSystemDirectory *p_dir) {
Set<String> file_paths;
// check children
for (int i = 0; i < p_dir->get_file_count(); i++) {
String file_name = p_dir->get_file(i);
String file_type = p_dir->get_file_type(i);
if (file_type != "GDNativeLibrary") {
continue;
}
Ref<GDNativeLibrary> lib = ResourceLoader::load(p_dir->get_file_path(i));
if (lib.is_valid() && lib->is_singleton()) {
file_paths.insert(p_dir->get_file_path(i));
}
}
// check subdirectories
for (int i = 0; i < p_dir->get_subdir_count(); i++) {
Set<String> paths = _find_singletons_recursive(p_dir->get_subdir(i));
for (Set<String>::Element *E = paths.front(); E; E = E->next()) {
file_paths.insert(E->get());
}
}
return file_paths;
}
void GDNativeLibrarySingletonEditor::_discover_singletons() {
EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->get_filesystem();
Set<String> file_paths = _find_singletons_recursive(dir);
bool changed = false;
Array current_files;
if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons")) {
current_files = ProjectSettings::get_singleton()->get("gdnative/singletons");
}
Array files;
for (Set<String>::Element *E = file_paths.front(); E; E = E->next()) {
if (!current_files.has(E->get())) {
changed = true;
}
files.append(E->get());
}
// Check for removed files
if (!changed) {
// Removed singleton
for (int j = 0; j < current_files.size(); j++) {
if (!files.has(current_files[j])) {
changed = true;
break;
}
}
}
if (changed) {
ProjectSettings::get_singleton()->set("gdnative/singletons", files);
_update_libraries(); // So singleton options (i.e. disabled) updates too
ProjectSettings::get_singleton()->save();
}
}
void GDNativeLibrarySingletonEditor::_update_libraries() {
updating = true;
libraries->clear();
libraries->create_item(); // root item
Array singletons;
if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons")) {
singletons = ProjectSettings::get_singleton()->get("gdnative/singletons");
}
Array singletons_disabled;
if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons_disabled")) {
singletons_disabled = ProjectSettings::get_singleton()->get("gdnative/singletons_disabled");
}
Array updated_disabled;
for (int i = 0; i < singletons.size(); i++) {
bool enabled = true;
String path = singletons[i];
if (singletons_disabled.has(path)) {
enabled = false;
updated_disabled.push_back(path);
}
TreeItem *ti = libraries->create_item(libraries->get_root());
ti->set_text(0, path.get_file());
ti->set_tooltip(0, path);
ti->set_metadata(0, path);
ti->set_cell_mode(1, TreeItem::CELL_MODE_RANGE);
ti->set_text(1, "Disabled,Enabled");
ti->set_range(1, enabled ? 1 : 0);
ti->set_custom_color(1, enabled ? Color(0, 1, 0) : Color(1, 0, 0));
ti->set_editable(1, true);
}
// The singletons list changed, we must update the settings
if (updated_disabled.size() != singletons_disabled.size()) {
ProjectSettings::get_singleton()->set("gdnative/singletons_disabled", updated_disabled);
}
updating = false;
}
void GDNativeLibrarySingletonEditor::_item_edited() {
if (updating) {
return;
}
TreeItem *item = libraries->get_edited();
if (!item) {
return;
}
bool enabled = item->get_range(1);
String path = item->get_metadata(0);
Array disabled_paths;
Array undo_paths;
if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons_disabled")) {
disabled_paths = ProjectSettings::get_singleton()->get("gdnative/singletons_disabled");
// Duplicate so redo works (not a reference)
disabled_paths = disabled_paths.duplicate();
// For undo, so we can reset the property.
undo_paths = disabled_paths.duplicate();
}
if (enabled) {
disabled_paths.erase(path);
} else {
if (disabled_paths.find(path) == -1) {
disabled_paths.push_back(path);
}
}
undo_redo->create_action(enabled ? TTR("Enabled GDNative Singleton") : TTR("Disabled GDNative Singleton"));
undo_redo->add_do_property(ProjectSettings::get_singleton(), "gdnative/singletons_disabled", disabled_paths);
undo_redo->add_do_method(this, "_update_libraries");
undo_redo->add_undo_property(ProjectSettings::get_singleton(), "gdnative/singletons_disabled", undo_paths);
undo_redo->add_undo_method(this, "_update_libraries");
undo_redo->commit_action();
}
void GDNativeLibrarySingletonEditor::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_VISIBILITY_CHANGED: {
if (is_visible_in_tree()) {
_update_libraries();
}
} break;
}
}
void GDNativeLibrarySingletonEditor::_bind_methods() {
ClassDB::bind_method(D_METHOD("_update_libraries"), &GDNativeLibrarySingletonEditor::_update_libraries);
}
GDNativeLibrarySingletonEditor::GDNativeLibrarySingletonEditor() {
undo_redo = EditorNode::get_singleton()->get_undo_redo();
libraries = memnew(Tree);
libraries->set_columns(2);
libraries->set_column_titles_visible(true);
libraries->set_column_title(0, TTR("Library"));
libraries->set_column_title(1, TTR("Status"));
libraries->set_hide_root(true);
add_margin_child(TTR("Libraries: "), libraries, true);
updating = false;
libraries->connect("item_edited", callable_mp(this, &GDNativeLibrarySingletonEditor::_item_edited));
EditorFileSystem::get_singleton()->connect("filesystem_changed", callable_mp(this, &GDNativeLibrarySingletonEditor::_discover_singletons));
}
#endif // TOOLS_ENABLED

View File

@ -1,62 +0,0 @@
/*************************************************************************/
/* gdnative_library_singleton_editor.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GD_NATIVE_LIBRARY_EDITOR_H
#define GD_NATIVE_LIBRARY_EDITOR_H
#ifdef TOOLS_ENABLED
#include "editor/editor_file_system.h"
#include "editor/project_settings_editor.h"
class GDNativeLibrarySingletonEditor : public VBoxContainer {
GDCLASS(GDNativeLibrarySingletonEditor, VBoxContainer);
private:
Tree *libraries;
UndoRedo *undo_redo;
bool updating;
static Set<String> _find_singletons_recursive(EditorFileSystemDirectory *p_dir);
protected:
void _notification(int p_what);
static void _bind_methods();
void _discover_singletons();
void _item_edited();
void _update_libraries();
public:
GDNativeLibrarySingletonEditor();
};
#endif
#endif // GD_NATIVE_LIBRARY_EDITOR_H

View File

@ -1 +0,0 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7 1-.56445 2.2578a5 5 0 0 0 -.68945.2793l-1.9883-1.1934-1.4141 1.4141 1.1953 1.9941a5 5 0 0 0 -.28516.68555l-2.2539.5625v2l2.2578.56445a5 5 0 0 0 .2793.6875l-1.1934 1.9902 1.4141 1.4141 1.9941-1.1953a5 5 0 0 0 .68555.28516l.5625 2.2539v-5.2695a2 2 0 0 1 -1-1.7305 2 2 0 0 1 1-1.7285v-.27148h1 4.5762a5 5 0 0 0 -.11328-.25195l1.1934-1.9902-1.4141-1.4141-1.9941 1.1953a5 5 0 0 0 -.68555-.28516l-.5625-2.2539h-2zm2 7v1 5 1h5c.55228 0 1-.4477 1-1v-5c0-.5523-.44772-1-1-1v4l-1-1-1 1v-4z" fill="#e0e0e0"/></svg>

Before

Width:  |  Height:  |  Size: 599 B

View File

@ -1 +0,0 @@
<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m7 1-.56445 2.2578a5 5 0 0 0 -.68945.2793l-1.9883-1.1934-1.4141 1.4141 1.1953 1.9941a5 5 0 0 0 -.28516.68555l-2.2539.5625h3v1 1h2v-.95117a2 2 0 0 1 0-.048828 2 2 0 0 1 2-2 2 2 0 0 1 2 2v1h5v-2l-2.2578-.56445a5 5 0 0 0 -.2793-.6875l1.1934-1.9902-1.4141-1.4141-1.9941 1.1953a5 5 0 0 0 -.68555-.28516l-.5625-2.2539h-2zm-6 7v4 4h2a3 3 0 0 0 3-3 3 3 0 0 0 -3-3v-2zm6 0v2h2v-2zm3 2v6h2v-4a1 1 0 0 1 1 1v3h2v-3a3 3 0 0 0 -3-3zm-7 2a1 1 0 0 1 1 1 1 1 0 0 1 -1 1zm4 0v4h2v-4z" fill="#e0e0e0"/></svg>

Before

Width:  |  Height:  |  Size: 583 B

View File

@ -1,56 +0,0 @@
/*************************************************************************/
/* godot_android.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_ANDROID_GDN_H
#define GODOT_ANDROID_GDN_H
#include <gdnative/gdnative.h>
#ifdef __ANDROID__
#include <jni.h>
#else
#define JNIEnv void
#define jobject void *
#endif
#ifdef __cplusplus
extern "C" {
#endif
JNIEnv *GDAPI godot_android_get_env();
jobject GDAPI godot_android_get_activity();
jobject GDAPI godot_android_get_surface();
bool GDAPI godot_android_is_activity_resumed();
#ifdef __cplusplus
}
#endif
#endif /* !GODOT_ANDROID_GDN_H */

View File

@ -1,58 +0,0 @@
/*************************************************************************/
/* aabb.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_AABB_H
#define GODOT_AABB_H
#ifdef __cplusplus
extern "C" {
#endif
#include <gdnative/math_defs.h>
#define GODOT_AABB_SIZE (sizeof(godot_real_t) * 6)
#ifndef GODOT_CORE_API_GODOT_AABB_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_AABB_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_AABB_SIZE];
} godot_aabb;
#endif
#include <gdnative/gdnative.h>
void GDAPI godot_aabb_new(godot_aabb *p_self);
void GDAPI godot_aabb_new_copy(godot_aabb *r_dest, const godot_aabb *p_src);
#ifdef __cplusplus
}
#endif
#endif // GODOT_AABB_H

View File

@ -1,62 +0,0 @@
/*************************************************************************/
/* array.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_ARRAY_H
#define GODOT_ARRAY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#define GODOT_ARRAY_SIZE sizeof(void *)
#ifndef GODOT_CORE_API_GODOT_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_ARRAY_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_ARRAY_SIZE];
} godot_array;
#endif
#include <gdnative/gdnative.h>
#include <gdnative/variant_struct.h>
void GDAPI godot_array_new(godot_array *p_self);
void GDAPI godot_array_new_copy(godot_array *r_dest, const godot_array *p_src);
void GDAPI godot_array_destroy(godot_array *p_self);
godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, godot_int p_index);
const godot_variant GDAPI *godot_array_operator_index_const(const godot_array *p_self, godot_int p_index);
#ifdef __cplusplus
}
#endif
#endif // GODOT_ARRAY_H

View File

@ -1,60 +0,0 @@
/*************************************************************************/
/* basis.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_BASIS_H
#define GODOT_BASIS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <gdnative/math_defs.h>
#define GODOT_BASIS_SIZE (sizeof(godot_real_t) * 9)
#ifndef GODOT_CORE_API_GODOT_BASIS_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_BASIS_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_BASIS_SIZE];
} godot_basis;
#endif
#include <gdnative/gdnative.h>
void GDAPI godot_basis_new(godot_basis *p_self);
void GDAPI godot_basis_new_copy(godot_basis *r_dest, const godot_basis *p_src);
godot_vector3 GDAPI *godot_basis_operator_index(godot_basis *p_self, godot_int p_index);
const godot_vector3 GDAPI *godot_basis_operator_index_const(const godot_basis *p_self, godot_int p_index);
#ifdef __cplusplus
}
#endif
#endif // GODOT_BASIS_H

View File

@ -1,60 +0,0 @@
/*************************************************************************/
/* callable.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_CALLABLE_H
#define GODOT_CALLABLE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
// Alignment hardcoded in `core/variant/callable.h`.
#define GODOT_CALLABLE_SIZE (16)
#ifndef GODOT_CORE_API_GODOT_CALLABLE_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_CALLABLE_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_CALLABLE_SIZE];
} godot_callable;
#endif
#include <gdnative/gdnative.h>
void GDAPI godot_callable_new(godot_callable *p_self);
void GDAPI godot_callable_new_copy(godot_callable *r_dest, const godot_callable *p_src);
void GDAPI godot_callable_destroy(godot_callable *p_self);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,61 +0,0 @@
/*************************************************************************/
/* color.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_COLOR_H
#define GODOT_COLOR_H
#ifdef __cplusplus
extern "C" {
#endif
#include <gdnative/math_defs.h>
// Colors should always use 32-bit floats, so don't use real_t here.
#define GODOT_COLOR_SIZE (sizeof(float) * 4)
#ifndef GODOT_CORE_API_GODOT_COLOR_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_COLOR_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_COLOR_SIZE];
} godot_color;
#endif
#include <gdnative/gdnative.h>
void GDAPI godot_color_new(godot_color *p_self);
void GDAPI godot_color_new_copy(godot_color *r_dest, const godot_color *p_src);
float GDAPI *godot_color_operator_index(godot_color *p_self, godot_int p_index);
const float GDAPI *godot_color_operator_index_const(const godot_color *p_self, godot_int p_index);
#ifdef __cplusplus
}
#endif
#endif // GODOT_COLOR_H

View File

@ -1,62 +0,0 @@
/*************************************************************************/
/* dictionary.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_DICTIONARY_H
#define GODOT_DICTIONARY_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#define GODOT_DICTIONARY_SIZE sizeof(void *)
#ifndef GODOT_CORE_API_GODOT_DICTIONARY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_DICTIONARY_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_DICTIONARY_SIZE];
} godot_dictionary;
#endif
#include <gdnative/gdnative.h>
#include <gdnative/variant_struct.h>
void GDAPI godot_dictionary_new(godot_dictionary *p_self);
void GDAPI godot_dictionary_new_copy(godot_dictionary *r_dest, const godot_dictionary *p_src);
void GDAPI godot_dictionary_destroy(godot_dictionary *p_self);
godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key);
const godot_variant GDAPI *godot_dictionary_operator_index_const(const godot_dictionary *p_self, const godot_variant *p_key);
#ifdef __cplusplus
}
#endif
#endif // GODOT_DICTIONARY_H

View File

@ -1,287 +0,0 @@
/*************************************************************************/
/* gdnative.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_GDNATIVE_H
#define GODOT_GDNATIVE_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32) || defined(__ANDROID__)
#define GDCALLINGCONV
#define GDAPI GDCALLINGCONV
#elif defined(__APPLE__)
#include "TargetConditionals.h"
#if TARGET_OS_IPHONE
#define GDCALLINGCONV __attribute__((visibility("default")))
#define GDAPI GDCALLINGCONV
#elif TARGET_OS_MAC
#define GDCALLINGCONV __attribute__((sysv_abi))
#define GDAPI GDCALLINGCONV
#endif
#else // !_WIN32 && !__APPLE__
#define GDCALLINGCONV __attribute__((sysv_abi))
#define GDAPI GDCALLINGCONV
#endif
// This is for libraries *using* the header, NOT GODOT EXPOSING STUFF!!
#ifdef __GNUC__
#define GDN_EXPORT __attribute__((visibility("default")))
#elif defined(_WIN32)
#define GDN_EXPORT __declspec(dllexport)
#else
#define GDN_EXPORT
#endif
#include <stdbool.h>
#include <stdint.h>
////// Error
typedef enum {
GODOT_OK, // (0)
GODOT_FAILED, ///< Generic fail error
GODOT_ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable
GODOT_ERR_UNCONFIGURED, ///< The object being used hasn't been properly set up yet
GODOT_ERR_UNAUTHORIZED, ///< Missing credentials for requested resource
GODOT_ERR_PARAMETER_RANGE_ERROR, ///< Parameter given out of range (5)
GODOT_ERR_OUT_OF_MEMORY, ///< Out of memory
GODOT_ERR_FILE_NOT_FOUND,
GODOT_ERR_FILE_BAD_DRIVE,
GODOT_ERR_FILE_BAD_PATH,
GODOT_ERR_FILE_NO_PERMISSION, // (10)
GODOT_ERR_FILE_ALREADY_IN_USE,
GODOT_ERR_FILE_CANT_OPEN,
GODOT_ERR_FILE_CANT_WRITE,
GODOT_ERR_FILE_CANT_READ,
GODOT_ERR_FILE_UNRECOGNIZED, // (15)
GODOT_ERR_FILE_CORRUPT,
GODOT_ERR_FILE_MISSING_DEPENDENCIES,
GODOT_ERR_FILE_EOF,
GODOT_ERR_CANT_OPEN, ///< Can't open a resource/socket/file
GODOT_ERR_CANT_CREATE, // (20)
GODOT_ERR_QUERY_FAILED,
GODOT_ERR_ALREADY_IN_USE,
GODOT_ERR_LOCKED, ///< resource is locked
GODOT_ERR_TIMEOUT,
GODOT_ERR_CANT_CONNECT, // (25)
GODOT_ERR_CANT_RESOLVE,
GODOT_ERR_CONNECTION_ERROR,
GODOT_ERR_CANT_ACQUIRE_RESOURCE,
GODOT_ERR_CANT_FORK,
GODOT_ERR_INVALID_DATA, ///< Data passed is invalid (30)
GODOT_ERR_INVALID_PARAMETER, ///< Parameter passed is invalid
GODOT_ERR_ALREADY_EXISTS, ///< When adding, item already exists
GODOT_ERR_DOES_NOT_EXIST, ///< When retrieving/erasing, it item does not exist
GODOT_ERR_DATABASE_CANT_READ, ///< database is full
GODOT_ERR_DATABASE_CANT_WRITE, ///< database is full (35)
GODOT_ERR_COMPILATION_FAILED,
GODOT_ERR_METHOD_NOT_FOUND,
GODOT_ERR_LINK_FAILED,
GODOT_ERR_SCRIPT_FAILED,
GODOT_ERR_CYCLIC_LINK, // (40)
GODOT_ERR_INVALID_DECLARATION,
GODOT_ERR_DUPLICATE_SYMBOL,
GODOT_ERR_PARSE_ERROR,
GODOT_ERR_BUSY,
GODOT_ERR_SKIP, // (45)
GODOT_ERR_HELP, ///< user requested help!!
GODOT_ERR_BUG, ///< a bug in the software certainly happened, due to a double check failing or unexpected behavior.
GODOT_ERR_PRINTER_ON_FIRE, /// the parallel port printer is engulfed in flames
} godot_error;
/////// Object (forward declared)
typedef void godot_object;
/////// String
#include <gdnative/string.h>
/////// String name
#include <gdnative/string_name.h>
////// Vector2 & Vector2i
#include <gdnative/vector2.h>
////// Rect2 & Rect2i
#include <gdnative/rect2.h>
////// Vector3 & Vector3i
#include <gdnative/vector3.h>
////// Transform2D
#include <gdnative/transform2d.h>
/////// Plane
#include <gdnative/plane.h>
/////// Quaternion
#include <gdnative/quaternion.h>
/////// AABB
#include <gdnative/aabb.h>
/////// Basis
#include <gdnative/basis.h>
/////// Transform3D
#include <gdnative/transform_3d.h>
/////// Color
#include <gdnative/color.h>
/////// NodePath
#include <gdnative/node_path.h>
/////// RID
#include <gdnative/rid.h>
/////// Callable & Signal
#include <gdnative/callable.h>
/////// Dictionary
#include <gdnative/dictionary.h>
/////// Array
#include <gdnative/array.h>
// single API file for Packed*Array
#include <gdnative/packed_arrays.h>
void GDAPI godot_object_destroy(godot_object *p_o);
////// Variant
#include <gdnative/variant.h>
////// Singleton API
godot_object GDAPI *godot_global_get_singleton(char *p_name); // Result shouldn't be freed.
////// MethodBind API
typedef struct {
uint8_t _dont_touch_that[1]; // TODO
} godot_method_bind;
godot_method_bind GDAPI *godot_method_bind_get_method(const char *p_classname, const char *p_methodname);
void GDAPI godot_method_bind_ptrcall(godot_method_bind *p_method_bind, godot_object *p_instance, const void **p_args, void *p_ret);
godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, godot_object *p_instance, const godot_variant **p_args, const int p_arg_count, godot_variant_call_error *p_call_error);
////// Script API
typedef struct godot_gdnative_api_version {
unsigned int major;
unsigned int minor;
} godot_gdnative_api_version;
typedef struct godot_gdnative_api_struct godot_gdnative_api_struct;
struct godot_gdnative_api_struct {
unsigned int type;
godot_gdnative_api_version version;
const godot_gdnative_api_struct *next;
};
#define GDNATIVE_VERSION_COMPATIBLE(want, have) (want.major == have.major && want.minor <= have.minor)
typedef struct {
godot_bool in_editor;
uint64_t core_api_hash;
uint64_t editor_api_hash;
uint64_t no_api_hash;
void (*report_version_mismatch)(const godot_object *p_library, const char *p_what, godot_gdnative_api_version p_want, godot_gdnative_api_version p_have);
void (*report_loading_error)(const godot_object *p_library, const char *p_what);
godot_object *gd_native_library; // pointer to GDNativeLibrary that is being initialized
const struct godot_gdnative_core_api_struct *api_struct;
const godot_string *active_library_path;
} godot_gdnative_init_options;
typedef struct {
godot_bool in_editor;
} godot_gdnative_terminate_options;
// Calling convention?
typedef godot_object *(*godot_class_constructor)();
godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname);
godot_dictionary GDAPI godot_get_global_constants();
////// GDNative procedure types
typedef void (*godot_gdnative_init_fn)(godot_gdnative_init_options *);
typedef void (*godot_gdnative_terminate_fn)(godot_gdnative_terminate_options *);
typedef godot_variant (*godot_gdnative_procedure_fn)(godot_array *);
////// System Functions
typedef godot_variant (*native_call_cb)(void *, godot_array *);
void GDAPI godot_register_native_call_type(const char *p_call_type, native_call_cb p_callback);
//using these will help Godot track how much memory is in use in debug mode
void GDAPI *godot_alloc(int p_bytes);
void GDAPI *godot_realloc(void *p_ptr, int p_bytes);
void GDAPI godot_free(void *p_ptr);
// Helper print functions.
void GDAPI godot_print_error(const char *p_description, const char *p_function, const char *p_file, int p_line);
void GDAPI godot_print_warning(const char *p_description, const char *p_function, const char *p_file, int p_line);
void GDAPI godot_print_script_error(const char *p_description, const char *p_function, const char *p_file, int p_line);
//tags used for safe dynamic casting
void GDAPI *godot_get_class_tag(const godot_string_name *p_class);
godot_object GDAPI *godot_object_cast_to(const godot_object *p_object, void *p_class_tag);
// equivalent of GDScript's instance_from_id
godot_object GDAPI *godot_instance_from_id(uint64_t p_instance_id);
uint64_t GDAPI godot_object_get_instance_id(const godot_object *p_object);
#ifdef __cplusplus
}
#endif
#endif // GODOT_GDNATIVE_H

View File

@ -1,66 +0,0 @@
/*************************************************************************/
/* math_defs.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_GDNATIVE_MATH_DEFS_H
#define GODOT_GDNATIVE_MATH_DEFS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdint.h>
////// bool
typedef bool godot_bool;
#define GODOT_TRUE 1
#define GODOT_FALSE 0
/////// int
typedef int64_t godot_int;
/////// float
typedef double godot_float;
#ifdef REAL_T_IS_DOUBLE
typedef double godot_real_t;
#else
typedef float godot_real_t;
#endif
#ifdef __cplusplus
}
#endif
#endif // GODOT_C_H

View File

@ -1,59 +0,0 @@
/*************************************************************************/
/* node_path.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_NODE_PATH_H
#define GODOT_NODE_PATH_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#define GODOT_NODE_PATH_SIZE sizeof(void *)
#ifndef GODOT_CORE_API_GODOT_NODE_PATH_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_NODE_PATH_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_NODE_PATH_SIZE];
} godot_node_path;
#endif
#include <gdnative/gdnative.h>
void GDAPI godot_node_path_new(godot_node_path *p_self);
void GDAPI godot_node_path_new_copy(godot_node_path *r_dest, const godot_node_path *p_src);
void GDAPI godot_node_path_destroy(godot_node_path *p_self);
#ifdef __cplusplus
}
#endif
#endif // GODOT_NODE_PATH_H

View File

@ -1,255 +0,0 @@
/*************************************************************************/
/* packed_arrays.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_PACKED_ARRAYS_H
#define GODOT_PACKED_ARRAYS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/////// PackedByteArray
#define GODOT_PACKED_BYTE_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_BYTE_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_BYTE_ARRAY_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_PACKED_BYTE_ARRAY_SIZE];
} godot_packed_byte_array;
#endif
/////// PackedInt32Array
#define GODOT_PACKED_INT32_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_INT32_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_INT32_ARRAY_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_PACKED_INT32_ARRAY_SIZE];
} godot_packed_int32_array;
#endif
/////// PackedInt64Array
#define GODOT_PACKED_INT64_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_INT64_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_INT64_ARRAY_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_PACKED_INT64_ARRAY_SIZE];
} godot_packed_int64_array;
#endif
/////// PackedFloat32Array
#define GODOT_PACKED_FLOAT32_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_FLOAT32_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_FLOAT32_ARRAY_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_PACKED_FLOAT32_ARRAY_SIZE];
} godot_packed_float32_array;
#endif
/////// PackedFloat64Array
#define GODOT_PACKED_FLOAT64_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_FLOAT64_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_FLOAT64_ARRAY_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_PACKED_FLOAT64_ARRAY_SIZE];
} godot_packed_float64_array;
#endif
/////// PackedStringArray
#define GODOT_PACKED_STRING_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_STRING_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_STRING_ARRAY_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_PACKED_STRING_ARRAY_SIZE];
} godot_packed_string_array;
#endif
/////// PackedVector2Array
#define GODOT_PACKED_VECTOR2_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR2_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_VECTOR2_ARRAY_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_PACKED_VECTOR2_ARRAY_SIZE];
} godot_packed_vector2_array;
#endif
/////// PackedVector2iArray
#define GODOT_PACKED_VECTOR2I_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR2I_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_VECTOR2I_ARRAY_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_PACKED_VECTOR2I_ARRAY_SIZE];
} godot_packed_vector2i_array;
#endif
/////// PackedVector3Array
#define GODOT_PACKED_VECTOR3_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR3_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_VECTOR3_ARRAY_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_PACKED_VECTOR3_ARRAY_SIZE];
} godot_packed_vector3_array;
#endif
/////// PackedVector3iArray
#define GODOT_PACKED_VECTOR3I_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_VECTOR3I_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_VECTOR3I_ARRAY_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_PACKED_VECTOR3I_ARRAY_SIZE];
} godot_packed_vector3i_array;
#endif
/////// PackedColorArray
#define GODOT_PACKED_COLOR_ARRAY_SIZE (2 * sizeof(void *))
#ifndef GODOT_CORE_API_GODOT_PACKED_COLOR_ARRAY_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PACKED_COLOR_ARRAY_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_PACKED_COLOR_ARRAY_SIZE];
} godot_packed_color_array;
#endif
#include <gdnative/gdnative.h>
// Byte.
void GDAPI godot_packed_byte_array_new(godot_packed_byte_array *p_self);
void GDAPI godot_packed_byte_array_new_copy(godot_packed_byte_array *r_dest, const godot_packed_byte_array *p_src);
void GDAPI godot_packed_byte_array_destroy(godot_packed_byte_array *p_self);
uint8_t GDAPI *godot_packed_byte_array_operator_index(godot_packed_byte_array *p_self, godot_int p_index);
const uint8_t GDAPI *godot_packed_byte_array_operator_index_const(const godot_packed_byte_array *p_self, godot_int p_index);
// Int32.
void GDAPI godot_packed_int32_array_new(godot_packed_int32_array *p_self);
void GDAPI godot_packed_int32_array_new_copy(godot_packed_int32_array *r_dest, const godot_packed_int32_array *p_src);
void GDAPI godot_packed_int32_array_destroy(godot_packed_int32_array *p_self);
int32_t GDAPI *godot_packed_int32_array_operator_index(godot_packed_int32_array *p_self, godot_int p_index);
const int32_t GDAPI *godot_packed_int32_array_operator_index_const(const godot_packed_int32_array *p_self, godot_int p_index);
// Int64.
void GDAPI godot_packed_int64_array_new(godot_packed_int64_array *p_self);
void GDAPI godot_packed_int64_array_new_copy(godot_packed_int64_array *r_dest, const godot_packed_int64_array *p_src);
void GDAPI godot_packed_int64_array_destroy(godot_packed_int64_array *p_self);
int64_t GDAPI *godot_packed_int64_array_operator_index(godot_packed_int64_array *p_self, godot_int p_index);
const int64_t GDAPI *godot_packed_int64_array_operator_index_const(const godot_packed_int64_array *p_self, godot_int p_index);
// Float32.
void GDAPI godot_packed_float32_array_new(godot_packed_float32_array *p_self);
void GDAPI godot_packed_float32_array_new_copy(godot_packed_float32_array *r_dest, const godot_packed_float32_array *p_src);
void GDAPI godot_packed_float32_array_destroy(godot_packed_float32_array *p_self);
float GDAPI *godot_packed_float32_array_operator_index(godot_packed_float32_array *p_self, godot_int p_index);
const float GDAPI *godot_packed_float32_array_operator_index_const(const godot_packed_float32_array *p_self, godot_int p_index);
// Float64.
void GDAPI godot_packed_float64_array_new(godot_packed_float64_array *p_self);
void GDAPI godot_packed_float64_array_new_copy(godot_packed_float64_array *r_dest, const godot_packed_float64_array *p_src);
void GDAPI godot_packed_float64_array_destroy(godot_packed_float64_array *p_self);
double GDAPI *godot_packed_float64_array_operator_index(godot_packed_float64_array *p_self, godot_int p_index);
const double GDAPI *godot_packed_float64_array_operator_index_const(const godot_packed_float64_array *p_self, godot_int p_index);
// String.
void GDAPI godot_packed_string_array_new(godot_packed_string_array *p_self);
void GDAPI godot_packed_string_array_new_copy(godot_packed_string_array *r_dest, const godot_packed_string_array *p_src);
void GDAPI godot_packed_string_array_destroy(godot_packed_string_array *p_self);
godot_string GDAPI *godot_packed_string_array_operator_index(godot_packed_string_array *p_self, godot_int p_index);
const godot_string GDAPI *godot_packed_string_array_operator_index_const(const godot_packed_string_array *p_self, godot_int p_index);
// Vector2.
void GDAPI godot_packed_vector2_array_new(godot_packed_vector2_array *p_self);
void GDAPI godot_packed_vector2_array_new_copy(godot_packed_vector2_array *r_dest, const godot_packed_vector2_array *p_src);
void GDAPI godot_packed_vector2_array_destroy(godot_packed_vector2_array *p_self);
godot_vector2 GDAPI *godot_packed_vector2_array_operator_index(godot_packed_vector2_array *p_self, godot_int p_index);
const godot_vector2 GDAPI *godot_packed_vector2_array_operator_index_const(const godot_packed_vector2_array *p_self, godot_int p_index);
// Vector2i.
void GDAPI godot_packed_vector2i_array_new(godot_packed_vector2i_array *p_self);
void GDAPI godot_packed_vector2i_array_new_copy(godot_packed_vector2i_array *r_dest, const godot_packed_vector2i_array *p_src);
void GDAPI godot_packed_vector2i_array_destroy(godot_packed_vector2i_array *p_self);
godot_vector2i GDAPI *godot_packed_vector2i_array_operator_index(godot_packed_vector2i_array *p_self, godot_int p_index);
const godot_vector2i GDAPI *godot_packed_vector2i_array_operator_index_const(const godot_packed_vector2i_array *p_self, godot_int p_index);
// Vector3.
void GDAPI godot_packed_vector3_array_new(godot_packed_vector3_array *p_self);
void GDAPI godot_packed_vector3_array_new_copy(godot_packed_vector3_array *r_dest, const godot_packed_vector3_array *p_src);
void GDAPI godot_packed_vector3_array_destroy(godot_packed_vector3_array *p_self);
godot_vector3 GDAPI *godot_packed_vector3_array_operator_index(godot_packed_vector3_array *p_self, godot_int p_index);
const godot_vector3 GDAPI *godot_packed_vector3_array_operator_index_const(const godot_packed_vector3_array *p_self, godot_int p_index);
// Vector3i.
void GDAPI godot_packed_vector3i_array_new(godot_packed_vector3i_array *p_self);
void GDAPI godot_packed_vector3i_array_new_copy(godot_packed_vector3i_array *r_dest, const godot_packed_vector3i_array *p_src);
void GDAPI godot_packed_vector3i_array_destroy(godot_packed_vector3i_array *p_self);
godot_vector3i GDAPI *godot_packed_vector3i_array_operator_index(godot_packed_vector3i_array *p_self, godot_int p_index);
const godot_vector3i GDAPI *godot_packed_vector3i_array_operator_index_const(const godot_packed_vector3i_array *p_self, godot_int p_index);
// Color.
void GDAPI godot_packed_color_array_new(godot_packed_color_array *p_self);
void GDAPI godot_packed_color_array_new_copy(godot_packed_color_array *r_dest, const godot_packed_color_array *p_src);
void GDAPI godot_packed_color_array_destroy(godot_packed_color_array *p_self);
godot_color GDAPI *godot_packed_color_array_operator_index(godot_packed_color_array *p_self, godot_int p_index);
const godot_color GDAPI *godot_packed_color_array_operator_index_const(const godot_packed_color_array *p_self, godot_int p_index);
#ifdef __cplusplus
}
#endif
#endif // GODOT_PACKED_ARRAYS_H

View File

@ -1,58 +0,0 @@
/*************************************************************************/
/* plane.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_PLANE_H
#define GODOT_PLANE_H
#ifdef __cplusplus
extern "C" {
#endif
#include <gdnative/math_defs.h>
#define GODOT_PLANE_SIZE (sizeof(godot_real_t) * 4)
#ifndef GODOT_CORE_API_GODOT_PLANE_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_PLANE_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_PLANE_SIZE];
} godot_plane;
#endif
#include <gdnative/gdnative.h>
void GDAPI godot_plane_new(godot_plane *p_self);
void GDAPI godot_plane_new_copy(godot_plane *r_dest, const godot_plane *p_src);
#ifdef __cplusplus
}
#endif
#endif // GODOT_PLANE_H

View File

@ -1,60 +0,0 @@
/*************************************************************************/
/* quaternion.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_QUATERNION_H
#define GODOT_QUATERNION_H
#ifdef __cplusplus
extern "C" {
#endif
#include <gdnative/math_defs.h>
#define GODOT_QUATERNION_SIZE (sizeof(godot_real_t) * 4)
#ifndef GODOT_CORE_API_GODOT_QUATERNION_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_QUATERNION_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_QUATERNION_SIZE];
} godot_quaternion;
#endif
#include <gdnative/gdnative.h>
void GDAPI godot_quaternion_new(godot_quaternion *p_self);
void GDAPI godot_quaternion_new_copy(godot_quaternion *r_dest, const godot_quaternion *p_src);
godot_real_t GDAPI *godot_quaternion_operator_index(godot_quaternion *p_self, godot_int p_index);
const godot_real_t GDAPI *godot_quaternion_operator_index_const(const godot_quaternion *p_self, godot_int p_index);
#ifdef __cplusplus
}
#endif
#endif // GODOT_QUATERNION_H

View File

@ -1,69 +0,0 @@
/*************************************************************************/
/* rect2.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_RECT2_H
#define GODOT_RECT2_H
#ifdef __cplusplus
extern "C" {
#endif
#include <gdnative/math_defs.h>
#define GODOT_RECT2_SIZE (sizeof(godot_real_t) * 4)
#ifndef GODOT_CORE_API_GODOT_RECT2_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_RECT2_TYPE_DEFINED
typedef struct godot_rect2 {
uint8_t _dont_touch_that[GODOT_RECT2_SIZE];
} godot_rect2;
#endif
#define GODOT_RECT2I_SIZE (sizeof(int32_t) * 4)
#ifndef GODOT_CORE_API_GODOT_RECT2I_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_RECT2I_TYPE_DEFINED
typedef struct godot_rect2i {
uint8_t _dont_touch_that[GODOT_RECT2I_SIZE];
} godot_rect2i;
#endif
#include <gdnative/gdnative.h>
void GDAPI godot_rect2_new(godot_rect2 *p_self);
void GDAPI godot_rect2_new_copy(godot_rect2 *r_dest, const godot_rect2 *p_src);
void GDAPI godot_rect2i_new(godot_rect2i *p_self);
void GDAPI godot_rect2i_new_copy(godot_rect2i *r_dest, const godot_rect2i *p_src);
#ifdef __cplusplus
}
#endif
#endif // GODOT_RECT2_H

View File

@ -1,58 +0,0 @@
/*************************************************************************/
/* rid.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_RID_H
#define GODOT_RID_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#define GODOT_RID_SIZE sizeof(uint64_t)
#ifndef GODOT_CORE_API_GODOT_RID_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_RID_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_RID_SIZE];
} godot_rid;
#endif
#include <gdnative/gdnative.h>
void GDAPI godot_rid_new(godot_rid *p_self);
void GDAPI godot_rid_new_copy(godot_rid *r_dest, const godot_rid *p_src);
#ifdef __cplusplus
}
#endif
#endif // GODOT_RID_H

View File

@ -1,60 +0,0 @@
/*************************************************************************/
/* signal.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_SIGNAL_H
#define GODOT_SIGNAL_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
// Alignment hardcoded in `core/variant/callable.h`.
#define GODOT_SIGNAL_SIZE (16)
#ifndef GODOT_CORE_API_GODOT_SIGNAL_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_SIGNAL_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_SIGNAL_SIZE];
} godot_signal;
#endif
#include <gdnative/gdnative.h>
void GDAPI godot_signal_new(godot_signal *p_self);
void GDAPI godot_signal_new_copy(godot_signal *r_dest, const godot_signal *p_src);
void GDAPI godot_signal_destroy(godot_signal *p_self);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,89 +0,0 @@
/*************************************************************************/
/* string.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_STRING_H
#define GODOT_STRING_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include <stdint.h>
#ifndef __cplusplus
typedef uint16_t char16_t;
typedef uint32_t char32_t;
#endif
typedef char32_t godot_char_type;
#define GODOT_STRING_SIZE sizeof(void *)
#ifndef GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_STRING_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_STRING_SIZE];
} godot_string;
#endif
#include <gdnative/gdnative.h>
#include <gdnative/math_defs.h>
void GDAPI godot_string_new(godot_string *r_dest);
void GDAPI godot_string_new_copy(godot_string *r_dest, const godot_string *p_src);
void GDAPI godot_string_destroy(godot_string *p_self);
void GDAPI godot_string_new_with_latin1_chars(godot_string *r_dest, const char *p_contents);
void GDAPI godot_string_new_with_utf8_chars(godot_string *r_dest, const char *p_contents);
void GDAPI godot_string_new_with_utf16_chars(godot_string *r_dest, const char16_t *p_contents);
void GDAPI godot_string_new_with_utf32_chars(godot_string *r_dest, const char32_t *p_contents);
void GDAPI godot_string_new_with_wide_chars(godot_string *r_dest, const wchar_t *p_contents);
void GDAPI godot_string_new_with_latin1_chars_and_len(godot_string *r_dest, const char *p_contents, const int p_size);
void GDAPI godot_string_new_with_utf8_chars_and_len(godot_string *r_dest, const char *p_contents, const int p_size);
void GDAPI godot_string_new_with_utf16_chars_and_len(godot_string *r_dest, const char16_t *p_contents, const int p_size);
void GDAPI godot_string_new_with_utf32_chars_and_len(godot_string *r_dest, const char32_t *p_contents, const int p_size);
void GDAPI godot_string_new_with_wide_chars_and_len(godot_string *r_dest, const wchar_t *p_contents, const int p_size);
const char GDAPI *godot_string_to_latin1_chars(const godot_string *p_self);
const char GDAPI *godot_string_to_utf8_chars(const godot_string *p_self);
const char16_t GDAPI *godot_string_to_utf16_chars(const godot_string *p_self);
const char32_t GDAPI *godot_string_to_utf32_chars(const godot_string *p_self);
const wchar_t GDAPI *godot_string_to_wide_chars(const godot_string *p_self);
char32_t GDAPI *godot_string_operator_index(godot_string *p_self, godot_int p_index);
const char32_t GDAPI *godot_string_operator_index_const(const godot_string *p_self, godot_int p_index);
#ifdef __cplusplus
}
#endif
#endif // GODOT_STRING_H

View File

@ -1,62 +0,0 @@
/*************************************************************************/
/* string_name.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_STRING_NAME_H
#define GODOT_STRING_NAME_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <wchar.h>
#define GODOT_STRING_NAME_SIZE sizeof(void *)
#ifndef GODOT_CORE_API_GODOT_STRING_NAME_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_STRING_NAME_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_STRING_NAME_SIZE];
} godot_string_name;
#endif
#include <gdnative/gdnative.h>
void GDAPI godot_string_name_new(godot_string_name *r_dest);
void GDAPI godot_string_name_new_copy(godot_string_name *r_dest, const godot_string_name *p_src);
void GDAPI godot_string_name_destroy(godot_string_name *p_self);
void GDAPI godot_string_name_new_with_latin1_chars(godot_string_name *r_dest, const char *p_contents);
#ifdef __cplusplus
}
#endif
#endif // GODOT_STRING_NAME_H

View File

@ -1,60 +0,0 @@
/*************************************************************************/
/* transform2d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_TRANSFORM2D_H
#define GODOT_TRANSFORM2D_H
#ifdef __cplusplus
extern "C" {
#endif
#include <gdnative/math_defs.h>
#define GODOT_TRANSFORM2D_SIZE (sizeof(godot_real_t) * 6)
#ifndef GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_TRANSFORM2D_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_TRANSFORM2D_SIZE];
} godot_transform2d;
#endif
#include <gdnative/gdnative.h>
void GDAPI godot_transform2d_new(godot_transform2d *p_self);
void GDAPI godot_transform2d_new_copy(godot_transform2d *r_dest, const godot_transform2d *p_src);
godot_vector2 GDAPI *godot_transform2d_operator_index(godot_transform2d *p_self, godot_int p_index);
const godot_vector2 GDAPI *godot_transform2d_operator_index_const(const godot_transform2d *p_self, godot_int p_index);
#ifdef __cplusplus
}
#endif
#endif // GODOT_TRANSFORM2D_H

View File

@ -1,60 +0,0 @@
/*************************************************************************/
/* transform_3d.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_TRANSFORM3D_H
#define GODOT_TRANSFORM3D_H
#ifdef __cplusplus
extern "C" {
#endif
#include <gdnative/math_defs.h>
#define GODOT_TRANSFORM3D_SIZE (sizeof(godot_real_t) * 12)
#ifndef GODOT_CORE_API_GODOT_TRANSFORM3D_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_TRANSFORM3D_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_TRANSFORM3D_SIZE];
} godot_transform3d;
#endif
#include <gdnative/gdnative.h>
void GDAPI godot_transform3d_new(godot_transform3d *p_self);
void GDAPI godot_transform3d_new_copy(godot_transform3d *r_dest, const godot_transform3d *p_src);
godot_vector3 GDAPI *godot_transform3d_operator_index(godot_transform3d *p_self, godot_int p_index);
const godot_vector3 GDAPI *godot_transform3d_operator_index_const(const godot_transform3d *p_self, godot_int p_index);
#ifdef __cplusplus
}
#endif
#endif // GODOT_TRANSFORM3D_H

View File

@ -1,425 +0,0 @@
/*************************************************************************/
/* variant.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_VARIANT_H
#define GODOT_VARIANT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <gdnative/math_defs.h>
#include <gdnative/variant_struct.h>
typedef enum godot_variant_type {
GODOT_VARIANT_TYPE_NIL,
// atomic types
GODOT_VARIANT_TYPE_BOOL,
GODOT_VARIANT_TYPE_INT,
GODOT_VARIANT_TYPE_FLOAT,
GODOT_VARIANT_TYPE_STRING,
// math types
GODOT_VARIANT_TYPE_VECTOR2,
GODOT_VARIANT_TYPE_VECTOR2I,
GODOT_VARIANT_TYPE_RECT2,
GODOT_VARIANT_TYPE_RECT2I,
GODOT_VARIANT_TYPE_VECTOR3,
GODOT_VARIANT_TYPE_VECTOR3I,
GODOT_VARIANT_TYPE_TRANSFORM2D,
GODOT_VARIANT_TYPE_PLANE,
GODOT_VARIANT_TYPE_QUATERNION,
GODOT_VARIANT_TYPE_AABB,
GODOT_VARIANT_TYPE_BASIS,
GODOT_VARIANT_TYPE_TRANSFORM3D,
// misc types
GODOT_VARIANT_TYPE_COLOR,
GODOT_VARIANT_TYPE_STRING_NAME,
GODOT_VARIANT_TYPE_NODE_PATH,
GODOT_VARIANT_TYPE_RID,
GODOT_VARIANT_TYPE_OBJECT,
GODOT_VARIANT_TYPE_CALLABLE,
GODOT_VARIANT_TYPE_SIGNAL,
GODOT_VARIANT_TYPE_DICTIONARY,
GODOT_VARIANT_TYPE_ARRAY,
// arrays
GODOT_VARIANT_TYPE_PACKED_BYTE_ARRAY,
GODOT_VARIANT_TYPE_PACKED_INT32_ARRAY,
GODOT_VARIANT_TYPE_PACKED_INT64_ARRAY,
GODOT_VARIANT_TYPE_PACKED_FLOAT32_ARRAY,
GODOT_VARIANT_TYPE_PACKED_FLOAT64_ARRAY,
GODOT_VARIANT_TYPE_PACKED_STRING_ARRAY,
GODOT_VARIANT_TYPE_PACKED_VECTOR2_ARRAY,
GODOT_VARIANT_TYPE_PACKED_VECTOR3_ARRAY,
GODOT_VARIANT_TYPE_PACKED_COLOR_ARRAY,
} godot_variant_type;
typedef enum godot_variant_call_error_error {
GODOT_CALL_ERROR_CALL_OK,
GODOT_CALL_ERROR_CALL_ERROR_INVALID_METHOD,
GODOT_CALL_ERROR_CALL_ERROR_INVALID_ARGUMENT,
GODOT_CALL_ERROR_CALL_ERROR_TOO_MANY_ARGUMENTS,
GODOT_CALL_ERROR_CALL_ERROR_TOO_FEW_ARGUMENTS,
GODOT_CALL_ERROR_CALL_ERROR_INSTANCE_IS_NULL,
} godot_variant_call_error_error;
typedef struct godot_variant_call_error {
godot_variant_call_error_error error;
int argument;
godot_variant_type expected;
} godot_variant_call_error;
typedef enum godot_variant_operator {
// comparison
GODOT_VARIANT_OP_EQUAL,
GODOT_VARIANT_OP_NOT_EQUAL,
GODOT_VARIANT_OP_LESS,
GODOT_VARIANT_OP_LESS_EQUAL,
GODOT_VARIANT_OP_GREATER,
GODOT_VARIANT_OP_GREATER_EQUAL,
// mathematic
GODOT_VARIANT_OP_ADD,
GODOT_VARIANT_OP_SUBTRACT,
GODOT_VARIANT_OP_MULTIPLY,
GODOT_VARIANT_OP_DIVIDE,
GODOT_VARIANT_OP_NEGATE,
GODOT_VARIANT_OP_POSITIVE,
GODOT_VARIANT_OP_MODULE,
GODOT_VARIANT_OP_STRING_CONCAT,
// bitwise
GODOT_VARIANT_OP_SHIFT_LEFT,
GODOT_VARIANT_OP_SHIFT_RIGHT,
GODOT_VARIANT_OP_BIT_AND,
GODOT_VARIANT_OP_BIT_OR,
GODOT_VARIANT_OP_BIT_XOR,
GODOT_VARIANT_OP_BIT_NEGATE,
// logic
GODOT_VARIANT_OP_AND,
GODOT_VARIANT_OP_OR,
GODOT_VARIANT_OP_XOR,
GODOT_VARIANT_OP_NOT,
// containment
GODOT_VARIANT_OP_IN,
GODOT_VARIANT_OP_MAX,
} godot_variant_operator;
typedef enum godot_variant_utility_function_type {
GODOT_UTILITY_FUNC_TYPE_MATH,
GODOT_UTILITY_FUNC_TYPE_RANDOM,
GODOT_UTILITY_FUNC_TYPE_GENERAL,
} godot_variant_utility_function_type;
// Types for function pointers.
typedef void (*godot_validated_operator_evaluator)(const godot_variant *p_left, const godot_variant *p_right, godot_variant *r_result);
typedef void (*godot_ptr_operator_evaluator)(const void *p_left, const void *p_right, void *r_result);
typedef void (*godot_validated_builtin_method)(godot_variant *p_base, const godot_variant **p_args, int p_argument_count, godot_variant *r_return);
typedef void (*godot_ptr_builtin_method)(void *p_base, const void **p_args, void *r_return, int p_argument_count);
typedef void (*godot_validated_constructor)(godot_variant *p_base, const godot_variant **p_args);
typedef void (*godot_ptr_constructor)(void *p_base, const void **p_args);
typedef void (*godot_validated_setter)(godot_variant *p_base, const godot_variant *p_value);
typedef void (*godot_validated_getter)(const godot_variant *p_base, godot_variant *r_value);
typedef void (*godot_ptr_setter)(void *p_base, const void *p_value);
typedef void (*godot_ptr_getter)(const void *p_base, void *r_value);
typedef void (*godot_validated_indexed_setter)(godot_variant *p_base, godot_int p_index, const godot_variant *p_value, bool *r_oob);
typedef void (*godot_validated_indexed_getter)(const godot_variant *p_base, godot_int p_index, godot_variant *r_value, bool *r_oob);
typedef void (*godot_ptr_indexed_setter)(void *p_base, godot_int p_index, const void *p_value);
typedef void (*godot_ptr_indexed_getter)(const void *p_base, godot_int p_index, void *r_value);
typedef void (*godot_validated_keyed_setter)(godot_variant *p_base, const godot_variant *p_key, const godot_variant *p_value, bool *r_valid);
typedef void (*godot_validated_keyed_getter)(const godot_variant *p_base, const godot_variant *p_key, godot_variant *r_value, bool *r_valid);
typedef bool (*godot_validated_keyed_checker)(const godot_variant *p_base, const godot_variant *p_key, bool *r_valid);
typedef void (*godot_ptr_keyed_setter)(void *p_base, const void *p_key, const void *p_value);
typedef void (*godot_ptr_keyed_getter)(const void *p_base, const void *p_key, void *r_value);
typedef uint32_t (*godot_ptr_keyed_checker)(const godot_variant *p_base, const godot_variant *p_key);
typedef void (*godot_validated_utility_function)(godot_variant *r_return, const godot_variant **p_arguments, int p_argument_count);
typedef void (*godot_ptr_utility_function)(void *r_return, const void **p_arguments, int p_argument_count);
#include <gdnative/aabb.h>
#include <gdnative/array.h>
#include <gdnative/basis.h>
#include <gdnative/callable.h>
#include <gdnative/color.h>
#include <gdnative/dictionary.h>
#include <gdnative/node_path.h>
#include <gdnative/packed_arrays.h>
#include <gdnative/plane.h>
#include <gdnative/quaternion.h>
#include <gdnative/rect2.h>
#include <gdnative/rid.h>
#include <gdnative/signal.h>
#include <gdnative/string.h>
#include <gdnative/string_name.h>
#include <gdnative/transform2d.h>
#include <gdnative/transform_3d.h>
#include <gdnative/variant.h>
#include <gdnative/vector2.h>
#include <gdnative/vector3.h>
#include <gdnative/gdnative.h>
// Memory.
void GDAPI godot_variant_new_copy(godot_variant *r_dest, const godot_variant *p_src);
void GDAPI godot_variant_new_nil(godot_variant *r_dest);
void GDAPI godot_variant_new_bool(godot_variant *r_dest, const godot_bool p_b);
void GDAPI godot_variant_new_int(godot_variant *r_dest, const godot_int p_i);
void GDAPI godot_variant_new_float(godot_variant *r_dest, const godot_float p_f);
void GDAPI godot_variant_new_string(godot_variant *r_dest, const godot_string *p_s);
void GDAPI godot_variant_new_vector2(godot_variant *r_dest, const godot_vector2 *p_v2);
void GDAPI godot_variant_new_vector2i(godot_variant *r_dest, const godot_vector2i *p_v2);
void GDAPI godot_variant_new_rect2(godot_variant *r_dest, const godot_rect2 *p_rect2);
void GDAPI godot_variant_new_rect2i(godot_variant *r_dest, const godot_rect2i *p_rect2);
void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3 *p_v3);
void GDAPI godot_variant_new_vector3i(godot_variant *r_dest, const godot_vector3i *p_v3);
void GDAPI godot_variant_new_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d);
void GDAPI godot_variant_new_plane(godot_variant *r_dest, const godot_plane *p_plane);
void GDAPI godot_variant_new_quaternion(godot_variant *r_dest, const godot_quaternion *p_quaternion);
void GDAPI godot_variant_new_aabb(godot_variant *r_dest, const godot_aabb *p_aabb);
void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis);
void GDAPI godot_variant_new_transform3d(godot_variant *r_dest, const godot_transform3d *p_trans);
void GDAPI godot_variant_new_color(godot_variant *r_dest, const godot_color *p_color);
void GDAPI godot_variant_new_string_name(godot_variant *r_dest, const godot_string_name *p_s);
void GDAPI godot_variant_new_node_path(godot_variant *r_dest, const godot_node_path *p_np);
void GDAPI godot_variant_new_rid(godot_variant *r_dest, const godot_rid *p_rid);
void GDAPI godot_variant_new_object(godot_variant *r_dest, const godot_object *p_obj);
void GDAPI godot_variant_new_callable(godot_variant *r_dest, const godot_callable *p_callable);
void GDAPI godot_variant_new_signal(godot_variant *r_dest, const godot_signal *p_signal);
void GDAPI godot_variant_new_dictionary(godot_variant *r_dest, const godot_dictionary *p_dict);
void GDAPI godot_variant_new_array(godot_variant *r_dest, const godot_array *p_arr);
void GDAPI godot_variant_new_packed_byte_array(godot_variant *r_dest, const godot_packed_byte_array *p_pba);
void GDAPI godot_variant_new_packed_int32_array(godot_variant *r_dest, const godot_packed_int32_array *p_pia);
void GDAPI godot_variant_new_packed_int64_array(godot_variant *r_dest, const godot_packed_int64_array *p_pia);
void GDAPI godot_variant_new_packed_float32_array(godot_variant *r_dest, const godot_packed_float32_array *p_pra);
void GDAPI godot_variant_new_packed_float64_array(godot_variant *r_dest, const godot_packed_float64_array *p_pra);
void GDAPI godot_variant_new_packed_string_array(godot_variant *r_dest, const godot_packed_string_array *p_psa);
void GDAPI godot_variant_new_packed_vector2_array(godot_variant *r_dest, const godot_packed_vector2_array *p_pv2a);
void GDAPI godot_variant_new_packed_vector3_array(godot_variant *r_dest, const godot_packed_vector3_array *p_pv3a);
void GDAPI godot_variant_new_packed_color_array(godot_variant *r_dest, const godot_packed_color_array *p_pca);
godot_bool GDAPI godot_variant_as_bool(const godot_variant *p_self);
godot_int GDAPI godot_variant_as_int(const godot_variant *p_self);
godot_float GDAPI godot_variant_as_float(const godot_variant *p_self);
godot_string GDAPI godot_variant_as_string(const godot_variant *p_self);
godot_vector2 GDAPI godot_variant_as_vector2(const godot_variant *p_self);
godot_vector2i GDAPI godot_variant_as_vector2i(const godot_variant *p_self);
godot_rect2 GDAPI godot_variant_as_rect2(const godot_variant *p_self);
godot_rect2i GDAPI godot_variant_as_rect2i(const godot_variant *p_self);
godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_self);
godot_vector3i GDAPI godot_variant_as_vector3i(const godot_variant *p_self);
godot_transform2d GDAPI godot_variant_as_transform2d(const godot_variant *p_self);
godot_plane GDAPI godot_variant_as_plane(const godot_variant *p_self);
godot_quaternion GDAPI godot_variant_as_quaternion(const godot_variant *p_self);
godot_aabb GDAPI godot_variant_as_aabb(const godot_variant *p_self);
godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_self);
godot_transform3d GDAPI godot_variant_as_transform3d(const godot_variant *p_self);
godot_color GDAPI godot_variant_as_color(const godot_variant *p_self);
godot_string_name GDAPI godot_variant_as_string_name(const godot_variant *p_self);
godot_node_path GDAPI godot_variant_as_node_path(const godot_variant *p_self);
godot_rid GDAPI godot_variant_as_rid(const godot_variant *p_self);
godot_object GDAPI *godot_variant_as_object(const godot_variant *p_self);
godot_callable GDAPI godot_variant_as_callable(const godot_variant *p_self);
godot_signal GDAPI godot_variant_as_signal(const godot_variant *p_self);
godot_dictionary GDAPI godot_variant_as_dictionary(const godot_variant *p_self);
godot_array GDAPI godot_variant_as_array(const godot_variant *p_self);
godot_packed_byte_array GDAPI godot_variant_as_packed_byte_array(const godot_variant *p_self);
godot_packed_int32_array GDAPI godot_variant_as_packed_int32_array(const godot_variant *p_self);
godot_packed_int64_array GDAPI godot_variant_as_packed_int64_array(const godot_variant *p_self);
godot_packed_float32_array GDAPI godot_variant_as_packed_float32_array(const godot_variant *p_self);
godot_packed_float64_array GDAPI godot_variant_as_packed_float64_array(const godot_variant *p_self);
godot_packed_string_array GDAPI godot_variant_as_packed_string_array(const godot_variant *p_self);
godot_packed_vector2_array GDAPI godot_variant_as_packed_vector2_array(const godot_variant *p_self);
godot_packed_vector3_array GDAPI godot_variant_as_packed_vector3_array(const godot_variant *p_self);
godot_packed_color_array GDAPI godot_variant_as_packed_color_array(const godot_variant *p_self);
void GDAPI godot_variant_destroy(godot_variant *p_self);
// Dynamic interaction.
void GDAPI godot_variant_call(godot_variant *p_self, const godot_string_name *p_method, const godot_variant **p_args, const godot_int p_argument_count, godot_variant *r_return, godot_variant_call_error *r_error);
void GDAPI godot_variant_call_with_cstring(godot_variant *p_self, const char *p_method, const godot_variant **p_args, const godot_int p_argument_count, godot_variant *r_return, godot_variant_call_error *r_error);
void GDAPI godot_variant_call_static(godot_variant_type p_type, const godot_string_name *p_method, const godot_variant **p_args, const godot_int p_argument_count, godot_variant *r_return, godot_variant_call_error *r_error);
void GDAPI godot_variant_call_static_with_cstring(godot_variant_type p_type, const char *p_method, const godot_variant **p_args, const godot_int p_argument_count, godot_variant *r_return, godot_variant_call_error *r_error);
void GDAPI godot_variant_evaluate(godot_variant_operator p_op, const godot_variant *p_a, const godot_variant *p_b, godot_variant *r_return, bool *r_valid);
void GDAPI godot_variant_set(godot_variant *p_self, const godot_variant *p_key, const godot_variant *p_value, bool *r_valid);
void GDAPI godot_variant_set_named(godot_variant *p_self, const godot_string_name *p_name, const godot_variant *p_value, bool *r_valid);
void GDAPI godot_variant_set_named_with_cstring(godot_variant *p_self, const char *p_name, const godot_variant *p_value, bool *r_valid);
void GDAPI godot_variant_set_keyed(godot_variant *p_self, const godot_variant *p_key, const godot_variant *p_value, bool *r_valid);
void GDAPI godot_variant_set_indexed(godot_variant *p_self, godot_int p_index, const godot_variant *p_value, bool *r_valid, bool *r_oob);
godot_variant GDAPI godot_variant_get(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid);
godot_variant GDAPI godot_variant_get_named(const godot_variant *p_self, const godot_string_name *p_key, bool *r_valid);
godot_variant GDAPI godot_variant_get_named_with_cstring(const godot_variant *p_self, const char *p_key, bool *r_valid);
godot_variant GDAPI godot_variant_get_keyed(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid);
godot_variant GDAPI godot_variant_get_indexed(const godot_variant *p_self, godot_int p_index, bool *r_valid, bool *r_oob);
/// Iteration.
bool GDAPI godot_variant_iter_init(const godot_variant *p_self, godot_variant *r_iter, bool *r_valid);
bool GDAPI godot_variant_iter_next(const godot_variant *p_self, godot_variant *r_iter, bool *r_valid);
godot_variant GDAPI godot_variant_iter_get(const godot_variant *p_self, godot_variant *r_iter, bool *r_valid);
/// Variant functions.
godot_bool GDAPI godot_variant_hash_compare(const godot_variant *p_self, const godot_variant *p_other);
godot_bool GDAPI godot_variant_booleanize(const godot_variant *p_self);
void GDAPI godot_variant_blend(const godot_variant *p_a, const godot_variant *p_b, float p_c, godot_variant *r_dst);
void GDAPI godot_variant_interpolate(const godot_variant *p_a, const godot_variant *p_b, float p_c, godot_variant *r_dst);
godot_variant GDAPI godot_variant_duplicate(const godot_variant *p_self, godot_bool p_deep);
godot_string GDAPI godot_variant_stringify(const godot_variant *p_self);
// Discovery API.
/// Operators.
godot_validated_operator_evaluator GDAPI godot_variant_get_validated_operator_evaluator(godot_variant_operator p_operator, godot_variant_type p_type_a, godot_variant_type p_type_b);
godot_ptr_operator_evaluator GDAPI godot_variant_get_ptr_operator_evaluator(godot_variant_operator p_operator, godot_variant_type p_type_a, godot_variant_type p_type_b);
godot_variant_type GDAPI godot_variant_get_operator_return_type(godot_variant_operator p_operator, godot_variant_type p_type_a, godot_variant_type p_type_b);
godot_string GDAPI godot_variant_get_operator_name(godot_variant_operator p_operator);
/// Built-in methods.
bool GDAPI godot_variant_has_builtin_method(godot_variant_type p_type, const godot_string_name *p_method);
bool GDAPI godot_variant_has_builtin_method_with_cstring(godot_variant_type p_type, const char *p_method);
godot_validated_builtin_method GDAPI godot_variant_get_validated_builtin_method(godot_variant_type p_type, const godot_string_name *p_method);
godot_validated_builtin_method GDAPI godot_variant_get_validated_builtin_method_with_cstring(godot_variant_type p_type, const char *p_method);
godot_ptr_builtin_method GDAPI godot_variant_get_ptr_builtin_method(godot_variant_type p_type, const godot_string_name *p_method);
godot_ptr_builtin_method GDAPI godot_variant_get_ptr_builtin_method_with_cstring(godot_variant_type p_type, const char *p_method);
int GDAPI godot_variant_get_builtin_method_argument_count(godot_variant_type p_type, const godot_string_name *p_method);
int GDAPI godot_variant_get_builtin_method_argument_count_with_cstring(godot_variant_type p_type, const char *p_method);
godot_variant_type GDAPI godot_variant_get_builtin_method_argument_type(godot_variant_type p_type, const godot_string_name *p_method, int p_argument);
godot_variant_type GDAPI godot_variant_get_builtin_method_argument_type_with_cstring(godot_variant_type p_type, const char *p_method, int p_argument);
godot_string GDAPI godot_variant_get_builtin_method_argument_name(godot_variant_type p_type, const godot_string_name *p_method, int p_argument);
godot_string GDAPI godot_variant_get_builtin_method_argument_name_with_cstring(godot_variant_type p_type, const char *p_method, int p_argument);
bool GDAPI godot_variant_has_builtin_method_return_value(godot_variant_type p_type, const godot_string_name *p_method);
bool GDAPI godot_variant_has_builtin_method_return_value_with_cstring(godot_variant_type p_type, const char *p_method);
godot_variant_type GDAPI godot_variant_get_builtin_method_return_type(godot_variant_type p_type, const godot_string_name *p_method);
godot_variant_type GDAPI godot_variant_get_builtin_method_return_type_with_cstring(godot_variant_type p_type, const char *p_method);
bool GDAPI godot_variant_is_builtin_method_const(godot_variant_type p_type, const godot_string_name *p_method);
bool GDAPI godot_variant_is_builtin_method_const_with_cstring(godot_variant_type p_type, const char *p_method);
bool GDAPI godot_variant_is_builtin_method_static(godot_variant_type p_type, const godot_string_name *p_method);
bool GDAPI godot_variant_is_builtin_method_static_with_cstring(godot_variant_type p_type, const char *p_method);
bool GDAPI godot_variant_is_builtin_method_vararg(godot_variant_type p_type, const godot_string_name *p_method);
bool GDAPI godot_variant_is_builtin_method_vararg_with_cstring(godot_variant_type p_type, const char *p_method);
int GDAPI godot_variant_get_builtin_method_count(godot_variant_type p_type);
void GDAPI godot_variant_get_builtin_method_list(godot_variant_type p_type, godot_string_name *r_list);
/// Constructors.
int GDAPI godot_variant_get_constructor_count(godot_variant_type p_type);
godot_validated_constructor GDAPI godot_variant_get_validated_constructor(godot_variant_type p_type, int p_constructor);
godot_ptr_constructor GDAPI godot_variant_get_ptr_constructor(godot_variant_type p_type, int p_constructor);
int GDAPI godot_variant_get_constructor_argument_count(godot_variant_type p_type, int p_constructor);
godot_variant_type GDAPI godot_variant_get_constructor_argument_type(godot_variant_type p_type, int p_constructor, int p_argument);
godot_string GDAPI godot_variant_get_constructor_argument_name(godot_variant_type p_type, int p_constructor, int p_argument);
void GDAPI godot_variant_construct(godot_variant_type p_type, godot_variant *p_base, const godot_variant **p_args, int p_argument_count, godot_variant_call_error *r_error);
/// Properties.
godot_variant_type GDAPI godot_variant_get_member_type(godot_variant_type p_type, const godot_string_name *p_member);
godot_variant_type GDAPI godot_variant_get_member_type_with_cstring(godot_variant_type p_type, const char *p_member);
int GDAPI godot_variant_get_member_count(godot_variant_type p_type);
void GDAPI godot_variant_get_member_list(godot_variant_type p_type, godot_string_name *r_list);
godot_validated_setter GDAPI godot_variant_get_validated_setter(godot_variant_type p_type, const godot_string_name *p_member);
godot_validated_setter GDAPI godot_variant_get_validated_setter_with_cstring(godot_variant_type p_type, const char *p_member);
godot_validated_getter GDAPI godot_variant_get_validated_getter(godot_variant_type p_type, const godot_string_name *p_member);
godot_validated_getter GDAPI godot_variant_get_validated_getter_with_cstring(godot_variant_type p_type, const char *p_member);
godot_ptr_setter GDAPI godot_variant_get_ptr_setter(godot_variant_type p_type, const godot_string_name *p_member);
godot_ptr_setter GDAPI godot_variant_get_ptr_setter_with_cstring(godot_variant_type p_type, const char *p_member);
godot_ptr_getter GDAPI godot_variant_get_ptr_getter(godot_variant_type p_type, const godot_string_name *p_member);
godot_ptr_getter GDAPI godot_variant_get_ptr_getter_with_cstring(godot_variant_type p_type, const char *p_member);
/// Indexing.
bool GDAPI godot_variant_has_indexing(godot_variant_type p_type);
godot_variant_type GDAPI godot_variant_get_indexed_element_type(godot_variant_type p_type);
godot_validated_indexed_setter GDAPI godot_variant_get_validated_indexed_setter(godot_variant_type p_type);
godot_validated_indexed_getter GDAPI godot_variant_get_validated_indexed_getter(godot_variant_type p_type);
godot_ptr_indexed_setter GDAPI godot_variant_get_ptr_indexed_setter(godot_variant_type p_type);
godot_ptr_indexed_getter GDAPI godot_variant_get_ptr_indexed_getter(godot_variant_type p_type);
uint64_t GDAPI godot_variant_get_indexed_size(const godot_variant *p_self);
/// Keying.
bool GDAPI godot_variant_is_keyed(godot_variant_type p_type);
godot_validated_keyed_setter GDAPI godot_variant_get_validated_keyed_setter(godot_variant_type p_type);
godot_validated_keyed_getter GDAPI godot_variant_get_validated_keyed_getter(godot_variant_type p_type);
godot_validated_keyed_checker GDAPI godot_variant_get_validated_keyed_checker(godot_variant_type p_type);
godot_ptr_keyed_setter GDAPI godot_variant_get_ptr_keyed_setter(godot_variant_type p_type);
godot_ptr_keyed_getter GDAPI godot_variant_get_ptr_keyed_getter(godot_variant_type p_type);
godot_ptr_keyed_checker GDAPI godot_variant_get_ptr_keyed_checker(godot_variant_type p_type);
/// Constants.
int GDAPI godot_variant_get_constants_count(godot_variant_type p_type);
void GDAPI godot_variant_get_constants_list(godot_variant_type p_type, godot_string_name *r_list);
bool GDAPI godot_variant_has_constant(godot_variant_type p_type, const godot_string_name *p_constant);
bool GDAPI godot_variant_has_constant_with_cstring(godot_variant_type p_type, const char *p_constant);
godot_variant GDAPI godot_variant_get_constant_value(godot_variant_type p_type, const godot_string_name *p_constant);
godot_variant GDAPI godot_variant_get_constant_value_with_cstring(godot_variant_type p_type, const char *p_constant);
/// Utilities.
bool GDAPI godot_variant_has_utility_function(const godot_string_name *p_function);
bool GDAPI godot_variant_has_utility_function_with_cstring(const char *p_function);
void GDAPI godot_variant_call_utility_function(const godot_string_name *p_function, godot_variant *r_ret, const godot_variant **p_args, int p_argument_count, godot_variant_call_error *r_error);
void GDAPI godot_variant_call_utility_function_with_cstring(const char *p_function, godot_variant *r_ret, const godot_variant **p_args, int p_argument_count, godot_variant_call_error *r_error);
godot_ptr_utility_function GDAPI godot_variant_get_ptr_utility_function(const godot_string_name *p_function);
godot_ptr_utility_function GDAPI godot_variant_get_ptr_utility_function_with_cstring(const char *p_function);
godot_validated_utility_function GDAPI godot_variant_get_validated_utility_function(const godot_string_name *p_function);
godot_validated_utility_function GDAPI godot_variant_get_validated_utility_function_with_cstring(const char *p_function);
godot_variant_utility_function_type GDAPI godot_variant_get_utility_function_type(const godot_string_name *p_function);
godot_variant_utility_function_type GDAPI godot_variant_get_utility_function_type_with_cstring(const char *p_function);
int GDAPI godot_variant_get_utility_function_argument_count(const godot_string_name *p_function);
int GDAPI godot_variant_get_utility_function_argument_count_with_cstring(const char *p_function);
godot_variant_type GDAPI godot_variant_get_utility_function_argument_type(const godot_string_name *p_function, int p_argument);
godot_variant_type GDAPI godot_variant_get_utility_function_argument_type_with_cstring(const char *p_function, int p_argument);
godot_string GDAPI godot_variant_get_utility_function_argument_name(const godot_string_name *p_function, int p_argument);
godot_string GDAPI godot_variant_get_utility_function_argument_name_with_cstring(const char *p_function, int p_argument);
bool GDAPI godot_variant_has_utility_function_return_value(const godot_string_name *p_function);
bool GDAPI godot_variant_has_utility_function_return_value_with_cstring(const char *p_function);
godot_variant_type GDAPI godot_variant_get_utility_function_return_type(const godot_string_name *p_function);
godot_variant_type GDAPI godot_variant_get_utility_function_return_type_with_cstring(const char *p_function);
bool GDAPI godot_variant_is_utility_function_vararg(const godot_string_name *p_function);
bool GDAPI godot_variant_is_utility_function_vararg_with_cstring(const char *p_function);
int GDAPI godot_variant_get_utility_function_count();
void GDAPI godot_variant_get_utility_function_list(godot_string_name *r_functions);
// Introspection.
godot_variant_type GDAPI godot_variant_get_type(const godot_variant *p_self);
bool GDAPI godot_variant_has_method(const godot_variant *p_self, const godot_string_name *p_method);
bool GDAPI godot_variant_has_member(godot_variant_type p_type, const godot_string_name *p_member);
bool GDAPI godot_variant_has_key(const godot_variant *p_self, const godot_variant *p_key, bool *r_valid);
godot_string GDAPI godot_variant_get_type_name(godot_variant_type p_type);
bool GDAPI godot_variant_can_convert(godot_variant_type p_from, godot_variant_type p_to);
bool GDAPI godot_variant_can_convert_strict(godot_variant_type p_from, godot_variant_type p_to);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,53 +0,0 @@
/*************************************************************************/
/* variant_struct.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_VARIANT_STRUCT_H
#define GODOT_VARIANT_STRUCT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <gdnative/math_defs.h>
#define GODOT_VARIANT_SIZE (sizeof(godot_real_t) * 4 + sizeof(int64_t))
#ifndef GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_VARIANT_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_VARIANT_SIZE];
} godot_variant;
#endif
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,73 +0,0 @@
/*************************************************************************/
/* vector2.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_VECTOR2_H
#define GODOT_VECTOR2_H
#ifdef __cplusplus
extern "C" {
#endif
#include <gdnative/math_defs.h>
#define GODOT_VECTOR2_SIZE (sizeof(godot_real_t) * 2)
#ifndef GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_VECTOR2_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_VECTOR2_SIZE];
} godot_vector2;
#endif
#define GODOT_VECTOR2I_SIZE (sizeof(int32_t) * 2)
#ifndef GODOT_CORE_API_GODOT_VECTOR2I_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_VECTOR2I_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_VECTOR2I_SIZE];
} godot_vector2i;
#endif
#include <gdnative/gdnative.h>
void GDAPI godot_vector2_new(godot_vector2 *p_self);
void GDAPI godot_vector2_new_copy(godot_vector2 *r_dest, const godot_vector2 *p_src);
void GDAPI godot_vector2i_new(godot_vector2i *p_self);
void GDAPI godot_vector2i_new_copy(godot_vector2i *r_dest, const godot_vector2i *p_src);
godot_real_t GDAPI *godot_vector2_operator_index(godot_vector2 *p_self, godot_int p_index);
const godot_real_t GDAPI *godot_vector2_operator_index_const(const godot_vector2 *p_self, godot_int p_index);
int32_t GDAPI *godot_vector2i_operator_index(godot_vector2i *p_self, godot_int p_index);
const int32_t GDAPI *godot_vector2i_operator_index_const(const godot_vector2i *p_self, godot_int p_index);
#ifdef __cplusplus
}
#endif
#endif // GODOT_VECTOR2_H

View File

@ -1,73 +0,0 @@
/*************************************************************************/
/* vector3.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_VECTOR3_H
#define GODOT_VECTOR3_H
#ifdef __cplusplus
extern "C" {
#endif
#include <gdnative/math_defs.h>
#define GODOT_VECTOR3_SIZE (sizeof(godot_real_t) * 3)
#ifndef GODOT_CORE_API_GODOT_VECTOR3_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_VECTOR3_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_VECTOR3_SIZE];
} godot_vector3;
#endif
#define GODOT_VECTOR3I_SIZE (sizeof(int32_t) * 3)
#ifndef GODOT_CORE_API_GODOT_VECTOR3I_TYPE_DEFINED
#define GODOT_CORE_API_GODOT_VECTOR3I_TYPE_DEFINED
typedef struct {
uint8_t _dont_touch_that[GODOT_VECTOR3I_SIZE];
} godot_vector3i;
#endif
#include <gdnative/gdnative.h>
void GDAPI godot_vector3_new(godot_vector3 *p_self);
void GDAPI godot_vector3_new_copy(godot_vector3 *r_dest, const godot_vector3 *p_src);
void GDAPI godot_vector3i_new(godot_vector3i *p_self);
void GDAPI godot_vector3i_new_copy(godot_vector3i *r_dest, const godot_vector3i *p_src);
godot_real_t GDAPI *godot_vector3_operator_index(godot_vector3 *p_self, godot_int p_index);
const godot_real_t GDAPI *godot_vector3_operator_index_const(const godot_vector3 *p_self, godot_int p_index);
int32_t GDAPI *godot_vector3i_operator_index(godot_vector3i *p_self, godot_int p_index);
const int32_t GDAPI *godot_vector3i_operator_index_const(const godot_vector3i *p_self, godot_int p_index);
#ifdef __cplusplus
}
#endif
#endif // GODOT_VECTOR3_H

View File

@ -1,233 +0,0 @@
/*************************************************************************/
/* godot_nativescript.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_NATIVESCRIPT_H
#define GODOT_NATIVESCRIPT_H
#include <gdnative/gdnative.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
GODOT_METHOD_RPC_MODE_DISABLED,
GODOT_METHOD_RPC_MODE_ANY_PEER,
GODOT_METHOD_RPC_MODE_AUTHORITY,
} godot_nativescript_method_rpc_mode;
typedef enum {
GODOT_PROPERTY_HINT_NONE, ///< no hint provided.
GODOT_PROPERTY_HINT_RANGE, ///< hint_text = "min,max,step,slider; //slider is optional"
GODOT_PROPERTY_HINT_EXP_RANGE, ///< hint_text = "min,max,step", exponential edit
GODOT_PROPERTY_HINT_ENUM, ///< hint_text= "val1,val2,val3,etc"
GODOT_PROPERTY_HINT_EXP_EASING, /// exponential easing function (Math::ease)
GODOT_PROPERTY_HINT_LENGTH, ///< hint_text= "length" (as integer)
GODOT_PROPERTY_HINT_KEY_ACCEL, ///< hint_text= "length" (as integer)
GODOT_PROPERTY_HINT_FLAGS, ///< hint_text= "flag1,flag2,etc" (as bit flags)
GODOT_PROPERTY_HINT_LAYERS_2D_RENDER,
GODOT_PROPERTY_HINT_LAYERS_2D_PHYSICS,
GODOT_PROPERTY_HINT_LAYERS_2D_NAVIGATION,
GODOT_PROPERTY_HINT_LAYERS_3D_RENDER,
GODOT_PROPERTY_HINT_LAYERS_3D_PHYSICS,
GODOT_PROPERTY_HINT_LAYERS_3D_NAVIGATION,
GODOT_PROPERTY_HINT_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,"
GODOT_PROPERTY_HINT_DIR, ///< a directory path must be passed
GODOT_PROPERTY_HINT_GLOBAL_FILE, ///< a file path must be passed, hint_text (optionally) is a filter "*.png,*.wav,*.doc,"
GODOT_PROPERTY_HINT_GLOBAL_DIR, ///< a directory path must be passed
GODOT_PROPERTY_HINT_RESOURCE_TYPE, ///< a resource object type
GODOT_PROPERTY_HINT_MULTILINE_TEXT, ///< used for string properties that can contain multiple lines
GODOT_PROPERTY_HINT_PLACEHOLDER_TEXT, ///< used to set a placeholder text for string properties
GODOT_PROPERTY_HINT_COLOR_NO_ALPHA, ///< used for ignoring alpha component when editing a color
GODOT_PROPERTY_HINT_IMAGE_COMPRESS_LOSSY,
GODOT_PROPERTY_HINT_IMAGE_COMPRESS_LOSSLESS,
GODOT_PROPERTY_HINT_OBJECT_ID,
GODOT_PROPERTY_HINT_TYPE_STRING, ///< a type string, the hint is the base type to choose
GODOT_PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE, ///< so something else can provide this (used in scripts)
GODOT_PROPERTY_HINT_METHOD_OF_VARIANT_TYPE, ///< a method of a type
GODOT_PROPERTY_HINT_METHOD_OF_BASE_TYPE, ///< a method of a base type
GODOT_PROPERTY_HINT_METHOD_OF_INSTANCE, ///< a method of an instance
GODOT_PROPERTY_HINT_METHOD_OF_SCRIPT, ///< a method of a script & base
GODOT_PROPERTY_HINT_PROPERTY_OF_VARIANT_TYPE, ///< a property of a type
GODOT_PROPERTY_HINT_PROPERTY_OF_BASE_TYPE, ///< a property of a base type
GODOT_PROPERTY_HINT_PROPERTY_OF_INSTANCE, ///< a property of an instance
GODOT_PROPERTY_HINT_PROPERTY_OF_SCRIPT, ///< a property of a script & base
GODOT_PROPERTY_HINT_LOCALE_ID,
GODOT_PROPERTY_HINT_MAX,
} godot_nativescript_property_hint;
typedef enum {
GODOT_PROPERTY_USAGE_STORAGE = 1,
GODOT_PROPERTY_USAGE_EDITOR = 2,
GODOT_PROPERTY_USAGE_NETWORK = 4,
GODOT_PROPERTY_USAGE_EDITOR_HELPER = 8,
GODOT_PROPERTY_USAGE_CHECKABLE = 16, //used for editing global variables
GODOT_PROPERTY_USAGE_CHECKED = 32, //used for editing global variables
GODOT_PROPERTY_USAGE_INTERNATIONALIZED = 64, //hint for internationalized strings
GODOT_PROPERTY_USAGE_GROUP = 128, //used for grouping props in the editor
GODOT_PROPERTY_USAGE_CATEGORY = 256,
GODOT_PROPERTY_USAGE_SUBGROUP = 512,
GODOT_PROPERTY_USAGE_NO_INSTANCE_STATE = 2048,
GODOT_PROPERTY_USAGE_RESTART_IF_CHANGED = 4096,
GODOT_PROPERTY_USAGE_SCRIPT_VARIABLE = 8192,
GODOT_PROPERTY_USAGE_STORE_IF_NULL = 16384,
GODOT_PROPERTY_USAGE_ANIMATE_AS_TRIGGER = 32768,
GODOT_PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED = 65536,
GODOT_PROPERTY_USAGE_DEFAULT = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_EDITOR | GODOT_PROPERTY_USAGE_NETWORK,
GODOT_PROPERTY_USAGE_DEFAULT_INTL = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_EDITOR | GODOT_PROPERTY_USAGE_NETWORK | GODOT_PROPERTY_USAGE_INTERNATIONALIZED,
GODOT_PROPERTY_USAGE_NO_EDITOR = GODOT_PROPERTY_USAGE_STORAGE | GODOT_PROPERTY_USAGE_NETWORK,
} godot_nativescript_property_usage_flags;
typedef struct {
godot_nativescript_method_rpc_mode rset_type;
godot_int type;
godot_nativescript_property_hint hint;
godot_string hint_string;
godot_nativescript_property_usage_flags usage;
godot_variant default_value;
} godot_nativescript_property_attributes;
typedef struct {
// instance pointer, method_data - return user data
GDCALLINGCONV void *(*create_func)(godot_object *, void *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
} godot_nativescript_instance_create_func;
typedef struct {
// instance pointer, method data, user data
GDCALLINGCONV void (*destroy_func)(godot_object *, void *, void *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
} godot_nativescript_instance_destroy_func;
void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_nativescript_instance_create_func p_create_func, godot_nativescript_instance_destroy_func p_destroy_func);
void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_nativescript_instance_create_func p_create_func, godot_nativescript_instance_destroy_func p_destroy_func);
typedef struct {
godot_nativescript_method_rpc_mode rpc_type;
} godot_nativescript_method_attributes;
typedef struct {
godot_string name;
godot_variant_type type;
godot_nativescript_property_hint hint;
godot_string hint_string;
} godot_nativescript_method_argument;
typedef struct {
// instance pointer, method data, user data, num args, args - return result as variant
GDCALLINGCONV godot_variant (*method)(godot_object *, void *, void *, int, godot_variant **);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
} godot_nativescript_instance_method;
void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_nativescript_method_attributes p_attr, godot_nativescript_instance_method p_method);
void GDAPI godot_nativescript_set_method_argument_information(void *p_gdnative_handle, const char *p_name, const char *p_function_name, int p_num_args, const godot_nativescript_method_argument *p_args);
typedef struct {
// instance pointer, method data, user data, value
GDCALLINGCONV void (*set_func)(godot_object *, void *, void *, godot_variant *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
} godot_nativescript_property_set_func;
typedef struct {
// instance pointer, method data, user data, value
GDCALLINGCONV godot_variant (*get_func)(godot_object *, void *, void *);
void *method_data;
GDCALLINGCONV void (*free_func)(void *);
} godot_nativescript_property_get_func;
void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_nativescript_property_attributes *p_attr, godot_nativescript_property_set_func p_set_func, godot_nativescript_property_get_func p_get_func);
typedef struct {
godot_string name;
godot_int type;
godot_nativescript_property_hint hint;
godot_string hint_string;
godot_nativescript_property_usage_flags usage;
godot_variant default_value;
} godot_nativescript_signal_argument;
typedef struct {
godot_string name;
int num_args;
godot_nativescript_signal_argument *args;
int num_default_args;
godot_variant *default_args;
} godot_nativescript_signal;
void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_nativescript_signal *p_signal);
void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance);
// documentation
void GDAPI godot_nativescript_set_class_documentation(void *p_gdnative_handle, const char *p_name, godot_string p_documentation);
void GDAPI godot_nativescript_set_method_documentation(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_string p_documentation);
void GDAPI godot_nativescript_set_property_documentation(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_string p_documentation);
void GDAPI godot_nativescript_set_signal_documentation(void *p_gdnative_handle, const char *p_name, const char *p_signal_name, godot_string p_documentation);
// type tag API
void GDAPI godot_nativescript_set_global_type_tag(int p_idx, const char *p_name, const void *p_type_tag);
const void GDAPI *godot_nativescript_get_global_type_tag(int p_idx, const char *p_name);
void GDAPI godot_nativescript_set_type_tag(void *p_gdnative_handle, const char *p_name, const void *p_type_tag);
const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object);
// instance binding API
typedef struct {
GDCALLINGCONV void *(*alloc_instance_binding_data)(void *, const void *, godot_object *);
GDCALLINGCONV void (*free_instance_binding_data)(void *, void *);
GDCALLINGCONV void (*refcount_incremented_instance_binding)(void *, godot_object *);
GDCALLINGCONV bool (*refcount_decremented_instance_binding)(void *, godot_object *);
void *data;
GDCALLINGCONV void (*free_func)(void *);
} godot_nativescript_instance_binding_functions;
int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_nativescript_instance_binding_functions p_binding_functions);
void GDAPI godot_nativescript_unregister_instance_binding_data_functions(int p_idx);
void GDAPI *godot_nativescript_get_instance_binding_data(int p_idx, godot_object *p_object);
void GDAPI godot_nativescript_profiling_add_data(const char *p_signature, uint64_t p_time);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -1,171 +0,0 @@
/*************************************************************************/
/* godot_pluginscript.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_PLUGINSCRIPT_H
#define GODOT_PLUGINSCRIPT_H
#include <gdnative/gdnative.h>
#include <nativescript/godot_nativescript.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef void godot_pluginscript_instance_data;
typedef void godot_pluginscript_script_data;
typedef void godot_pluginscript_language_data;
// --- Instance ---
typedef struct {
godot_pluginscript_instance_data *(*init)(godot_pluginscript_script_data *p_data, godot_object *p_owner);
void (*finish)(godot_pluginscript_instance_data *p_data);
godot_bool (*set_prop)(godot_pluginscript_instance_data *p_data, const godot_string_name *p_name, const godot_variant *p_value);
godot_bool (*get_prop)(godot_pluginscript_instance_data *p_data, const godot_string_name *p_name, godot_variant *r_ret);
godot_variant (*call_method)(godot_pluginscript_instance_data *p_data,
const godot_string_name *p_method, const godot_variant **p_args,
int p_argcount, godot_variant_call_error *r_error);
void (*notification)(godot_pluginscript_instance_data *p_data, int p_notification);
godot_string (*to_string)(godot_pluginscript_instance_data *p_data, godot_bool *r_valid);
//this is used by script languages that keep a reference counter of their own
//you can make make Ref<> not die when it reaches zero, so deleting the reference
//depends entirely from the script.
// Note: You can set those function pointer to nullptr if not needed.
void (*refcount_incremented)(godot_pluginscript_instance_data *p_data);
bool (*refcount_decremented)(godot_pluginscript_instance_data *p_data); // return true if it can die
} godot_pluginscript_instance_desc;
// --- Script ---
typedef struct {
godot_pluginscript_script_data *data;
godot_string_name name;
godot_bool is_tool;
godot_string_name base;
godot_string icon_path;
// Member lines format: {<string>: <int>}
godot_dictionary member_lines;
// Method info dictionary format
// {
// name: <string>
// args: [<dict:property>]
// default_args: [<variant>]
// return: <dict:property>
// flags: <int>
// rpc_mode: <int:godot_method_rpc_mode>
// }
godot_array methods;
// Same format than for methods
godot_array signals;
// Property info dictionary format
// {
// name: <string>
// type: <int:godot_variant_type>
// hint: <int:godot_property_hint>
// hint_string: <string>
// usage: <int:godot_property_usage_flags>
// default_value: <variant>
// rset_mode: <int:godot_method_rpc_mode>
// }
godot_array properties;
} godot_pluginscript_script_manifest;
typedef struct {
godot_pluginscript_script_manifest (*init)(godot_pluginscript_language_data *p_data, const godot_string *p_path, const godot_string *p_source, godot_error *r_error);
void (*finish)(godot_pluginscript_script_data *p_data);
godot_pluginscript_instance_desc instance_desc;
} godot_pluginscript_script_desc;
// --- Language ---
typedef struct {
godot_string_name signature;
godot_int call_count;
godot_int total_time; // In microseconds
godot_int self_time; // In microseconds
} godot_pluginscript_profiling_data;
typedef struct {
const char *name;
const char *type;
const char *extension;
const char **recognized_extensions; // nullptr terminated array
godot_pluginscript_language_data *(*init)();
void (*finish)(godot_pluginscript_language_data *p_data);
const char **reserved_words; // nullptr terminated array
const char **comment_delimiters; // nullptr terminated array
const char **string_delimiters; // nullptr terminated array
godot_bool has_named_classes;
godot_bool supports_builtin_mode;
godot_bool can_inherit_from_file;
godot_string (*get_template_source_code)(godot_pluginscript_language_data *p_data, const godot_string *p_class_name, const godot_string *p_base_class_name);
godot_bool (*validate)(godot_pluginscript_language_data *p_data, const godot_string *p_script, const godot_string *p_path, godot_packed_string_array *r_functions, godot_array *r_errors); // errors = Array of Dictionary with "line", "column", "message" keys
int (*find_function)(godot_pluginscript_language_data *p_data, const godot_string *p_function, const godot_string *p_code); // Can be nullptr
godot_string (*make_function)(godot_pluginscript_language_data *p_data, const godot_string *p_class, const godot_string *p_name, const godot_packed_string_array *p_args);
godot_error (*complete_code)(godot_pluginscript_language_data *p_data, const godot_string *p_code, const godot_string *p_path, godot_object *p_owner, godot_array *r_options, godot_bool *r_force, godot_string *r_call_hint);
void (*auto_indent_code)(godot_pluginscript_language_data *p_data, godot_string *p_code, int p_from_line, int p_to_line);
void (*add_global_constant)(godot_pluginscript_language_data *p_data, const godot_string_name *p_variable, const godot_variant *p_value);
godot_string (*debug_get_error)(godot_pluginscript_language_data *p_data);
int (*debug_get_stack_level_count)(godot_pluginscript_language_data *p_data);
int (*debug_get_stack_level_line)(godot_pluginscript_language_data *p_data, int p_level);
godot_string (*debug_get_stack_level_function)(godot_pluginscript_language_data *p_data, int p_level);
godot_string (*debug_get_stack_level_source)(godot_pluginscript_language_data *p_data, int p_level);
void (*debug_get_stack_level_locals)(godot_pluginscript_language_data *p_data, int p_level, godot_packed_string_array *p_locals, godot_array *p_values, int p_max_subitems, int p_max_depth);
void (*debug_get_stack_level_members)(godot_pluginscript_language_data *p_data, int p_level, godot_packed_string_array *p_members, godot_array *p_values, int p_max_subitems, int p_max_depth);
void (*debug_get_globals)(godot_pluginscript_language_data *p_data, godot_packed_string_array *p_locals, godot_array *p_values, int p_max_subitems, int p_max_depth);
godot_string (*debug_parse_stack_level_expression)(godot_pluginscript_language_data *p_data, int p_level, const godot_string *p_expression, int p_max_subitems, int p_max_depth);
// TODO: could this stuff be moved to the godot_pluginscript_language_desc ?
void (*get_public_functions)(godot_pluginscript_language_data *p_data, godot_array *r_functions);
void (*get_public_constants)(godot_pluginscript_language_data *p_data, godot_dictionary *r_constants);
void (*profiling_start)(godot_pluginscript_language_data *p_data);
void (*profiling_stop)(godot_pluginscript_language_data *p_data);
int (*profiling_get_accumulated_data)(godot_pluginscript_language_data *p_data, godot_pluginscript_profiling_data *r_info, int p_info_max);
int (*profiling_get_frame_data)(godot_pluginscript_language_data *p_data, godot_pluginscript_profiling_data *r_info, int p_info_max);
void (*profiling_frame)(godot_pluginscript_language_data *p_data);
godot_pluginscript_script_desc script_desc;
} godot_pluginscript_language_desc;
void GDAPI godot_pluginscript_register_language(const godot_pluginscript_language_desc *language_desc);
#ifdef __cplusplus
}
#endif
#endif // GODOT_PLUGINSCRIPT_H

View File

@ -1,75 +0,0 @@
/*************************************************************************/
/* godot_videodecoder.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GODOT_NATIVEVIDEODECODER_H
#define GODOT_NATIVEVIDEODECODER_H
#include <gdnative/gdnative.h>
#ifdef __cplusplus
extern "C" {
#endif
#define GODOTAV_API_MAJOR 0
#define GODOTAV_API_MINOR 1
typedef struct
{
godot_gdnative_api_version version;
void *next;
void *(*constructor)(godot_object *);
void (*destructor)(void *);
const char *(*get_plugin_name)();
const char **(*get_supported_extensions)(int *count);
godot_bool (*open_file)(void *, void *); // data struct, and a FileAccess pointer
godot_float (*get_length)(const void *);
godot_float (*get_playback_position)(const void *);
void (*seek)(void *, godot_float);
void (*set_audio_track)(void *, godot_int);
void (*update)(void *, godot_float);
godot_packed_byte_array *(*get_videoframe)(void *);
godot_int (*get_audioframe)(void *, float *, int);
godot_int (*get_channels)(const void *);
godot_int (*get_mix_rate)(const void *);
godot_vector2 (*get_texture_size)(const void *);
} godot_videodecoder_interface_gdnative;
typedef int (*GDNativeAudioMixCallback)(void *, const float *, int);
// FileAccess wrappers for custom FFmpeg IO
godot_int GDAPI godot_videodecoder_file_read(void *file_ptr, uint8_t *buf, int buf_size);
int64_t GDAPI godot_videodecoder_file_seek(void *file_ptr, int64_t pos, int whence);
void GDAPI godot_videodecoder_register_decoder(const godot_videodecoder_interface_gdnative *p_interface);
#ifdef __cplusplus
}
#endif
#endif /* GODOT_NATIVEVIDEODECODER_H */

View File

@ -1,9 +0,0 @@
#!/usr/bin/env python
Import("env")
Import("env_gdnative")
env_gdnative.add_source_files(env.modules_sources, "*.cpp")
if "platform" in env and env["platform"] in ["linuxbsd", "iphone"]:
env.Append(LINKFLAGS=["-rdynamic"])

View File

@ -1,948 +0,0 @@
/*************************************************************************/
/* api_generator.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "api_generator.h"
#ifdef TOOLS_ENABLED
#include "core/config/engine.h"
#include "core/core_constants.h"
#include "core/io/file_access.h"
#include "core/object/class_db.h"
#include "core/string/string_builder.h"
#include "core/templates/pair.h"
#include "core/variant/variant_parser.h"
// helper stuff
static Error save_file(const String &p_path, const List<String> &p_content) {
FileAccessRef file = FileAccess::open(p_path, FileAccess::WRITE);
ERR_FAIL_COND_V(!file, ERR_FILE_CANT_WRITE);
for (const List<String>::Element *e = p_content.front(); e != nullptr; e = e->next()) {
file->store_string(e->get());
}
file->close();
return OK;
}
// helper stuff end
struct MethodAPI {
String method_name;
String return_type;
List<String> argument_types;
List<String> argument_names;
Map<int, Variant> default_arguments;
int argument_count = 0;
bool has_varargs = false;
bool is_editor = false;
bool is_noscript = false;
bool is_const = false;
bool is_static = false; // For builtin types.
bool is_reverse = false;
bool is_virtual = false;
bool is_from_script = false;
};
struct PropertyAPI {
String name;
String getter;
String setter;
String type;
int index = 0;
};
struct ConstantAPI {
String constant_name;
int constant_value = 0;
Variant builtin_constant_value; // For builtin types;
String builtin_constant_type; // For builtin types;
};
struct SignalAPI {
String name;
List<String> argument_types;
List<String> argument_names;
Map<int, Variant> default_arguments;
};
struct EnumAPI {
String name;
List<Pair<int, String>> values;
};
struct OperatorAPI { // For builtin types;
String name;
int oper = Variant::OP_MAX;
String other_type;
String return_type;
};
struct ClassAPI {
String class_name;
String super_class_name;
ClassDB::APIType api_type = ClassDB::API_NONE;
bool is_singleton = false;
String singleton_name;
bool is_instantiable = false;
// @Unclear
bool is_ref_counted = false;
bool has_indexing = false; // For builtin types.
String indexed_type; // For builtin types.
bool is_keyed = false; // For builtin types.
List<MethodAPI> methods;
List<MethodAPI> constructors; // For builtin types.
List<PropertyAPI> properties;
List<ConstantAPI> constants;
List<SignalAPI> signals_;
List<EnumAPI> enums;
List<OperatorAPI> operators; // For builtin types.
};
static String get_type_name(const PropertyInfo &info) {
if (info.type == Variant::INT && (info.usage & PROPERTY_USAGE_CLASS_IS_ENUM)) {
return String("enum.") + String(info.class_name).replace(".", "::");
}
if (info.class_name != StringName()) {
return info.class_name;
}
if (info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
return info.class_name;
}
if (info.type == Variant::NIL && (info.usage & PROPERTY_USAGE_NIL_IS_VARIANT)) {
return "Variant";
}
if (info.type == Variant::NIL) {
return "void";
}
return Variant::get_type_name(info.type);
}
/*
* Some comparison helper functions we need
*/
struct MethodInfoComparator {
StringName::AlphCompare compare;
bool operator()(const MethodInfo &p_a, const MethodInfo &p_b) const {
return compare(p_a.name, p_b.name);
}
};
struct PropertyInfoComparator {
StringName::AlphCompare compare;
bool operator()(const PropertyInfo &p_a, const PropertyInfo &p_b) const {
return compare(p_a.name, p_b.name);
}
};
struct ConstantAPIComparator {
NoCaseComparator compare;
bool operator()(const ConstantAPI &p_a, const ConstantAPI &p_b) const {
return compare(p_a.constant_name, p_b.constant_name);
}
};
/*
* Reads the entire Godot API to a list
*/
List<ClassAPI> generate_c_api_classes() {
List<ClassAPI> api;
List<StringName> classes;
ClassDB::get_class_list(&classes);
classes.sort_custom<StringName::AlphCompare>();
// Register global constants as a fake CoreConstants singleton class
{
ClassAPI global_constants_api;
global_constants_api.class_name = "CoreConstants";
global_constants_api.api_type = ClassDB::API_CORE;
global_constants_api.is_singleton = true;
global_constants_api.singleton_name = "CoreConstants";
global_constants_api.is_instantiable = false;
const int constants_count = CoreConstants::get_global_constant_count();
Map<StringName, EnumAPI> enum_api_map;
for (int i = 0; i < constants_count; ++i) {
StringName enum_name = CoreConstants::get_global_constant_enum(i);
String name = String(CoreConstants::get_global_constant_name(i));
int value = CoreConstants::get_global_constant_value(i);
if (enum_name == StringName()) {
ConstantAPI constant_api;
constant_api.constant_name = name;
constant_api.constant_value = value;
global_constants_api.constants.push_back(constant_api);
} else {
EnumAPI enum_api;
if (enum_api_map.has(enum_name)) {
enum_api = enum_api_map[enum_name];
} else {
enum_api.name = String(enum_name);
}
enum_api.values.push_back(Pair(value, name));
enum_api_map[enum_name] = enum_api;
}
}
for (const KeyValue<StringName, EnumAPI> &E : enum_api_map) {
global_constants_api.enums.push_back(E.value);
}
global_constants_api.constants.sort_custom<ConstantAPIComparator>();
api.push_back(global_constants_api);
}
for (List<StringName>::Element *e = classes.front(); e != nullptr; e = e->next()) {
StringName class_name = e->get();
if (!ClassDB::is_class_exposed(class_name)) {
continue;
}
ClassAPI class_api;
class_api.api_type = ClassDB::get_api_type(e->get());
class_api.class_name = class_name;
class_api.super_class_name = ClassDB::get_parent_class(class_name);
{
class_api.is_singleton = Engine::get_singleton()->has_singleton(class_name);
if (class_api.is_singleton) {
class_api.singleton_name = class_name;
}
}
class_api.is_instantiable = !class_api.is_singleton && ClassDB::can_instantiate(class_name);
{
List<StringName> inheriters;
ClassDB::get_inheriters_from_class("RefCounted", &inheriters);
bool is_ref_counted = !!inheriters.find(class_name) || class_name == "RefCounted";
// @Unclear
class_api.is_ref_counted = !class_api.is_singleton && is_ref_counted;
}
// constants
{
List<String> constant;
ClassDB::get_integer_constant_list(class_name, &constant, true);
constant.sort_custom<NoCaseComparator>();
for (List<String>::Element *c = constant.front(); c != nullptr; c = c->next()) {
ConstantAPI constant_api;
constant_api.constant_name = c->get();
constant_api.constant_value = ClassDB::get_integer_constant(class_name, c->get());
class_api.constants.push_back(constant_api);
}
}
// signals
{
List<MethodInfo> signals_;
ClassDB::get_signal_list(class_name, &signals_, true);
signals_.sort_custom<MethodInfoComparator>();
for (int i = 0; i < signals_.size(); i++) {
SignalAPI signal;
MethodInfo method_info = signals_[i];
signal.name = method_info.name;
for (int j = 0; j < method_info.arguments.size(); j++) {
PropertyInfo argument = method_info.arguments[j];
String type;
String name = argument.name;
if (argument.name.contains(":")) {
type = argument.name.get_slice(":", 1);
name = argument.name.get_slice(":", 0);
} else {
type = get_type_name(argument);
}
signal.argument_names.push_back(name);
signal.argument_types.push_back(type);
}
Vector<Variant> default_arguments = method_info.default_arguments;
int default_start = signal.argument_names.size() - default_arguments.size();
for (int j = 0; j < default_arguments.size(); j++) {
signal.default_arguments[default_start + j] = default_arguments[j];
}
class_api.signals_.push_back(signal);
}
}
//properties
{
List<PropertyInfo> properties;
ClassDB::get_property_list(class_name, &properties, true);
properties.sort_custom<PropertyInfoComparator>();
for (List<PropertyInfo>::Element *p = properties.front(); p != nullptr; p = p->next()) {
PropertyAPI property_api;
property_api.name = p->get().name;
property_api.getter = ClassDB::get_property_getter(class_name, p->get().name);
property_api.setter = ClassDB::get_property_setter(class_name, p->get().name);
if (p->get().name.contains(":")) {
property_api.type = p->get().name.get_slice(":", 1);
property_api.name = p->get().name.get_slice(":", 0);
} else {
MethodInfo minfo;
ClassDB::get_method_info(class_name, property_api.getter, &minfo, true, false);
property_api.type = get_type_name(minfo.return_val);
}
property_api.index = ClassDB::get_property_index(class_name, p->get().name);
if (!property_api.setter.is_empty() || !property_api.getter.is_empty()) {
class_api.properties.push_back(property_api);
}
}
}
//methods
{
List<MethodInfo> methods;
ClassDB::get_method_list(class_name, &methods, true);
methods.sort_custom<MethodInfoComparator>();
for (List<MethodInfo>::Element *m = methods.front(); m != nullptr; m = m->next()) {
MethodAPI method_api;
MethodBind *method_bind = ClassDB::get_method(class_name, m->get().name);
MethodInfo &method_info = m->get();
//method name
method_api.method_name = method_info.name;
//method return type
if (method_api.method_name.contains(":")) {
method_api.return_type = method_api.method_name.get_slice(":", 1);
method_api.method_name = method_api.method_name.get_slice(":", 0);
} else {
method_api.return_type = get_type_name(m->get().return_val);
}
method_api.argument_count = method_info.arguments.size();
method_api.has_varargs = method_bind && method_bind->is_vararg();
// Method flags
method_api.is_virtual = false;
if (method_info.flags) {
const uint32_t flags = method_info.flags;
method_api.is_editor = flags & METHOD_FLAG_EDITOR;
method_api.is_noscript = flags & METHOD_FLAG_NOSCRIPT;
method_api.is_const = flags & METHOD_FLAG_CONST;
method_api.is_reverse = flags & METHOD_FLAG_REVERSE;
method_api.is_virtual = flags & METHOD_FLAG_VIRTUAL;
method_api.is_from_script = flags & METHOD_FLAG_FROM_SCRIPT;
}
method_api.is_virtual = method_api.is_virtual || method_api.method_name[0] == '_';
// method argument name and type
for (int i = 0; i < method_api.argument_count; i++) {
String arg_name;
String arg_type;
PropertyInfo arg_info = method_info.arguments[i];
arg_name = arg_info.name;
if (arg_info.name.contains(":")) {
arg_type = arg_info.name.get_slice(":", 1);
arg_name = arg_info.name.get_slice(":", 0);
} else if (arg_info.hint == PROPERTY_HINT_RESOURCE_TYPE) {
arg_type = arg_info.class_name;
} else if (arg_info.type == Variant::NIL) {
arg_type = "Variant";
} else if (arg_info.type == Variant::OBJECT) {
arg_type = arg_info.class_name;
if (arg_type.is_empty()) {
arg_type = Variant::get_type_name(arg_info.type);
}
} else {
arg_type = get_type_name(arg_info);
}
method_api.argument_names.push_back(arg_name);
method_api.argument_types.push_back(arg_type);
if (method_bind && method_bind->has_default_argument(i)) {
method_api.default_arguments[i] = method_bind->get_default_argument(i);
}
}
class_api.methods.push_back(method_api);
}
}
// enums
{
List<EnumAPI> enums;
List<StringName> enum_names;
ClassDB::get_enum_list(class_name, &enum_names, true);
for (const StringName &E : enum_names) {
List<StringName> value_names;
EnumAPI enum_api;
enum_api.name = E;
ClassDB::get_enum_constants(class_name, E, &value_names, true);
for (List<StringName>::Element *val_e = value_names.front(); val_e; val_e = val_e->next()) {
int int_val = ClassDB::get_integer_constant(class_name, val_e->get(), nullptr);
enum_api.values.push_back(Pair<int, String>(int_val, val_e->get()));
}
enum_api.values.sort_custom<PairSort<int, String>>();
class_api.enums.push_back(enum_api);
}
}
api.push_back(class_api);
}
return api;
}
/*
* Reads the builtin Variant API to a list
*/
List<ClassAPI> generate_c_builtin_api_types() {
List<ClassAPI> api;
// Special class for the utility methods.
{
ClassAPI utility_api;
utility_api.class_name = "Utilities";
utility_api.is_instantiable = false;
List<StringName> utility_functions;
Variant::get_utility_function_list(&utility_functions);
for (const StringName &E : utility_functions) {
const StringName &function_name = E;
MethodAPI function_api;
function_api.method_name = function_name;
function_api.has_varargs = Variant::is_utility_function_vararg(function_name);
function_api.argument_count = function_api.has_varargs ? 0 : Variant::get_utility_function_argument_count(function_name);
function_api.is_const = Variant::get_utility_function_type(function_name) == Variant::UTILITY_FUNC_TYPE_MATH;
for (int i = 0; i < function_api.argument_count; i++) {
function_api.argument_names.push_back(Variant::get_utility_function_argument_name(function_name, i));
Variant::Type arg_type = Variant::get_utility_function_argument_type(function_name, i);
function_api.argument_types.push_back(arg_type == Variant::NIL ? "Variant" : Variant::get_type_name(arg_type));
}
if (Variant::has_utility_function_return_value(function_name)) {
Variant::Type ret_type = Variant::get_utility_function_return_type(function_name);
function_api.return_type = ret_type == Variant::NIL ? "Variant" : Variant::get_type_name(ret_type);
} else {
function_api.return_type = "void";
}
utility_api.methods.push_back(function_api);
}
api.push_back(utility_api);
}
for (int t = 0; t < Variant::VARIANT_MAX; t++) {
Variant::Type type = (Variant::Type)t;
ClassAPI class_api;
class_api.class_name = Variant::get_type_name(type);
class_api.is_instantiable = true;
class_api.has_indexing = Variant::has_indexing(type);
class_api.indexed_type = Variant::get_type_name(Variant::get_indexed_element_type(type));
class_api.is_keyed = Variant::is_keyed(type);
// Types that are passed by reference.
switch (type) {
case Variant::OBJECT:
case Variant::DICTIONARY:
case Variant::ARRAY:
case Variant::PACKED_BYTE_ARRAY:
case Variant::PACKED_INT32_ARRAY:
case Variant::PACKED_INT64_ARRAY:
case Variant::PACKED_FLOAT32_ARRAY:
case Variant::PACKED_FLOAT64_ARRAY:
case Variant::PACKED_STRING_ARRAY:
case Variant::PACKED_VECTOR2_ARRAY:
case Variant::PACKED_VECTOR3_ARRAY:
case Variant::PACKED_COLOR_ARRAY:
class_api.is_ref_counted = true;
break;
default:
class_api.is_ref_counted = false;
break;
}
// Methods.
List<StringName> methods;
Variant::get_builtin_method_list(type, &methods);
for (const StringName &E : methods) {
const StringName &method_name = E;
MethodAPI method_api;
method_api.method_name = method_name;
method_api.argument_count = Variant::get_builtin_method_argument_count(type, method_name);
method_api.has_varargs = Variant::is_builtin_method_vararg(type, method_name);
method_api.is_const = Variant::is_builtin_method_const(type, method_name);
method_api.is_static = Variant::is_builtin_method_static(type, method_name);
for (int i = 0; i < method_api.argument_count; i++) {
method_api.argument_names.push_back(Variant::get_builtin_method_argument_name(type, method_name, i));
Variant::Type arg_type = Variant::get_builtin_method_argument_type(type, method_name, i);
method_api.argument_types.push_back(arg_type == Variant::NIL ? "Variant" : Variant::get_type_name(arg_type));
}
Vector<Variant> default_arguments = Variant::get_builtin_method_default_arguments(type, method_name);
int default_start = method_api.argument_names.size() - default_arguments.size();
for (int i = 0; i < default_arguments.size(); i++) {
method_api.default_arguments[default_start + i] = default_arguments[i];
}
if (Variant::has_builtin_method_return_value(type, method_name)) {
Variant::Type ret_type = Variant::get_builtin_method_return_type(type, method_name);
method_api.return_type = ret_type == Variant::NIL ? "Variant" : Variant::get_type_name(ret_type);
} else {
method_api.return_type = "void";
}
class_api.methods.push_back(method_api);
}
// Constructors.
for (int c = 0; c < Variant::get_constructor_count(type); c++) {
MethodAPI constructor_api;
constructor_api.method_name = Variant::get_type_name(type);
constructor_api.argument_count = Variant::get_constructor_argument_count(type, c);
constructor_api.return_type = Variant::get_type_name(type);
for (int i = 0; i < constructor_api.argument_count; i++) {
constructor_api.argument_names.push_back(Variant::get_constructor_argument_name(type, c, i));
Variant::Type arg_type = Variant::get_constructor_argument_type(type, c, i);
constructor_api.argument_types.push_back(arg_type == Variant::NIL ? "Variant" : Variant::get_type_name(arg_type));
}
class_api.constructors.push_back(constructor_api);
}
// Constants.
List<StringName> constants;
Variant::get_constants_for_type(type, &constants);
for (const StringName &E : constants) {
const StringName &constant_name = E;
ConstantAPI constant_api;
constant_api.constant_name = constant_name;
constant_api.builtin_constant_value = Variant::get_constant_value(type, constant_name);
constant_api.builtin_constant_type = Variant::get_type_name(constant_api.builtin_constant_value.get_type());
class_api.constants.push_back(constant_api);
}
// Members.
List<StringName> members;
Variant::get_member_list(type, &members);
for (const StringName &E : members) {
const StringName &member_name = E;
PropertyAPI member_api;
member_api.name = member_name;
Variant::Type member_type = Variant::get_member_type(type, member_name);
member_api.type = member_type == Variant::NIL ? "Variant" : Variant::get_type_name(member_type);
class_api.properties.push_back(member_api);
}
// Operators.
for (int op = 0; op < Variant::OP_MAX; op++) {
Variant::Operator oper = (Variant::Operator)op;
for (int ot = 0; ot < Variant::VARIANT_MAX; ot++) {
Variant::Type other_type = (Variant::Type)ot;
if (!Variant::get_validated_operator_evaluator(oper, type, other_type)) {
continue;
}
OperatorAPI oper_api;
oper_api.name = Variant::get_operator_name(oper);
oper_api.oper = oper;
oper_api.other_type = Variant::get_type_name(other_type);
oper_api.return_type = Variant::get_type_name(Variant::get_operator_return_type(oper, type, other_type));
class_api.operators.push_back(oper_api);
}
}
api.push_back(class_api);
}
return api;
}
/*
* Generates the JSON source from the API in p_api
*/
static List<String> generate_c_api_json(const List<ClassAPI> &p_api) {
// I'm sorry for the \t mess
List<String> source;
VariantWriter writer;
source.push_back("[\n");
for (const List<ClassAPI>::Element *c = p_api.front(); c != nullptr; c = c->next()) {
ClassAPI api = c->get();
source.push_back("\t{\n");
source.push_back("\t\t\"name\": \"" + api.class_name + "\",\n");
source.push_back("\t\t\"base_class\": \"" + api.super_class_name + "\",\n");
source.push_back(String("\t\t\"api_type\": \"") + (api.api_type == ClassDB::API_CORE ? "core" : (api.api_type == ClassDB::API_EDITOR ? "tools" : "none")) + "\",\n");
source.push_back(String("\t\t\"singleton\": ") + (api.is_singleton ? "true" : "false") + ",\n");
source.push_back("\t\t\"singleton_name\": \"" + api.singleton_name + "\",\n");
source.push_back(String("\t\t\"instantiable\": ") + (api.is_instantiable ? "true" : "false") + ",\n");
source.push_back(String("\t\t\"is_ref_counted\": ") + (api.is_ref_counted ? "true" : "false") + ",\n");
source.push_back("\t\t\"constants\": {\n");
for (List<ConstantAPI>::Element *e = api.constants.front(); e; e = e->next()) {
source.push_back("\t\t\t\"" + e->get().constant_name + "\": " + String::num_int64(e->get().constant_value) + (e->next() ? "," : "") + "\n");
}
source.push_back("\t\t},\n");
source.push_back("\t\t\"properties\": [\n");
for (List<PropertyAPI>::Element *e = api.properties.front(); e; e = e->next()) {
source.push_back("\t\t\t{\n");
source.push_back("\t\t\t\t\"name\": \"" + e->get().name + "\",\n");
source.push_back("\t\t\t\t\"type\": \"" + e->get().type + "\",\n");
source.push_back("\t\t\t\t\"getter\": \"" + e->get().getter + "\",\n");
source.push_back("\t\t\t\t\"setter\": \"" + e->get().setter + "\",\n");
source.push_back(String("\t\t\t\t\"index\": ") + itos(e->get().index) + "\n");
source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n");
}
source.push_back("\t\t],\n");
source.push_back("\t\t\"signals\": [\n");
for (List<SignalAPI>::Element *e = api.signals_.front(); e; e = e->next()) {
source.push_back("\t\t\t{\n");
source.push_back("\t\t\t\t\"name\": \"" + e->get().name + "\",\n");
source.push_back("\t\t\t\t\"arguments\": [\n");
for (int i = 0; i < e->get().argument_names.size(); i++) {
source.push_back("\t\t\t\t\t{\n");
source.push_back("\t\t\t\t\t\t\"name\": \"" + e->get().argument_names[i] + "\",\n");
source.push_back("\t\t\t\t\t\t\"type\": \"" + e->get().argument_types[i] + "\",\n");
source.push_back(String("\t\t\t\t\t\t\"has_default_value\": ") + (e->get().default_arguments.has(i) ? "true" : "false") + ",\n");
String default_value;
if (e->get().default_arguments.has(i)) {
writer.write_to_string(e->get().default_arguments[i], default_value);
default_value = default_value.replace("\n", "").json_escape();
}
source.push_back("\t\t\t\t\t\t\"default_value\": \"" + default_value + "\"\n");
source.push_back(String("\t\t\t\t\t}") + ((i < e->get().argument_names.size() - 1) ? "," : "") + "\n");
}
source.push_back("\t\t\t\t]\n");
source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n");
}
source.push_back("\t\t],\n");
source.push_back("\t\t\"methods\": [\n");
for (List<MethodAPI>::Element *e = api.methods.front(); e; e = e->next()) {
source.push_back("\t\t\t{\n");
source.push_back("\t\t\t\t\"name\": \"" + e->get().method_name + "\",\n");
source.push_back("\t\t\t\t\"return_type\": \"" + e->get().return_type + "\",\n");
source.push_back(String("\t\t\t\t\"is_editor\": ") + (e->get().is_editor ? "true" : "false") + ",\n");
source.push_back(String("\t\t\t\t\"is_noscript\": ") + (e->get().is_noscript ? "true" : "false") + ",\n");
source.push_back(String("\t\t\t\t\"is_const\": ") + (e->get().is_const ? "true" : "false") + ",\n");
source.push_back(String("\t\t\t\t\"is_reverse\": ") + (e->get().is_reverse ? "true" : "false") + ",\n");
source.push_back(String("\t\t\t\t\"is_virtual\": ") + (e->get().is_virtual ? "true" : "false") + ",\n");
source.push_back(String("\t\t\t\t\"has_varargs\": ") + (e->get().has_varargs ? "true" : "false") + ",\n");
source.push_back(String("\t\t\t\t\"is_from_script\": ") + (e->get().is_from_script ? "true" : "false") + ",\n");
source.push_back("\t\t\t\t\"arguments\": [\n");
for (int i = 0; i < e->get().argument_names.size(); i++) {
source.push_back("\t\t\t\t\t{\n");
source.push_back("\t\t\t\t\t\t\"name\": \"" + e->get().argument_names[i] + "\",\n");
source.push_back("\t\t\t\t\t\t\"type\": \"" + e->get().argument_types[i] + "\",\n");
source.push_back(String("\t\t\t\t\t\t\"has_default_value\": ") + (e->get().default_arguments.has(i) ? "true" : "false") + ",\n");
String default_value;
if (e->get().default_arguments.has(i)) {
writer.write_to_string(e->get().default_arguments[i], default_value);
default_value = default_value.replace("\n", "").json_escape();
}
source.push_back("\t\t\t\t\t\t\"default_value\": \"" + default_value + "\"\n");
source.push_back(String("\t\t\t\t\t}") + ((i < e->get().argument_names.size() - 1) ? "," : "") + "\n");
}
source.push_back("\t\t\t\t]\n");
source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n");
}
source.push_back("\t\t],\n");
source.push_back("\t\t\"enums\": [\n");
for (List<EnumAPI>::Element *e = api.enums.front(); e; e = e->next()) {
source.push_back("\t\t\t{\n");
source.push_back("\t\t\t\t\"name\": \"" + e->get().name + "\",\n");
source.push_back("\t\t\t\t\"values\": {\n");
for (List<Pair<int, String>>::Element *val_e = e->get().values.front(); val_e; val_e = val_e->next()) {
source.push_back("\t\t\t\t\t\"" + val_e->get().second + "\": " + itos(val_e->get().first));
source.push_back(String((val_e->next() ? "," : "")) + "\n");
}
source.push_back("\t\t\t\t}\n");
source.push_back(String("\t\t\t}") + (e->next() ? "," : "") + "\n");
}
source.push_back("\t\t]\n");
source.push_back(String("\t}") + (c->next() ? "," : "") + "\n");
}
source.push_back("]");
return source;
}
static int indent_level = 0;
static void append_indented(StringBuilder &p_source, const String &p_text) {
for (int i = 0; i < indent_level; i++) {
p_source.append("\t");
}
p_source.append(p_text);
p_source.append("\n");
}
static void append_indented(StringBuilder &p_source, const char *p_text) {
for (int i = 0; i < indent_level; i++) {
p_source.append("\t");
}
p_source.append(p_text);
p_source.append("\n");
}
static void write_builtin_method(StringBuilder &p_source, const MethodAPI &p_method) {
VariantWriter writer;
append_indented(p_source, vformat(R"("name": "%s",)", p_method.method_name));
append_indented(p_source, vformat(R"("return_type": "%s",)", p_method.return_type));
append_indented(p_source, vformat(R"("is_const": %s,)", p_method.is_const ? "true" : "false"));
append_indented(p_source, vformat(R"("is_static": %s,)", p_method.is_static ? "true" : "false"));
append_indented(p_source, vformat(R"("has_varargs": %s,)", p_method.has_varargs ? "true" : "false"));
append_indented(p_source, R"("arguments": [)");
indent_level++;
for (int i = 0; i < p_method.argument_count; i++) {
append_indented(p_source, "{");
indent_level++;
append_indented(p_source, vformat(R"("name": "%s",)", p_method.argument_names[i]));
append_indented(p_source, vformat(R"("type": "%s",)", p_method.argument_types[i]));
append_indented(p_source, vformat(R"("has_default_value": %s,)", p_method.default_arguments.has(i) ? "true" : "false"));
String default_value;
if (p_method.default_arguments.has(i)) {
writer.write_to_string(p_method.default_arguments[i], default_value);
default_value = default_value.replace("\n", "").json_escape();
}
append_indented(p_source, vformat(R"("default_value": "%s")", default_value));
indent_level--;
append_indented(p_source, i < p_method.argument_count - 1 ? "}," : "}");
}
indent_level--;
append_indented(p_source, "]");
}
static List<String> generate_c_builtin_api_json(const List<ClassAPI> &p_api) {
StringBuilder source;
source.append("[\n");
indent_level = 1;
for (const List<ClassAPI>::Element *C = p_api.front(); C; C = C->next()) {
const ClassAPI &class_api = C->get();
append_indented(source, "{");
indent_level++;
append_indented(source, vformat(R"("name": "%s",)", class_api.class_name));
append_indented(source, vformat(R"("is_instantiable": %s,)", class_api.is_instantiable ? "true" : "false"));
append_indented(source, vformat(R"("is_ref_counted": %s,)", class_api.is_ref_counted ? "true" : "false"));
append_indented(source, vformat(R"("has_indexing": %s,)", class_api.has_indexing ? "true" : "false"));
append_indented(source, vformat(R"("indexed_type": "%s",)", class_api.has_indexing && class_api.indexed_type == "Nil" ? "Variant" : class_api.indexed_type));
append_indented(source, vformat(R"("is_keyed": %s,)", class_api.is_keyed ? "true" : "false"));
// Constructors.
append_indented(source, R"("constructors": [)");
indent_level++;
for (const List<MethodAPI>::Element *E = class_api.constructors.front(); E; E = E->next()) {
const MethodAPI &constructor = E->get();
append_indented(source, "{");
indent_level++;
write_builtin_method(source, constructor);
indent_level--;
append_indented(source, E->next() ? "}," : "}");
}
indent_level--;
append_indented(source, "],");
// Constants.
append_indented(source, R"("constants": [)");
indent_level++;
for (const List<ConstantAPI>::Element *E = class_api.constants.front(); E; E = E->next()) {
const ConstantAPI &constant = E->get();
append_indented(source, "{");
indent_level++;
append_indented(source, vformat(R"("name": "%s",)", constant.constant_name));
append_indented(source, vformat(R"("type": "%s",)", constant.builtin_constant_type));
append_indented(source, vformat(R"("value": "%s")", constant.builtin_constant_value.operator String()));
indent_level--;
append_indented(source, E->next() ? "}," : "}");
}
indent_level--;
append_indented(source, "],");
// Methods.
append_indented(source, R"("methods": [)");
indent_level++;
for (const List<MethodAPI>::Element *E = class_api.methods.front(); E; E = E->next()) {
const MethodAPI &method = E->get();
append_indented(source, "{");
indent_level++;
write_builtin_method(source, method);
indent_level--;
append_indented(source, E->next() ? "}," : "}");
}
indent_level--;
append_indented(source, "],");
// Members.
append_indented(source, R"("members": [)");
indent_level++;
for (const List<PropertyAPI>::Element *E = class_api.properties.front(); E; E = E->next()) {
const PropertyAPI &member = E->get();
append_indented(source, "{");
indent_level++;
append_indented(source, vformat(R"("name": "%s",)", member.name));
append_indented(source, vformat(R"("type": "%s")", member.type));
indent_level--;
append_indented(source, E->next() ? "}," : "}");
}
indent_level--;
append_indented(source, "],");
// Operators.
append_indented(source, R"("operators": [)");
indent_level++;
for (const List<OperatorAPI>::Element *E = class_api.operators.front(); E; E = E->next()) {
const OperatorAPI &oper = E->get();
append_indented(source, "{");
indent_level++;
append_indented(source, vformat(R"("name": "%s",)", oper.name));
append_indented(source, vformat(R"("operator": %d,)", oper.oper));
append_indented(source, vformat(R"("other_type": "%s",)", oper.other_type));
append_indented(source, vformat(R"("return_type": "%s")", oper.return_type));
indent_level--;
append_indented(source, E->next() ? "}," : "}");
}
indent_level--;
append_indented(source, "]");
indent_level--;
append_indented(source, C->next() ? "}," : "}");
}
indent_level--;
source.append("]\n");
List<String> result;
result.push_back(source.as_string());
return result;
}
#endif
/*
* Saves the whole Godot API to a JSON file located at
* p_path
*/
Error generate_c_api(const String &p_path) {
#ifndef TOOLS_ENABLED
return ERR_BUG;
#else
List<ClassAPI> api = generate_c_api_classes();
List<String> json_source = generate_c_api_json(api);
return save_file(p_path, json_source);
#endif
}
/*
* Saves the builtin Godot API to a JSON file located at
* p_path
*/
Error generate_c_builtin_api(const String &p_path) {
#ifndef TOOLS_ENABLED
return ERR_BUG;
#else
List<ClassAPI> api = generate_c_builtin_api_types();
List<String> json_source = generate_c_builtin_api_json(api);
return save_file(p_path, json_source);
#endif
}

View File

@ -1,40 +0,0 @@
/*************************************************************************/
/* api_generator.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef API_GENERATOR_H
#define API_GENERATOR_H
#include "core/string/ustring.h"
#include "core/typedefs.h"
Error generate_c_api(const String &p_path);
Error generate_c_builtin_api(const String &p_path);
#endif // API_GENERATOR_H

View File

@ -1,344 +0,0 @@
/*************************************************************************/
/* godot_nativescript.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "nativescript/godot_nativescript.h"
#include "core/config/project_settings.h"
#include "core/core_constants.h"
#include "core/error/error_macros.h"
#include "core/object/class_db.h"
#include "core/variant/variant.h"
#include "gdnative/gdnative.h"
#include <stdint.h>
#include "nativescript.h"
#ifdef __cplusplus
extern "C" {
#endif
extern "C" void _native_script_hook() {
}
#define NSL NativeScriptLanguage::get_singleton()
// Script API
void GDAPI godot_nativescript_register_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_nativescript_instance_create_func p_create_func, godot_nativescript_instance_destroy_func p_destroy_func) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc> *classes = &NSL->library_classes[*s];
NativeScriptDesc desc;
desc.create_func = p_create_func;
desc.destroy_func = p_destroy_func;
desc.is_tool = false;
desc.base = p_base;
if (classes->has(p_base)) {
desc.base_data = &(*classes)[p_base];
desc.base_native_type = desc.base_data->base_native_type;
const NativeScriptDesc *b = desc.base_data;
while (b) {
desc.rpc_methods.append_array(b->rpc_methods);
b = b->base_data;
}
} else {
desc.base_data = nullptr;
desc.base_native_type = p_base;
}
classes->insert(p_name, desc);
}
void GDAPI godot_nativescript_register_tool_class(void *p_gdnative_handle, const char *p_name, const char *p_base, godot_nativescript_instance_create_func p_create_func, godot_nativescript_instance_destroy_func p_destroy_func) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc> *classes = &NSL->library_classes[*s];
NativeScriptDesc desc;
desc.create_func = p_create_func;
desc.destroy_func = p_destroy_func;
desc.is_tool = true;
desc.base = p_base;
if (classes->has(p_base)) {
desc.base_data = &(*classes)[p_base];
desc.base_native_type = desc.base_data->base_native_type;
const NativeScriptDesc *b = desc.base_data;
while (b) {
desc.rpc_methods.append_array(b->rpc_methods);
b = b->base_data;
}
} else {
desc.base_data = nullptr;
desc.base_native_type = p_base;
}
classes->insert(p_name, desc);
}
void GDAPI godot_nativescript_register_method(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_nativescript_method_attributes p_attr, godot_nativescript_instance_method p_method) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class.");
NativeScriptDesc::Method method;
method.method = p_method;
method.rpc_mode = p_attr.rpc_type;
method.rpc_method_id = UINT16_MAX;
method.info = MethodInfo(p_function_name);
E->get().methods.insert(p_function_name, method);
if (p_attr.rpc_type != GODOT_METHOD_RPC_MODE_DISABLED) {
Multiplayer::RPCConfig nd;
nd.name = String(p_name);
nd.rpc_mode = Multiplayer::RPCMode(p_attr.rpc_type);
E->get().rpc_methods.push_back(nd);
}
}
void GDAPI godot_nativescript_register_property(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_nativescript_property_attributes *p_attr, godot_nativescript_property_set_func p_set_func, godot_nativescript_property_get_func p_get_func) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class.");
NativeScriptDesc::Property property;
property.default_value = *(Variant *)&p_attr->default_value;
property.getter = p_get_func;
property.setter = p_set_func;
property.info = PropertyInfo((Variant::Type)p_attr->type,
p_path,
(PropertyHint)p_attr->hint,
*(String *)&p_attr->hint_string,
(PropertyUsageFlags)p_attr->usage);
E->get().properties.insert(p_path, property);
}
void GDAPI godot_nativescript_register_signal(void *p_gdnative_handle, const char *p_name, const godot_nativescript_signal *p_signal) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
ERR_FAIL_COND_MSG(!E, "Attempted to register method on non-existent class.");
List<PropertyInfo> args;
Vector<Variant> default_args;
for (int i = 0; i < p_signal->num_args; i++) {
PropertyInfo info;
godot_nativescript_signal_argument arg = p_signal->args[i];
info.hint = (PropertyHint)arg.hint;
info.hint_string = *(String *)&arg.hint_string;
info.name = *(String *)&arg.name;
info.type = (Variant::Type)arg.type;
info.usage = (PropertyUsageFlags)arg.usage;
args.push_back(info);
}
for (int i = 0; i < p_signal->num_default_args; i++) {
Variant *v;
godot_nativescript_signal_argument attrib = p_signal->args[i];
v = (Variant *)&attrib.default_value;
default_args.push_back(*v);
}
MethodInfo method_info;
method_info.name = *(String *)&p_signal->name;
method_info.arguments = args;
method_info.default_arguments = default_args;
NativeScriptDesc::Signal signal;
signal.signal = method_info;
E->get().signals_.insert(*(String *)&p_signal->name, signal);
}
void GDAPI *godot_nativescript_get_userdata(godot_object *p_instance) {
Object *instance = (Object *)p_instance;
if (!instance) {
return nullptr;
}
if (instance->get_script_instance() && instance->get_script_instance()->get_language() == NativeScriptLanguage::get_singleton()) {
return ((NativeScriptInstance *)instance->get_script_instance())->userdata;
}
return nullptr;
}
/*
*
*
* NativeScript 1.1
*
*
*/
void GDAPI godot_nativescript_set_method_argument_information(void *p_gdnative_handle, const char *p_name, const char *p_function_name, int p_num_args, const godot_nativescript_method_argument *p_args) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
ERR_FAIL_COND_MSG(!E, "Attempted to add argument information for a method on a non-existent class.");
Map<StringName, NativeScriptDesc::Method>::Element *method = E->get().methods.find(p_function_name);
ERR_FAIL_COND_MSG(!method, "Attempted to add argument information to non-existent method.");
MethodInfo *method_information = &method->get().info;
List<PropertyInfo> args;
for (int i = 0; i < p_num_args; i++) {
godot_nativescript_method_argument arg = p_args[i];
String name = *(String *)&arg.name;
String hint_string = *(String *)&arg.hint_string;
Variant::Type type = (Variant::Type)arg.type;
PropertyHint hint = (PropertyHint)arg.hint;
args.push_back(PropertyInfo(type, p_name, hint, hint_string));
}
method_information->arguments = args;
}
void GDAPI godot_nativescript_set_class_documentation(void *p_gdnative_handle, const char *p_name, godot_string p_documentation) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a non-existent class.");
E->get().documentation = *(String *)&p_documentation;
}
void GDAPI godot_nativescript_set_method_documentation(void *p_gdnative_handle, const char *p_name, const char *p_function_name, godot_string p_documentation) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a method on a non-existent class.");
Map<StringName, NativeScriptDesc::Method>::Element *method = E->get().methods.find(p_function_name);
ERR_FAIL_COND_MSG(!method, "Attempted to add documentation to non-existent method.");
method->get().documentation = *(String *)&p_documentation;
}
void GDAPI godot_nativescript_set_property_documentation(void *p_gdnative_handle, const char *p_name, const char *p_path, godot_string p_documentation) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a property on a non-existent class.");
OrderedHashMap<StringName, NativeScriptDesc::Property>::Element property = E->get().properties.find(p_path);
ERR_FAIL_COND_MSG(!property, "Attempted to add documentation to non-existent property.");
property.get().documentation = *(String *)&p_documentation;
}
void GDAPI godot_nativescript_set_signal_documentation(void *p_gdnative_handle, const char *p_name, const char *p_signal_name, godot_string p_documentation) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
ERR_FAIL_COND_MSG(!E, "Attempted to add documentation to a signal on a non-existent class.");
Map<StringName, NativeScriptDesc::Signal>::Element *signal = E->get().signals_.find(p_signal_name);
ERR_FAIL_COND_MSG(!signal, "Attempted to add documentation to non-existent signal.");
signal->get().documentation = *(String *)&p_documentation;
}
void GDAPI godot_nativescript_set_global_type_tag(int p_idx, const char *p_name, const void *p_type_tag) {
NativeScriptLanguage::get_singleton()->set_global_type_tag(p_idx, StringName(p_name), p_type_tag);
}
const void GDAPI *godot_nativescript_get_global_type_tag(int p_idx, const char *p_name) {
return NativeScriptLanguage::get_singleton()->get_global_type_tag(p_idx, StringName(p_name));
}
void GDAPI godot_nativescript_set_type_tag(void *p_gdnative_handle, const char *p_name, const void *p_type_tag) {
String *s = (String *)p_gdnative_handle;
Map<StringName, NativeScriptDesc>::Element *E = NSL->library_classes[*s].find(p_name);
ERR_FAIL_COND_MSG(!E, "Attempted to set type tag on a non-existent class.");
E->get().type_tag = p_type_tag;
}
const void GDAPI *godot_nativescript_get_type_tag(const godot_object *p_object) {
const Object *o = (Object *)p_object;
if (!o->get_script_instance()) {
return nullptr;
} else {
NativeScript *script = Object::cast_to<NativeScript>(o->get_script_instance()->get_script().ptr());
if (!script) {
return nullptr;
}
if (script->get_script_desc()) {
return script->get_script_desc()->type_tag;
}
}
return nullptr;
}
int GDAPI godot_nativescript_register_instance_binding_data_functions(godot_nativescript_instance_binding_functions p_binding_functions) {
return NativeScriptLanguage::get_singleton()->register_binding_functions(p_binding_functions);
}
void GDAPI godot_nativescript_unregister_instance_binding_data_functions(int p_idx) {
NativeScriptLanguage::get_singleton()->unregister_binding_functions(p_idx);
}
void GDAPI *godot_nativescript_get_instance_binding_data(int p_idx, godot_object *p_object) {
return nullptr;
}
void GDAPI godot_nativescript_profiling_add_data(const char *p_signature, uint64_t p_time) {
NativeScriptLanguage::get_singleton()->profiling_add_data(StringName(p_signature), p_time);
}
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,393 +0,0 @@
/*************************************************************************/
/* nativescript.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef NATIVE_SCRIPT_H
#define NATIVE_SCRIPT_H
#include "core/doc_data.h"
#include "core/io/resource.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/object/script_language.h"
#include "core/os/mutex.h"
#include "core/os/thread_safe.h"
#include "core/templates/oa_hash_map.h"
#include "core/templates/ordered_hash_map.h"
#include "core/templates/safe_refcount.h"
#include "core/templates/self_list.h"
#include "scene/main/node.h"
#include "modules/gdnative/gdnative.h"
#include <nativescript/godot_nativescript.h>
struct NativeScriptDesc {
struct Method {
godot_nativescript_instance_method method;
MethodInfo info;
int rpc_mode = 0;
uint16_t rpc_method_id = 0;
String documentation;
};
struct Property {
godot_nativescript_property_set_func setter;
godot_nativescript_property_get_func getter;
PropertyInfo info;
Variant default_value;
String documentation;
};
struct Signal {
MethodInfo signal;
String documentation;
};
Map<StringName, Method> methods;
Vector<Multiplayer::RPCConfig> rpc_methods;
OrderedHashMap<StringName, Property> properties;
Map<StringName, Signal> signals_; // QtCreator doesn't like the name signals
StringName base;
StringName base_native_type;
NativeScriptDesc *base_data = nullptr;
godot_nativescript_instance_create_func create_func;
godot_nativescript_instance_destroy_func destroy_func;
String documentation;
const void *type_tag = nullptr;
bool is_tool = false;
inline NativeScriptDesc() {
memset(&create_func, 0, sizeof(godot_nativescript_instance_create_func));
memset(&destroy_func, 0, sizeof(godot_nativescript_instance_destroy_func));
}
};
class NativeScript : public Script {
GDCLASS(NativeScript, Script);
#ifdef TOOLS_ENABLED
Set<PlaceHolderScriptInstance *> placeholders;
void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) override;
#endif
friend class NativeScriptInstance;
friend class NativeScriptLanguage;
friend class NativeReloadNode;
friend class GDNativeLibrary;
Ref<GDNativeLibrary> library;
String lib_path;
String class_name;
String script_class_name;
String script_class_icon_path;
Mutex owners_lock;
Set<Object *> instance_owners;
protected:
static void _bind_methods();
public:
inline NativeScriptDesc *get_script_desc() const;
bool inherits_script(const Ref<Script> &p_script) const override;
void set_class_name(String p_class_name);
String get_class_name() const;
void set_library(Ref<GDNativeLibrary> p_library);
Ref<GDNativeLibrary> get_library() const;
void set_script_class_name(String p_type);
String get_script_class_name() const;
void set_script_class_icon_path(String p_icon_path);
String get_script_class_icon_path() const;
virtual bool can_instantiate() const override;
virtual Ref<Script> get_base_script() const override; //for script inheritance
virtual StringName get_instance_base_type() const override; // this may not work in all scripts, will return empty if so
virtual ScriptInstance *instance_create(Object *p_this) override;
virtual PlaceHolderScriptInstance *placeholder_instance_create(Object *p_this) override;
virtual bool instance_has(const Object *p_this) const override;
virtual bool has_source_code() const override;
virtual String get_source_code() const override;
virtual void set_source_code(const String &p_code) override;
virtual Error reload(bool p_keep_state = false) override;
#ifdef TOOLS_ENABLED
virtual const Vector<DocData::ClassDoc> &get_documentation() const override {
static Vector<DocData::ClassDoc> docs;
return docs;
}
#endif // TOOLS_ENABLED
virtual bool has_method(const StringName &p_method) const override;
virtual MethodInfo get_method_info(const StringName &p_method) const override;
virtual bool is_tool() const override;
virtual bool is_valid() const override;
virtual ScriptLanguage *get_language() const override;
virtual bool has_script_signal(const StringName &p_signal) const override;
virtual void get_script_signal_list(List<MethodInfo> *r_signals) const override;
virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const override;
virtual void update_exports() override; //editor tool
virtual void get_script_method_list(List<MethodInfo> *p_list) const override;
virtual void get_script_property_list(List<PropertyInfo> *p_list) const override;
virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const override;
String get_class_documentation() const;
String get_method_documentation(const StringName &p_method) const;
String get_signal_documentation(const StringName &p_signal_name) const;
String get_property_documentation(const StringName &p_path) const;
Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
NativeScript();
~NativeScript();
};
class NativeScriptInstance : public ScriptInstance {
friend class NativeScript;
Object *owner;
Ref<NativeScript> script;
#ifdef DEBUG_ENABLED
StringName current_method_call;
#endif
void _ml_call_reversed(NativeScriptDesc *script_data, const StringName &p_method, const Variant **p_args, int p_argcount);
public:
void *userdata;
virtual bool set(const StringName &p_name, const Variant &p_value);
virtual bool get(const StringName &p_name, Variant &r_ret) const;
virtual void get_property_list(List<PropertyInfo> *p_properties) const;
virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid) const;
virtual void get_method_list(List<MethodInfo> *p_list) const;
virtual bool has_method(const StringName &p_method) const;
virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
virtual void notification(int p_what);
String to_string(bool *r_valid);
virtual Ref<Script> get_script() const;
virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const;
virtual ScriptLanguage *get_language();
virtual void refcount_incremented();
virtual bool refcount_decremented();
~NativeScriptInstance();
};
class NativeReloadNode;
class NativeScriptLanguage : public ScriptLanguage {
friend class NativeScript;
friend class NativeScriptInstance;
friend class NativeReloadNode;
private:
static NativeScriptLanguage *singleton;
int lang_idx = 0;
void _unload_stuff(bool p_reload = false);
Mutex mutex;
#ifndef NO_THREADS
Set<Ref<GDNativeLibrary>> libs_to_init;
Set<NativeScript *> scripts_to_register;
SafeFlag has_objects_to_register; // so that we don't lock mutex every frame - it's rarely needed
void defer_init_library(Ref<GDNativeLibrary> lib, NativeScript *script);
#endif
void init_library(const Ref<GDNativeLibrary> &lib);
void register_script(NativeScript *script);
void unregister_script(NativeScript *script);
void call_libraries_cb(const StringName &name);
Vector<Pair<bool, godot_nativescript_instance_binding_functions>> binding_functions;
Set<Vector<void *> *> binding_instances;
Map<int, HashMap<StringName, const void *>> global_type_tags;
struct ProfileData {
StringName signature;
uint64_t call_count = 0;
uint64_t self_time = 0;
uint64_t total_time = 0;
uint64_t frame_call_count = 0;
uint64_t frame_self_time = 0;
uint64_t frame_total_time = 0;
uint64_t last_frame_call_count = 0;
uint64_t last_frame_self_time = 0;
uint64_t last_frame_total_time = 0;
};
Map<StringName, ProfileData> profile_data;
public:
// These two maps must only be touched on the main thread
Map<String, Map<StringName, NativeScriptDesc>> library_classes;
Map<String, Ref<GDNative>> library_gdnatives;
Map<String, Set<NativeScript *>> library_script_users;
StringName _init_call_type;
StringName _init_call_name;
StringName _terminate_call_name;
StringName _noarg_call_type;
StringName _frame_call_name;
#ifndef NO_THREADS
StringName _thread_enter_call_name;
StringName _thread_exit_call_name;
#endif
NativeScriptLanguage();
~NativeScriptLanguage();
inline static NativeScriptLanguage *get_singleton() {
return singleton;
}
_FORCE_INLINE_ void set_language_index(int p_idx) { lang_idx = p_idx; }
#ifndef NO_THREADS
virtual void thread_enter();
virtual void thread_exit();
#endif
virtual void frame();
virtual String get_name() const;
virtual void init();
virtual String get_type() const;
virtual String get_extension() const;
virtual Error execute_file(const String &p_path);
virtual void finish();
virtual void get_reserved_words(List<String> *p_words) const;
virtual bool is_control_flow_keyword(String p_keyword) const;
virtual void get_comment_delimiters(List<String> *p_delimiters) const;
virtual void get_string_delimiters(List<String> *p_delimiters) const;
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
virtual bool validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
virtual Script *create_script() const;
virtual bool has_named_classes() const;
virtual bool supports_builtin_mode() const;
virtual int find_function(const String &p_function, const String &p_code) const;
virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const;
virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
virtual String debug_get_error() const;
virtual int debug_get_stack_level_count() const;
virtual int debug_get_stack_level_line(int p_level) const;
virtual String debug_get_stack_level_function(int p_level) const;
virtual String debug_get_stack_level_source(int p_level) const;
virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth);
virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth);
virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth);
virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth);
virtual void reload_all_scripts();
virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual void get_public_functions(List<MethodInfo> *p_functions) const;
virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const;
virtual void profiling_start();
virtual void profiling_stop();
virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max);
virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max);
int register_binding_functions(godot_nativescript_instance_binding_functions p_binding_functions);
void unregister_binding_functions(int p_idx);
void *get_instance_binding_data(int p_idx, Object *p_object);
virtual void *alloc_instance_binding_data(Object *p_object);
virtual void free_instance_binding_data(void *p_data);
virtual void refcount_incremented_instance_binding(Object *p_object);
virtual bool refcount_decremented_instance_binding(Object *p_object);
void set_global_type_tag(int p_idx, StringName p_class_name, const void *p_type_tag);
const void *get_global_type_tag(int p_idx, StringName p_class_name) const;
virtual bool handles_global_class_type(const String &p_type) const;
virtual String get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const;
void profiling_add_data(StringName p_signature, uint64_t p_time);
};
inline NativeScriptDesc *NativeScript::get_script_desc() const {
Map<StringName, NativeScriptDesc>::Element *E = NativeScriptLanguage::singleton->library_classes[lib_path].find(class_name);
return E ? &E->get() : nullptr;
}
class NativeReloadNode : public Node {
GDCLASS(NativeReloadNode, Node);
bool unloaded = false;
public:
static void _bind_methods();
void _notification(int p_what);
NativeReloadNode() {}
};
class ResourceFormatLoaderNativeScript : public ResourceFormatLoader {
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
};
class ResourceFormatSaverNativeScript : public ResourceFormatSaver {
virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
virtual bool recognize(const RES &p_resource) const;
virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
};
#endif // GDNATIVE_H

View File

@ -1,71 +0,0 @@
/*************************************************************************/
/* register_types.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_types.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "nativescript.h"
#include "core/os/os.h"
NativeScriptLanguage *native_script_language;
Ref<ResourceFormatLoaderNativeScript> resource_loader_gdns;
Ref<ResourceFormatSaverNativeScript> resource_saver_gdns;
void register_nativescript_types() {
native_script_language = memnew(NativeScriptLanguage);
GDREGISTER_CLASS(NativeScript);
native_script_language->set_language_index(ScriptServer::get_language_count());
ScriptServer::register_language(native_script_language);
resource_saver_gdns.instantiate();
ResourceSaver::add_resource_format_saver(resource_saver_gdns);
resource_loader_gdns.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_gdns);
}
void unregister_nativescript_types() {
ResourceLoader::remove_resource_format_loader(resource_loader_gdns);
resource_loader_gdns.unref();
ResourceSaver::remove_resource_format_saver(resource_saver_gdns);
resource_saver_gdns.unref();
if (native_script_language) {
ScriptServer::unregister_language(native_script_language);
memdelete(native_script_language);
}
}

View File

@ -1,37 +0,0 @@
/*************************************************************************/
/* register_types.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef NATIVESCRIPT_REGISTER_TYPES_H
#define NATIVESCRIPT_REGISTER_TYPES_H
void register_nativescript_types();
void unregister_nativescript_types();
#endif // NATIVESCRIPT_REGISTER_TYPES_H

View File

@ -1,6 +0,0 @@
#!/usr/bin/env python
Import("env")
Import("env_gdnative")
env_gdnative.add_source_files(env.modules_sources, "*.cpp")

View File

@ -1,140 +0,0 @@
/*************************************************************************/
/* pluginscript_instance.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "pluginscript_instance.h"
// Godot imports
#include "core/os/os.h"
#include "core/variant/variant.h"
// PluginScript imports
#include "pluginscript_language.h"
#include "pluginscript_script.h"
bool PluginScriptInstance::set(const StringName &p_name, const Variant &p_value) {
return _desc->set_prop(_data, (const godot_string_name *)&p_name, (const godot_variant *)&p_value);
}
bool PluginScriptInstance::get(const StringName &p_name, Variant &r_ret) const {
return _desc->get_prop(_data, (const godot_string_name *)&p_name, (godot_variant *)&r_ret);
}
Ref<Script> PluginScriptInstance::get_script() const {
return _script;
}
ScriptLanguage *PluginScriptInstance::get_language() {
return _script->get_language();
}
Variant::Type PluginScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const {
if (!_script->has_property(p_name)) {
if (r_is_valid) {
*r_is_valid = false;
}
return Variant::NIL;
}
if (r_is_valid) {
*r_is_valid = true;
}
return _script->get_property_info(p_name).type;
}
void PluginScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const {
_script->get_script_property_list(p_properties);
}
void PluginScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
_script->get_script_method_list(p_list);
}
bool PluginScriptInstance::has_method(const StringName &p_method) const {
return _script->has_method(p_method);
}
Variant PluginScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
// TODO: optimize when calling a Godot method from Godot to avoid param conversion ?
godot_variant ret = _desc->call_method(
_data, (godot_string_name *)&p_method, (const godot_variant **)p_args,
p_argcount, (godot_variant_call_error *)&r_error);
Variant var_ret = *(Variant *)&ret;
godot_variant_destroy(&ret);
return var_ret;
}
void PluginScriptInstance::notification(int p_notification) {
_desc->notification(_data, p_notification);
}
String PluginScriptInstance::to_string(bool *r_valid) {
godot_string ret = _desc->to_string(_data, r_valid);
String str_ret = *(String *)&ret;
godot_string_destroy(&ret);
return str_ret;
}
const Vector<Multiplayer::RPCConfig> PluginScriptInstance::get_rpc_methods() const {
return _script->get_rpc_methods();
}
void PluginScriptInstance::refcount_incremented() {
if (_desc->refcount_decremented) {
_desc->refcount_incremented(_data);
}
}
bool PluginScriptInstance::refcount_decremented() {
// Return true if it can die
if (_desc->refcount_decremented) {
return _desc->refcount_decremented(_data);
}
return true;
}
PluginScriptInstance::PluginScriptInstance() {
}
bool PluginScriptInstance::init(PluginScript *p_script, Object *p_owner) {
_owner = p_owner;
_owner_variant = Variant(p_owner);
_script = Ref<PluginScript>(p_script);
_desc = &p_script->_desc->instance_desc;
_data = _desc->init(p_script->_data, (godot_object *)p_owner);
ERR_FAIL_COND_V(_data == nullptr, false);
p_owner->set_script_instance(this);
return true;
}
PluginScriptInstance::~PluginScriptInstance() {
_desc->finish(_data);
_script->_language->lock();
_script->_instances.erase(_owner);
_script->_language->unlock();
}

View File

@ -1,82 +0,0 @@
/*************************************************************************/
/* pluginscript_instance.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef PLUGINSCRIPT_INSTANCE_H
#define PLUGINSCRIPT_INSTANCE_H
// Godot imports
#include "core/object/script_language.h"
// PluginScript imports
#include <pluginscript/godot_pluginscript.h>
class PluginScript;
class PluginScriptInstance : public ScriptInstance {
friend class PluginScript;
private:
Ref<PluginScript> _script;
Object *_owner = nullptr;
Variant _owner_variant;
godot_pluginscript_instance_data *_data = nullptr;
const godot_pluginscript_instance_desc *_desc = nullptr;
public:
_FORCE_INLINE_ Object *get_owner() { return _owner; }
virtual bool set(const StringName &p_name, const Variant &p_value);
virtual bool get(const StringName &p_name, Variant &r_ret) const;
virtual void get_property_list(List<PropertyInfo> *p_properties) const;
virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = nullptr) const;
virtual void get_method_list(List<MethodInfo> *p_list) const;
virtual bool has_method(const StringName &p_method) const;
virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Callable::CallError &r_error);
virtual void notification(int p_notification);
virtual String to_string(bool *r_valid);
virtual Ref<Script> get_script() const;
virtual ScriptLanguage *get_language();
virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const;
virtual void refcount_incremented();
virtual bool refcount_decremented();
PluginScriptInstance();
bool init(PluginScript *p_script, Object *p_owner);
virtual ~PluginScriptInstance();
};
#endif // PLUGINSCRIPT_INSTANCE_H

View File

@ -1,459 +0,0 @@
/*************************************************************************/
/* pluginscript_language.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
// Godot imports
#include "core/config/project_settings.h"
#include "core/io/file_access.h"
#include "core/os/os.h"
// PluginScript imports
#include "pluginscript_language.h"
#include "pluginscript_script.h"
String PluginScriptLanguage::get_name() const {
return String(_desc.name);
}
void PluginScriptLanguage::init() {
_data = _desc.init();
}
String PluginScriptLanguage::get_type() const {
// We should use _desc.type here, however the returned type is used to
// query ClassDB which would complain given the type is not registered
// from his point of view...
// To solve this we just use a more generic (but present in ClassDB) type.
return String("PluginScript");
}
String PluginScriptLanguage::get_extension() const {
return String(_desc.extension);
}
Error PluginScriptLanguage::execute_file(const String &p_path) {
// TODO: pretty sure this method is totally deprecated and should be removed...
return OK;
}
void PluginScriptLanguage::finish() {
_desc.finish(_data);
}
/* EDITOR FUNCTIONS */
void PluginScriptLanguage::get_reserved_words(List<String> *p_words) const {
if (_desc.reserved_words) {
const char **w = _desc.reserved_words;
while (*w) {
p_words->push_back(*w);
w++;
}
}
}
bool PluginScriptLanguage::is_control_flow_keyword(String p_keyword) const {
return false;
}
void PluginScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) const {
if (_desc.comment_delimiters) {
const char **w = _desc.comment_delimiters;
while (*w) {
p_delimiters->push_back(*w);
w++;
}
}
}
void PluginScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const {
if (_desc.string_delimiters) {
const char **w = _desc.string_delimiters;
while (*w) {
p_delimiters->push_back(*w);
w++;
}
}
}
Ref<Script> PluginScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const {
Script *ns = create_script();
Ref<Script> script = Ref<Script>(ns);
if (_desc.get_template_source_code) {
godot_string src = _desc.get_template_source_code(_data, (godot_string *)&p_class_name, (godot_string *)&p_base_class_name);
script->set_source_code(*(String *)&src);
godot_string_destroy(&src);
}
return script;
}
bool PluginScriptLanguage::validate(const String &p_script, const String &p_path, List<String> *r_functions, List<ScriptLanguage::ScriptError> *r_errors, List<ScriptLanguage::Warning> *r_warnings, Set<int> *r_safe_lines) const {
PackedStringArray functions;
Array errors;
if (_desc.validate) {
bool ret = _desc.validate(
_data,
(godot_string *)&p_script,
(godot_string *)&p_path,
(godot_packed_string_array *)&functions,
(godot_array *)&errors);
for (int i = 0; i < functions.size(); i++) {
r_functions->push_back(functions[i]);
}
if (r_errors) {
for (int i = 0; i < errors.size(); i++) {
Dictionary error = errors[i];
ScriptLanguage::ScriptError e;
e.line = error["line"];
e.column = error["column"];
e.message = error["message"];
r_errors->push_back(e);
}
}
return ret;
}
return true;
}
Script *PluginScriptLanguage::create_script() const {
PluginScript *script = memnew(PluginScript());
// I'm hurting kittens doing this I guess...
script->init(const_cast<PluginScriptLanguage *>(this));
return script;
}
bool PluginScriptLanguage::has_named_classes() const {
return _desc.has_named_classes;
}
bool PluginScriptLanguage::supports_builtin_mode() const {
return _desc.supports_builtin_mode;
}
bool PluginScriptLanguage::can_inherit_from_file() const {
return _desc.can_inherit_from_file;
}
int PluginScriptLanguage::find_function(const String &p_function, const String &p_code) const {
if (_desc.find_function) {
return _desc.find_function(_data, (godot_string *)&p_function, (godot_string *)&p_code);
}
return -1;
}
String PluginScriptLanguage::make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const {
if (_desc.make_function) {
godot_string tmp = _desc.make_function(_data, (godot_string *)&p_class, (godot_string *)&p_name, (godot_packed_string_array *)&p_args);
String ret = *(String *)&tmp;
godot_string_destroy(&tmp);
return ret;
}
return String();
}
Error PluginScriptLanguage::complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_force, String &r_call_hint) {
if (_desc.complete_code) {
Array options;
godot_error tmp = _desc.complete_code(
_data,
(godot_string *)&p_code,
(godot_string *)&p_path,
(godot_object *)p_owner,
(godot_array *)&options,
&r_force,
(godot_string *)&r_call_hint);
for (int i = 0; i < options.size(); i++) {
ScriptCodeCompletionOption option(options[i], ScriptCodeCompletionOption::KIND_PLAIN_TEXT);
r_options->push_back(option);
}
return (Error)tmp;
}
return ERR_UNAVAILABLE;
}
void PluginScriptLanguage::auto_indent_code(String &p_code, int p_from_line, int p_to_line) const {
if (_desc.auto_indent_code) {
_desc.auto_indent_code(_data, (godot_string *)&p_code, p_from_line, p_to_line);
}
return;
}
void PluginScriptLanguage::add_global_constant(const StringName &p_variable, const Variant &p_value) {
_desc.add_global_constant(_data, (godot_string_name *)&p_variable, (godot_variant *)&p_value);
}
/* LOADER FUNCTIONS */
void PluginScriptLanguage::get_recognized_extensions(List<String> *p_extensions) const {
for (int i = 0; _desc.recognized_extensions[i]; ++i) {
p_extensions->push_back(String(_desc.recognized_extensions[i]));
}
}
void PluginScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const {
// TODO: provide this statically in `godot_pluginscript_language_desc` ?
if (_desc.get_public_functions) {
Array functions;
_desc.get_public_functions(_data, (godot_array *)&functions);
for (int i = 0; i < functions.size(); i++) {
MethodInfo mi = MethodInfo::from_dict(functions[i]);
p_functions->push_back(mi);
}
}
}
void PluginScriptLanguage::get_public_constants(List<Pair<String, Variant>> *p_constants) const {
// TODO: provide this statically in `godot_pluginscript_language_desc` ?
if (_desc.get_public_constants) {
Dictionary constants;
_desc.get_public_constants(_data, (godot_dictionary *)&constants);
for (const Variant *key = constants.next(); key; key = constants.next(key)) {
Variant value = constants[*key];
p_constants->push_back(Pair<String, Variant>(*key, value));
}
}
}
void PluginScriptLanguage::profiling_start() {
#ifdef DEBUG_ENABLED
if (_desc.profiling_start) {
lock();
_desc.profiling_start(_data);
unlock();
}
#endif
}
void PluginScriptLanguage::profiling_stop() {
#ifdef DEBUG_ENABLED
if (_desc.profiling_stop) {
lock();
_desc.profiling_stop(_data);
unlock();
}
#endif
}
int PluginScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max) {
int info_count = 0;
#ifdef DEBUG_ENABLED
if (_desc.profiling_get_accumulated_data) {
godot_pluginscript_profiling_data *info = (godot_pluginscript_profiling_data *)memalloc(
sizeof(godot_pluginscript_profiling_data) * p_info_max);
info_count = _desc.profiling_get_accumulated_data(_data, info, p_info_max);
for (int i = 0; i < info_count; ++i) {
p_info_arr[i].signature = *(StringName *)&info[i].signature;
p_info_arr[i].call_count = info[i].call_count;
p_info_arr[i].total_time = info[i].total_time;
p_info_arr[i].self_time = info[i].self_time;
godot_string_name_destroy(&info[i].signature);
}
}
#endif
return info_count;
}
int PluginScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max) {
int info_count = 0;
#ifdef DEBUG_ENABLED
if (_desc.profiling_get_frame_data) {
godot_pluginscript_profiling_data *info = (godot_pluginscript_profiling_data *)memalloc(
sizeof(godot_pluginscript_profiling_data) * p_info_max);
info_count = _desc.profiling_get_frame_data(_data, info, p_info_max);
for (int i = 0; i < info_count; ++i) {
p_info_arr[i].signature = *(StringName *)&info[i].signature;
p_info_arr[i].call_count = info[i].call_count;
p_info_arr[i].total_time = info[i].total_time;
p_info_arr[i].self_time = info[i].self_time;
godot_string_name_destroy(&info[i].signature);
}
}
#endif
return info_count;
}
void PluginScriptLanguage::frame() {
#ifdef DEBUG_ENABLED
if (_desc.profiling_frame) {
_desc.profiling_frame(_data);
}
#endif
}
/* DEBUGGER FUNCTIONS */
String PluginScriptLanguage::debug_get_error() const {
if (_desc.debug_get_error) {
godot_string tmp = _desc.debug_get_error(_data);
String ret = *(String *)&tmp;
godot_string_destroy(&tmp);
return ret;
}
return String("Nothing");
}
int PluginScriptLanguage::debug_get_stack_level_count() const {
if (_desc.debug_get_stack_level_count) {
return _desc.debug_get_stack_level_count(_data);
}
return 1;
}
int PluginScriptLanguage::debug_get_stack_level_line(int p_level) const {
if (_desc.debug_get_stack_level_line) {
return _desc.debug_get_stack_level_line(_data, p_level);
}
return 1;
}
String PluginScriptLanguage::debug_get_stack_level_function(int p_level) const {
if (_desc.debug_get_stack_level_function) {
godot_string tmp = _desc.debug_get_stack_level_function(_data, p_level);
String ret = *(String *)&tmp;
godot_string_destroy(&tmp);
return ret;
}
return String("Nothing");
}
String PluginScriptLanguage::debug_get_stack_level_source(int p_level) const {
if (_desc.debug_get_stack_level_source) {
godot_string tmp = _desc.debug_get_stack_level_source(_data, p_level);
String ret = *(String *)&tmp;
godot_string_destroy(&tmp);
return ret;
}
return String("Nothing");
}
void PluginScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
if (_desc.debug_get_stack_level_locals) {
PackedStringArray locals;
Array values;
_desc.debug_get_stack_level_locals(_data, p_level, (godot_packed_string_array *)&locals, (godot_array *)&values, p_max_subitems, p_max_depth);
for (int i = 0; i < locals.size(); i++) {
p_locals->push_back(locals[i]);
}
for (int i = 0; i < values.size(); i++) {
p_values->push_back(values[i]);
}
}
}
void PluginScriptLanguage::debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
if (_desc.debug_get_stack_level_members) {
PackedStringArray members;
Array values;
_desc.debug_get_stack_level_members(_data, p_level, (godot_packed_string_array *)&members, (godot_array *)&values, p_max_subitems, p_max_depth);
for (int i = 0; i < members.size(); i++) {
p_members->push_back(members[i]);
}
for (int i = 0; i < values.size(); i++) {
p_values->push_back(values[i]);
}
}
}
void PluginScriptLanguage::debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems, int p_max_depth) {
if (_desc.debug_get_globals) {
PackedStringArray locals;
Array values;
_desc.debug_get_globals(_data, (godot_packed_string_array *)&locals, (godot_array *)&values, p_max_subitems, p_max_depth);
for (int i = 0; i < locals.size(); i++) {
p_locals->push_back(locals[i]);
}
for (int i = 0; i < values.size(); i++) {
p_values->push_back(values[i]);
}
}
}
String PluginScriptLanguage::debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems, int p_max_depth) {
if (_desc.debug_parse_stack_level_expression) {
godot_string tmp = _desc.debug_parse_stack_level_expression(_data, p_level, (godot_string *)&p_expression, p_max_subitems, p_max_depth);
String ret = *(String *)&tmp;
godot_string_destroy(&tmp);
return ret;
}
return String("Nothing");
}
void PluginScriptLanguage::reload_all_scripts() {
// TODO
}
void PluginScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload) {
#ifdef DEBUG_ENABLED
lock();
// TODO
unlock();
#endif
}
bool PluginScriptLanguage::handles_global_class_type(const String &p_type) const {
return p_type == "PluginScript";
}
String PluginScriptLanguage::get_global_class_name(const String &p_path, String *r_base_type, String *r_icon_path) const {
if (!p_path.is_empty()) {
Ref<PluginScript> script = ResourceLoader::load(p_path, "PluginScript");
if (script.is_valid()) {
if (r_base_type) {
*r_base_type = script->get_instance_base_type();
}
if (r_icon_path) {
*r_icon_path = script->get_script_class_icon_path();
}
return script->get_script_class_name();
}
if (r_base_type) {
*r_base_type = String();
}
if (r_icon_path) {
*r_icon_path = String();
}
}
return String();
}
void PluginScriptLanguage::lock() {
_lock.lock();
}
void PluginScriptLanguage::unlock() {
_lock.unlock();
}
PluginScriptLanguage::PluginScriptLanguage(const godot_pluginscript_language_desc *desc) :
_desc(*desc) {
_resource_loader = Ref<ResourceFormatLoaderPluginScript>(memnew(ResourceFormatLoaderPluginScript(this)));
_resource_saver = Ref<ResourceFormatSaverPluginScript>(memnew(ResourceFormatSaverPluginScript(this)));
}
PluginScriptLanguage::~PluginScriptLanguage() {
}

View File

@ -1,138 +0,0 @@
/*************************************************************************/
/* pluginscript_language.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef PLUGINSCRIPT_LANGUAGE_H
#define PLUGINSCRIPT_LANGUAGE_H
// Godot imports
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/object/script_language.h"
#include "core/templates/map.h"
#include "core/templates/self_list.h"
// PluginScript imports
#include "pluginscript_loader.h"
#include <pluginscript/godot_pluginscript.h>
class PluginScript;
class PluginScriptInstance;
class PluginScriptLanguage : public ScriptLanguage {
friend class PluginScript;
friend class PluginScriptInstance;
Ref<ResourceFormatLoaderPluginScript> _resource_loader;
Ref<ResourceFormatSaverPluginScript> _resource_saver;
const godot_pluginscript_language_desc _desc;
godot_pluginscript_language_data *_data;
Mutex _lock;
SelfList<PluginScript>::List _script_list;
public:
virtual String get_name() const;
_FORCE_INLINE_ Ref<ResourceFormatLoaderPluginScript> get_resource_loader() { return _resource_loader; }
_FORCE_INLINE_ Ref<ResourceFormatSaverPluginScript> get_resource_saver() { return _resource_saver; }
/* LANGUAGE FUNCTIONS */
virtual void init();
virtual String get_type() const;
virtual String get_extension() const;
virtual Error execute_file(const String &p_path);
virtual void finish();
/* EDITOR FUNCTIONS */
virtual void get_reserved_words(List<String> *p_words) const;
virtual bool is_control_flow_keyword(String p_keyword) const;
virtual void get_comment_delimiters(List<String> *p_delimiters) const;
virtual void get_string_delimiters(List<String> *p_delimiters) const;
virtual Ref<Script> get_template(const String &p_class_name, const String &p_base_class_name) const;
virtual bool validate(const String &p_script, const String &p_path = "", List<String> *r_functions = nullptr, List<ScriptLanguage::ScriptError> *r_errors = nullptr, List<ScriptLanguage::Warning> *r_warnings = nullptr, Set<int> *r_safe_lines = nullptr) const;
virtual Script *create_script() const;
virtual bool has_named_classes() const;
virtual bool supports_builtin_mode() const;
virtual bool can_inherit_from_file() const;
virtual int find_function(const String &p_function, const String &p_code) const;
virtual String make_function(const String &p_class, const String &p_name, const PackedStringArray &p_args) const;
virtual Error complete_code(const String &p_code, const String &p_path, Object *p_owner, List<ScriptCodeCompletionOption> *r_options, bool &r_force, String &r_call_hint);
virtual void auto_indent_code(String &p_code, int p_from_line, int p_to_line) const;
virtual void add_global_constant(const StringName &p_variable, const Variant &p_value);
/* MULTITHREAD FUNCTIONS */
//some VMs need to be notified of thread creation/exiting to allocate a stack
// void thread_enter() {}
// void thread_exit() {}
/* DEBUGGER FUNCTIONS */
virtual String debug_get_error() const;
virtual int debug_get_stack_level_count() const;
virtual int debug_get_stack_level_line(int p_level) const;
virtual String debug_get_stack_level_function(int p_level) const;
virtual String debug_get_stack_level_source(int p_level) const;
virtual void debug_get_stack_level_locals(int p_level, List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
virtual void debug_get_stack_level_members(int p_level, List<String> *p_members, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
virtual void debug_get_globals(List<String> *p_locals, List<Variant> *p_values, int p_max_subitems = -1, int p_max_depth = -1);
virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1);
// virtual Vector<StackInfo> debug_get_current_stack_info() { return Vector<StackInfo>(); }
virtual void reload_all_scripts();
virtual void reload_tool_script(const Ref<Script> &p_script, bool p_soft_reload);
/* LOADER FUNCTIONS */
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual void get_public_functions(List<MethodInfo> *p_functions) const;
virtual void get_public_constants(List<Pair<String, Variant>> *p_constants) const;
virtual void profiling_start();
virtual void profiling_stop();
virtual int profiling_get_accumulated_data(ProfilingInfo *p_info_arr, int p_info_max);
virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max);
virtual void frame();
/* GLOBAL CLASSES */
virtual bool handles_global_class_type(const String &p_type) const;
virtual String get_global_class_name(const String &p_path, String *r_base_type = nullptr, String *r_icon_path = nullptr) const;
void lock();
void unlock();
PluginScriptLanguage(const godot_pluginscript_language_desc *desc);
virtual ~PluginScriptLanguage();
};
#endif // PLUGINSCRIPT_LANGUAGE_H

View File

@ -1,114 +0,0 @@
/*************************************************************************/
/* pluginscript_loader.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
// Godot imports
#include "core/io/file_access.h"
// Pythonscript imports
#include "pluginscript_language.h"
#include "pluginscript_loader.h"
#include "pluginscript_script.h"
ResourceFormatLoaderPluginScript::ResourceFormatLoaderPluginScript(PluginScriptLanguage *language) {
_language = language;
}
RES ResourceFormatLoaderPluginScript::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, CacheMode p_cache_mode) {
if (r_error) {
*r_error = ERR_FILE_CANT_OPEN;
}
PluginScript *script = memnew(PluginScript);
script->init(_language);
Ref<PluginScript> scriptres(script);
Error err = script->load_source_code(p_path);
ERR_FAIL_COND_V(err != OK, RES());
script->set_path(p_original_path);
script->reload();
if (r_error) {
*r_error = OK;
}
return scriptres;
}
void ResourceFormatLoaderPluginScript::get_recognized_extensions(List<String> *p_extensions) const {
p_extensions->push_back(_language->get_extension());
}
bool ResourceFormatLoaderPluginScript::handles_type(const String &p_type) const {
return p_type == "Script" || p_type == _language->get_type();
}
String ResourceFormatLoaderPluginScript::get_resource_type(const String &p_path) const {
String el = p_path.get_extension().to_lower();
if (el == _language->get_extension()) {
return _language->get_type();
}
return "";
}
ResourceFormatSaverPluginScript::ResourceFormatSaverPluginScript(PluginScriptLanguage *language) {
_language = language;
}
Error ResourceFormatSaverPluginScript::save(const String &p_path, const RES &p_resource, uint32_t p_flags) {
Ref<PluginScript> sqscr = p_resource;
ERR_FAIL_COND_V(sqscr.is_null(), ERR_INVALID_PARAMETER);
String source = sqscr->get_source_code();
Error err;
FileAccess *file = FileAccess::open(p_path, FileAccess::WRITE, &err);
ERR_FAIL_COND_V(err, err);
file->store_string(source);
if (file->get_error() != OK && file->get_error() != ERR_FILE_EOF) {
memdelete(file);
return ERR_CANT_CREATE;
}
file->close();
memdelete(file);
return OK;
}
void ResourceFormatSaverPluginScript::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
if (Object::cast_to<PluginScript>(*p_resource)) {
p_extensions->push_back(_language->get_extension());
}
}
bool ResourceFormatSaverPluginScript::recognize(const RES &p_resource) const {
return Object::cast_to<PluginScript>(*p_resource) != nullptr;
}

View File

@ -1,62 +0,0 @@
/*************************************************************************/
/* pluginscript_loader.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef PYTHONSCRIPT_PY_LOADER_H
#define PYTHONSCRIPT_PY_LOADER_H
// Godot imports
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/object/script_language.h"
class PluginScriptLanguage;
class ResourceFormatLoaderPluginScript : public ResourceFormatLoader {
PluginScriptLanguage *_language;
public:
ResourceFormatLoaderPluginScript(PluginScriptLanguage *language);
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, CacheMode p_cache_mode = CACHE_MODE_REUSE);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
};
class ResourceFormatSaverPluginScript : public ResourceFormatSaver {
PluginScriptLanguage *_language;
public:
ResourceFormatSaverPluginScript(PluginScriptLanguage *language);
virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags = 0);
virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const;
virtual bool recognize(const RES &p_resource) const;
};
#endif // PYTHONSCRIPT_PY_LOADER_H

View File

@ -1,510 +0,0 @@
/*************************************************************************/
/* pluginscript_script.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
// Godot imports
#include "core/io/file_access.h"
// PluginScript imports
#include "pluginscript_instance.h"
#include "pluginscript_script.h"
#include <stdint.h>
#ifdef DEBUG_ENABLED
#define __ASSERT_SCRIPT_REASON "Cannot retrieve PluginScript class for this script, is your code correct?"
#define ASSERT_SCRIPT_VALID() \
{ \
ERR_FAIL_COND_MSG(!can_instantiate(), __ASSERT_SCRIPT_REASON); \
}
#define ASSERT_SCRIPT_VALID_V(ret) \
{ \
ERR_FAIL_COND_V_MSG(!can_instantiate(), ret, __ASSERT_SCRIPT_REASON); \
}
#else
#define ASSERT_SCRIPT_VALID()
#define ASSERT_SCRIPT_VALID_V(ret)
#endif
void PluginScript::_bind_methods() {
ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "new", &PluginScript::_new, MethodInfo("new"));
}
PluginScriptInstance *PluginScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Callable::CallError &r_error) {
r_error.error = Callable::CallError::CALL_OK;
// Create instance
PluginScriptInstance *instance = memnew(PluginScriptInstance());
if (instance->init(this, p_owner)) {
_language->lock();
_instances.insert(instance->get_owner());
_language->unlock();
} else {
r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
memdelete(instance);
ERR_FAIL_V(nullptr);
}
// Construct
// TODO: Support arguments in the constructor?
// There is currently no way to get the constructor function name of the script.
// instance->call("__init__", p_args, p_argcount, r_error);
if (p_argcount > 0) {
WARN_PRINT("PluginScript doesn't support arguments in the constructor");
}
return instance;
}
Variant PluginScript::_new(const Variant **p_args, int p_argcount, Callable::CallError &r_error) {
r_error.error = Callable::CallError::CALL_OK;
if (!_valid) {
r_error.error = Callable::CallError::CALL_ERROR_INVALID_METHOD;
return Variant();
}
REF ref;
Object *owner = nullptr;
if (get_instance_base_type() == StringName()) {
owner = memnew(RefCounted);
} else {
owner = ClassDB::instantiate(get_instance_base_type());
}
if (!owner) {
r_error.error = Callable::CallError::CALL_ERROR_INSTANCE_IS_NULL;
return Variant();
}
RefCounted *r = Object::cast_to<RefCounted>(owner);
if (r) {
ref = REF(r);
}
PluginScriptInstance *instance = _create_instance(p_args, p_argcount, owner, r_error);
if (!instance) {
if (ref.is_null()) {
memdelete(owner); //no owner, sorry
}
return Variant();
}
if (ref.is_valid()) {
return ref;
} else {
return owner;
}
}
#ifdef TOOLS_ENABLED
void PluginScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) {
placeholders.erase(p_placeholder);
}
#endif
bool PluginScript::can_instantiate() const {
bool can = _valid || (!_tool && !ScriptServer::is_scripting_enabled());
return can;
}
bool PluginScript::inherits_script(const Ref<Script> &p_script) const {
Ref<PluginScript> ps = p_script;
if (ps.is_null()) {
return false;
}
const PluginScript *s = this;
while (s) {
if (s == p_script.ptr()) {
return true;
}
s = Object::cast_to<PluginScript>(s->_ref_base_parent.ptr());
}
return false;
}
Ref<Script> PluginScript::get_base_script() const {
if (_ref_base_parent.is_valid()) {
return Ref<PluginScript>(_ref_base_parent);
} else {
return Ref<Script>();
}
}
StringName PluginScript::get_instance_base_type() const {
if (_native_parent) {
return _native_parent;
}
if (_ref_base_parent.is_valid()) {
return _ref_base_parent->get_instance_base_type();
}
return StringName();
}
void PluginScript::update_exports() {
#ifdef TOOLS_ENABLED
ASSERT_SCRIPT_VALID();
if (placeholders.size()) {
//update placeholders if any
Map<StringName, Variant> propdefvalues;
List<PropertyInfo> propinfos;
get_script_property_list(&propinfos);
for (Set<PlaceHolderScriptInstance *>::Element *E = placeholders.front(); E; E = E->next()) {
E->get()->update(propinfos, _properties_default_values);
}
}
#endif
}
// TODO: rename p_this "p_owner" ?
ScriptInstance *PluginScript::instance_create(Object *p_this) {
ASSERT_SCRIPT_VALID_V(nullptr);
// TODO check script validity ?
if (!_tool && !ScriptServer::is_scripting_enabled()) {
#ifdef TOOLS_ENABLED
// Instance a fake script for editing the values
PlaceHolderScriptInstance *si = memnew(PlaceHolderScriptInstance(get_language(), Ref<Script>(this), p_this));
placeholders.insert(si);
update_exports();
return si;
#else
return nullptr;
#endif
}
StringName base_type = get_instance_base_type();
if (base_type) {
if (!ClassDB::is_parent_class(p_this->get_class_name(), base_type)) {
String msg = "Script inherits from native type '" + String(base_type) + "', so it can't be instantiated in object of type: '" + p_this->get_class() + "'";
// TODO: implement PluginscriptLanguage::debug_break_parse
// if (EngineDebugger::is_active()) {
// _language->debug_break_parse(get_path(), 0, msg);
// }
ERR_FAIL_V_MSG(nullptr, msg);
}
}
Callable::CallError unchecked_error;
return _create_instance(nullptr, 0, p_this, unchecked_error);
}
bool PluginScript::instance_has(const Object *p_this) const {
ERR_FAIL_COND_V(!_language, false);
_language->lock();
bool hasit = _instances.has((Object *)p_this);
_language->unlock();
return hasit;
}
bool PluginScript::has_source_code() const {
return !_source.is_empty();
}
String PluginScript::get_source_code() const {
return _source;
}
void PluginScript::set_source_code(const String &p_code) {
if (_source == p_code) {
return;
}
_source = p_code;
}
Error PluginScript::reload(bool p_keep_state) {
ERR_FAIL_COND_V(!_language, ERR_UNCONFIGURED);
_language->lock();
ERR_FAIL_COND_V(!p_keep_state && _instances.size(), ERR_ALREADY_IN_USE);
_language->unlock();
_valid = false;
String basedir = _path;
if (basedir.is_empty()) {
basedir = get_path();
}
if (!basedir.is_empty()) {
basedir = basedir.get_base_dir();
}
if (_data) {
_desc->finish(_data);
}
Error err;
godot_pluginscript_script_manifest manifest = _desc->init(
_language->_data,
(godot_string *)&_path,
(godot_string *)&_source,
(godot_error *)&err);
// Manifest's attributes must be explicitly freed
#define FREE_SCRIPT_MANIFEST(manifest) \
{ \
godot_string_name_destroy(&manifest.name); \
godot_string_name_destroy(&manifest.base); \
godot_dictionary_destroy(&manifest.member_lines); \
godot_array_destroy(&manifest.methods); \
godot_array_destroy(&manifest.signals); \
godot_array_destroy(&manifest.properties); \
}
if (err) {
FREE_SCRIPT_MANIFEST(manifest);
// TODO: GDscript uses `ScriptDebugger` here to jump into the parsing error
return err;
}
// Script's parent is passed as base_name which can make reference to a
// ClassDB name (i.e. `Node2D`) or a resource path (i.e. `res://foo/bar.gd`)
StringName *base_name = (StringName *)&manifest.base;
if (*base_name) {
if (ClassDB::class_exists(*base_name)) {
_native_parent = *base_name;
} else {
Ref<Script> res = ResourceLoader::load(*base_name);
if (res.is_valid()) {
_ref_base_parent = res;
} else {
String name = *(StringName *)&manifest.name;
FREE_SCRIPT_MANIFEST(manifest);
ERR_FAIL_V_MSG(ERR_PARSE_ERROR, _path + ": Script '" + name + "' has an invalid parent '" + *base_name + "'.");
}
}
}
_valid = true;
// Use the manifest to configure this script object
_data = manifest.data;
_name = *(StringName *)&manifest.name;
_tool = manifest.is_tool;
_icon_path = *(String *)&manifest.icon_path;
Dictionary *members = (Dictionary *)&manifest.member_lines;
for (const Variant *key = members->next(); key != nullptr; key = members->next(key)) {
_member_lines[*key] = (*members)[*key];
}
Array *methods = (Array *)&manifest.methods;
_rpc_methods.clear();
if (_ref_base_parent.is_valid()) {
/// XXX TODO Should this be _rpc_methods.append_array(...)
_rpc_methods = _ref_base_parent->get_rpc_methods();
}
for (int i = 0; i < methods->size(); ++i) {
Dictionary v = (*methods)[i];
MethodInfo mi = MethodInfo::from_dict(v);
_methods_info[mi.name] = mi;
// rpc_mode is passed as an optional field and is not part of MethodInfo
Variant var = v["rpc_mode"];
if (var != Variant()) {
Multiplayer::RPCConfig nd;
nd.name = mi.name;
nd.rpc_mode = Multiplayer::RPCMode(int(var));
// TODO Transfer Channel
if (_rpc_methods.find(nd) == -1) {
_rpc_methods.push_back(nd);
}
}
}
// Sort so we are 100% that they are always the same.
_rpc_methods.sort_custom<Multiplayer::SortRPCConfig>();
Array *signals = (Array *)&manifest.signals;
for (int i = 0; i < signals->size(); ++i) {
Variant v = (*signals)[i];
MethodInfo mi = MethodInfo::from_dict(v);
_signals_info[mi.name] = mi;
}
Array *properties = (Array *)&manifest.properties;
for (int i = 0; i < properties->size(); ++i) {
Dictionary v = (*properties)[i];
PropertyInfo pi = PropertyInfo::from_dict(v);
_properties_info[pi.name] = pi;
_properties_default_values[pi.name] = v["default_value"];
}
FREE_SCRIPT_MANIFEST(manifest);
return OK;
#undef FREE_SCRIPT_MANIFEST
}
void PluginScript::get_script_method_list(List<MethodInfo> *r_methods) const {
ASSERT_SCRIPT_VALID();
for (Map<StringName, MethodInfo>::Element *e = _methods_info.front(); e != nullptr; e = e->next()) {
r_methods->push_back(e->get());
}
}
void PluginScript::get_script_property_list(List<PropertyInfo> *r_properties) const {
ASSERT_SCRIPT_VALID();
for (Map<StringName, PropertyInfo>::Element *e = _properties_info.front(); e != nullptr; e = e->next()) {
r_properties->push_back(e->get());
}
}
bool PluginScript::has_method(const StringName &p_method) const {
ASSERT_SCRIPT_VALID_V(false);
return _methods_info.has(p_method);
}
MethodInfo PluginScript::get_method_info(const StringName &p_method) const {
ASSERT_SCRIPT_VALID_V(MethodInfo());
const Map<StringName, MethodInfo>::Element *e = _methods_info.find(p_method);
if (e != nullptr) {
return e->get();
} else {
return MethodInfo();
}
}
bool PluginScript::has_property(const StringName &p_method) const {
ASSERT_SCRIPT_VALID_V(false);
return _properties_info.has(p_method);
}
PropertyInfo PluginScript::get_property_info(const StringName &p_property) const {
ASSERT_SCRIPT_VALID_V(PropertyInfo());
const Map<StringName, PropertyInfo>::Element *e = _properties_info.find(p_property);
if (e != nullptr) {
return e->get();
} else {
return PropertyInfo();
}
}
bool PluginScript::get_property_default_value(const StringName &p_property, Variant &r_value) const {
ASSERT_SCRIPT_VALID_V(false);
#ifdef TOOLS_ENABLED
const Map<StringName, Variant>::Element *e = _properties_default_values.find(p_property);
if (e != nullptr) {
r_value = e->get();
return true;
} else {
return false;
}
#endif
return false;
}
ScriptLanguage *PluginScript::get_language() const {
return _language;
}
Error PluginScript::load_source_code(const String &p_path) {
Vector<uint8_t> sourcef;
Error err;
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
ERR_FAIL_COND_V_MSG(err, err, "Cannot open file '" + p_path + "'.");
uint64_t len = f->get_length();
sourcef.resize(len + 1);
uint8_t *w = sourcef.ptrw();
uint64_t r = f->get_buffer(w, len);
f->close();
memdelete(f);
ERR_FAIL_COND_V(r != len, ERR_CANT_OPEN);
w[len] = 0;
String s;
if (s.parse_utf8((const char *)w)) {
ERR_FAIL_V_MSG(ERR_INVALID_DATA, "Script '" + p_path + "' contains invalid unicode (UTF-8), so it was not loaded. Please ensure that scripts are saved in valid UTF-8 unicode.");
}
_source = s;
#ifdef TOOLS_ENABLED
// source_changed_cache=true;
#endif
_path = p_path;
return OK;
}
bool PluginScript::has_script_signal(const StringName &p_signal) const {
ASSERT_SCRIPT_VALID_V(false);
return _signals_info.has(p_signal);
}
void PluginScript::get_script_signal_list(List<MethodInfo> *r_signals) const {
ASSERT_SCRIPT_VALID();
for (Map<StringName, MethodInfo>::Element *e = _signals_info.front(); e != nullptr; e = e->next()) {
r_signals->push_back(e->get());
}
}
int PluginScript::get_member_line(const StringName &p_member) const {
#ifdef TOOLS_ENABLED
if (_member_lines.has(p_member)) {
return _member_lines[p_member];
}
#endif
return -1;
}
const Vector<Multiplayer::RPCConfig> PluginScript::get_rpc_methods() const {
return _rpc_methods;
}
PluginScript::PluginScript() :
_script_list(this) {
}
void PluginScript::init(PluginScriptLanguage *language) {
_desc = &language->_desc.script_desc;
_language = language;
#ifdef DEBUG_ENABLED
_language->lock();
_language->_script_list.add(&_script_list);
_language->unlock();
#endif
}
PluginScript::~PluginScript() {
if (_desc && _data) {
_desc->finish(_data);
}
#ifdef DEBUG_ENABLED
if (_language) {
_language->lock();
_language->_script_list.remove(&_script_list);
_language->unlock();
}
#endif
}

View File

@ -1,146 +0,0 @@
/*************************************************************************/
/* pluginscript_script.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef PLUGINSCRIPT_SCRIPT_H
#define PLUGINSCRIPT_SCRIPT_H
// Godot imports
#include "core/doc_data.h"
#include "core/object/script_language.h"
// PluginScript imports
#include "pluginscript_language.h"
#include <pluginscript/godot_pluginscript.h>
class PluginScript : public Script {
GDCLASS(PluginScript, Script);
friend class PluginScriptInstance;
friend class PluginScriptLanguage;
private:
godot_pluginscript_script_data *_data = nullptr;
const godot_pluginscript_script_desc *_desc = nullptr;
PluginScriptLanguage *_language = nullptr;
bool _tool = false;
bool _valid = false;
Ref<Script> _ref_base_parent;
StringName _native_parent;
SelfList<PluginScript> _script_list;
Map<StringName, int> _member_lines;
Map<StringName, Variant> _properties_default_values;
Map<StringName, PropertyInfo> _properties_info;
Map<StringName, MethodInfo> _signals_info;
Map<StringName, MethodInfo> _methods_info;
Vector<Multiplayer::RPCConfig> _rpc_methods;
Set<Object *> _instances;
//exported members
String _source;
String _path;
StringName _name;
String _icon_path;
protected:
static void _bind_methods();
bool inherits_script(const Ref<Script> &p_script) const override;
PluginScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, Callable::CallError &r_error);
Variant _new(const Variant **p_args, int p_argcount, Callable::CallError &r_error);
#ifdef TOOLS_ENABLED
Set<PlaceHolderScriptInstance *> placeholders;
//void _update_placeholder(PlaceHolderScriptInstance *p_placeholder);
virtual void _placeholder_erased(PlaceHolderScriptInstance *p_placeholder) override;
#endif
public:
String get_script_class_name() const {
return _name;
}
String get_script_class_icon_path() const {
return _icon_path;
}
virtual bool can_instantiate() const override;
virtual Ref<Script> get_base_script() const override; //for script inheritance
virtual StringName get_instance_base_type() const override; // this may not work in all scripts, will return empty if so
virtual ScriptInstance *instance_create(Object *p_this) override;
virtual bool instance_has(const Object *p_this) const override;
virtual bool has_source_code() const override;
virtual String get_source_code() const override;
virtual void set_source_code(const String &p_code) override;
virtual Error reload(bool p_keep_state = false) override;
// TODO: load_source_code only allow utf-8 file, should handle bytecode as well ?
virtual Error load_source_code(const String &p_path);
#ifdef TOOLS_ENABLED
virtual const Vector<DocData::ClassDoc> &get_documentation() const override {
static Vector<DocData::ClassDoc> docs;
return docs;
}
#endif // TOOLS_ENABLED
virtual bool has_method(const StringName &p_method) const override;
virtual MethodInfo get_method_info(const StringName &p_method) const override;
bool has_property(const StringName &p_method) const;
PropertyInfo get_property_info(const StringName &p_property) const;
bool is_tool() const override { return _tool; }
bool is_valid() const override { return true; }
virtual ScriptLanguage *get_language() const override;
virtual bool has_script_signal(const StringName &p_signal) const override;
virtual void get_script_signal_list(List<MethodInfo> *r_signals) const override;
virtual bool get_property_default_value(const StringName &p_property, Variant &r_value) const override;
virtual void update_exports() override;
virtual void get_script_method_list(List<MethodInfo> *r_methods) const override;
virtual void get_script_property_list(List<PropertyInfo> *r_properties) const override;
virtual int get_member_line(const StringName &p_member) const override;
virtual const Vector<Multiplayer::RPCConfig> get_rpc_methods() const override;
PluginScript();
void init(PluginScriptLanguage *language);
virtual ~PluginScript();
};
#endif // PLUGINSCRIPT_SCRIPT_H

View File

@ -1,121 +0,0 @@
/*************************************************************************/
/* register_types.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_types.h"
#include "core/config/project_settings.h"
#include "core/io/dir_access.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/os/os.h"
#include "scene/main/scene_tree.h"
#include "pluginscript_language.h"
#include "pluginscript_script.h"
#include <pluginscript/godot_pluginscript.h>
static List<PluginScriptLanguage *> pluginscript_languages;
static Error _check_language_desc(const godot_pluginscript_language_desc *desc) {
ERR_FAIL_COND_V(!desc->name, ERR_BUG);
ERR_FAIL_COND_V(!desc->type, ERR_BUG);
ERR_FAIL_COND_V(!desc->extension, ERR_BUG);
ERR_FAIL_COND_V(!desc->recognized_extensions || !desc->recognized_extensions[0], ERR_BUG);
ERR_FAIL_COND_V(!desc->init, ERR_BUG);
ERR_FAIL_COND_V(!desc->finish, ERR_BUG);
// desc->reserved_words is not mandatory
// desc->comment_delimiters is not mandatory
// desc->string_delimiters is not mandatory
// desc->get_template_source_code is not mandatory
// desc->validate is not mandatory
// desc->get_template_source_code is not mandatory
// desc->validate is not mandatory
// desc->find_function is not mandatory
// desc->make_function is not mandatory
// desc->complete_code is not mandatory
// desc->auto_indent_code is not mandatory
ERR_FAIL_COND_V(!desc->add_global_constant, ERR_BUG);
// desc->debug_get_error is not mandatory
// desc->debug_get_stack_level_count is not mandatory
// desc->debug_get_stack_level_line is not mandatory
// desc->debug_get_stack_level_function is not mandatory
// desc->debug_get_stack_level_source is not mandatory
// desc->debug_get_stack_level_locals is not mandatory
// desc->debug_get_stack_level_members is not mandatory
// desc->debug_get_globals is not mandatory
// desc->debug_parse_stack_level_expression is not mandatory
// desc->profiling_start is not mandatory
// desc->profiling_stop is not mandatory
// desc->profiling_get_accumulated_data is not mandatory
// desc->profiling_get_frame_data is not mandatory
// desc->profiling_frame is not mandatory
ERR_FAIL_COND_V(!desc->script_desc.init, ERR_BUG);
ERR_FAIL_COND_V(!desc->script_desc.finish, ERR_BUG);
ERR_FAIL_COND_V(!desc->script_desc.instance_desc.init, ERR_BUG);
ERR_FAIL_COND_V(!desc->script_desc.instance_desc.finish, ERR_BUG);
ERR_FAIL_COND_V(!desc->script_desc.instance_desc.set_prop, ERR_BUG);
ERR_FAIL_COND_V(!desc->script_desc.instance_desc.get_prop, ERR_BUG);
ERR_FAIL_COND_V(!desc->script_desc.instance_desc.call_method, ERR_BUG);
ERR_FAIL_COND_V(!desc->script_desc.instance_desc.notification, ERR_BUG);
// desc->script_desc.instance_desc.refcount_incremented is not mandatory
// desc->script_desc.instance_desc.refcount_decremented is not mandatory
return OK;
}
void GDAPI godot_pluginscript_register_language(const godot_pluginscript_language_desc *language_desc) {
Error ret = _check_language_desc(language_desc);
if (ret) {
ERR_FAIL();
}
PluginScriptLanguage *language = memnew(PluginScriptLanguage(language_desc));
ScriptServer::register_language(language);
ResourceLoader::add_resource_format_loader(language->get_resource_loader());
ResourceSaver::add_resource_format_saver(language->get_resource_saver());
pluginscript_languages.push_back(language);
}
void register_pluginscript_types() {
GDREGISTER_CLASS(PluginScript);
}
void unregister_pluginscript_types() {
for (List<PluginScriptLanguage *>::Element *e = pluginscript_languages.front(); e; e = e->next()) {
PluginScriptLanguage *language = e->get();
ScriptServer::unregister_language(language);
ResourceLoader::remove_resource_format_loader(language->get_resource_loader());
ResourceSaver::remove_resource_format_saver(language->get_resource_saver());
memdelete(language);
}
}

View File

@ -1,37 +0,0 @@
/*************************************************************************/
/* register_types.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef PLUGINSCRIPT_REGISTER_TYPES_H
#define PLUGINSCRIPT_REGISTER_TYPES_H
void register_pluginscript_types();
void unregister_pluginscript_types();
#endif // PLUGINSCRIPT_REGISTER_TYPES_H

View File

@ -1,360 +0,0 @@
/*************************************************************************/
/* register_types.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "register_types.h"
#include "gdnative/gdnative.h"
#include "gdnative.h"
#include "nativescript/register_types.h"
#include "pluginscript/register_types.h"
#include "videodecoder/register_types.h"
#include "core/config/engine.h"
#include "core/config/project_settings.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/os/os.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_export.h"
#include "editor/editor_node.h"
#include "gdnative_library_editor_plugin.h"
#include "gdnative_library_singleton_editor.h"
class GDNativeExportPlugin : public EditorExportPlugin {
protected:
virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features);
};
struct LibrarySymbol {
const char *name;
bool is_required;
};
void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) {
if (p_type != "GDNativeLibrary") {
return;
}
Ref<GDNativeLibrary> lib = ResourceLoader::load(p_path);
if (lib.is_null()) {
return;
}
Ref<ConfigFile> config = lib->get_config_file();
{
List<String> entry_keys;
config->get_section_keys("entry", &entry_keys);
for (const String &key : entry_keys) {
Vector<String> tags = key.split(".");
bool skip = false;
for (int i = 0; i < tags.size(); i++) {
bool has_feature = p_features.has(tags[i]);
if (!has_feature) {
skip = true;
break;
}
}
if (skip) {
continue;
}
String entry_lib_path = config->get_value("entry", key);
if (!entry_lib_path.begins_with("res://")) {
print_line("Skipping export of out-of-project library " + entry_lib_path);
continue;
}
add_shared_object(entry_lib_path, tags);
}
}
{
List<String> dependency_keys;
config->get_section_keys("dependencies", &dependency_keys);
for (const String &key : dependency_keys) {
Vector<String> tags = key.split(".");
bool skip = false;
for (int i = 0; i < tags.size(); i++) {
bool has_feature = p_features.has(tags[i]);
if (!has_feature) {
skip = true;
break;
}
}
if (skip) {
continue;
}
Vector<String> dependency_paths = config->get_value("dependencies", key);
for (int i = 0; i < dependency_paths.size(); i++) {
if (!dependency_paths[i].begins_with("res://")) {
print_line("Skipping export of out-of-project library " + dependency_paths[i]);
continue;
}
add_shared_object(dependency_paths[i], tags);
}
}
}
// Add symbols for statically linked libraries on iOS
if (p_features.has("iOS")) {
bool should_fake_dynamic = false;
List<String> entry_keys;
config->get_section_keys("entry", &entry_keys);
for (const String &key : entry_keys) {
Vector<String> tags = key.split(".");
bool skip = false;
for (int i = 0; i < tags.size(); i++) {
bool has_feature = p_features.has(tags[i]);
if (!has_feature) {
skip = true;
break;
}
}
if (skip) {
continue;
}
String entry_lib_path = config->get_value("entry", key);
if (entry_lib_path.begins_with("res://") && entry_lib_path.ends_with(".a")) {
// If we find static library that was used for export
// we should add a fake lookup table.
// In case of dynamic library being used,
// this symbols will not cause any issues with library loading.
should_fake_dynamic = true;
break;
}
}
if (should_fake_dynamic) {
// Register symbols in the "fake" dynamic lookup table, because dlsym does not work well on iOS.
LibrarySymbol expected_symbols[] = {
{ "gdnative_init", true },
{ "gdnative_terminate", false },
{ "nativescript_init", false },
{ "nativescript_frame", false },
{ "nativescript_thread_enter", false },
{ "nativescript_thread_exit", false },
{ "gdnative_singleton", false }
};
String declare_pattern = "extern \"C\" void $name(void)$weak;\n";
String additional_code = "extern void register_dynamic_symbol(char *name, void *address);\n"
"extern void add_ios_init_callback(void (*cb)());\n";
String linker_flags = "";
for (unsigned long i = 0; i < sizeof(expected_symbols) / sizeof(expected_symbols[0]); ++i) {
String full_name = lib->get_symbol_prefix() + expected_symbols[i].name;
String code = declare_pattern.replace("$name", full_name);
code = code.replace("$weak", expected_symbols[i].is_required ? "" : " __attribute__((weak))");
additional_code += code;
if (!expected_symbols[i].is_required) {
if (linker_flags.length() > 0) {
linker_flags += " ";
}
linker_flags += "-Wl,-U,_" + full_name;
}
}
additional_code += String("void $prefixinit() {\n").replace("$prefix", lib->get_symbol_prefix());
String register_pattern = " if (&$name) register_dynamic_symbol((char *)\"$name\", (void *)$name);\n";
for (unsigned long i = 0; i < sizeof(expected_symbols) / sizeof(expected_symbols[0]); ++i) {
String full_name = lib->get_symbol_prefix() + expected_symbols[i].name;
additional_code += register_pattern.replace("$name", full_name);
}
additional_code += "}\n";
additional_code += String("struct $prefixstruct {$prefixstruct() {add_ios_init_callback($prefixinit);}};\n").replace("$prefix", lib->get_symbol_prefix());
additional_code += String("$prefixstruct $prefixstruct_instance;\n").replace("$prefix", lib->get_symbol_prefix());
add_ios_cpp_code(additional_code);
add_ios_linker_flags(linker_flags);
}
}
}
static void editor_init_callback() {
GDNativeLibrarySingletonEditor *library_editor = memnew(GDNativeLibrarySingletonEditor);
library_editor->set_name(TTR("GDNative"));
ProjectSettingsEditor::get_singleton()->get_tabs()->add_child(library_editor);
Ref<GDNativeExportPlugin> export_plugin;
export_plugin.instantiate();
EditorExport::get_singleton()->add_export_plugin(export_plugin);
EditorNode::get_singleton()->add_editor_plugin(memnew(GDNativeLibraryEditorPlugin));
}
#endif
static godot_variant cb_standard_varcall(void *p_procedure_handle, godot_array *p_args) {
godot_gdnative_procedure_fn proc;
proc = (godot_gdnative_procedure_fn)p_procedure_handle;
return proc(p_args);
}
GDNativeCallRegistry *GDNativeCallRegistry::singleton;
Vector<Ref<GDNative>> singleton_gdnatives;
Ref<GDNativeLibraryResourceLoader> resource_loader_gdnlib;
Ref<GDNativeLibraryResourceSaver> resource_saver_gdnlib;
void register_gdnative_types() {
#ifdef TOOLS_ENABLED
EditorNode::add_init_callback(editor_init_callback);
#endif
GDREGISTER_CLASS(GDNativeLibrary);
GDREGISTER_CLASS(GDNative);
resource_loader_gdnlib.instantiate();
ResourceLoader::add_resource_format_loader(resource_loader_gdnlib);
resource_saver_gdnlib.instantiate();
ResourceSaver::add_resource_format_saver(resource_saver_gdnlib);
GDNativeCallRegistry::singleton = memnew(GDNativeCallRegistry);
GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall);
register_nativescript_types();
register_pluginscript_types();
register_videodecoder_types();
// run singletons
Array singletons = Array();
if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons")) {
singletons = ProjectSettings::get_singleton()->get("gdnative/singletons");
}
Array excluded = Array();
if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons_disabled")) {
excluded = ProjectSettings::get_singleton()->get("gdnative/singletons_disabled");
}
for (int i = 0; i < singletons.size(); i++) {
String path = singletons[i];
if (excluded.has(path)) {
continue;
}
Ref<GDNativeLibrary> lib = ResourceLoader::load(path);
Ref<GDNative> singleton;
singleton.instantiate();
singleton->set_library(lib);
if (!singleton->initialize()) {
// Can't initialize. Don't make a native_call then
continue;
}
void *proc_ptr;
Error err = singleton->get_symbol(
lib->get_symbol_prefix() + "gdnative_singleton",
proc_ptr);
if (err != OK) {
ERR_PRINT("No " + lib->get_symbol_prefix() + "gdnative_singleton in \"" + singleton->get_library()->get_current_library_path() + "\" found");
} else {
singleton_gdnatives.push_back(singleton);
((void (*)())proc_ptr)();
}
}
}
void unregister_gdnative_types() {
for (int i = 0; i < singleton_gdnatives.size(); i++) {
if (singleton_gdnatives[i].is_null()) {
continue;
}
if (!singleton_gdnatives[i]->is_initialized()) {
continue;
}
singleton_gdnatives.write[i]->terminate();
}
singleton_gdnatives.clear();
unregister_videodecoder_types();
unregister_pluginscript_types();
unregister_nativescript_types();
memdelete(GDNativeCallRegistry::singleton);
ResourceLoader::remove_resource_format_loader(resource_loader_gdnlib);
resource_loader_gdnlib.unref();
ResourceSaver::remove_resource_format_saver(resource_saver_gdnlib);
resource_saver_gdnlib.unref();
// This is for printing out the sizes of the core types
/*
print_line(String("array:\t") + itos(sizeof(Array)));
print_line(String("basis:\t") + itos(sizeof(Basis)));
print_line(String("color:\t") + itos(sizeof(Color)));
print_line(String("dict:\t" ) + itos(sizeof(Dictionary)));
print_line(String("node_path:\t") + itos(sizeof(NodePath)));
print_line(String("plane:\t") + itos(sizeof(Plane)));
print_line(String("poolarray:\t") + itos(sizeof(PackedByteArray)));
print_line(String("quat:\t") + itos(sizeof(Quat)));
print_line(String("rect2:\t") + itos(sizeof(Rect2)));
print_line(String("aabb:\t") + itos(sizeof(AABB)));
print_line(String("rid:\t") + itos(sizeof(RID)));
print_line(String("string:\t") + itos(sizeof(String)));
print_line(String("transform:\t") + itos(sizeof(Transform3D)));
print_line(String("transfo2D:\t") + itos(sizeof(Transform2D)));
print_line(String("variant:\t") + itos(sizeof(Variant)));
print_line(String("vector2:\t") + itos(sizeof(Vector2)));
print_line(String("vector3:\t") + itos(sizeof(Vector3)));
*/
}

View File

@ -1,37 +0,0 @@
/*************************************************************************/
/* register_types.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef GDNATIVE_REGISTER_TYPES_H
#define GDNATIVE_REGISTER_TYPES_H
void register_gdnative_types();
void unregister_gdnative_types();
#endif // GDNATIVE_REGISTER_TYPES_H

View File

@ -1,205 +0,0 @@
/*************************************************************************/
/* test_variant.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#ifndef TEST_GDNATIVE_VARIANT_H
#define TEST_GDNATIVE_VARIANT_H
#include <gdnative/gdnative.h>
#include <gdnative/variant.h>
#include "tests/test_macros.h"
namespace TestGDNativeVariant {
TEST_CASE("[GDNative Variant] New Variant with copy") {
godot_variant src;
godot_variant_new_int(&src, 42);
godot_variant copy;
godot_variant_new_copy(&copy, &src);
CHECK(godot_variant_as_int(&copy) == 42);
CHECK(godot_variant_get_type(&copy) == GODOT_VARIANT_TYPE_INT);
godot_variant_destroy(&src);
godot_variant_destroy(&copy);
}
TEST_CASE("[GDNative Variant] New Variant with Nil") {
godot_variant val;
godot_variant_new_nil(&val);
CHECK(godot_variant_get_type(&val) == GODOT_VARIANT_TYPE_NIL);
godot_variant_destroy(&val);
}
TEST_CASE("[GDNative Variant] New Variant with bool") {
godot_variant val;
godot_variant_new_bool(&val, true);
CHECK(godot_variant_as_bool(&val));
CHECK(godot_variant_get_type(&val) == GODOT_VARIANT_TYPE_BOOL);
godot_variant_destroy(&val);
}
TEST_CASE("[GDNative Variant] New Variant with float") {
godot_variant val;
godot_variant_new_float(&val, 4.2);
CHECK(godot_variant_as_float(&val) == 4.2);
CHECK(godot_variant_get_type(&val) == GODOT_VARIANT_TYPE_FLOAT);
godot_variant_destroy(&val);
}
TEST_CASE("[GDNative Variant] New Variant with String") {
String str = "something";
godot_variant val;
godot_variant_new_string(&val, (godot_string *)&str);
godot_string gd_str = godot_variant_as_string(&val);
String *result = (String *)&gd_str;
CHECK(*result == String("something"));
CHECK(godot_variant_get_type(&val) == GODOT_VARIANT_TYPE_STRING);
godot_variant_destroy(&val);
godot_string_destroy(&gd_str);
}
TEST_CASE("[GDNative Variant] Variant call") {
String str("something");
godot_variant self;
godot_variant_new_string(&self, (godot_string *)&str);
godot_variant ret;
godot_string_name method;
godot_string_name_new_with_latin1_chars(&method, "is_valid_identifier");
godot_variant_call_error error;
godot_variant_call(&self, &method, nullptr, 0, &ret, &error);
CHECK(godot_variant_get_type(&ret) == GODOT_VARIANT_TYPE_BOOL);
CHECK(godot_variant_as_bool(&ret));
godot_variant_destroy(&ret);
godot_variant_destroy(&self);
godot_string_name_destroy(&method);
}
TEST_CASE("[GDNative Variant] Variant evaluate") {
godot_variant one;
godot_variant_new_int(&one, 1);
godot_variant two;
godot_variant_new_int(&two, 2);
godot_variant three;
godot_variant_new_nil(&three);
bool valid = false;
godot_variant_evaluate(GODOT_VARIANT_OP_ADD, &one, &two, &three, &valid);
CHECK(godot_variant_get_type(&three) == GODOT_VARIANT_TYPE_INT);
CHECK(godot_variant_as_int(&three) == 3);
CHECK(valid);
godot_variant_destroy(&one);
godot_variant_destroy(&two);
godot_variant_destroy(&three);
}
TEST_CASE("[GDNative Variant] Variant set/get named") {
godot_string_name x;
godot_string_name_new_with_latin1_chars(&x, "x");
Vector2 vec(0, 0);
godot_variant self;
godot_variant_new_vector2(&self, (godot_vector2 *)&vec);
godot_variant set;
godot_variant_new_float(&set, 1.0);
bool set_valid = false;
godot_variant_set_named(&self, &x, &set, &set_valid);
bool get_valid = false;
godot_variant get = godot_variant_get_named(&self, &x, &get_valid);
CHECK(get_valid);
CHECK(set_valid);
CHECK(godot_variant_get_type(&get) == GODOT_VARIANT_TYPE_FLOAT);
CHECK(godot_variant_as_float(&get) == 1.0);
godot_string_name_destroy(&x);
godot_variant_destroy(&self);
godot_variant_destroy(&set);
godot_variant_destroy(&get);
}
TEST_CASE("[GDNative Variant] Get utility function argument name") {
godot_string_name function;
godot_string_name_new_with_latin1_chars(&function, "pow");
godot_string arg_name = godot_variant_get_utility_function_argument_name(&function, 0);
String *arg_name_str = (String *)&arg_name;
CHECK(*arg_name_str == "base");
godot_string_destroy(&arg_name);
godot_string_name_destroy(&function);
}
TEST_CASE("[GDNative Variant] Get utility function list") {
int count = godot_variant_get_utility_function_count();
godot_string_name *c_list = (godot_string_name *)godot_alloc(count * sizeof(godot_string_name));
godot_variant_get_utility_function_list(c_list);
List<StringName> cpp_list;
Variant::get_utility_function_list(&cpp_list);
godot_string_name *cur = c_list;
for (const StringName &E : cpp_list) {
const StringName &cpp_name = E;
StringName *c_name = (StringName *)cur++;
CHECK(*c_name == cpp_name);
}
godot_free(c_list);
}
} // namespace TestGDNativeVariant
#endif // TEST_GDNATIVE_VARIANT_H

Some files were not shown because too many files have changed in this diff Show More