diff options
author | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2013-05-26 08:44:02 +0000 |
---|---|---|
committer | martin-s <martin-s@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2013-05-26 08:44:02 +0000 |
commit | 1298062f2e9484e1ee20e1ec9717e562409120b2 (patch) | |
tree | e9b601f8ca687d5d592e15a9a8ae3d02da47c080 /navit/speech.c | |
parent | 4acd82ad52253a31987d5e1342b521f44b96b1ac (diff) | |
download | navit-1298062f2e9484e1ee20e1ec9717e562409120b2.tar.gz |
Fix:Core:Coding standard and converted speech to new scheme
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@5507 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/speech.c')
-rw-r--r-- | navit/speech.c | 37 |
1 files changed, 27 insertions, 10 deletions
diff --git a/navit/speech.c b/navit/speech.c index 1dbe40535..8b03f3c4b 100644 --- a/navit/speech.c +++ b/navit/speech.c @@ -23,11 +23,12 @@ #include "item.h" #include "speech.h" #include "plugin.h" +#include "xmlconfig.h" struct speech { + NAVIT_OBJECT; struct speech_priv *priv; struct speech_methods meth; - struct attr **attrs; }; @@ -50,14 +51,12 @@ speech_new(struct attr *parent, struct attr **attrs) dbg(0,"wrong type '%s'\n", attr->u.str); return NULL; } - this_=g_new0(struct speech, 1); - this_->priv=speech_new(&this_->meth, attrs, parent); - this_->attrs=attr_list_dup(attrs); + this_=(struct speech *)navit_object_new(attrs, &speech_func, sizeof(struct speech)); + this_->priv=speech_new(&this_->meth, this_->attrs, parent); dbg(1, "say=%p\n", this_->meth.say); dbg(1,"priv=%p\n", this_->priv); if (! this_->priv) { - attr_list_free(this_->attrs); - g_free(this_); + speech_destroy(this_); return NULL; } dbg(1,"return %p\n", this_); @@ -68,9 +67,9 @@ speech_new(struct attr *parent, struct attr **attrs) void speech_destroy(struct speech *this_) { - this_->meth.destroy(this_->priv); - attr_list_free(this_->attrs); - g_free(this_); + if (this_->priv) + this_->meth.destroy(this_->priv); + navit_object_destroy((struct navit_object *)this_); } int @@ -80,8 +79,9 @@ speech_say(struct speech *this_, const char *text) return (this_->meth.say)(this_->priv, text); } +struct attr active=ATTR_INT(active, 1); struct attr *speech_default_attrs[]={ - ATTR_DEF_INT(active, 1), + &active, NULL, }; @@ -146,3 +146,20 @@ speech_set_attr(struct speech *this_, struct attr *attr) //callback_list_call_attr_2(this_->attr_cbl, attr->type, this_, attr); return 1; } + +struct object_func speech_func = { + attr_speech, + (object_func_new)speech_new, + (object_func_get_attr)speech_get_attr, + (object_func_iter_new)navit_object_attr_iter_new, + (object_func_iter_destroy)navit_object_attr_iter_destroy, + (object_func_set_attr)speech_set_attr, + (object_func_add_attr)navit_object_add_attr, + (object_func_remove_attr)navit_object_remove_attr, + (object_func_init)NULL, + (object_func_destroy)speech_destroy, + (object_func_dup)NULL, + (object_func_ref)navit_object_ref, + (object_func_unref)navit_object_unref, +}; + |