aboutsummaryrefslogtreecommitdiffhomepage
path: root/function.c
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2005-10-06 08:37:08 +1000
committerGravatar axel <axel@liljencrantz.se>2005-10-06 08:37:08 +1000
commitb9b841f60319fb5838060cb724a4882ef3be9a74 (patch)
treeabc72116fe9878b2356957c624eb6b235af20148 /function.c
parentb065bd6282f8facfa229e250d693ac43c9eb84b2 (diff)
Initial update for new event subsystem
darcs-hash:20051005223708-ac50b-8a8d7e003e1c24747f3f154cb66b6c1a1015c35b.gz
Diffstat (limited to 'function.c')
-rw-r--r--function.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/function.c b/function.c
index b71eab88..c57760e4 100644
--- a/function.c
+++ b/function.c
@@ -15,11 +15,8 @@
#include "parser.h"
#include "common.h"
#include "intern.h"
+#include "event.h"
-/**
- Table containing all functions
-*/
-static hash_table_t function;
/**
Struct describing a function
@@ -32,7 +29,12 @@ typedef struct
wchar_t *desc;
int is_binding;
}
-function_data_t;
+ function_data_t;
+
+/**
+ Table containing all functions
+*/
+static hash_table_t function;
/**
Free all contents of an entry to the function hash table
@@ -62,8 +64,11 @@ void function_destroy()
void function_add( const wchar_t *name,
const wchar_t *val,
const wchar_t *desc,
- int is_binding)
+ array_list_t *events,
+ int is_binding )
{
+ int i;
+
if( function_exists( name ) )
function_remove( name );
@@ -72,6 +77,12 @@ void function_add( const wchar_t *name,
d->desc = desc?wcsdup( desc ):0;
d->is_binding = is_binding;
hash_put( &function, intern(name), d );
+
+ for( i=0; i<al_get_count( events ); i++ )
+ {
+ event_add_handler( (event_t *)al_get( events, i ) );
+ }
+
}
int function_exists( const wchar_t *cmd )
@@ -84,6 +95,11 @@ void function_remove( const wchar_t *name )
void *key;
function_data_t *d;
+ event_t ev;
+ ev.type=EVENT_ANY;
+ ev.function_name=name;
+ event_remove( &ev );
+
hash_remove( &function,
name,
(const void **) &key,
@@ -146,3 +162,4 @@ void function_get_names( array_list_t *list, int get_hidden )
hash_foreach2( &function, &get_names_internal, list );
}
+