+/*
+ * Copyright (C) 2005 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+
+
#include <rdp.h>
#include <stdlib.h>
g_node_destroy (tree);
}
-static void rdp_init (GTypeInstance* instance, gpointer g_class)
-{
- Rdp* self = RDP(instance);
- self->cb = NULL;
- self->data = NULL;
- self->buffer = NULL;
- self->start = NULL;
-}
-
-static void rdp_finalize (GObject* obj)
-{
- RdpClass* klass;
- GObject* parent_class;
- Rdp* self;
- self = RDP(obj);
- g_free (self->start);
- klass = RDP_GET_CLASS(obj);
- parent_class = g_type_class_peek_parent (klass);
- G_OBJECT_CLASS(parent_class)->finalize (obj);
-}
-
-static void rdp_class_init (RdpClass* klass)
-{
- GObjectClass* gobj_class = G_OBJECT_CLASS(klass);
- gobj_class->finalize = rdp_finalize;
-}
-
-GType rdp_get_type ()
-{
- static GType type = 0;
- if (type == 0)
- {
- static const GTypeInfo info =
- {
- sizeof (RdpClass),
- NULL,
- NULL,
- (GClassInitFunc)rdp_class_init,
- NULL,
- NULL,
- sizeof (Rdp),
- 0,
- rdp_init
- };
- type = g_type_register_static (GRAMMAR_TYPE, "RdpType", &info, 0);
- }
- return type;
-}
-
-Rdp* rdp_new (nextcb cb, gpointer data, gint value)
+rdp_t* rdp_new (nextcb cb, gpointer data, gint value, grammar_t* grammar)
{
- Rdp* parser;
+ rdp_t* parser;
- parser = g_object_new (RDP_TYPE, NULL);
+ parser = g_malloc (sizeof (rdp_t));
parser->cb = cb;
parser->data = data;
parser->start = symbol_new (FALSE, value);
+ parser->grammar = grammar;
parser->buffer = g_list_append (NULL, NULL);
}
-void rdp_delete (Rdp* parser)
+void rdp_delete (rdp_t* rdp)
{
-
- g_object_unref (parser);
-
+ g_free (rdp->start);
}
-symbol_t* buffer_next (Rdp* parser, gpointer* attrib)
+symbol_t* buffer_next (rdp_t* parser, gpointer* attrib)
{
buffer_t* buffer;
}
-gboolean rdp_step (Rdp* parser, symbol_t* symbol, gpointer* attrib)
+gboolean rdp_step (rdp_t* parser, symbol_t* symbol, gpointer* attrib)
{
GList* l;
return TRUE;
}
- for (l = grammar_get_rules (parser, symbol); l != NULL; l = g_list_next (l))
+ l = grammar_get_rules (parser->grammar, symbol);
+ for (; l != NULL; l = g_list_next (l))
{
rule_t* rule;
}
-gpointer rdp_build (Rdp* parser)
+gpointer rdp_build (rdp_t* parser)
{
gpointer attrib;