-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,622 additions
and
125 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,3 +247,4 @@ $RECYCLE.BIN/ | |
|
||
build/** | ||
archive/** | ||
msgs/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "(gdb) Launch", | ||
"type": "cppdbg", | ||
"request": "launch", | ||
"program": "${workspaceFolder}/build/uros-rtidl", | ||
"args": [ | ||
"-baseType", | ||
"Twist", | ||
"-typeDir", | ||
"${workspaceFolder}/test/msg", | ||
"-outDir", | ||
"${workspaceFolder}/test/output", | ||
"-pyTemplate", | ||
"./test/pythonTypeTemplate.j2" | ||
|
||
], | ||
"stopAtEntry": true, | ||
"cwd": "${workspaceFolder}", | ||
"environment": [], | ||
"MIMode": "gdb", | ||
"externalConsole": false, | ||
"setupCommands": [ | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"files.associations": { | ||
"parser.h": "c", | ||
"datatypecatalog.h": "c", | ||
"string": "cpp" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM ubuntu:22.04 | ||
|
||
RUN apt -y update && \ | ||
apt -y upgrade && \ | ||
apt -y install \ | ||
build-essential \ | ||
antlr \ | ||
python3 pip \ | ||
bison flex \ | ||
emacs nano \ | ||
cmake git \ | ||
gdb gdbserver && \ | ||
pip3 install ampy rshell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
docker build -t mros-rtidl-img . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
#include "CustomTemplate.h" | ||
|
||
std::string DataTypeValue::render() { | ||
|
||
std::string name = "dataTypeMode"; | ||
std::shared_ptr<Jinja2CppLight::Value> mode = this->tpl->valueByName[name]; | ||
std::string val; | ||
if (mode) val = mode->render(); | ||
return val; | ||
}; | ||
|
||
bool DataTypeValue::isTrue() const { | ||
return true; //!values.empty(); | ||
}; | ||
|
||
DataTypeTemplate &DataTypeTemplate::setValue( std::string name, DataTypeValue value ) { | ||
|
||
valueByName[ name ] = std::make_shared<DataTypeValue>( std::move(value) ); | ||
std::shared_ptr<Jinja2CppLight::Value> value = valueByName["dataTypeMode"]; | ||
return *this; | ||
} ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
#ifndef __CUSTOM_TEMPLATE_H__ | ||
#define __CUSTOM_TEMPLATE_H__ | ||
|
||
#include "Jinja2CppLight.h" | ||
#include "DataTypeCatalog.h" | ||
|
||
class DataTypeTemplate; | ||
|
||
class DataTypeValue : public Jinja2CppLight::Value { | ||
public: | ||
DataTypeDefinition *data; | ||
DataTypeTemplate *tpl; | ||
|
||
DataTypeValue( DataTypeDefinition* _data ) { | ||
this->data = _data; | ||
} | ||
|
||
virtual std::string render(); | ||
bool isTrue() const; | ||
}; | ||
|
||
class DataTypeTemplate : public Jinja2CppLight::Template { | ||
|
||
DataTypeTemplate &setValue( std::string name, DataTypeValue value ); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#ifndef __DATATYPE_CATALOG_H__ | ||
#define __DATATYPE_CATALOG_H__ | ||
|
||
#include <iostream> | ||
#include <list> | ||
|
||
#include "DataTypeCatalog.h" | ||
|
||
DataTypeCatalog g_DataTypeCatalog; | ||
|
||
void DataTypeDefinition::addField(sIdent *left, sIdent *right) { | ||
DataField field; | ||
|
||
field.typeName = left->name; | ||
|
||
if (left->name_prefix != 0x00) { | ||
field.typePrefix = left->name_prefix; | ||
} | ||
|
||
field.valueName = right->name; | ||
field.valueType = left->type; | ||
this->fields.push_back(field); | ||
} | ||
|
||
void DataTypeDefinition::print() { | ||
std::cout << "\r\nType Name: [" << typeName << "] Type Prefix: [" << typePrefix << "]\r\n Fields:\r\n"; | ||
for (DataField field : fields) { | ||
std::cout << " Name: [" << field.typeName << "] Prefix: [" << field.typePrefix << "] Value Name: [" << field.valueName << "] Value Type: [" << field.valueType << "]\r\n"; | ||
} | ||
} | ||
|
||
void DataTypeCatalog::addDataTypeDefinition(DataTypeDefinition* type){ | ||
m_TypeMap[type->getTypeName()] = type; | ||
m_currentDataType = type; | ||
} | ||
|
||
|
||
DataTypeDefinition* DataTypeCatalog::getDataType(std::string name) { | ||
if (m_TypeMap.count(name)) return m_TypeMap[name]; | ||
else return NULL; | ||
} | ||
|
||
void DataTypeCatalog::print() { | ||
|
||
std::cout << "\r\n\r\nData Type Catalog\r\n"; | ||
for (auto entry : m_TypeMap) { | ||
DataTypeDefinition* def = entry.second; | ||
def->print(); | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#ifndef __DATACATALOG_H__ | ||
#define __DATACATALOG_H__ | ||
|
||
#include "types.h" | ||
|
||
#include "lexer.h" | ||
#include "parser.h" | ||
#include <ctype.h> | ||
#include <unistd.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#include <string> | ||
#include <map> | ||
#include <list> | ||
|
||
struct DataField { | ||
std::string typeName; | ||
std::string typePrefix; | ||
std::string valueName; | ||
int valueType; | ||
}; | ||
|
||
typedef struct DataField DataField; | ||
|
||
class DataTypeDefinition { | ||
|
||
public: | ||
DataTypeDefinition(std::string typeName, std::string typePrefix) { | ||
this->typeName = typeName; | ||
this->typePrefix = typePrefix; | ||
}; | ||
|
||
void addField(sIdent *left, sIdent *right); | ||
const std::string getTypeName() { return typeName; } | ||
const std::string getTypePrefix() { return typePrefix; } | ||
std::list<DataField> getFields() { return fields; } | ||
void print(); | ||
|
||
private: | ||
std::string typeName; | ||
std::string typePrefix; | ||
std::list<DataField> fields; | ||
}; | ||
|
||
|
||
class DataTypeCatalog { | ||
|
||
public: | ||
void addDataTypeDefinition(DataTypeDefinition* type); | ||
DataTypeDefinition* getActiveDataType() { return m_currentDataType;} | ||
DataTypeDefinition* getDataType(std::string name); | ||
std::map<std::string, DataTypeDefinition*> getDataTypeCatalog() {return m_TypeMap;} | ||
void print(); | ||
|
||
private: | ||
std::map<std::string, DataTypeDefinition*> m_TypeMap; | ||
DataTypeDefinition *m_currentDataType = NULL; | ||
|
||
|
||
}; | ||
|
||
extern DataTypeCatalog g_DataTypeCatalog; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include "DataTypeCatalog.h" | ||
#include "DataTypeFunc.h" | ||
|
||
|
||
extern "C" void addField(sIdent *left, sIdent *right) { | ||
DataTypeDefinition* type = g_DataTypeCatalog.getActiveDataType(); | ||
if (type != NULL) type->addField(left, right); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef __DATA_TYPE_FUNC_H__ | ||
#define __DATA_TYPE_FUNC_H__ | ||
#include "types.h" | ||
|
||
|
||
#ifdef __cplusplus | ||
extern "C" | ||
{ | ||
#endif | ||
|
||
void addField(sIdent* left, sIdent* right); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
Oops, something went wrong.