Migrated credential_factory to INIT/METHOD macros

This commit is contained in:
Martin Willi
2010-09-02 10:49:02 +02:00
parent 4171cbd60b
commit b019136596
@@ -68,12 +68,9 @@ struct entry_t {
builder_function_t constructor; builder_function_t constructor;
}; };
/** METHOD(credential_factory_t, add_builder, void,
* Implementation of credential_factory_t.add_builder_constructor. private_credential_factory_t *this, credential_type_t type, int subtype,
*/ builder_function_t constructor)
static void add_builder(private_credential_factory_t *this,
credential_type_t type, int subtype,
builder_function_t constructor)
{ {
entry_t *entry = malloc_thing(entry_t); entry_t *entry = malloc_thing(entry_t);
@@ -85,11 +82,8 @@ static void add_builder(private_credential_factory_t *this,
this->lock->unlock(this->lock); this->lock->unlock(this->lock);
} }
/** METHOD(credential_factory_t, remove_builder, void,
* Implementation of credential_factory_t.remove_builder. private_credential_factory_t *this, builder_function_t constructor)
*/
static void remove_builder(private_credential_factory_t *this,
builder_function_t constructor)
{ {
enumerator_t *enumerator; enumerator_t *enumerator;
entry_t *entry; entry_t *entry;
@@ -108,11 +102,8 @@ static void remove_builder(private_credential_factory_t *this,
this->lock->unlock(this->lock); this->lock->unlock(this->lock);
} }
/** METHOD(credential_factory_t, create, void*,
* Implementation of credential_factory_t.create. private_credential_factory_t *this, credential_type_t type, int subtype, ...)
*/
static void* create(private_credential_factory_t *this, credential_type_t type,
int subtype, ...)
{ {
enumerator_t *enumerator; enumerator_t *enumerator;
entry_t *entry; entry_t *entry;
@@ -158,10 +149,8 @@ static void* create(private_credential_factory_t *this, credential_type_t type,
return construct; return construct;
} }
/** METHOD(credential_factory_t, destroy, void,
* Implementation of credential_factory_t.destroy private_credential_factory_t *this)
*/
static void destroy(private_credential_factory_t *this)
{ {
this->constructors->destroy_function(this->constructors, free); this->constructors->destroy_function(this->constructors, free);
this->recursive->destroy(this->recursive); this->recursive->destroy(this->recursive);
@@ -174,16 +163,19 @@ static void destroy(private_credential_factory_t *this)
*/ */
credential_factory_t *credential_factory_create() credential_factory_t *credential_factory_create()
{ {
private_credential_factory_t *this = malloc_thing(private_credential_factory_t); private_credential_factory_t *this;
this->public.create = (void*(*)(credential_factory_t*, credential_type_t type, int subtype, ...))create; INIT(this,
this->public.add_builder = (void(*)(credential_factory_t*,credential_type_t type, int subtype, builder_function_t constructor))add_builder; .public = {
this->public.remove_builder = (void(*)(credential_factory_t*,builder_function_t constructor))remove_builder; .create = _create,
this->public.destroy = (void(*)(credential_factory_t*))destroy; .add_builder = _add_builder,
.remove_builder = _remove_builder,
this->constructors = linked_list_create(); .destroy = _destroy,
this->recursive = thread_value_create(NULL); },
this->lock = rwlock_create(RWLOCK_TYPE_DEFAULT); .constructors = linked_list_create(),
.recursive = thread_value_create(NULL),
.lock = rwlock_create(RWLOCK_TYPE_DEFAULT),
);
return &this->public; return &this->public;
} }