From b321b6d9db8a6df958a90f4cff33dded8f209e8e Mon Sep 17 00:00:00 2001 From: Dave Abrahams Date: Sat, 16 Nov 2002 22:45:46 +0000 Subject: [PATCH] Tweaks, pseudocode [SVN r16294] --- doc/polymorphism.txt | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/doc/polymorphism.txt b/doc/polymorphism.txt index f407f296..05afe517 100644 --- a/doc/polymorphism.txt +++ b/doc/polymorphism.txt @@ -9,8 +9,12 @@ How Runtime Polymorphism is expressed in Boost.Python: struct Bcb : B { - virtual std::string f() { return "B"; } + Bcb(PyObject* self) : m_self(self) {} + + virtual std::string f() { return call_method(m_sef, "f"); } static std::string f_default(B& b) { return b.B::f(); } + + PyObject* m_self; }; struct C : B @@ -149,3 +153,22 @@ B.f invokes B::f virtually. However, people complained about the artificial class in the hierarchy, which was revealed when they tried to do normal kinds of Python introspection. +------- + +Assumption: we will have a function which builds a virtual function +dispatch callable Python object. + + make_virtual_function(pvmf, default_impl, call_policies, dispatch_type) + +Pseudocode: + + Get first argument from Python arg tuple + if it contains /only/ dispatch_type + call default_impl + else + call through pvmf + + + + +