Modified:
trunk/imbus/TODO
trunk/imbus/src/im_component_info.c
trunk/imbus/src/im_component_info.h
trunk/imbus/src/im_object.c
trunk/imbus/src/im_object.h
trunk/imbus/src/im_quark.h
trunk/imbus/src/im_string.h
trunk/imbus/src/im_type.c
trunk/imbus/tests/test_byte_stream.c
trunk/imbus/tests/test_text_stream.c
Log:
Various updates.
Modified: trunk/imbus/TODO
==============================================================================
--- trunk/imbus/TODO (original)
+++ trunk/imbus/TODO Sun Nov 25 02:34:13 2007
@@ -43,3 +43,6 @@
Add events to add/remove hotkeys from a registered hotkey profile
Reimplement key code as object.
+
+Think about the event of switching active component.
+Think about how to register the languages supported by IMEngine component.
Modified: trunk/imbus/src/im_component_info.c
==============================================================================
--- trunk/imbus/src/im_component_info.c (original)
+++ trunk/imbus/src/im_component_info.c Sun Nov 25 02:34:13 2007
@@ -25,20 +25,22 @@
/* private */
IMUInt32 unique_id;
- IMString *string_id;
- IMString *name;
- IMString *desc;
- IMString *icon;
- IMEventRoles *event_roles;
};
struct _IMComponentInfoClass
{
IMObjectClass parent_class;
+
+ IMQuark qsid;
+ IMQuark qname;
+ IMQuark qdesc;
+ IMQuark qicon;
+ IMQuark qroles;
};
/************************ Internal varable ************************/
static const IMObjectClass *__im_component_info_parent_class = 0;
+static const IMComponentInfoClass *__im_component_info_class = 0;
/************* Implementation of internal functions ***************/
@@ -46,30 +48,13 @@
__im_component_info_initialize (IMPointer info)
{
((IMComponentInfo*)info)->unique_id = 0;
- ((IMComponentInfo*)info)->string_id = 0;
- ((IMComponentInfo*)info)->name = 0;
- ((IMComponentInfo*)info)->desc = 0;
- ((IMComponentInfo*)info)->icon = 0;
- ((IMComponentInfo*)info)->event_roles = 0;
}
static void
__im_component_info_finalize (IMPointer info)
{
IMComponentInfo *p = IM_COMPONENT_INFO (info);
-
_im_assert (p != 0);
-
- if (p->string_id)
- im_object_unref (p->string_id);
- if (p->name)
- im_object_unref (p->name);
- if (p->desc)
- im_object_unref (p->desc);
- if (p->icon)
- im_object_unref (p->icon);
- if (p->event_roles)
- im_object_unref (p->event_roles);
}
static void
@@ -80,13 +65,7 @@
_im_assert (dp && sp);
- __im_component_info_finalize (dest);
dp->unique_id = sp->unique_id;
- dp->string_id = (sp->string_id ? im_object_ref (sp->string_id) : 0);
- dp->name = (sp->name ? im_object_ref (sp->name) : 0);
- dp->desc = (sp->desc ? im_object_ref (sp->desc) : 0);
- dp->icon = (sp->icon ? im_object_ref (sp->icon) : 0);
- dp->event_roles = (sp->event_roles ? im_object_ref
(sp->event_roles) : 0);
/* Call copy method of parent class */
__im_component_info_parent_class->copy (dest, src);
@@ -106,41 +85,6 @@
if (!im_stream_put_uint32 (sp, cp->unique_id))
return FALSE;
- if (cp->string_id) {
- if (!im_stream_put_object (sp, cp->string_id))
- return FALSE;
- } else {
- if (!im_stream_put_void (sp))
- return FALSE;
- }
- if (cp->name) {
- if (!im_stream_put_object (sp, cp->name))
- return FALSE;
- } else {
- if (!im_stream_put_void (sp))
- return FALSE;
- }
- if (cp->desc) {
- if (!im_stream_put_object (sp, cp->desc))
- return FALSE;
- } else {
- if (!im_stream_put_void (sp))
- return FALSE;
- }
- if (cp->icon) {
- if (!im_stream_put_object (sp, cp->icon))
- return FALSE;
- } else {
- if (!im_stream_put_void (sp))
- return FALSE;
- }
- if (cp->event_roles) {
- if (!im_stream_put_object (sp, cp->event_roles))
- return FALSE;
- } else {
- if (!im_stream_put_void (sp))
- return FALSE;
- }
return TRUE;
}
@@ -157,81 +101,10 @@
if (!__im_component_info_parent_class->deserialize (obj, stream))
return FALSE;
- __im_component_info_finalize (obj);
type = im_stream_get_data_type (sp);
if (type != IM_TYPE_UINT32 || !im_stream_get_uint32 (sp, &cp->unique_id))
return FALSE;
- type = im_stream_get_data_type (sp);
- if (type == IM_TYPE_STRING) {
- cp->string_id = im_object_ref (im_object_new (type));
- if (!im_stream_get_object (sp, cp->string_id)) {
- im_object_unref (cp->string_id);
- cp->string_id = 0;
- return FALSE;
- }
- } else if (type == IM_TYPE_VOID) {
- cp->string_id = 0;
- if (!im_stream_get_void (sp))
- return FALSE;
- }
-
- type = im_stream_get_data_type (sp);
- if (type == IM_TYPE_STRING) {
- cp->name = im_object_ref (im_object_new (type));
- if (!im_stream_get_object (sp, cp->name)) {
- im_object_unref (cp->name);
- cp->name = 0;
- return FALSE;
- }
- } else if (type == IM_TYPE_VOID) {
- cp->name = 0;
- if (!im_stream_get_void (sp))
- return FALSE;
- }
-
- type = im_stream_get_data_type (sp);
- if (type == IM_TYPE_STRING) {
- cp->desc = im_object_ref (im_object_new (type));
- if (!im_stream_get_object (sp, cp->desc)) {
- im_object_unref (cp->desc);
- cp->desc = 0;
- return FALSE;
- }
- } else if (type == IM_TYPE_VOID) {
- cp->desc = 0;
- if (!im_stream_get_void (sp))
- return FALSE;
- }
-
- type = im_stream_get_data_type (sp);
- if (type == IM_TYPE_STRING) {
- cp->icon = im_object_ref (im_object_new (type));
- if (!im_stream_get_object (sp, cp->icon)) {
- im_object_unref (cp->icon);
- cp->icon = 0;
- return FALSE;
- }
- } else if (type == IM_TYPE_VOID) {
- cp->icon = 0;
- if (!im_stream_get_void (sp))
- return FALSE;
- }
-
- type = im_stream_get_data_type (sp);
- if (type == IM_TYPE_EVENT_ROLES) {
- cp->event_roles = im_object_ref (im_object_new (type));
- if (!im_stream_get_object (sp, cp->event_roles)) {
- im_object_unref (cp->event_roles);
- cp->event_roles = 0;
- return FALSE;
- }
- } else if (type == IM_TYPE_VOID) {
- cp->event_roles = 0;
- if (!im_stream_get_void (sp))
- return FALSE;
- }
-
return TRUE;
}
@@ -239,12 +112,20 @@
__im_component_info_class_init (IMPointer klass)
{
IMObjectClass *cp = (IMObjectClass *)klass;
+ IMComponentInfoClass *cicp = (IMComponentInfoClass *)klass;
cp->copy = __im_component_info_copy;
cp->serialize = __im_component_info_serialize;
cp->deserialize = __im_component_info_deserialize;
__im_component_info_parent_class = im_object_class_get_parent (cp);
+ __im_component_info_class = cicp;
+
+ cicp->qsid = im_quark_from_static_string (".s");
+ cicp->qname = im_quark_from_static_string (".n");
+ cicp->qdesc = im_quark_from_static_string (".d");
+ cicp->qicon = im_quark_from_static_string (".i");
+ cicp->qroles = im_quark_from_static_string (".r");
}
/************* Implementation of public functions ***************/
@@ -282,7 +163,7 @@
IMComponentInfo*
im_component_info_new_full (IMString *string_id, IMString *name,
- IMString *desc, IMString *icon_file,
+ IMString *desc, IMString *icon,
IMEventRoles *event_roles)
{
IMComponentInfo *info;
@@ -290,19 +171,27 @@
_im_return_val_if_fail (IM_IS_STRING(string_id) || !string_id, 0);
_im_return_val_if_fail (IM_IS_STRING(name) || !name, 0);
_im_return_val_if_fail (IM_IS_STRING(desc) || !desc, 0);
- _im_return_val_if_fail (IM_IS_STRING(icon_file) || !icon_file, 0);
+ _im_return_val_if_fail (IM_IS_STRING(icon) || !icon, 0);
_im_return_val_if_fail (IM_IS_EVENT_ROLES(event_roles) ||
!event_roles, 0);
info = (IMComponentInfo *)im_object_new (IM_TYPE_COMPONENT_INFO);
-
_im_assert (info);
- info->string_id = (string_id ? im_object_ref (string_id) : 0);
- info->name = (name ? im_object_ref (name) : 0);
- info->desc = (desc ? im_object_ref (desc) : 0);
- info->icon = (icon_file ? im_object_ref (icon_file) : 0);
- info->event_roles = (event_roles ? im_object_ref (event_roles) : 0);
-
+ if (string_id)
+ im_object_set_quark_attachment (info, __im_component_info_class->qsid,
+ string_id);
+ if (name)
+ im_object_set_quark_attachment (info, __im_component_info_class->qname,
+ name);
+ if (desc)
+ im_object_set_quark_attachment (info, __im_component_info_class->qdesc,
+ desc);
+ if (icon)
+ im_object_set_quark_attachment (info, __im_component_info_class->qicon,
+ icon);
+ if (event_roles)
+ im_object_set_quark_attachment (info, __im_component_info_class->qroles,
+ event_roles);
return info;
}
@@ -326,55 +215,97 @@
_im_return_if_fail (IM_IS_COMPONENT_INFO(info));
_im_return_if_fail (IM_IS_STRING(string_id) || !string_id);
- if (info->string_id)
- im_object_unref (info->string_id);
-
- info->string_id = (string_id ? im_object_ref (string_id) : 0);
+ if (string_id)
+ im_object_set_quark_attachment (info, __im_component_info_class->qsid,
+ string_id);
+ else
+ im_object_remove_quark_attachment (info, __im_component_info_class->qsid);
}
IMString*
im_component_info_get_string_id (IMComponentInfo *info)
{
_im_return_val_if_fail (IM_IS_COMPONENT_INFO(info), 0);
- return info->string_id;
+ return IM_STRING(
+ im_object_get_quark_attachment (info, __im_component_info_class->qsid));
}
void
-im_component_info_set_name (IMComponentInfo *info, IMString *name)
+im_component_info_set_name (IMComponentInfo *info, IMString *name,
+ const IMChar *lang)
{
+ IMQuark qkey;
_im_return_if_fail (IM_IS_COMPONENT_INFO(info));
_im_return_if_fail (IM_IS_STRING(name) || !name);
- if (info->name)
- im_object_unref (info->name);
+ if (lang && *lang) {
+ IMString *key = im_string_new_from_printf (".n.%s", lang);
+ qkey = im_quark_from_string (im_string_c_str (key));
+ im_object_unref (key);
+ } else {
+ qkey = __im_component_info_class->qname;
+ }
- info->name = (name ? im_object_ref (name) : 0);
+ if (name)
+ im_object_set_quark_attachment (info, qkey, name);
+ else
+ im_object_remove_quark_attachment (info, qkey);
}
IMString*
-im_component_info_get_name (IMComponentInfo *info)
+im_component_info_get_name (IMComponentInfo *info, const IMChar *lang)
{
+ IMQuark qkey;
_im_return_val_if_fail (IM_IS_COMPONENT_INFO(info), 0);
- return info->name;
+
+ if (lang && *lang) {
+ IMString *key = im_string_new_from_printf (".n.%s", lang);
+ qkey = im_quark_from_string (im_string_c_str (key));
+ im_object_unref (key);
+ } else {
+ qkey = __im_component_info_class->qname;
+ }
+
+ return IM_STRING(im_object_get_quark_attachment (info, qkey));
}
void
-im_component_info_set_description (IMComponentInfo *info, IMString *desc)
+im_component_info_set_description (IMComponentInfo *info, IMString *desc,
+ const IMChar *lang)
{
+ IMQuark qkey;
_im_return_if_fail (IM_IS_COMPONENT_INFO(info));
_im_return_if_fail (IM_IS_STRING(desc) || !desc);
- if (info->desc)
- im_object_unref (info->desc);
+ if (lang && *lang) {
+ IMString *key = im_string_new_from_printf (".d.%s", lang);
+ qkey = im_quark_from_string (im_string_c_str (key));
+ im_object_unref (key);
+ } else {
+ qkey = __im_component_info_class->qdesc;
+ }
- info->desc = (desc ? im_object_ref (desc) : 0);
+ if (desc)
+ im_object_set_quark_attachment (info, qkey, desc);
+ else
+ im_object_remove_quark_attachment (info, qkey);
}
IMString*
-im_component_info_get_desc (IMComponentInfo *info)
+im_component_info_get_description (IMComponentInfo *info, const IMChar *lang)
{
+ IMQuark qkey;
_im_return_val_if_fail (IM_IS_COMPONENT_INFO(info), 0);
- return info->desc;
+
+ if (lang && *lang) {
+ IMString *key = im_string_new_from_printf (".d.%s", lang);
+ qkey = im_quark_from_string (im_string_c_str (key));
+ im_object_unref (key);
+ } else {
+ qkey = __im_component_info_class->qdesc;
+ }
+
+ return IM_STRING(im_object_get_quark_attachment (info, qkey));
}
void
@@ -383,17 +314,19 @@
_im_return_if_fail (IM_IS_COMPONENT_INFO(info));
_im_return_if_fail (IM_IS_STRING(icon) || !icon);
- if (info->icon)
- im_object_unref (info->icon);
-
- info->icon = (icon ? im_object_ref (icon) : 0);
+ if (icon)
+ im_object_set_quark_attachment (info, __im_component_info_class->qicon,
+ icon);
+ else
+ im_object_remove_quark_attachment (info, __im_component_info_class->qicon);
}
IMString*
im_component_info_get_icon (IMComponentInfo *info)
{
_im_return_val_if_fail (IM_IS_COMPONENT_INFO(info), 0);
- return info->icon;
+ return IM_STRING(
+ im_object_get_quark_attachment (info, __im_component_info_class->qicon));
}
void
@@ -403,17 +336,32 @@
_im_return_if_fail (IM_IS_COMPONENT_INFO(info));
_im_return_if_fail (IM_IS_EVENT_ROLES(event_roles) || !event_roles);
- if (info->event_roles)
- im_object_unref (info->event_roles);
-
- info->event_roles = (event_roles ? im_object_ref (event_roles) : 0);
+ if (event_roles)
+ im_object_set_quark_attachment (info, __im_component_info_class->qroles,
+ event_roles);
+ else
+ im_object_remove_quark_attachment (info, __im_component_info_class->qroles);
}
IMEventRoles*
im_component_info_get_event_roles (IMComponentInfo *info)
{
_im_return_val_if_fail (IM_IS_COMPONENT_INFO(info), 0);
- return info->event_roles;
+ return IM_EVENT_ROLES(
+ im_object_get_quark_attachment (info, __im_component_info_class->qroles));
+}
+
+void
+im_component_info_set_languages (IMComponentInfo *info, IMString *langs)
+{
+ /* TODO */
+}
+
+IMString*
+im_component_info_get_languages (IMComponentInfo *info)
+{
+ /* TODO */
+ return 0;
}
/*
Modified: trunk/imbus/src/im_component_info.h
==============================================================================
--- trunk/imbus/src/im_component_info.h (original)
+++ trunk/imbus/src/im_component_info.h Sun Nov 25 02:34:13 2007
@@ -72,10 +72,12 @@
* @param string_id Unique string id of the component
* @param name Human readable name of the component, must be in UTF-8
* encoding. The ownership of this object will be
assumed by
- * the newly created IMComponentInfo object.
+ * the newly created IMComponentInfo object. It's the
+ * default name without specified language tag.
* @param desc Human readable description of the component,
must be in UTF-8
* encoding. The ownership of this object will be
assumed by
- * the newly created IMComponentInfo object.
+ * the newly created IMComponentInfo object. It's the
+ * default description without specified language tag.
* @param icon_file Path to icon file of the component. The
ownership of this
* object will be assumed by the newly created
* IMComponentInfo object.
@@ -151,9 +153,12 @@
* @param name An IMString object contains the new human readable name.
* The ownership of this object will be assumed by the
* specified IMComponentInfo object.
+ * @param lang A language tag associated to the specified name. NULL means
+ * the default name.
*/
void im_component_info_set_name (IMComponentInfo
*info,
- IMString
*name);
+ IMString
*name,
+ const IMChar
*lang);
/**
* @brief Gets component's human readable name stored in a specified
@@ -161,6 +166,8 @@
*
* @param info Pointer to an IMComponentInfo object, of which the name
* will be returned.
+ * @param lang A language tag of which the associated name to be retrieved.
+ * NULL means the default name shall be retrieved..
* @return The component's human readable name stored in the specified
* IMComponentInfo object.
* The returned IMString object is owned by the specified
@@ -168,7 +175,8 @@
* object, a reference of the object must be assumed by the caller.
* Caller shall not change the value of returned object.
*/
-IMString* im_component_info_get_name (IMComponentInfo
*info);
+IMString* im_component_info_get_name (IMComponentInfo
*info,
+ const IMChar
*lang);
/**
* @brief Sets component's human readable description stored in a specified
@@ -179,9 +187,12 @@
* @param desc An IMString object contains the new human readable description.
* The ownership of this object will be assumed by the
* specified IMComponentInfo object.
+ * @param lang A language tag associated to the specified description. NULL
+ * means the default description.
*/
void im_component_info_set_description(IMComponentInfo
*info,
- IMString
*desc);
+ IMString
*desc,
+ const IMChar
*lang);
/**
* @brief Gets component's human readable description stored in a specified
@@ -189,6 +200,8 @@
*
* @param info Pointer to an IMComponentInfo object, of which the description
* will be returned.
+ * @param lang A language tag of which the associated name to be retrieved.
+ * NULL means the default description shall be retrieved..
* @return The component's human readable description stored in the specified
* IMComponentInfo object.
* The returned IMString object is owned by the specified
@@ -196,7 +209,8 @@
* object, a reference of the object must be assumed by the caller.
* Caller shall not change the value of returned object.
*/
-IMString* im_component_info_get_description(IMComponentInfo
*info);
+IMString* im_component_info_get_description(IMComponentInfo
*info,
+ const IMChar
*lang);
/**
* @brief Sets component's icon file stored in a specified IMComponentInfo
@@ -251,6 +265,35 @@
* Caller shall not change the value of returned object.
*/
IMEventRoles* im_component_info_get_event_roles(IMComponentInfo
*info);
+
+/**
+ * @brief Sets component's supported languages to a specified IMComponentInfo
+ * object.
+ *
+ * @param info Pointer to an IMComponentInfo object, for which the supported
+ * languages will be set.
+ * @param langs An IMString object contains a list of supported languages.
+ * The ownership of this object will be assumed by the
+ * specified IMComponentInfo object.
+ * The language tag shall be in format "en-us", multiple
tags are
+ * separated by comma.
+ */
+void im_component_info_set_languages (IMComponentInfo
*info,
+ IMString
*langs);
+
+/**
+ * @brief Gets component's supported languages from a specified IMComponentInfo
+ * object.
+ *
+ * @param info Pointer to an IMComponentInfo object, of which the supported
+ * languages will be returned.
+ * @return The component's supported languages. The returned IMString object
+ * is owned by the specified IMComponentInfo object, if caller wants
+ * to keep the returned object, a reference of the object must be
+ * assumed by the caller. Caller shall not change the value of returned
+ * object.
+ */
+IMString* im_component_info_get_languages (IMComponentInfo
*info);
IM_END_DECLS
Modified: trunk/imbus/src/im_object.c
==============================================================================
--- trunk/imbus/src/im_object.c (original)
+++ trunk/imbus/src/im_object.c Sun Nov 25 02:34:13 2007
@@ -13,7 +13,7 @@
{
/**< private >**/
IMInt refcount;
- IMDataList *children;
+ IMDataList *attachments;
};
/* ============================= Internal func
============================= */
@@ -44,7 +44,7 @@
/* initially floating. */
p->impl->refcount = -1;
- im_datalist_init (&p->impl->children);
+ im_datalist_init (&p->impl->attachments);
}
static void
@@ -56,39 +56,39 @@
_im_verbose ("%p: <-dtor\n", obj);
#endif
- im_datalist_clear (&p->impl->children);
+ im_datalist_clear (&p->impl->attachments);
im_slice_delete(IMObjectImpl, p->impl);
}
static IMBool
-__foreach_copy_children (IMQuark key_id, IMPointer child, IMPointer object)
+__foreach_copy_attachments (IMQuark key_id, IMPointer att, IMPointer object)
{
- im_object_attach_quark_child (object, key_id, im_object_clone (child));
+ im_object_set_quark_attachment (object, key_id, im_object_clone (att));
return TRUE;
}
static void
__im_object_copy (IMPointer dest, IMConstPointer src)
{
- im_datalist_clear (&((IMObject*)dest)->impl->children);
- im_datalist_foreach (&((IMObject*)src)->impl->children,
__foreach_copy_children, dest);
+ im_datalist_clear (&((IMObject*)dest)->impl->attachments);
+ im_datalist_foreach (&((IMObject*)src)->impl->attachments,
__foreach_copy_attachments, dest);
}
static IMBool
-__foreach_serialize_children (IMQuark key_id, IMPointer child,
IMPointer stream)
+__foreach_serialize_attachments (IMQuark key_id, IMPointer att,
IMPointer stream)
{
return im_stream_put_c_string ((IMStream*)stream,
im_quark_to_string (key_id), -1) &&
- im_stream_put_object ((IMStream*)stream, child);
+ im_stream_put_object ((IMStream*)stream, att);
}
static IMBool
__im_object_serialize (IMConstPointer obj, IMPointer stream)
{
- IMSize len = im_datalist_length (&((const IMObject*)obj)->impl->children);
+ IMSize len = im_datalist_length (&((const IMObject*)obj)->impl->attachments);
if (len) {
- /* serialize all children */
+ /* serialize all attachments */
im_stream_put_uint32 ((IMStream*)stream, len);
- return im_datalist_foreach (&((const IMObject*)obj)->impl->children,
- __foreach_serialize_children,
+ return im_datalist_foreach (&((const IMObject*)obj)->impl->attachments,
+ __foreach_serialize_attachments,
stream);
} else {
return im_stream_put_void ((IMStream*)stream);
@@ -109,7 +109,7 @@
return FALSE;
while (len) {
- IMPointer child;
+ IMPointer att;
IMSize key_len;
IMType type;
@@ -136,19 +136,19 @@
if (!IM_TYPE_IS_OBJECT(type))
break;
- child = im_object_new (type);
+ att = im_object_new (type);
- _im_assert (child);
+ _im_assert (att);
- if (!im_stream_get_object (stream, child)) {
- im_object_unref (child);
+ if (!im_stream_get_object (stream, att)) {
+ im_object_unref (att);
break;
}
- /* The ownership of child will be assumed by
+ /* The ownership of att will be assumed by
* this method.
*/
- im_object_attach_child (obj, key, child);
+ im_object_set_attachment (obj, key, att);
-- len;
}
@@ -419,70 +419,70 @@
}
void
-im_object_attach_child (IMPointer object, const IMChar *key, IMPointer child)
+im_object_set_attachment (IMPointer object, const IMChar *key,
IMPointer att)
{
_im_return_if_fail (im_object_valid (object));
- _im_return_if_fail (im_object_valid (child));
+ _im_return_if_fail (im_object_valid (att));
_im_return_if_fail (key && *key);
- im_object_ref (child);
+ im_object_ref (att);
- im_datalist_set_data_full (&((IMObject*)object)->impl->children,
+ im_datalist_set_data_full (&((IMObject*)object)->impl->attachments,
key,
- child,
+ att,
im_object_unref);
}
IMPointer
-im_object_get_child (IMConstPointer object, const IMChar *key)
+im_object_get_attachment (IMConstPointer object, const IMChar *key)
{
_im_return_val_if_fail (im_object_valid (object), 0);
_im_return_val_if_fail (key && *key, 0);
- return im_datalist_get_data (&((const
IMObject*)object)->impl->children, key);
+ return im_datalist_get_data (&((const
IMObject*)object)->impl->attachments, key);
}
void
-im_object_remove_child (IMPointer object, const IMChar *key)
+im_object_remove_attachment (IMPointer object, const IMChar *key)
{
_im_return_if_fail (im_object_valid (object));
_im_return_if_fail (key && *key);
- im_datalist_remove_data (&((IMObject*)object)->impl->children, key);
+ im_datalist_remove_data (&((IMObject*)object)->impl->attachments, key);
}
void
-im_object_attach_quark_child (IMPointer object, IMQuark quark,
IMPointer child)
+im_object_set_quark_attachment (IMPointer object, IMQuark quark,
IMPointer att)
{
_im_return_if_fail (im_object_valid (object));
- _im_return_if_fail (im_object_valid (child));
+ _im_return_if_fail (im_object_valid (att));
_im_return_if_fail (quark > 0);
- im_object_ref (child);
+ im_object_ref (att);
- im_datalist_id_set_data_full (&((IMObject*)object)->impl->children,
+ im_datalist_id_set_data_full (&((IMObject*)object)->impl->attachments,
quark,
- child,
+ att,
im_object_unref);
}
IMPointer
-im_object_get_quark_child (IMConstPointer object, IMQuark quark)
+im_object_get_quark_attachment (IMConstPointer object, IMQuark quark)
{
_im_return_val_if_fail (im_object_valid (object), 0);
- return im_datalist_id_get_data (&((const
IMObject*)object)->impl->children, quark);
+ return im_datalist_id_get_data (&((const
IMObject*)object)->impl->attachments, quark);
}
void
-im_object_remove_quark_child (IMPointer object, IMQuark quark)
+im_object_remove_quark_attachment (IMPointer object, IMQuark quark)
{
_im_return_if_fail (im_object_valid (object));
if (!quark)
return;
- im_datalist_id_remove_data (&((IMObject*)object)->impl->children, quark);
+ im_datalist_id_remove_data
(&((IMObject*)object)->impl->attachments, quark);
}
/*
Modified: trunk/imbus/src/im_object.h
==============================================================================
--- trunk/imbus/src/im_object.h (original)
+++ trunk/imbus/src/im_object.h Sun Nov 25 02:34:13 2007
@@ -249,7 +249,7 @@
*
* This function will only call serialize method of the object's class.
*
- * serialize method of its parent class should be called inside its own
+ * serialize method of its parent class should be called inside its own
* serialize method, so that data member of its parent class can be
* serialized correctly.
*
@@ -319,75 +319,76 @@
/**
* @brief Attach an object to another object with specified string key.
*
- * An object can have one or more child objects attached. Each child
+ * An object can have one or more objects attached. Each attached
* object is associated with a specified key, so that it can be
* retrieved by the key later.
*
* @param object The parent object.
- * @param key The string key to be associated to the child object.
- * @param child The child object. It'll just be referenced by the
+ * @param key The string key to be associated to the attached object.
It shall
+ * not start with dot ('.').
+ * @param att The attached object. It'll just be referenced by the
* parent object, rather than making a copy.
*/
-void im_object_attach_child (IMPointer object,
+void im_object_set_attachment (IMPointer object,
const IMChar *key,
- IMPointer child);
+ IMPointer att);
/**
- * @brief Return the child object with specified key of an object.
+ * @brief Return an attached object with specified key of an object.
*
* @param object The parent object.
- * @param key Key of the child object to be retrieved.
- * @return The child object, or NULL if there is no child object for that
+ * @param key Key of the attached object to be retrieved.
+ * @return The attached object, or NULL if there is no object for that
* key.
*/
-IMPointer im_object_get_child (IMConstPointer object,
+IMPointer im_object_get_attachment (IMConstPointer object,
const IMChar *key);
/**
- * @brief Remove a child object with specified key of an object.
+ * @brief Remove a attached object with specified key of an object.
*
* @param object The parent object.
- * @param key Key of the child object to be removed.
+ * @param key Key of the attached object to be removed.
*/
-void im_object_remove_child (IMPointer object,
+void im_object_remove_attachment (IMPointer object,
const IMChar *key);
/**
* @brief Attach an object to another object with specified quark key.
*
- * Just like im_object_attach_child(), but use a IMQuark instead of
+ * Just like im_object_set_attachment (), but use a IMQuark instead of
* a string key.
*
* @param object The parent object.
- * @param quark The IMQuark to be associated to the child object.
- * @param child The child object. It'll just be referenced by the
+ * @param quark The IMQuark to be associated to the attached object.
+ * @param att The object to be attached. It'll just be referenced by the
* parent object, rather than making a copy.
*/
-void im_object_attach_quark_child(IMPointer object,
- IMQuark quark,
- IMPointer child);
+void im_object_set_quark_attachment(IMPointer object,
+ IMQuark quark,
+ IMPointer att);
/**
- * @brief Return the child object with specified quark key of an object.
+ * @brief Return the attached object with specified quark key of an object.
*
- * Just like im_object_get_child(), but use a IMQuark instead of a
+ * Just like im_object_get_attachment(), but use a IMQuark instead of a
* string key.
*
* @param object The parent object.
- * @param quark IMQuark of the child object to be retrieved.
- * @return The child object, or NULL if there is no child object for that
+ * @param quark IMQuark of the attached object to be retrieved.
+ * @return The attached object, or NULL if there is no object for that
* key.
*/
-IMPointer im_object_get_quark_child (IMConstPointer object,
- IMQuark quark);
+IMPointer im_object_get_quark_attachment(IMConstPointer object,
+ IMQuark quark);
/**
- * @brief Remove a child object with specified quark key of an object.
+ * @brief Remove an attached object with specified quark key of an object.
*
- * Just like im_object_remove_child(), but use a IMQuark instead.
+ * Just like im_object_remove_attachment(), but use a IMQuark instead.
*
* @param object The parent object.
- * @param quark IMQuark of the child object to be removed.
+ * @param quark IMQuark of the attached object to be removed.
*/
-void im_object_remove_quark_child(IMPointer object,
- IMQuark quark);
+void im_object_remove_quark_attachment(IMPointer object,
+ IMQuark quark);
IM_END_DECLS
#endif
Modified: trunk/imbus/src/im_quark.h
==============================================================================
--- trunk/imbus/src/im_quark.h (original)
+++ trunk/imbus/src/im_quark.h Sun Nov 25 02:34:13 2007
@@ -112,7 +112,7 @@
* comparing the pointers, instead of using strcmp().
*
* TODO
- * The im_intern_string() function
+ * The im_intern_string() function
* The string pointed to by the return value shall not be modified or freed.
* @param string a string
* @return a canonical representation for the string.
@@ -124,7 +124,7 @@
* comparing the pointers, instead of using strcmp().
*
* TODO
- * The im_intern_static_string() function
+ * The im_intern_static_string() function
* im_intern_static_string() does not copy the string, therefore
* string must not be freed or modified.
*
Modified: trunk/imbus/src/im_string.h
==============================================================================
--- trunk/imbus/src/im_string.h (original)
+++ trunk/imbus/src/im_string.h Sun Nov 25 02:34:13 2007
@@ -769,7 +769,7 @@
/**
* @brief Convert all alphabet characters in a specified range
* of a string to uppercase.
- *
+ *
* @param string an IMString object to converted.
* @param pos the start position of the string.
* @param len the number of charator to converted for the start position.
@@ -782,7 +782,7 @@
/**
* @brief Remove blank characters at the begin and end of a string.
- *
+ *
* @param string an IMString object to converted.
*
* @return void.
@@ -792,7 +792,7 @@
/**
* @brief Split the specified string into sub strings by one of given delimiter
* chars.
- *
+ *
* @param string an IMString object to be splitted.
* @param delim_chars given delimiter chars
*
Modified: trunk/imbus/src/im_type.c
==============================================================================
--- trunk/imbus/src/im_type.c (original)
+++ trunk/imbus/src/im_type.c Sun Nov 25 02:34:13 2007
@@ -220,7 +220,7 @@
__add_to_type_name_repo (slot->qname, type);
}
-/**
+/**
* If type == 0, then it's an user defined class. otherwise, it's a
builtin class.
*/
static IMType
Modified: trunk/imbus/tests/test_byte_stream.c
==============================================================================
--- trunk/imbus/tests/test_byte_stream.c (original)
+++ trunk/imbus/tests/test_byte_stream.c Sun Nov 25 02:34:13 2007
@@ -27,6 +27,8 @@
IMProperty *prop;
IMIOChannel *channel_out;
IMInt i;
+ IMEventRoles *roles;
+ IMComponentInfo *info;
IMInt32 int32dim [10] = {1,2,3,4,5,6,7,8,9,10};
@@ -168,9 +170,9 @@
im_stream_put_object (stream, text);
- im_object_attach_child (table, "A Text Label",
im_text_new_from_utf8_string ("This is a LookupTable.", -1));
- im_object_attach_child (table, "A Circle", circle_new (111, 222, 333));
- im_object_attach_child (table, "A String",
im_string_new_from_text_utf8 (text));
+ im_object_set_attachment (table, "A Text Label",
im_text_new_from_utf8_string ("This is a LookupTable.", -1));
+ im_object_set_attachment (table, "A Circle", circle_new (111, 222, 333));
+ im_object_set_attachment (table, "A String",
im_string_new_from_text_utf8 (text));
im_stream_put_object (stream, table);
@@ -253,6 +255,24 @@
im_stream_put_object (stream, proplist);
+ roles = im_event_roles_new ();
+
+ im_event_roles_set (roles, IM_EVENT_REGISTER_COMPONENT, IM_EVENT_ROLE_PRODUCER);
+ im_event_roles_set (roles, IM_EVENT_DEREGISTER_COMPONENT, IM_EVENT_ROLE_PRODUCER);
+ im_event_roles_set (roles, IM_EVENT_PROCESS_KEY_EVENT, IM_EVENT_ROLE_CONSUMER);
+ im_event_roles_set (roles, IM_EVENT_UPDATE_SPOT_LOCATION, IM_EVENT_ROLE_OBSERVER);
+
+ info = im_component_info_new_full (im_string_new_static ("org.imbus.foo"),
+ im_string_new_static ("Test Component"),
+ im_string_new_static ("Just a test"),
+ im_string_new_static ("file://org.imbus.foo/foo.png"),
+ roles);
+ im_component_info_set_unique_id (info, 12345);
+ im_component_info_set_name (info, im_string_new_static ("中文名字"), "zh-cn");
+ im_component_info_set_description (info, im_string_new_static ("中
文说明"), "zh-cn");
+
+ im_stream_put_object (stream, info);
+
im_stream_write (stream, channel_out, 0, 0);
im_object_unref (array);
@@ -261,6 +281,7 @@
im_object_unref (proplist);
im_object_unref (stream);
im_object_unref (channel_out);
+ im_object_unref (info);
}
#define GET_FUNDAMENTAL_VALUE(stream,strtype,type,fmt) \
Modified: trunk/imbus/tests/test_text_stream.c
==============================================================================
--- trunk/imbus/tests/test_text_stream.c (original)
+++ trunk/imbus/tests/test_text_stream.c Sun Nov 25 02:34:13 2007
@@ -26,6 +26,8 @@
IMPropList *subproplist;
IMProperty *prop;
IMIOChannel *channel_out;
+ IMEventRoles *roles;
+ IMComponentInfo *info;
IMInt32 int32dim [10] = {1,2,3,4,5,6,7,8,9,10};
@@ -167,9 +169,9 @@
im_stream_put_object (stream, text);
- im_object_attach_child (table, "A Text Label",
im_text_new_from_utf8_string ("This is a LookupTable.", -1));
- im_object_attach_child (table, "A Circle", circle_new (111, 222, 333));
- im_object_attach_child (table, "A String",
im_string_new_from_text_utf8 (text));
+ im_object_set_attachment (table, "A Text Label",
im_text_new_from_utf8_string ("This is a LookupTable.", -1));
+ im_object_set_attachment (table, "A Circle", circle_new (111, 222, 333));
+ im_object_set_attachment (table, "A String",
im_string_new_from_text_utf8 (text));
im_stream_put_object (stream, table);
@@ -252,6 +254,24 @@
im_stream_put_object (stream, proplist);
+ roles = im_event_roles_new ();
+
+ im_event_roles_set (roles, IM_EVENT_REGISTER_COMPONENT, IM_EVENT_ROLE_PRODUCER);
+ im_event_roles_set (roles, IM_EVENT_DEREGISTER_COMPONENT, IM_EVENT_ROLE_PRODUCER);
+ im_event_roles_set (roles, IM_EVENT_PROCESS_KEY_EVENT, IM_EVENT_ROLE_CONSUMER);
+ im_event_roles_set (roles, IM_EVENT_UPDATE_SPOT_LOCATION, IM_EVENT_ROLE_OBSERVER);
+
+ info = im_component_info_new_full (im_string_new_static ("org.imbus.foo"),
+ im_string_new_static ("Test Component"),
+ im_string_new_static ("Just a test"),
+ im_string_new_static ("file://org.imbus.foo/foo.png"),
+ roles);
+ im_component_info_set_unique_id (info, 12345);
+ im_component_info_set_name (info, im_string_new_static ("中文名字"), "zh-cn");
+ im_component_info_set_description (info, im_string_new_static ("中
文说明"), "zh-cn");
+
+ im_stream_put_object (stream, info);
+
string = im_string_new_static ("quit");
im_stream_put_object (stream, string);
im_object_unref (string);
@@ -264,6 +284,7 @@
im_object_unref (proplist);
im_object_unref (stream);
im_object_unref (channel_out);
+ im_object_unref (info);
}
#define GET_FUNDAMENTAL_VALUE(stream,strtype,type,fmt) \