Merge pull request #127 from Redwan13/master

C++14 syntax sugar
pull/130/head
Thomas Herzog 2018-04-25 13:05:57 +02:00 committed by GitHub
commit 6f8ce54b1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 58 additions and 58 deletions

View File

@ -88,17 +88,17 @@ def generate_class_header(used_classes, c):
used_class_name = remove_enum_prefix(extract_nested_type(used_class)) used_class_name = remove_enum_prefix(extract_nested_type(used_class))
if used_class_name not in included: if used_class_name not in included:
included.append(used_class_name) included.append(used_class_name)
source.append("#include <" + used_class_name + ".hpp>") source.append("#include \"" + used_class_name + ".hpp\"")
elif is_enum(used_class) and is_nested_type(used_class) and not is_nested_type(used_class, class_name): elif is_enum(used_class) and is_nested_type(used_class) and not is_nested_type(used_class, class_name):
used_class_name = remove_enum_prefix(used_class) used_class_name = remove_enum_prefix(used_class)
if used_class_name not in included: if used_class_name not in included:
included.append(used_class_name) included.append(used_class_name)
source.append("#include <" + used_class_name + ".hpp>") source.append("#include \"" + used_class_name + ".hpp\"")
source.append("") source.append("")
if c["base_class"] != "": if c["base_class"] != "":
source.append("#include <" + strip_name(c["base_class"]) + ".hpp>") source.append("#include \"" + strip_name(c["base_class"]) + ".hpp\"")
@ -251,7 +251,7 @@ def generate_class_header(used_classes, c):
def generate_class_implementation(icalls, used_classes, c): def generate_class_implementation(icalls, used_classes, c):
class_name = strip_name(c["name"]) class_name = strip_name(c["name"])
source = [] source = []
source.append("#include <" + class_name + ".hpp>") source.append("#include \"" + class_name + ".hpp\"")
source.append("") source.append("")
source.append("") source.append("")
@ -271,7 +271,7 @@ def generate_class_implementation(icalls, used_classes, c):
if is_enum(used_class): if is_enum(used_class):
continue continue
else: else:
source.append("#include <" + strip_name(used_class) + ".hpp>") source.append("#include \"" + strip_name(used_class) + ".hpp\"")
source.append("") source.append("")
source.append("") source.append("")
@ -342,8 +342,8 @@ def generate_class_implementation(icalls, used_classes, c):
source.append("\t___singleton_init();") source.append("\t___singleton_init();")
source.append("\tstatic godot_method_bind *mb = NULL;") source.append("\tstatic godot_method_bind *mb = nullptr;")
source.append("\tif (mb == NULL) {") source.append("\tif (mb == nullptr) {")
source.append("\t\tmb = godot::api->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}") source.append("\t}")
@ -481,7 +481,7 @@ def generate_icall_header(icalls):
source.append("") source.append("")
source.append("#include <core/CoreTypes.hpp>") source.append("#include <core/CoreTypes.hpp>")
source.append("#include <Object.hpp>") source.append("#include \"Object.hpp\"")
source.append("") source.append("")
source.append("") source.append("")
@ -532,7 +532,7 @@ def generate_icall_implementation(icalls):
source.append("#include <core/GodotGlobal.hpp>") source.append("#include <core/GodotGlobal.hpp>")
source.append("#include <core/CoreTypes.hpp>") source.append("#include <core/CoreTypes.hpp>")
source.append("#include <Object.hpp>") source.append("#include \"Object.hpp\"")
source.append("") source.append("")
source.append("") source.append("")

View File

@ -41,8 +41,8 @@ public:
AABB merge(const AABB& p_with) const; AABB merge(const AABB& p_with) const;
void merge_with(const AABB& p_aabb); ///merge with another AABB void merge_with(const AABB& p_aabb); ///merge with another AABB
AABB intersection(const AABB& p_aabb) const; ///get box where two intersect, empty if no intersection occurs AABB intersection(const AABB& p_aabb) const; ///get box where two intersect, empty if no intersection occurs
bool intersects_segment(const Vector3& p_from, const Vector3& p_to,Vector3* r_clip=NULL,Vector3* r_normal=NULL) const; bool intersects_segment(const Vector3& p_from, const Vector3& p_to,Vector3* r_clip=nullptr,Vector3* r_normal=nullptr) const;
bool intersects_ray(const Vector3& p_from, const Vector3& p_dir,Vector3* r_clip=NULL,Vector3* r_normal=NULL) const; bool intersects_ray(const Vector3& p_from, const Vector3& p_dir,Vector3* r_clip=nullptr,Vector3* r_normal=nullptr) const;
bool smits_intersect_ray(const Vector3 &from,const Vector3& p_dir, real_t t0, real_t t1) const; bool smits_intersect_ray(const Vector3 &from,const Vector3& p_dir, real_t t0, real_t t1) const;
bool intersects_convex_shape(const Plane *p_plane, int p_plane_count) const; bool intersects_convex_shape(const Plane *p_plane, int p_plane_count) const;

View File

@ -4,7 +4,7 @@
namespace godot { namespace godot {
enum Error { enum class Error {
OK, OK,
FAILED, ///< Generic fail error FAILED, ///< Generic fail error
ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable ERR_UNAVAILABLE, ///< What is requested is unsupported/unavailable

View File

@ -8,13 +8,13 @@
#include <nativescript/godot_nativescript.h> #include <nativescript/godot_nativescript.h>
#include <core/CoreTypes.hpp> #include "CoreTypes.hpp"
#include <core/Variant.hpp> #include "Variant.hpp"
#include <core/Ref.hpp> #include "Ref.hpp"
#include <Object.hpp> #include "Object.hpp"
#include <core/GodotGlobal.hpp> #include "GodotGlobal.hpp"
namespace godot { namespace godot {
@ -454,7 +454,7 @@ void register_signal(String name, Dictionary args = Dictionary())
signal.num_args = args.size(); signal.num_args = args.size();
signal.num_default_args = 0; signal.num_default_args = 0;
// Need to check because malloc(0) is platform-dependent. Zero arguments will leave args to NULL. // Need to check because malloc(0) is platform-dependent. Zero arguments will leave args to nullptr.
if(signal.num_args != 0) { if(signal.num_args != 0) {
signal.args = (godot_signal_argument*) godot::api->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); memset((void *) signal.args, 0, sizeof(godot_signal_argument) * signal.num_args);

View File

@ -25,7 +25,7 @@ public:
godot_pool_byte_array_read_access *_read_access; godot_pool_byte_array_read_access *_read_access;
public: public:
inline Read() { inline Read() {
_read_access = NULL; _read_access = nullptr;
} }
inline Read(const Read & p_other) { inline Read(const Read & p_other) {
@ -54,7 +54,7 @@ public:
godot_pool_byte_array_write_access *_write_access; godot_pool_byte_array_write_access *_write_access;
public: public:
inline Write() { inline Write() {
_write_access = NULL; _write_access = nullptr;
} }
inline Write(const Write & p_other) { inline Write(const Write & p_other) {
@ -121,7 +121,7 @@ public:
godot_pool_int_array_read_access *_read_access; godot_pool_int_array_read_access *_read_access;
public: public:
inline Read() { inline Read() {
_read_access = NULL; _read_access = nullptr;
} }
inline Read(const Read & p_other) { inline Read(const Read & p_other) {
@ -150,7 +150,7 @@ public:
godot_pool_int_array_write_access *_write_access; godot_pool_int_array_write_access *_write_access;
public: public:
inline Write() { inline Write() {
_write_access = NULL; _write_access = nullptr;
} }
inline Write(const Write & p_other) { inline Write(const Write & p_other) {
@ -217,7 +217,7 @@ public:
godot_pool_real_array_read_access *_read_access; godot_pool_real_array_read_access *_read_access;
public: public:
inline Read() { inline Read() {
_read_access = NULL; _read_access = nullptr;
} }
inline Read(const Read & p_other) { inline Read(const Read & p_other) {
@ -246,7 +246,7 @@ public:
godot_pool_real_array_write_access *_write_access; godot_pool_real_array_write_access *_write_access;
public: public:
inline Write() { inline Write() {
_write_access = NULL; _write_access = nullptr;
} }
inline Write(const Write & p_other) { inline Write(const Write & p_other) {
@ -313,7 +313,7 @@ public:
godot_pool_string_array_read_access *_read_access; godot_pool_string_array_read_access *_read_access;
public: public:
inline Read() { inline Read() {
_read_access = NULL; _read_access = nullptr;
} }
inline Read(const Read & p_other) { inline Read(const Read & p_other) {
@ -342,7 +342,7 @@ public:
godot_pool_string_array_write_access *_write_access; godot_pool_string_array_write_access *_write_access;
public: public:
inline Write() { inline Write() {
_write_access = NULL; _write_access = nullptr;
} }
inline Write(const Write & p_other) { inline Write(const Write & p_other) {
@ -410,7 +410,7 @@ public:
godot_pool_vector2_array_read_access *_read_access; godot_pool_vector2_array_read_access *_read_access;
public: public:
inline Read() { inline Read() {
_read_access = NULL; _read_access = nullptr;
} }
inline Read(const Read & p_other) { inline Read(const Read & p_other) {
@ -439,7 +439,7 @@ public:
godot_pool_vector2_array_write_access *_write_access; godot_pool_vector2_array_write_access *_write_access;
public: public:
inline Write() { inline Write() {
_write_access = NULL; _write_access = nullptr;
} }
inline Write(const Write & p_other) { inline Write(const Write & p_other) {
@ -506,7 +506,7 @@ public:
godot_pool_vector3_array_read_access *_read_access; godot_pool_vector3_array_read_access *_read_access;
public: public:
inline Read() { inline Read() {
_read_access = NULL; _read_access = nullptr;
} }
inline Read(const Read & p_other) { inline Read(const Read & p_other) {
@ -535,7 +535,7 @@ public:
godot_pool_vector3_array_write_access *_write_access; godot_pool_vector3_array_write_access *_write_access;
public: public:
inline Write() { inline Write() {
_write_access = NULL; _write_access = nullptr;
} }
inline Write(const Write & p_other) { inline Write(const Write & p_other) {
@ -602,7 +602,7 @@ public:
godot_pool_color_array_read_access *_read_access; godot_pool_color_array_read_access *_read_access;
public: public:
inline Read() { inline Read() {
_read_access = NULL; _read_access = nullptr;
} }
inline Read(const Read & p_other) { inline Read(const Read & p_other) {
@ -631,7 +631,7 @@ public:
godot_pool_color_array_write_access *_write_access; godot_pool_color_array_write_access *_write_access;
public: public:
inline Write() { inline Write() {
_write_access = NULL; _write_access = nullptr;
} }
inline Write(const Write & p_other) { inline Write(const Write & p_other) {

View File

@ -14,7 +14,7 @@ class String;
typedef Vector2 Size2; typedef Vector2 Size2;
typedef Vector2 Point2; typedef Vector2 Point2;
class Transform2D; struct Transform2D;
struct Rect2 { struct Rect2 {
@ -45,7 +45,7 @@ struct Rect2 {
bool intersects_transformed(const Transform2D& p_xform, const Rect2& p_rect) const; bool intersects_transformed(const Transform2D& p_xform, const Rect2& p_rect) const;
bool intersects_segment(const Point2& p_from, const Point2& p_to, Point2* r_pos=NULL, Point2* r_normal=NULL) const; bool intersects_segment(const Point2& p_from, const Point2& p_to, Point2* r_pos=nullptr, Point2* r_normal=nullptr) const;
inline bool encloses(const Rect2& p_rect) const { inline bool encloses(const Rect2& p_rect) const {

View File

@ -12,7 +12,7 @@ namespace godot {
template <class T> template <class T>
class Ref { class Ref {
T *reference = NULL; T *reference = nullptr;
void ref(const Ref &p_from) { void ref(const Ref &p_from) {
@ -101,7 +101,7 @@ public:
//r.reference = Object::cast_to<T>(refb); //r.reference = Object::cast_to<T>(refb);
r.reference = (T*)refb; r.reference = (T*)refb;
ref(r); ref(r);
r.reference = NULL; r.reference = nullptr;
} }
void operator=(const Variant &p_variant) { void operator=(const Variant &p_variant) {
@ -117,19 +117,19 @@ public:
//r.reference = Object::cast_to<T>(refb); //r.reference = Object::cast_to<T>(refb);
r.reference = (T *)refb; r.reference = (T *)refb;
ref(r); ref(r);
r.reference = NULL; r.reference = nullptr;
} }
Ref(const Ref &p_from) { Ref(const Ref &p_from) {
reference = NULL; reference = nullptr;
ref(p_from); ref(p_from);
} }
template <class T_Other> template <class T_Other>
Ref(const Ref<T_Other> &p_from) { Ref(const Ref<T_Other> &p_from) {
reference = NULL; reference = nullptr;
// TODO We need a safe cast // TODO We need a safe cast
Reference *refb = const_cast<Reference *>(static_cast<const Reference *>(p_from.ptr())); Reference *refb = const_cast<Reference *>(static_cast<const Reference *>(p_from.ptr()));
if (!refb) { if (!refb) {
@ -141,7 +141,7 @@ public:
//r.reference = Object::cast_to<T>(refb); //r.reference = Object::cast_to<T>(refb);
r.reference = (T *)refb; r.reference = (T *)refb;
ref(r); ref(r);
r.reference = NULL; r.reference = nullptr;
} }
Ref(T *p_reference) { Ref(T *p_reference) {
@ -149,12 +149,12 @@ public:
if (p_reference) if (p_reference)
ref_pointer(p_reference); ref_pointer(p_reference);
else else
reference = NULL; reference = nullptr;
} }
Ref(const Variant &p_variant) { Ref(const Variant &p_variant) {
reference = NULL; reference = nullptr;
// TODO We need a safe cast // TODO We need a safe cast
Reference *refb = (Reference *) (Object *) p_variant; Reference *refb = (Reference *) (Object *) p_variant;
if (!refb) { if (!refb) {
@ -166,11 +166,11 @@ public:
//r.reference = Object::cast_to<T>(refb); //r.reference = Object::cast_to<T>(refb);
r.reference = (T *)refb; r.reference = (T *)refb;
ref(r); ref(r);
r.reference = NULL; r.reference = nullptr;
} }
inline bool is_valid() const { return reference != NULL; } inline bool is_valid() const { return reference != nullptr; }
inline bool is_null() const { return reference == NULL; } inline bool is_null() const { return reference == nullptr; }
void unref() { void unref() {
//TODO this should be moved to mutexes, since this engine does not really //TODO this should be moved to mutexes, since this engine does not really
@ -182,7 +182,7 @@ public:
//memdelete(reference); //memdelete(reference);
delete reference; delete reference;
} }
reference = NULL; reference = nullptr;
} }
void instance() { void instance() {
@ -192,7 +192,7 @@ public:
Ref() { Ref() {
reference = NULL; reference = nullptr;
} }
~Ref() { ~Ref() {

View File

@ -8,7 +8,7 @@ namespace godot {
typedef Vector2 Size2; typedef Vector2 Size2;
class Rect2; struct Rect2;
struct Transform2D { struct Transform2D {
// Warning #1: basis of Transform2D is stored differently from Basis. In terms of elements array, the basis matrix looks like "on paper": // Warning #1: basis of Transform2D is stored differently from Basis. In terms of elements array, the basis matrix looks like "on paper":

View File

@ -5,8 +5,8 @@
namespace godot { namespace godot {
void *_RegisterState::nativescript_handle; void *_RegisterState::nativescript_handle;
const godot_gdnative_core_api_struct *api = NULL; const godot_gdnative_core_api_struct *api = nullptr;
const godot_gdnative_ext_nativescript_api_struct *nativescript_api = NULL; const godot_gdnative_ext_nativescript_api_struct *nativescript_api = nullptr;
void Godot::print(const String& message) void Godot::print(const String& message)
{ {
@ -21,13 +21,13 @@ void Godot::print_warning(const String& description, const String& function, con
char * c_func = function.alloc_c_string(); char * c_func = function.alloc_c_string();
char * c_file = file.alloc_c_string(); char * c_file = file.alloc_c_string();
if (c_desc != NULL && c_func !=NULL && c_file != NULL) { if (c_desc != nullptr && c_func !=nullptr && c_file != nullptr) {
godot::api->godot_print_warning(c_desc, c_func, c_file, line); godot::api->godot_print_warning(c_desc, c_func, c_file, line);
}; };
if (c_desc != NULL) godot::api->godot_free(c_desc); if (c_desc != nullptr) godot::api->godot_free(c_desc);
if (c_func != NULL) godot::api->godot_free(c_func); if (c_func != nullptr) godot::api->godot_free(c_func);
if (c_file != NULL) godot::api->godot_free(c_file); if (c_file != nullptr) godot::api->godot_free(c_file);
} }
void Godot::print_error(const String& description, const String& function, const String& file, int line) void Godot::print_error(const String& description, const String& function, const String& file, int line)
@ -38,13 +38,13 @@ void Godot::print_error(const String& description, const String& function, const
char * c_func = function.alloc_c_string(); char * c_func = function.alloc_c_string();
char * c_file = file.alloc_c_string(); char * c_file = file.alloc_c_string();
if (c_desc != NULL && c_func !=NULL && c_file != NULL) { if (c_desc != nullptr && c_func !=nullptr && c_file != nullptr) {
godot::api->godot_print_error(c_desc, c_func, c_file, line); godot::api->godot_print_error(c_desc, c_func, c_file, line);
}; };
if (c_desc != NULL) godot::api->godot_free(c_desc); if (c_desc != nullptr) godot::api->godot_free(c_desc);
if (c_func != NULL) godot::api->godot_free(c_func); if (c_func != nullptr) godot::api->godot_free(c_func);
if (c_file != NULL) godot::api->godot_free(c_file); if (c_file != nullptr) godot::api->godot_free(c_file);
} }
void Godot::gdnative_init(godot_gdnative_init_options *options) void Godot::gdnative_init(godot_gdnative_init_options *options)