Permalink
Browse files

Prototype write_set_list_of_function for jsbml

  • Loading branch information...
hovo1990 committed Jul 21, 2016
1 parent b5a0466 commit f4deff156ca7f4d37fb8445effb98d92c4ba8815
@@ -716,6 +716,10 @@ def write_child_lo_element_functions_by_groups(self, function_to_write):
code = lo_functions.write_is_set_list_of_function()
self.write_function_implementation(code)
if function_to_write == 'setListOf':
code = lo_functions.write_set_list_of_function()
self.write_function_implementation(code)
if function_to_write == 'addElement':
code = lo_functions.write_add_element_function()
@@ -787,6 +791,9 @@ def write_child_lo_element_functions(self):
function_to_write = 'isSetListOf'
self.write_child_lo_element_functions_by_groups(function_to_write)
function_to_write = 'setListOf'
self.write_child_lo_element_functions_by_groups(function_to_write)
num_elements = len(self.child_lo_elements)
for i in range(0, num_elements):
element = self.child_lo_elements[i]
@@ -1526,6 +1526,111 @@ def write_is_set_list_of_function(self, is_const=False):
########################################################################
# Functions for writing setListOf
# function to write set
def write_set_list_of_function(self, is_const=False):
if not self.is_java_api and not is_const:
return
loname = strFunctions.list_of_name(self.child_name)
loname_lower = strFunctions.jsbml_list_of_name(self.child_name)
# create comment parts
params = []
if self.is_java_api:
title_line = 'Returns the {0} from this {1}.' \
''.format(loname, self.object_name)
return_lines = ['@return the {0} '
'from this {1}.'.format(loname, self.object_name)]
else:
title_line = 'Returns a ListOf_t* containing {0} objects ' \
'from this {1}.'.format(self.object_child_name,
self.object_name)
params.append('@param {0} the {1} structure whose \"{2}\" is sought'
'.'.format(self.abbrev_parent, self.object_name,
loname))
return_lines = ['@return the \"{0}\" from this {1} as a '
'ListOf_t *.'.format(loname, self.object_name)]
additional = []
# create the function declaration
lo_name = strFunctions.remove_prefix(loname)
lo_name_lower = strFunctions.remove_prefix(loname_lower)
used_java_name = strFunctions.upper_first(self.child_name)
used_java_name_lower = strFunctions.lower_first(self.child_name)
params.append('Sets the given {{@code ListOf<{0}>}}.'.format(used_java_name))
params.append('If {{@link {0}}} was defined before \
and contains some elements, they are all unset.'.format(loname_lower))
params.append(' ')
params.append('@param {0}'.format(loname_lower))
code = []
# used_java_name = strFunctions.upper_first(strFunctions.remove_prefix(self.object_name))
# used_java_name_lower = strFunctions.upper_first(strFunctions.remove_prefix(self.object_name_lower))
if self.is_java_api:
function = 'set{0}'.format(lo_name)
arguments = ['ListOf<{0}> {1}'.format(used_java_name, loname_lower)] # ['{0}s'.format(used_java_name)]
return_type = 'void'
# if is_const:
# return_type = 'const {0}*'.format(loname)
# else:
# return_type = '{0}*'.format(loname)
else:
function = '{0}_get{1}'.format(self.class_name, name_used)
arguments = ['{0}* {1}'.format(self.object_name,
self.abbrev_parent)]
if global_variables.is_package:
return_type = 'ListOf_t*'
else:
return_type = '{0}ListOf_t*'.format(global_variables.prefix)
if self.is_java_api:
# implementation = ['return '
# '&{0}'.format(self.class_object['memberName'])]
# code = [self.create_code_block('line', implementation)]
implementation = ['unset{0}()'.format(loname_lower)]
implementation.append('this.{0} = {1}'.format(loname_lower, loname_lower))
implementation.append('this.{0}.setSBaseListType(ListOf.Type.other)'.format(loname_lower))
if self.status != 'plugin':
implementation.append('registerChild({0})'.format(loname_lower))
temp_code = self.create_code_block('line', implementation)
code.append(temp_code)
else:
implementation = ['return ({0} != NULL) ? {0}->get{1}() : '
'NULL'.format(self.abbrev_parent, name_used)]
code = [self.create_code_block('line', implementation)]
# return the parts
if self.status == 'plugin':
implementation = ['{isSetExtendedSBase()']
implementation.append('extendedSBase.registerChild({0})'.format(loname_lower))
temp_code = self.create_code_block('if', implementation)
code.append(temp_code)
line = 'return {0}'.format(loname_lower)
line_code = line # self.create_code_block('line', line)
code.append(line_code)
return dict({'title_line': title_line,
'params': params,
'return_lines': return_lines,
'additional': additional,
'function': function,
'return_type': return_type,
'arguments': arguments,
'constant': is_const,
'virtual': False,
'object_name': self.struct_name,
'implementation': code})
########################################################################
# HELPER FUNCTIONS
@staticmethod

0 comments on commit f4deff1

Please sign in to comment.