Excised some more halloc and array_list_t

This commit is contained in:
ridiculousfish 2012-02-08 02:34:31 -08:00
parent b2e5809180
commit 3dc56de0ae
4 changed files with 18 additions and 21 deletions

View File

@ -1456,8 +1456,7 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
int argc = builtin_count_args( argv );
int res=STATUS_BUILTIN_OK;
wchar_t *desc=0;
array_list_t *events;
int i;
std::vector<event_t *> events;
array_list_t *named_arguments=0;
wchar_t *name = 0;
int shadows = 1;
@ -1465,7 +1464,6 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
woptind=0;
parser.push_block( FUNCTION_DEF );
events=al_halloc( parser.current_block );
static const struct woption
long_options[] =
@ -1562,7 +1560,7 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
e->type = EVENT_SIGNAL;
e->param1.signal = sig;
e->function_name=0;
al_push( events, e );
events.push_back(e);
break;
}
@ -1585,7 +1583,7 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
e->type = EVENT_VARIABLE;
e->param1.variable = halloc_wcsdup( parser.current_block, woptarg );
e->function_name=0;
al_push( events, e );
events.push_back(e);
break;
}
@ -1599,7 +1597,7 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
e->type = EVENT_GENERIC;
e->param1.param = halloc_wcsdup( parser.current_block, woptarg );
e->function_name=0;
al_push( events, e );
events.push_back(e);
break;
}
@ -1675,7 +1673,7 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
else
{
e->function_name=0;
al_push( events, e );
events.push_back(e);
}
break;
}
@ -1806,9 +1804,9 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
d->named_arguments = named_arguments;
d->shadows = shadows;
for( i=0; i<al_get_count( events ); i++ )
for( size_t i=0; i<events.size(); i++ )
{
event_t *e = (event_t *)al_get( events, i );
event_t *e = events.at(i);
e->function_name = d->name;
}

View File

@ -13,6 +13,7 @@
#define FISH_EVENT_H
#include "common.h"
#include "event.h"
/**
The signal number that is used to match any signal
@ -45,7 +46,7 @@ enum
- When used as a parameter to event_add, it represents a class of events, and function_name is the name of the function which will be called whenever an event matching the specified class occurs. This is also how events are stored internally.
- When used as a parameter to event_get, event_remove and event_fire, it represents a class of events, and if the function_name field is non-zero, only events which call the specified function will be returned.
*/
typedef struct
struct event_t
{
/**
Type of event
@ -93,8 +94,7 @@ typedef struct
is ignored.
*/
wcstring_list_t *arguments;
}
event_t;
};
/**
Add an event handler

View File

@ -160,8 +160,6 @@ void function_init()
void function_add( function_data_t *data, const parser_t &parser )
{
int i;
CHECK( data->name, );
CHECK( data->definition, );
scoped_lock lock(functions_lock);
@ -177,7 +175,7 @@ void function_add( function_data_t *data, const parser_t &parser )
if( data->named_arguments )
{
for( i=0; i<al_get_count( data->named_arguments ); i++ )
for( size_t i=0; i<al_get_count( data->named_arguments ); i++ )
{
info->named_arguments.push_back((wchar_t *)al_get( data->named_arguments, i ));
}
@ -191,9 +189,9 @@ void function_add( function_data_t *data, const parser_t &parser )
info->shadows = data->shadows;
for( i=0; i<al_get_count( data->events ); i++ )
for( size_t i=0; i< data->events.size(); i++ )
{
event_add_handler( (event_t *)al_get( data->events, i ) );
event_add_handler( data->events.at(i) );
}
}

View File

@ -14,6 +14,7 @@
#include "util.h"
#include "common.h"
#include "event.h"
#include <tr1/memory>
using std::tr1::shared_ptr;
@ -28,7 +29,7 @@ class env_vars;
structure is used for that purpose. Parhaps these two should be
merged.
*/
typedef struct function_data
struct function_data_t
{
/**
Name of function
@ -45,7 +46,7 @@ typedef struct function_data
/**
List of all event handlers for this function
*/
array_list_t *events;
std::vector<event_t *> events;
/**
List of all named arguments for this function
*/
@ -55,7 +56,7 @@ typedef struct function_data
of the underlying function.
*/
int shadows;
} function_data_t;
};
class function_info_t {
public: