@@ -111,88 +111,102 @@ void export_binaryfile()
111
111
// -----------------------------------------------------------------------------
112
112
// Exposes CPointer
113
113
// -----------------------------------------------------------------------------
114
- // These two macros ease the exposing part of get_<type> methods
115
114
#define OVERLOAD_GET_TYPE (name, type ) \
116
115
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS (get_##name##_overload, CPointer::Get<type>, 0 , 1 )
117
116
118
- #define EXPOSE_GET_TYPE (name, type ) \
119
- def (" get_" XSTRINGIFY(name), \
120
- &CPointer::Get<type>, \
121
- get_##name##_overload( \
122
- args (" offset" ), \
123
- "Returns the value at the given memory location." \
124
- ) \
125
- )
126
-
127
- // These two macros ease the exposing part of set_<type> methods
128
117
#define OVERLOAD_SET_TYPE (name, type ) \
129
118
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS (set_##name##_overload, CPointer::Set<type>, 1 , 2 )
130
119
120
+ #define OVERLOAD_GET_SET_TYPE (name, type ) \
121
+ OVERLOAD_GET_TYPE (name, type) \
122
+ OVERLOAD_SET_TYPE(name, type)
123
+
131
124
#define EXPOSE_SET_TYPE (name, type ) \
132
- def (" set_" XSTRINGIFY(name), \
125
+ . def(" set_" XSTRINGIFY(name), \
133
126
&CPointer::Set<type>, \
134
127
set_##name##_overload( \
135
128
args (" value" , " offset" ), \
136
129
"Sets the value at the given memory location." \
137
130
) \
138
131
)
132
+
133
+ #define EXPOSE_GET_TYPE (name, type ) \
134
+ .def(" get_" XSTRINGIFY(name), \
135
+ &CPointer::Get<type>, \
136
+ get_##name##_overload( \
137
+ args (" offset" ), \
138
+ "Returns the value at the given memory location." \
139
+ ) \
140
+ )
141
+
142
+ #define EXPOSE_GET_SET_TYPE (name, type ) \
143
+ EXPOSE_SET_TYPE (name, type) \
144
+ EXPOSE_GET_TYPE(name, type)
139
145
146
+ // get/set_<type> overloads
147
+ OVERLOAD_GET_SET_TYPE(bool , bool )
148
+ OVERLOAD_GET_SET_TYPE(char , char )
149
+ OVERLOAD_GET_SET_TYPE(uchar, unsigned char )
150
+ OVERLOAD_GET_SET_TYPE(short , short )
151
+ OVERLOAD_GET_SET_TYPE(ushort, unsigned short )
152
+ OVERLOAD_GET_SET_TYPE(int , int )
153
+ OVERLOAD_GET_SET_TYPE(uint, unsigned int )
154
+ OVERLOAD_GET_SET_TYPE(long , long )
155
+ OVERLOAD_GET_SET_TYPE(ulong, unsigned long )
156
+ OVERLOAD_GET_SET_TYPE(long_long, long long )
157
+ OVERLOAD_GET_SET_TYPE(ulong_long, unsigned long long )
158
+ OVERLOAD_GET_SET_TYPE(float , float )
159
+ OVERLOAD_GET_SET_TYPE(double , double )
160
+
140
161
// get_<type> overloads
141
- OVERLOAD_GET_TYPE(bool , bool )
142
- OVERLOAD_GET_TYPE(char , char )
143
- OVERLOAD_GET_TYPE(uchar, unsigned char )
144
- OVERLOAD_GET_TYPE(short , short )
145
- OVERLOAD_GET_TYPE(ushort, unsigned short )
146
- OVERLOAD_GET_TYPE(int , int )
147
- OVERLOAD_GET_TYPE(uint, unsigned int )
148
- OVERLOAD_GET_TYPE(long , long )
149
- OVERLOAD_GET_TYPE(ulong, unsigned long )
150
- OVERLOAD_GET_TYPE(long_long, long long )
151
- OVERLOAD_GET_TYPE(ulong_long, unsigned long long )
152
- OVERLOAD_GET_TYPE(float , float )
153
- OVERLOAD_GET_TYPE(double , double )
154
162
OVERLOAD_GET_TYPE(string_ptr, const char *)
155
163
156
164
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(get_ptr_overload, GetPtr, 0 , 1 )
157
165
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(get_string_array_overload, GetStringArray, 0 , 1 )
158
166
159
167
// set_<type> overloads
160
- OVERLOAD_SET_TYPE(bool , bool )
161
- OVERLOAD_SET_TYPE(char , char )
162
- OVERLOAD_SET_TYPE(uchar, unsigned char )
163
- OVERLOAD_SET_TYPE(short , short )
164
- OVERLOAD_SET_TYPE(ushort, unsigned short )
165
- OVERLOAD_SET_TYPE(int , int )
166
- OVERLOAD_SET_TYPE(uint, unsigned int )
167
- OVERLOAD_SET_TYPE(long , long )
168
- OVERLOAD_SET_TYPE(ulong, unsigned long )
169
- OVERLOAD_SET_TYPE(long_long, long long )
170
- OVERLOAD_SET_TYPE(ulong_long, unsigned long long )
171
- OVERLOAD_SET_TYPE(float , float )
172
- OVERLOAD_SET_TYPE(double , double )
173
-
174
168
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(set_ptr_overload, SetPtr, 1 , 2 )
175
169
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(set_string_ptr_overload, SetStringPtr, 1 , 2 )
176
170
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(set_string_array_overload, SetStringArray, 1 , 2 )
177
171
172
+ // These three macros ease the exposing part of DynCall
173
+ #define EXPOSE_DC_SET (pyname, cppname ) \
174
+ .def(" set_arg_" XSTRINGIFY(pyname), \
175
+ &CPointer::SetArg##cppname, \
176
+ args (" value" ), \
177
+ "Adds a new parameter to the virtual machine." \
178
+ )
179
+
180
+ #define EXPOSE_DC_CALL (pyname, cppname ) \
181
+ .def(" call_" XSTRINGIFY(pyname), \
182
+ &CPointer::Call##cppname, \
183
+ " Calls the virtual machine." \
184
+ )
185
+
186
+ #define EXPOSE_DC (pyname, cppname ) \
187
+ EXPOSE_DC_SET (pyname, cppname) \
188
+ EXPOSE_DC_CALL(pyname, cppname)
189
+
178
190
void export_memtools()
179
191
{
180
192
class_<CPointer>(" Pointer" , init< optional<unsigned long > >())
193
+ // get/set_<type> methods
194
+ EXPOSE_GET_SET_TYPE (bool , bool )
195
+ EXPOSE_GET_SET_TYPE (char , char )
196
+ EXPOSE_GET_SET_TYPE (uchar, unsigned char )
197
+ EXPOSE_GET_SET_TYPE (short , short )
198
+ EXPOSE_GET_SET_TYPE (ushort, unsigned short )
199
+ EXPOSE_GET_SET_TYPE (int , int )
200
+ EXPOSE_GET_SET_TYPE (uint, unsigned int )
201
+ EXPOSE_GET_SET_TYPE (long , long )
202
+ EXPOSE_GET_SET_TYPE (ulong, unsigned long )
203
+ EXPOSE_GET_SET_TYPE (long_long, long long )
204
+ EXPOSE_GET_SET_TYPE (ulong_long, unsigned long long )
205
+ EXPOSE_GET_SET_TYPE (float , float )
206
+ EXPOSE_GET_SET_TYPE (double , double )
207
+
181
208
// get_<type> methods
182
- .EXPOSE_GET_TYPE (bool , bool )
183
- .EXPOSE_GET_TYPE (char , char )
184
- .EXPOSE_GET_TYPE (uchar, unsigned char )
185
- .EXPOSE_GET_TYPE (short , short )
186
- .EXPOSE_GET_TYPE (ushort, unsigned short )
187
- .EXPOSE_GET_TYPE (int , int )
188
- .EXPOSE_GET_TYPE (uint, unsigned int )
189
- .EXPOSE_GET_TYPE (long , long )
190
- .EXPOSE_GET_TYPE (ulong, unsigned long )
191
- .EXPOSE_GET_TYPE (long_long, long long )
192
- .EXPOSE_GET_TYPE (ulong_long, unsigned long long )
193
- .EXPOSE_GET_TYPE (float , float )
194
- .EXPOSE_GET_TYPE (double , double )
195
- .EXPOSE_GET_TYPE (string_ptr, const char *)
209
+ EXPOSE_GET_TYPE (string_ptr, const char *)
196
210
197
211
.def (" get_ptr" ,
198
212
&CPointer::GetPtr,
@@ -211,20 +225,6 @@ void export_memtools()
211
225
)
212
226
213
227
// set_<type> methods
214
- .EXPOSE_SET_TYPE (bool , bool )
215
- .EXPOSE_SET_TYPE (char , char )
216
- .EXPOSE_SET_TYPE (uchar, unsigned char )
217
- .EXPOSE_SET_TYPE (short , short )
218
- .EXPOSE_SET_TYPE (ushort, unsigned short )
219
- .EXPOSE_SET_TYPE (int , int )
220
- .EXPOSE_SET_TYPE (uint, unsigned int )
221
- .EXPOSE_SET_TYPE (long , long )
222
- .EXPOSE_SET_TYPE (ulong, unsigned long )
223
- .EXPOSE_SET_TYPE (long_long, long long )
224
- .EXPOSE_SET_TYPE (ulong_long, unsigned long long )
225
- .EXPOSE_SET_TYPE (float , float )
226
- .EXPOSE_SET_TYPE (double , double )
227
-
228
228
.def (" set_ptr" ,
229
229
&CPointer::SetPtr,
230
230
set_ptr_overload (
@@ -249,10 +249,37 @@ void export_memtools()
249
249
)
250
250
)
251
251
252
+ // DynCall methods
253
+ .def (" reset_vm" ,
254
+ &CPointer::ResetVM,
255
+ " Resets the virtual machine."
256
+ )
257
+
258
+ .def (" set_mode" ,
259
+ &CPointer::SetMode,
260
+ " Sets the calling convention." ,
261
+ args (" convention" )
262
+ )
263
+
264
+ EXPOSE_DC_CALL (void , Void)
265
+ EXPOSE_DC (bool , Bool)
266
+ EXPOSE_DC (char , Char)
267
+ EXPOSE_DC (uchar, UChar)
268
+ EXPOSE_DC (short , Short)
269
+ EXPOSE_DC (ushort, UShort)
270
+ EXPOSE_DC (int , Int)
271
+ EXPOSE_DC (uint, UInt)
272
+ EXPOSE_DC (long , Long)
273
+ EXPOSE_DC (ulong, ULong)
274
+ EXPOSE_DC (float , Float)
275
+ EXPOSE_DC (double , Double)
276
+ EXPOSE_DC (pointer, Pointer)
277
+ EXPOSE_DC (string, String)
278
+
252
279
// Other methods
253
280
.def (" get_virtual_func" ,
254
281
&CPointer::GetVirtualFunc,
255
- " Returns the address (as a CPointer instance) of a virtual function at the given index." ,
282
+ " Returns the address (as a Pointer instance) of a virtual function at the given index." ,
256
283
args (" index" ),
257
284
manage_new_object_policy ()
258
285
)
0 commit comments