| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -31,7 +31,7 @@ | |||
| 31 | 31 | #include "boost/unordered_map.hpp" | |
| 32 | 32 | ||
| 33 | 33 | // Source.Python | |
| 34 | - #include "modules/memory/memory_function.h" | ||
| 34 | + #include "modules/memory/memory_pointer.h" | ||
| 35 | 35 | #include "entities_props.h" | |
| 36 | 36 | #include ENGINE_INCLUDE_PATH(entities_props.h) | |
| 37 | 37 | ||
@@ -136,15 +136,15 @@ int SendTableSharedExt::find_offset(SendTable* pTable, const char* name) | |||
| 136 | 136 | // ============================================================================ | |
| 137 | 137 | // >> SendPropSharedExt | |
| 138 | 138 | // ============================================================================ | |
| 139 | - CFunction* SendPropSharedExt::get_proxy_function(SendProp *pSendProp, object oCallingConvention, object args, object oReturnType) | ||
| 139 | + BoostSendVarProxyFn SendPropSharedExt::get_proxy_function(SendProp *pSendProp) | ||
| 140 | 140 | { | |
| 141 | 141 | if (pSendProp->IsExcludeProp()) | |
| 142 | 142 | BOOST_RAISE_EXCEPTION(PyExc_TypeError, "%s is excluded.", pSendProp->GetName()); | |
| 143 | 143 | ||
| 144 | 144 | if (pSendProp->GetType() == DPT_DataTable) | |
| 145 | 145 | BOOST_RAISE_EXCEPTION(PyExc_TypeError, "%s is a DataTable.", pSendProp->GetName()); | |
| 146 | 146 | ||
| 147 | - return new CFunction((unsigned long)pSendProp->GetProxyFn(), oCallingConvention, args, oReturnType); | ||
| 147 | + return BoostSendVarProxyFn(pSendProp->GetProxyFn()); | ||
| 148 | 148 | } | |
| 149 | 149 | ||
| 150 | 150 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -37,10 +37,15 @@ | |||
| 37 | 37 | #include "isaverestore.h" | |
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | + //----------------------------------------------------------------------------- | ||
| 41 | + // typedefs | ||
| 42 | + //----------------------------------------------------------------------------- | ||
| 43 | + BOOST_FUNCTION_TYPEDEF(void (const SendProp*, const void*, const void*, DVariant*, int, int), BoostSendVarProxyFn) | ||
| 44 | + | ||
| 45 | + | ||
| 40 | 46 | //----------------------------------------------------------------------------- | |
| 41 | 47 | // Forward declarations | |
| 42 | 48 | //----------------------------------------------------------------------------- | |
| 43 | - class CFunction; | ||
| 44 | 49 | class CPointer; | |
| 45 | 50 | ||
| 46 | 51 | ||
@@ -61,7 +66,7 @@ class SendTableSharedExt | |||
| 61 | 66 | class SendPropSharedExt | |
| 62 | 67 | { | |
| 63 | 68 | public: | |
| 64 | - static CFunction *get_proxy_function(SendProp *pSendProp, object oCallingConvention, object args, object oReturnType); | ||
| 69 | + static BoostSendVarProxyFn get_proxy_function(SendProp *pSendProp); | ||
| 65 | 70 | }; | |
| 66 | 71 | ||
| 67 | 72 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -116,6 +116,8 @@ void export_send_table(scope _props) | |||
| 116 | 116 | //----------------------------------------------------------------------------- | |
| 117 | 117 | void export_send_prop(scope _props) | |
| 118 | 118 | { | |
| 119 | + EXPOSE_FUNCTION_TYPEDEF(BoostSendVarProxyFn, "SendVarProxyFn") | ||
| 120 | + | ||
| 119 | 121 | class_<SendProp, SendProp *, boost::noncopyable> SendProp_("SendProp", no_init); | |
| 120 | 122 | ||
| 121 | 123 | // Properties... | |
@@ -140,6 +142,7 @@ void export_send_prop(scope _props) | |||
| 140 | 142 | ); | |
| 141 | 143 | ||
| 142 | 144 | SendProp_.add_property("offset", &SendProp::GetOffset); | |
| 145 | + SendProp_.add_property("proxy_function", &SendPropSharedExt::get_proxy_function); | ||
| 143 | 146 | ||
| 144 | 147 | // CS:GO specific properties... | |
| 145 | 148 | SendProp_.NOT_IMPLEMENTED_ATTR("priority"); | |
@@ -150,8 +153,6 @@ void export_send_prop(scope _props) | |||
| 150 | 153 | SendProp_.def("is_exclude_prop", &SendProp::IsExcludeProp); | |
| 151 | 154 | SendProp_.def("is_inside_array", &SendProp::IsInsideArray); | |
| 152 | 155 | ||
| 153 | - SendProp_.def("get_proxy_function", &SendPropSharedExt::get_proxy_function, manage_new_object_policy()); | ||
| 154 | - | ||
| 155 | 156 | // CS:GO specific methods... | |
| 156 | 157 | SendProp_.NOT_IMPLEMENTED("get_priority"); | |
| 157 | 158 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,6 +29,7 @@ | |||
| 29 | 29 | //--------------------------------------------------------------------------------- | |
| 30 | 30 | // Includes | |
| 31 | 31 | //--------------------------------------------------------------------------------- | |
| 32 | + #include "boost/function.hpp" | ||
| 32 | 33 | #include "boost/python.hpp" | |
| 33 | 34 | using namespace boost::python; | |
| 34 | 35 | ||
@@ -42,6 +43,23 @@ using namespace boost::python; | |||
| 42 | 43 | #error("SOURCE_ENGINE_BRANCH define must be globally defined, did we forget?"); | |
| 43 | 44 | #endif | |
| 44 | 45 | ||
| 46 | + //--------------------------------------------------------------------------------- | ||
| 47 | + // Macros to expose function typedefs | ||
| 48 | + //--------------------------------------------------------------------------------- | ||
| 49 | + // Example typedef: | ||
| 50 | + // typedef int (*MultiplyFn)(int, int); | ||
| 51 | + // | ||
| 52 | + // Example usage: | ||
| 53 | + // BOOST_FUNCTION_TYPEDEF(int (int, int), BoostMultiplyFn) | ||
| 54 | + #define BOOST_FUNCTION_TYPEDEF(sig, cpp_name) \ | ||
| 55 | + typedef boost::function< sig> cpp_name; | ||
| 56 | + | ||
| 57 | + // Example usage: | ||
| 58 | + // EXPOSE_FUNCTION_TYPEDEF(BoostMultiplyFn, "MultiplyFn") | ||
| 59 | + #define EXPOSE_FUNCTION_TYPEDEF(cpp_name, py_name) \ | ||
| 60 | + class_<cpp_name>(py_name, no_init) \ | ||
| 61 | + .def("__call__", &cpp_name::operator()) \ | ||
| 62 | + ; | ||
| 45 | 63 | ||
| 46 | 64 | //--------------------------------------------------------------------------------- | |
| 47 | 65 | // Surround boost python statements with this macro in order to handle exceptions. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments