src/macro.h

00001 
00002 
00003 #ifndef __IMAGER_MACRO_H__
00004 #define __IMAGER_MACRO_H__
00005 
00006 #include <gtk/gtk.h>
00007 #include <gdk_imlib.h>
00008 #include <gdk/gdk.h>
00009 
00010 #include "defs.h"
00011 
00012 
00013 
00014 typedef enum { MT_NULL, MT_IMG, MT_REAL, MT_INT, MT_STRING } MT_TYPE;
00015 
00016 
00017 typedef struct
00018 {
00019         char* keywd;
00020         int token;
00021         int numparms;
00022         MT_TYPE type;
00023         void* apointer;
00024 }
00025 keywordtype;
00026 
00027 
00028 
00029 typedef struct
00030 {
00031         char name[16];
00032         MT_TYPE type;
00033         float numvalue;         /* we use either this numerical storage... */
00034         long intvalue;          /* ... or this integer-only storage ... */
00035         image_type imgptr;              /* ... or an image structure... */
00036         char* strg;                             /* ... or a string */
00037         float* arrayptr;                /* ... or a numerical array */
00038         unsigned char dimension;        /* n-dimensional array; 0=scalar */
00039         int numelems;                           /* Nmber of array elements total */
00040         int xmax, ymax, zmax;           /* Array bounds */
00041 }
00042 variable_type;
00043 
00044 
00045 typedef struct
00046 {
00047         variable_type v;
00048         unsigned char op;
00049         unsigned char precedence;
00050 }
00051 exprstack_type;
00052 
00053 
00054 typedef struct 
00055 {
00056         int x;
00057         int y;
00058         int z;
00059         int dim;
00060 }
00061 subscript_type;
00062 
00063 
00064 typedef struct 
00065 {
00066         char isint;
00067         long intvalue;
00068         float realvalue;
00069 }
00070 num_type;
00071 
00072 
00073 /* Allow a maximum of 50 macros */
00074 
00075 #define MACMAX  50
00076 
00077 gpointer macromenutbl[MACMAX];  /* Contains the GtkWidget menu entries */
00078 gpointer macrodef[MACMAX];              /* Contains the macro string buffer */
00079 gpointer macronames[MACMAX];    /* Contains the macro name strings */
00080 int macroopts[MACMAX];
00081 int nummacros;
00082 int macrolevel;
00083 int forlevel;
00084 int iflevel;
00085 int immd_mode;
00086 int mac_has_output;
00087 
00088 
00089 /* for simplicity, allocate the variable list statically */
00090 
00091 variable_type vars[128];
00092 int var_max;
00093 char current_macro[2048];
00094 int current_macro_pos;
00095 char *mac_logbuffer;
00096 int mac_logsize;
00097 variable_type nullvar;
00098 
00099 
00100 
00101 void macro_error (int errnumber, int pos);
00102 
00103 
00104 char isnum (char c);
00105 char isalpha (char c);
00106 char isalpha2 (char c);
00107 
00108 
00109 num_type extract_num (char* buf, int* idx);
00110 void extract_string (char* buf, int* idx, char* result, int maxlen);
00111 
00112 int findvar (char* varname);
00113 int addvar (variable_type v);
00114 int deletevar (variable_type v);
00115 void free_all_vars ();
00116 void storevar (variable_type v);
00117 void macro_swapvar (variable_type *x, variable_type *y);
00118 
00119 subscript_type extract_subscript (char* buf, int* idx);
00120 variable_type extract_var (char* buf, int* idx);
00121 variable_type expr (unsigned char* buf, int* idx, MT_TYPE expctype);
00122 int img_match_size (image_type* img1, image_type* img2);
00123 int exec_macro_single (unsigned char* buf, int* idx);
00124 void immediate_exec ();
00125 
00126 void listbuf (unsigned char* buf, int idx1, int idx2, char* list, int lim);
00127 
00128 
00129 void load_macro (const char *macfile);
00130 void delete_macros ();
00131 
00132 int register_dso_macro (char* kwd, int numparams, MT_TYPE type, void* apointer);
00133 
00134 
00135 #define MAC_ADDLOG(C)   { strncat (mac_logbuffer, C, mac_logsize); mac_has_output=1; }
00136 
00137 
00138 
00139 #endif
00140 

Generated on Sat Nov 15 23:24:49 2008 for Crystal Image by  doxygen 1.5.3