mirror of https://github.com/pybind/pybind11
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1002 B
36 lines
1002 B
#!/usr/bin/env python |
|
from __future__ import print_function |
|
import sys |
|
sys.path.append('.') |
|
|
|
from example import ExampleVirt, runExampleVirt, runExampleVirtVirtual, runExampleVirtBool |
|
|
|
|
|
class ExtendedExampleVirt(ExampleVirt): |
|
def __init__(self, state): |
|
super(ExtendedExampleVirt, self).__init__(state + 1) |
|
self.data = "Hello world" |
|
|
|
def run(self, value): |
|
print('ExtendedExampleVirt::run(%i), calling parent..' % value) |
|
return super(ExtendedExampleVirt, self).run(value + 1) |
|
|
|
def run_bool(self): |
|
print('ExtendedExampleVirt::run_bool()') |
|
return False |
|
|
|
def pure_virtual(self): |
|
print('ExtendedExampleVirt::pure_virtual(): %s' % self.data) |
|
|
|
|
|
ex12 = ExampleVirt(10) |
|
print(runExampleVirt(ex12, 20)) |
|
try: |
|
runExampleVirtVirtual(ex12) |
|
except Exception as e: |
|
print("Caught expected exception: " + str(e)) |
|
|
|
ex12p = ExtendedExampleVirt(10) |
|
print(runExampleVirt(ex12p, 20)) |
|
print(runExampleVirtBool(ex12p)) |
|
runExampleVirtVirtual(ex12p)
|
|
|