Cleanup and support for relative paths
This commit is contained in:
1 parent
389113722e
commit
c17fbd2dcf
11 files changed
+339
-73
No files matched your search
@@ -1,11 +1,11 @@
|
||||
#ifndef DOMAIN_ATTRIBUTE_H
|
||||
#define DOMAIN_ATTRIBUTE_H
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "rule.h"
|
||||
#include "value.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace domain {
|
||||
|
||||
class Enumeration {
|
||||
|
||||
@@ -30,7 +30,7 @@ std::optional<std::vector<Value>> Connection::getSecondWires() {
|
||||
}
|
||||
|
||||
Attribute Connection::getAttribute(std::string name) {
|
||||
for(uint i=0; i<attributes.size(); i++) {
|
||||
for(unsigned int i=0; i<attributes.size(); i++) {
|
||||
if(attributes[i].getName() == name) {
|
||||
return attributes[i];
|
||||
}
|
||||
@@ -39,7 +39,7 @@ Attribute Connection::getAttribute(std::string name) {
|
||||
}
|
||||
|
||||
bool Connection::hasAttribute(std::string name) {
|
||||
for(uint i=0; i<attributes.size(); i++) {
|
||||
for(unsigned int i=0; i<attributes.size(); i++) {
|
||||
if(attributes[i].getName() == name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#define DOMAIN_FUNCTION_SIGNATURE_H
|
||||
|
||||
#include<functional>
|
||||
#include<vector>
|
||||
|
||||
#include "value.h"
|
||||
|
||||
namespace domain {
|
||||
|
||||
@@ -8,7 +8,7 @@ Condition::Condition(std::string function, std::vector<Value> params, bool negat
|
||||
|
||||
bool Condition::evaluate(RuleContext &context) {
|
||||
std::vector<Value> request;
|
||||
for(uint i=0; i<params.size(); i++) {
|
||||
for(unsigned int i=0; i<params.size(); i++) {
|
||||
if(params[i].isType(Value::ADDRESS_SPACE_REFERENCE)) {
|
||||
request.push_back(Value::fromAddressSpace(context.addressSpaces.at(params[i].asReference())));
|
||||
} else if(params[i].isType(Value::ATTRIBUTE_REFERENCE)) {
|
||||
@@ -50,7 +50,7 @@ Rule::Rule(std::vector<IfStatement> statements)
|
||||
{}
|
||||
|
||||
std::optional<Action> Rule::evaluate(RuleContext &context) {
|
||||
for(uint i=0; i<statements.size(); i++) {
|
||||
for(unsigned int i=0; i<statements.size(); i++) {
|
||||
auto response = statements[i].evaluate(context);
|
||||
if(response) {
|
||||
return response;
|
||||
|
||||
@@ -1016,8 +1016,7 @@ PResult<ValueNode> ComdelParser::parseValue() {
|
||||
return unexpected();
|
||||
}
|
||||
|
||||
//return spanner(value);
|
||||
return value;
|
||||
return spanner(value);
|
||||
}
|
||||
|
||||
std::optional<SchemaNode> ComdelParser::parseSchema() {
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <QDir>
|
||||
|
||||
std::optional<LibraryNode> loadLibraryFromFile(ParseContext * parseContext,
|
||||
const char* name,
|
||||
@@ -75,7 +76,17 @@ std::optional<SchemaNode> loadSchemaFromFile(ParseContext * parseContext,
|
||||
}
|
||||
|
||||
if(unit->source) {
|
||||
unit->library = loadLibraryFromFile(parseContext, unit->source->asString().c_str(), stream);
|
||||
QFileInfo info(name);
|
||||
auto filepath = info.absolutePath();
|
||||
QDir dir;
|
||||
dir.setCurrent(filepath);
|
||||
|
||||
auto libraryPath = dir.absoluteFilePath(QString::fromStdString(unit->source->asString()));
|
||||
|
||||
unit->library = loadLibraryFromFile(parseContext, libraryPath.toUtf8().data(), stream);
|
||||
if(unit->library == std::nullopt) {
|
||||
return std::nullopt;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user