Skip to content

Commit b321b6d

Browse files
committed
Tweaks, pseudocode
[SVN r16294]
1 parent 56c5227 commit b321b6d

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

doc/polymorphism.txt

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ How Runtime Polymorphism is expressed in Boost.Python:
99

1010
struct Bcb : B
1111
{
12-
virtual std::string f() { return "B"; }
12+
Bcb(PyObject* self) : m_self(self) {}
13+
14+
virtual std::string f() { return call_method<std::string>(m_sef, "f"); }
1315
static std::string f_default(B& b) { return b.B::f(); }
16+
17+
PyObject* m_self;
1418
};
1519

1620
struct C : B
@@ -149,3 +153,22 @@ B.f invokes B::f virtually. However, people complained about the
149153
artificial class in the hierarchy, which was revealed when they tried
150154
to do normal kinds of Python introspection.
151155

156+
-------
157+
158+
Assumption: we will have a function which builds a virtual function
159+
dispatch callable Python object.
160+
161+
make_virtual_function(pvmf, default_impl, call_policies, dispatch_type)
162+
163+
Pseudocode:
164+
165+
Get first argument from Python arg tuple
166+
if it contains /only/ dispatch_type
167+
call default_impl
168+
else
169+
call through pvmf
170+
171+
172+
173+
174+

0 commit comments

Comments
 (0)