[DEV] update function interface

This commit is contained in:
Edouard DUPIN 2014-12-31 21:27:09 +01:00
parent a5e126fde2
commit c2955dee56
4 changed files with 96 additions and 4 deletions

View File

@ -16,22 +16,106 @@ static std::string getValue(const std::string& _file, const std::shared_ptr<eci:
return std::string(_file, _it->getStartPos(), _it->getStopPos()-_it->getStartPos());
}
eci::Variable getVariableWithType(const std::string& _value) {
eci::Variable ret;
if (_value == "void") {
} else if ( _value == "int"
|| _value == "int32_t"
|| _value == "signed int") {
} else if ( _value == "unsigned int"
|| _value == "uint32_t") {
} else if ( _value == "short"
|| _value == "int16_t"
|| _value == "signed short") {
} else if ( _value == "unsigned short"
|| _value == "uint16_t") {
} else if ( _value == "char"
|| _value == "int8_t"
|| _value == "signed char") {
} else if ( _value == "unsigned char"
|| _value == "uint8_t") {
} else if ( _value == "long"
|| _value == "int64_t"
|| _value == "signed long") {
} else if ( _value == "unsigned long"
|| _value == "uint64_t") {
} else if (_value == "bool") {
} else if (_value == "size_t") {
} else {
ECI_ERROR("get variable with type : " << _value << "' << NOT parsed !!!!" );
}
return ret;
}
eci::File::File(const std::string& _filename) {
m_fileName = _filename;
m_fileData = etk::FSNodeReadAllData(_filename);
eci::ParserCpp tmpParser;
tmpParser.parse(m_fileData);
// all we need all the time:
std::vector<eci::Variable> returnList;
std::vector<eci::Variable> argumentList;
std::string name;
std::string value;
std::shared_ptr<eci::Class> lastClass;
std::shared_ptr<eci::Function> lastFunction;
std::shared_ptr<eci::Variable> lastVariable;
enum eci::visibility lastVisibility = eci::visibilityPublic;
for (auto &it : tmpParser.m_result.m_list) {
value = getValue(m_fileData, it);
switch (it->getTockenId()) {
case tokenCppVisibility:
ECI_INFO("get visibility : " << getValue(m_fileData, it) << "'" );
ECI_INFO("get visibility : " << value << "'" );
if (value == "private") {
lastVisibility = eci::visibilityPrivate;
} else if (value == "public") {
lastVisibility = eci::visibilityPublic;
} else if (value == "protected") {
lastVisibility = eci::visibilityProtected;
//} else if (value == "inline") {
//} else if (value == "const") {
//} else if (value == "virtual") {
//} else if (value == "friend") {
//} else if (value == "extern") {
//} else if (value == "register") {
//} else if (value == "static") {
//} else if (value == "volatile") {
} else {
ECI_ERROR("get visibility : " << value << "' << NOT parsed !!!!" );
}
break;
case tokenCppType:
ECI_INFO("get type : " << getValue(m_fileData, it) << "'" );
ECI_INFO("get type : " << value << "'" );
if (name == "") {
returnList.push_back(getVariableWithType(value));
} else {
ECI_ERROR(" get type : " << value << "' after name !!!" );
}
break;
case tokenCppString:
ECI_INFO("get string : " << getValue(m_fileData, it) << "'" );
ECI_INFO("get string : " << value << "'" );
name = value;
break;
}
}

View File

@ -23,6 +23,9 @@ namespace eci {
protected:
std::string m_fileName; //!< Name of the file.
std::string m_fileData; //!< Data of the file.
std::vector<std::shared_ptr<eci::Function>> m_listFunction; // all function in the file
std::vector<std::shared_ptr<eci::Class>> m_listClass; // all class in the file
std::vector<std::shared_ptr<eci::Variable>> m_listVariable; // all variable in the file
};
}

View File

@ -29,6 +29,11 @@ namespace eci {
std::vector<eci::Variable> m_arguments; //!< return value.
std::vector<std::shared_ptr<eci::Value>> call(const std::vector<std::shared_ptr<eci::Value>>& _input);
// 3 step:
// - first get Tockens (returns , names, const, parameters, codes
// - interpreted all of this ... no link on variables
// - all is linked
};
}

View File

@ -35,7 +35,7 @@ eci::ParserCpp::ParserCpp() {
m_lexer.append(tokenCppHookOut, "\\]");
m_lexer.append(tokenCppBranch, "\\b(return|goto|if|else|case|default|break|continue|while|do|for)\\b");
m_lexer.append(tokenCppSystem, "\\b(new|delete|try|catch)\\b");
m_lexer.append(tokenCppType, "\\b(bool|char(16_t|32_t)?|double|float|u?int(8|16|32|64|128)?(_t)?|long|short|signed|size_t|unsigned|void|(I|U)(8|16|32|64|128))\\b");
m_lexer.append(tokenCppType, "\\b(bool|char(16_t|32_t)?|double|float|u?int(8|16|32|64|128)?(_t)?|long|short|signed|size_t|unsigned|void)\\b");
m_lexer.append(tokenCppVisibility, "\\b(inline|const|virtual|private|public|protected|friend|const|extern|register|static|volatile)\\b");
m_lexer.append(tokenCppContener, "\\b(class|namespace|struct|union|enum)\\b");
m_lexer.append(tokenCppTypeDef, "\\btypedef\\b");