2005-09-20 13:26:39 +00:00
|
|
|
/** \file function.h
|
|
|
|
|
|
|
|
Prototypes for functions for storing and retrieving function
|
2006-11-15 14:16:49 +00:00
|
|
|
information. These functions also take care of autoloading
|
|
|
|
functions in the $fish_function_path. Actual function evaluation
|
|
|
|
is taken care of by the parser and to some degree the builtin
|
|
|
|
handling library.
|
2005-09-20 13:26:39 +00:00
|
|
|
*/
|
|
|
|
|
2005-10-04 15:11:39 +00:00
|
|
|
#ifndef FISH_FUNCTION_H
|
|
|
|
#define FISH_FUNCTION_H
|
|
|
|
|
|
|
|
#include <wchar.h>
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
|
2007-04-22 22:10:33 +00:00
|
|
|
/**
|
|
|
|
Structure describing a function
|
|
|
|
*/
|
|
|
|
typedef struct function_data
|
|
|
|
{
|
2008-01-13 16:47:47 +00:00
|
|
|
/**
|
|
|
|
Name of function
|
|
|
|
*/
|
2007-04-22 22:10:33 +00:00
|
|
|
wchar_t *name;
|
2008-01-13 16:47:47 +00:00
|
|
|
/**
|
|
|
|
Description of function
|
|
|
|
*/
|
2007-04-22 22:10:33 +00:00
|
|
|
wchar_t *description;
|
2008-01-13 16:47:47 +00:00
|
|
|
/**
|
|
|
|
Function definition
|
|
|
|
*/
|
2007-04-22 22:10:33 +00:00
|
|
|
wchar_t *definition;
|
2008-01-13 16:47:47 +00:00
|
|
|
/**
|
|
|
|
List of all event handlers for this function
|
|
|
|
*/
|
2007-04-22 22:10:33 +00:00
|
|
|
array_list_t *events;
|
2008-01-13 16:47:47 +00:00
|
|
|
/**
|
|
|
|
List of all named arguments for this function
|
|
|
|
*/
|
2007-04-22 22:10:33 +00:00
|
|
|
array_list_t *named_arguments;
|
2008-01-13 16:47:47 +00:00
|
|
|
/**
|
|
|
|
Set to non-zero if invoking this function shadows the variables
|
|
|
|
of the underlying function.
|
|
|
|
*/
|
2007-04-22 22:10:33 +00:00
|
|
|
int shadows;
|
|
|
|
}
|
|
|
|
function_data_t;
|
|
|
|
|
|
|
|
|
2005-09-20 13:26:39 +00:00
|
|
|
/**
|
|
|
|
Initialize function data
|
|
|
|
*/
|
|
|
|
void function_init();
|
2006-11-15 14:16:49 +00:00
|
|
|
|
2005-09-20 13:26:39 +00:00
|
|
|
/**
|
|
|
|
Destroy function data
|
|
|
|
*/
|
|
|
|
void function_destroy();
|
|
|
|
|
|
|
|
/**
|
2006-11-15 14:16:49 +00:00
|
|
|
Add an function. The parameters values are copied and should be
|
|
|
|
freed by the caller.
|
2005-09-20 13:26:39 +00:00
|
|
|
*/
|
2007-04-22 22:10:33 +00:00
|
|
|
void function_add( function_data_t *data );
|
2005-09-20 13:26:39 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Remove the function with the specified name.
|
|
|
|
*/
|
|
|
|
void function_remove( const wchar_t *name );
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the definition of the function with the name \c name.
|
|
|
|
*/
|
|
|
|
const wchar_t *function_get_definition( const wchar_t *name );
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the description of the function with the name \c name.
|
|
|
|
*/
|
|
|
|
const wchar_t *function_get_desc( const wchar_t *name );
|
|
|
|
|
|
|
|
/**
|
|
|
|
Sets the description of the function with the name \c name.
|
|
|
|
*/
|
|
|
|
void function_set_desc( const wchar_t *name, const wchar_t *desc );
|
|
|
|
|
|
|
|
/**
|
2006-11-15 14:16:49 +00:00
|
|
|
Returns true if the function with the name name exists.
|
2005-09-20 13:26:39 +00:00
|
|
|
*/
|
2005-11-29 19:50:30 +00:00
|
|
|
int function_exists( const wchar_t *name );
|
2005-09-20 13:26:39 +00:00
|
|
|
|
|
|
|
/**
|
2006-11-15 14:16:49 +00:00
|
|
|
Insert all function names into l. These are not copies of the
|
|
|
|
strings and should not be freed after use.
|
2005-09-20 13:26:39 +00:00
|
|
|
|
|
|
|
\param list the list to add the names to
|
|
|
|
\param get_hidden whether to include hidden functions, i.e. ones starting with an underscore
|
|
|
|
*/
|
|
|
|
void function_get_names( array_list_t *list,
|
|
|
|
int get_hidden );
|
|
|
|
|
2006-02-08 17:37:18 +00:00
|
|
|
/**
|
|
|
|
Returns tha absolute path of the file where the specified function
|
|
|
|
was defined. Returns 0 if the file was defined on the commandline.
|
2006-11-15 14:16:49 +00:00
|
|
|
|
|
|
|
This function does not autoload functions, it will only work on
|
|
|
|
functions that have already been defined.
|
2006-02-08 17:37:18 +00:00
|
|
|
*/
|
2006-01-26 14:48:10 +00:00
|
|
|
const wchar_t *function_get_definition_file( const wchar_t *name );
|
|
|
|
|
2006-02-08 17:37:18 +00:00
|
|
|
/**
|
2006-11-15 14:16:49 +00:00
|
|
|
Returns the linenumber where the definition of the specified
|
|
|
|
function started.
|
|
|
|
|
|
|
|
This function does not autoload functions, it will only work on
|
|
|
|
functions that have already been defined.
|
2006-02-08 17:37:18 +00:00
|
|
|
*/
|
2006-01-26 14:48:10 +00:00
|
|
|
int function_get_definition_offset( const wchar_t *name );
|
|
|
|
|
2007-04-16 20:06:11 +00:00
|
|
|
/**
|
|
|
|
Returns a list of all named arguments of the specified function.
|
|
|
|
*/
|
|
|
|
array_list_t *function_get_named_arguments( const wchar_t *name );
|
|
|
|
|
2007-04-22 22:10:33 +00:00
|
|
|
/**
|
|
|
|
Returns whether this function shadows variables of the underlying function
|
|
|
|
*/
|
|
|
|
int function_get_shadows( const wchar_t *name );
|
|
|
|
|
2005-10-04 15:11:39 +00:00
|
|
|
#endif
|