Skip to content

Commit

Permalink
Create release v0.3.103.
Browse files Browse the repository at this point in the history
  • Loading branch information
abi-git-user committed Sep 14, 2022
1 parent dbfc97b commit fe5afe2
Show file tree
Hide file tree
Showing 154 changed files with 470 additions and 255 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ cmake_minimum_required(VERSION 3.10.2)

set(PROJECT_NAME libCellML)
set(PROJECT_URL https://libcellml.org)
set(_PROJECT_VERSION 0.3.102)
set(_PROJECT_VERSION 0.3.103)
set(PROJECT_DEVELOPER_VERSION )
project(${PROJECT_NAME} VERSION ${_PROJECT_VERSION} LANGUAGES CXX)

Expand Down
2 changes: 2 additions & 0 deletions cmake/add_rpath_for_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
string(REPLACE "${LIST_SEPARATOR}" ";" SHARED_OBJECT_MODULES "${SHARED_OBJECT_MODULES}")
foreach(_M ${SHARED_OBJECT_MODULES})
execute_process(COMMAND ${INSTALL_NAME_TOOL_EXE} -change "/Library/Frameworks/Python.framework/Versions/${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/Python" @rpath/Python.framework/Versions/${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/Python ${_M})
execute_process(COMMAND ${INSTALL_NAME_TOOL_EXE} -add_rpath /Library/Frameworks ${_M})
execute_process(COMMAND ${INSTALL_NAME_TOOL_EXE} -add_rpath /usr/local/Frameworks ${_M})
execute_process(COMMAND ${INSTALL_NAME_TOOL_EXE} -add_rpath /opt/homebrew/Frameworks ${_M})
endforeach()

20 changes: 20 additions & 0 deletions docs/changelogs/changelog_v0.3.103.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
libCellML v0.3.103 Changelog
============================

Bug
---

* Fix segfault when printing complete MathML document by `@hsorby <https://github.com/hsorby>`_ [`#1026 <https://github.com/cellml/libcellml/pull/1026>`_].

Python bindings
---------------

* Add more search paths for macOS python bindings by `@hsorby <https://github.com/hsorby>`_ [`#1037 <https://github.com/cellml/libcellml/pull/1037>`_].

Contributors
------------

.. image:: https://avatars.githubusercontent.com/u/778048?v=4
:target: https://github.com/hsorby
:height: 32
:width: 32
1 change: 1 addition & 0 deletions docs/changelogs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelogs

.. toctree::

changelog_v0.3.103
changelog_v0.3.102
changelog_v0.3.101
changelog_v0.3.100
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Changelogs

.. toctree::

changelogs/changelog_v0.3.103
changelogs/changelog_v0.3.102
changelogs/changelog_v0.3.101
changelogs/changelog_v0.3.100
Expand Down
1 change: 1 addition & 0 deletions src/api/libcellml/issue.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class LIBCELLML_EXPORT Issue
friend class Annotator;
friend class Importer;
friend class Parser;
friend class Printer;
friend class Validator;

public:
Expand Down
1 change: 0 additions & 1 deletion src/api/libcellml/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ limitations under the License.
#include "libcellml/logger.h"
#include "libcellml/model.h"
#include "libcellml/types.h"
#include "libcellml/units.h"

namespace libcellml {

Expand Down
9 changes: 5 additions & 4 deletions src/api/libcellml/printer.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ limitations under the License.
#include <string>

#include "libcellml/exportdefinitions.h"
#include "libcellml/logger.h"
#include "libcellml/types.h"

namespace libcellml {
Expand All @@ -28,7 +29,7 @@ namespace libcellml {
*
* The Printer class is for representing a CellML Printer.
*/
class LIBCELLML_EXPORT Printer
class LIBCELLML_EXPORT Printer: public Logger
{
public:
~Printer(); /**< Destructor, @private. */
Expand Down Expand Up @@ -59,13 +60,13 @@ class LIBCELLML_EXPORT Printer
*
* @return The @c std::string representation of the @ref Model.
*/
std::string printModel(const ModelPtr &model, bool autoIds = false) const;
std::string printModel(const ModelPtr &model, bool autoIds = false);

private:
Printer(); /**< Constructor, @private. */

struct PrinterImpl; /**< Forward declaration for pImpl idiom, @private. */
PrinterImpl *mPimpl; /**< Private member to implementation pointer, @private. */
class PrinterImpl; /**< Forward declaration for pImpl idiom, @private. */
PrinterImpl *pFunc(); /**< Getter for private implementation pointer, @private. */
};

} // namespace libcellml
1 change: 1 addition & 0 deletions src/api/libcellml/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ class LIBCELLML_EXPORT AnyCellmlElement
friend class Importer;
friend class Issue;
friend class Parser;
friend class Printer;
friend class Validator;

public:
Expand Down
1 change: 1 addition & 0 deletions src/bindings/interface/printer.i
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
%include <std_string.i>

%import "createconstructor.i"
%import "logger.i"
%import "types.i"

%feature("docstring") libcellml::Printer
Expand Down
76 changes: 62 additions & 14 deletions src/printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,31 +26,41 @@ limitations under the License.

#include "libcellml/component.h"
#include "libcellml/importsource.h"
#include "libcellml/issue.h"
#include "libcellml/model.h"
#include "libcellml/reset.h"
#include "libcellml/units.h"
#include "libcellml/variable.h"

#include "anycellmlelement_p.h"
#include "internaltypes.h"
#include "issue_p.h"
#include "logger_p.h"
#include "utilities.h"
#include "xmldoc.h"

#include <iostream>

namespace libcellml {

/**
* @brief The Printer::PrinterImpl struct.
*
* The private implementation for the Printer class.
*/
struct Printer::PrinterImpl
class Printer::PrinterImpl: public Logger::LoggerImpl
{
std::string printImports(const ModelPtr &model, IdList &idList, bool autoIds);
std::string printUnits(const UnitsPtr &units, IdList &idList, bool autoIds);
public:
Printer *mPrinter = nullptr;

std::string printComponent(const ComponentPtr &component, IdList &idList, bool autoIds);
std::string printEncapsulation(const ComponentPtr &component, IdList &idList, bool autoIds);
std::string printVariable(const VariablePtr &variable, IdList &idList, bool autoIds);
std::string printImports(const ModelPtr &model, IdList &idList, bool autoIds);
std::string printMath(const std::string &math);
std::string printReset(const ResetPtr &reset, IdList &idList, bool autoIds);
std::string printResetChild(const std::string &childLabel, const std::string &childId, const std::string &math, IdList &idList, bool autoIds);
std::string printUnits(const UnitsPtr &units, IdList &idList, bool autoIds);
std::string printVariable(const VariablePtr &variable, IdList &idList, bool autoIds);
};

std::string printMapVariables(const VariablePairPtr &variablePair, IdList &idList, bool autoIds)
Expand Down Expand Up @@ -127,12 +137,32 @@ std::string printConnections(const ComponentMap &componentMap, const VariableMap
return connections;
}

std::string printMath(const std::string &math)
std::string Printer::PrinterImpl::printMath(const std::string &math)
{
static const std::regex before(">[\\s\n\t]*");
static const std::regex after("[\\s\n\t]*<");
auto temp = std::regex_replace(math, before, ">");
return std::regex_replace(temp, after, "<");
static const std::regex xmlDeclaration(R"|(<\?xml[[:space:]]+version=.*\?>)|");

XmlDocPtr xmlDoc = std::make_shared<XmlDoc>();
xmlKeepBlanksDefault(0);
xmlDoc->parse(math);
if (xmlDoc->xmlErrorCount() == 0) {
auto result = xmlDoc->prettyPrint();
// Remove any XML declarations from the string.
result = std::regex_replace(result, xmlDeclaration, "");
// Clean whitespace in the math.
result = std::regex_replace(result, before, ">");
return std::regex_replace(result, after, "<");
} else {
for (size_t i = 0; i < xmlDoc->xmlErrorCount(); ++i) {
auto issue = Issue::IssueImpl::create();
issue->mPimpl->setDescription("LibXml2 error: " + xmlDoc->xmlError(i));
issue->mPimpl->setReferenceRule(Issue::ReferenceRule::XML);
addIssue(issue);
}
}

return "";
}

void buildMapsForComponentsVariables(const ComponentPtr &component, ComponentMap &componentMap, VariableMap &variableMap)
Expand Down Expand Up @@ -255,7 +285,13 @@ std::string Printer::PrinterImpl::printComponent(const ComponentPtr &component,
repr += printReset(component->reset(i), idList, autoIds);
}
if (!component->math().empty()) {
size_t startIssueCount = mPrinter->issueCount();
repr += printMath(component->math());
size_t endIssueCount = mPrinter->issueCount();
for (size_t current = startIssueCount; current < endIssueCount; ++current) {
auto issue = mPrinter->issue(current);
issue->mPimpl->mItem->mPimpl->setComponent(component);
}
}

repr += "</component>";
Expand Down Expand Up @@ -376,6 +412,7 @@ std::string Printer::PrinterImpl::printReset(const ResetPtr &reset, IdList &idLi
repr += " id=\"" + makeUniqueId(idList) + "\"";
}

size_t startIssueCount = mPrinter->issueCount();
std::string testValue = printResetChild("test_value", reset->testValueId(), reset->testValue(), idList, autoIds);
if (!testValue.empty()) {
repr += ">" + testValue;
Expand All @@ -390,6 +427,11 @@ std::string Printer::PrinterImpl::printReset(const ResetPtr &reset, IdList &idLi
hasChild = true;
}
if (hasChild) {
size_t endIssueCount = mPrinter->issueCount();
for (size_t current = startIssueCount; current < endIssueCount; ++current) {
auto issue = mPrinter->issue(current);
issue->mPimpl->mItem->mPimpl->setReset(reset);
}
repr += "</reset>";
} else {
repr += "/>";
Expand Down Expand Up @@ -453,22 +495,28 @@ std::string Printer::PrinterImpl::printImports(const ModelPtr &model, IdList &id
return repr;
}

Printer::PrinterImpl *Printer::pFunc()
{
return reinterpret_cast<Printer::PrinterImpl *>(Logger::pFunc());
}

Printer::Printer()
: mPimpl(new PrinterImpl())
: Logger(new PrinterImpl())
{
pFunc()->mPrinter = this;
}

Printer::~Printer()
{
delete mPimpl;
delete pFunc();
}

PrinterPtr Printer::create() noexcept
{
return std::shared_ptr<Printer> {new Printer {}};
}

std::string Printer::printModel(const ModelPtr &model, bool autoIds) const
std::string Printer::printModel(const ModelPtr &model, bool autoIds)
{
if (model == nullptr) {
return "";
Expand Down Expand Up @@ -497,21 +545,21 @@ std::string Printer::printModel(const ModelPtr &model, bool autoIds) const
}

if (model->hasImports()) {
repr += mPimpl->printImports(model, idList, autoIds);
repr += pFunc()->printImports(model, idList, autoIds);
}

for (size_t i = 0; i < model->unitsCount(); ++i) {
repr += mPimpl->printUnits(model->units(i), idList, autoIds);
repr += pFunc()->printUnits(model->units(i), idList, autoIds);
}

std::string componentEncapsulation;
// Serialise components of the model, imported components have already been dealt with at this point,
// ... but their locally-defined children have not.
for (size_t i = 0; i < model->componentCount(); ++i) {
ComponentPtr component = model->component(i);
repr += mPimpl->printComponent(component, idList, autoIds);
repr += pFunc()->printComponent(component, idList, autoIds);
if (component->componentCount() > 0) {
componentEncapsulation += mPimpl->printEncapsulation(component, idList, autoIds);
componentEncapsulation += pFunc()->printEncapsulation(component, idList, autoIds);
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ if(LIBCELLML_LLVM_COVERAGE)
COMMENT "Running LLVM coverage tests")

add_custom_target(llvm_coverage_report
COMMAND ${LLVM_COV_EXE} show $<TARGET_FILE:cellml> -instr-profile=${DATA_PROFILE_FILENAME} -format=html -Xdemangler c++filt -Xdemangler -n -o coverage_report
COMMAND ${LLVM_COV_EXE} show $<TARGET_FILE:cellml> -instr-profile=${DATA_PROFILE_FILENAME} -format=html -Xdemangler c++filt -Xdemangler -n -o coverage_report --show-branches=count
DEPENDS prepare_llvm_coverage
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Running LLVM coverage missing lines command")
Expand Down
2 changes: 1 addition & 1 deletion tests/bindings/javascript/version.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ describe("Version tests", () => {
libcellml = await libCellMLModule();
});
test('Checking version string.', () => {
expect(libcellml.versionString()).toBe('0.3.102');
expect(libcellml.versionString()).toBe('0.3.103');
});
})
Loading

0 comments on commit fe5afe2

Please sign in to comment.