Skip to content

Commit 1cb47ef

Browse files
committed
added *.ipp.
1 parent 0f82cdb commit 1cb47ef

17 files changed

Lines changed: 386 additions & 47 deletions

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

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,33 @@ class Map : public ScriptObject
3636
Map(PyTypeObject* pyType, bool isInitialised = false);
3737
virtual ~Map();
3838

39-
/** 暴露一些字典方法给python */
39+
/**
40+
暴露一些字典方法给python
41+
*/
4042
static PyObject* __py_has_key(PyObject* self, PyObject* args);
4143
static PyObject* __py_keys(PyObject* self, PyObject* args);
4244
static PyObject* __py_values(PyObject* self, PyObject* args);
4345
static PyObject* __py_items(PyObject* self, PyObject* args);
4446
static PyObject* __py_update(PyObject* self, PyObject* args);
4547

46-
/** map操作函数相关 */
48+
/**
49+
map操作函数相关
50+
*/
4751
static PyObject* mp_subscript(PyObject* self, PyObject* key);
4852

4953
static int mp_ass_subscript(PyObject* self,
5054
PyObject* key, PyObject* value);
5155

5256
static int mp_length(PyObject* self);
5357

54-
/** 获取字典对象 */
55-
PyObject* getDictObject(void)const{ return pyDict_;}
58+
/**
59+
获取字典对象
60+
*/
61+
INLINE PyObject* getDictObject(void)const;
5662

57-
/** 数据改变通知 */
63+
/**
64+
数据改变通知
65+
*/
5866
virtual void onDataChanged(std::string& key, std::string& value,
5967
bool isDelete = false);
6068

@@ -64,4 +72,9 @@ class Map : public ScriptObject
6472

6573
}
6674
}
75+
76+
#ifdef CODE_INLINE
77+
#include "map.ipp"
78+
#endif
79+
6780
#endif

‎kbe/src/lib/pyscript/map.ipp‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
This source file is part of KBEngine
3+
For the latest info, see http://www.kbengine.org/
4+
5+
Copyright (c) 2008-2012 KBEngine.
6+
7+
KBEngine is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU Lesser General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
KBEngine is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public License
18+
along with KBEngine. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
22+
namespace KBEngine {
23+
namespace script{
24+
25+
INLINE PyObject* Map::getDictObject(void)const
26+
{
27+
return pyDict_;
28+
}
29+
30+
}
31+
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,16 @@ class PyMemoryStream : public ScriptObject
3737
PyMemoryStream(PyTypeObject* pyType, bool isInitialised = false);
3838
virtual ~PyMemoryStream();
3939

40+
INLINE MemoryStream& stream();
4041
protected:
4142
MemoryStream stream_;
4243
} ;
4344

4445
}
4546
}
4647

48+
#ifdef CODE_INLINE
49+
#include "py_memorystream.ipp"
50+
#endif
51+
4752
#endif
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
This source file is part of KBEngine
3+
For the latest info, see http://www.kbengine.org/
4+
5+
Copyright (c) 2008-2012 KBEngine.
6+
7+
KBEngine is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU Lesser General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
KBEngine is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public License
18+
along with KBEngine. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
22+
namespace KBEngine {
23+
namespace script{
24+
25+
INLINE MemoryStream& PyMemoryStream::stream()
26+
{
27+
return stream_;
28+
}
29+
30+
}
31+
}
32+

‎kbe/src/lib/pyscript/pyscript90.vcproj‎

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@
157157
<File
158158
RelativePath=".\copy.cpp"
159159
>
160-
</File>
160+
</File>
161161
<File
162162
RelativePath=".\map.cpp"
163163
>
@@ -183,15 +183,15 @@
183183
>
184184
</File>
185185
<File
186-
RelativePath="scriptObject.cpp"
186+
RelativePath="scriptobject.cpp"
187187
>
188188
</File>
189189
<File
190-
RelativePath="scriptStdOutErr.cpp"
190+
RelativePath="scriptstdouterr.cpp"
191191
>
192192
</File>
193193
<File
194-
RelativePath="scriptStdOutErrHook.cpp"
194+
RelativePath="scriptstdouterrhook.cpp"
195195
>
196196
</File>
197197
<File
@@ -261,15 +261,15 @@
261261
>
262262
</File>
263263
<File
264-
RelativePath="scriptObject.hpp"
264+
RelativePath="scriptobject.hpp"
265265
>
266266
</File>
267267
<File
268-
RelativePath="scriptStdOutErr.hpp"
268+
RelativePath="scriptstdouterr.hpp"
269269
>
270270
</File>
271271
<File
272-
RelativePath="scriptStdOutErrHook.hpp"
272+
RelativePath="scriptstdouterrhook.hpp"
273273
>
274274
</File>
275275
<File
@@ -299,10 +299,42 @@
299299
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
300300
>
301301
</Filter>
302+
<File
303+
RelativePath=".\map.ipp"
304+
>
305+
</File>
306+
<File
307+
RelativePath=".\py_memorystream.ipp"
308+
>
309+
</File>
310+
<File
311+
RelativePath=".\pywatcher.ipp"
312+
>
313+
</File>
302314
<File
303315
RelativePath=".\ReadMe.txt"
304316
>
305317
</File>
318+
<File
319+
RelativePath=".\script.ipp"
320+
>
321+
</File>
322+
<File
323+
RelativePath=".\scriptobject.ipp"
324+
>
325+
</File>
326+
<File
327+
RelativePath=".\scriptstdouterr.ipp"
328+
>
329+
</File>
330+
<File
331+
RelativePath=".\scriptstdouterrhook.ipp"
332+
>
333+
</File>
334+
<File
335+
RelativePath=".\sequence.ipp"
336+
>
337+
</File>
306338
</Files>
307339
<Globals>
308340
</Globals>

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

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -54,26 +54,7 @@ class PyWatcherObject : public WatcherObject
5454
(*s) << id_ << getVal();
5555
};
5656

57-
T getVal()
58-
{
59-
T v;
60-
61-
PyObject* pyObj1 = PyObject_CallFunction(pyCallable_, const_cast<char*>(""));
62-
if(!pyObj1)
63-
{
64-
PyErr_Format(PyExc_Exception, "PyWatcherObject::addToStream: callFunction is error! path=%s name=%s.\n",
65-
path(), name());
66-
PyErr_PrintEx(0);
67-
}
68-
else
69-
{
70-
readVal(pyObj1, v);
71-
SCRIPT_ERROR_CHECK();
72-
Py_DECREF(pyObj1);
73-
}
74-
75-
return v;
76-
}
57+
INLINE T getVal();
7758

7859
void readVal(PyObject* pyVal, T& v)
7960
{
@@ -162,4 +143,9 @@ bool initializePyWatcher(Script* pScript);
162143

163144
}
164145
}
146+
147+
#ifdef CODE_INLINE
148+
#include "pywatcher.ipp"
149+
#endif
150+
165151
#endif

‎kbe/src/lib/pyscript/pywatcher.ipp‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
This source file is part of KBEngine
3+
For the latest info, see http://www.kbengine.org/
4+
5+
Copyright (c) 2008-2012 KBEngine.
6+
7+
KBEngine is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU Lesser General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
KBEngine is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public License
18+
along with KBEngine. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
22+
namespace KBEngine {
23+
namespace script{
24+
25+
template <class T>
26+
INLINE T PyWatcherObject<T>::getVal()
27+
{
28+
T v;
29+
30+
PyObject* pyObj1 = PyObject_CallFunction(pyCallable_, const_cast<char*>(""));
31+
if(!pyObj1)
32+
{
33+
PyErr_Format(PyExc_Exception, "PyWatcherObject::addToStream: callFunction is error! path=%s name=%s.\n",
34+
path(), name());
35+
PyErr_PrintEx(0);
36+
}
37+
else
38+
{
39+
readVal(pyObj1, v);
40+
SCRIPT_ERROR_CHECK();
41+
Py_DECREF(pyObj1);
42+
}
43+
44+
return v;
45+
}
46+
47+
}
48+
}
49+

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

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,21 @@ class Script
5454
Script();
5555
virtual ~Script();
5656

57-
/** 安装和卸载脚本模块 */
57+
/**
58+
安装和卸载脚本模块
59+
*/
5860
virtual bool install(const wchar_t* pythonHomeDir, std::wstring pyPaths,
5961
const char* moduleName, COMPONENT_TYPE componentType);
6062

6163
virtual bool uninstall(void);
6264

63-
/** 获取脚本基础模块 */
64-
PyObject* getModule(void)const { return module_; }
65+
/**
66+
获取脚本基础模块
67+
*/
68+
INLINE PyObject* getModule(void)const;
6569

6670
int run_simpleString(const char* command, std::string* retBufferPtr);
67-
int run_simpleString(std::string command, std::string* retBufferPtr)
68-
{
69-
return run_simpleString(command.c_str(), retBufferPtr);
70-
}
71+
INLINE int run_simpleString(std::string command, std::string* retBufferPtr);
7172

7273
int registerToModule(const char* attrName, PyObject* pyObj);
7374
int unregisterToModule(const char* attrName);
@@ -86,4 +87,9 @@ class Script
8687

8788
}
8889
}
90+
91+
#ifdef CODE_INLINE
92+
#include "script.ipp"
93+
#endif
94+
8995
#endif

‎kbe/src/lib/pyscript/script.ipp‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
This source file is part of KBEngine
3+
For the latest info, see http://www.kbengine.org/
4+
5+
Copyright (c) 2008-2012 KBEngine.
6+
7+
KBEngine is free software: you can redistribute it and/or modify
8+
it under the terms of the GNU Lesser General Public License as published by
9+
the Free Software Foundation, either version 3 of the License, or
10+
(at your option) any later version.
11+
12+
KBEngine is distributed in the hope that it will be useful,
13+
but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
GNU Lesser General Public License for more details.
16+
17+
You should have received a copy of the GNU Lesser General Public License
18+
along with KBEngine. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
21+
22+
namespace KBEngine {
23+
namespace script{
24+
25+
INLINE int Script::run_simpleString(std::string command, std::string* retBufferPtr)
26+
{
27+
return run_simpleString(command.c_str(), retBufferPtr);
28+
}
29+
30+
INLINE PyObject* Script::getModule(void)const
31+
{
32+
return module_;
33+
}
34+
35+
}
36+
}
37+

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,4 +525,10 @@ class ScriptObject: public PyObject
525525

526526
}
527527
}
528+
529+
530+
#ifdef CODE_INLINE
531+
#include "scriptobject.ipp"
532+
#endif
533+
528534
#endif

0 commit comments

Comments
 (0)