mirror of
https://github.com/boostorg/python.git
synced 2026-01-19 16:32:16 +00:00
- fixed staticmethod bug
- fixed hierarchies bug when using AllFromHeader [SVN r18971]
This commit is contained in:
@@ -7,6 +7,11 @@ Fixed a bug where the macro BOOST_PYTHON_OPAQUE_SPECIALIZED_TYPE_ID was being
|
||||
called multiple times for the same type.
|
||||
Thanks to Gottfried Ganßauge for reporting this!
|
||||
|
||||
Fixed bug where using AllFromHeader didn't use bases<> when exporting
|
||||
hierarchies.
|
||||
|
||||
Fixed the staticmethod bug.
|
||||
|
||||
5 July 2003
|
||||
Changed how --multiple works: now it generates one cpp file for each pyste
|
||||
file, makeing easier to integrate Pyste with build systems.
|
||||
|
||||
@@ -8,7 +8,3 @@
|
||||
instance)
|
||||
|
||||
- Virtual operators
|
||||
|
||||
- staticmethod bug
|
||||
|
||||
- opaque pointers bug
|
||||
|
||||
@@ -4,7 +4,7 @@ from distutils.core import setup
|
||||
import sys
|
||||
|
||||
setup (name = "Pyste",
|
||||
version = "0.9.9",
|
||||
version = "0.9.10",
|
||||
description = "Pyste - Python Semi-Automatic Exporter",
|
||||
maintainer = "Bruno da Silva de Oliveira",
|
||||
maintainer_email = "nicodemus@globalite.com.br",
|
||||
|
||||
@@ -97,10 +97,11 @@ class ClassExporter(Exporter):
|
||||
self.ExportMethods()
|
||||
self.ExportOperators()
|
||||
self.ExportNestedClasses(exported_names)
|
||||
self.ExportNestedEnums()
|
||||
self.ExportNestedEnums(exported_names)
|
||||
self.ExportSmartPointer()
|
||||
self.ExportOpaquePointerPolicies()
|
||||
self.Write(codeunit)
|
||||
exported_names[self.class_.FullName()] = 1
|
||||
|
||||
|
||||
def InheritMethods(self, exported_names):
|
||||
@@ -341,6 +342,8 @@ class ClassExporter(Exporter):
|
||||
methods = [x for x in self.public_members if IsExportable(x)]
|
||||
methods.extend(self.GetAddedMethods())
|
||||
|
||||
staticmethods = {}
|
||||
|
||||
for method in methods:
|
||||
method_info = self.info[method.name]
|
||||
|
||||
@@ -375,14 +378,19 @@ class ClassExporter(Exporter):
|
||||
self.Add('inside', code)
|
||||
# static method
|
||||
if isinstance(method, Method) and method.static:
|
||||
code = '.staticmethod("%s")' % name
|
||||
self.Add('inside', code)
|
||||
staticmethods[name] = 1
|
||||
# add wrapper code if this method has one
|
||||
wrapper = method_info.wrapper
|
||||
if wrapper and wrapper.code:
|
||||
self.Add('declaration', wrapper.code)
|
||||
|
||||
# export staticmethod statements
|
||||
for name in staticmethods:
|
||||
code = '.staticmethod("%s")' % name
|
||||
self.Add('inside', code)
|
||||
|
||||
|
||||
|
||||
def MakeNonVirtual(self):
|
||||
'''Make all methods that the user indicated to no_override no more virtual, delegating their
|
||||
export to the ExportMethods routine'''
|
||||
@@ -583,7 +591,7 @@ class ClassExporter(Exporter):
|
||||
self.nested_codeunits.append(codeunit)
|
||||
|
||||
|
||||
def ExportNestedEnums(self):
|
||||
def ExportNestedEnums(self, exported_names):
|
||||
nested_enums = [x for x in self.public_members if isinstance(x, ClassEnumeration)]
|
||||
for enum in nested_enums:
|
||||
enum_info = self.info[enum.name]
|
||||
@@ -592,7 +600,7 @@ class ClassExporter(Exporter):
|
||||
exporter = EnumExporter(enum_info)
|
||||
exporter.SetDeclarations(self.declarations)
|
||||
codeunit = SingleCodeUnit(None, None)
|
||||
exporter.Export(codeunit, None)
|
||||
exporter.Export(codeunit, exported_names)
|
||||
self.nested_codeunits.append(codeunit)
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ class EnumExporter(Exporter):
|
||||
self.enum = self.GetDeclaration(self.info.name)
|
||||
|
||||
|
||||
def Export(self, codeunit, expoted_names):
|
||||
def Export(self, codeunit, exported_names):
|
||||
if not self.info.exclude:
|
||||
indent = self.INDENT
|
||||
in_indent = self.INDENT*2
|
||||
@@ -34,6 +34,7 @@ class EnumExporter(Exporter):
|
||||
code += in_indent + '.value("%s", %s)\n' % (rename, value_fullname)
|
||||
code += indent + ';\n\n'
|
||||
codeunit.Write('module', code)
|
||||
exported_names[self.enum.FullName()] = 1
|
||||
|
||||
|
||||
def Unit(self):
|
||||
|
||||
@@ -3,7 +3,7 @@ import os.path
|
||||
#==============================================================================
|
||||
# Exporter
|
||||
#==============================================================================
|
||||
class Exporter:
|
||||
class Exporter(object):
|
||||
'Base class for objects capable to generate boost.python code.'
|
||||
|
||||
INDENT = ' ' * 4
|
||||
|
||||
@@ -24,6 +24,7 @@ class FunctionExporter(Exporter):
|
||||
self.ExportDeclaration(decl, len(decls) == 1, codeunit)
|
||||
self.ExportOpaquePointer(decl, codeunit)
|
||||
self.GenerateOverloads(decls, codeunit)
|
||||
exported_names[decl.FullName()] = 1
|
||||
|
||||
|
||||
def ExportDeclaration(self, decl, unique, codeunit):
|
||||
|
||||
@@ -39,7 +39,7 @@ from policies import *
|
||||
from CppParser import CppParser, CppParserError
|
||||
import time
|
||||
|
||||
__VERSION__ = '0.9.9'
|
||||
__VERSION__ = '0.9.10'
|
||||
|
||||
def RecursiveIncludes(include):
|
||||
'Return a list containg the include dir and all its subdirectories'
|
||||
@@ -221,7 +221,6 @@ def Begin():
|
||||
if multiple:
|
||||
codeunit.SetCurrent(export.interface_file, export.Unit())
|
||||
export.GenerateCode(codeunit, exported_names)
|
||||
exported_names[export.Name()] = 1
|
||||
# force collect of cyclic references
|
||||
gc.collect()
|
||||
# finally save the code unit
|
||||
|
||||
@@ -33,7 +33,10 @@ public:
|
||||
const int const_value;
|
||||
|
||||
// test static functions
|
||||
static int mul(int x=2, int y=3) { return x*y; }
|
||||
static int mul(int x, int y) { return x*y; }
|
||||
static double mul(double x, double y) { return x*y; }
|
||||
|
||||
static int square(int x=2) { return x*x; }
|
||||
};
|
||||
|
||||
inline int call_f(C& c)
|
||||
|
||||
@@ -57,9 +57,12 @@ class BasicExampleTest(unittest.TestCase):
|
||||
def test_mul(result, *args):
|
||||
self.assertEqual(C.mul(*args), result)
|
||||
self.assertEqual(c.mul(*args), result)
|
||||
test_mul(6)
|
||||
test_mul(3, 1)
|
||||
test_mul(16, 8, 2)
|
||||
test_mul(6.0, 2.0, 3.0)
|
||||
self.assertEqual(C.square(), 4)
|
||||
self.assertEqual(c.square(), 4)
|
||||
self.assertEqual(C.square(3), 9)
|
||||
self.assertEqual(c.square(3), 9)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
Class('inherit2::B', 'inherit2.h')
|
||||
Class('inherit2::D', 'inherit2.h')
|
||||
header = AllFromHeader('inherit2.h')
|
||||
exclude(header.A)
|
||||
exclude(header.C)
|
||||
|
||||
Reference in New Issue
Block a user