Hi Vladmir, Vladimir Sukhoy wrote:
But that's not exactly what I want, because I really meant that shared_ptr IS MyClass, so I want to write
mc = MyClass()
and have C++ function MyClass::Create being called instead.
Of course, I can override this with Python (which rox), even procedurally, like that:
def override_constructor(cls, cons, d): def override_func(cls, *args, **kwargs): return cons(*args, **kwargs) dc = {'__new__' : override_func} from new import classobj d[cls.__name__] = classobj(cls.__name__, (cls,), dc)
override_constructor(MyClass, MyClass.Create, globals())
Is there a way to do the same thing with pyste at wrapper generation step?
Not right now, and I don't have any definite plans for it either. :/ I suggest you keep inserting the constructor like you are doing. Regards, Bruno.