Permalink
Browse files

prototype get_list_of method

  • Loading branch information...
hovo1990 committed Jul 20, 2016
1 parent 92a25aa commit 78d74fb32a78c3b4d3d97732333729b652403c8b
@@ -728,6 +728,10 @@ def write_child_lo_element_functions_by_groups(self, function_to_write):
code = lo_functions.write_remove_element_by_id()
self.write_function_implementation(code)
if function_to_write == 'getListOf':
code = lo_functions.write_get_list_of_function()
self.write_function_implementation(code)
# main function to write the functions dealing with a child listOf element
def write_child_lo_element_functions(self):
@@ -740,6 +744,9 @@ def write_child_lo_element_functions(self):
function_to_write = 'removeElementById'
self.write_child_lo_element_functions_by_groups(function_to_write)
function_to_write = 'getListOf'
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):
@@ -761,8 +768,7 @@ def write_child_lo_element_functions(self):
# TODO
code = lo_functions.write_get_list_of_function(is_const=True)
self.write_function_implementation(code)
# # ? same as previous
@@ -1134,6 +1134,7 @@ def write_get_list_of_function(self, is_const=False):
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:
@@ -1152,15 +1153,31 @@ def write_get_list_of_function(self, is_const=False):
'ListOf_t *.'.format(loname, self.object_name)]
additional = []
# create the function declaration
name_used = strFunctions.remove_prefix(loname)
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('Returns the {{@link {0}}}'.format(loname_lower))
params.append('Creates it if it does not already exist.')
params.append(' ')
params.append('@return the {{@link {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 = 'get{0}'.format(name_used)
arguments = []
if is_const:
return_type = 'const {0}*'.format(loname)
else:
return_type = '{0}*'.format(loname)
function = 'get{0}'.format(lo_name)
arguments = []#['{0}s'.format(used_java_name)]
return_type = 'ListOf<{0}>'.format(used_java_name)
# 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,
@@ -1170,14 +1187,38 @@ def write_get_list_of_function(self, is_const=False):
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 = ['return '
# '&{0}'.format(self.class_object['memberName'])]
# code = [self.create_code_block('line', implementation)]
implementation = ['{0} == null'.format(loname_lower)]
implementation.append('{0} == new ListOf<{1}>()'.format(loname_lower, used_java_name))
implementation.append('{0}.setNamespace({1}Constants.namespaceURI)'.format(loname_lower, self.package))
implementation.append('{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('if', 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,

0 comments on commit 78d74fb

Please sign in to comment.