Skip to content

Commit

Permalink
Updated set method for enum
Browse files Browse the repository at this point in the history
  • Loading branch information
hovo1990 committed Jul 25, 2016
1 parent 8fc02a5 commit 4e62d11
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
15 changes: 8 additions & 7 deletions generator/java_code_files/JavaCodeFile.py
Expand Up @@ -78,13 +78,13 @@ def write_class(self):
self.write_mandatory_functions()


self.write_child_element_functions()
# self.write_child_element_functions()
self.write_listof_functions()

# TODOs
self.write_child_lo_element_functions()

self.write_concrete_functions()
# self.write_concrete_functions()

# TODO write hash, read, write bugs
self.write_general_functions()
Expand Down Expand Up @@ -327,11 +327,12 @@ def write_attribute_functions(self):



code = attrib_functions.write_set_string_for_enum(True, i)
self.write_function_implementation(code)

code = attrib_functions.write_add_element_for_vector(True, i)
self.write_function_implementation(code)
# TODO GSOC 2016 this part is not needed?
# code = attrib_functions.write_set_string_for_enum(True, i)
# self.write_function_implementation(code)
#
# code = attrib_functions.write_add_element_for_vector(True, i)
# self.write_function_implementation(code)

for i in range(0, num_attributes):
code = attrib_functions.write_unset(True, i)
Expand Down
43 changes: 32 additions & 11 deletions generator/java_code_files/java_functions/SetGetFunctions.py
Expand Up @@ -1068,8 +1068,7 @@ def write_set(self, is_attribute, index, write_for = "String"):
.format(attribute['name'], att_type,
ob_type))

params = ['@param {0}'.format(attribute['name'])]
# ' the {0} to set'.format(attribute['name'])]


return_lines.append("@copydetails doc_returns_success_code")
return_lines.append('@li @{0}constant{1}{2}, '
Expand All @@ -1094,9 +1093,15 @@ def write_set(self, is_attribute, index, write_for = "String"):
attribute['capAttName'])
return_type = 'int'

# params = ['@param {0}'.format(attribute['name'])]
# # ' the {0} to set'.format(attribute['name'])]

params = ['Sets the value of {0}'.format(attribute['name'])]
params.append(' ')
params.append('@param {0} the value of {1} to be set.'.format(attribute['name'], attribute['name']))
# ' the {0} to set'.format(attribute['name'])]

# TODO write_set implementation of return_type definition DONE
# TODO write_set implementation of return_type definition?
if attribute['type'] == 'SIdRef':
return_type = 'boolean'
else:
Expand All @@ -1118,6 +1123,13 @@ def write_set(self, is_attribute, index, write_for = "String"):
arguments.append('{0}& {1}'
.format(attribute['attTypeCode'],
attribute['name']))
elif attribute['attType'] == 'enum':
data = self.jsbml_data_tree['Difference'][attribute['JClassType']]
if len(data) > 0:
arg_type = data
else:
arg_type = attribute['JClassType']
arguments.append('{0} {1}'.format(arg_type, attribute['name']))
else:
arguments.append('{0} {1}'
.format((attribute['attTypeCode']
Expand Down Expand Up @@ -2026,14 +2038,23 @@ def set_java_attribute(self, attribute, write_for = 'String'):
'return {0}'.format(self.success)]
code = [dict({'code_type': 'line', 'code': implementation})]
elif attribute['type'] == 'enum': # TODO setType setOperation setSig
implementation = ['{0}_isValid({1}) == '
'0'.format(attribute['element'], name),
'{0} = {1}'.format(member,
attribute['default']),
'return {0}'.format(self.invalid_att), 'else',
'{0} = {1}'.format(member, name),
'return {0}'.format(self.success)]
code = [dict({'code_type': 'if_else', 'code': implementation})]
# TODO maybe all should look like this
curr_att_type = attribute['JClassType']
implementation = []
implementation.append('{0} old{1} = this.{2}'.format(curr_att_type, attribute['capAttName'],
name))
implementation.append('this.{0} = null'.format(name))
implementation.append('firePropertyChange({0}Constants.{1}, old{1}, this.{1})'.format(self.package,
name))
code = [dict({'code_type': 'line', 'code': implementation})]
# implementation = ['{0}_isValid({1}) == '
# '0'.format(attribute['element'], name),
# '{0} = {1}'.format(member,
# attribute['default']),
# 'return {0}'.format(self.invalid_att), 'else',
# '{0} = {1}'.format(member, name),
# 'return {0}'.format(self.success)]
# code = [dict({'code_type': 'if_else', 'code': implementation})]
elif query.has_is_set_member(attribute):
code = self.write_set_att_with_member(attribute, True)

Expand Down

0 comments on commit 4e62d11

Please sign in to comment.