[libgda/libgda-vala: 10/11] GObject Introspection improvements: make introspectable more GdaSqlBuilder API and add new (gda_sql_
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda/libgda-vala: 10/11] GObject Introspection improvements: make introspectable more GdaSqlBuilder API and add new (gda_sql_
- Date: Thu, 13 Oct 2011 14:45:12 +0000 (UTC)
commit 34e459b8274bba796f34e36742a64b3aa50f362c
Author: Daniel Espinosa <despinosa src gnome org>
Date: Thu Oct 13 09:40:58 2011 -0500
GObject Introspection improvements: make introspectable more GdaSqlBuilder API and add new (gda_sql_builder_compound_add_sub_select_from_builder and gda_sql_builder_compound_add_sub_select)
libgda/Gda-5.0.metadata | 1 -
libgda/Makefile.am | 4 +-
libgda/gda-sql-builder.c | 80 +++++++++++++++++++--
libgda/gda-sql-builder.h | 5 +-
libgda/handlers/gda-handler-time.c | 12 ++--
libgda/sql-parser/gda-statement-struct-compound.h | 2 +-
libgda/sql-parser/gda-statement-struct-decl.h | 47 ++++++++++++-
libgda/sql-parser/gda-statement-struct-parts.h | 69 ++++++++++++++----
8 files changed, 187 insertions(+), 33 deletions(-)
---
diff --git a/libgda/Gda-5.0.metadata b/libgda/Gda-5.0.metadata
index 6502e38..6d63728 100644
--- a/libgda/Gda-5.0.metadata
+++ b/libgda/Gda-5.0.metadata
@@ -1,6 +1,5 @@
// Vala Bindings for GDA
Gda cheader_filename="libgda/libgda.h"
-ValueList type="GLib.List<GLib.Value>"
ServerProviderMeta skip
ServerProviderXa skip
// libxml2: replace xml.NodePtr by xml.Node* used by Vala bindings
diff --git a/libgda/Makefile.am b/libgda/Makefile.am
index c84741c..6433382 100644
--- a/libgda/Makefile.am
+++ b/libgda/Makefile.am
@@ -315,7 +315,9 @@ threadwrapper = \
sqlparser = \
sql-parser/gda-sql-parser.h \
sql-parser/gda-sql-parser.c \
- sql-parser/gda-statement-struct-decl.h
+ sql-parser/gda-statement-struct-decl.h \
+ sql-parser/gda-statement-struct-parts.h \
+ sql-parser/gda-statement-struct-compound.h
handlers = \
handlers/gda-handler-bin.h \
diff --git a/libgda/gda-sql-builder.c b/libgda/gda-sql-builder.c
index 526f385..2464bb4 100644
--- a/libgda/gda-sql-builder.c
+++ b/libgda/gda-sql-builder.c
@@ -911,14 +911,14 @@ gda_sql_builder_add_expr (GdaSqlBuilder *builder, GdaDataHandler *dh, GType type
/**
* gda_sql_builder_add_id:
* @builder: a #GdaSqlBuilder object
- * @string: a string
+ * @str: a string
*
* Defines an expression representing an identifier in @builder,
* which may be reused to build other parts of a statement,
* for instance as a parameter to gda_sql_builder_add_cond() or
* gda_sql_builder_add_field_value_id().
*
- * The new expression will contain the @string literal.
+ * The new expression will contain the @str literal.
* For example:
* <programlisting>
* gda_sql_builder_add_id (b, "name")
@@ -940,16 +940,16 @@ gda_sql_builder_add_expr (GdaSqlBuilder *builder, GdaDataHandler *dh, GType type
* Since: 4.2
*/
GdaSqlBuilderId
-gda_sql_builder_add_id (GdaSqlBuilder *builder, const gchar *string)
+gda_sql_builder_add_id (GdaSqlBuilder *builder, const gchar *str)
{
g_return_val_if_fail (GDA_IS_SQL_BUILDER (builder), 0);
g_return_val_if_fail (builder->priv->main_stmt, 0);
GdaSqlExpr *expr;
expr = gda_sql_expr_new (NULL);
- if (string) {
+ if (str) {
expr->value = gda_value_new (G_TYPE_STRING);
- g_value_set_string (expr->value, string);
+ g_value_set_string (expr->value, str);
expr->value_is_ident = TRUE;
}
@@ -1039,7 +1039,7 @@ gda_sql_builder_add_param (GdaSqlBuilder *builder, const gchar *param_name, GTyp
}
/**
- * gda_sql_builder_add_cond: (skip)
+ * gda_sql_builder_add_cond:
* @builder: a #GdaSqlBuilder object
* @op: type of condition
* @op1: the ID of the 1st argument (not 0)
@@ -1764,7 +1764,7 @@ gda_sql_builder_add_sub_select (GdaSqlBuilder *builder, GdaSqlStatement *sqlst)
}
/**
- * gda_sql_builder_compound_set_type: (skip)
+ * gda_sql_builder_compound_set_type:
* @builder: a #GdaSqlBuilder object
* @compound_type: a type of compound
*
@@ -1818,6 +1818,42 @@ gda_sql_builder_compound_add_sub_select (GdaSqlBuilder *builder, GdaSqlStatement
cstmt->stmt_list = g_slist_append (cstmt->stmt_list, sub);
}
+
+/**
+ * gda_sql_builder_compound_add_sub_select_from_builder:
+ * @builder: a #GdaSqlBuilder object
+ * @subselect: a #GdaSqlBuilder, which has to be a SELECT or compound SELECT. This will be copied.
+ *
+ * Add a sub select to a COMPOUND statement
+ *
+ * Since: 4.2
+ */
+void
+gda_sql_builder_compound_add_sub_select_from_builder (GdaSqlBuilder *builder, GdaSqlBuilder *subselect)
+{
+ GdaSqlStatementCompound *cstmt;
+ GdaSqlStatement *sqlst;
+ GdaSqlStatement *sub;
+
+ g_return_if_fail (GDA_IS_SQL_BUILDER (builder));
+ g_return_if_fail (builder->priv->main_stmt);
+ g_return_if_fail (GDA_IS_SQL_BUILDER (subselect));
+ g_return_if_fail (subselect->priv->main_stmt);
+ if (builder->priv->main_stmt->stmt_type != GDA_SQL_STATEMENT_COMPOUND) {
+ g_warning (_("Wrong statement type"));
+ return;
+ }
+ sqlst = gda_sql_builder_get_sql_statement(subselect);
+ g_return_if_fail (sqlst);
+ g_return_if_fail ((sqlst->stmt_type == GDA_SQL_STATEMENT_SELECT) ||
+ (sqlst->stmt_type == GDA_SQL_STATEMENT_COMPOUND));
+
+ cstmt = (GdaSqlStatementCompound*) builder->priv->main_stmt->contents;
+ sub = gda_sql_statement_copy (sqlst);
+
+ cstmt->stmt_list = g_slist_append (cstmt->stmt_list, sub);
+}
+
/**
* gda_sql_builder_add_case: (skip)
* @builder: a #GdaSqlBuilder object
@@ -1993,3 +2029,33 @@ gda_sql_builder_import_expression (GdaSqlBuilder *builder, GdaSqlExpr *expr)
g_return_val_if_fail (GDA_SQL_ANY_PART (expr)->type == GDA_SQL_ANY_EXPR, 0);
return add_part (builder, (GdaSqlAnyPart *) gda_sql_expr_copy (expr));
}
+
+
+/**
+ * gda_sql_builder_import_expression_from_builder:
+ * @builder: a #GdaSqlBuilder object
+ * @query: a #GdaSqlBuilder object to get expression from
+ * @expr_id: a #GdaSqlBuilderId of the expression in @query
+ *
+ * Imports the an expression located in @query into @builder.
+ *
+ * Returns: the ID of the new expression, or %0 if there was an error
+ *
+ * Since: 4.2
+ */
+GdaSqlBuilderId
+gda_sql_builder_import_expression_from_builder (GdaSqlBuilder *builder, GdaSqlBuilder *query, GdaSqlBuilderId *expr_id)
+{
+ GdaSqlExpr *expr;
+
+ g_return_val_if_fail (GDA_IS_SQL_BUILDER (builder), 0);
+ g_return_val_if_fail (builder->priv->main_stmt, 0);
+ g_return_val_if_fail (GDA_IS_SQL_BUILDER (query), 0);
+ g_return_val_if_fail (query->priv->main_stmt, 0);
+ g_return_val_if_fail (expr_id, 0);
+
+ expr = gda_sql_builder_export_expression(query, expr_id);
+ g_return_val_if_fail (GDA_SQL_ANY_PART (expr)->type == GDA_SQL_ANY_EXPR, 0);
+ return add_part (builder, (GdaSqlAnyPart *) gda_sql_expr_copy (expr));
+}
+
diff --git a/libgda/gda-sql-builder.h b/libgda/gda-sql-builder.h
index 39f64a5..215a0f4 100644
--- a/libgda/gda-sql-builder.h
+++ b/libgda/gda-sql-builder.h
@@ -2,6 +2,7 @@
* Copyright (C) 2009 - 2010 Murray Cumming <murrayc murrayc com>
* Copyright (C) 2009 - 2011 Vivien Malerba <malerba gnome-db org>
* Copyright (C) 2010 Jonh Wendell <jwendell gnome org>
+ * Copyright (C) 2011 Daniel Espinosa <despinosa src gnome org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -111,7 +112,7 @@ GdaStatement *gda_sql_builder_get_statement (GdaSqlBuilder *builder, GError
GdaSqlStatement *gda_sql_builder_get_sql_statement (GdaSqlBuilder *builder);
/* Expression API */
-GdaSqlBuilderId gda_sql_builder_add_id (GdaSqlBuilder *builder, const gchar *string);
+GdaSqlBuilderId gda_sql_builder_add_id (GdaSqlBuilder *builder, const gchar *str);
GdaSqlBuilderId gda_sql_builder_add_field_id (GdaSqlBuilder *builder, const gchar *field_name, const gchar *table_name);
GdaSqlBuilderId gda_sql_builder_add_expr (GdaSqlBuilder *builder, GdaDataHandler *dh, GType type, ...);
GdaSqlBuilderId gda_sql_builder_add_expr_value (GdaSqlBuilder *builder, GdaDataHandler *dh, const GValue *value);
@@ -162,10 +163,12 @@ void gda_sql_builder_select_group_by (GdaSqlBuilder *builder, GdaSq
/* COMPOUND SELECT Statement API */
void gda_sql_builder_compound_set_type (GdaSqlBuilder *builder, GdaSqlStatementCompoundType compound_type);
void gda_sql_builder_compound_add_sub_select (GdaSqlBuilder *builder, GdaSqlStatement *sqlst);
+void gda_sql_builder_compound_add_sub_select_from_builder (GdaSqlBuilder *builder, GdaSqlBuilder *subselect);
/* import/Export API */
GdaSqlExpr *gda_sql_builder_export_expression (GdaSqlBuilder *builder, GdaSqlBuilderId id);
GdaSqlBuilderId gda_sql_builder_import_expression (GdaSqlBuilder *builder, GdaSqlExpr *expr);
+GdaSqlBuilderId gda_sql_builder_import_expression_from_builder (GdaSqlBuilder *builder, GdaSqlBuilder *query, GdaSqlBuilderId *expr_id);
G_END_DECLS
diff --git a/libgda/handlers/gda-handler-time.c b/libgda/handlers/gda-handler-time.c
index caa8e48..6abe257 100644
--- a/libgda/handlers/gda-handler-time.c
+++ b/libgda/handlers/gda-handler-time.c
@@ -425,27 +425,27 @@ handler_compute_locale (GdaHandlerTime *hdl)
/**
* gda_handler_time_get_no_locale_str_from_value:
- * @hdl: a #GdaHandlerTime object
+ * @dh: a #GdaHandlerTime object
* @value: a #GValue value
*
* Returns: a new string representing @value without taking the current
* locale into account
*/
gchar *
-gda_handler_time_get_no_locale_str_from_value (GdaHandlerTime *hdl, const GValue *value)
+gda_handler_time_get_no_locale_str_from_value (GdaHandlerTime *dh, const GValue *value)
{
gchar *retval = NULL, *str;
GType type;
- g_return_val_if_fail (GDA_IS_HANDLER_TIME (hdl), NULL);
- g_return_val_if_fail (hdl->priv, NULL);
+ g_return_val_if_fail (GDA_IS_HANDLER_TIME (dh), NULL);
+ g_return_val_if_fail (dh->priv, NULL);
type = G_VALUE_TYPE (value);
if (type == G_TYPE_DATE) {
const GDate *date;
date = (GDate *) g_value_get_boxed (value);
- str = render_date_locale (date, hdl->priv->sql_locale);
+ str = render_date_locale (date, dh->priv->sql_locale);
if (!str)
retval = g_strdup ("NULL");
else
@@ -466,7 +466,7 @@ gda_handler_time_get_no_locale_str_from_value (GdaHandlerTime *hdl, const GValue
gdats = gda_value_get_timestamp ((GValue *) value);
vdate = g_date_new_dmy (gdats->day, gdats->month, gdats->year);
- str = render_date_locale (vdate, hdl->priv->sql_locale);
+ str = render_date_locale (vdate, dh->priv->sql_locale);
g_date_free (vdate);
if (str) {
diff --git a/libgda/sql-parser/gda-statement-struct-compound.h b/libgda/sql-parser/gda-statement-struct-compound.h
index 6ab777b..d357d68 100644
--- a/libgda/sql-parser/gda-statement-struct-compound.h
+++ b/libgda/sql-parser/gda-statement-struct-compound.h
@@ -53,7 +53,7 @@ typedef enum {
* Structure definition
*/
/**
- * GdaSqlStatementCompound:
+ * GdaSqlStatementCompound: (skip)
* @any:
* @compound_type:
* @stmt_list:
diff --git a/libgda/sql-parser/gda-statement-struct-decl.h b/libgda/sql-parser/gda-statement-struct-decl.h
index 5128107..badaf03 100644
--- a/libgda/sql-parser/gda-statement-struct-decl.h
+++ b/libgda/sql-parser/gda-statement-struct-decl.h
@@ -32,33 +32,76 @@ G_BEGIN_DECLS
/* error reporting */
extern GQuark gda_sql_error_quark (void);
#define GDA_SQL_ERROR gda_sql_error_quark ()
-
+/*
+ * GdaSqlError: (skip)
+ *
+ **/
typedef enum {
GDA_SQL_STRUCTURE_CONTENTS_ERROR,
GDA_SQL_MALFORMED_IDENTIFIER_ERROR,
GDA_SQL_MISSING_IDENTIFIER_ERROR,
GDA_SQL_VALIDATION_ERROR
} GdaSqlError;
+/*
+ * GdaSqlErrorType: (skip)
+ *
+ **/
typedef GdaSqlError GdaSqlErrorType;
/*
* Struct declarations
*/
+/*
+ * GdaSqlAnyPart: (skip)
+ *
+ **/
typedef struct _GdaSqlAnyPart GdaSqlAnyPart;
+/*
+ * GdaSqlStatement: (skip)
+ *
+ **/
typedef struct _GdaSqlStatement GdaSqlStatement;
+/*
+ * GdaSqlStatementUnknown: (skip)
+ *
+ **/
typedef struct _GdaSqlStatementUnknown GdaSqlStatementUnknown;
+/*
+ * GdaSqlStatementTransaction: (skip)
+ *
+ **/
typedef struct _GdaSqlStatementTransaction GdaSqlStatementTransaction;
+/*
+ * GdaSqlStatementSelect: (skip)
+ *
+ **/
typedef struct _GdaSqlStatementSelect GdaSqlStatementSelect;
+/*
+ * GdaSqlStatementInsert: (skip)
+ *
+ **/
typedef struct _GdaSqlStatementInsert GdaSqlStatementInsert;
+/*
+ * GdaSqlStatementDelete: (skip)
+ *
+ **/
typedef struct _GdaSqlStatementDelete GdaSqlStatementDelete;
+/*
+ * GdaSqlStatementUpdate: (skip)
+ *
+ **/
typedef struct _GdaSqlStatementUpdate GdaSqlStatementUpdate;
+/*
+ * GdaSqlStatementCompound: (skip)
+ *
+ **/
typedef struct _GdaSqlStatementCompound GdaSqlStatementCompound;
/*
* Statement type
*/
/**
- * GdaSqlStatementType: (skip)
+ * GdaSqlStatementType:
* @GDA_SQL_STATEMENT_SELECT: a SELECT statement
* @GDA_SQL_STATEMENT_INSERT: an INSERT statement
* @GDA_SQL_STATEMENT_UPDATE: an UPDATE statement
diff --git a/libgda/sql-parser/gda-statement-struct-parts.h b/libgda/sql-parser/gda-statement-struct-parts.h
index a999e36..3d3bead 100644
--- a/libgda/sql-parser/gda-statement-struct-parts.h
+++ b/libgda/sql-parser/gda-statement-struct-parts.h
@@ -30,24 +30,67 @@
#include <libgda/gda-meta-struct.h>
G_BEGIN_DECLS
-
+/*
+ * GdaSqlExpr: (skip)
+ *
+ **/
typedef struct _GdaSqlExpr GdaSqlExpr;
+/*
+ * GdaSqlField: (skip)
+ *
+ **/
typedef struct _GdaSqlField GdaSqlField;
+/*
+ * GdaSqlTable: (skip)
+ *
+ **/
typedef struct _GdaSqlTable GdaSqlTable;
+/*
+ * GdaSqlFunction: (skip)
+ *
+ **/
typedef struct _GdaSqlFunction GdaSqlFunction;
+/*
+ * GdaSqlOperation: (skip)
+ *
+ **/
typedef struct _GdaSqlOperation GdaSqlOperation;
+/*
+ * GdaSqlCase: (skip)
+ *
+ **/
typedef struct _GdaSqlCase GdaSqlCase;
+/*
+ * GdaSqlSelectField: (skip)
+ *
+ **/
typedef struct _GdaSqlSelectField GdaSqlSelectField;
+/*
+ * GdaSqlSelectTarget: (skip)
+ *
+ **/
typedef struct _GdaSqlSelectTarget GdaSqlSelectTarget;
+/*
+ * GdaSqlSelectJoin: (skip)
+ *
+ **/
typedef struct _GdaSqlSelectJoin GdaSqlSelectJoin;
+/*
+ * GdaSqlSelectFrom: (skip)
+ *
+ **/
typedef struct _GdaSqlSelectFrom GdaSqlSelectFrom;
+/*
+ * GdaSqlSelectOrder: (skip)
+ *
+ **/
typedef struct _GdaSqlSelectOrder GdaSqlSelectOrder;
/*
* Any Expression
*/
/**
- * GdaSqlExpr:
+ * GdaSqlExpr: (skip)
* @any: inheritance structure
* @value: (allow-none): a #GValue, or %NULL. Please see specific note about this field.
* @param_spec: (allow-none): a #GdaSqlParamSpec, or %NULL if this is not a variable
@@ -94,21 +137,19 @@ struct _GdaSqlExpr {
};
#define GDA_TYPE_SQL_EXPR (gda_sql_expr_get_type())
-
GType gda_sql_expr_get_type (void) G_GNUC_CONST;
GdaSqlExpr *gda_sql_expr_new (GdaSqlAnyPart *parent);
void gda_sql_expr_free (GdaSqlExpr *expr);
GdaSqlExpr *gda_sql_expr_copy (GdaSqlExpr *expr);
gchar *gda_sql_expr_serialize (GdaSqlExpr *expr);
void _gda_sql_expr_check_clean (GdaSqlExpr *expr);
-
void gda_sql_expr_take_select (GdaSqlExpr *expr, GdaSqlStatement *stmt);
/*
* Any Table's field
*/
/**
- * GdaSqlField:
+ * GdaSqlField: (skip)
* any:
* @field_name:
* @validity_meta_table_column:
@@ -140,7 +181,7 @@ void gda_sql_field_take_name (GdaSqlField *field, GValue *value
* Any table
*/
/**
- * GdaSqlTable:
+ * GdaSqlTable: (skip)
* @any:
* @table_name:
* @validity_meta_object:
@@ -173,7 +214,7 @@ void gda_sql_table_take_name (GdaSqlTable *table, GValue *value
* A function with any number of arguments
*/
/**
- * GdaSqlFunction:
+ * GdaSqlFunction: (skip)
* @any: inheritance structure
* @function_name: name of the function , in the form [[catalog.]schema.]function_name
* @args_list: list of #GdaSqlExpr expressions, one for each argument
@@ -274,7 +315,7 @@ typedef enum {
} GdaSqlOperatorType;
/**
- * GdaSqlOperation:
+ * GdaSqlOperation: (skip)
* @any: inheritance structure
* @operator_type:
* @operands: list of #GdaSqlExpr operands
@@ -303,7 +344,7 @@ GdaSqlOperatorType gda_sql_operation_operator_from_string (const gchar *op);
* A CASE expression
*/
/**
- * GdaSqlCase:
+ * GdaSqlCase: (skip)
* @any: inheritance structure
* @base_expr: expression to test
* @when_expr_list: list of #GdaSqlExpr, one for each WHEN clause
@@ -335,7 +376,7 @@ gchar *gda_sql_case_serialize (GdaSqlCase *sc);
* Any expression in a SELECT ... before the FROM clause
*/
/**
- * GdaSqlSelectField:
+ * GdaSqlSelectField: (skip)
* @any: inheritance structure
* @expr: expression
* @field_name: field name part of @expr if @expr represents a field
@@ -381,7 +422,7 @@ void gda_sql_select_field_take_alias (GdaSqlSelectField *field
* Any TARGET ... in a SELECT statement
*/
/**
- * GdaSqlSelectTarget:
+ * GdaSqlSelectTarget: (skip)
* @any: inheritance structure
* @expr: expression
* @table_name: table name part of @expr if @expr represents a table
@@ -441,7 +482,7 @@ typedef enum {
} GdaSqlSelectJoinType;
/**
- * GdaSqlSelectJoin:
+ * GdaSqlSelectJoin: (skip)
* @any: inheritance structure
* @type: type of join
* @position: represents a join between a target at (pos < @position) and the one at @position
@@ -476,7 +517,7 @@ const gchar *gda_sql_select_join_type_to_string (GdaSqlSelectJoinType type
* Any FROM ... in a SELECT statement
*/
/**
- * GdaSqlSelectFrom:
+ * GdaSqlSelectFrom: (skip)
* @any: inheritance structure
* @targets: (element-type Gda.SqlSelectTarget): list of #GdaSqlSelectTarget
* @joins: (element-type Gda.SqlSelectJoin): list of #GdaSqlSelectJoin
@@ -507,7 +548,7 @@ void gda_sql_select_from_take_new_join (GdaSqlSelectFrom *from, G
* Any expression in a SELECT ... after the ORDER BY
*/
/**
- * GdaSqlSelectOrder:
+ * GdaSqlSelectOrder: (skip)
* @any: inheritance structure
* @expr: expression to order on
* @asc: TRUE is ordering is ascending
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]