Skip to content

Commit 2fb6353

Browse files
committed
up
1 parent 1d0c9ba commit 2fb6353

File tree

1 file changed

+57
-5
lines changed

1 file changed

+57
-5
lines changed

kbe/src/lib/entitydef/entity_macro.h

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ public: \
11151115
Py_RETURN_FALSE; \
11161116
} \
11171117
\
1118-
const char* eventName; \
1118+
const char* eventName = NULL; \
11191119
PyObject* pycallback = NULL; \
11201120
if(PyArg_ParseTuple(args, "sO", &eventName, &pycallback) == -1) \
11211121
{ \
@@ -1125,6 +1125,14 @@ public: \
11251125
Py_RETURN_FALSE; \
11261126
} \
11271127
\
1128+
if(!eventName) \
1129+
{ \
1130+
PyErr_Format(PyExc_AssertionError, "%s::registerEvent:: eventName error!", pobj->scriptName()); \
1131+
PyErr_PrintEx(0); \
1132+
pycallback = NULL; \
1133+
Py_RETURN_FALSE; \
1134+
} \
1135+
\
11281136
return PyBool_FromLong(pobj->registerEvent(eventName, pycallback)); \
11291137
} \
11301138
\
@@ -1143,7 +1151,7 @@ public: \
11431151
Py_RETURN_FALSE; \
11441152
} \
11451153
\
1146-
const char* eventName; \
1154+
const char* eventName = NULL; \
11471155
PyObject* pycallback = NULL; \
11481156
if(PyArg_ParseTuple(args, "sO", &eventName, &pycallback) == -1) \
11491157
{ \
@@ -1153,6 +1161,14 @@ public: \
11531161
Py_RETURN_FALSE; \
11541162
} \
11551163
\
1164+
if(!eventName) \
1165+
{ \
1166+
PyErr_Format(PyExc_AssertionError, "%s::deregisterEvent:: eventName error!", pobj->scriptName());\
1167+
PyErr_PrintEx(0); \
1168+
pycallback = NULL; \
1169+
Py_RETURN_FALSE; \
1170+
} \
1171+
\
11561172
return PyBool_FromLong(pobj->deregisterEvent(eventName, pycallback)); \
11571173
} \
11581174
\
@@ -1171,7 +1187,7 @@ public: \
11711187
Py_RETURN_FALSE; \
11721188
} \
11731189
\
1174-
char* eventName; \
1190+
char* eventName = NULL; \
11751191
if(currargsSize == 1) \
11761192
{ \
11771193
if(PyArg_ParseTuple(args, "s", &eventName) == -1) \
@@ -1181,6 +1197,13 @@ public: \
11811197
Py_RETURN_FALSE; \
11821198
} \
11831199
\
1200+
if(!eventName) \
1201+
{ \
1202+
PyErr_Format(PyExc_AssertionError, "%s::fireEvent:: eventName error!", pobj->scriptName()); \
1203+
PyErr_PrintEx(0); \
1204+
Py_RETURN_FALSE; \
1205+
} \
1206+
\
11841207
pobj->fireEvent(eventName); \
11851208
} \
11861209
else if(currargsSize == 2) \
@@ -1193,6 +1216,13 @@ public: \
11931216
Py_RETURN_FALSE; \
11941217
} \
11951218
\
1219+
if(!eventName) \
1220+
{ \
1221+
PyErr_Format(PyExc_AssertionError, "%s::fireEvent:: eventName error!", pobj->scriptName()); \
1222+
PyErr_PrintEx(0); \
1223+
Py_RETURN_FALSE; \
1224+
} \
1225+
\
11961226
PyObject* pyargs = PyTuple_New(1); \
11971227
Py_INCREF(pyobj); \
11981228
PyTuple_SET_ITEM(pyargs, 0, pyobj); \
@@ -1202,6 +1232,14 @@ public: \
12021232
else \
12031233
{ \
12041234
PyObject* pyEvnName = PyTuple_GET_ITEM(args, 0); \
1235+
\
1236+
if(!PyUnicode_Check(pyEvnName)) \
1237+
{ \
1238+
PyErr_Format(PyExc_AssertionError, "%s::fireEvent:: eventName error!", pobj->scriptName()); \
1239+
PyErr_PrintEx(0); \
1240+
Py_RETURN_FALSE; \
1241+
} \
1242+
\
12051243
wchar_t* PyUnicode_AsWideCharStringRet0 = PyUnicode_AsWideCharString(pyEvnName, NULL); \
12061244
eventName = strutil::wchar2char(PyUnicode_AsWideCharStringRet0); \
12071245
PyMem_Free(PyUnicode_AsWideCharStringRet0); \
@@ -1257,7 +1295,7 @@ public: \
12571295
Py_RETURN_NONE; \
12581296
} \
12591297
\
1260-
char* componentName; \
1298+
char* componentName = NULL; \
12611299
if(currargsSize == 1) \
12621300
{ \
12631301
if(PyArg_ParseTuple(args, "s", &componentName) == -1) \
@@ -1267,6 +1305,13 @@ public: \
12671305
Py_RETURN_NONE; \
12681306
} \
12691307
\
1308+
if(!componentName) \
1309+
{ \
1310+
PyErr_Format(PyExc_AssertionError, "%s::getComponent:: componentName error!", pobj->scriptName());\
1311+
PyErr_PrintEx(0); \
1312+
Py_RETURN_NONE; \
1313+
} \
1314+
\
12701315
return pobj->pyGetComponent(componentName, false); \
12711316
} \
12721317
else if(currargsSize == 2) \
@@ -1276,7 +1321,14 @@ public: \
12761321
{ \
12771322
PyErr_Format(PyExc_AssertionError, "%s::getComponent:: args error!", pobj->scriptName()); \
12781323
PyErr_PrintEx(0); \
1279-
Py_RETURN_FALSE; \
1324+
Py_RETURN_NONE; \
1325+
} \
1326+
\
1327+
if(!componentName) \
1328+
{ \
1329+
PyErr_Format(PyExc_AssertionError, "%s::getComponent:: componentName error!", pobj->scriptName());\
1330+
PyErr_PrintEx(0); \
1331+
Py_RETURN_NONE; \
12801332
} \
12811333
\
12821334
return pobj->pyGetComponent(componentName, (pyobj == Py_True)); \

0 commit comments

Comments
 (0)