[anjuta/cxxparser] symbol-db: added test-queries program and renamed some queries.
- From: Massimo Cora' <mcora src gnome org>
- To: svn-commits-list gnome org
- Subject: [anjuta/cxxparser] symbol-db: added test-queries program and renamed some queries.
- Date: Wed, 29 Jul 2009 00:18:03 +0000 (UTC)
commit d4db9655eeb0c3d8d867ec53f40ce1d87b115f82
Author: Massimo Corà <mcora src gnome org>
Date: Wed Jul 29 02:11:02 2009 +0200
symbol-db: added test-queries program and renamed some queries.
We need a test program to test some complex "very" scoped symbols.
Cxxparser is near to be complete and more tests more features we can include.
configure.in | 1 +
plugins/symbol-db/Makefile.am | 2 +-
plugins/symbol-db/symbol-db-engine-queries.c | 2 +-
plugins/symbol-db/symbol-db-engine-queries.h | 13 ++-
plugins/symbol-db/test-queries/Makefile.am | 55 +++++++++
plugins/symbol-db/test-queries/main.c | 128 ++++++++++++++++++++
plugins/symbol-db/test-queries/run_test.sh | 1 +
.../test-queries/sample-db/complex-scopes.cpp | 51 ++++++++
8 files changed, 249 insertions(+), 4 deletions(-)
---
diff --git a/configure.in b/configure.in
index 350af92..f420b28 100644
--- a/configure.in
+++ b/configure.in
@@ -756,6 +756,7 @@ plugins/symbol-db/benchmark/Makefile
plugins/symbol-db/images/Makefile
plugins/symbol-db/Makefile
plugins/symbol-db/anjuta-tags/Makefile
+plugins/symbol-db/test-queries/Makefile
plugins/symbol-db/cxxparser/Makefile
plugins/cvs-plugin/Makefile
plugins/project-wizard/Makefile
diff --git a/plugins/symbol-db/Makefile.am b/plugins/symbol-db/Makefile.am
index 5e938a1..1b2a419 100644
--- a/plugins/symbol-db/Makefile.am
+++ b/plugins/symbol-db/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = images benchmark anjuta-tags cxxparser
+SUBDIRS = images benchmark anjuta-tags cxxparser test-queries
symbol_db_datadir = $(anjuta_data_dir)
symbol_db_data_DATA = tables.sql tables-from-1-to-228.sql
diff --git a/plugins/symbol-db/symbol-db-engine-queries.c b/plugins/symbol-db/symbol-db-engine-queries.c
index e848697..d7ea836 100644
--- a/plugins/symbol-db/symbol-db-engine-queries.c
+++ b/plugins/symbol-db/symbol-db-engine-queries.c
@@ -1221,7 +1221,7 @@ select b.* from symbol a, symbol b where a.symbol_id = 348 and
* "scope2_name", NULL
*/
SymbolDBEngineIterator *
-symbol_db_engine_get_scope_members (SymbolDBEngine *dbe,
+symbol_db_engine_get_scope_members_by_path (SymbolDBEngine *dbe,
const GPtrArray* scope_path,
SymExtraInfo sym_info)
{
diff --git a/plugins/symbol-db/symbol-db-engine-queries.h b/plugins/symbol-db/symbol-db-engine-queries.h
index 93cfa99..0f31cb6 100644
--- a/plugins/symbol-db/symbol-db-engine-queries.h
+++ b/plugins/symbol-db/symbol-db-engine-queries.h
@@ -37,6 +37,15 @@
* ITERATABLE QUERIES
**********************/
+/* Usually you'll see many functions that have a gint symbol_id parameter.
+ * You may wonder why we don't pass a SymbolDBEngineIteratorNode. Well,
+ * because of the iterator architecture and its underlying data (the
+ * GdaDataModel): you can easily save an integer id, but not an IteratorNode, which
+ * would change after a symbol_db_engine_iterator_move_next ().
+ * Think of that integer id as an handle, and use it as that.
+ */
+
+
/**
* Use this function to find symbols names by patterns like '%foo_func%'
* that will return a family of my_foo_func_1, your_foo_func_2 etc
@@ -127,7 +136,7 @@ symbol_db_engine_get_file_symbols (SymbolDBEngine *dbe,
* Use this function to get global symbols only. I.e. private or file-only scoped symbols
* will NOT be returned.
* @param filter_kinds Can be NULL. In that case we'll return all the kinds of symbols found
- * at root level [global level]. A maximum of 5 filter_kinds are admitted.
+ * at root level [global level]. A maximum of 255 filter_kinds are admitted.
* @param include_kinds Should we include in the result the filter_kinds or not?
* @param group_them If TRUE then will be issued a 'group by symbol.name' option.
* If FALSE you can have as result more symbols with the same name but different
@@ -199,7 +208,7 @@ symbol_db_engine_get_scope_chain_by_file_line (SymbolDBEngine *dbe,
* "scope2_name", NULL
*/
SymbolDBEngineIterator *
-symbol_db_engine_get_scope_members (SymbolDBEngine *dbe,
+symbol_db_engine_get_scope_members_by_path (SymbolDBEngine *dbe,
const GPtrArray* scope_path,
SymExtraInfo sym_info);
diff --git a/plugins/symbol-db/test-queries/Makefile.am b/plugins/symbol-db/test-queries/Makefile.am
new file mode 100644
index 0000000..42b1f93
--- /dev/null
+++ b/plugins/symbol-db/test-queries/Makefile.am
@@ -0,0 +1,55 @@
+noinst_PROGRAMS = \
+ test-queries
+
+
+AM_CPPFLAGS = \
+ -DPACKAGE_LOCALE_DIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+ -DANJUTA_DATA_DIR=\"$(anjuta_data_dir)\" \
+ -DANJUTA_PLUGIN_DIR=\"$(anjuta_plugin_dir)\" \
+ -DANJUTA_IMAGE_DIR=\"$(anjuta_image_dir)\" \
+ -DANJUTA_GLADE_DIR=\"$(anjuta_glade_dir)\" \
+ -DANJUTA_UI_DIR=\"$(anjuta_ui_dir)\" \
+ -DPACKAGE_SRC_DIR=\"$(srcdir)\" \
+ $(LIBANJUTA_CFLAGS) \
+ $(PLUGIN_SYMBOL_DB_CFLAGS) \
+ $(GDL_CFLAGS) \
+ -DDEBUG
+
+test_queries_SOURCES = \
+ main.c \
+ ../readtags.c \
+ ../readtags.h \
+ ../symbol-db-engine-core.c \
+ ../symbol-db-engine-core.h \
+ ../symbol-db-engine-queries.c \
+ ../symbol-db-engine-queries.h \
+ ../symbol-db-engine-iterator.c \
+ ../symbol-db-engine-iterator.h \
+ ../symbol-db-engine-utils.c \
+ ../symbol-db-engine-utils.h \
+ ../symbol-db-engine-iterator-node.c \
+ ../symbol-db-engine-iterator-node.h \
+ ../symbol-db-view.h \
+ ../symbol-db-view.c \
+ ../libgda-extra/gda-data-model-concat.c \
+ ../libgda-extra/gda-data-model-concat.h \
+ ../symbol-db-engine.h
+
+
+test_queries_LDFLAGS = \
+ $(LIBANJUTA_LIBS) \
+ $(PLUGIN_SYMBOL_DB_LIBS)
+
+
+## File created by the gnome-build tools
+
+
+
+
+
+
+
+
+
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/symbol-db/test-queries/main.c b/plugins/symbol-db/test-queries/main.c
new file mode 100644
index 0000000..5b5fc3e
--- /dev/null
+++ b/plugins/symbol-db/test-queries/main.c
@@ -0,0 +1,128 @@
+#include "../symbol-db-engine.h"
+#include <libanjuta/anjuta-debug.h>
+#include <gtk/gtk.h>
+
+static void on_single_file_scan_end (SymbolDBEngine* engine, GPtrArray* files)
+{
+ static int i = 0;
+ g_message ("Finished [%d]: %s", i, (gchar*)g_ptr_array_index (files, i));
+ i++;
+}
+
+static void
+get_scope_members_by_path (SymbolDBEngine* dbe)
+{
+ GPtrArray *array;
+ SymbolDBEngineIterator *iter;
+
+ DEBUG_PRINT ("");
+
+ array = g_ptr_array_new ();
+ g_ptr_array_add (array, "namespace");
+// g_ptr_array_add (array, "NSOne");
+ g_ptr_array_add (array, "NSFour");
+ g_ptr_array_add (array, NULL);
+
+ iter = symbol_db_engine_get_scope_members_by_path (dbe, array, SYMINFO_SIMPLE);
+
+ if (iter == NULL)
+ {
+ g_warning ("Iterator null");
+ return;
+ }
+
+ do {
+ SymbolDBEngineIteratorNode *node;
+
+ node = SYMBOL_DB_ENGINE_ITERATOR_NODE (iter);
+
+ DEBUG_PRINT ("node name %s",
+ symbol_db_engine_iterator_node_get_symbol_name (node));
+
+ } while (symbol_db_engine_iterator_move_next (iter) == TRUE);
+
+
+ g_ptr_array_free (array, TRUE);
+}
+
+
+static void
+do_test_queries (SymbolDBEngine* dbe)
+{
+
+ get_scope_members_by_path (dbe);
+
+}
+
+static void
+on_scan_end (SymbolDBEngine* dbe, gpointer user_data)
+{
+ DEBUG_PRINT ("on_scan_end ()");
+
+ do_test_queries (dbe);
+
+ symbol_db_engine_close_db (dbe);
+ g_object_unref (dbe);
+ exit(0);
+}
+
+int main (int argc, char** argv)
+{
+ SymbolDBEngine* engine;
+ GHashTable *mimes;
+ GPtrArray* files;
+ GPtrArray* languages = g_ptr_array_new();
+ gchar* root_dir;
+ GFile *g_dir;
+ int i;
+
+ gtk_init(&argc, &argv);
+ g_thread_init (NULL);
+ gda_init ();
+
+ g_dir = g_file_new_for_path ("sample-db");
+ if (g_dir == NULL)
+ {
+ g_warning ("sample-db doesn't exist");
+ return -1;
+ }
+
+ root_dir = g_file_get_path (g_dir);
+
+ engine = symbol_db_engine_new_full ("anjuta-tags", "sample-db");
+
+ if (!symbol_db_engine_open_db (engine, root_dir, root_dir))
+ {
+ g_message ("Could not open database: %s", root_dir);
+ return -1;
+ }
+
+ symbol_db_engine_add_new_project (engine, NULL, root_dir);
+
+ mimes = g_hash_table_new (g_str_hash, g_str_equal);
+ g_hash_table_insert (mimes, "text/x-csrc", "text/x-csrc");
+ g_hash_table_insert (mimes, "text/x-chdr", "text/x-chdr");
+ g_hash_table_insert (mimes, "text/x-c++src", "text/x-c++src");
+ g_hash_table_insert (mimes, "text/x-c+++hdr", "text/x-c++hdr");
+
+ files = symbol_db_util_get_source_files_by_mime (root_dir, mimes);
+ g_hash_table_destroy (mimes);
+
+ for (i = 0; i < files->len; i++)
+ {
+ g_message ("(%d) %s", i, (gchar*)g_ptr_array_index (files, i));
+ g_ptr_array_add (languages, "C");
+ }
+
+ g_signal_connect (engine, "scan-end", G_CALLBACK (on_scan_end), NULL);
+ g_signal_connect (G_OBJECT (engine), "single-file-scan-end",
+ G_CALLBACK (on_single_file_scan_end), files);
+
+ symbol_db_engine_add_new_files_full (engine, root_dir, files, languages, TRUE);
+
+ g_free (root_dir);
+ g_object_unref (g_dir);
+
+ gtk_main();
+ return 0;
+}
diff --git a/plugins/symbol-db/test-queries/run_test.sh b/plugins/symbol-db/test-queries/run_test.sh
new file mode 100755
index 0000000..284d4ee
--- /dev/null
+++ b/plugins/symbol-db/test-queries/run_test.sh
@@ -0,0 +1 @@
+rm sample-db/*.db; make && ./test-queries
diff --git a/plugins/symbol-db/test-queries/sample-db/complex-scopes.cpp b/plugins/symbol-db/test-queries/sample-db/complex-scopes.cpp
new file mode 100644
index 0000000..6a51d58
--- /dev/null
+++ b/plugins/symbol-db/test-queries/sample-db/complex-scopes.cpp
@@ -0,0 +1,51 @@
+
+namespace NSOne {
+
+ /* this class is a copy of the one in namespace NSFour */
+ class OneA {
+ OneA () {};
+
+ private:
+ int foo (void ) {};
+
+ }
+
+ namespace NSTwo {
+ struct TwoA {
+ char a;
+ int b;
+ void *c;
+ };
+
+ typedef struct _TwoB {
+ char *hey;
+ int dude;
+
+ } TwoB;
+
+ void TwoC (int a, char b, void *c);
+ }
+
+
+ namespace NSTree {
+
+
+ }
+
+}
+
+
+
+/* the bastard one :) */
+namespace NSFour {
+
+ /* simulate some problems with naming... */
+ /* the exact class as in NSOne */
+ class OneA {
+ OneA () {};
+
+ private:
+ int foo (void ) {};
+
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]