[anjuta/cxxparser] cxx-parser: test-complex-struct solved.
- From: Massimo Cora' <mcora src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [anjuta/cxxparser] cxx-parser: test-complex-struct solved.
- Date: Fri, 31 Jul 2009 23:27:38 +0000 (UTC)
commit 4e524e9ad69365abd66d62847310b0200595886d
Author: Massimo Corà <mcora src gnome org>
Date: Sat Aug 1 01:24:19 2009 +0200
cxx-parser: test-complex-struct solved.
this commit just to set a milestone in the process.
Now there's a need of a rewrite of process_expression (), maybe in a modular way.
Typedef kind detection is not done in the last printout so the test-complex-struct
isn't completed but the result is there the same.
plugins/symbol-db/cxxparser/engine-parser.cpp | 42 +++++++++++++++----
plugins/symbol-db/cxxparser/main.c | 4 +-
.../cxxparser/sample-db/test-cast-simple-struct.c | 8 ++--
.../cxxparser/sample-db/test-simple-struct.c | 4 +-
4 files changed, 41 insertions(+), 17 deletions(-)
---
diff --git a/plugins/symbol-db/cxxparser/engine-parser.cpp b/plugins/symbol-db/cxxparser/engine-parser.cpp
index eb8f612..54ee9d2 100644
--- a/plugins/symbol-db/cxxparser/engine-parser.cpp
+++ b/plugins/symbol-db/cxxparser/engine-parser.cpp
@@ -226,20 +226,40 @@ EngineParser::processExpression(const string& stmt,
symbol_db_engine_find_symbol_by_name_pattern_filtered (
_dbe, prev_token_type_name.c_str (),
SYMTYPE_SCOPE_CONTAINER, TRUE,
- SYMSEARCH_FILESCOPE_IGNORE, NULL, -1 ,
- -1, SYMINFO_SIMPLE);
- do {
+ SYMSEARCH_FILESCOPE_IGNORE, NULL, 1,
+ -1, (SymExtraInfo)(SYMINFO_SIMPLE | SYMINFO_KIND));
+ if (curr_searchable_scope != NULL)
+ {
SymbolDBEngineIteratorNode *node;
node = SYMBOL_DB_ENGINE_ITERATOR_NODE (curr_searchable_scope);
cout << "Current Searchable Scope " <<
- symbol_db_engine_iterator_node_get_symbol_name (node) << endl;
-
- } while (symbol_db_engine_iterator_move_next (curr_searchable_scope) == TRUE);
+ symbol_db_engine_iterator_node_get_symbol_name (node) <<
+ " and id "<< symbol_db_engine_iterator_node_get_symbol_id (node) <<
+ endl;
- /* reset it to first position */
- symbol_db_engine_iterator_first (curr_searchable_scope);
+ /* is it a typedef? In that case find the parent struct */
+ if (g_strcmp0 (symbol_db_engine_iterator_node_get_symbol_extra_string (node,
+ SYMINFO_KIND), "typedef") == 0)
+ {
+ cout << "it's a struct!" << endl;
+ int struct_id = symbol_db_engine_get_parent_scope_id_by_symbol_id (_dbe,
+ symbol_db_engine_iterator_node_get_symbol_id (node),
+ NULL);
+
+ g_object_unref (curr_searchable_scope);
+ curr_searchable_scope = symbol_db_engine_get_symbol_info_by_id (_dbe,
+ struct_id,
+ (SymExtraInfo)(SYMINFO_SIMPLE | SYMINFO_KIND));
+
+ node = SYMBOL_DB_ENGINE_ITERATOR_NODE (curr_searchable_scope);
+ cout << "(NEW) Current Searchable Scope " <<
+ symbol_db_engine_iterator_node_get_symbol_name (node) <<
+ " and id "<< symbol_db_engine_iterator_node_get_symbol_id (node) <<
+ endl;
+ }
+ }
}
cout << "--------\nCurrent token \"" << current_token << "\" with op " << op << endl;
@@ -289,6 +309,10 @@ EngineParser::processExpression(const string& stmt,
else
{
cout << "Good element " << result.m_name << endl;
+ out_type_name = result.m_name;
+ out_type_scope = symbol_db_engine_iterator_node_get_symbol_name (node);
+ evaluation_succeed = true;
+ continue;
}
// FIXME iter?
diff --git a/plugins/symbol-db/cxxparser/main.c b/plugins/symbol-db/cxxparser/main.c
index c5f2f23..8cab016 100644
--- a/plugins/symbol-db/cxxparser/main.c
+++ b/plugins/symbol-db/cxxparser/main.c
@@ -135,9 +135,9 @@ int main (int argc, char *argv[])
g_test_init (&argc, &argv, NULL);
-// g_test_add_func ("/simple_c/test-simple-struct", test_simple_struct);
+ g_test_add_func ("/simple_c/test-simple-struct", test_simple_struct);
// g_test_add_func ("/simple_c/test-cast-simple-struct", test_cast_simple_struct);
- g_test_add_func ("/complex_c/test-complex-struct", test_complex_struct);
+// g_test_add_func ("/complex_c/test-complex-struct", test_complex_struct);
g_test_run ();
g_message ("test run finished");
diff --git a/plugins/symbol-db/cxxparser/sample-db/test-cast-simple-struct.c b/plugins/symbol-db/cxxparser/sample-db/test-cast-simple-struct.c
index 7f87eac..9f71df9 100644
--- a/plugins/symbol-db/cxxparser/sample-db/test-cast-simple-struct.c
+++ b/plugins/symbol-db/cxxparser/sample-db/test-cast-simple-struct.c
@@ -1,15 +1,15 @@
-struct asd {
+struct _asd {
char a;
int b;
};
-struct foo {
+struct _foo {
char c;
void *d;
};
void main () {
- asd var;
- ((foo)var).
+ _asd var;
+ ((_foo)var).
diff --git a/plugins/symbol-db/cxxparser/sample-db/test-simple-struct.c b/plugins/symbol-db/cxxparser/sample-db/test-simple-struct.c
index 131a67b..7ed4e40 100644
--- a/plugins/symbol-db/cxxparser/sample-db/test-simple-struct.c
+++ b/plugins/symbol-db/cxxparser/sample-db/test-simple-struct.c
@@ -1,11 +1,11 @@
-struct asd {
+struct _asd {
char a;
int b;
};
void main () {
- asd var;
+ _asd var;
var.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]