mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
Excised some more halloc and array_list_t
This commit is contained in:
parent
b2e5809180
commit
3dc56de0ae
16
builtin.cpp
16
builtin.cpp
|
@ -1456,8 +1456,7 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
|
||||||
int argc = builtin_count_args( argv );
|
int argc = builtin_count_args( argv );
|
||||||
int res=STATUS_BUILTIN_OK;
|
int res=STATUS_BUILTIN_OK;
|
||||||
wchar_t *desc=0;
|
wchar_t *desc=0;
|
||||||
array_list_t *events;
|
std::vector<event_t *> events;
|
||||||
int i;
|
|
||||||
array_list_t *named_arguments=0;
|
array_list_t *named_arguments=0;
|
||||||
wchar_t *name = 0;
|
wchar_t *name = 0;
|
||||||
int shadows = 1;
|
int shadows = 1;
|
||||||
|
@ -1465,7 +1464,6 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
|
||||||
woptind=0;
|
woptind=0;
|
||||||
|
|
||||||
parser.push_block( FUNCTION_DEF );
|
parser.push_block( FUNCTION_DEF );
|
||||||
events=al_halloc( parser.current_block );
|
|
||||||
|
|
||||||
static const struct woption
|
static const struct woption
|
||||||
long_options[] =
|
long_options[] =
|
||||||
|
@ -1562,7 +1560,7 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
|
||||||
e->type = EVENT_SIGNAL;
|
e->type = EVENT_SIGNAL;
|
||||||
e->param1.signal = sig;
|
e->param1.signal = sig;
|
||||||
e->function_name=0;
|
e->function_name=0;
|
||||||
al_push( events, e );
|
events.push_back(e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1585,7 +1583,7 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
|
||||||
e->type = EVENT_VARIABLE;
|
e->type = EVENT_VARIABLE;
|
||||||
e->param1.variable = halloc_wcsdup( parser.current_block, woptarg );
|
e->param1.variable = halloc_wcsdup( parser.current_block, woptarg );
|
||||||
e->function_name=0;
|
e->function_name=0;
|
||||||
al_push( events, e );
|
events.push_back(e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1599,7 +1597,7 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
|
||||||
e->type = EVENT_GENERIC;
|
e->type = EVENT_GENERIC;
|
||||||
e->param1.param = halloc_wcsdup( parser.current_block, woptarg );
|
e->param1.param = halloc_wcsdup( parser.current_block, woptarg );
|
||||||
e->function_name=0;
|
e->function_name=0;
|
||||||
al_push( events, e );
|
events.push_back(e);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1675,7 +1673,7 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
e->function_name=0;
|
e->function_name=0;
|
||||||
al_push( events, e );
|
events.push_back(e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1806,9 +1804,9 @@ static int builtin_function( parser_t &parser, wchar_t **argv )
|
||||||
d->named_arguments = named_arguments;
|
d->named_arguments = named_arguments;
|
||||||
d->shadows = shadows;
|
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;
|
e->function_name = d->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
6
event.h
6
event.h
|
@ -13,6 +13,7 @@
|
||||||
#define FISH_EVENT_H
|
#define FISH_EVENT_H
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "event.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The signal number that is used to match any signal
|
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_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.
|
- 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
|
Type of event
|
||||||
|
@ -93,8 +94,7 @@ typedef struct
|
||||||
is ignored.
|
is ignored.
|
||||||
*/
|
*/
|
||||||
wcstring_list_t *arguments;
|
wcstring_list_t *arguments;
|
||||||
}
|
};
|
||||||
event_t;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Add an event handler
|
Add an event handler
|
||||||
|
|
|
@ -160,8 +160,6 @@ void function_init()
|
||||||
|
|
||||||
void function_add( function_data_t *data, const parser_t &parser )
|
void function_add( function_data_t *data, const parser_t &parser )
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
CHECK( data->name, );
|
CHECK( data->name, );
|
||||||
CHECK( data->definition, );
|
CHECK( data->definition, );
|
||||||
scoped_lock lock(functions_lock);
|
scoped_lock lock(functions_lock);
|
||||||
|
@ -177,7 +175,7 @@ void function_add( function_data_t *data, const parser_t &parser )
|
||||||
|
|
||||||
if( data->named_arguments )
|
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 ));
|
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;
|
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) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "event.h"
|
||||||
|
|
||||||
#include <tr1/memory>
|
#include <tr1/memory>
|
||||||
using std::tr1::shared_ptr;
|
using std::tr1::shared_ptr;
|
||||||
|
@ -28,7 +29,7 @@ class env_vars;
|
||||||
structure is used for that purpose. Parhaps these two should be
|
structure is used for that purpose. Parhaps these two should be
|
||||||
merged.
|
merged.
|
||||||
*/
|
*/
|
||||||
typedef struct function_data
|
struct function_data_t
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
Name of function
|
Name of function
|
||||||
|
@ -45,7 +46,7 @@ typedef struct function_data
|
||||||
/**
|
/**
|
||||||
List of all event handlers for this function
|
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
|
List of all named arguments for this function
|
||||||
*/
|
*/
|
||||||
|
@ -55,7 +56,7 @@ typedef struct function_data
|
||||||
of the underlying function.
|
of the underlying function.
|
||||||
*/
|
*/
|
||||||
int shadows;
|
int shadows;
|
||||||
} function_data_t;
|
};
|
||||||
|
|
||||||
class function_info_t {
|
class function_info_t {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user