aboutsummaryrefslogtreecommitdiffhomepage
path: root/function.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-01-23 11:42:41 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-01-23 11:42:41 -0800
commit6e8637fbc98a7ff23696e6f9e0f53a465bcbcf22 (patch)
tree7410b542d5db999eb771e3e0447beb6f2a14a9a4 /function.cpp
parent8403aae92886de1e0bd379c94b3715b6df6dc0e4 (diff)
Move autoloading from a map of path names to a real object autoload_t.
Moved the various things we can autoload into static objects. Next step is to make them thread safe.
Diffstat (limited to 'function.cpp')
-rw-r--r--function.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/function.cpp b/function.cpp
index cac0f336..aa625f9e 100644
--- a/function.cpp
+++ b/function.cpp
@@ -38,6 +38,7 @@
#include "expand.h"
#include "halloc.h"
#include "halloc_util.h"
+#include "builtin_scripts.h"
class function_internal_info_t
{
@@ -75,6 +76,9 @@ public:
bool shadows;
};
+/* Autoloader for functions */
+static autoload_t function_autoloader(L"fish_function_path", internal_function_scripts, sizeof internal_function_scripts / sizeof *internal_function_scripts);
+
/**
Table containing all functions
*/
@@ -136,10 +140,7 @@ static int load( const wchar_t *name )
UNLOCK_FUNCTIONS();
is_autoload = 1;
- res = parse_util_load( name,
- L"fish_function_path",
- &function_remove,
- 1 );
+ res = function_autoloader.load( name, &function_remove, 1 );
is_autoload = was_autoload;
return res;
}
@@ -291,7 +292,7 @@ void function_remove( const wchar_t *name )
*/
if( !is_autoload )
{
- parse_util_unload( name, L"fish_function_path", 0 );
+ function_autoloader.unload( name, 0 );
}
UNLOCK_FUNCTIONS();
}