Permalink
Browse files

Prototype get Count method

  • Loading branch information...
hovo1990 committed Jul 21, 2016
1 parent 2804d3c commit 7dd54a4a9c15f4e395aea147aea1cb868ae5a157
@@ -78,12 +78,12 @@ def write_class(self):
self.write_mandatory_functions()
# self.write_child_element_functions()
# self.write_listof_functions()
self.write_child_element_functions()
self.write_listof_functions()
self.write_child_lo_element_functions()
# self.write_concrete_functions()
self.write_concrete_functions()
# TODO write hash, read, write bugs
self.write_general_functions()
@@ -732,6 +732,12 @@ def write_child_lo_element_functions_by_groups(self, function_to_write):
code = lo_functions.write_get_list_of_function()
self.write_function_implementation(code)
# getInputCount alternative
if function_to_write == 'getNum':
code = lo_functions.write_get_num_element_function()
self.write_function_implementation(code)
if function_to_write == 'createElement':
if 'concretes' in element:
for n in range(0, len(element['concretes'])):
@@ -772,7 +778,8 @@ def write_child_lo_element_functions(self):
function_to_write = 'createElementID'
self.write_child_lo_element_functions_by_groups(function_to_write)
function_to_write = 'getNum'
self.write_child_lo_element_functions_by_groups(function_to_write)
num_elements = len(self.child_lo_elements)
@@ -798,8 +805,8 @@ def write_child_lo_element_functions(self):
#getInputCount
code = lo_functions.write_get_element_by_index(is_const=False)
self.write_function_implementation(code)
# code = lo_functions.write_get_element_by_index(is_const=False)
# self.write_function_implementation(code)
# # ? same as previous
# code = lo_functions.write_get_element_by_index(is_const=True)
@@ -830,9 +837,7 @@ def write_child_lo_element_functions(self):
# getInputCount alternative
code = lo_functions.write_get_num_element_function()
self.write_function_implementation(code)
@@ -1251,36 +1251,46 @@ def write_get_num_element_function(self, parameter=None):
'this {1}.'.format(self.object_child_name,
self.object_name)
params = []
if parameter:
params.append('@param {0} the {0} of the {1} to return.'
''.format(parameter['name'], self.object_child_name))
if not self.is_java_api:
params.append('@param {0} the {1} structure to query.'
.format(self.abbrev_parent, self.object_name))
# if parameter:
# params.append('@param {0} the {0} of the {1} to return.'
# ''.format(parameter['name'], self.object_child_name))
# if not self.is_java_api:
# params.append('@param {0} the {1} structure to query.'
# .format(self.abbrev_parent, self.object_name))
return_lines = ['@return the number of {0} objects in '
'this {1}.'.format(self.object_child_name,
self.object_name)]
additional = []
# create the function declaration
arguments = []
if parameter:
arguments.append('{0} {1}'.format(parameter['type'], parameter['name']))
used_c_name = strFunctions.remove_prefix(self.plural)
used_java_name_plural = strFunctions.remove_prefix(self.plural)
used_java_name = strFunctions.remove_prefix(self.child_name)
if self.is_java_api:
function = 'getNum{0}'.format(used_c_name)
function = 'getNum{0}'.format(used_java_name_plural)
else:
function = '{0}_getNum{1}'.format(self.class_name, used_c_name)
function = '{0}_getNum{1}'.format(self.class_name, used_java_name_plural)
arguments.append('{0}* {1}'.format(self.object_name,
self.abbrev_parent))
return_type = 'unsigned int'
return_type = 'int'
params.append('Returns the number of {{@link {0}}}s in this'.format(used_java_name))
params.append('{{@link {0}}}.'.format(self.package))
params.append(' ')
params.append('@return the number of {{@link {0}}}s in this {{@link {0}}}.'.format(used_java_name,
self.package))
params.append('@libsbml.deprecated same as {{@link #get{0}Count()}}'.format(used_java_name))
if self.is_java_api and self.is_list_of:
implementation = ['return size()']
implementation = ['return get{0}Count()'.format(used_java_name)]
elif self.is_java_api and not self.is_list_of:
if not self.document:
implementation = ['return {0}.'
'size()'.format(self.class_object['memberName'])]
implementation = ['return get{0}Count()'.format(used_java_name)]
# implementation = ['return {0}.'
# 'size()'.format(self.class_object['memberName'])]
elif parameter:
implementation = ['return getErrorLog()->'
'getNumFailsWith{0}({1})'
@@ -1293,7 +1303,7 @@ def write_get_num_element_function(self, parameter=None):
else:
implementation = ['return ({0} != NULL) ? {0}->getNum{1}() : '
'{2}_INT_MAX'.format(self.abbrev_parent,
used_c_name,
used_java_name_plural,
self.cap_language)]
code = [self.create_code_block('line', implementation)]
# return the parts

0 comments on commit 7dd54a4

Please sign in to comment.