diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/class_db.h | 2 | ||||
-rw-r--r-- | core/io/packet_peer_udp.h | 2 | ||||
-rw-r--r-- | core/io/tcp_server.h | 2 | ||||
-rw-r--r-- | core/math/plane.cpp | 4 | ||||
-rw-r--r-- | core/math/plane.h | 4 | ||||
-rw-r--r-- | core/method_ptrcall.h | 57 | ||||
-rw-r--r-- | core/pair.h | 2 | ||||
-rw-r--r-- | core/vector.h | 8 |
8 files changed, 61 insertions, 20 deletions
diff --git a/core/class_db.h b/core/class_db.h index f73e082c52..4287c5990f 100644 --- a/core/class_db.h +++ b/core/class_db.h @@ -45,7 +45,7 @@ struct ParamHint { String hint_text; Variant default_val; - ParamHint(const String &p_name = "", PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_text = "", Variant p_default_val = Variant()) + ParamHint(const String &p_name = "", PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_text = "", const Variant &p_default_val = Variant()) : name(p_name), hint(p_hint), hint_text(p_hint_text), diff --git a/core/io/packet_peer_udp.h b/core/io/packet_peer_udp.h index a39eb6bcfd..007b810b67 100644 --- a/core/io/packet_peer_udp.h +++ b/core/io/packet_peer_udp.h @@ -49,7 +49,7 @@ protected: public: void set_blocking_mode(bool p_enable); - virtual Error listen(int p_port, IP_Address p_bind_address = IP_Address("*"), int p_recv_buffer_size = 65536) = 0; + virtual Error listen(int p_port, const IP_Address &p_bind_address = IP_Address("*"), int p_recv_buffer_size = 65536) = 0; virtual void close() = 0; virtual Error wait() = 0; virtual bool is_listening() const = 0; diff --git a/core/io/tcp_server.h b/core/io/tcp_server.h index 4e7fa7cf3e..b4ff3246ad 100644 --- a/core/io/tcp_server.h +++ b/core/io/tcp_server.h @@ -45,7 +45,7 @@ protected: static void _bind_methods(); public: - virtual Error listen(uint16_t p_port, const IP_Address p_bind_address = IP_Address("*")) = 0; + virtual Error listen(uint16_t p_port, const IP_Address &p_bind_address = IP_Address("*")) = 0; virtual bool is_connection_available() const = 0; virtual Ref<StreamPeerTCP> take_connection() = 0; diff --git a/core/math/plane.cpp b/core/math/plane.cpp index f5e92866c4..17928d07c3 100644 --- a/core/math/plane.cpp +++ b/core/math/plane.cpp @@ -103,7 +103,7 @@ bool Plane::intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r return true; } -bool Plane::intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3 *p_intersection) const { +bool Plane::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection) const { Vector3 segment = p_dir; real_t den = normal.dot(segment); @@ -128,7 +128,7 @@ bool Plane::intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3 *p_intersectio return true; } -bool Plane::intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3 *p_intersection) const { +bool Plane::intersects_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 *p_intersection) const { Vector3 segment = p_begin - p_end; real_t den = normal.dot(segment); diff --git a/core/math/plane.h b/core/math/plane.h index 92ebcd8024..73d584e553 100644 --- a/core/math/plane.h +++ b/core/math/plane.h @@ -56,8 +56,8 @@ public: /* intersections */ bool intersect_3(const Plane &p_plane1, const Plane &p_plane2, Vector3 *r_result = 0) const; - bool intersects_ray(Vector3 p_from, Vector3 p_dir, Vector3 *p_intersection) const; - bool intersects_segment(Vector3 p_begin, Vector3 p_end, Vector3 *p_intersection) const; + bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *p_intersection) const; + bool intersects_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 *p_intersection) const; _FORCE_INLINE_ Vector3 project(const Vector3 &p_point) const { diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h index ead58c23c8..d8755fd98b 100644 --- a/core/method_ptrcall.h +++ b/core/method_ptrcall.h @@ -80,6 +80,26 @@ struct PtrToArg { } \ } +#define MAKE_PTRARG_BY_REFERENCE(m_type) \ + template <> \ + struct PtrToArg<m_type> { \ + _FORCE_INLINE_ static m_type convert(const void *p_ptr) { \ + return *reinterpret_cast<const m_type *>(p_ptr); \ + } \ + _FORCE_INLINE_ static void encode(const m_type &p_val, void *p_ptr) { \ + *((m_type *)p_ptr) = p_val; \ + } \ + }; \ + template <> \ + struct PtrToArg<const m_type &> { \ + _FORCE_INLINE_ static m_type convert(const void *p_ptr) { \ + return *reinterpret_cast<const m_type *>(p_ptr); \ + } \ + _FORCE_INLINE_ static void encode(const m_type &p_val, void *p_ptr) { \ + *((m_type *)p_ptr) = p_val; \ + } \ + } + MAKE_PTRARG(bool); MAKE_PTRARGCONV(uint8_t, int64_t); MAKE_PTRARGCONV(int8_t, int64_t); @@ -95,14 +115,14 @@ MAKE_PTRARG(double); MAKE_PTRARG(String); MAKE_PTRARG(Vector2); MAKE_PTRARG(Rect2); -MAKE_PTRARG(Vector3); +MAKE_PTRARG_BY_REFERENCE(Vector3); MAKE_PTRARG(Transform2D); -MAKE_PTRARG(Plane); +MAKE_PTRARG_BY_REFERENCE(Plane); MAKE_PTRARG(Quat); -MAKE_PTRARG(Rect3); -MAKE_PTRARG(Basis); -MAKE_PTRARG(Transform); -MAKE_PTRARG(Color); +MAKE_PTRARG_BY_REFERENCE(Rect3); +MAKE_PTRARG_BY_REFERENCE(Basis); +MAKE_PTRARG_BY_REFERENCE(Transform); +MAKE_PTRARG_BY_REFERENCE(Color); MAKE_PTRARG(NodePath); MAKE_PTRARG(RID); MAKE_PTRARG(Dictionary); @@ -114,7 +134,7 @@ MAKE_PTRARG(PoolStringArray); MAKE_PTRARG(PoolVector2Array); MAKE_PTRARG(PoolVector3Array); MAKE_PTRARG(PoolColorArray); -MAKE_PTRARG(Variant); +MAKE_PTRARG_BY_REFERENCE(Variant); //this is for Object @@ -311,8 +331,29 @@ MAKE_DVECARR(Plane); } \ } +#define MAKE_STRINGCONV_BY_REFERENCE(m_type) \ + template <> \ + struct PtrToArg<m_type> { \ + _FORCE_INLINE_ static m_type convert(const void *p_ptr) { \ + m_type s = *reinterpret_cast<const String *>(p_ptr); \ + return s; \ + } \ + _FORCE_INLINE_ static void encode(const m_type &p_vec, void *p_ptr) { \ + String *arr = reinterpret_cast<String *>(p_ptr); \ + *arr = p_vec; \ + } \ + }; \ + \ + template <> \ + struct PtrToArg<const m_type &> { \ + _FORCE_INLINE_ static m_type convert(const void *p_ptr) { \ + m_type s = *reinterpret_cast<const String *>(p_ptr); \ + return s; \ + } \ + } + MAKE_STRINGCONV(StringName); -MAKE_STRINGCONV(IP_Address); +MAKE_STRINGCONV_BY_REFERENCE(IP_Address); template <> struct PtrToArg<PoolVector<Face3> > { diff --git a/core/pair.h b/core/pair.h index d4b1897537..d517339ddf 100644 --- a/core/pair.h +++ b/core/pair.h @@ -37,7 +37,7 @@ struct Pair { S second; Pair() {} - Pair(F p_first, S p_second) + Pair(F p_first, const S &p_second) : first(p_first), second(p_second) { } diff --git a/core/vector.h b/core/vector.h index 5eed8dce96..9f523c567c 100644 --- a/core/vector.h +++ b/core/vector.h @@ -117,7 +117,7 @@ public: } _FORCE_INLINE_ bool empty() const { return _ptr == 0; } Error resize(int p_size); - bool push_back(T p_elem); + bool push_back(const T &p_elem); void remove(int p_index); void erase(const T &p_val) { @@ -129,7 +129,7 @@ public: template <class T_val> int find(const T_val &p_val, int p_from = 0) const; - void set(int p_index, T p_elem); + void set(int p_index, const T &p_elem); T get(int p_index) const; inline T &operator[](int p_index) { @@ -336,7 +336,7 @@ void Vector<T>::invert() { } template <class T> -void Vector<T>::set(int p_index, T p_elem) { +void Vector<T>::set(int p_index, const T &p_elem) { operator[](p_index) = p_elem; } @@ -348,7 +348,7 @@ T Vector<T>::get(int p_index) const { } template <class T> -bool Vector<T>::push_back(T p_elem) { +bool Vector<T>::push_back(const T &p_elem) { Error err = resize(size() + 1); ERR_FAIL_COND_V(err, true) |