home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2002 April / pcpro0402.iso / essentials / graphics / Gimp / gimp-src-20001226.exe / src / gimp / unofficial-plug-ins / mathmap / overload.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-21  |  2.6 KB  |  106 lines

  1. /* -*- c -*- */
  2.  
  3. /*
  4.  * overload.h
  5.  *
  6.  * MathMap
  7.  *
  8.  * Copyright (C) 1997-2000 Mark Probst
  9.  *
  10.  * This program is free software; you can redistribute it and/or
  11.  * modify it under the terms of the GNU General Public License
  12.  * as published by the Free Software Foundation; either version 2
  13.  * of the License, or (at your option) any later version.
  14.  *
  15.  * This program is distributed in the hope that it will be useful,
  16.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18.  * GNU General Public License for more details.
  19.  *
  20.  * You should have received a copy of the GNU General Public License
  21.  * along with this program; if not, write to the Free Software
  22.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  23.  */
  24.  
  25. #ifndef __OVERLOAD_H__
  26. #define __OVERLOAD_H__
  27.  
  28. #include "tuples.h"
  29. #include "builtins.h"
  30. #include "macros.h"
  31.  
  32. #define MAX_FUNCTION_LENGTH     63
  33. #define MAX_BINDING_LENGTH      63
  34.  
  35. typedef struct _binding_t
  36. {
  37.     int is_bound;
  38.     int value;
  39.  
  40.     struct _binding_t *next;
  41. } binding_t;
  42.  
  43. typedef struct _named_binding_t
  44. {
  45.     char name[MAX_BINDING_LENGTH + 1];
  46.     binding_t *binding;
  47.  
  48.     struct _named_binding_t *next;
  49. } named_binding_t;
  50.  
  51. typedef struct _overload_arg_t
  52. {
  53.     binding_t *tag;
  54.     binding_t *length;
  55.  
  56.     struct _overload_arg_t *next;
  57. } overload_arg_t;
  58.  
  59. #define OVERLOAD_BUILTIN     1
  60. #define OVERLOAD_MACRO       2
  61.  
  62. typedef struct _overload_entry_t
  63. {
  64.     char name[MAX_FUNCTION_LENGTH + 1];
  65.     int type;
  66.     overload_arg_t *result;
  67.     overload_arg_t *args;
  68.     int num_args;
  69.     union
  70.     {
  71.     struct
  72.     {
  73.         int sidefx;
  74.         builtin_function_t builtin;
  75.         generator_function_t generator;
  76.     } builtin;
  77.     macro_function_t macro;
  78.     } v;
  79.  
  80.     struct _overload_entry_t *next;
  81. } overload_entry_t;
  82.  
  83. typedef struct _function_arg_info_t
  84. {
  85.     tuple_info_t info;
  86.  
  87.     struct _function_arg_info_t *next;
  88. } function_arg_info_t;
  89.  
  90. binding_t* new_free_variable_binding (void);
  91. binding_t* new_constant_binding (int value);
  92. overload_arg_t* new_overload_argument (binding_t *tag, binding_t *length, overload_arg_t *next);
  93.  
  94. void clear_bindings (void);
  95. binding_t* free_binding_with_name (const char *name);
  96.  
  97. void register_overloaded_builtin (const char *name, const char *argstring, int sidefx,
  98.                   builtin_function_t func, generator_function_t gen);
  99. void register_overloaded_macro (const char *name, const char *argstring, macro_function_t func);
  100.  
  101. overload_entry_t* overloaded_builtin_with_function (builtin_function_t function);
  102.  
  103. overload_entry_t* resolve_function_call (const char *name, function_arg_info_t *args, tuple_info_t *result);
  104.  
  105. #endif
  106.