Skip to content

Commit d49a2dc

Browse files
committed
Replaced get_exposed_classes() with the dict EXPOSED_CLASSES
- Type and Key are now subclasses of object - EntityEnumerator.enum_entity is now a pure virtual
1 parent e4c7b8f commit d49a2dc

File tree

7 files changed

+10
-35
lines changed

7 files changed

+10
-35
lines changed

addons/source-python/packages/source-python/memory/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
'alloc',
2929
'find_binary',
3030
'get_error',
31-
'get_exposed_classes',
31+
'EXPOSED_CLASSES',
3232
'get_object_pointer',
3333
'get_size',
3434
'make_object'

addons/source-python/packages/source-python/memory/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
# =============================================================================
3030
# >> Type
3131
# =============================================================================
32-
class Type:
32+
class Type(object):
3333
'''
3434
This class is used to specify the type of an attribute or array created by
3535
a TypeManager instance.
@@ -64,7 +64,7 @@ def is_native(type_name):
6464
# =============================================================================
6565
# >> Key
6666
# =============================================================================
67-
class Key:
67+
class Key(object):
6868
'''
6969
This class holds some constants and provides converters for parse_data().
7070
'''

addons/source-python/packages/source-python/memory/manager.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
# >> ALL DECLARATION
1515
# =============================================================================
1616
__all__ = [
17-
'EXPOSED_CLASSES',
1817
'CustomType',
1918
'TypeManager',
2019
'manager',
@@ -24,12 +23,6 @@
2423
]
2524

2625

27-
# =============================================================================
28-
# >> GLOBAL VARIABLES
29-
# =============================================================================
30-
EXPOSED_CLASSES = get_exposed_classes()
31-
32-
3326
# =============================================================================
3427
# >> CustomType
3528
# =============================================================================

src/core/modules/engines/engines_wrap_python.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ void export_engine_trace()
12171217
// Enumerator baseclass
12181218
class_<IEntityEnumeratorWrap, boost::noncopyable>("EntityEnumerator")
12191219
.def("enum_entity",
1220-
&IEntityEnumeratorWrap::EnumEntity,
1220+
pure_virtual(&IEntityEnumeratorWrap::EnumEntity),
12211221
"Gets called with each handle."
12221222
)
12231223

src/core/modules/memory/memory_tools.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ extern std::map<CHook *, std::map<DynamicHooks::HookType_t, std::list<PyObject *
4444

4545
CHookManager* g_pHookMngr = new CHookManager;
4646

47-
std::map<const char*, object> g_ExposedClasses;
47+
dict g_oExposedClasses;
4848

4949
//-----------------------------------------------------------------------------
5050
// CPointer class
@@ -370,18 +370,4 @@ void CFunction::RemoveHook(DynamicHooks::HookType_t eType, PyObject* pCallable)
370370
return;
371371

372372
g_mapCallbacks[pHook][eType].remove(pCallable);
373-
}
374-
375-
376-
//-----------------------------------------------------------------------------
377-
// Functions
378-
//-----------------------------------------------------------------------------
379-
dict GetExposedClasses()
380-
{
381-
dict exposed_classes = dict();
382-
for(std::map<const char*, object>::iterator iter=g_ExposedClasses.begin(); iter != g_ExposedClasses.end(); ++iter)
383-
{
384-
exposed_classes[iter->first] = iter->second;
385-
}
386-
return exposed_classes;
387-
}
373+
}

src/core/modules/memory/memory_tools.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ using namespace boost::python;
4242

4343
// Externals
4444
extern DCCallVM* g_pCallVM;
45+
extern dict g_oExposedClasses;
4546

4647

4748
//---------------------------------------------------------------------------------
@@ -68,8 +69,8 @@ extern DCCallVM* g_pCallVM;
6869

6970
// Use this macro to add the class to the ExposedClasses dict
7071
#define STORE_CLASS(classname, pyname) \
71-
extern std::map<const char*, object> g_ExposedClasses; \
72-
g_ExposedClasses[XSTRINGIFY(classname)] = scope().attr(pyname);
72+
extern dict g_oExposedClasses; \
73+
g_oExposedClasses[XSTRINGIFY(classname)] = scope().attr(pyname);
7374

7475
// Use this macro to add the class to the three functions
7576
// Note: This must be at the end of the class definition!
@@ -387,6 +388,4 @@ inline object GetSize(object cls)
387388
return cls.attr("_size");
388389
}
389390

390-
dict GetExposedClasses();
391-
392391
#endif // _MEMORY_TOOLS_H

src/core/modules/memory/memory_wrap_python.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,10 +483,7 @@ void export_callbacks()
483483

484484
void export_sizes()
485485
{
486-
def("get_exposed_classes",
487-
GetExposedClasses,
488-
"Returns a dictionary that contains classes which can be used with get_object_pointer() etc."
489-
);
486+
scope().attr("EXPOSED_CLASSES") = g_oExposedClasses;
490487

491488
// Don't remove this! It's required for the ADD_NATIVE_TYPE_SIZE macro.
492489
scope().attr("TYPE_SIZES") = dict();

0 commit comments

Comments
 (0)