SetHashTable.c

Go to the documentation of this file.
00001 /*------------------------------------------------------------------------*/
00002 /* file: SetHashTable.c                                                   */
00003 /* Copyright INRIA 2006                                                   */
00004 /* Authors : Jean-Baptiste Silvy                                          */
00005 /* desc : implementation of the scilab hashtable for the set procedure    */
00006 /*------------------------------------------------------------------------*/
00007 
00008 #include "SetHashTable.h"
00009 #include "machine.h"
00010 #include "setHandleProperty.h"
00011 #include "sciprint.h"
00012 
00016 static BOOL setHashTableCreated = FALSE ;
00017 
00021 static SetPropertyHashTable * setHashTable = NULL ;
00022 
00027 typedef struct  
00028 {
00029   char            * key ;
00030   setPropertyFunc   accessor ;
00031 } setHashTableCouple ;
00032 
00038 #define NB_PROPERTIES 122
00039 
00044 static setHashTableCouple propertyTable[NB_PROPERTIES] =
00045 { { "visible"            , set_visible_property             },
00046   { "pixel_drawing_mode" , set_pixel_drawing_mode_property  },
00047   { "old_style"          , set_old_style_property           },
00048   { "figure_style"       , set_figure_style_property        },
00049   { "auto_resize"        , set_auto_resize_property         },
00050   { "figure_position"    , set_figure_position_property     },
00051   { "axes_size"          , set_axes_size_property           },
00052   { "figure_size"        , set_figure_size_property         },
00053   { "figure_name"        , set_figure_name_property         },
00054   { "figure_id"          , set_figure_id_property           },
00055   { "rotation_style"     , set_rotation_style_property      },
00056   { "immediate_drawing"  , set_immediate_drawing_property   },
00057   { "pixmap"             , set_pixmap_property              },
00058   { "parent"             , set_parent_property              },
00059   { "current_axes"       , set_current_axes_property        },
00060   { "current_figure"     , set_current_figure_property      },
00061   { "current_obj"        , set_current_entity_property      },
00062   { "current_entity"     , set_current_entity_property      },
00063   { "hdl"                , set_current_entity_property      },
00064   { "children"           , set_children_property            },
00065   { "default_values"     , set_default_values_property      },
00066   { "color_map"          , set_color_map_property           },
00067   { "interp_color_vector", set_interp_color_vector_property },
00068   { "interp_color_mode"  , set_interp_color_mode_property   },
00069   { "background"         , set_background_property          },
00070   { "foreground"         , set_foreground_property          },
00071   { "fill_mode"          , set_fill_mode_property           },
00072   { "thickness"          , set_thickness_property           },
00073   { "arrow_size_factor"  , set_arrow_size_factor_property   },
00074   { "segs_color"         , set_segs_color_property          },
00075   { "line_style"         , set_line_style_property          },
00076   { "line_mode"          , set_line_mode_property           },
00077   { "surface_mode"       , set_surface_mode_property        },
00078   { "mark_style"         , set_mark_style_property          },
00079   { "mark_mode"          , set_mark_mode_property           },
00080   { "mark_size_unit"     , set_mark_size_unit_property      },
00081   { "mark_size"          , set_mark_size_property           },
00082   { "mark_foreground"    , set_mark_foreground_property     },
00083   { "mark_background"    , set_mark_background_property     },
00084   { "bar_layout"         , set_bar_layout_property          },
00085   { "bar_width"          , set_bar_width_property           },
00086   { "x_shift"            , set_x_shift_property             },
00087   { "y_shift"            , set_y_shift_property             },
00088   { "z_shift"            , set_z_shift_property             },
00089   { "polyline_style"     , set_polyline_style_property      },
00090   { "font_size"          , set_font_size_property           },
00091   { "font_angle"         , set_font_angle_property          },
00092   { "font_foreground"    , set_font_foreground_property     },
00093   { "font_color"         , set_font_color_property          },
00094   { "font_style"         , set_font_style_property          },
00095   { "font_name"          , set_font_name_property           },
00096   { "text_box_mode"      , set_text_box_mode_property       },
00097   { "auto_dimensionning" , set_auto_dimensionning_property  },
00098   { "alignment"          , set_alignment_property           },
00099   { "text_box"           , set_text_box_property            },
00100   { "text"               , set_text_property                },
00101   { "auto_clear"         , set_auto_clear_property          },
00102   { "auto_scale"         , set_auto_scale_property          },
00103   { "zoom_box"           , set_zoom_box_property            },
00104   { "zoom_state"         , set_zoom_state_property          },
00105   { "clip_box"           , set_clip_box_property            },
00106   { "clip_state"         , set_clip_state_property          },
00107   { "data"               , set_data_property                },
00108   { "callbackmevent"     , set_callbackmevent_property      },
00109   { "callback"           , set_callback_property            },
00110   { "x_label"            , set_x_label_property             },
00111   { "y_label"            , set_y_label_property             },
00112   { "z_label"            , set_z_label_property             },
00113   { "title"              , set_title_property               },
00114   { "log_flags"          , set_log_flags_property           },
00115   { "tics_direction"     , set_tics_direction_property      },
00116   { "x_location"         , set_x_location_property          },
00117   { "y_location"         , set_y_location_property          },
00118   { "tight_limits"       , set_tight_limits_property        },
00119   { "closed"             , set_closed_property              },
00120   { "auto_position"      , set_auto_position_property       },
00121   { "auto_rotation"      , set_auto_rotation_property       },
00122   { "position"           , set_position_property            },
00123   { "auto_ticks"         , set_auto_ticks_property          },
00124   { "axes_reverse"       , set_axes_reverse_property        },
00125   { "view"               , set_view_property                },
00126   { "axes_bounds"        , set_axes_bounds_property         },
00127   { "data_bounds"        , set_data_bounds_property         },
00128   { "margins"            , set_margins_property             },
00129   { "tics_color"         , set_tics_color_property          },
00130   { "tics_style"         , set_tics_style_property          },
00131   { "sub_tics"           , set_sub_tics_property            },
00132   { "sub_ticks"          , set_sub_tics_property            },
00133   { "tics_segment"       , set_tics_segment_property        },
00134   { "labels_font_size"   , set_labels_font_size_property    },
00135   { "labels_font_color"  , set_labels_font_color_property   },
00136   { "labels_font_style"  , set_labels_font_style_property   },
00137   { "format_n"           , set_format_n_property            },
00138   { "xtics_coord"        , set_xtics_coord_property         },
00139   { "ytics_coord"        , set_ytics_coord_property         },
00140   { "tics_labels"        , set_tics_labels_property         },
00141   { "box"                , set_box_property                 },
00142   { "grid"               , set_grid_property                },
00143   { "axes_visible"       , set_axes_visible_property        },
00144   { "hiddencolor"        , set_hidden_color_property        },
00145   { "isoview"            , set_isoview_property             },
00146   { "cube_scaling"       , set_cube_scaling_property        },
00147   { "arrow_size"         , set_arrow_size_property          },
00148   { "colored"            , set_colored_property             },
00149   { "data_mapping"       , set_data_mapping_property        },
00150   { "rotation_angles"    , set_rotation_angles_property     },
00151   { "color_mode"         , set_color_mode_property          },
00152   { "color_flag"         , set_color_flag_property          },
00153   { "cdata_mapping"      , set_cdata_mapping_property       },
00154   { "surface_color"      , set_surface_color_property       },
00155   { "triangles"          , set_triangles_property           },
00156   { "z_bounds"           , set_z_bounds_property            },
00157   { "user_data"          , set_user_data_property           },
00158   { "handle_visible"     , set_handle_visible_property      },
00159   { "callback_type"      , set_callback_type_property       },
00160   { "menu_enable"        , set_menu_enable_property         },
00161   { "hidden_axis_color"  , set_hidden_axis_color_property   },
00162   { "x_ticks"            , set_x_ticks_property             },
00163   { "y_ticks"            , set_y_ticks_property             },
00164   { "z_ticks"            , set_z_ticks_property             },
00165   { "viewport"           , set_viewport_property            },
00166   { "info_message"       , set_info_message_property        }
00167 } ;
00168 
00169 /*-----------------------------------------------------------------------------------*/
00170 SetPropertyHashTable * createScilabSetHashTable( void )
00171 {
00172   int i ;
00173   if ( setHashTableCreated )
00174   {
00175     return setHashTable ;
00176   }
00177 
00178   /* create the hash table */
00179   setHashTable = createSetHashTable() ;
00180 
00181   if ( setHashTable == NULL )
00182   {
00183     return NULL ;
00184   }
00185 
00186   /* insert every couple */
00187   for ( i = 0 ; i < NB_PROPERTIES ; i++ )
00188   {
00189     insertSetHashtable( setHashTable, propertyTable[i].key, propertyTable[i].accessor ) ;
00190   }
00191 
00192   setHashTableCreated = TRUE ;
00193 
00194   return setHashTable ;
00195 
00196 }
00197 /*-----------------------------------------------------------------------------------*/
00198 int callSetProperty( sciPointObj * pObj, int stackPointer, int valueType, int nbRow, int nbCol, char * propertyName )
00199 {
00200   setPropertyFunc accessor = searchSetHashtable( setHashTable, propertyName ) ;
00201   if ( accessor == NULL )
00202   {
00203     sciprint( "Unknown property.\n" ) ;
00204     return -1 ;
00205   }
00206   return accessor( pObj, stackPointer, valueType, nbRow, nbCol ) ;
00207 }
00208 /*-----------------------------------------------------------------------------------*/
00209 void destroyScilabSetHashTable( void )
00210 {
00211   if ( !setHashTableCreated )
00212   {
00213     return ;
00214   }
00215 
00216   destroySetHashTable( setHashTable ) ;
00217   setHashTableCreated = FALSE ;
00218 }
00219 /*-----------------------------------------------------------------------------------*/
00220 
00221 #undef NB_PROPERTIES

Generated on Sun Mar 4 15:03:51 2007 for Scilab [trunk] by  doxygen 1.5.1