def _create_body( self ): answer = [] answer.append( 'typedef %s;' % self.wrapper.wrapper_creator_type.create_typedef( 'array_wrapper_creator' ) ) answer.append( os.linesep * 2 ) doc = '' if self.declaration.type_qualifiers.has_static: answer.append( self.parent.class_var_name + '.add_static_property' ) else: if self.documentation: doc = self.documentation answer.append( self.parent.class_var_name + '.add_property' ) answer.append( '( ' ) answer.append('"%s"' % self.declaration.name ) answer.append( os.linesep + self.indent( self.PARAM_SEPARATOR ) ) temp = [ algorithm.create_identifier( self, "::boost::python::make_function" ) ] temp.append( '( ' ) temp.append( 'array_wrapper_creator(&%s)' % self.wrapper.wrapper_creator_full_name ) if not self.declaration.type_qualifiers.has_static: temp.append( os.linesep + self.indent( self.PARAM_SEPARATOR, 6 ) ) temp.append( call_policies.with_custodian_and_ward_postcall( 0, 1 ).create(self) ) temp.append( ' )' ) answer.append( ''.join( temp ) ) if doc: answer.append( os.linesep ) answer.append( self.PARAM_SEPARATOR ) answer.append( doc ) answer.append( ' );' ) return ''.join( answer )
def _generate_for_pointer(self): doc = '' #static property does not support documentation if self.declaration.type_qualifiers.has_static: add_property = 'add_static_property' else: if self.documentation: doc = self.documentation add_property = 'add_property' answer = [add_property] answer.append('( ') answer.append('"%s"' % self.alias) answer.append(self.PARAM_SEPARATOR) #according to David Abrahams: #http://mail.python.org/pipermail/c++-sig/2003-January/003276.html call_pol = call_policies.return_internal_reference().create(self) make_function = algorithm.create_identifier( self, '::boost::python::make_function') answer.append( '%(mk_func)s( (%(getter_type)s)(&%(wfname)s), %(call_pol)s )' % { 'mk_func': make_function, 'getter_type': self.wrapper.getter_type, 'wfname': self.wrapper.getter_full_name, 'call_pol': call_pol }) #don't generate setter method, right now I don't know how to do it. if self.wrapper.has_setter: answer.append(self.PARAM_SEPARATOR) call_pol = '' if not self.declaration.type_qualifiers.has_static: call_pol = ", " + call_policies.with_custodian_and_ward_postcall( 1, 2).create(self) answer.append( '%(mk_func)s( (%(setter_type)s)(&%(wfname)s)%(call_pol)s )' % { 'mk_func': make_function, 'setter_type': self.wrapper.setter_type, 'wfname': self.wrapper.setter_full_name, 'call_pol': call_pol }) if doc: answer.append(self.PARAM_SEPARATOR) answer.append(doc) answer.append(' ) ') code = ''.join(answer) if len(code) <= self.LINE_LENGTH: return code else: for i in range(len(answer)): if answer[i] == self.PARAM_SEPARATOR: answer[i] = os.linesep + self.indent( self.indent(self.indent(answer[i]))) return ''.join(answer)
def _generate_for_pointer( self ): doc = '' #static property does not support documentation if self.declaration.type_qualifiers.has_static: add_property = 'add_static_property' else: if self.documentation: doc = self.documentation add_property = 'add_property' answer = [ add_property ] answer.append( '( ' ) answer.append('"%s"' % self.alias) answer.append( self.PARAM_SEPARATOR ) #according to David Abrahams: #http://mail.python.org/pipermail/c++-sig/2003-January/003276.html call_pol = call_policies.return_internal_reference().create( self ) make_function = algorithm.create_identifier( self, '::boost::python::make_function' ) answer.append( '%(mk_func)s( (%(getter_type)s)(&%(wfname)s), %(call_pol)s )' % { 'mk_func' : make_function , 'getter_type' : self.wrapper.getter_type , 'wfname' : self.wrapper.getter_full_name , 'call_pol' : call_pol } ) #don't generate setter method, right now I don't know how to do it. if self.wrapper.has_setter: answer.append( self.PARAM_SEPARATOR ) call_pol = '' if not self.declaration.type_qualifiers.has_static: call_pol = ", " + call_policies.with_custodian_and_ward_postcall( 1, 2 ).create(self) answer.append( '%(mk_func)s( (%(setter_type)s)(&%(wfname)s)%(call_pol)s )' % { 'mk_func' : make_function , 'setter_type' : self.wrapper.setter_type , 'wfname' : self.wrapper.setter_full_name , 'call_pol' : call_pol } ) if doc: answer.append( self.PARAM_SEPARATOR ) answer.append( doc ) answer.append( ' ) ' ) code = ''.join( answer ) if len( code ) <= self.LINE_LENGTH: return code else: for i in range( len( answer ) ): if answer[i] == self.PARAM_SEPARATOR: answer[i] = os.linesep + self.indent( self.indent( self.indent( answer[i] ) ) ) return ''.join( answer )
def _create_body(self): answer = [] answer.append('typedef %s;' % self.wrapper.wrapper_creator_type.create_typedef( 'array_wrapper_creator')) answer.append(os.linesep * 2) doc = '' if self.declaration.type_qualifiers.has_static: answer.append(self.parent.class_var_name + '.add_static_property') else: if self.documentation: doc = self.documentation answer.append(self.parent.class_var_name + '.add_property') answer.append('( ') answer.append('"%s"' % self.declaration.name) answer.append(os.linesep + self.indent(self.PARAM_SEPARATOR)) temp = [ algorithm.create_identifier(self, "::boost::python::make_function") ] temp.append('( ') temp.append('array_wrapper_creator(&%s)' % self.wrapper.wrapper_creator_full_name) if not self.declaration.type_qualifiers.has_static: temp.append(os.linesep + self.indent(self.PARAM_SEPARATOR, 6)) temp.append( call_policies.with_custodian_and_ward_postcall(0, 1).create(self)) temp.append(' )') answer.append(''.join(temp)) if doc: answer.append(os.linesep) answer.append(self.PARAM_SEPARATOR) answer.append(doc) answer.append(' );') return ''.join(answer)