|
|
@@ -12,11 +12,11 @@ namespace pkpy {
|
|
|
return OBJ_GET(Type, vm->_modules[__x0]->attr(__x1)); \
|
|
|
} \
|
|
|
static PyObject* register_class(VM* vm, PyObject* mod) { \
|
|
|
- PyObject* type = vm->new_type_object(mod, #name, vm->tp_object); \
|
|
|
if(OBJ_NAME(mod) != #mod) { \
|
|
|
auto msg = fmt("register_class() failed: ", OBJ_NAME(mod), " != ", #mod); \
|
|
|
throw std::runtime_error(msg); \
|
|
|
} \
|
|
|
+ PyObject* type = vm->new_type_object(mod, #name, vm->tp_object); \
|
|
|
T::_register(vm, mod, type); \
|
|
|
type->attr()._try_perfect_rehash(); \
|
|
|
return type; \
|
|
|
@@ -30,12 +30,13 @@ struct VoidP{
|
|
|
|
|
|
void* ptr;
|
|
|
VoidP(void* ptr): ptr(ptr){}
|
|
|
+ VoidP(): ptr(nullptr){}
|
|
|
|
|
|
static void _register(VM* vm, PyObject* mod, PyObject* type){
|
|
|
- vm->bind_static_method<1>(type, "__new__", CPP_NOT_IMPLEMENTED());
|
|
|
+ vm->bind_default_constructor<VoidP>(type);
|
|
|
|
|
|
- vm->bind_static_method<1>(type, "__repr__", [](VM* vm, ArgsView args){
|
|
|
- VoidP& self = CAST(VoidP&, args[0]);
|
|
|
+ vm->bind_method<0>(type, "__repr__", [](VM* vm, ArgsView args){
|
|
|
+ VoidP& self = _CAST(VoidP&, args[0]);
|
|
|
std::stringstream ss;
|
|
|
ss << "<void* at " << self.ptr << ">";
|
|
|
return VAR(ss.str());
|