Implemented using api struct

pull/47/head
Bastiaan Olij 2017-10-21 10:42:10 +11:00
parent f24ecfc74d
commit 6452ba6e88
22 changed files with 380 additions and 403 deletions

1
.gitignore vendored
View File

@ -1,6 +1,7 @@
src/*.cpp
src/*.hpp
include/*.hpp
logs/*
*.o
*.os
*.so

View File

@ -3,14 +3,11 @@ import os, subprocess
# Local dependency paths, adapt them to your setup
godot_headers_path = ARGUMENTS.get("headers", "../godot_headers/")
godot_bin_path = ARGUMENTS.get("godotbinpath", "../godot_fork/bin/")
# for windows
godot_lib_path = ARGUMENTS.get("godotlibpath", godot_bin_path)
godot_headers_path = ARGUMENTS.get("headers", os.getenv("GODOT_HEADERS", "../godot_headers/"))
godot_bin_path = ARGUMENTS.get("godotbinpath", os.getenv("GODOT_BIN_PATH", "../godot_fork/bin/"))
target = ARGUMENTS.get("target", "debug")
platform = ARGUMENTS.get("p", "linux")
platform = ARGUMENTS.get("p", ARGUMENTS.get("platform", "linux"))
# This makes sure to keep the session environment variables on windows,
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
@ -23,7 +20,6 @@ if ARGUMENTS.get("use_llvm", "no") == "yes":
godot_name = "godot." + ("x11" if platform == "linux" else platform) + ".tools.64"
def add_sources(sources, directory):
for file in os.listdir(directory):
if file.endswith('.cpp'):
@ -44,13 +40,10 @@ if platform == "windows":
env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '/MDd'])
else:
env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '/MD'])
env.Append(LIBS=[godot_name])
env.Append(LIBPATH=[godot_lib_path])
sources = []
add_sources(sources, "src/core")
if ARGUMENTS.get("generate_bindings", "no") == "yes":
godot_executable = godot_bin_path + godot_name
@ -72,7 +65,6 @@ if ARGUMENTS.get("generate_bindings", "no") == "yes":
binding_generator.generate_bindings(json_api_file)
add_sources(sources, "src")
library = env.StaticLibrary(target='bin/godot_cpp_bindings', source=sources)

View File

@ -66,7 +66,7 @@ def generate_class_header(used_classes, c):
source.append("")
source.append("")
source.append("#include <gdnative/gdnative.h>")
source.append("#include <gdnative_api_struct.gen.h>")
source.append("#include <stdint.h>")
source.append("")
@ -240,6 +240,7 @@ def generate_class_implementation(icalls, used_classes, c):
source.append("")
source.append("")
source.append("#include <GodotGlobal.hpp>")
source.append("#include <CoreTypes.hpp>")
source.append("#include <Ref.hpp>")
@ -278,7 +279,7 @@ def generate_class_implementation(icalls, used_classes, c):
source.append("static inline void ___singleton_init()")
source.append("{")
source.append("\tif (" + core_object_name + " == nullptr) {")
source.append("\t\t" + core_object_name + " = godot_global_get_singleton((char *) \"" + strip_name(c["name"]) + "\");")
source.append("\t\t" + core_object_name + " = godot::api->godot_global_get_singleton((char *) \"" + strip_name(c["name"]) + "\");")
source.append("\t}")
source.append("}")
@ -290,12 +291,12 @@ def generate_class_implementation(icalls, used_classes, c):
if c["instanciable"]:
source.append("void *" + strip_name(c["name"]) + "::operator new(size_t)")
source.append("{")
source.append("\treturn godot_get_class_constructor((char *)\"" + c["name"] + "\")();")
source.append("\treturn godot::api->godot_get_class_constructor((char *)\"" + c["name"] + "\")();")
source.append("}")
source.append("void " + strip_name(c["name"]) + "::operator delete(void *ptr)")
source.append("{")
source.append("\tgodot_object_destroy((godot_object *)ptr);")
source.append("\tgodot::api->godot_object_destroy((godot_object *)ptr);")
source.append("}")
for method in c["methods"]:
@ -328,7 +329,7 @@ def generate_class_implementation(icalls, used_classes, c):
source.append("\tstatic godot_method_bind *mb = NULL;")
source.append("\tif (mb == NULL) {")
source.append("\t\tmb = godot_method_bind_get_method(\"" + c["name"] +"\", \"" + method["name"] + "\");")
source.append("\t\tmb = godot::api->godot_method_bind_get_method(\"" + c["name"] +"\", \"" + method["name"] + "\");")
source.append("\t}")
return_statement = ""
@ -359,7 +360,7 @@ def generate_class_implementation(icalls, used_classes, c):
source.append("\tVariant __given_args[" + str(len(method["arguments"])) + "];")
for i, argument in enumerate(method["arguments"]):
source.append("\tgodot_variant_new_nil((godot_variant *) &__given_args[" + str(i) + "]);")
source.append("\tgodot::api->godot_variant_new_nil((godot_variant *) &__given_args[" + str(i) + "]);")
source.append("")
@ -392,13 +393,13 @@ def generate_class_implementation(icalls, used_classes, c):
source.append("")
source.append("\tVariant __result;")
source.append("\t*(godot_variant *) &__result = godot_method_bind_call(mb, (godot_object *) " + core_object_name + ", (const godot_variant **) __args, " + size + ", nullptr);")
source.append("\t*(godot_variant *) &__result = godot::api->godot_method_bind_call(mb, (godot_object *) " + core_object_name + ", (const godot_variant **) __args, " + size + ", nullptr);")
source.append("")
for i, argument in enumerate(method["arguments"]):
source.append("\tgodot_variant_destroy((godot_variant *) &__given_args[" + str(i) + "]);")
source.append("\tgodot::api->godot_variant_destroy((godot_variant *) &__given_args[" + str(i) + "]);")
source.append("")
@ -460,7 +461,7 @@ def generate_icall_header(icalls):
source.append("")
source.append("#include <gdnative/gdnative.h>")
source.append("#include <gdnative_api_struct.gen.h>")
source.append("#include <stdint.h>")
source.append("")
@ -510,10 +511,11 @@ def generate_icall_implementation(icalls):
source.append("")
source.append("#include <gdnative/gdnative.h>")
source.append("#include <gdnative_api_struct.gen.h>")
source.append("#include <stdint.h>")
source.append("")
source.append("#include <GodotGlobal.hpp>")
source.append("#include <CoreTypes.hpp>")
source.append("#include <Object.hpp>")
source.append("")
@ -568,7 +570,7 @@ def generate_icall_implementation(icalls):
source.append("\t};")
source.append("")
source.append("\tgodot_method_bind_ptrcall(mb, inst, args, " + ("nullptr" if ret_type == "void" else "&ret") + ");")
source.append("\tgodot::api->godot_method_bind_ptrcall(mb, inst, args, " + ("nullptr" if ret_type == "void" else "&ret") + ");")
if ret_type != "void":
source.append("\treturn ret;")

View File

@ -4,7 +4,7 @@
#include <cstdlib>
#include <cstring>
#include <gdnative/gdnative.h>
#include <gdnative_api_struct.gen.h>
#include <nativescript/godot_nativescript.h>
@ -86,7 +86,7 @@ struct _ArgCast<Variant> {
template<class T>
T *as(Object *obj)
{
return (T *) godot_nativescript_get_userdata(obj);
return (T *) godot::api->godot_nativescript_get_userdata(obj);
}
// instance and destroy funcs
@ -118,7 +118,7 @@ void register_class()
destroy.destroy_func = _godot_class_destroy_func<T>;
godot_nativescript_register_class(godot::_RegisterState::nativescript_handle, T::___get_type_name(), T::___get_base_type_name(), create, destroy);
godot::api->godot_nativescript_register_class(godot::_RegisterState::nativescript_handle, T::___get_type_name(), T::___get_base_type_name(), create, destroy);
T::_register_methods();
}
@ -132,7 +132,7 @@ void register_tool_class()
destroy.destroy_func = _godot_class_destroy_func<T>;
godot_nativescript_register_tool_class(godot::_RegisterState::nativescript_handle, T::___get_type_name(), T::___get_base_type_name(), create, destroy);
godot::api->godot_nativescript_register_tool_class(godot::_RegisterState::nativescript_handle, T::___get_type_name(), T::___get_base_type_name(), create, destroy);
T::_register_methods();
}
@ -216,7 +216,7 @@ template<class T, class R, class... As>
godot_variant __wrapped_method(godot_object *, void *method_data, void *user_data, int num_args, godot_variant **args)
{
godot_variant v;
godot_variant_new_nil(&v);
godot::api->godot_variant_new_nil(&v);
T *obj = (T *) user_data;
_WrappedMethod<T, R, As...> *method = (_WrappedMethod<T, R, As...>*) method_data;
@ -233,7 +233,7 @@ template<class T, class R, class... As>
void *___make_wrapper_function(R (T::*f)(As...))
{
using MethodType = _WrappedMethod<T, R, As...>;
MethodType *p = (MethodType *) godot_alloc(sizeof(MethodType));
MethodType *p = (MethodType *) godot::api->godot_alloc(sizeof(MethodType));
p->f = f;
return (void *) p;
}
@ -278,14 +278,14 @@ void register_method(const char *name, M method_ptr, godot_method_rpc_mode rpc_t
{
godot_instance_method method = {};
method.method_data = ___make_wrapper_function(method_ptr);
method.free_func = godot_free;
method.free_func = godot::api->godot_free;
method.method = (__godot_wrapper_method) ___get_wrapper_function(method_ptr);
godot_method_attributes attr = {};
attr.rpc_type = rpc_type;
godot_nativescript_register_method(godot::_RegisterState::nativescript_handle, ___get_method_class_name(method_ptr), name, attr, method);
godot::api->godot_nativescript_register_method(godot::_RegisterState::nativescript_handle, ___get_method_class_name(method_ptr), name, attr, method);
}
@ -313,7 +313,7 @@ struct _PropertyGetFunc {
T *obj = (T *) user_data;
godot_variant var;
godot_variant_new_nil(&var);
godot::api->godot_variant_new_nil(&var);
Variant *v = (Variant *) &var;
@ -351,7 +351,7 @@ struct _PropertyDefaultGetFunc {
T *obj = (T *) user_data;
godot_variant var;
godot_variant_new_nil(&var);
godot::api->godot_variant_new_nil(&var);
Variant *v = (Variant *) &var;
@ -387,23 +387,23 @@ void register_property(const char *name, P (T::*var), P default_value, godot_met
attr.usage = usage;
attr.hint_string = *_hint_string;
_PropertyDefaultSetFunc<T, P> *wrapped_set = (_PropertyDefaultSetFunc<T, P> *) godot_alloc(sizeof(_PropertyDefaultSetFunc<T, P>));
_PropertyDefaultSetFunc<T, P> *wrapped_set = (_PropertyDefaultSetFunc<T, P> *)godot::api->godot_alloc(sizeof(_PropertyDefaultSetFunc<T, P>));
wrapped_set->f = var;
_PropertyDefaultGetFunc<T, P> *wrapped_get = (_PropertyDefaultGetFunc<T, P> *) godot_alloc(sizeof(_PropertyDefaultGetFunc<T, P>));
_PropertyDefaultGetFunc<T, P> *wrapped_get = (_PropertyDefaultGetFunc<T, P> *) godot::api->godot_alloc(sizeof(_PropertyDefaultGetFunc<T, P>));
wrapped_get->f = var;
godot_property_set_func set_func = {};
set_func.method_data = (void *) wrapped_set;
set_func.free_func = godot_free;
set_func.free_func = godot::api->godot_free;
set_func.set_func = &_PropertyDefaultSetFunc<T, P>::_wrapped_setter;
godot_property_get_func get_func = {};
get_func.method_data = (void *) wrapped_get;
get_func.free_func = godot_free;
get_func.free_func = godot::api->godot_free;
get_func.get_func = &_PropertyDefaultGetFunc<T, P>::_wrapped_getter;
godot_nativescript_register_property(godot::_RegisterState::nativescript_handle, T::___get_type_name(), name, &attr, set_func, get_func);
godot::api->godot_nativescript_register_property(godot::_RegisterState::nativescript_handle, T::___get_type_name(), name, &attr, set_func, get_func);
}
@ -421,23 +421,23 @@ void register_property(const char *name, void (T::*setter)(P), P (T::*getter)(),
attr.rset_type = rpc_mode;
attr.usage = usage;
_PropertySetFunc<T, P> *wrapped_set = (_PropertySetFunc<T, P> *) godot_alloc(sizeof(_PropertySetFunc<T, P>));
_PropertySetFunc<T, P> *wrapped_set = (_PropertySetFunc<T, P> *) godot::api->godot_alloc(sizeof(_PropertySetFunc<T, P>));
wrapped_set->f = setter;
_PropertyGetFunc<T, P> *wrapped_get = (_PropertyGetFunc<T, P> *) godot_alloc(sizeof(_PropertyGetFunc<T, P>));
_PropertyGetFunc<T, P> *wrapped_get = (_PropertyGetFunc<T, P> *) godot::api->godot_alloc(sizeof(_PropertyGetFunc<T, P>));
wrapped_get->f = getter;
godot_property_set_func set_func = {};
set_func.method_data = (void *) wrapped_set;
set_func.free_func = godot_free;
set_func.free_func = godot::api->godot_free;
set_func.set_func = &_PropertySetFunc<T, P>::_wrapped_setter;
godot_property_get_func get_func = {};
get_func.method_data = (void *) wrapped_get;
get_func.free_func = godot_free;
get_func.free_func = godot::api->godot_free;
get_func.get_func = &_PropertyGetFunc<T, P>::_wrapped_getter;
godot_nativescript_register_property(godot::_RegisterState::nativescript_handle, T::___get_type_name(), name, &attr, set_func, get_func);
godot::api->godot_nativescript_register_property(godot::_RegisterState::nativescript_handle, T::___get_type_name(), name, &attr, set_func, get_func);
}
@ -449,7 +449,7 @@ void register_signal(String name, Dictionary args = Dictionary())
signal.num_args = args.size();
signal.num_default_args = 0;
signal.args = (godot_signal_argument*) godot_alloc(sizeof(godot_signal_argument) * signal.num_args);
signal.args = (godot_signal_argument*) godot::api->godot_alloc(sizeof(godot_signal_argument) * signal.num_args);
memset((void *) signal.args, 0, sizeof(godot_signal_argument) * signal.num_args);
@ -458,7 +458,7 @@ void register_signal(String name, Dictionary args = Dictionary())
// String name = entry[0];
String name = args.keys()[i];
godot_string *_key = (godot_string *)&name;
godot_string_new_copy(&signal.args[i].name, _key);
godot::api->godot_string_new_copy(&signal.args[i].name, _key);
// if (entry.size() > 1) {
// signal.args[i].type = entry[1];
@ -466,13 +466,13 @@ void register_signal(String name, Dictionary args = Dictionary())
signal.args[i].type = args.values()[i];
}
godot_nativescript_register_signal(godot::_RegisterState::nativescript_handle, T::___get_type_name(), &signal);
godot::api->godot_nativescript_register_signal(godot::_RegisterState::nativescript_handle, T::___get_type_name(), &signal);
for (int i = 0; i < signal.num_args; i++) {
godot_string_destroy(&signal.args[i].name);
godot::api->godot_string_destroy(&signal.args[i].name);
}
godot_free(signal.args);
godot::api->godot_free(signal.args);
}

View File

@ -1,11 +1,14 @@
#ifndef GODOT_GLOBAL_HPP
#define GODOT_GLOBAL_HPP
#include <gdnative_api_struct.gen.h>
#include "String.hpp"
namespace godot {
extern "C" const godot_gdnative_api_struct *api;
class Godot {
public:

View File

@ -2,6 +2,7 @@
#define REF_H
#include "Variant.hpp"
#include "GodotGlobal.hpp"
namespace godot {
@ -156,7 +157,7 @@ public:
void unref()
{
if (reference && reference->unreference()) {
godot_object_destroy((godot_object *) reference);
godot::api->godot_object_destroy((godot_object *) reference);
}
reference = nullptr;
}

View File

@ -1,56 +1,56 @@
#include "Array.hpp"
#include "Variant.hpp"
#include "GodotGlobal.hpp"
#include <cstdlib>
#include "Variant.hpp"
namespace godot {
class Object;
Array::Array()
{
godot_array_new(&_godot_array);
godot::api->godot_array_new(&_godot_array);
}
Array::Array(const PoolByteArray& a)
{
godot_array_new_pool_byte_array(&_godot_array, (godot_pool_byte_array *) &a);
godot::api->godot_array_new_pool_byte_array(&_godot_array, (godot_pool_byte_array *) &a);
}
Array::Array(const PoolIntArray& a)
{
godot_array_new_pool_int_array(&_godot_array, (godot_pool_int_array *) &a);
godot::api->godot_array_new_pool_int_array(&_godot_array, (godot_pool_int_array *) &a);
}
Array::Array(const PoolRealArray& a)
{
godot_array_new_pool_real_array(&_godot_array, (godot_pool_real_array *) &a);
godot::api->godot_array_new_pool_real_array(&_godot_array, (godot_pool_real_array *) &a);
}
Array::Array(const PoolStringArray& a)
{
godot_array_new_pool_string_array(&_godot_array, (godot_pool_string_array *) &a);
godot::api->godot_array_new_pool_string_array(&_godot_array, (godot_pool_string_array *) &a);
}
Array::Array(const PoolVector2Array& a)
{
godot_array_new_pool_vector2_array(&_godot_array, (godot_pool_vector2_array *) &a);
godot::api->godot_array_new_pool_vector2_array(&_godot_array, (godot_pool_vector2_array *) &a);
}
Array::Array(const PoolVector3Array& a)
{
godot_array_new_pool_vector3_array(&_godot_array, (godot_pool_vector3_array *) &a);
godot::api->godot_array_new_pool_vector3_array(&_godot_array, (godot_pool_vector3_array *) &a);
}
Array::Array(const PoolColorArray& a)
{
godot_array_new_pool_color_array(&_godot_array, (godot_pool_color_array *) &a);
godot::api->godot_array_new_pool_color_array(&_godot_array, (godot_pool_color_array *) &a);
}
Variant& Array::operator [](const int idx)
{
godot_variant *v = godot_array_operator_index(&_godot_array, idx);
godot_variant *v = godot::api->godot_array_operator_index(&_godot_array, idx);
return *(Variant *) v;
}
@ -58,132 +58,132 @@ Variant Array::operator [](const int idx) const
{
// Yes, I'm casting away the const... you can hate me now.
// since the result is
godot_variant *v = godot_array_operator_index((godot_array *) &_godot_array, idx);
godot_variant *v = godot::api->godot_array_operator_index((godot_array *) &_godot_array, idx);
return *(Variant *) v;
}
void Array::append(const Variant& v)
{
godot_array_append(&_godot_array, (godot_variant *) &v);
godot::api->godot_array_append(&_godot_array, (godot_variant *) &v);
}
void Array::clear()
{
godot_array_clear(&_godot_array);
godot::api->godot_array_clear(&_godot_array);
}
int Array::count(const Variant& v)
{
return godot_array_count(&_godot_array, (godot_variant *) &v);
return godot::api->godot_array_count(&_godot_array, (godot_variant *) &v);
}
bool Array::empty() const
{
return godot_array_empty(&_godot_array);
return godot::api->godot_array_empty(&_godot_array);
}
void Array::erase(const Variant& v)
{
godot_array_erase(&_godot_array, (godot_variant *) &v);
godot::api->godot_array_erase(&_godot_array, (godot_variant *) &v);
}
Variant Array::front() const
{
godot_variant v = godot_array_front(&_godot_array);
godot_variant v = godot::api->godot_array_front(&_godot_array);
return *(Variant *) &v;
}
Variant Array::back() const
{
godot_variant v = godot_array_back(&_godot_array);
godot_variant v = godot::api->godot_array_back(&_godot_array);
return *(Variant *) &v;
}
int Array::find(const Variant& what, const int from)
{
return godot_array_find(&_godot_array, (godot_variant *) &what, from);
return godot::api->godot_array_find(&_godot_array, (godot_variant *) &what, from);
}
int Array::find_last(const Variant& what)
{
return godot_array_find_last(&_godot_array, (godot_variant *) &what);
return godot::api->godot_array_find_last(&_godot_array, (godot_variant *) &what);
}
bool Array::has(const Variant& what) const
{
return godot_array_has(&_godot_array, (godot_variant *) &what);
return godot::api->godot_array_has(&_godot_array, (godot_variant *) &what);
}
uint32_t Array::hash() const
{
return godot_array_hash(&_godot_array);
return godot::api->godot_array_hash(&_godot_array);
}
void Array::insert(const int pos, const Variant& value)
{
godot_array_insert(&_godot_array, pos, (godot_variant *) &value);
godot::api->godot_array_insert(&_godot_array, pos, (godot_variant *) &value);
}
void Array::invert()
{
godot_array_invert(&_godot_array);
godot::api->godot_array_invert(&_godot_array);
}
Variant Array::pop_back()
{
godot_variant v = godot_array_pop_back(&_godot_array);
godot_variant v = godot::api->godot_array_pop_back(&_godot_array);
return *(Variant *) &v;
}
Variant Array::pop_front()
{
godot_variant v = godot_array_pop_front(&_godot_array);
godot_variant v = godot::api->godot_array_pop_front(&_godot_array);
return *(Variant *) &v;
}
void Array::push_back(const Variant& v)
{
godot_array_push_back(&_godot_array, (godot_variant *) &v);
godot::api->godot_array_push_back(&_godot_array, (godot_variant *) &v);
}
void Array::push_front(const Variant& v)
{
godot_array_push_front(&_godot_array, (godot_variant *) &v);
godot::api->godot_array_push_front(&_godot_array, (godot_variant *) &v);
}
void Array::remove(const int idx)
{
godot_array_remove(&_godot_array, idx);
godot::api->godot_array_remove(&_godot_array, idx);
}
int Array::size() const
{
return godot_array_size(&_godot_array);
return godot::api->godot_array_size(&_godot_array);
}
void Array::resize(const int size)
{
godot_array_resize(&_godot_array, size);
godot::api->godot_array_resize(&_godot_array, size);
}
int Array::rfind(const Variant& what, const int from)
{
return godot_array_rfind(&_godot_array, (godot_variant *) &what, from);
return godot::api->godot_array_rfind(&_godot_array, (godot_variant *) &what, from);
}
void Array::sort()
{
godot_array_sort(&_godot_array);
godot::api->godot_array_sort(&_godot_array);
}
void Array::sort_custom(Object *obj, const String& func)
{
godot_array_sort_custom(&_godot_array, (godot_object *) obj, (godot_string *) &func);
godot::api->godot_array_sort_custom(&_godot_array, (godot_object *) obj, (godot_string *) &func);
}
Array::~Array()
{
godot_array_destroy(&_godot_array);
godot::api->godot_array_destroy(&_godot_array);
}
}

View File

@ -1,15 +1,10 @@
#include "Basis.hpp"
#include "Defs.hpp"
#include "Vector3.hpp"
#include "Quat.hpp"
#include <algorithm>
namespace godot {

View File

@ -1,13 +1,10 @@
#include "Color.hpp"
#include "Defs.hpp"
#include "String.hpp"
#include <gdnative/color.h>
#include <cmath>
#include "Defs.hpp"
#include "String.hpp"
namespace godot {
#define MIN(a, b) (a < b ? a : b)

View File

@ -1,84 +1,82 @@
#include "Dictionary.hpp"
#include "Variant.hpp"
#include "Array.hpp"
#include "GodotGlobal.hpp"
namespace godot {
Dictionary::Dictionary()
{
godot_dictionary_new(&_godot_dictionary);
godot::api->godot_dictionary_new(&_godot_dictionary);
}
void Dictionary::clear()
{
godot_dictionary_clear(&_godot_dictionary);
godot::api->godot_dictionary_clear(&_godot_dictionary);
}
bool Dictionary::empty() const
{
return godot_dictionary_empty(&_godot_dictionary);
return godot::api->godot_dictionary_empty(&_godot_dictionary);
}
void Dictionary::erase(const Variant& key)
{
godot_dictionary_erase(&_godot_dictionary, (godot_variant *) &key);
godot::api->godot_dictionary_erase(&_godot_dictionary, (godot_variant *) &key);
}
bool Dictionary::has(const Variant& key) const
{
return godot_dictionary_has(&_godot_dictionary, (godot_variant *) &key);
return godot::api->godot_dictionary_has(&_godot_dictionary, (godot_variant *) &key);
}
bool Dictionary::has_all(const Array& keys) const
{
return godot_dictionary_has_all(&_godot_dictionary, (godot_array *) &keys);
return godot::api->godot_dictionary_has_all(&_godot_dictionary, (godot_array *) &keys);
}
uint32_t Dictionary::hash() const
{
return godot_dictionary_hash(&_godot_dictionary);
return godot::api->godot_dictionary_hash(&_godot_dictionary);
}
Array Dictionary::keys() const
{
godot_array a = godot_dictionary_keys(&_godot_dictionary);
godot_array a = godot::api->godot_dictionary_keys(&_godot_dictionary);
return *(Array *) &a;
}
Variant &Dictionary::operator [](const Variant& key)
{
return *(Variant *) godot_dictionary_operator_index(&_godot_dictionary, (godot_variant *) &key);
return *(Variant *) godot::api->godot_dictionary_operator_index(&_godot_dictionary, (godot_variant *) &key);
}
const Variant &Dictionary::operator [](const Variant& key) const
{
// oops I did it again
return *(Variant *) godot_dictionary_operator_index((godot_dictionary *) &_godot_dictionary, (godot_variant *) &key);
return *(Variant *) godot::api->godot_dictionary_operator_index((godot_dictionary *) &_godot_dictionary, (godot_variant *) &key);
}
int Dictionary::size() const
{
return godot_dictionary_size(&_godot_dictionary);
return godot::api->godot_dictionary_size(&_godot_dictionary);
}
String Dictionary::to_json() const
{
godot_string s = godot_dictionary_to_json(&_godot_dictionary);
godot_string s = godot::api->godot_dictionary_to_json(&_godot_dictionary);
return *(String *) &s;
}
Array Dictionary::values() const
{
godot_array a = godot_dictionary_values(&_godot_dictionary);
godot_array a = godot::api->godot_dictionary_values(&_godot_dictionary);
return *(Array *) &a;
}
Dictionary::~Dictionary()
{
godot_dictionary_destroy(&_godot_dictionary);
godot::api->godot_dictionary_destroy(&_godot_dictionary);
}

View File

@ -2,25 +2,24 @@
#include "String.hpp"
#include <gdnative/gdnative.h>
namespace godot {
void *_RegisterState::nativescript_handle;
const godot_gdnative_api_struct *api = NULL;
void Godot::print(const String& message)
{
godot_print((godot_string *) &message);
godot::api->godot_print((godot_string *) &message);
}
void Godot::print_warning(const String& description, const String& function, const String& file, int line)
{
godot_print_warning(description.c_string(), function.c_string(), file.c_string(), line);
godot::api->godot_print_warning(description.c_string(), function.c_string(), file.c_string(), line);
}
void Godot::print_error(const String& description, const String& function, const String& file, int line)
{
godot_print_error(description.c_string(), function.c_string(), file.c_string(), line);
godot::api->godot_print_error(description.c_string(), function.c_string(), file.c_string(), line);
}
};
@ -28,6 +27,7 @@ void Godot::print_error(const String& description, const String& function, const
void gdnative_init(godot_gdnative_init_options *options);
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *options)
{
godot::api = options->api_struct;
gdnative_init(options);
}

View File

@ -1,6 +1,6 @@
#include "NodePath.hpp"
#include "String.hpp"
#include "GodotGlobal.hpp"
#include <gdnative/node_path.h>
@ -10,81 +10,81 @@ namespace godot {
NodePath::NodePath()
{
String from = "";
godot_node_path_new(&_node_path, (godot_string *) &from);
godot::api->godot_node_path_new(&_node_path, (godot_string *) &from);
}
NodePath::NodePath(const NodePath &other)
{
String from = other;
godot_node_path_new(&_node_path, (godot_string *) &from);
godot_node_path_operator_equal(&_node_path, &other._node_path);
godot::api->godot_node_path_new(&_node_path, (godot_string *) &from);
godot::api->godot_node_path_operator_equal(&_node_path, &other._node_path);
}
NodePath::NodePath(const String &from)
{
godot_node_path_new(&_node_path, (godot_string *) &from);
godot::api->godot_node_path_new(&_node_path, (godot_string *) &from);
}
NodePath::NodePath(const char *contents)
{
String from = contents;
godot_node_path_new(&_node_path, (godot_string *) &from);
godot::api->godot_node_path_new(&_node_path, (godot_string *) &from);
}
String NodePath::get_name(const int idx) const
{
godot_string str = godot_node_path_get_name(&_node_path, idx);
godot_string str = godot::api->godot_node_path_get_name(&_node_path, idx);
return *(String *) &str;
}
int NodePath::get_name_count() const
{
return godot_node_path_get_name_count(&_node_path);
return godot::api->godot_node_path_get_name_count(&_node_path);
}
String NodePath::get_property() const
{
godot_string str = godot_node_path_get_property(&_node_path);
godot_string str = godot::api->godot_node_path_get_property(&_node_path);
return *(String *) &str;
}
String NodePath::get_subname(const int idx) const
{
godot_string str = godot_node_path_get_subname(&_node_path, idx);
godot_string str = godot::api->godot_node_path_get_subname(&_node_path, idx);
return *(String *) &str;
}
int NodePath::get_subname_count() const
{
return godot_node_path_get_subname_count(&_node_path);
return godot::api->godot_node_path_get_subname_count(&_node_path);
}
bool NodePath::is_absolute() const
{
return godot_node_path_is_absolute(&_node_path);
return godot::api->godot_node_path_is_absolute(&_node_path);
}
bool NodePath::is_empty() const
{
return godot_node_path_is_empty(&_node_path);
return godot::api->godot_node_path_is_empty(&_node_path);
}
NodePath::operator String() const
{
godot_string str = godot_node_path_as_string(&_node_path);
godot_string str = godot::api->godot_node_path_as_string(&_node_path);
return *(String *) &str;
}
void NodePath::operator =(const NodePath& other)
{
godot_node_path_operator_equal(&_node_path, &other._node_path);
godot::api->godot_node_path_operator_equal(&_node_path, &other._node_path);
}
NodePath::~NodePath()
{
godot_node_path_destroy(&_node_path);
godot::api->godot_node_path_destroy(&_node_path);
}

View File

@ -1,5 +1,4 @@
#include "Plane.hpp"
#include "Vector3.hpp"
#include <cmath>

View File

@ -1,11 +1,10 @@
#include "PoolArrays.hpp"
#include "Defs.hpp"
#include "String.hpp"
#include "Color.hpp"
#include "Vector2.hpp"
#include "Vector3.hpp"
#include "GodotGlobal.hpp"
#include <gdnative/pool_arrays.h>
@ -13,484 +12,484 @@ namespace godot {
PoolByteArray::PoolByteArray()
{
godot_pool_byte_array_new(&_godot_array);
godot::api->godot_pool_byte_array_new(&_godot_array);
}
PoolByteArray::PoolByteArray(const Array& array)
{
godot_pool_byte_array_new_with_array(&_godot_array, (godot_array *) &array);
godot::api->godot_pool_byte_array_new_with_array(&_godot_array, (godot_array *) &array);
}
void PoolByteArray::append(const uint8_t data)
{
godot_pool_byte_array_append(&_godot_array, data);
godot::api->godot_pool_byte_array_append(&_godot_array, data);
}
void PoolByteArray::append_array(const PoolByteArray& array)
{
godot_pool_byte_array_append_array(&_godot_array, &array._godot_array);
godot::api->godot_pool_byte_array_append_array(&_godot_array, &array._godot_array);
}
int PoolByteArray::insert(const int idx, const uint8_t data)
{
return godot_pool_byte_array_insert(&_godot_array, idx, data);
return godot::api->godot_pool_byte_array_insert(&_godot_array, idx, data);
}
void PoolByteArray::invert()
{
godot_pool_byte_array_invert(&_godot_array);
godot::api->godot_pool_byte_array_invert(&_godot_array);
}
void PoolByteArray::push_back(const uint8_t data)
{
godot_pool_byte_array_push_back(&_godot_array, data);
godot::api->godot_pool_byte_array_push_back(&_godot_array, data);
}
void PoolByteArray::remove(const int idx)
{
godot_pool_byte_array_remove(&_godot_array, idx);
godot::api->godot_pool_byte_array_remove(&_godot_array, idx);
}
void PoolByteArray::resize(const int size)
{
godot_pool_byte_array_resize(&_godot_array, size);
godot::api->godot_pool_byte_array_resize(&_godot_array, size);
}
void PoolByteArray::set(const int idx, const uint8_t data)
{
godot_pool_byte_array_set(&_godot_array, idx, data);
godot::api->godot_pool_byte_array_set(&_godot_array, idx, data);
}
uint8_t PoolByteArray::operator [](const int idx)
{
return godot_pool_byte_array_get(&_godot_array, idx);
return godot::api->godot_pool_byte_array_get(&_godot_array, idx);
}
int PoolByteArray::size()
{
return godot_pool_byte_array_size(&_godot_array);
return godot::api->godot_pool_byte_array_size(&_godot_array);
}
PoolByteArray::~PoolByteArray()
{
godot_pool_byte_array_destroy(&_godot_array);
godot::api->godot_pool_byte_array_destroy(&_godot_array);
}
PoolIntArray::PoolIntArray()
{
godot_pool_int_array_new(&_godot_array);
godot::api->godot_pool_int_array_new(&_godot_array);
}
PoolIntArray::PoolIntArray(const Array& array)
{
godot_pool_int_array_new_with_array(&_godot_array, (godot_array *) &array);
godot::api->godot_pool_int_array_new_with_array(&_godot_array, (godot_array *) &array);
}
void PoolIntArray::append(const int data)
{
godot_pool_int_array_append(&_godot_array, data);
godot::api->godot_pool_int_array_append(&_godot_array, data);
}
void PoolIntArray::append_array(const PoolIntArray& array)
{
godot_pool_int_array_append_array(&_godot_array, &array._godot_array);
godot::api->godot_pool_int_array_append_array(&_godot_array, &array._godot_array);
}
int PoolIntArray::insert(const int idx, const int data)
{
return godot_pool_int_array_insert(&_godot_array, idx, data);
return godot::api->godot_pool_int_array_insert(&_godot_array, idx, data);
}
void PoolIntArray::invert()
{
godot_pool_int_array_invert(&_godot_array);
godot::api->godot_pool_int_array_invert(&_godot_array);
}
void PoolIntArray::push_back(const int data)
{
godot_pool_int_array_push_back(&_godot_array, data);
godot::api->godot_pool_int_array_push_back(&_godot_array, data);
}
void PoolIntArray::remove(const int idx)
{
godot_pool_int_array_remove(&_godot_array, idx);
godot::api->godot_pool_int_array_remove(&_godot_array, idx);
}
void PoolIntArray::resize(const int size)
{
godot_pool_int_array_resize(&_godot_array, size);
godot::api->godot_pool_int_array_resize(&_godot_array, size);
}
void PoolIntArray::set(const int idx, const int data)
{
godot_pool_int_array_set(&_godot_array, idx, data);
godot::api->godot_pool_int_array_set(&_godot_array, idx, data);
}
int PoolIntArray::operator [](const int idx)
{
return godot_pool_int_array_get(&_godot_array, idx);
return godot::api->godot_pool_int_array_get(&_godot_array, idx);
}
int PoolIntArray::size()
{
return godot_pool_int_array_size(&_godot_array);
return godot::api->godot_pool_int_array_size(&_godot_array);
}
PoolIntArray::~PoolIntArray()
{
godot_pool_int_array_destroy(&_godot_array);
godot::api->godot_pool_int_array_destroy(&_godot_array);
}
PoolRealArray::PoolRealArray()
{
godot_pool_real_array_new(&_godot_array);
godot::api->godot_pool_real_array_new(&_godot_array);
}
PoolRealArray::PoolRealArray(const Array& array)
{
godot_pool_real_array_new_with_array(&_godot_array, (godot_array *) &array);
godot::api->godot_pool_real_array_new_with_array(&_godot_array, (godot_array *) &array);
}
void PoolRealArray::append(const real_t data)
{
godot_pool_real_array_append(&_godot_array, data);
godot::api->godot_pool_real_array_append(&_godot_array, data);
}
void PoolRealArray::append_array(const PoolRealArray& array)
{
godot_pool_real_array_append_array(&_godot_array, &array._godot_array);
godot::api->godot_pool_real_array_append_array(&_godot_array, &array._godot_array);
}
int PoolRealArray::insert(const int idx, const real_t data)
{
return godot_pool_real_array_insert(&_godot_array, idx, data);
return godot::api->godot_pool_real_array_insert(&_godot_array, idx, data);
}
void PoolRealArray::invert()
{
godot_pool_real_array_invert(&_godot_array);
godot::api->godot_pool_real_array_invert(&_godot_array);
}
void PoolRealArray::push_back(const real_t data)
{
godot_pool_real_array_push_back(&_godot_array, data);
godot::api->godot_pool_real_array_push_back(&_godot_array, data);
}
void PoolRealArray::remove(const int idx)
{
godot_pool_real_array_remove(&_godot_array, idx);
godot::api->godot_pool_real_array_remove(&_godot_array, idx);
}
void PoolRealArray::resize(const int size)
{
godot_pool_real_array_resize(&_godot_array, size);
godot::api->godot_pool_real_array_resize(&_godot_array, size);
}
void PoolRealArray::set(const int idx, const real_t data)
{
godot_pool_real_array_set(&_godot_array, idx, data);
godot::api->godot_pool_real_array_set(&_godot_array, idx, data);
}
real_t PoolRealArray::operator [](const int idx)
{
return godot_pool_real_array_get(&_godot_array, idx);
return godot::api->godot_pool_real_array_get(&_godot_array, idx);
}
int PoolRealArray::size()
{
return godot_pool_real_array_size(&_godot_array);
return godot::api->godot_pool_real_array_size(&_godot_array);
}
PoolRealArray::~PoolRealArray()
{
godot_pool_real_array_destroy(&_godot_array);
godot::api->godot_pool_real_array_destroy(&_godot_array);
}
PoolStringArray::PoolStringArray()
{
godot_pool_string_array_new(&_godot_array);
godot::api->godot_pool_string_array_new(&_godot_array);
}
PoolStringArray::PoolStringArray(const Array& array)
{
godot_pool_string_array_new_with_array(&_godot_array, (godot_array *) &array);
godot::api->godot_pool_string_array_new_with_array(&_godot_array, (godot_array *) &array);
}
void PoolStringArray::append(const String& data)
{
godot_pool_string_array_append(&_godot_array, (godot_string *) &data);
godot::api->godot_pool_string_array_append(&_godot_array, (godot_string *) &data);
}
void PoolStringArray::append_array(const PoolStringArray& array)
{
godot_pool_string_array_append_array(&_godot_array, &array._godot_array);
godot::api->godot_pool_string_array_append_array(&_godot_array, &array._godot_array);
}
int PoolStringArray::insert(const int idx, const String& data)
{
return godot_pool_string_array_insert(&_godot_array, idx, (godot_string *) &data);
return godot::api->godot_pool_string_array_insert(&_godot_array, idx, (godot_string *) &data);
}
void PoolStringArray::invert()
{
godot_pool_string_array_invert(&_godot_array);
godot::api->godot_pool_string_array_invert(&_godot_array);
}
void PoolStringArray::push_back(const String& data)
{
godot_pool_string_array_push_back(&_godot_array, (godot_string *) &data);
godot::api->godot_pool_string_array_push_back(&_godot_array, (godot_string *) &data);
}
void PoolStringArray::remove(const int idx)
{
godot_pool_string_array_remove(&_godot_array, idx);
godot::api->godot_pool_string_array_remove(&_godot_array, idx);
}
void PoolStringArray::resize(const int size)
{
godot_pool_string_array_resize(&_godot_array, size);
godot::api->godot_pool_string_array_resize(&_godot_array, size);
}
void PoolStringArray::set(const int idx, const String& data)
{
godot_pool_string_array_set(&_godot_array, idx, (godot_string *) &data);
godot::api->godot_pool_string_array_set(&_godot_array, idx, (godot_string *) &data);
}
String PoolStringArray::operator [](const int idx)
{
String s;
godot_string str = godot_pool_string_array_get(&_godot_array, idx);
godot_string_new_copy((godot_string *) &s, &str);
godot_string_destroy(&str);
godot_string str = godot::api->godot_pool_string_array_get(&_godot_array, idx);
godot::api->godot_string_new_copy((godot_string *) &s, &str);
godot::api->godot_string_destroy(&str);
return s;
}
int PoolStringArray::size()
{
return godot_pool_string_array_size(&_godot_array);
return godot::api->godot_pool_string_array_size(&_godot_array);
}
PoolStringArray::~PoolStringArray()
{
godot_pool_string_array_destroy(&_godot_array);
godot::api->godot_pool_string_array_destroy(&_godot_array);
}
PoolVector2Array::PoolVector2Array()
{
godot_pool_vector2_array_new(&_godot_array);
godot::api->godot_pool_vector2_array_new(&_godot_array);
}
PoolVector2Array::PoolVector2Array(const Array& array)
{
godot_pool_vector2_array_new_with_array(&_godot_array, (godot_array *) &array);
godot::api->godot_pool_vector2_array_new_with_array(&_godot_array, (godot_array *) &array);
}
void PoolVector2Array::append(const Vector2& data)
{
godot_pool_vector2_array_append(&_godot_array, (godot_vector2 *) &data);
godot::api->godot_pool_vector2_array_append(&_godot_array, (godot_vector2 *) &data);
}
void PoolVector2Array::append_array(const PoolVector2Array& array)
{
godot_pool_vector2_array_append_array(&_godot_array, &array._godot_array);
godot::api->godot_pool_vector2_array_append_array(&_godot_array, &array._godot_array);
}
int PoolVector2Array::insert(const int idx, const Vector2& data)
{
return godot_pool_vector2_array_insert(&_godot_array, idx, (godot_vector2 *) &data);
return godot::api->godot_pool_vector2_array_insert(&_godot_array, idx, (godot_vector2 *) &data);
}
void PoolVector2Array::invert()
{
godot_pool_vector2_array_invert(&_godot_array);
godot::api->godot_pool_vector2_array_invert(&_godot_array);
}
void PoolVector2Array::push_back(const Vector2& data)
{
godot_pool_vector2_array_push_back(&_godot_array, (godot_vector2 *) &data);
godot::api->godot_pool_vector2_array_push_back(&_godot_array, (godot_vector2 *) &data);
}
void PoolVector2Array::remove(const int idx)
{
godot_pool_vector2_array_remove(&_godot_array, idx);
godot::api->godot_pool_vector2_array_remove(&_godot_array, idx);
}
void PoolVector2Array::resize(const int size)
{
godot_pool_vector2_array_resize(&_godot_array, size);
godot::api->godot_pool_vector2_array_resize(&_godot_array, size);
}
void PoolVector2Array::set(const int idx, const Vector2& data)
{
godot_pool_vector2_array_set(&_godot_array, idx, (godot_vector2 *) &data);
godot::api->godot_pool_vector2_array_set(&_godot_array, idx, (godot_vector2 *) &data);
}
Vector2 PoolVector2Array::operator [](const int idx)
{
Vector2 v;
*(godot_vector2 *) &v = godot_pool_vector2_array_get(&_godot_array, idx);
*(godot_vector2 *) &v = godot::api->godot_pool_vector2_array_get(&_godot_array, idx);
return v;
}
int PoolVector2Array::size()
{
return godot_pool_vector2_array_size(&_godot_array);
return godot::api->godot_pool_vector2_array_size(&_godot_array);
}
PoolVector2Array::~PoolVector2Array()
{
godot_pool_vector2_array_destroy(&_godot_array);
godot::api->godot_pool_vector2_array_destroy(&_godot_array);
}
PoolVector3Array::PoolVector3Array()
{
godot_pool_vector3_array_new(&_godot_array);
godot::api->godot_pool_vector3_array_new(&_godot_array);
}
PoolVector3Array::PoolVector3Array(const Array& array)
{
godot_pool_vector3_array_new_with_array(&_godot_array, (godot_array *) &array);
godot::api->godot_pool_vector3_array_new_with_array(&_godot_array, (godot_array *) &array);
}
void PoolVector3Array::append(const Vector3& data)
{
godot_pool_vector3_array_append(&_godot_array, (godot_vector3 *) &data);
godot::api->godot_pool_vector3_array_append(&_godot_array, (godot_vector3 *) &data);
}
void PoolVector3Array::append_array(const PoolVector3Array& array)
{
godot_pool_vector3_array_append_array(&_godot_array, &array._godot_array);
godot::api->godot_pool_vector3_array_append_array(&_godot_array, &array._godot_array);
}
int PoolVector3Array::insert(const int idx, const Vector3& data)
{
return godot_pool_vector3_array_insert(&_godot_array, idx, (godot_vector3 *) &data);
return godot::api->godot_pool_vector3_array_insert(&_godot_array, idx, (godot_vector3 *) &data);
}
void PoolVector3Array::invert()
{
godot_pool_vector3_array_invert(&_godot_array);
godot::api->godot_pool_vector3_array_invert(&_godot_array);
}
void PoolVector3Array::push_back(const Vector3& data)
{
godot_pool_vector3_array_push_back(&_godot_array, (godot_vector3 *) &data);
godot::api->godot_pool_vector3_array_push_back(&_godot_array, (godot_vector3 *) &data);
}
void PoolVector3Array::remove(const int idx)
{
godot_pool_vector3_array_remove(&_godot_array, idx);
godot::api->godot_pool_vector3_array_remove(&_godot_array, idx);
}
void PoolVector3Array::resize(const int size)
{
godot_pool_vector3_array_resize(&_godot_array, size);
godot::api->godot_pool_vector3_array_resize(&_godot_array, size);
}
void PoolVector3Array::set(const int idx, const Vector3& data)
{
godot_pool_vector3_array_set(&_godot_array, idx, (godot_vector3 *) &data);
godot::api->godot_pool_vector3_array_set(&_godot_array, idx, (godot_vector3 *) &data);
}
Vector3 PoolVector3Array::operator [](const int idx)
{
Vector3 v;
*(godot_vector3 *) &v = godot_pool_vector3_array_get(&_godot_array, idx);
*(godot_vector3 *) &v = godot::api->godot_pool_vector3_array_get(&_godot_array, idx);
return v;
}
int PoolVector3Array::size()
{
return godot_pool_vector3_array_size(&_godot_array);
return godot::api->godot_pool_vector3_array_size(&_godot_array);
}
PoolVector3Array::~PoolVector3Array()
{
godot_pool_vector3_array_destroy(&_godot_array);
godot::api->godot_pool_vector3_array_destroy(&_godot_array);
}
PoolColorArray::PoolColorArray()
{
godot_pool_color_array_new(&_godot_array);
godot::api->godot_pool_color_array_new(&_godot_array);
}
PoolColorArray::PoolColorArray(const Array& array)
{
godot_pool_color_array_new_with_array(&_godot_array, (godot_array *) &array);
godot::api->godot_pool_color_array_new_with_array(&_godot_array, (godot_array *) &array);
}
void PoolColorArray::append(const Color& data)
{
godot_pool_color_array_append(&_godot_array, (godot_color *) &data);
godot::api->godot_pool_color_array_append(&_godot_array, (godot_color *) &data);
}
void PoolColorArray::append_array(const PoolColorArray& array)
{
godot_pool_color_array_append_array(&_godot_array, &array._godot_array);
godot::api->godot_pool_color_array_append_array(&_godot_array, &array._godot_array);
}
int PoolColorArray::insert(const int idx, const Color& data)
{
return godot_pool_color_array_insert(&_godot_array, idx, (godot_color *) &data);
return godot::api->godot_pool_color_array_insert(&_godot_array, idx, (godot_color *) &data);
}
void PoolColorArray::invert()
{
godot_pool_color_array_invert(&_godot_array);
godot::api->godot_pool_color_array_invert(&_godot_array);
}
void PoolColorArray::push_back(const Color& data)
{
godot_pool_color_array_push_back(&_godot_array, (godot_color *) &data);
godot::api->godot_pool_color_array_push_back(&_godot_array, (godot_color *) &data);
}
void PoolColorArray::remove(const int idx)
{
godot_pool_color_array_remove(&_godot_array, idx);
godot::api->godot_pool_color_array_remove(&_godot_array, idx);
}
void PoolColorArray::resize(const int size)
{
godot_pool_color_array_resize(&_godot_array, size);
godot::api->godot_pool_color_array_resize(&_godot_array, size);
}
void PoolColorArray::set(const int idx, const Color& data)
{
godot_pool_color_array_set(&_godot_array, idx, (godot_color *) &data);
godot::api->godot_pool_color_array_set(&_godot_array, idx, (godot_color *) &data);
}
Color PoolColorArray::operator [](const int idx)
{
Color v;
*(godot_color *) &v = godot_pool_color_array_get(&_godot_array, idx);
*(godot_color *) &v = godot::api->godot_pool_color_array_get(&_godot_array, idx);
return v;
}
int PoolColorArray::size()
{
return godot_pool_color_array_size(&_godot_array);
return godot::api->godot_pool_color_array_size(&_godot_array);
}
PoolColorArray::~PoolColorArray()
{
godot_pool_color_array_destroy(&_godot_array);
godot::api->godot_pool_color_array_destroy(&_godot_array);
}

View File

@ -1,14 +1,10 @@
#include "Quat.hpp"
#include "Defs.hpp"
#include "Vector3.hpp"
#include "Basis.hpp"
#include <cmath>
#include "Defs.hpp"
#include "Vector3.hpp"
#include "Basis.hpp"
namespace godot {
real_t Quat::length() const

View File

@ -2,17 +2,19 @@
#include <gdnative/rid.h>
#include "GodotGlobal.hpp"
namespace godot {
RID::RID(Object *p)
{
godot_rid_new_with_resource(&_godot_rid, (const godot_object *) p);
godot::api->godot_rid_new_with_resource(&_godot_rid, (const godot_object *) p);
}
int32_t RID::get_rid() const
{
return godot_rid_get_id(&_godot_rid);
return godot::api->godot_rid_get_id(&_godot_rid);
}

View File

@ -1,13 +1,10 @@
#include "Rect2.hpp"
#include "Vector2.hpp"
#include "String.hpp"
#include "Transform2D.hpp"
#include <cmath>
#include "Transform2D.hpp"
namespace godot {
#ifndef MAX

View File

@ -1,7 +1,5 @@
#include "Rect3.hpp"
#include "Vector3.hpp"
#include "Plane.hpp"
#include <algorithm>

View File

@ -4,6 +4,7 @@
#include "NodePath.hpp"
#include "PoolArrays.hpp"
#include "Variant.hpp"
#include "GodotGlobal.hpp"
#include <gdnative/string.h>
@ -12,53 +13,53 @@
namespace godot {
godot::String::String() {
godot_string_new(&_godot_string);
godot::api->godot_string_new(&_godot_string);
}
String::String(const char *contents) {
godot_string_new_data(&_godot_string, contents, strlen(contents));
godot::api->godot_string_new_data(&_godot_string, contents, strlen(contents));
}
String::String(const wchar_t *contents) {
// @Todo
// godot_string_new_data(&_godot_string, contents, strlen(contents));
godot_string_new(&_godot_string);
// godot::api->godot_string_new_data(&_godot_string, contents, strlen(contents));
godot::api->godot_string_new(&_godot_string);
}
String::String(const wchar_t c) {
// @Todo
godot_string_new(&_godot_string);
godot::api->godot_string_new(&_godot_string);
}
String::String(const String &other) {
godot_string_new_copy(&_godot_string, &other._godot_string);
godot::api->godot_string_new_copy(&_godot_string, &other._godot_string);
}
String::~String() {
godot_string_destroy(&_godot_string);
godot::api->godot_string_destroy(&_godot_string);
}
wchar_t &String::operator[](const int idx) {
return *godot_string_operator_index(&_godot_string, idx);
return *godot::api->godot_string_operator_index(&_godot_string, idx);
}
wchar_t String::operator[](const int idx) const {
return *godot_string_operator_index((godot_string *)&_godot_string, idx);
return *godot::api->godot_string_operator_index((godot_string *)&_godot_string, idx);
}
int String::length() const {
int len = 0;
godot_string_get_data(&_godot_string, nullptr, &len);
godot::api->godot_string_get_data(&_godot_string, nullptr, &len);
return len;
}
void String::operator=(const String &s) {
godot_string_destroy(&_godot_string);
godot_string_new_copy(&_godot_string, &s._godot_string);
godot::api->godot_string_destroy(&_godot_string);
godot::api->godot_string_new_copy(&_godot_string, &s._godot_string);
}
bool String::operator==(const String &s) {
return godot_string_operator_equal(&_godot_string, &s._godot_string);
return godot::api->godot_string_operator_equal(&_godot_string, &s._godot_string);
}
bool String::operator!=(const String &s) {
@ -68,13 +69,13 @@ bool String::operator!=(const String &s) {
String String::operator+(const String &s) {
String new_string = *this;
new_string._godot_string =
godot_string_operator_plus(&new_string._godot_string, &s._godot_string);
godot::api->godot_string_operator_plus(&new_string._godot_string, &s._godot_string);
return new_string;
}
void String::operator+=(const String &s) {
_godot_string = godot_string_operator_plus(&_godot_string, &s._godot_string);
_godot_string = godot::api->godot_string_operator_plus(&_godot_string, &s._godot_string);
}
void String::operator+=(const wchar_t c) {
@ -82,11 +83,11 @@ void String::operator+=(const wchar_t c) {
}
bool String::operator<(const String &s) {
return godot_string_operator_less(&_godot_string, &s._godot_string);
return godot::api->godot_string_operator_less(&_godot_string, &s._godot_string);
}
bool String::operator<=(const String &s) {
return godot_string_operator_less(&_godot_string, &s._godot_string) ||
return godot::api->godot_string_operator_less(&_godot_string, &s._godot_string) ||
(*this == s);
}
@ -103,7 +104,7 @@ String::operator NodePath() const {
}
const char *String::c_string() const {
return godot_string_c_str(&_godot_string);
return godot::api->godot_string_c_str(&_godot_string);
}
String operator+(const char *a, const String &b) {
@ -111,322 +112,322 @@ String operator+(const char *a, const String &b) {
}
bool String::begins_with(String &p_string) const {
return godot_string_begins_with(&_godot_string, &p_string._godot_string);
return godot::api->godot_string_begins_with(&_godot_string, &p_string._godot_string);
}
bool String::begins_with_char_array(const char *p_char_array) const {
return godot_string_begins_with_char_array(&_godot_string, p_char_array);
return godot::api->godot_string_begins_with_char_array(&_godot_string, p_char_array);
}
PoolStringArray String::bigrams() const {
godot_array arr = godot_string_bigrams(&_godot_string);
godot_array arr = godot::api->godot_string_bigrams(&_godot_string);
return *(PoolStringArray *)&arr;
}
String String::c_escape() const {
String new_string;
new_string._godot_string = godot_string_c_escape(&_godot_string);
new_string._godot_string = godot::api->godot_string_c_escape(&_godot_string);
return new_string;
}
String String::c_unescape() const {
String new_string;
new_string._godot_string = godot_string_c_unescape(&_godot_string);
new_string._godot_string = godot::api->godot_string_c_unescape(&_godot_string);
return new_string;
}
String String::capitalize() const {
String new_string;
new_string._godot_string = godot_string_capitalize(&_godot_string);
new_string._godot_string = godot::api->godot_string_capitalize(&_godot_string);
return new_string;
}
bool String::empty() const {
return godot_string_empty(&_godot_string);
return godot::api->godot_string_empty(&_godot_string);
}
bool String::ends_with(String &p_string) const {
return godot_string_ends_with(&_godot_string, &p_string._godot_string);
return godot::api->godot_string_ends_with(&_godot_string, &p_string._godot_string);
}
void String::erase(int position, int chars) {
godot_string_erase(&_godot_string, position, chars);
godot::api->godot_string_erase(&_godot_string, position, chars);
}
int String::find(String p_what, int p_from) const {
return godot_string_find(&_godot_string, p_what._godot_string);
return godot::api->godot_string_find(&_godot_string, p_what._godot_string);
}
int String::find_last(String what) const {
return godot_string_find_last(&_godot_string, what._godot_string);
return godot::api->godot_string_find_last(&_godot_string, what._godot_string);
}
int String::findn(String what, int from) const {
return godot_string_findn(&_godot_string, what._godot_string);
return godot::api->godot_string_findn(&_godot_string, what._godot_string);
}
String String::format(Variant values, String placeholder) const {
String new_string;
new_string._godot_string = godot_string_format(&_godot_string, (godot_variant *)&values);
new_string._godot_string = godot::api->godot_string_format(&_godot_string, (godot_variant *)&values);
return new_string;
}
String String::get_base_dir() const {
String new_string;
new_string._godot_string = godot_string_get_base_dir(&_godot_string);
new_string._godot_string = godot::api->godot_string_get_base_dir(&_godot_string);
return new_string;
}
String String::get_basename() const {
godot_string new_string = godot_string_get_basename(&_godot_string);
godot_string new_string = godot::api->godot_string_get_basename(&_godot_string);
return *(String *)&new_string;
}
String String::get_extension() const {
godot_string new_string = godot_string_get_extension(&_godot_string);
godot_string new_string = godot::api->godot_string_get_extension(&_godot_string);
return *(String *)&new_string;
}
String String::get_file() const {
godot_string new_string = godot_string_get_file(&_godot_string);
godot_string new_string = godot::api->godot_string_get_file(&_godot_string);
return *(String *)&new_string;
}
int String::hash() const {
return godot_string_hash(&_godot_string);
return godot::api->godot_string_hash(&_godot_string);
}
int String::hex_to_int() const {
return godot_string_hex_to_int(&_godot_string);
return godot::api->godot_string_hex_to_int(&_godot_string);
}
String String::insert(int position, String what) const {
String new_string;
new_string._godot_string = godot_string_insert(&_godot_string, position, what._godot_string);
new_string._godot_string = godot::api->godot_string_insert(&_godot_string, position, what._godot_string);
return new_string;
}
bool String::is_abs_path() const {
return godot_string_is_abs_path(&_godot_string);
return godot::api->godot_string_is_abs_path(&_godot_string);
}
bool String::is_rel_path() const {
return godot_string_is_rel_path(&_godot_string);
return godot::api->godot_string_is_rel_path(&_godot_string);
}
bool String::is_subsequence_of(String text) const {
return godot_string_is_subsequence_of(&_godot_string, &text._godot_string);
return godot::api->godot_string_is_subsequence_of(&_godot_string, &text._godot_string);
}
bool String::is_subsequence_ofi(String text) const {
return godot_string_is_subsequence_ofi(&_godot_string, &text._godot_string);
return godot::api->godot_string_is_subsequence_ofi(&_godot_string, &text._godot_string);
}
bool String::is_valid_float() const {
return godot_string_is_valid_float(&_godot_string);
return godot::api->godot_string_is_valid_float(&_godot_string);
}
bool String::is_valid_html_color() const {
return godot_string_is_valid_html_color(&_godot_string);
return godot::api->godot_string_is_valid_html_color(&_godot_string);
}
bool String::is_valid_identifier() const {
return godot_string_is_valid_identifier(&_godot_string);
return godot::api->godot_string_is_valid_identifier(&_godot_string);
}
bool String::is_valid_integer() const {
return godot_string_is_numeric(&_godot_string);
return godot::api->godot_string_is_numeric(&_godot_string);
}
bool String::is_valid_ip_address() const {
return godot_string_is_valid_ip_address(&_godot_string);
return godot::api->godot_string_is_valid_ip_address(&_godot_string);
}
String String::json_escape() const {
String new_string;
new_string._godot_string = godot_string_json_escape(&_godot_string);
new_string._godot_string = godot::api->godot_string_json_escape(&_godot_string);
return new_string;
}
String String::left(int position) const {
String new_string;
new_string._godot_string = godot_string_left(&_godot_string, position);
new_string._godot_string = godot::api->godot_string_left(&_godot_string, position);
return new_string;
}
bool String::match(String expr) const {
return godot_string_match(&_godot_string, &expr._godot_string);
return godot::api->godot_string_match(&_godot_string, &expr._godot_string);
}
bool String::matchn(String expr) const {
return godot_string_match(&_godot_string, &expr._godot_string);
return godot::api->godot_string_match(&_godot_string, &expr._godot_string);
}
PoolByteArray String::md5_buffer() const {
godot_pool_byte_array arr = godot_string_md5_buffer(&_godot_string);
godot_pool_byte_array arr = godot::api->godot_string_md5_buffer(&_godot_string);
return *(PoolByteArray *)&arr;
}
String String::md5_text() const {
String new_string;
new_string._godot_string = godot_string_md5_text(&_godot_string);
new_string._godot_string = godot::api->godot_string_md5_text(&_godot_string);
return new_string;
}
int String::ord_at(int at) const {
return godot_string_ord_at(&_godot_string, at);
return godot::api->godot_string_ord_at(&_godot_string, at);
}
String String::pad_decimals(int digits) const {
String new_string;
new_string._godot_string = godot_string_pad_decimals(&_godot_string, digits);
new_string._godot_string = godot::api->godot_string_pad_decimals(&_godot_string, digits);
return new_string;
}
String String::pad_zeros(int digits) const {
String new_string;
new_string._godot_string = godot_string_pad_zeros(&_godot_string, digits);
new_string._godot_string = godot::api->godot_string_pad_zeros(&_godot_string, digits);
return new_string;
}
String String::percent_decode() const {
String new_string;
new_string._godot_string = godot_string_percent_decode(&_godot_string);
new_string._godot_string = godot::api->godot_string_percent_decode(&_godot_string);
return new_string;
}
String String::percent_encode() const {
String new_string;
new_string._godot_string = godot_string_percent_encode(&_godot_string);
new_string._godot_string = godot::api->godot_string_percent_encode(&_godot_string);
return new_string;
}
String String::plus_file(String file) const {
String new_string;
new_string._godot_string = godot_string_plus_file(&_godot_string, &file._godot_string);
new_string._godot_string = godot::api->godot_string_plus_file(&_godot_string, &file._godot_string);
return new_string;
}
String String::replace(String p_key, String p_with) const {
String new_string;
new_string._godot_string = godot_string_replace(&_godot_string, p_key._godot_string, p_with._godot_string);
new_string._godot_string = godot::api->godot_string_replace(&_godot_string, p_key._godot_string, p_with._godot_string);
return new_string;
}
String String::replacen(String what, String forwhat) const {
String new_string;
new_string._godot_string = godot_string_replacen(&_godot_string, what._godot_string, forwhat._godot_string);
new_string._godot_string = godot::api->godot_string_replacen(&_godot_string, what._godot_string, forwhat._godot_string);
return new_string;
}
int String::rfind(String what, int from) const {
return godot_string_rfind(&_godot_string, what._godot_string);
return godot::api->godot_string_rfind(&_godot_string, what._godot_string);
}
int String::rfindn(String what, int from) const {
// From -1
return godot_string_rfindn(&_godot_string, what._godot_string);
return godot::api->godot_string_rfindn(&_godot_string, what._godot_string);
}
String String::right(int position) const {
String new_string;
new_string._godot_string = godot_string_right(&_godot_string, position);
new_string._godot_string = godot::api->godot_string_right(&_godot_string, position);
return new_string;
}
PoolByteArray String::sha256_buffer() const {
godot_pool_byte_array arr = godot_string_sha256_buffer(&_godot_string);
godot_pool_byte_array arr = godot::api->godot_string_sha256_buffer(&_godot_string);
return *(PoolByteArray *)&arr;
}
String String::sha256_text() const {
String new_string;
new_string._godot_string = godot_string_sha256_text(&_godot_string);
new_string._godot_string = godot::api->godot_string_sha256_text(&_godot_string);
return new_string;
}
float String::similarity(String text) const {
return godot_string_similarity(&_godot_string, &text._godot_string);
return godot::api->godot_string_similarity(&_godot_string, &text._godot_string);
}
PoolStringArray String::split(String divisor, bool allow_empty) const {
godot_array arr = godot_string_split(&_godot_string, &divisor._godot_string);
godot_array arr = godot::api->godot_string_split(&_godot_string, &divisor._godot_string);
return *(PoolStringArray *)&arr;
}
PoolRealArray String::split_floats(String divisor, bool allow_empty) const {
godot_array arr = godot_string_split_floats(&_godot_string, &divisor._godot_string);
godot_array arr = godot::api->godot_string_split_floats(&_godot_string, &divisor._godot_string);
return *(PoolRealArray *)&arr;
}
String String::strip_edges(bool left, bool right) const {
String new_string;
new_string._godot_string = godot_string_strip_edges(&_godot_string, left, right);
new_string._godot_string = godot::api->godot_string_strip_edges(&_godot_string, left, right);
return new_string;
}
String String::substr(int from, int len) const {
String new_string;
new_string._godot_string = godot_string_substr(&_godot_string, from, len);
new_string._godot_string = godot::api->godot_string_substr(&_godot_string, from, len);
return new_string;
}
float String::to_float() const {
return godot_string_to_float(&_godot_string);
return godot::api->godot_string_to_float(&_godot_string);
}
int64_t String::to_int() const {
return godot_string_to_int(&_godot_string);
return godot::api->godot_string_to_int(&_godot_string);
}
String String::to_lower() const {
String new_string;
new_string._godot_string = godot_string_to_lower(&_godot_string);
new_string._godot_string = godot::api->godot_string_to_lower(&_godot_string);
return new_string;
}
String String::to_upper() const {
String new_string;
new_string._godot_string = godot_string_to_upper(&_godot_string);
new_string._godot_string = godot::api->godot_string_to_upper(&_godot_string);
return new_string;
}
String String::xml_escape() const {
String new_string;
new_string._godot_string = godot_string_xml_escape(&_godot_string);
new_string._godot_string = godot::api->godot_string_xml_escape(&_godot_string);
return new_string;
}
String String::xml_unescape() const {
String new_string;
new_string._godot_string = godot_string_xml_unescape(&_godot_string);
new_string._godot_string = godot::api->godot_string_xml_unescape(&_godot_string);
return new_string;
}

View File

@ -1,9 +1,6 @@
#include "Transform2D.hpp"
#include "Vector2.hpp"
#include "String.hpp"
#include "Rect2.hpp"
#include <algorithm>

View File

@ -3,8 +3,8 @@
#include <gdnative/variant.h>
#include "Defs.hpp"
#include "CoreTypes.hpp"
#include "GodotGlobal.hpp"
#include <iostream>
@ -12,187 +12,187 @@ namespace godot {
Variant::Variant()
{
godot_variant_new_nil(&_godot_variant);
godot::api->godot_variant_new_nil(&_godot_variant);
}
Variant::Variant(const Variant& v)
{
godot_variant_new_copy(&_godot_variant, &v._godot_variant);
godot::api->godot_variant_new_copy(&_godot_variant, &v._godot_variant);
}
Variant::Variant(bool p_bool)
{
godot_variant_new_bool(&_godot_variant, p_bool);
godot::api->godot_variant_new_bool(&_godot_variant, p_bool);
}
Variant::Variant(signed int p_int) // real one
{
godot_variant_new_int(&_godot_variant, p_int);
godot::api->godot_variant_new_int(&_godot_variant, p_int);
}
Variant::Variant(unsigned int p_int)
{
godot_variant_new_uint(&_godot_variant, p_int);
godot::api->godot_variant_new_uint(&_godot_variant, p_int);
}
Variant::Variant(signed short p_short) // real one
{
godot_variant_new_int(&_godot_variant, (int) p_short);
godot::api->godot_variant_new_int(&_godot_variant, (int) p_short);
}
Variant::Variant(int64_t p_char) // real one
{
godot_variant_new_int(&_godot_variant, p_char);
godot::api->godot_variant_new_int(&_godot_variant, p_char);
}
Variant::Variant(uint64_t p_char)
{
godot_variant_new_uint(&_godot_variant, p_char);
godot::api->godot_variant_new_uint(&_godot_variant, p_char);
}
Variant::Variant(float p_float)
{
godot_variant_new_real(&_godot_variant, p_float);
godot::api->godot_variant_new_real(&_godot_variant, p_float);
}
Variant::Variant(double p_double)
{
godot_variant_new_real(&_godot_variant, p_double);
godot::api->godot_variant_new_real(&_godot_variant, p_double);
}
Variant::Variant(const String& p_string)
{
godot_variant_new_string(&_godot_variant, (godot_string *) &p_string);
godot::api->godot_variant_new_string(&_godot_variant, (godot_string *) &p_string);
}
Variant::Variant(const char * const p_cstring)
{
String s = String(p_cstring);
godot_variant_new_string(&_godot_variant, (godot_string *) &s);
godot::api->godot_variant_new_string(&_godot_variant, (godot_string *) &s);
}
Variant::Variant(const wchar_t * p_wstring)
{
String s = p_wstring;
godot_variant_new_string(&_godot_variant, (godot_string *) &s);
godot::api->godot_variant_new_string(&_godot_variant, (godot_string *) &s);
}
Variant::Variant(const Vector2& p_vector2)
{
godot_variant_new_vector2(&_godot_variant, (godot_vector2 *) &p_vector2);
godot::api->godot_variant_new_vector2(&_godot_variant, (godot_vector2 *) &p_vector2);
}
Variant::Variant(const Rect2& p_rect2)
{
godot_variant_new_rect2(&_godot_variant, (godot_rect2 *) &p_rect2);
godot::api->godot_variant_new_rect2(&_godot_variant, (godot_rect2 *) &p_rect2);
}
Variant::Variant(const Vector3& p_vector3)
{
godot_variant_new_vector3(&_godot_variant, (godot_vector3 *) &p_vector3);
godot::api->godot_variant_new_vector3(&_godot_variant, (godot_vector3 *) &p_vector3);
}
Variant::Variant(const Plane& p_plane)
{
godot_variant_new_plane(&_godot_variant, (godot_plane *) &p_plane);
godot::api->godot_variant_new_plane(&_godot_variant, (godot_plane *) &p_plane);
}
Variant::Variant(const Rect3& p_aabb)
{
godot_variant_new_rect3(&_godot_variant, (godot_rect3 *) &p_aabb);
godot::api->godot_variant_new_rect3(&_godot_variant, (godot_rect3 *) &p_aabb);
}
Variant::Variant(const Quat& p_quat)
{
godot_variant_new_quat(&_godot_variant, (godot_quat *) &p_quat);
godot::api->godot_variant_new_quat(&_godot_variant, (godot_quat *) &p_quat);
}
Variant::Variant(const Basis& p_transform)
{
godot_variant_new_basis(&_godot_variant, (godot_basis *) &p_transform);
godot::api->godot_variant_new_basis(&_godot_variant, (godot_basis *) &p_transform);
}
Variant::Variant(const Transform2D& p_transform)
{
godot_variant_new_transform2d(&_godot_variant, (godot_transform2d *) &p_transform);
godot::api->godot_variant_new_transform2d(&_godot_variant, (godot_transform2d *) &p_transform);
}
Variant::Variant(const Transform& p_transform)
{
godot_variant_new_transform(&_godot_variant, (godot_transform *) &p_transform);
godot::api->godot_variant_new_transform(&_godot_variant, (godot_transform *) &p_transform);
}
Variant::Variant(const Color& p_color)
{
godot_variant_new_color(&_godot_variant, (godot_color *) &p_color);
godot::api->godot_variant_new_color(&_godot_variant, (godot_color *) &p_color);
}
Variant::Variant(const NodePath& p_path)
{
godot_variant_new_node_path(&_godot_variant, (godot_node_path *) &p_path);
godot::api->godot_variant_new_node_path(&_godot_variant, (godot_node_path *) &p_path);
}
Variant::Variant(const RID& p_rid)
{
godot_variant_new_rid(&_godot_variant, (godot_rid *) &p_rid);
godot::api->godot_variant_new_rid(&_godot_variant, (godot_rid *) &p_rid);
}
Variant::Variant(const Object* p_object)
{
godot_variant_new_object(&_godot_variant, (godot_object *) p_object);
godot::api->godot_variant_new_object(&_godot_variant, (godot_object *) p_object);
}
Variant::Variant(const Dictionary& p_dictionary)
{
godot_variant_new_dictionary(&_godot_variant, (godot_dictionary *) &p_dictionary);
godot::api->godot_variant_new_dictionary(&_godot_variant, (godot_dictionary *) &p_dictionary);
}
Variant::Variant(const Array& p_array)
{
godot_variant_new_array(&_godot_variant, (godot_array *) &p_array);
godot::api->godot_variant_new_array(&_godot_variant, (godot_array *) &p_array);
}
Variant::Variant(const PoolByteArray& p_raw_array)
{
godot_variant_new_pool_byte_array(&_godot_variant, (godot_pool_byte_array *) &p_raw_array);
godot::api->godot_variant_new_pool_byte_array(&_godot_variant, (godot_pool_byte_array *) &p_raw_array);
}
Variant::Variant(const PoolIntArray& p_int_array)
{
godot_variant_new_pool_int_array(&_godot_variant, (godot_pool_int_array *) &p_int_array);
godot::api->godot_variant_new_pool_int_array(&_godot_variant, (godot_pool_int_array *) &p_int_array);
}
Variant::Variant(const PoolRealArray& p_real_array)
{
godot_variant_new_pool_real_array(&_godot_variant, (godot_pool_real_array *) &p_real_array);
godot::api->godot_variant_new_pool_real_array(&_godot_variant, (godot_pool_real_array *) &p_real_array);
}
Variant::Variant(const PoolStringArray& p_string_array)
{
godot_variant_new_pool_string_array(&_godot_variant, (godot_pool_string_array *) &p_string_array);
godot::api->godot_variant_new_pool_string_array(&_godot_variant, (godot_pool_string_array *) &p_string_array);
}
Variant::Variant(const PoolVector2Array& p_vector2_array)
{
godot_variant_new_pool_vector2_array(&_godot_variant, (godot_pool_vector2_array *) &p_vector2_array);
godot::api->godot_variant_new_pool_vector2_array(&_godot_variant, (godot_pool_vector2_array *) &p_vector2_array);
}
Variant::Variant(const PoolVector3Array& p_vector3_array)
{
godot_variant_new_pool_vector3_array(&_godot_variant, (godot_pool_vector3_array *) &p_vector3_array);
godot::api->godot_variant_new_pool_vector3_array(&_godot_variant, (godot_pool_vector3_array *) &p_vector3_array);
}
Variant::Variant(const PoolColorArray& p_color_array)
{
godot_variant_new_pool_color_array(&_godot_variant, (godot_pool_color_array *) &p_color_array);
godot::api->godot_variant_new_pool_color_array(&_godot_variant, (godot_pool_color_array *) &p_color_array);
}
Variant &Variant::operator =(const Variant& v)
{
godot_variant_new_copy(&_godot_variant, &v._godot_variant);
godot::api->godot_variant_new_copy(&_godot_variant, &v._godot_variant);
return *this;
}
@ -203,192 +203,192 @@ Variant::operator bool() const
}
Variant::operator signed int() const
{
return godot_variant_as_int(&_godot_variant);
return godot::api->godot_variant_as_int(&_godot_variant);
}
Variant::operator unsigned int() const // this is the real one
{
return godot_variant_as_uint(&_godot_variant);
return godot::api->godot_variant_as_uint(&_godot_variant);
}
Variant::operator signed short() const
{
return godot_variant_as_int(&_godot_variant);
return godot::api->godot_variant_as_int(&_godot_variant);
}
Variant::operator unsigned short() const
{
return godot_variant_as_uint(&_godot_variant);
return godot::api->godot_variant_as_uint(&_godot_variant);
}
Variant::operator signed char() const
{
return godot_variant_as_int(&_godot_variant);
return godot::api->godot_variant_as_int(&_godot_variant);
}
Variant::operator unsigned char() const
{
return godot_variant_as_uint(&_godot_variant);
return godot::api->godot_variant_as_uint(&_godot_variant);
}
Variant::operator int64_t() const
{
return godot_variant_as_int(&_godot_variant);
return godot::api->godot_variant_as_int(&_godot_variant);
}
Variant::operator uint64_t() const
{
return godot_variant_as_uint(&_godot_variant);
return godot::api->godot_variant_as_uint(&_godot_variant);
}
Variant::operator wchar_t() const
{
return godot_variant_as_int(&_godot_variant);
return godot::api->godot_variant_as_int(&_godot_variant);
}
Variant::operator float() const
{
return godot_variant_as_real(&_godot_variant);
return godot::api->godot_variant_as_real(&_godot_variant);
}
Variant::operator double() const
{
return godot_variant_as_real(&_godot_variant);
return godot::api->godot_variant_as_real(&_godot_variant);
}
Variant::operator String() const
{
godot_string s = godot_variant_as_string(&_godot_variant);
godot_string s = godot::api->godot_variant_as_string(&_godot_variant);
return *(String *) &s;
}
Variant::operator Vector2() const
{
godot_vector2 s = godot_variant_as_vector2(&_godot_variant);
godot_vector2 s = godot::api->godot_variant_as_vector2(&_godot_variant);
return *(Vector2 *) &s;
}
Variant::operator Rect2() const
{
godot_rect2 s = godot_variant_as_rect2(&_godot_variant);
godot_rect2 s = godot::api->godot_variant_as_rect2(&_godot_variant);
return *(Rect2 *) &s;
}
Variant::operator Vector3() const
{
godot_vector3 s = godot_variant_as_vector3(&_godot_variant);
godot_vector3 s = godot::api->godot_variant_as_vector3(&_godot_variant);
return *(Vector3 *) &s;
}
Variant::operator Plane() const
{
godot_plane s = godot_variant_as_plane(&_godot_variant);
godot_plane s = godot::api->godot_variant_as_plane(&_godot_variant);
return *(Plane *) &s;
}
Variant::operator Rect3() const
{
godot_rect3 s = godot_variant_as_rect3(&_godot_variant);
godot_rect3 s = godot::api->godot_variant_as_rect3(&_godot_variant);
return *(Rect3 *) &s;
}
Variant::operator Quat() const
{
godot_quat s = godot_variant_as_quat(&_godot_variant);
godot_quat s = godot::api->godot_variant_as_quat(&_godot_variant);
return *(Quat *) &s;
}
Variant::operator Basis() const
{
godot_basis s = godot_variant_as_basis(&_godot_variant);
godot_basis s = godot::api->godot_variant_as_basis(&_godot_variant);
return *(Basis *) &s;
}
Variant::operator Transform() const
{
godot_transform s = godot_variant_as_transform(&_godot_variant);
godot_transform s = godot::api->godot_variant_as_transform(&_godot_variant);
return *(Transform *) &s;
}
Variant::operator Transform2D() const
{
godot_transform2d s = godot_variant_as_transform2d(&_godot_variant);
godot_transform2d s = godot::api->godot_variant_as_transform2d(&_godot_variant);
return *(Transform2D *) &s;
}
Variant::operator Color() const
{
godot_color s = godot_variant_as_color(&_godot_variant);
godot_color s = godot::api->godot_variant_as_color(&_godot_variant);
return *(Color *) &s;
}
Variant::operator NodePath() const
{
godot_node_path s = godot_variant_as_node_path(&_godot_variant);
godot_node_path s = godot::api->godot_variant_as_node_path(&_godot_variant);
return *(NodePath *) &s;
}
Variant::operator RID() const
{
godot_rid s = godot_variant_as_rid(&_godot_variant);
godot_rid s = godot::api->godot_variant_as_rid(&_godot_variant);
return *(RID *) &s;
}
Variant::operator Dictionary() const
{
godot_dictionary d = godot_variant_as_dictionary(&_godot_variant);
godot_dictionary d = godot::api->godot_variant_as_dictionary(&_godot_variant);
return *(Dictionary *) &d;
}
Variant::operator Array() const
{
godot_array s = godot_variant_as_array(&_godot_variant);
godot_array s = godot::api->godot_variant_as_array(&_godot_variant);
return *(Array *) &s;
}
Variant::operator PoolByteArray() const
{
godot_pool_byte_array s = godot_variant_as_pool_byte_array(&_godot_variant);
godot_pool_byte_array s = godot::api->godot_variant_as_pool_byte_array(&_godot_variant);
return *(PoolByteArray *) &s;
}
Variant::operator PoolIntArray() const
{
godot_pool_int_array s = godot_variant_as_pool_int_array(&_godot_variant);
godot_pool_int_array s = godot::api->godot_variant_as_pool_int_array(&_godot_variant);
return *(PoolIntArray *) &s;
}
Variant::operator PoolRealArray() const
{
godot_pool_real_array s = godot_variant_as_pool_real_array(&_godot_variant);
godot_pool_real_array s = godot::api->godot_variant_as_pool_real_array(&_godot_variant);
return *(PoolRealArray *) &s;
}
Variant::operator PoolStringArray() const
{
godot_pool_string_array s = godot_variant_as_pool_string_array(&_godot_variant);
godot_pool_string_array s = godot::api->godot_variant_as_pool_string_array(&_godot_variant);
return *(PoolStringArray *) &s;
}
Variant::operator PoolVector2Array() const
{
godot_pool_vector2_array s = godot_variant_as_pool_vector2_array(&_godot_variant);
godot_pool_vector2_array s = godot::api->godot_variant_as_pool_vector2_array(&_godot_variant);
return *(PoolVector2Array *) &s;
}
Variant::operator PoolVector3Array() const
{
godot_pool_vector3_array s = godot_variant_as_pool_vector3_array(&_godot_variant);
godot_pool_vector3_array s = godot::api->godot_variant_as_pool_vector3_array(&_godot_variant);
return *(PoolVector3Array *) &s;
}
Variant::operator PoolColorArray() const
{
godot_pool_color_array s = godot_variant_as_pool_color_array(&_godot_variant);
godot_pool_color_array s = godot::api->godot_variant_as_pool_color_array(&_godot_variant);
return *(PoolColorArray *) &s;
}
Variant::operator Object*() const {
godot_object *o = godot_variant_as_object(&_godot_variant);
godot_object *o = godot::api->godot_variant_as_object(&_godot_variant);
return (Object *) o;
}
Variant::Type Variant::get_type() const
{
return (Type) godot_variant_get_type(&_godot_variant);
return (Type) godot::api->godot_variant_get_type(&_godot_variant);
}
Variant Variant::call(const String& method, const Variant **args, const int arg_count)
{
Variant v;
*(godot_variant *) &v = godot_variant_call(&_godot_variant, (godot_string *) &method, (const godot_variant **)args, arg_count, nullptr);
*(godot_variant *) &v = godot::api->godot_variant_call(&_godot_variant, (godot_string *) &method, (const godot_variant **)args, arg_count, nullptr);
return v;
}
bool Variant::has_method(const String& method)
{
return godot_variant_has_method(&_godot_variant, (godot_string *) &method);
return godot::api->godot_variant_has_method(&_godot_variant, (godot_string *) &method);
}
bool Variant::operator ==(const Variant& b) const
{
return godot_variant_operator_equal(&_godot_variant, &b._godot_variant);
return godot::api->godot_variant_operator_equal(&_godot_variant, &b._godot_variant);
}
bool Variant::operator !=(const Variant& b) const
@ -398,7 +398,7 @@ bool Variant::operator !=(const Variant& b) const
bool Variant::operator <(const Variant& b) const
{
return godot_variant_operator_less(&_godot_variant, &b._godot_variant);
return godot::api->godot_variant_operator_less(&_godot_variant, &b._godot_variant);
}
bool Variant::operator <=(const Variant& b) const
@ -418,17 +418,17 @@ bool Variant::operator >=(const Variant& b) const
bool Variant::hash_compare(const Variant& b) const
{
return godot_variant_hash_compare(&_godot_variant, &b._godot_variant);
return godot::api->godot_variant_hash_compare(&_godot_variant, &b._godot_variant);
}
bool Variant::booleanize() const
{
return godot_variant_booleanize(&_godot_variant);
return godot::api->godot_variant_booleanize(&_godot_variant);
}
Variant::~Variant()
{
godot_variant_destroy(&_godot_variant);
godot::api->godot_variant_destroy(&_godot_variant);
}

View File

@ -6,7 +6,6 @@
#include <cmath>
#include "Basis.hpp"
namespace godot {