aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ld-lua-symbol.c42
-rw-r--r--src/ld-lua-symbol.h3
-rw-r--r--src/ld-lua.c2
-rw-r--r--src/ld-symbol-category.h5
-rw-r--r--src/ld-symbol.h3
5 files changed, 41 insertions, 14 deletions
diff --git a/src/ld-lua-symbol.c b/src/ld-lua-symbol.c
index 1278756..b3e13af 100644
--- a/src/ld-lua-symbol.c
+++ b/src/ld-lua-symbol.c
@@ -29,17 +29,21 @@
/*
* LdLuaSymbolPrivate:
- * @lua: Parent Lua object.
+ * @lua: Parent #LdLua object.
+ * @ident: Identifier for the symbol.
*/
struct _LdLuaSymbolPrivate
{
LdLua *lua;
+ gchar *ident;
};
G_DEFINE_TYPE (LdLuaSymbol, ld_lua_symbol, LD_TYPE_SYMBOL);
static void ld_lua_symbol_finalize (GObject *gobject);
+static void ld_lua_symbol_draw (LdSymbol *self, cairo_t *cr);
+
static void
ld_lua_symbol_class_init (LdLuaSymbolClass *klass)
@@ -49,7 +53,7 @@ ld_lua_symbol_class_init (LdLuaSymbolClass *klass)
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = ld_lua_symbol_finalize;
- /* TODO: Override the "draw" method of LdSymbol. */
+ klass->parent_class.draw = ld_lua_symbol_draw;
g_type_class_add_private (klass, sizeof (LdLuaSymbolPrivate));
}
@@ -69,6 +73,8 @@ ld_lua_symbol_finalize (GObject *gobject)
self = LD_LUA_SYMBOL (gobject);
g_object_unref (self->priv->lua);
+ g_free (self->priv->ident);
+
/* Chain up to the parent class. */
G_OBJECT_CLASS (ld_lua_symbol_parent_class)->finalize (gobject);
}
@@ -76,23 +82,37 @@ ld_lua_symbol_finalize (GObject *gobject)
/**
* ld_symbol_new:
- * @library: A library object.
- * @filename: The file from which the symbol will be loaded.
+ * @lua: An #LdLua object.
+ * @ident: Identifier for the symbol.
*
* Load a symbol from a file into the library.
*/
LdSymbol *
-ld_lua_symbol_new (LdSymbolCategory *parent, LdLua *lua)
+ld_lua_symbol_new (LdLua *lua, const gchar *ident)
{
- LdLuaSymbol *symbol;
+ LdLuaSymbol *self;
- symbol = g_object_new (LD_TYPE_LUA_SYMBOL, NULL);
+ g_return_val_if_fail (LD_IS_LUA (lua), NULL);
+ g_return_val_if_fail (ident != NULL, NULL);
- /* TODO: Create a separate ld-symbol-private.h, include it in this file
- * and then assign and ref the parent category here.
- */
+ self = g_object_new (LD_TYPE_LUA_SYMBOL, NULL);
- symbol->priv->lua = lua;
+ self->priv->lua = lua;
g_object_ref (lua);
+
+ self->priv->ident = g_strdup (ident);
+ return LD_SYMBOL (self);
+}
+
+static void
+ld_lua_symbol_draw (LdSymbol *self, cairo_t *cr)
+{
+ g_return_if_fail (LD_IS_SYMBOL (self));
+ g_return_if_fail (cr != NULL);
+
+ /* TODO: Implement. */
+ /* Retrieve the function for rendering from the registry or wherever
+ * it's going to end up, and call it.
+ */
}
diff --git a/src/ld-lua-symbol.h b/src/ld-lua-symbol.h
index a90feb7..9e5af9b 100644
--- a/src/ld-lua-symbol.h
+++ b/src/ld-lua-symbol.h
@@ -33,7 +33,6 @@ typedef struct _LdLuaSymbolClass LdLuaSymbolClass;
/**
* LdLuaSymbol:
- * @name: The name of this symbol.
*/
struct _LdLuaSymbol
{
@@ -54,7 +53,7 @@ struct _LdLuaSymbolClass
GType ld_lua_symbol_get_type (void) G_GNUC_CONST;
-LdSymbol *ld_lua_symbol_new (LdSymbolCategory *parent, LdLua *lua);
+LdSymbol *ld_lua_symbol_new (LdLua *lua, const gchar *ident);
G_END_DECLS
diff --git a/src/ld-lua.c b/src/ld-lua.c
index 4440356..5e4da89 100644
--- a/src/ld-lua.c
+++ b/src/ld-lua.c
@@ -269,7 +269,7 @@ ld_lua_logdiag_register (lua_State *L)
*/
/*
- symbol = ld_lua_symbol_new (ud->category, ud->self);
+ symbol = ld_lua_symbol_new (ud->self);
ld_symbol_category_insert (ud->category, symbol, -1);
g_object_unref (symbol);
*/
diff --git a/src/ld-symbol-category.h b/src/ld-symbol-category.h
index 6f48606..42ad8ac 100644
--- a/src/ld-symbol-category.h
+++ b/src/ld-symbol-category.h
@@ -65,6 +65,11 @@ GType ld_symbol_category_get_type (void) G_GNUC_CONST;
LdSymbolCategory *
ld_symbol_category_new (LdLibrary *parent);
+/* TODO: Methods for inserting and removing children. */
+/* TODO: Create a separate ld-symbol-private.h, include it in this ld-s-c.c
+ * and then assign and ref the parent category here.
+ */
+
G_END_DECLS
diff --git a/src/ld-symbol.h b/src/ld-symbol.h
index 3d5967c..8ead147 100644
--- a/src/ld-symbol.h
+++ b/src/ld-symbol.h
@@ -65,6 +65,9 @@ gchar *ld_symbol_build_identifier (LdSymbol *self);
void ld_symbol_draw (LdSymbol *self, cairo_t *cr);
/* TODO: An interface for symbol terminals etc. */
+/* TODO: Store a pointer to the parent, probably as a property,
+ * using g_object_add_weak_pointer/remove_weak_pointer.
+ */
G_END_DECLS