Ignore:
Timestamp:
Feb 21, 2008 6:43:57 PM (15 years ago)
Author:
mmc
Message:

Optimization part is getting better. Fleshed out the plug-in for
PGApack, and integrated a first cut that includes the data handling.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/optimizer/src/rp_tcloptions.c

    r897 r898  
    2323 *  Built-in types:
    2424 */
     25RpCustomTclOptionParse RpOption_ParseBoolean;
     26RpCustomTclOptionGet RpOption_GetBoolean;
     27RpTclOptionType RpOption_Boolean = {
     28    "boolean", RpOption_ParseBoolean, RpOption_GetBoolean, NULL
     29};
     30
    2531RpCustomTclOptionParse RpOption_ParseInt;
    2632RpCustomTclOptionGet RpOption_GetInt;
     
    175181/*
    176182 * ======================================================================
     183 *  BOOLEAN
     184 * ======================================================================
     185 */
     186int
     187RpOption_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
     200int
     201RpOption_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 * ======================================================================
    177213 *  INTEGER
    178214 * ======================================================================
     
    335371    *(char***)(cdata+offset) = NULL;
    336372}
     373
     374/*
     375 * ======================================================================
     376 *  CHOICES
     377 * ======================================================================
     378 */
     379int
     380RpOption_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
     392int
     393RpOption_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
     403void
     404RpOption_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.