add member function supoort

This commit is contained in:
fuwangqin 2016-12-30 18:12:31 +08:00
parent bfa1c6eb07
commit a5feef884b
2 changed files with 9 additions and 9 deletions

View File

@ -110,7 +110,7 @@ private:
std::string next_token(std::string delimiters); std::string next_token(std::string delimiters);
std::string get_namespace(); std::string get_namespace();
function_code_t gen_unpack_code(const object_t &obj); function_code_t gen_unpack_code(const object_t &obj);
std::string get_static_string(const std::string &str, int index); std::string get_static_string(const std::string &str, int &index);
std::string get_include_files(); std::string get_include_files();
std::string get_filename(const char *filepath); std::string get_filename(const char *filepath);

View File

@ -633,7 +633,7 @@ bool gsoner::check_comment()
return result; return result;
} }
std::string gsoner::get_static_string(const std::string &str, int index) std::string gsoner::get_static_string(const std::string &str, int &index)
{ {
if (str[index] != '"') if (str[index] != '"')
return ""; return "";
@ -668,6 +668,10 @@ std::string gsoner::get_static_string(const std::string &str, int index)
index++; index++;
continue; continue;
} }
else
{
break;
}
} }
lines.push_back(str[index]); lines.push_back(str[index]);
@ -713,7 +717,6 @@ std::pair<bool, std::string> gsoner::get_function_declare()
if (codes_[j] == '"') if (codes_[j] == '"')
{ {
std::string str = get_static_string(codes_,j); std::string str = get_static_string(codes_,j);
j += str.size() + 2;
} }
if (codes_[j] == '=') if (codes_[j] == '=')
break; break;
@ -886,7 +889,6 @@ bool gsoner::check_function()
lines.push_back('"'); lines.push_back('"');
lines += str; lines += str;
lines.push_back('"'); lines.push_back('"');
pos_ += str.size();
continue; continue;
} }
else if (codes_[pos_] == '}') else if (codes_[pos_] == '}')
@ -902,7 +904,9 @@ bool gsoner::check_function()
lines.push_back(codes_[pos_]); lines.push_back(codes_[pos_]);
pos_++; pos_++;
} }
std::cout << "find function:" << std::endl;
std::cout << res.second << std::endl;
std::cout << lines << std::endl;
return true; return true;
} }
@ -931,7 +935,6 @@ bool gsoner::check_member()
lines.push_back('"'); lines.push_back('"');
lines += str; lines += str;
lines.push_back('"'); lines.push_back('"');
pos_ += str.size() + 2;
} }
if(codes_[pos_] == ';') if(codes_[pos_] == ';')
@ -1318,9 +1321,6 @@ void gsoner::parse_code()
case 's': case 's':
if(check_struct_begin()) if(check_struct_begin())
continue; continue;
case 'v':
if(check_function())
continue;
default: default:
if(check_function()) if(check_function())
continue; continue;