1 /* Expressions. 2 */ 3 4 /* 5 6 Copyright (C) 1991-2003 The National Gallery 7 8 This program is free software; you can redistribute it and/or modify 9 it under the terms of the GNU General Public License as published by 10 the Free Software Foundation; either version 2 of the License, or 11 (at your option) any later version. 12 13 This program is distributed in the hope that it will be useful, 14 but WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 GNU General Public License for more details. 17 18 You should have received a copy of the GNU General Public License along 19 with this program; if not, write to the Free Software Foundation, Inc., 20 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 22 */ 23 24 /* 25 26 These files are distributed with VIPS - http://www.vips.ecs.soton.ac.uk 27 28 */ 29 30 #define TYPE_EXPR (expr_get_type()) 31 #define EXPR( obj ) \ 32 (G_TYPE_CHECK_INSTANCE_CAST( (obj), TYPE_EXPR, Expr )) 33 #define EXPR_CLASS( klass ) \ 34 (G_TYPE_CHECK_CLASS_CAST( (klass), TYPE_EXPR, ExprClass)) 35 #define IS_EXPR( obj ) \ 36 (G_TYPE_CHECK_INSTANCE_TYPE( (obj), TYPE_EXPR )) 37 #define IS_EXPR_CLASS( klass ) \ 38 (G_TYPE_CHECK_CLASS_TYPE( (klass), TYPE_EXPR )) 39 #define EXPR_GET_CLASS( obj ) \ 40 (G_TYPE_INSTANCE_GET_CLASS( (obj), TYPE_EXPR, ExprClass )) 41 42 /* What we track to parse and compile some text. Can have several 43 * of these for a symbol, all with different values. 44 */ 45 struct _Expr { 46 /* We don't contain anything, but we are contained by Symbol, so we 47 * need to be an iContainer subclass. 48 */ 49 iContainer parent_object; 50 51 Symbol *sym; /* We are an expr for this symbol, scopewise */ 52 Row *row; /* (optional) we have this display */ 53 54 Compile *compile; /* Our compiled code */ 55 56 GSList *static_links; /* Static LinkExprs which reference us */ 57 GSList *dynamic_links; /* Dynamic LinkExprs which reference us */ 58 59 PElement root; /* Pointer to value of this expr */ 60 61 /* Are we recorded as having an Imageinfo as a value? Use this to 62 * unlink us from the last ii we were linked to. 63 */ 64 Imageinfo *imageinfo; 65 66 gboolean err; /* TRUE if there is an error in this expr */ 67 char *error_top; 68 char *error_sub; 69 }; 70 71 typedef struct _ExprClass { 72 iContainerClass parent_class; 73 74 /* 75 76 new_value expr has been recalced and root points to a 77 new piece of graph 78 79 */ 80 81 void (*new_value)( Expr *expr ); 82 } ExprClass; 83 84 extern GSList *expr_error_all; 85 86 void *expr_error_print( Expr *expr, VipsBuf *buf ); 87 88 typedef void *(*map_expr_fn)( Expr *, void *, void * ); 89 Expr *expr_map_all( Expr *expr, map_expr_fn fn, void *a ); 90 91 void *expr_name_print( Expr *expr ); 92 void expr_name( Expr *expr, VipsBuf *buf ); 93 94 Expr *expr_get_parent( Expr *expr ); 95 Expr *expr_get_root( Expr *expr ); 96 Expr *expr_get_root_dynamic( Expr *expr ); 97 98 GType expr_get_type( void ); 99 void *expr_strip( Expr *expr ); 100 Expr *expr_new( Symbol *sym ); 101 Expr *expr_clone( Symbol *sym ); 102 103 /* Set and clear error state. 104 */ 105 void *expr_error_set( Expr *expr ); 106 void expr_error_clear( Expr *expr ); 107 void expr_error_get( Expr *expr ); 108 109 void expr_link_make( Expr *expr, Symbol *child ); 110 void *expr_link_break( Expr *expr, Symbol *child ); 111 void *expr_dirty( Expr *expr, int serial ); 112 void *expr_dirty_intrans( Expr *expr, int serial ); 113 114 void expr_tip( Expr *expr, VipsBuf *buf ); 115 116 void expr_new_value( Expr *expr ); 117 118 void expr_resolve( Expr *expr ); 119