2003-09-01 18:02:06 +00:00
|
|
|
/* -*- mode: C; c-file-style: "gnu" -*- */
|
|
|
|
|
/* dbus-gparser.c parse DBus description files
|
|
|
|
|
*
|
2005-01-29 19:52:19 +00:00
|
|
|
* Copyright (C) 2003, 2005 Red Hat, Inc.
|
2003-09-01 18:02:06 +00:00
|
|
|
*
|
2004-08-10 03:07:01 +00:00
|
|
|
* Licensed under the Academic Free License version 2.1
|
2003-09-01 18:02:06 +00:00
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
#include "dbus-gparser.h"
|
|
|
|
|
#include "dbus-gidl.h"
|
2003-09-03 02:08:25 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
|
|
#include <libintl.h>
|
|
|
|
|
#define _(x) gettext ((x))
|
|
|
|
|
#define N_(x) x
|
|
|
|
|
|
2003-09-07 23:04:54 +00:00
|
|
|
#ifndef DOXYGEN_SHOULD_SKIP_THIS
|
|
|
|
|
|
2003-09-03 02:08:25 +00:00
|
|
|
#define ELEMENT_IS(name) (strcmp (element_name, (name)) == 0)
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
const char **retloc;
|
|
|
|
|
} LocateAttr;
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
locate_attributes (const char *element_name,
|
|
|
|
|
const char **attribute_names,
|
|
|
|
|
const char **attribute_values,
|
|
|
|
|
GError **error,
|
|
|
|
|
const char *first_attribute_name,
|
|
|
|
|
const char **first_attribute_retloc,
|
|
|
|
|
...)
|
|
|
|
|
{
|
|
|
|
|
va_list args;
|
|
|
|
|
const char *name;
|
|
|
|
|
const char **retloc;
|
|
|
|
|
int n_attrs;
|
|
|
|
|
#define MAX_ATTRS 24
|
|
|
|
|
LocateAttr attrs[MAX_ATTRS];
|
|
|
|
|
gboolean retval;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (first_attribute_name != NULL, FALSE);
|
|
|
|
|
g_return_val_if_fail (first_attribute_retloc != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
retval = TRUE;
|
|
|
|
|
|
|
|
|
|
n_attrs = 1;
|
|
|
|
|
attrs[0].name = first_attribute_name;
|
|
|
|
|
attrs[0].retloc = first_attribute_retloc;
|
|
|
|
|
*first_attribute_retloc = NULL;
|
|
|
|
|
|
|
|
|
|
va_start (args, first_attribute_retloc);
|
|
|
|
|
|
|
|
|
|
name = va_arg (args, const char*);
|
|
|
|
|
retloc = va_arg (args, const char**);
|
|
|
|
|
|
|
|
|
|
while (name != NULL)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (retloc != NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
g_assert (n_attrs < MAX_ATTRS);
|
|
|
|
|
|
|
|
|
|
attrs[n_attrs].name = name;
|
|
|
|
|
attrs[n_attrs].retloc = retloc;
|
|
|
|
|
n_attrs += 1;
|
|
|
|
|
*retloc = NULL;
|
|
|
|
|
|
|
|
|
|
name = va_arg (args, const char*);
|
|
|
|
|
retloc = va_arg (args, const char**);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
va_end (args);
|
|
|
|
|
|
|
|
|
|
if (!retval)
|
|
|
|
|
return retval;
|
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
while (attribute_names[i])
|
|
|
|
|
{
|
|
|
|
|
int j;
|
|
|
|
|
gboolean found;
|
|
|
|
|
|
|
|
|
|
found = FALSE;
|
|
|
|
|
j = 0;
|
|
|
|
|
while (j < n_attrs)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (attrs[j].name, attribute_names[i]) == 0)
|
|
|
|
|
{
|
|
|
|
|
retloc = attrs[j].retloc;
|
|
|
|
|
|
|
|
|
|
if (*retloc != NULL)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("Attribute \"%s\" repeated twice on the same <%s> element"),
|
|
|
|
|
attrs[j].name, element_name);
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*retloc = attribute_values[i];
|
|
|
|
|
found = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
++j;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!found)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("Attribute \"%s\" is invalid on <%s> element in this context"),
|
|
|
|
|
attribute_names[i], element_name);
|
|
|
|
|
retval = FALSE;
|
|
|
|
|
goto out;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
++i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
|
return retval;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
check_no_attributes (const char *element_name,
|
|
|
|
|
const char **attribute_names,
|
|
|
|
|
const char **attribute_values,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
if (attribute_names[0] != NULL)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("Attribute \"%s\" is invalid on <%s> element in this context"),
|
|
|
|
|
attribute_names[0], element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2003-09-01 18:02:06 +00:00
|
|
|
|
|
|
|
|
struct Parser
|
|
|
|
|
{
|
|
|
|
|
int refcount;
|
|
|
|
|
|
2003-09-03 02:08:25 +00:00
|
|
|
NodeInfo *result; /* Filled in when we pop the last node */
|
|
|
|
|
GSList *node_stack;
|
|
|
|
|
InterfaceInfo *interface;
|
|
|
|
|
MethodInfo *method;
|
|
|
|
|
SignalInfo *signal;
|
2005-01-29 19:52:19 +00:00
|
|
|
PropertyInfo *property;
|
2003-09-03 02:08:25 +00:00
|
|
|
ArgInfo *arg;
|
2003-09-01 18:02:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Parser*
|
|
|
|
|
parser_new (void)
|
|
|
|
|
{
|
|
|
|
|
Parser *parser;
|
|
|
|
|
|
|
|
|
|
parser = g_new0 (Parser, 1);
|
|
|
|
|
|
|
|
|
|
parser->refcount = 1;
|
|
|
|
|
|
|
|
|
|
return parser;
|
|
|
|
|
}
|
|
|
|
|
|
2003-11-27 01:25:50 +00:00
|
|
|
Parser *
|
2003-09-01 18:02:06 +00:00
|
|
|
parser_ref (Parser *parser)
|
|
|
|
|
{
|
|
|
|
|
parser->refcount += 1;
|
2003-11-27 01:25:50 +00:00
|
|
|
|
|
|
|
|
return parser;
|
2003-09-01 18:02:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
parser_unref (Parser *parser)
|
|
|
|
|
{
|
|
|
|
|
parser->refcount -= 1;
|
|
|
|
|
if (parser->refcount == 0)
|
|
|
|
|
{
|
2003-09-03 02:08:25 +00:00
|
|
|
if (parser->result)
|
|
|
|
|
node_info_unref (parser->result);
|
2003-09-01 18:02:06 +00:00
|
|
|
|
|
|
|
|
g_free (parser);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
parser_check_doctype (Parser *parser,
|
|
|
|
|
const char *doctype,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2003-09-03 02:08:25 +00:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
2003-09-01 18:02:06 +00:00
|
|
|
|
2004-06-01 03:02:26 +00:00
|
|
|
if (strcmp (doctype, "node") != 0)
|
2003-09-01 18:02:06 +00:00
|
|
|
{
|
|
|
|
|
g_set_error (error,
|
2003-09-03 02:08:25 +00:00
|
|
|
G_MARKUP_ERROR,
|
2003-09-01 18:02:06 +00:00
|
|
|
G_MARKUP_ERROR_PARSE,
|
2004-06-01 03:02:26 +00:00
|
|
|
"D-BUS description file has the wrong document type %s, use node or interface",
|
2003-09-01 18:02:06 +00:00
|
|
|
doctype);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-03 02:08:25 +00:00
|
|
|
static gboolean
|
|
|
|
|
parse_node (Parser *parser,
|
|
|
|
|
const char *element_name,
|
|
|
|
|
const char **attribute_names,
|
|
|
|
|
const char **attribute_values,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
NodeInfo *node;
|
|
|
|
|
|
|
|
|
|
if (parser->interface ||
|
|
|
|
|
parser->method ||
|
|
|
|
|
parser->signal ||
|
2005-01-29 19:52:19 +00:00
|
|
|
parser->property ||
|
2003-09-03 02:08:25 +00:00
|
|
|
parser->arg)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
2005-01-29 19:52:19 +00:00
|
|
|
_("Can't put <%s> element here"),
|
2003-09-03 02:08:25 +00:00
|
|
|
element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name = NULL;
|
|
|
|
|
if (!locate_attributes (element_name, attribute_names,
|
|
|
|
|
attribute_values, error,
|
|
|
|
|
"name", &name,
|
|
|
|
|
NULL))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* Only the root node can have no name */
|
|
|
|
|
if (parser->node_stack != NULL && name == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("\"%s\" attribute required on <%s> element "),
|
|
|
|
|
"name", element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-29 19:52:19 +00:00
|
|
|
/* Root element name must be absolute */
|
|
|
|
|
if (parser->node_stack == NULL && name && *name != '/')
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("\"%s\" attribute on <%s> element must be an absolute object path, \"%s\" not OK"),
|
|
|
|
|
"name", element_name, name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Other element names must not be absolute */
|
|
|
|
|
if (parser->node_stack != NULL && name && *name == '/')
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("\"%s\" attribute on <%s> element must not be an absolute object path, \"%s\" starts with /"),
|
|
|
|
|
"name", element_name, name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-09-17 03:52:07 +00:00
|
|
|
|
2003-09-03 02:08:25 +00:00
|
|
|
node = node_info_new (name);
|
2003-09-17 03:52:07 +00:00
|
|
|
|
|
|
|
|
if (parser->node_stack != NULL)
|
|
|
|
|
{
|
|
|
|
|
node_info_add_node (parser->node_stack->data,
|
|
|
|
|
node);
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-03 02:08:25 +00:00
|
|
|
parser->node_stack = g_slist_prepend (parser->node_stack,
|
|
|
|
|
node);
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
parse_interface (Parser *parser,
|
|
|
|
|
const char *element_name,
|
|
|
|
|
const char **attribute_names,
|
|
|
|
|
const char **attribute_values,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
2005-02-17 Colin Walters <walters@verbum.org>
This patch is based on initial work from
Paul Kuliniewicz <kuliniew@purdue.edu>.
* glib/dbus-gvalue.c (dbus_gvalue_init): New function; move
initialization of GValue from dbus type to here.
(dbus_gvalue_genmarshal_name_from_type): New function; generates a string
for the "glib-genmarshal" program from a DBus type.
(dbus_gvalue_binding_type_from_type): New function; turns a DBus type
into the C name for it we use in the glib bindings.
(dbus_gvalue_ctype_from_type): New function; maps a DBus type into a
glib C type (not GValue).
(dbus_gvalue_demarshal): invoke dbus_gvalue_init.
* glib/dbus-gutils.c (_dbus_gutils_wincaps_to_uscore): Moved here
from dbus-gobject.c.
* glib/dbus-gutils.h: Prototype it.
* glib/dbus-gproxy.c: Include new dbus-gobject.h.
(marshal_dbus_message_to_g_marshaller): Use new shared function
dbus_glib_marshal_dbus_message_to_gvalue_array.
* glib/dbus-gparser.c (parse_interface, parse_method): Handle c_name attribute.
Will be changed once we have annotations.
* glib/dbus-gobject.c: Change info_hash_mutex from GStaticMutex to
GStaticRWLock. Callers updated.
(wincaps_to_uscore): Move to dbus-gutils.c. Callers updated.
(string_table_next): New function for iterating over zero-terminated
string value array.
(string_table_lookup): New function; retrieves specific entry in
array.
(get_method_data): New function; look up method data in object data chunk.
(object_error_domain_prefix_from_object_info)
(object_error_code_from_object_info): New functions, but not implemented yet.
(method_interface_from_object_info): New function; retrieve interface name.
(method_name_from_object_info): New function; retrieve method name.
(method_arg_info_from_object_info): New function; retrieve argument data.
(arg_iterate): New function; iterates over serialized argument data.
(method_dir_signature_from_object_info): New function; returns a
GString holding type signature for arguments for just one
direction (input or output).
(method_input_signature_from_object_info)
(method_output_signature_from_object_info): New functions.
(dbus_glib_marshal_dbus_message_to_gvalue_array): New shared function;
converts dbus message arguments into a GValue array. Used for both
signal handling and method invocation.
(struct DBusGlibWriteIterfaceData): New utility structure.
(write_interface): New function; generate introspection XML for
an interface.
(introspect_interfaces): New function; gathers all interface->methods,
generates introspection XML for them.
(handle_introspect): Invoke introspect_interfaces.
(get_object_property): Be sure to zero-initalize stack-allocated GValue.
(lookup_object_and_method): New function; examines an incoming message
and attempts to match it up (via interface, method name, and argument
signature) with a known object and method.
(gerror_domaincode_to_dbus_error_name): New function; converts a
GError domain and code into a DBus error name. Needs GError data
added to object introspection to work well.
(gerror_to_dbus_error_message): Creates a DBusMessage error return from
GError.
(invoke_object_method): New function to invoke an object method
looked up via lookup_object_and_method. Parses the incoming
message, turns it into a GValue array, then invokes the marshaller
specified in the DBusGMethodInfo. Creates a new message with
either return values or error message as appropriate.
(gobject_message_function): Invoke lookup_object_and_method and
invoke_object_method.
* glib/dbus-glib-tool.c: Include dbus-binding-tool-glib.h.
(enum DBusBindingOutputMode): New enum for binding output modes.
(pretty_print): Print binding names.
(dbus_binding_tool_error_quark): GError bits.
(version): Fix typo.
(main): Create GIOChannel for output. Parse new --mode argument,
possible values are "pretty-print", "glib-server", "glib-client".
Use mode to invoke appropriate function.
* glib/dbus-gobject.h: Prototype dbus_glib_marshal_dbus_message_to_gvalue_array.
* glib/dbus-glib-tool.h: New header, just includes GError bits
for now.
* glib/dbus-gidl.c (struct InterfaceInfo): Add bindings hashtable;
maps binding style to name.
(struct MethodInfo): Ditto.
(get_hash_keys, get_hash_key): Utility function, returns keys for
a GHashTable.
(interface_info_new, method_info_new): Initialize bindings.
(interface_info_unref, method_info_unref): Destroy bindings.
(method_info_get_binding_names, method_info_get_binding_name)
(interface_info_get_binding_names, interface_info_get_binding_name):
Functions for retrieving binding names.
(method_info_set_binding_name, interface_info_set_binding_name):
Functions for setting binding names.
* glib/dbus-binding-tool-glib.h: New file, has prototypes
for glib binding generation.
* glib/dbus-binding-tool-glib.c: New file, implements server-side
and client-side glib glue generation.
* glib/Makefile.am (dbus_binding_tool_SOURCES): Add
dbus-binding-tool-glib.c, dbus-binding-tool-glib.h,
dbus-glib-tool.h.
* dbus/dbus-glib.h (struct DBusGMethodMarshaller): Remove in favor
of using GClosureMarshal directly.
(struct DBusGObjectInfo): Add n_infos member.
* test/glib/test-service-glib.xml: New file; contains introspection data
for MyTestObject used in test-service-glib.c.
* test/glib/test-service-glib.c (enum MyObjectError): New GError enum.
(my_object_do_nothing, my_object_increment, my_object_throw_error)
(my_object_uppercase, my_object_many_args): New test methods.
(main): Use dbus_g_object_class_install_info to include generated object
info.
* test/glib/Makefile.am: Generate server-side glue for test-service-glib.c,
as well as client-side bindings.
* test/glib/test-dbus-glib.c: Include test-service-glib-bindings.h.
(main): Activate TestSuiteGLibService; test invoke a bunch of its methods
using both the dbus_gproxy stuff directly as well as the generated bindings.
2005-02-17 17:41:30 +00:00
|
|
|
const char *c_name;
|
2003-09-03 02:08:25 +00:00
|
|
|
InterfaceInfo *iface;
|
|
|
|
|
NodeInfo *top;
|
|
|
|
|
|
|
|
|
|
if (parser->interface ||
|
|
|
|
|
parser->method ||
|
|
|
|
|
parser->signal ||
|
2005-01-29 19:52:19 +00:00
|
|
|
parser->property ||
|
2003-09-03 02:08:25 +00:00
|
|
|
parser->arg ||
|
|
|
|
|
(parser->node_stack == NULL))
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
2005-01-29 19:52:19 +00:00
|
|
|
_("Can't put <%s> element here"),
|
2003-09-03 02:08:25 +00:00
|
|
|
element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name = NULL;
|
|
|
|
|
if (!locate_attributes (element_name, attribute_names,
|
|
|
|
|
attribute_values, error,
|
|
|
|
|
"name", &name,
|
2005-02-17 Colin Walters <walters@verbum.org>
This patch is based on initial work from
Paul Kuliniewicz <kuliniew@purdue.edu>.
* glib/dbus-gvalue.c (dbus_gvalue_init): New function; move
initialization of GValue from dbus type to here.
(dbus_gvalue_genmarshal_name_from_type): New function; generates a string
for the "glib-genmarshal" program from a DBus type.
(dbus_gvalue_binding_type_from_type): New function; turns a DBus type
into the C name for it we use in the glib bindings.
(dbus_gvalue_ctype_from_type): New function; maps a DBus type into a
glib C type (not GValue).
(dbus_gvalue_demarshal): invoke dbus_gvalue_init.
* glib/dbus-gutils.c (_dbus_gutils_wincaps_to_uscore): Moved here
from dbus-gobject.c.
* glib/dbus-gutils.h: Prototype it.
* glib/dbus-gproxy.c: Include new dbus-gobject.h.
(marshal_dbus_message_to_g_marshaller): Use new shared function
dbus_glib_marshal_dbus_message_to_gvalue_array.
* glib/dbus-gparser.c (parse_interface, parse_method): Handle c_name attribute.
Will be changed once we have annotations.
* glib/dbus-gobject.c: Change info_hash_mutex from GStaticMutex to
GStaticRWLock. Callers updated.
(wincaps_to_uscore): Move to dbus-gutils.c. Callers updated.
(string_table_next): New function for iterating over zero-terminated
string value array.
(string_table_lookup): New function; retrieves specific entry in
array.
(get_method_data): New function; look up method data in object data chunk.
(object_error_domain_prefix_from_object_info)
(object_error_code_from_object_info): New functions, but not implemented yet.
(method_interface_from_object_info): New function; retrieve interface name.
(method_name_from_object_info): New function; retrieve method name.
(method_arg_info_from_object_info): New function; retrieve argument data.
(arg_iterate): New function; iterates over serialized argument data.
(method_dir_signature_from_object_info): New function; returns a
GString holding type signature for arguments for just one
direction (input or output).
(method_input_signature_from_object_info)
(method_output_signature_from_object_info): New functions.
(dbus_glib_marshal_dbus_message_to_gvalue_array): New shared function;
converts dbus message arguments into a GValue array. Used for both
signal handling and method invocation.
(struct DBusGlibWriteIterfaceData): New utility structure.
(write_interface): New function; generate introspection XML for
an interface.
(introspect_interfaces): New function; gathers all interface->methods,
generates introspection XML for them.
(handle_introspect): Invoke introspect_interfaces.
(get_object_property): Be sure to zero-initalize stack-allocated GValue.
(lookup_object_and_method): New function; examines an incoming message
and attempts to match it up (via interface, method name, and argument
signature) with a known object and method.
(gerror_domaincode_to_dbus_error_name): New function; converts a
GError domain and code into a DBus error name. Needs GError data
added to object introspection to work well.
(gerror_to_dbus_error_message): Creates a DBusMessage error return from
GError.
(invoke_object_method): New function to invoke an object method
looked up via lookup_object_and_method. Parses the incoming
message, turns it into a GValue array, then invokes the marshaller
specified in the DBusGMethodInfo. Creates a new message with
either return values or error message as appropriate.
(gobject_message_function): Invoke lookup_object_and_method and
invoke_object_method.
* glib/dbus-glib-tool.c: Include dbus-binding-tool-glib.h.
(enum DBusBindingOutputMode): New enum for binding output modes.
(pretty_print): Print binding names.
(dbus_binding_tool_error_quark): GError bits.
(version): Fix typo.
(main): Create GIOChannel for output. Parse new --mode argument,
possible values are "pretty-print", "glib-server", "glib-client".
Use mode to invoke appropriate function.
* glib/dbus-gobject.h: Prototype dbus_glib_marshal_dbus_message_to_gvalue_array.
* glib/dbus-glib-tool.h: New header, just includes GError bits
for now.
* glib/dbus-gidl.c (struct InterfaceInfo): Add bindings hashtable;
maps binding style to name.
(struct MethodInfo): Ditto.
(get_hash_keys, get_hash_key): Utility function, returns keys for
a GHashTable.
(interface_info_new, method_info_new): Initialize bindings.
(interface_info_unref, method_info_unref): Destroy bindings.
(method_info_get_binding_names, method_info_get_binding_name)
(interface_info_get_binding_names, interface_info_get_binding_name):
Functions for retrieving binding names.
(method_info_set_binding_name, interface_info_set_binding_name):
Functions for setting binding names.
* glib/dbus-binding-tool-glib.h: New file, has prototypes
for glib binding generation.
* glib/dbus-binding-tool-glib.c: New file, implements server-side
and client-side glib glue generation.
* glib/Makefile.am (dbus_binding_tool_SOURCES): Add
dbus-binding-tool-glib.c, dbus-binding-tool-glib.h,
dbus-glib-tool.h.
* dbus/dbus-glib.h (struct DBusGMethodMarshaller): Remove in favor
of using GClosureMarshal directly.
(struct DBusGObjectInfo): Add n_infos member.
* test/glib/test-service-glib.xml: New file; contains introspection data
for MyTestObject used in test-service-glib.c.
* test/glib/test-service-glib.c (enum MyObjectError): New GError enum.
(my_object_do_nothing, my_object_increment, my_object_throw_error)
(my_object_uppercase, my_object_many_args): New test methods.
(main): Use dbus_g_object_class_install_info to include generated object
info.
* test/glib/Makefile.am: Generate server-side glue for test-service-glib.c,
as well as client-side bindings.
* test/glib/test-dbus-glib.c: Include test-service-glib-bindings.h.
(main): Activate TestSuiteGLibService; test invoke a bunch of its methods
using both the dbus_gproxy stuff directly as well as the generated bindings.
2005-02-17 17:41:30 +00:00
|
|
|
"c_name", &c_name,
|
2003-09-03 02:08:25 +00:00
|
|
|
NULL))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("\"%s\" attribute required on <%s> element "),
|
|
|
|
|
"name", element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
top = parser->node_stack->data;
|
|
|
|
|
|
|
|
|
|
iface = interface_info_new (name);
|
2005-02-17 Colin Walters <walters@verbum.org>
This patch is based on initial work from
Paul Kuliniewicz <kuliniew@purdue.edu>.
* glib/dbus-gvalue.c (dbus_gvalue_init): New function; move
initialization of GValue from dbus type to here.
(dbus_gvalue_genmarshal_name_from_type): New function; generates a string
for the "glib-genmarshal" program from a DBus type.
(dbus_gvalue_binding_type_from_type): New function; turns a DBus type
into the C name for it we use in the glib bindings.
(dbus_gvalue_ctype_from_type): New function; maps a DBus type into a
glib C type (not GValue).
(dbus_gvalue_demarshal): invoke dbus_gvalue_init.
* glib/dbus-gutils.c (_dbus_gutils_wincaps_to_uscore): Moved here
from dbus-gobject.c.
* glib/dbus-gutils.h: Prototype it.
* glib/dbus-gproxy.c: Include new dbus-gobject.h.
(marshal_dbus_message_to_g_marshaller): Use new shared function
dbus_glib_marshal_dbus_message_to_gvalue_array.
* glib/dbus-gparser.c (parse_interface, parse_method): Handle c_name attribute.
Will be changed once we have annotations.
* glib/dbus-gobject.c: Change info_hash_mutex from GStaticMutex to
GStaticRWLock. Callers updated.
(wincaps_to_uscore): Move to dbus-gutils.c. Callers updated.
(string_table_next): New function for iterating over zero-terminated
string value array.
(string_table_lookup): New function; retrieves specific entry in
array.
(get_method_data): New function; look up method data in object data chunk.
(object_error_domain_prefix_from_object_info)
(object_error_code_from_object_info): New functions, but not implemented yet.
(method_interface_from_object_info): New function; retrieve interface name.
(method_name_from_object_info): New function; retrieve method name.
(method_arg_info_from_object_info): New function; retrieve argument data.
(arg_iterate): New function; iterates over serialized argument data.
(method_dir_signature_from_object_info): New function; returns a
GString holding type signature for arguments for just one
direction (input or output).
(method_input_signature_from_object_info)
(method_output_signature_from_object_info): New functions.
(dbus_glib_marshal_dbus_message_to_gvalue_array): New shared function;
converts dbus message arguments into a GValue array. Used for both
signal handling and method invocation.
(struct DBusGlibWriteIterfaceData): New utility structure.
(write_interface): New function; generate introspection XML for
an interface.
(introspect_interfaces): New function; gathers all interface->methods,
generates introspection XML for them.
(handle_introspect): Invoke introspect_interfaces.
(get_object_property): Be sure to zero-initalize stack-allocated GValue.
(lookup_object_and_method): New function; examines an incoming message
and attempts to match it up (via interface, method name, and argument
signature) with a known object and method.
(gerror_domaincode_to_dbus_error_name): New function; converts a
GError domain and code into a DBus error name. Needs GError data
added to object introspection to work well.
(gerror_to_dbus_error_message): Creates a DBusMessage error return from
GError.
(invoke_object_method): New function to invoke an object method
looked up via lookup_object_and_method. Parses the incoming
message, turns it into a GValue array, then invokes the marshaller
specified in the DBusGMethodInfo. Creates a new message with
either return values or error message as appropriate.
(gobject_message_function): Invoke lookup_object_and_method and
invoke_object_method.
* glib/dbus-glib-tool.c: Include dbus-binding-tool-glib.h.
(enum DBusBindingOutputMode): New enum for binding output modes.
(pretty_print): Print binding names.
(dbus_binding_tool_error_quark): GError bits.
(version): Fix typo.
(main): Create GIOChannel for output. Parse new --mode argument,
possible values are "pretty-print", "glib-server", "glib-client".
Use mode to invoke appropriate function.
* glib/dbus-gobject.h: Prototype dbus_glib_marshal_dbus_message_to_gvalue_array.
* glib/dbus-glib-tool.h: New header, just includes GError bits
for now.
* glib/dbus-gidl.c (struct InterfaceInfo): Add bindings hashtable;
maps binding style to name.
(struct MethodInfo): Ditto.
(get_hash_keys, get_hash_key): Utility function, returns keys for
a GHashTable.
(interface_info_new, method_info_new): Initialize bindings.
(interface_info_unref, method_info_unref): Destroy bindings.
(method_info_get_binding_names, method_info_get_binding_name)
(interface_info_get_binding_names, interface_info_get_binding_name):
Functions for retrieving binding names.
(method_info_set_binding_name, interface_info_set_binding_name):
Functions for setting binding names.
* glib/dbus-binding-tool-glib.h: New file, has prototypes
for glib binding generation.
* glib/dbus-binding-tool-glib.c: New file, implements server-side
and client-side glib glue generation.
* glib/Makefile.am (dbus_binding_tool_SOURCES): Add
dbus-binding-tool-glib.c, dbus-binding-tool-glib.h,
dbus-glib-tool.h.
* dbus/dbus-glib.h (struct DBusGMethodMarshaller): Remove in favor
of using GClosureMarshal directly.
(struct DBusGObjectInfo): Add n_infos member.
* test/glib/test-service-glib.xml: New file; contains introspection data
for MyTestObject used in test-service-glib.c.
* test/glib/test-service-glib.c (enum MyObjectError): New GError enum.
(my_object_do_nothing, my_object_increment, my_object_throw_error)
(my_object_uppercase, my_object_many_args): New test methods.
(main): Use dbus_g_object_class_install_info to include generated object
info.
* test/glib/Makefile.am: Generate server-side glue for test-service-glib.c,
as well as client-side bindings.
* test/glib/test-dbus-glib.c: Include test-service-glib-bindings.h.
(main): Activate TestSuiteGLibService; test invoke a bunch of its methods
using both the dbus_gproxy stuff directly as well as the generated bindings.
2005-02-17 17:41:30 +00:00
|
|
|
if (c_name)
|
|
|
|
|
interface_info_set_binding_name (iface, "C", c_name);
|
2003-09-03 02:08:25 +00:00
|
|
|
node_info_add_interface (top, iface);
|
|
|
|
|
interface_info_unref (iface);
|
|
|
|
|
|
|
|
|
|
parser->interface = iface;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
parse_method (Parser *parser,
|
|
|
|
|
const char *element_name,
|
|
|
|
|
const char **attribute_names,
|
|
|
|
|
const char **attribute_values,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
2005-02-17 Colin Walters <walters@verbum.org>
This patch is based on initial work from
Paul Kuliniewicz <kuliniew@purdue.edu>.
* glib/dbus-gvalue.c (dbus_gvalue_init): New function; move
initialization of GValue from dbus type to here.
(dbus_gvalue_genmarshal_name_from_type): New function; generates a string
for the "glib-genmarshal" program from a DBus type.
(dbus_gvalue_binding_type_from_type): New function; turns a DBus type
into the C name for it we use in the glib bindings.
(dbus_gvalue_ctype_from_type): New function; maps a DBus type into a
glib C type (not GValue).
(dbus_gvalue_demarshal): invoke dbus_gvalue_init.
* glib/dbus-gutils.c (_dbus_gutils_wincaps_to_uscore): Moved here
from dbus-gobject.c.
* glib/dbus-gutils.h: Prototype it.
* glib/dbus-gproxy.c: Include new dbus-gobject.h.
(marshal_dbus_message_to_g_marshaller): Use new shared function
dbus_glib_marshal_dbus_message_to_gvalue_array.
* glib/dbus-gparser.c (parse_interface, parse_method): Handle c_name attribute.
Will be changed once we have annotations.
* glib/dbus-gobject.c: Change info_hash_mutex from GStaticMutex to
GStaticRWLock. Callers updated.
(wincaps_to_uscore): Move to dbus-gutils.c. Callers updated.
(string_table_next): New function for iterating over zero-terminated
string value array.
(string_table_lookup): New function; retrieves specific entry in
array.
(get_method_data): New function; look up method data in object data chunk.
(object_error_domain_prefix_from_object_info)
(object_error_code_from_object_info): New functions, but not implemented yet.
(method_interface_from_object_info): New function; retrieve interface name.
(method_name_from_object_info): New function; retrieve method name.
(method_arg_info_from_object_info): New function; retrieve argument data.
(arg_iterate): New function; iterates over serialized argument data.
(method_dir_signature_from_object_info): New function; returns a
GString holding type signature for arguments for just one
direction (input or output).
(method_input_signature_from_object_info)
(method_output_signature_from_object_info): New functions.
(dbus_glib_marshal_dbus_message_to_gvalue_array): New shared function;
converts dbus message arguments into a GValue array. Used for both
signal handling and method invocation.
(struct DBusGlibWriteIterfaceData): New utility structure.
(write_interface): New function; generate introspection XML for
an interface.
(introspect_interfaces): New function; gathers all interface->methods,
generates introspection XML for them.
(handle_introspect): Invoke introspect_interfaces.
(get_object_property): Be sure to zero-initalize stack-allocated GValue.
(lookup_object_and_method): New function; examines an incoming message
and attempts to match it up (via interface, method name, and argument
signature) with a known object and method.
(gerror_domaincode_to_dbus_error_name): New function; converts a
GError domain and code into a DBus error name. Needs GError data
added to object introspection to work well.
(gerror_to_dbus_error_message): Creates a DBusMessage error return from
GError.
(invoke_object_method): New function to invoke an object method
looked up via lookup_object_and_method. Parses the incoming
message, turns it into a GValue array, then invokes the marshaller
specified in the DBusGMethodInfo. Creates a new message with
either return values or error message as appropriate.
(gobject_message_function): Invoke lookup_object_and_method and
invoke_object_method.
* glib/dbus-glib-tool.c: Include dbus-binding-tool-glib.h.
(enum DBusBindingOutputMode): New enum for binding output modes.
(pretty_print): Print binding names.
(dbus_binding_tool_error_quark): GError bits.
(version): Fix typo.
(main): Create GIOChannel for output. Parse new --mode argument,
possible values are "pretty-print", "glib-server", "glib-client".
Use mode to invoke appropriate function.
* glib/dbus-gobject.h: Prototype dbus_glib_marshal_dbus_message_to_gvalue_array.
* glib/dbus-glib-tool.h: New header, just includes GError bits
for now.
* glib/dbus-gidl.c (struct InterfaceInfo): Add bindings hashtable;
maps binding style to name.
(struct MethodInfo): Ditto.
(get_hash_keys, get_hash_key): Utility function, returns keys for
a GHashTable.
(interface_info_new, method_info_new): Initialize bindings.
(interface_info_unref, method_info_unref): Destroy bindings.
(method_info_get_binding_names, method_info_get_binding_name)
(interface_info_get_binding_names, interface_info_get_binding_name):
Functions for retrieving binding names.
(method_info_set_binding_name, interface_info_set_binding_name):
Functions for setting binding names.
* glib/dbus-binding-tool-glib.h: New file, has prototypes
for glib binding generation.
* glib/dbus-binding-tool-glib.c: New file, implements server-side
and client-side glib glue generation.
* glib/Makefile.am (dbus_binding_tool_SOURCES): Add
dbus-binding-tool-glib.c, dbus-binding-tool-glib.h,
dbus-glib-tool.h.
* dbus/dbus-glib.h (struct DBusGMethodMarshaller): Remove in favor
of using GClosureMarshal directly.
(struct DBusGObjectInfo): Add n_infos member.
* test/glib/test-service-glib.xml: New file; contains introspection data
for MyTestObject used in test-service-glib.c.
* test/glib/test-service-glib.c (enum MyObjectError): New GError enum.
(my_object_do_nothing, my_object_increment, my_object_throw_error)
(my_object_uppercase, my_object_many_args): New test methods.
(main): Use dbus_g_object_class_install_info to include generated object
info.
* test/glib/Makefile.am: Generate server-side glue for test-service-glib.c,
as well as client-side bindings.
* test/glib/test-dbus-glib.c: Include test-service-glib-bindings.h.
(main): Activate TestSuiteGLibService; test invoke a bunch of its methods
using both the dbus_gproxy stuff directly as well as the generated bindings.
2005-02-17 17:41:30 +00:00
|
|
|
const char *c_name;
|
2003-09-03 02:08:25 +00:00
|
|
|
MethodInfo *method;
|
|
|
|
|
NodeInfo *top;
|
|
|
|
|
|
|
|
|
|
if (parser->interface == NULL ||
|
|
|
|
|
parser->node_stack == NULL ||
|
|
|
|
|
parser->method ||
|
|
|
|
|
parser->signal ||
|
2005-01-29 19:52:19 +00:00
|
|
|
parser->property ||
|
2003-09-03 02:08:25 +00:00
|
|
|
parser->arg)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
2005-01-29 19:52:19 +00:00
|
|
|
_("Can't put <%s> element here"),
|
2003-09-03 02:08:25 +00:00
|
|
|
element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name = NULL;
|
|
|
|
|
if (!locate_attributes (element_name, attribute_names,
|
|
|
|
|
attribute_values, error,
|
|
|
|
|
"name", &name,
|
2005-02-17 Colin Walters <walters@verbum.org>
This patch is based on initial work from
Paul Kuliniewicz <kuliniew@purdue.edu>.
* glib/dbus-gvalue.c (dbus_gvalue_init): New function; move
initialization of GValue from dbus type to here.
(dbus_gvalue_genmarshal_name_from_type): New function; generates a string
for the "glib-genmarshal" program from a DBus type.
(dbus_gvalue_binding_type_from_type): New function; turns a DBus type
into the C name for it we use in the glib bindings.
(dbus_gvalue_ctype_from_type): New function; maps a DBus type into a
glib C type (not GValue).
(dbus_gvalue_demarshal): invoke dbus_gvalue_init.
* glib/dbus-gutils.c (_dbus_gutils_wincaps_to_uscore): Moved here
from dbus-gobject.c.
* glib/dbus-gutils.h: Prototype it.
* glib/dbus-gproxy.c: Include new dbus-gobject.h.
(marshal_dbus_message_to_g_marshaller): Use new shared function
dbus_glib_marshal_dbus_message_to_gvalue_array.
* glib/dbus-gparser.c (parse_interface, parse_method): Handle c_name attribute.
Will be changed once we have annotations.
* glib/dbus-gobject.c: Change info_hash_mutex from GStaticMutex to
GStaticRWLock. Callers updated.
(wincaps_to_uscore): Move to dbus-gutils.c. Callers updated.
(string_table_next): New function for iterating over zero-terminated
string value array.
(string_table_lookup): New function; retrieves specific entry in
array.
(get_method_data): New function; look up method data in object data chunk.
(object_error_domain_prefix_from_object_info)
(object_error_code_from_object_info): New functions, but not implemented yet.
(method_interface_from_object_info): New function; retrieve interface name.
(method_name_from_object_info): New function; retrieve method name.
(method_arg_info_from_object_info): New function; retrieve argument data.
(arg_iterate): New function; iterates over serialized argument data.
(method_dir_signature_from_object_info): New function; returns a
GString holding type signature for arguments for just one
direction (input or output).
(method_input_signature_from_object_info)
(method_output_signature_from_object_info): New functions.
(dbus_glib_marshal_dbus_message_to_gvalue_array): New shared function;
converts dbus message arguments into a GValue array. Used for both
signal handling and method invocation.
(struct DBusGlibWriteIterfaceData): New utility structure.
(write_interface): New function; generate introspection XML for
an interface.
(introspect_interfaces): New function; gathers all interface->methods,
generates introspection XML for them.
(handle_introspect): Invoke introspect_interfaces.
(get_object_property): Be sure to zero-initalize stack-allocated GValue.
(lookup_object_and_method): New function; examines an incoming message
and attempts to match it up (via interface, method name, and argument
signature) with a known object and method.
(gerror_domaincode_to_dbus_error_name): New function; converts a
GError domain and code into a DBus error name. Needs GError data
added to object introspection to work well.
(gerror_to_dbus_error_message): Creates a DBusMessage error return from
GError.
(invoke_object_method): New function to invoke an object method
looked up via lookup_object_and_method. Parses the incoming
message, turns it into a GValue array, then invokes the marshaller
specified in the DBusGMethodInfo. Creates a new message with
either return values or error message as appropriate.
(gobject_message_function): Invoke lookup_object_and_method and
invoke_object_method.
* glib/dbus-glib-tool.c: Include dbus-binding-tool-glib.h.
(enum DBusBindingOutputMode): New enum for binding output modes.
(pretty_print): Print binding names.
(dbus_binding_tool_error_quark): GError bits.
(version): Fix typo.
(main): Create GIOChannel for output. Parse new --mode argument,
possible values are "pretty-print", "glib-server", "glib-client".
Use mode to invoke appropriate function.
* glib/dbus-gobject.h: Prototype dbus_glib_marshal_dbus_message_to_gvalue_array.
* glib/dbus-glib-tool.h: New header, just includes GError bits
for now.
* glib/dbus-gidl.c (struct InterfaceInfo): Add bindings hashtable;
maps binding style to name.
(struct MethodInfo): Ditto.
(get_hash_keys, get_hash_key): Utility function, returns keys for
a GHashTable.
(interface_info_new, method_info_new): Initialize bindings.
(interface_info_unref, method_info_unref): Destroy bindings.
(method_info_get_binding_names, method_info_get_binding_name)
(interface_info_get_binding_names, interface_info_get_binding_name):
Functions for retrieving binding names.
(method_info_set_binding_name, interface_info_set_binding_name):
Functions for setting binding names.
* glib/dbus-binding-tool-glib.h: New file, has prototypes
for glib binding generation.
* glib/dbus-binding-tool-glib.c: New file, implements server-side
and client-side glib glue generation.
* glib/Makefile.am (dbus_binding_tool_SOURCES): Add
dbus-binding-tool-glib.c, dbus-binding-tool-glib.h,
dbus-glib-tool.h.
* dbus/dbus-glib.h (struct DBusGMethodMarshaller): Remove in favor
of using GClosureMarshal directly.
(struct DBusGObjectInfo): Add n_infos member.
* test/glib/test-service-glib.xml: New file; contains introspection data
for MyTestObject used in test-service-glib.c.
* test/glib/test-service-glib.c (enum MyObjectError): New GError enum.
(my_object_do_nothing, my_object_increment, my_object_throw_error)
(my_object_uppercase, my_object_many_args): New test methods.
(main): Use dbus_g_object_class_install_info to include generated object
info.
* test/glib/Makefile.am: Generate server-side glue for test-service-glib.c,
as well as client-side bindings.
* test/glib/test-dbus-glib.c: Include test-service-glib-bindings.h.
(main): Activate TestSuiteGLibService; test invoke a bunch of its methods
using both the dbus_gproxy stuff directly as well as the generated bindings.
2005-02-17 17:41:30 +00:00
|
|
|
"c_name", &c_name,
|
2003-09-03 02:08:25 +00:00
|
|
|
NULL))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("\"%s\" attribute required on <%s> element "),
|
|
|
|
|
"name", element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
top = parser->node_stack->data;
|
|
|
|
|
|
|
|
|
|
method = method_info_new (name);
|
2005-02-17 Colin Walters <walters@verbum.org>
This patch is based on initial work from
Paul Kuliniewicz <kuliniew@purdue.edu>.
* glib/dbus-gvalue.c (dbus_gvalue_init): New function; move
initialization of GValue from dbus type to here.
(dbus_gvalue_genmarshal_name_from_type): New function; generates a string
for the "glib-genmarshal" program from a DBus type.
(dbus_gvalue_binding_type_from_type): New function; turns a DBus type
into the C name for it we use in the glib bindings.
(dbus_gvalue_ctype_from_type): New function; maps a DBus type into a
glib C type (not GValue).
(dbus_gvalue_demarshal): invoke dbus_gvalue_init.
* glib/dbus-gutils.c (_dbus_gutils_wincaps_to_uscore): Moved here
from dbus-gobject.c.
* glib/dbus-gutils.h: Prototype it.
* glib/dbus-gproxy.c: Include new dbus-gobject.h.
(marshal_dbus_message_to_g_marshaller): Use new shared function
dbus_glib_marshal_dbus_message_to_gvalue_array.
* glib/dbus-gparser.c (parse_interface, parse_method): Handle c_name attribute.
Will be changed once we have annotations.
* glib/dbus-gobject.c: Change info_hash_mutex from GStaticMutex to
GStaticRWLock. Callers updated.
(wincaps_to_uscore): Move to dbus-gutils.c. Callers updated.
(string_table_next): New function for iterating over zero-terminated
string value array.
(string_table_lookup): New function; retrieves specific entry in
array.
(get_method_data): New function; look up method data in object data chunk.
(object_error_domain_prefix_from_object_info)
(object_error_code_from_object_info): New functions, but not implemented yet.
(method_interface_from_object_info): New function; retrieve interface name.
(method_name_from_object_info): New function; retrieve method name.
(method_arg_info_from_object_info): New function; retrieve argument data.
(arg_iterate): New function; iterates over serialized argument data.
(method_dir_signature_from_object_info): New function; returns a
GString holding type signature for arguments for just one
direction (input or output).
(method_input_signature_from_object_info)
(method_output_signature_from_object_info): New functions.
(dbus_glib_marshal_dbus_message_to_gvalue_array): New shared function;
converts dbus message arguments into a GValue array. Used for both
signal handling and method invocation.
(struct DBusGlibWriteIterfaceData): New utility structure.
(write_interface): New function; generate introspection XML for
an interface.
(introspect_interfaces): New function; gathers all interface->methods,
generates introspection XML for them.
(handle_introspect): Invoke introspect_interfaces.
(get_object_property): Be sure to zero-initalize stack-allocated GValue.
(lookup_object_and_method): New function; examines an incoming message
and attempts to match it up (via interface, method name, and argument
signature) with a known object and method.
(gerror_domaincode_to_dbus_error_name): New function; converts a
GError domain and code into a DBus error name. Needs GError data
added to object introspection to work well.
(gerror_to_dbus_error_message): Creates a DBusMessage error return from
GError.
(invoke_object_method): New function to invoke an object method
looked up via lookup_object_and_method. Parses the incoming
message, turns it into a GValue array, then invokes the marshaller
specified in the DBusGMethodInfo. Creates a new message with
either return values or error message as appropriate.
(gobject_message_function): Invoke lookup_object_and_method and
invoke_object_method.
* glib/dbus-glib-tool.c: Include dbus-binding-tool-glib.h.
(enum DBusBindingOutputMode): New enum for binding output modes.
(pretty_print): Print binding names.
(dbus_binding_tool_error_quark): GError bits.
(version): Fix typo.
(main): Create GIOChannel for output. Parse new --mode argument,
possible values are "pretty-print", "glib-server", "glib-client".
Use mode to invoke appropriate function.
* glib/dbus-gobject.h: Prototype dbus_glib_marshal_dbus_message_to_gvalue_array.
* glib/dbus-glib-tool.h: New header, just includes GError bits
for now.
* glib/dbus-gidl.c (struct InterfaceInfo): Add bindings hashtable;
maps binding style to name.
(struct MethodInfo): Ditto.
(get_hash_keys, get_hash_key): Utility function, returns keys for
a GHashTable.
(interface_info_new, method_info_new): Initialize bindings.
(interface_info_unref, method_info_unref): Destroy bindings.
(method_info_get_binding_names, method_info_get_binding_name)
(interface_info_get_binding_names, interface_info_get_binding_name):
Functions for retrieving binding names.
(method_info_set_binding_name, interface_info_set_binding_name):
Functions for setting binding names.
* glib/dbus-binding-tool-glib.h: New file, has prototypes
for glib binding generation.
* glib/dbus-binding-tool-glib.c: New file, implements server-side
and client-side glib glue generation.
* glib/Makefile.am (dbus_binding_tool_SOURCES): Add
dbus-binding-tool-glib.c, dbus-binding-tool-glib.h,
dbus-glib-tool.h.
* dbus/dbus-glib.h (struct DBusGMethodMarshaller): Remove in favor
of using GClosureMarshal directly.
(struct DBusGObjectInfo): Add n_infos member.
* test/glib/test-service-glib.xml: New file; contains introspection data
for MyTestObject used in test-service-glib.c.
* test/glib/test-service-glib.c (enum MyObjectError): New GError enum.
(my_object_do_nothing, my_object_increment, my_object_throw_error)
(my_object_uppercase, my_object_many_args): New test methods.
(main): Use dbus_g_object_class_install_info to include generated object
info.
* test/glib/Makefile.am: Generate server-side glue for test-service-glib.c,
as well as client-side bindings.
* test/glib/test-dbus-glib.c: Include test-service-glib-bindings.h.
(main): Activate TestSuiteGLibService; test invoke a bunch of its methods
using both the dbus_gproxy stuff directly as well as the generated bindings.
2005-02-17 17:41:30 +00:00
|
|
|
if (c_name)
|
|
|
|
|
method_info_set_binding_name (method, "C", c_name);
|
2003-09-03 02:08:25 +00:00
|
|
|
interface_info_add_method (parser->interface, method);
|
|
|
|
|
method_info_unref (method);
|
|
|
|
|
|
|
|
|
|
parser->method = method;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
parse_signal (Parser *parser,
|
|
|
|
|
const char *element_name,
|
|
|
|
|
const char **attribute_names,
|
|
|
|
|
const char **attribute_values,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
SignalInfo *signal;
|
|
|
|
|
NodeInfo *top;
|
|
|
|
|
|
|
|
|
|
if (parser->interface == NULL ||
|
|
|
|
|
parser->node_stack == NULL ||
|
|
|
|
|
parser->signal ||
|
2005-01-29 19:52:19 +00:00
|
|
|
parser->method ||
|
|
|
|
|
parser->property ||
|
2003-09-03 02:08:25 +00:00
|
|
|
parser->arg)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
2005-01-29 19:52:19 +00:00
|
|
|
_("Can't put <%s> element here"),
|
2003-09-03 02:08:25 +00:00
|
|
|
element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name = NULL;
|
|
|
|
|
if (!locate_attributes (element_name, attribute_names,
|
|
|
|
|
attribute_values, error,
|
|
|
|
|
"name", &name,
|
|
|
|
|
NULL))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("\"%s\" attribute required on <%s> element "),
|
|
|
|
|
"name", element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
top = parser->node_stack->data;
|
|
|
|
|
|
|
|
|
|
signal = signal_info_new (name);
|
|
|
|
|
interface_info_add_signal (parser->interface, signal);
|
|
|
|
|
signal_info_unref (signal);
|
|
|
|
|
|
|
|
|
|
parser->signal = signal;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
|
basic_type_from_string (const char *str)
|
|
|
|
|
{
|
|
|
|
|
if (strcmp (str, "string") == 0)
|
|
|
|
|
return DBUS_TYPE_STRING;
|
2005-01-28 03:06:56 +00:00
|
|
|
else if (strcmp (str, "int16") == 0)
|
|
|
|
|
return DBUS_TYPE_INT16;
|
|
|
|
|
else if (strcmp (str, "uint16") == 0)
|
|
|
|
|
return DBUS_TYPE_UINT16;
|
2003-09-03 02:08:25 +00:00
|
|
|
else if (strcmp (str, "int32") == 0)
|
|
|
|
|
return DBUS_TYPE_INT32;
|
|
|
|
|
else if (strcmp (str, "uint32") == 0)
|
|
|
|
|
return DBUS_TYPE_UINT32;
|
|
|
|
|
else if (strcmp (str, "int64") == 0)
|
|
|
|
|
return DBUS_TYPE_INT64;
|
|
|
|
|
else if (strcmp (str, "uint64") == 0)
|
|
|
|
|
return DBUS_TYPE_UINT64;
|
|
|
|
|
else if (strcmp (str, "double") == 0)
|
|
|
|
|
return DBUS_TYPE_DOUBLE;
|
|
|
|
|
else if (strcmp (str, "byte") == 0)
|
|
|
|
|
return DBUS_TYPE_BYTE;
|
|
|
|
|
else if (strcmp (str, "boolean") == 0)
|
|
|
|
|
return DBUS_TYPE_BOOLEAN;
|
|
|
|
|
else if (strcmp (str, "byte") == 0)
|
|
|
|
|
return DBUS_TYPE_BYTE;
|
|
|
|
|
else if (strcmp (str, "object") == 0)
|
|
|
|
|
return DBUS_TYPE_OBJECT_PATH;
|
2005-01-30 07:44:08 +00:00
|
|
|
else if (strcmp (str, "variant") == 0)
|
|
|
|
|
return DBUS_TYPE_VARIANT;
|
2003-09-03 02:08:25 +00:00
|
|
|
else
|
|
|
|
|
return DBUS_TYPE_INVALID;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-29 19:52:19 +00:00
|
|
|
/* FIXME we have to allow type signatures, not just basic types
|
|
|
|
|
*/
|
2003-09-03 02:08:25 +00:00
|
|
|
static int
|
2005-01-29 19:52:19 +00:00
|
|
|
type_from_string (const char *str,
|
|
|
|
|
const char *element_name,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
int t;
|
|
|
|
|
|
|
|
|
|
t = basic_type_from_string (str);
|
|
|
|
|
|
|
|
|
|
if (t == DBUS_TYPE_INVALID)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("Type \"%s\" not understood on <%s> element "),
|
|
|
|
|
str, element_name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return t;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
parse_property (Parser *parser,
|
|
|
|
|
const char *element_name,
|
|
|
|
|
const char **attribute_names,
|
|
|
|
|
const char **attribute_values,
|
|
|
|
|
GError **error)
|
2003-09-03 02:08:25 +00:00
|
|
|
{
|
2005-01-29 19:52:19 +00:00
|
|
|
const char *name;
|
|
|
|
|
const char *access;
|
|
|
|
|
const char *type;
|
|
|
|
|
PropertyInfo *property;
|
|
|
|
|
NodeInfo *top;
|
|
|
|
|
PropertyAccessFlags access_flags;
|
|
|
|
|
int t;
|
|
|
|
|
|
|
|
|
|
if (parser->interface == NULL ||
|
|
|
|
|
parser->node_stack == NULL ||
|
|
|
|
|
parser->signal ||
|
|
|
|
|
parser->method ||
|
|
|
|
|
parser->property ||
|
|
|
|
|
parser->arg)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("Can't put <%s> element here"),
|
|
|
|
|
element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name = NULL;
|
|
|
|
|
if (!locate_attributes (element_name, attribute_names,
|
|
|
|
|
attribute_values, error,
|
|
|
|
|
"name", &name,
|
|
|
|
|
"access", &access,
|
|
|
|
|
"type", &type,
|
|
|
|
|
NULL))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("\"%s\" attribute required on <%s> element "),
|
|
|
|
|
"name", element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (access == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("\"%s\" attribute required on <%s> element "),
|
|
|
|
|
"access", element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (type == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("\"%s\" attribute required on <%s> element "),
|
|
|
|
|
"type", element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
t = type_from_string (type, element_name, error);
|
|
|
|
|
if (t == DBUS_TYPE_INVALID)
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
access_flags = 0;
|
|
|
|
|
if (strcmp (access, "readwrite") == 0)
|
|
|
|
|
access_flags = PROPERTY_READ | PROPERTY_WRITE;
|
|
|
|
|
else if (strcmp (access, "read") == 0)
|
|
|
|
|
access_flags = PROPERTY_READ;
|
|
|
|
|
else if (strcmp (access, "write") == 0)
|
|
|
|
|
access_flags = PROPERTY_WRITE;
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("access=\"%s\" must have value readwrite, read, or write on %s\n"),
|
|
|
|
|
access, element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
top = parser->node_stack->data;
|
|
|
|
|
|
|
|
|
|
property = property_info_new (name, t, access_flags);
|
|
|
|
|
interface_info_add_property (parser->interface, property);
|
|
|
|
|
property_info_unref (property);
|
|
|
|
|
|
|
|
|
|
parser->property = property;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2003-09-03 02:08:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
parse_arg (Parser *parser,
|
|
|
|
|
const char *element_name,
|
|
|
|
|
const char **attribute_names,
|
|
|
|
|
const char **attribute_values,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
|
|
|
|
const char *name;
|
|
|
|
|
const char *type;
|
|
|
|
|
const char *direction;
|
|
|
|
|
ArgDirection dir;
|
|
|
|
|
int t;
|
|
|
|
|
ArgInfo *arg;
|
2005-02-12 20:27:45 +00:00
|
|
|
char *generated_name;
|
2003-09-03 02:08:25 +00:00
|
|
|
|
|
|
|
|
if (!(parser->method || parser->signal) ||
|
|
|
|
|
parser->node_stack == NULL ||
|
2005-01-29 19:52:19 +00:00
|
|
|
parser->property ||
|
2003-09-03 02:08:25 +00:00
|
|
|
parser->arg)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
2005-01-29 19:52:19 +00:00
|
|
|
_("Can't put <%s> element here"),
|
2003-09-03 02:08:25 +00:00
|
|
|
element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
name = NULL;
|
|
|
|
|
if (!locate_attributes (element_name, attribute_names,
|
|
|
|
|
attribute_values, error,
|
|
|
|
|
"name", &name,
|
|
|
|
|
"type", &type,
|
|
|
|
|
"direction", &direction,
|
|
|
|
|
NULL))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* name can be null for args */
|
|
|
|
|
|
|
|
|
|
if (type == NULL)
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("\"%s\" attribute required on <%s> element "),
|
|
|
|
|
"type", element_name);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (direction == NULL)
|
|
|
|
|
{
|
|
|
|
|
/* methods default to in, signal to out */
|
|
|
|
|
if (parser->method)
|
|
|
|
|
direction = "in";
|
|
|
|
|
else if (parser->signal)
|
|
|
|
|
direction = "out";
|
|
|
|
|
else
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-29 19:52:19 +00:00
|
|
|
dir = ARG_INVALID;
|
|
|
|
|
|
2003-09-03 02:08:25 +00:00
|
|
|
if (strcmp (direction, "in") == 0)
|
|
|
|
|
dir = ARG_IN;
|
|
|
|
|
else if (strcmp (direction, "out") == 0)
|
|
|
|
|
dir = ARG_OUT;
|
2005-01-29 19:52:19 +00:00
|
|
|
|
|
|
|
|
if (dir == ARG_INVALID ||
|
|
|
|
|
(parser->signal && dir == ARG_IN))
|
2003-09-03 02:08:25 +00:00
|
|
|
{
|
2005-01-29 19:52:19 +00:00
|
|
|
if (parser->signal)
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("Signals must have direction=\"out\" (just omit the direction attribute)"));
|
|
|
|
|
else
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("\"%s\" attribute on <%s> has value \"in\" or \"out\""),
|
|
|
|
|
"direction", element_name);
|
2003-09-03 02:08:25 +00:00
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2005-01-29 19:52:19 +00:00
|
|
|
t = type_from_string (type, element_name, error);
|
|
|
|
|
if (t == DBUS_TYPE_INVALID)
|
|
|
|
|
return FALSE;
|
2005-02-12 20:27:45 +00:00
|
|
|
|
|
|
|
|
generated_name = NULL;
|
|
|
|
|
if (name == NULL)
|
|
|
|
|
generated_name = g_strdup_printf ("arg%d",
|
|
|
|
|
parser->method ?
|
|
|
|
|
method_info_get_n_args (parser->method) :
|
|
|
|
|
signal_info_get_n_args (parser->signal));
|
|
|
|
|
|
2003-09-03 02:08:25 +00:00
|
|
|
|
2005-02-12 20:27:45 +00:00
|
|
|
arg = arg_info_new (name ? name : generated_name, dir, t);
|
2003-09-03 02:08:25 +00:00
|
|
|
if (parser->method)
|
|
|
|
|
method_info_add_arg (parser->method, arg);
|
|
|
|
|
else if (parser->signal)
|
|
|
|
|
signal_info_add_arg (parser->signal, arg);
|
|
|
|
|
else
|
|
|
|
|
g_assert_not_reached ();
|
|
|
|
|
|
2005-02-12 20:27:45 +00:00
|
|
|
g_free (generated_name);
|
|
|
|
|
|
2003-09-03 02:08:25 +00:00
|
|
|
arg_info_unref (arg);
|
|
|
|
|
|
|
|
|
|
parser->arg = arg;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-01 18:02:06 +00:00
|
|
|
gboolean
|
|
|
|
|
parser_start_element (Parser *parser,
|
|
|
|
|
const char *element_name,
|
|
|
|
|
const char **attribute_names,
|
|
|
|
|
const char **attribute_values,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2003-09-03 02:08:25 +00:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
2003-09-01 18:02:06 +00:00
|
|
|
|
2003-09-03 02:08:25 +00:00
|
|
|
if (ELEMENT_IS ("node"))
|
|
|
|
|
{
|
|
|
|
|
if (!parse_node (parser, element_name, attribute_names,
|
|
|
|
|
attribute_values, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else if (ELEMENT_IS ("interface"))
|
|
|
|
|
{
|
|
|
|
|
if (!parse_interface (parser, element_name, attribute_names,
|
|
|
|
|
attribute_values, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else if (ELEMENT_IS ("method"))
|
|
|
|
|
{
|
|
|
|
|
if (!parse_method (parser, element_name, attribute_names,
|
|
|
|
|
attribute_values, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else if (ELEMENT_IS ("signal"))
|
|
|
|
|
{
|
|
|
|
|
if (!parse_signal (parser, element_name, attribute_names,
|
|
|
|
|
attribute_values, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2005-01-29 19:52:19 +00:00
|
|
|
else if (ELEMENT_IS ("property"))
|
|
|
|
|
{
|
|
|
|
|
if (!parse_property (parser, element_name, attribute_names,
|
|
|
|
|
attribute_values, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
2003-09-03 02:08:25 +00:00
|
|
|
else if (ELEMENT_IS ("arg"))
|
|
|
|
|
{
|
|
|
|
|
if (!parse_arg (parser, element_name, attribute_names,
|
|
|
|
|
attribute_values, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
g_set_error (error, G_MARKUP_ERROR,
|
|
|
|
|
G_MARKUP_ERROR_PARSE,
|
|
|
|
|
_("Element <%s> not recognized"),
|
|
|
|
|
element_name);
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-01 18:02:06 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
parser_end_element (Parser *parser,
|
|
|
|
|
const char *element_name,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2003-09-03 02:08:25 +00:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
|
|
|
|
|
|
|
|
|
if (ELEMENT_IS ("interface"))
|
|
|
|
|
{
|
|
|
|
|
parser->interface = NULL;
|
|
|
|
|
}
|
|
|
|
|
else if (ELEMENT_IS ("method"))
|
|
|
|
|
{
|
|
|
|
|
parser->method = NULL;
|
|
|
|
|
}
|
|
|
|
|
else if (ELEMENT_IS ("signal"))
|
|
|
|
|
{
|
|
|
|
|
parser->signal = NULL;
|
|
|
|
|
}
|
2005-01-29 19:52:19 +00:00
|
|
|
else if (ELEMENT_IS ("property"))
|
|
|
|
|
{
|
|
|
|
|
parser->property = NULL;
|
|
|
|
|
}
|
2003-09-03 02:08:25 +00:00
|
|
|
else if (ELEMENT_IS ("arg"))
|
|
|
|
|
{
|
|
|
|
|
parser->arg = NULL;
|
|
|
|
|
}
|
|
|
|
|
else if (ELEMENT_IS ("node"))
|
|
|
|
|
{
|
|
|
|
|
NodeInfo *top;
|
2003-09-01 18:02:06 +00:00
|
|
|
|
2003-09-03 02:08:25 +00:00
|
|
|
g_assert (parser->node_stack != NULL);
|
|
|
|
|
top = parser->node_stack->data;
|
|
|
|
|
|
|
|
|
|
parser->node_stack = g_slist_remove (parser->node_stack,
|
|
|
|
|
top);
|
|
|
|
|
|
|
|
|
|
if (parser->node_stack == NULL)
|
|
|
|
|
parser->result = top; /* We are done, store the result */
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
g_assert_not_reached (); /* should have had an error on start_element */
|
|
|
|
|
|
2003-09-01 18:02:06 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
parser_content (Parser *parser,
|
|
|
|
|
const char *content,
|
|
|
|
|
int len,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2003-09-03 02:08:25 +00:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
2003-09-01 18:02:06 +00:00
|
|
|
|
2005-01-29 19:52:19 +00:00
|
|
|
/* FIXME check that it's all whitespace */
|
|
|
|
|
|
2003-09-01 18:02:06 +00:00
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
parser_finished (Parser *parser,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2003-09-03 02:08:25 +00:00
|
|
|
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
2003-09-01 18:02:06 +00:00
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
2003-09-03 02:08:25 +00:00
|
|
|
|
|
|
|
|
NodeInfo*
|
|
|
|
|
parser_get_nodes (Parser *parser)
|
|
|
|
|
{
|
|
|
|
|
return parser->result;
|
|
|
|
|
}
|
2003-09-07 23:04:54 +00:00
|
|
|
|
|
|
|
|
#endif /* DOXYGEN_SHOULD_SKIP_THIS */
|