Skip to content

Commit

Permalink
Merge pull request #102 from sbmlteam/sk-fix-tests-other
Browse files Browse the repository at this point in the history
Adding any changes
  • Loading branch information
skeating committed May 24, 2023
2 parents d35818b + d87572a commit 20585bc
Show file tree
Hide file tree
Showing 108 changed files with 54,010 additions and 35,735 deletions.
7 changes: 5 additions & 2 deletions deviser/base_files/BaseCppFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,10 @@ def update_attribute_dictionary(self, att_type, mydict, attrib_name):
:return: nothing
"""
# Now update the dictionary, with the set of values according
# to att_type:
# to att_type

# note util_NaN must be prefixed by language if used in other library in v2

if att_type in ['SId', 'SIdRef', 'IDREF', 'ID', 'UnitSId',
'UnitSIdRef', 'string']:
mydict.update({'attType': 'string', 'attTypeCode': 'std::string&',
Expand All @@ -306,7 +309,7 @@ def update_attribute_dictionary(self, att_type, mydict, attrib_name):
elif att_type == 'double':
mydict.update({'attType': 'double', 'attTypeCode': 'double',
'CType': 'double', 'isNumber': True,
'default': 'util_NaN()'})
'default': gv.util_NaN})

elif att_type == 'int':
mydict.update({'attType': 'integer', 'attTypeCode': 'int',
Expand Down
7 changes: 4 additions & 3 deletions deviser/code_files/CppCodeFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def write_general_includes(self):
self.write_line_verbatim('#include <{0}/{1}'
'.h>'.format(self.language,
lo_name))
self.write_line_verbatim('#include <sbml/xml/XMLInputStream.h>')
self.write_line_verbatim('#include <xml/XMLInputStream.h>')

# determine whether we need to write other headers
write_element_filter = False
Expand Down Expand Up @@ -559,8 +559,9 @@ def write_document_error_log_functions(self):
num_elements = len(self.child_elements)
# add error log and ns to child elements
att_tc = 'XMLNamespaces*'
if not global_variables.is_package:
att_tc = 'LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces*'
# not needed in v 2.0
# if not global_variables.is_package:
# att_tc = 'LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces*'
element = dict({'name': 'Namespaces',
'isArray': False,
'attTypeCode': att_tc,
Expand Down
11 changes: 6 additions & 5 deletions deviser/code_files/CppHeaderFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ def write_general_includes(self):
include_lines += ['<{0}/{1}ErrorLog.h>'.format(self.language, global_variables.prefix)]

# if we another library we need the libsbml ns qualifier
if not global_variables.is_package:
include_lines += ['<sbml/common/libsbml-namespace.h>']

# not tru in v 2.0
# if not global_variables.is_package:
# include_lines += ['<common/libsbml-namespace.h>']

# write them out
for line in include_lines:
Expand Down Expand Up @@ -637,8 +637,9 @@ def write_document_error_log_functions(self):
num_elements = len(self.child_elements)
# add error log and ns to child elements
att_tc = 'XMLNamespaces*'
if not global_variables.is_package:
att_tc = 'LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces*'
# not needed in v 2.0
# if not global_variables.is_package:
# att_tc = 'LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces*'
element = dict({'name': 'Namespaces',
'isArray': False,
'attTypeCode': att_tc,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
#
# @file BaseClassFiles.py
# @file OtherLibraryFiles.py
# @brief class for generating base files for other library implementations
# @author Frank Bergmann
# @author Sarah Keating
Expand Down Expand Up @@ -50,7 +50,7 @@
from ..base_files import BaseCMakeFile, BaseTemplateFile


class BaseClassFiles(BaseTemplateFile.BaseTemplateFile):
class OtherLibraryFiles(BaseTemplateFile.BaseTemplateFile):
"""Class for all Base files"""

def __init__(self, name, elements, verbose=False):
Expand Down
3 changes: 2 additions & 1 deletion deviser/code_files/cpp_functions/Constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,8 @@ def write_constructor_args(self, ns):
else:
sep = ','
for attrib in self.attributes:
if not self.is_plugin and global_variables.language == 'sbml' and (attrib['memberName'] == 'mId' or attrib['memberName'] == 'mName'):
if not self.is_plugin and global_variables.language == 'sbml' and \
(attrib['memberName'] == 'mId' or attrib['memberName'] == 'mName'):
continue
elif global_variables.language != 'sbml' and attrib['memberName'] == 'mId':
continue
Expand Down
18 changes: 10 additions & 8 deletions deviser/code_files/cpp_functions/GeneralFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,10 +663,11 @@ def write_write_elements(self):
# create the function declaration
function = 'writeElements'
return_type = 'void'
if global_variables.is_package:
arguments = ['XMLOutputStream& stream']
else:
arguments = ['LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream']
# no longer necessary to have libsbml namespace in v2
# if global_variables.is_package:
arguments = ['XMLOutputStream& stream']
# else:
# arguments = ['LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream']

# create the function implementation
base = self.base_class
Expand Down Expand Up @@ -917,10 +918,11 @@ def write_write(self):
# create the function declaration
function = 'write'
return_type = 'void'
if global_variables.is_package:
arguments = ['XMLOutputStream& stream']
else:
arguments = ['LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream']
# not needed in v 2.0
# if global_variables.is_package:
arguments = ['XMLOutputStream& stream']
# else:
# arguments = ['LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream']

# create the function implementation
# find the array attribute
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ def write_add_object(self):
code = []
if not self.has_elements_with_same_xml_name():
# create the function implementation
last_line = ['return LIBSBML_OPERATION_FAILED']
last_line = ['return {0}'.format(global_variables.ret_failed)]
first = True
block = []
if_block = []
Expand Down
66 changes: 36 additions & 30 deletions deviser/code_files/cpp_functions/ProtectedFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,13 @@ def write_create_object(self):
# create the function declaration
function = 'createObject'
return_type = '{0}*'.format(self.std_base)
if global_variables.is_package:
arguments = ['XMLInputStream& stream']
xmlns = 'XMLNamespaces'
else:
arguments = ['LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream& stream']
xmlns = 'LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces'
# libsbml ns not needed in v 2.0
# if global_variables.is_package:
arguments = ['XMLInputStream& stream']
xmlns = 'XMLNamespaces'
# else:
# arguments = ['LIBSBML_CPP_NAMESPACE_QUALIFIER XMLInputStream& stream']
# xmlns = 'LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces'

# create the function implementation
code = []
Expand Down Expand Up @@ -609,10 +610,11 @@ def write_add_expected_attributes(self):
# create the function declaration
function = 'addExpectedAttributes'
return_type = 'void'
if global_variables.is_package:
arguments = ['ExpectedAttributes& attributes']
else:
arguments = ['LIBSBML_CPP_NAMESPACE_QUALIFIER ExpectedAttributes& attributes']
# no longer necessary to have libsbml namespace in v2
# if global_variables.is_package:
arguments = ['ExpectedAttributes& attributes']
# else:
# arguments = ['LIBSBML_CPP_NAMESPACE_QUALIFIER ExpectedAttributes& attributes']

# create the function implementation
if self.base_class:
Expand Down Expand Up @@ -679,12 +681,13 @@ def write_read_attributes(self):
# create function declaration
function = 'readAttributes'
return_type = 'void'
if global_variables.is_package:
arguments = ['const XMLAttributes& attributes',
'const ExpectedAttributes& expectedAttributes']
else:
arguments = ['const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLAttributes& attributes',
'const LIBSBML_CPP_NAMESPACE_QUALIFIER ExpectedAttributes& expectedAttributes']
# no longer necessary to have libsbml namespace in v2
# if global_variables.is_package:
arguments = ['const XMLAttributes& attributes',
'const ExpectedAttributes& expectedAttributes']
# else:
# arguments = ['const LIBSBML_CPP_NAMESPACE_QUALIFIER XMLAttributes& attributes',
# 'const LIBSBML_CPP_NAMESPACE_QUALIFIER ExpectedAttributes& expectedAttributes']

# create the function implementation
implementation = ['unsigned int level = getLevel()',
Expand Down Expand Up @@ -934,10 +937,11 @@ def write_write_attributes(self):
# create function declaration
function = 'writeAttributes'
return_type = 'void'
if global_variables.is_package:
arguments = ['XMLOutputStream& stream']
else:
arguments = ['LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream']
# no longer necessary to have libsbml namespace in v2
# if global_variables.is_package:
arguments = ['XMLOutputStream& stream']
# else:
# arguments = ['LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream']

# create the function implementation
if self.base_class:
Expand Down Expand Up @@ -1006,10 +1010,11 @@ def write_write_version_attributes(self, version):
pkg_version = self.lv_info[version]['pkg_version']
function = 'writeL{0}V{1}V{2}Attributes'.format(level_val, version_val, pkg_version)
return_type = 'void'
if global_variables.is_package:
arguments = ['XMLOutputStream& stream']
else:
arguments = ['LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream']
# not needed in v 2.0
# if global_variables.is_package:
arguments = ['XMLOutputStream& stream']
# else:
# arguments = ['LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream']

# create the function implementation
code = []
Expand Down Expand Up @@ -1055,12 +1060,13 @@ def write_write_xmlns(self):
# create the function declaration
function = 'writeXMLNS'
return_type = 'void'
if global_variables.is_package:
arguments = ['XMLOutputStream& stream']
xmlns = 'XMLNamespaces'
else:
arguments = ['LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream']
xmlns = 'LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces'
# not needed for v 2.0
# if global_variables.is_package:
arguments = ['XMLOutputStream& stream']
xmlns = 'XMLNamespaces'
# else:
# arguments = ['LIBSBML_CPP_NAMESPACE_QUALIFIER XMLOutputStream& stream']
# xmlns = 'LIBSBML_CPP_NAMESPACE_QUALIFIER XMLNamespaces'

# create the function implementation
implementation = ['{0} xmlns'.format(xmlns),
Expand Down
8 changes: 4 additions & 4 deletions deviser/code_files/cpp_functions/SetGetFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1591,8 +1591,7 @@ def get_c_attribute(self, attribute):
self.cap_language)]
elif attribute['attType'] == 'double':
line = ['return ({0} != NULL) ? {0}->get{1}() : '
'util_NaN()'.format(self.abbrev_parent,
attribute['capAttName'])]
'{2}'.format(self.abbrev_parent, attribute['capAttName'], global_variables.util_NaN)]
elif attribute['attType'] == 'boolean':
line = ['return ({0} != NULL) ? static_cast<int>({0}->get{1}()) : '
'0'.format(self.abbrev_parent,
Expand All @@ -1608,9 +1607,10 @@ def get_c_attribute(self, attribute):
use_name = 'static_cast<const ' \
'{0}*>({1})'.format(self.class_name,
self.abbrev_parent)
line = ['return {0}->get{1}().empty() ? NULL : safe_strdup({0}'
line = ['return {0}->get{1}().empty() ? NULL : {2}({0}'
'->get{1}().c_str())'.format(use_name,
attribute['capAttName'])]
attribute['capAttName'],
global_variables.safe_strdup)]
code.append(self.create_code_block('line', line))
return code

Expand Down

0 comments on commit 20585bc

Please sign in to comment.