Skip to content

Commit

Permalink
Implement native extension system
Browse files Browse the repository at this point in the history
* Deprecates GDNative in favor of a simpler, lower level interface.
* New extension system allows registering core engine classes.
* Simple header interface in gdnative_interace.h
  • Loading branch information
reduz committed Jun 25, 2021
1 parent c8444c3 commit b1d15c5
Show file tree
Hide file tree
Showing 50 changed files with 3,308 additions and 216 deletions.
1 change: 1 addition & 0 deletions core/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ SConscript("io/SCsub")
SConscript("debugger/SCsub")
SConscript("input/SCsub")
SConscript("variant/SCsub")
SConscript("extension/SCsub")
SConscript("object/SCsub")
SConscript("templates/SCsub")
SConscript("string/SCsub")
Expand Down
5 changes: 3 additions & 2 deletions core/config/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,10 @@ Engine::Engine() {
singleton = this;
}

Engine::Singleton::Singleton(const StringName &p_name, Object *p_ptr) :
Engine::Singleton::Singleton(const StringName &p_name, Object *p_ptr, const StringName &p_class_name) :
name(p_name),
ptr(p_ptr) {
ptr(p_ptr),
class_name(p_class_name) {
#ifdef DEBUG_ENABLED
RefCounted *rc = Object::cast_to<RefCounted>(p_ptr);
if (rc && !rc->is_referenced()) {
Expand Down
3 changes: 2 additions & 1 deletion core/config/engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class Engine {
struct Singleton {
StringName name;
Object *ptr;
Singleton(const StringName &p_name = StringName(), Object *p_ptr = nullptr);
StringName class_name; //used for binding generation hinting
Singleton(const StringName &p_name = StringName(), Object *p_ptr = nullptr, const StringName &p_class_name = StringName());
};

private:
Expand Down
7 changes: 7 additions & 0 deletions core/extension/SCsub
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env python

Import("env")

env_extension = env.Clone()

env_extension.add_source_files(env.core_sources, "*.cpp")
805 changes: 805 additions & 0 deletions core/extension/extension_api_dump.cpp

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions core/extension/extension_api_dump.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*************************************************************************/
/* extension_api_dump.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2021 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_DUMP_H
#define API_DUMP_H

#include "core/extension/native_extension.h"

#ifdef TOOLS_ENABLED

class NativeExtensionAPIDump {
public:
static Dictionary generate_extension_api();
static void generate_extension_json_file(const String &p_path);
};
#endif

#endif // API_DUMP_H
Loading

0 comments on commit b1d15c5

Please sign in to comment.