diff options
Diffstat (limited to 'src/map/magic-expr.hpp')
-rw-r--r-- | src/map/magic-expr.hpp | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/src/map/magic-expr.hpp b/src/map/magic-expr.hpp index 58f6596..e582a66 100644 --- a/src/map/magic-expr.hpp +++ b/src/map/magic-expr.hpp @@ -1,5 +1,4 @@ -#ifndef TMWA_MAP_MAGIC_EXPR_HPP -#define TMWA_MAP_MAGIC_EXPR_HPP +#pragma once // magic-expr.hpp - Pure functions for the old magic backend. // // Copyright © 2004-2011 The Mana World Development Team @@ -20,15 +19,22 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>. -# include "../sanity.hpp" +#include "fwd.hpp" -# include "magic-interpreter.hpp" +#include "../generic/fwd.hpp" -# include "../range/slice.hpp" +#include "../range/fwd.hpp" -# include "../strings/fwd.hpp" -# include "../strings/zstring.hpp" +#include "../strings/zstring.hpp" +#include "../strings/literal.hpp" +#include "../mmo/fwd.hpp" + +#include "magic-interpreter.t.hpp" + + +namespace tmwa +{ /* * Argument types: * i : int @@ -44,34 +50,20 @@ */ struct fun_t { - ZString name; - ZString signature; + LString name; + LString signature; char ret_ty; int (*fun)(dumb_ptr<env_t> env, val_t *result, Slice<val_t> arga); }; -struct op_t -{ - ZString name; - ZString signature; - int (*op)(dumb_ptr<env_t> env, Slice<val_t> arga); -}; - /** * Retrieves a function by name * @param name The name to look up - * @return A function of that name, or NULL. + * @return A function of that name, or nullptr. */ fun_t *magic_get_fun(ZString name); /** - * Retrieves an operation by name - * @param name The name to look up - * @return An operation of that name, or NULL, and a function index - */ -op_t *magic_get_op(ZString name); - -/** * Evaluates an expression and stores the result in `dest' */ void magic_eval(dumb_ptr<env_t> env, val_t *dest, dumb_ptr<expr_t> expr); @@ -95,9 +87,9 @@ void magic_copy_var(val_t *dest, val_t *src); void magic_random_location(location_t *dest, dumb_ptr<area_t> area); // ret -1: not a string, ret 1: no such item, ret 0: OK -int magic_find_item(Slice<val_t> args, int index, struct item *item, int *stackable); +int magic_find_item(Slice<val_t> args, int index, Item *item, int *stackable); -# define GET_ARG_ITEM(index, dest, stackable) \ +#define GET_ARG_ITEM(index, dest, stackable) \ switch (magic_find_item(args, index, &dest, &stackable)) \ { \ case -1: return 1; \ @@ -107,4 +99,11 @@ int magic_find_item(Slice<val_t> args, int index, struct item *item, int *stacka int magic_location_in_area(map_local *m, int x, int y, dumb_ptr<area_t> area); -#endif // TMWA_MAP_MAGIC_EXPR_HPP +/* Helper definitions for dealing with functions and operations */ + +int magic_signature_check(ZString opname, ZString funname, ZString signature, + Slice<val_t> args, int line, int column); + +void magic_area_rect(map_local **m, int *x, int *y, int *width, int *height, + area_t& area); +} // namespace tmwa |