Skip to content

Commit 359b64e

Browse files
committed
Renamed CUserMessage to UserMessage
Removed unused macros
1 parent 3bb16cc commit 359b64e

File tree

3 files changed

+117
-256
lines changed

3 files changed

+117
-256
lines changed

src/core/modules/memory/memory_wrap_python.cpp

Lines changed: 43 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ BOOST_PYTHON_FUNCTION_OVERLOADS(find_binary_overload, find_binary, 1, 2);
5858

5959
void export_binaryfile()
6060
{
61-
BOOST_ABSTRACT_CLASS(CBinaryFile)
61+
class_<CBinaryFile, boost::noncopyable>("CBinaryFile", no_init)
6262

6363
// Class methods
6464
CLASS_METHOD(CBinaryFile,
@@ -76,36 +76,31 @@ void export_binaryfile()
7676
)
7777

7878
// Special methods
79-
CLASS_METHOD_SPECIAL(CBinaryFile,
80-
"__getattr__",
81-
find_address,
79+
.def("__getattr__",
80+
&CBinaryFile::find_address,
8281
"Returns the address of a signature or symbol found in memory.",
8382
args("identifier"),
8483
manage_new_object_policy()
8584
)
8685

87-
CLASS_METHOD_SPECIAL(CBinaryFile,
88-
"__getitem__",
89-
find_address,
86+
.def("__getitem__",
87+
&CBinaryFile::find_address,
9088
"Returns the address of a signature or symbol found in memory.",
9189
args("identifier"),
9290
manage_new_object_policy()
9391
)
94-
92+
9593
// Properties
96-
CLASS_PROPERTY_READ_ONLY(CBinaryFile,
97-
"addr",
98-
get_address,
94+
.add_property("addr",
95+
&CBinaryFile::get_address,
9996
"Returns the base address of this binary."
10097
)
10198

102-
CLASS_PROPERTY_READ_ONLY(CBinaryFile,
103-
"size",
104-
get_size,
99+
.add_property("size",
100+
&CBinaryFile::get_size,
105101
"Returns the size of this binary."
106102
)
107-
108-
BOOST_END_CLASS()
103+
;
109104

110105
def("find_binary",
111106
&find_binary,
@@ -158,7 +153,7 @@ DECLARE_CLASS_METHOD_OVERLOAD(CPointer, set_string, 1, 4);
158153

159154
void export_memtools()
160155
{
161-
BOOST_CLASS_CONSTRUCTOR(CPointer, optional<unsigned long>)
156+
class_<CPointer>("CPointer", init< optional<unsigned long> >())
162157

163158
// Class methods
164159
CLASS_METHOD_OVERLOAD_RET(CPointer,
@@ -579,54 +574,48 @@ void export_memtools()
579574
)
580575

581576
// Special methods
582-
CLASS_METHOD_SPECIAL(CPointer,
583-
"__int__",
584-
get_address,
577+
.def("__int__",
578+
&CPointer::get_address,
585579
"Returns the address of this memory block."
586580
)
587581

588-
CLASS_METHOD_SPECIAL(CPointer,
589-
"__bool__",
590-
is_valid,
582+
.def("__bool__",
583+
&CPointer::is_valid,
591584
"Returns True if the address is not NULL."
592585
)
593586

594-
CLASS_METHOD_SPECIAL(CPointer,
595-
"__add__",
596-
add,
587+
.def("__add__",
588+
&CPointer::add,
597589
"Adds a value to the base address.",
598590
manage_new_object_policy()
599591
)
600592

601-
CLASS_METHOD_SPECIAL(CPointer,
602-
"__sub__",
603-
sub,
593+
.def("__sub__",
594+
&CPointer::sub,
604595
"Subtracts a value from the base address.",
605596
manage_new_object_policy()
606597
)
607598

608599
// Properties
609-
CLASS_PROPERTY_READ_ONLY(CPointer,
610-
"addr",
611-
get_address,
600+
.add_property("addr",
601+
&CPointer::get_address,
612602
"Returns the address of this memory block."
613603
)
614604

615-
CLASS_PROPERTY_READ_ONLY(CPointer,
616-
"size",
617-
get_size,
605+
.add_property("size",
606+
&CPointer::get_size,
618607
"Returns the size of this memory block."
619608
)
609+
;
620610

621-
BOOST_END_CLASS()
622-
623-
BOOST_FUNCTION(alloc,
611+
def("alloc",
612+
alloc,
624613
"Allocates a memory block.",
625614
args("iSize"),
626615
manage_new_object_policy()
627616
);
628617

629-
BOOST_INHERITED_CLASS_CONSTRUCTOR(CFunction, CPointer, unsigned long, Convention_t, char*)
618+
class_<CFunction, bases<CPointer> >("CFunction", init<unsigned long, Convention_t, char*>())
630619

631620
CLASS_METHOD_VARIADIC(CFunction,
632621
__call__,
@@ -669,8 +658,7 @@ void export_memtools()
669658
remove_post_hook,
670659
"Removes a post-hook callback."
671660
)
672-
673-
BOOST_END_CLASS()
661+
;
674662

675663
DEFINE_CLASS_METHOD_VARIADIC(CFunction, __call__);
676664
DEFINE_CLASS_METHOD_VARIADIC(CFunction, call_trampoline);
@@ -682,34 +670,33 @@ void export_memtools()
682670
void export_dyncall()
683671
{
684672
enum_<Convention_t>("Convention")
685-
ENUM_VALUE("CDECL", CONV_CDECL)
686-
ENUM_VALUE("STDCALL", CONV_STDCALL)
687-
ENUM_VALUE("THISCALL", CONV_THISCALL)
688-
BOOST_END_CLASS()
673+
.value("CDECL", CONV_CDECL)
674+
.value("STDCALL", CONV_STDCALL)
675+
.value("THISCALL", CONV_THISCALL)
676+
;
689677

690678
// Other constants that are very useful.
691-
BOOST_GLOBAL_ATTRIBUTE("DC_ERROR_NONE", DC_ERROR_NONE);
692-
BOOST_GLOBAL_ATTRIBUTE("DC_ERROR_UNSUPPORTED_MODE", DC_ERROR_UNSUPPORTED_MODE);
679+
scope().attr("DC_ERROR_NONE") = DC_ERROR_NONE;
680+
scope().attr("DC_ERROR_UNSUPPORTED_MODE") = DC_ERROR_UNSUPPORTED_MODE;
693681

694-
BOOST_FUNCTION(get_error,
682+
def("get_error",
683+
get_error,
695684
"Returns the last DynCall error ID."
696685
);
697686
}
698687

699688
void export_dynamichooks()
700689
{
701-
BOOST_CLASS_CONSTRUCTOR(CStackData, CHook*)
690+
class_<CStackData>("CStackData", init<CHook*>())
702691

703692
// Special methods
704-
CLASS_METHOD_SPECIAL(CStackData,
705-
"__getitem__",
706-
get_item,
693+
.def("__getitem__",
694+
&CStackData::get_item,
707695
"Returns the argument at the specified index."
708696
)
709697

710-
CLASS_METHOD_SPECIAL(CStackData,
711-
"__setitem__",
712-
set_item,
698+
.def("__setitem__",
699+
&CStackData::set_item,
713700
"Sets the argument at the specified index."
714701
)
715702

@@ -721,6 +708,5 @@ void export_dynamichooks()
721708
),
722709
"Stack pointer register."
723710
)
724-
725-
BOOST_END_CLASS()
711+
;
726712
}

0 commit comments

Comments
 (0)