From bac46105800203e28ce9006a70736c8b19a38089 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 17 Apr 2011 21:54:06 -0400 Subject: [PATCH] Hooks - Removed obsolete field hook. --- src/API.cpp | 57 ----------------------------------------------------- src/API.h | 1 - 2 files changed, 58 deletions(-) diff --git a/src/API.cpp b/src/API.cpp index 383ceea93..e18a8226d 100644 --- a/src/API.cpp +++ b/src/API.cpp @@ -258,63 +258,6 @@ bool API::callTaskHook ( return rc == 0 ? true : false; } -//////////////////////////////////////////////////////////////////////////////// -bool API::callFieldHook ( - const std::string& file, - const std::string& function, - const std::string& name, - std::string& value) -{ - loadFile (file); - - // Get function. - lua_getglobal (L, function.c_str ()); - if (!lua_isfunction (L, -1)) - { - lua_pop (L, 1); - throw std::string ("The Lua function '") + function + "' was not found."; - } - - // Prepare args. - lua_pushstring (L, name.c_str ()); - lua_pushstring (L, value.c_str ()); - - // Make call. - if (lua_pcall (L, 2, 3, 0) != 0) - throw std::string ("Error calling '") + function + "' - " + lua_tostring (L, -1) + "."; - - // Call successful - get return values. - if (!lua_isstring (L, -3)) - throw std::string ("Error: '") + function + "' did not return a modified value."; - - if (!lua_isnumber (L, -2)) - throw std::string ("Error: '") + function + "' did not return a success indicator."; - - if (!lua_isstring (L, -1) && !lua_isnil (L, -1)) - throw std::string ("Error: '") + function + "' did not return a message or nil."; - - const char* new_value = lua_tostring (L, -3); - int rc = lua_tointeger (L, -2); - const char* message = lua_tostring (L, -1); - - if (rc == 0) - { - // Overwrite with the modified value. - value = new_value; - - if (message) - context.footnote (std::string ("Warning: ") + message); - } - else - { - if (message) - throw std::string (message); - } - - lua_pop (L, 1); - return rc == 0 ? true : false; -} - //////////////////////////////////////////////////////////////////////////////// void API::loadFile (const std::string& file) { diff --git a/src/API.h b/src/API.h index 547ec1fe6..6d870490d 100644 --- a/src/API.h +++ b/src/API.h @@ -52,7 +52,6 @@ public: void initialize (); bool callProgramHook (const std::string&, const std::string&); bool callTaskHook (const std::string&, const std::string&, Task&); - bool callFieldHook (const std::string&, const std::string&, const std::string&, std::string&); private: void loadFile (const std::string&);