mirror of
https://github.com/boostorg/python.git
synced 2026-01-30 08:02:38 +00:00
- Default policy for functions/methods that return const T& is now
return_value_policy<copy_const_reference>(). [SVN r18077]
This commit is contained in:
@@ -2,8 +2,12 @@ from Exporter import Exporter
|
||||
from policies import *
|
||||
from declarations import *
|
||||
from settings import *
|
||||
import exporterutils
|
||||
|
||||
|
||||
#==============================================================================
|
||||
# FunctionExporter
|
||||
#==============================================================================
|
||||
class FunctionExporter(Exporter):
|
||||
'Generates boost.python code to export the given function.'
|
||||
|
||||
@@ -14,7 +18,7 @@ class FunctionExporter(Exporter):
|
||||
def Export(self, codeunit, exported_names):
|
||||
decls = self.GetDeclarations(self.info.name)
|
||||
for decl in decls:
|
||||
self.CheckPolicy(decl)
|
||||
self.info.policy = exporterutils.HandlePolicy(decl, self.info.policy)
|
||||
self.ExportDeclaration(decl, len(decls) == 1, codeunit)
|
||||
self.GenerateOverloads(decls, codeunit)
|
||||
|
||||
@@ -23,17 +27,6 @@ class FunctionExporter(Exporter):
|
||||
return self.info.name
|
||||
|
||||
|
||||
def CheckPolicy(self, func):
|
||||
'Warns the user if this function needs a policy'
|
||||
def IsString(type):
|
||||
return type.const and type.name == 'char' and isinstance(type, PointerType)
|
||||
needs_policy = isinstance(func.result, (ReferenceType, PointerType))
|
||||
if IsString(func.result):
|
||||
needs_policy = False
|
||||
if needs_policy and self.info.policy is None:
|
||||
print '---> Error: Function "%s" needs a policy.' % func.FullName()
|
||||
print
|
||||
|
||||
def ExportDeclaration(self, decl, unique, codeunit):
|
||||
name = self.info.rename or decl.name
|
||||
defs = namespaces.python + 'def("%s", ' % name
|
||||
|
||||
Reference in New Issue
Block a user