Changeset 898 for trunk/optimizer/src/rp_tcloptions.c
- Timestamp:
- Feb 21, 2008, 6:43:57 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/optimizer/src/rp_tcloptions.c
r897 r898 23 23 * Built-in types: 24 24 */ 25 RpCustomTclOptionParse RpOption_ParseBoolean; 26 RpCustomTclOptionGet RpOption_GetBoolean; 27 RpTclOptionType RpOption_Boolean = { 28 "boolean", RpOption_ParseBoolean, RpOption_GetBoolean, NULL 29 }; 30 25 31 RpCustomTclOptionParse RpOption_ParseInt; 26 32 RpCustomTclOptionGet RpOption_GetInt; … … 175 181 /* 176 182 * ====================================================================== 183 * BOOLEAN 184 * ====================================================================== 185 */ 186 int 187 RpOption_ParseBoolean(interp, valObj, cdata, offset) 188 Tcl_Interp *interp; /* interpreter handling this request */ 189 Tcl_Obj *valObj; /* set option to this new value */ 190 ClientData cdata; /* save in this data structure */ 191 int offset; /* save at this offset in cdata */ 192 { 193 int *ptr = (int*)(cdata+offset); 194 if (Tcl_GetBooleanFromObj(interp, valObj, ptr) != TCL_OK) { 195 return TCL_ERROR; 196 } 197 return TCL_OK; 198 } 199 200 int 201 RpOption_GetBoolean(interp, cdata, offset) 202 Tcl_Interp *interp; /* interpreter handling this request */ 203 ClientData cdata; /* get from this data structure */ 204 int offset; /* get from this offset in cdata */ 205 { 206 int *ptr = (int*)(cdata+offset); 207 Tcl_SetObjResult(interp, Tcl_NewBooleanObj(*ptr)); 208 return TCL_OK; 209 } 210 211 /* 212 * ====================================================================== 177 213 * INTEGER 178 214 * ====================================================================== … … 335 371 *(char***)(cdata+offset) = NULL; 336 372 } 373 374 /* 375 * ====================================================================== 376 * CHOICES 377 * ====================================================================== 378 */ 379 int 380 RpOption_ParseChoices(interp, valObj, cdata, offset) 381 Tcl_Interp *interp; /* interpreter handling this request */ 382 Tcl_Obj *valObj; /* set option to this new value */ 383 ClientData cdata; /* save in this data structure */ 384 int offset; /* save at this offset in cdata */ 385 { 386 char **ptr = (char**)(cdata+offset); 387 char *value = Tcl_GetStringFromObj(valObj, (int*)NULL); 388 *ptr = strdup(value); 389 return TCL_OK; 390 } 391 392 int 393 RpOption_GetChoices(interp, cdata, offset) 394 Tcl_Interp *interp; /* interpreter handling this request */ 395 ClientData cdata; /* get from this data structure */ 396 int offset; /* get from this offset in cdata */ 397 { 398 char *ptr = (char*)(cdata+offset); 399 Tcl_SetObjResult(interp, Tcl_NewStringObj(ptr,-1)); 400 return TCL_OK; 401 } 402 403 void 404 RpOption_CleanupChoices(cdata, offset) 405 ClientData cdata; /* cleanup in this data structure */ 406 int offset; /* cleanup at this offset in cdata */ 407 { 408 char **ptr = (char**)(cdata+offset); 409 if (*ptr != NULL) { 410 free((char*)(*ptr)); 411 *ptr = NULL; 412 } 413 }
Note: See TracChangeset
for help on using the changeset viewer.