Skip to content

Commit a073186

Browse files
author
kbengine
committed
git-svn-id: https://kbengine.svn.sourceforge.net/svnroot/kbengine@262 d26bdfbe-e24b-4f15-971f-8e0596e1bc08
1 parent 1dc9e3d commit a073186

11 files changed

Lines changed: 37 additions & 40 deletions

File tree

‎kbe/src/lib/entitydef/entity_macro.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public: \
131131
return args; \
132132
} \
133133
\
134-
static PyObject* pyGetID(Entity *self, void *closure) \
134+
static PyObject* __pyGetID(Entity *self, void *closure) \
135135
{ \
136136
return PyLong_FromLong(self->getID()); \
137137
} \
@@ -154,7 +154,7 @@ public: \
154154
{ \
155155
spaceID_ = id; \
156156
} \
157-
static PyObject* pyGetSpaceID(Entity *self, void *closure) \
157+
static PyObject* __pyGetSpaceID(Entity *self, void *closure) \
158158
{ \
159159
return PyLong_FromLong(self->getSpaceID()); \
160160
} \

‎kbe/src/lib/entitydef/entitymailboxabstract.cpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@ PyObject* EntityMailboxAbstract::__reduce_ex__(PyObject* self, PyObject* protoco
8383
return args;
8484
}
8585

86+
//-------------------------------------------------------------------------------------
87+
PyObject* EntityMailboxAbstract::pyGetID()
88+
{
89+
return PyLong_FromLong(getID());
90+
}
91+
8692
//-------------------------------------------------------------------------------------
8793

8894
}

‎kbe/src/lib/entitydef/entitymailboxabstract.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class EntityMailboxAbstract : public script::ScriptObject
5151
/** 获取entityID */
5252
ENTITY_ID getID()const{ return id_; }
5353
void setID(int id){ id_ = id; }
54-
static PyObject* pyGetID(PyObject *self, void *closure){ return PyLong_FromLong(static_cast<EntityMailboxAbstract*>(self)->getID()); }
54+
DECLARE_PY_GET_MOTHOD(pyGetID);
5555

5656
/** 获得组件ID */
5757
COMPONENT_ID getComponentID(void)const{ return componentID_; }

‎kbe/src/lib/pyscript/scriptobject.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,14 +509,14 @@ public: \
509509
*/
510510
#define SCRIPT_GETSET_DECLARE_BEGIN(CLASS) PyGetSetDef CLASS::_##CLASS##_scriptGetSeters[] = {
511511
#define SCRIPT_GETSET_DECLARE(NAME, GET, SET, DOC, CLOSURE) {const_cast<char*>(NAME), (getter)GET, (setter)SET, DOC, CLOSURE},
512-
#define SCRIPT_GET_DECLARE(NAME, GET, DOC, CLOSURE) {const_cast<char*>(NAME), (getter)GET, (setter)__py_readonly_descr, DOC, CLOSURE},
512+
#define SCRIPT_GET_DECLARE(NAME, GET, DOC, CLOSURE) {const_cast<char*>(NAME), (getter)__##GET, (setter)__py_readonly_descr, DOC, CLOSURE},
513513
#define SCRIPT_SET_DECLARE(NAME, GET, DOC, CLOSURE) {const_cast<char*>(NAME), (getter)GET, (setter)__py_writeonly_descr, DOC, CLOSURE},
514514
#define SCRIPT_GETSET_DECLARE_END() {NULL, NULL, NULL, NULL, NULL}};
515515

516516
/* 声明一个脚本get方法 */
517517
#define DECLARE_PY_GET_MOTHOD(MNAME) \
518518
PyObject* MNAME(); \
519-
static PyObject* py##MNAME(PyObject *self, void *closure) \
519+
static PyObject* __##MNAME(PyObject *self, void *closure) \
520520
{ \
521521
return static_cast<ThisClass*>(self)->MNAME(); \
522522
} \

‎kbe/src/lib/pyscript/vector2.cpp‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,15 @@ PyObject* ScriptVector2::tp_repr()
165165
}
166166

167167
//-------------------------------------------------------------------------------------
168-
PyObject* ScriptVector2::pyGetVectorLength(PyObject *self, void *closure)
168+
PyObject* ScriptVector2::pyGetVectorLength()
169169
{
170-
ScriptVector2* sv = static_cast<ScriptVector2*>(self);
171-
Vector2& v = sv->getVector();
172-
return PyFloat_FromDouble(KBEVec2Length(&v));
170+
return PyFloat_FromDouble(KBEVec2Length(&getVector()));
173171
}
174172

175173
//-------------------------------------------------------------------------------------
176-
PyObject* ScriptVector2::pyGetVectorLengthSquared(PyObject *self, void *closure)
174+
PyObject* ScriptVector2::pyGetVectorLengthSquared()
177175
{
178-
ScriptVector2* sv = static_cast<ScriptVector2*>(self);
179-
Vector2& v = sv->getVector();
180-
return PyFloat_FromDouble(KBEVec2LengthSq(&v));
176+
return PyFloat_FromDouble(KBEVec2LengthSq(&getVector()));
181177
}
182178

183179
//-------------------------------------------------------------------------------------

‎kbe/src/lib/pyscript/vector2.hpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,9 @@ class ScriptVector2 : public ScriptObject
7272
static PyObject* pyTuple(PyObject* self, PyObject* args);
7373
static PyObject* pyList(PyObject* self, PyObject* args);
7474
static PyObject* pySet(PyObject* self, PyObject* args);
75-
static PyObject* pyGetVectorLength(PyObject *self, void *closure);
76-
static PyObject* pyGetVectorLengthSquared(PyObject *self, void *closure);
75+
76+
DECLARE_PY_GET_MOTHOD(pyGetVectorLength);
77+
DECLARE_PY_GET_MOTHOD(pyGetVectorLengthSquared);
7778

7879
/** 支持pickler 方法 */
7980
static PyObject* __reduce_ex__(PyObject* self, PyObject* protocol);

‎kbe/src/lib/pyscript/vector3.cpp‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,19 +168,15 @@ PyObject* ScriptVector3::tp_repr()
168168
}
169169

170170
//-------------------------------------------------------------------------------------
171-
PyObject* ScriptVector3::pyGetVectorLength(PyObject *self, void *closure)
171+
PyObject* ScriptVector3::pyGetVectorLength()
172172
{
173-
ScriptVector3* sv = static_cast<ScriptVector3*>(self);
174-
Vector3& v = sv->getVector();
175-
return PyFloat_FromDouble(KBEVec3Length(&v));
173+
return PyFloat_FromDouble(KBEVec3Length(&getVector()));
176174
}
177175

178176
//-------------------------------------------------------------------------------------
179-
PyObject* ScriptVector3::pyGetVectorLengthSquared(PyObject *self, void *closure)
177+
PyObject* ScriptVector3::pyGetVectorLengthSquared()
180178
{
181-
ScriptVector3* sv = static_cast<ScriptVector3*>(self);
182-
Vector3& v = sv->getVector();
183-
return PyFloat_FromDouble(KBEVec3LengthSq(&v));
179+
return PyFloat_FromDouble(KBEVec3LengthSq(&getVector()));
184180
}
185181

186182
//-------------------------------------------------------------------------------------

‎kbe/src/lib/pyscript/vector3.hpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,9 @@ class ScriptVector3 : public ScriptObject
7676
static PyObject* pyTuple(PyObject* self, PyObject* args);
7777
static PyObject* pyList(PyObject* self, PyObject* args);
7878
static PyObject* pySet(PyObject* self, PyObject* args);
79-
static PyObject* pyGetVectorLength(PyObject *self, void *closure);
80-
static PyObject* pyGetVectorLengthSquared(PyObject *self, void *closure);
79+
80+
DECLARE_PY_GET_MOTHOD(pyGetVectorLength);
81+
DECLARE_PY_GET_MOTHOD(pyGetVectorLengthSquared);
8182

8283
/** 支持pickler 方法 */
8384
static PyObject* __reduce_ex__(PyObject* self, PyObject* protocol);

‎kbe/src/lib/pyscript/vector4.cpp‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,19 +167,15 @@ PyObject* ScriptVector4::tp_repr()
167167
}
168168

169169
//-------------------------------------------------------------------------------------
170-
PyObject* ScriptVector4::pyGetVectorLength(PyObject *self, void *closure)
170+
PyObject* ScriptVector4::pyGetVectorLength()
171171
{
172-
ScriptVector4* sv = static_cast<ScriptVector4*>(self);
173-
Vector4& v = sv->getVector();
174-
return PyFloat_FromDouble(KBEVec4Length(&v));
172+
return PyFloat_FromDouble(KBEVec4Length(&getVector()));
175173
}
176174

177175
//-------------------------------------------------------------------------------------
178-
PyObject* ScriptVector4::pyGetVectorLengthSquared(PyObject *self, void *closure)
176+
PyObject* ScriptVector4::pyGetVectorLengthSquared()
179177
{
180-
ScriptVector4* sv = static_cast<ScriptVector4*>(self);
181-
Vector4& v = sv->getVector();
182-
return PyFloat_FromDouble(KBEVec4LengthSq(&v));
178+
return PyFloat_FromDouble(KBEVec4LengthSq(&getVector()));
183179
}
184180

185181
//-------------------------------------------------------------------------------------

‎kbe/src/lib/pyscript/vector4.hpp‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,9 @@ class ScriptVector4 : public ScriptObject
7575
static PyObject* pyTuple(PyObject* self, PyObject* args);
7676
static PyObject* pyList(PyObject* self, PyObject* args);
7777
static PyObject* pySet(PyObject* self, PyObject* args);
78-
static PyObject* pyGetVectorLength(PyObject *self, void *closure);
79-
static PyObject* pyGetVectorLengthSquared(PyObject *self, void *closure);
78+
79+
DECLARE_PY_GET_MOTHOD(pyGetVectorLength);
80+
DECLARE_PY_GET_MOTHOD(pyGetVectorLengthSquared);
8081

8182
/** 支持pickler 方法 */
8283
static PyObject* __reduce_ex__(PyObject* self, PyObject* protocol);

0 commit comments

Comments
 (0)