Changeset 1384 for trunk/lang


Ignore:
Timestamp:
Apr 6, 2009, 10:19:50 AM (16 years ago)
Author:
gah
Message:
 
Location:
trunk/lang
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lang/python/Rappture/PyRpEncode.cc

    r1368 r1384  
    4545    }
    4646
    47     rv = PyFloat_FromDouble(Rappture::encoding::isbinary(data,dlen));
    48 
     47    rv = PyFloat_FromDouble(Rappture::encoding::isBinary(data,dlen));
    4948    return rv;
    5049}
  • trunk/lang/tcl/src/RpEncodeTclInterface.cc

    r1383 r1384  
    1919}
    2020
    21 static Tcl_ObjCmdProc RpTclEncodingIs;
    22 static Tcl_ObjCmdProc RpTclEncodingEncode;
    23 static Tcl_ObjCmdProc RpTclEncodingDecode;
     21static Tcl_ObjCmdProc IsCmd;
     22static Tcl_ObjCmdProc EncodeCmd;
     23static Tcl_ObjCmdProc DecodeCmd;
    2424
    2525/**********************************************************************/
     
    3737RpEncoding_Init(Tcl_Interp *interp)
    3838{
    39 
    4039    Tcl_CreateObjCommand(interp, "::Rappture::encoding::is",
    41         RpTclEncodingIs, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     40        IsCmd, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    4241
    4342    Tcl_CreateObjCommand(interp, "::Rappture::encoding::encode",
    44         RpTclEncodingEncode, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     43        EncodeCmd, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    4544
    4645    Tcl_CreateObjCommand(interp, "::Rappture::encoding::decode",
    47         RpTclEncodingDecode, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
    48 
    49     return TCL_OK;
    50 }
    51 
    52 /**********************************************************************/
    53 // FUNCTION: RpTclEncodingIs()
     46        DecodeCmd, (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
     47    return TCL_OK;
     48}
     49
     50/**********************************************************************/
     51// FUNCTION: IsCmd()
    5452/// Rappture::encoding::is checks to see if given string is binary.
    5553/**
     
    6159
    6260static int
    63 RpTclEncodingIs (ClientData cdata, Tcl_Interp *interp,
    64     int objc, Tcl_Obj *const objv[])
     61IsCmd(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const *objv)
    6562{
    6663    Tcl_ResetResult(interp);
     
    7976    const char *buf;
    8077    const char *string;
    81     buf = (const char*) Tcl_GetByteArrayFromObj(objv[2], &bufLen);
     78    buf = (const char *)Tcl_GetByteArrayFromObj(objv[2], &bufLen);
    8279    const char *type = Tcl_GetString(objv[1]);
    83     if (('b' == *type) && (strcmp(type,"binary") == 0)) {
    84         bool isBinary;
    85 
    86         isBinary = (Rappture::encoding::isbinary(buf,bufLen) != 0);
    87         string = (isBinary) ? "yes" : "no" ;
     80    if (('b' == *type) && (strcmp(type, "binary") == 0)) {
     81        string = (Rappture::encoding::isBinary(buf, bufLen)) ? "yes" : "no";
    8882    } else if (('e' == *type) && (strcmp(type,"encoded") == 0)) {
    8983        bool isEncoded;
     
    10195
    10296/**********************************************************************/
    103 // FUNCTION: RpTclEncodingEncode()
     97// FUNCTION: EncodeCmd --
    10498/// Rappture::encoding::encode function in Tcl, encodes provided string
    10599/**
     
    167161typedef struct {
    168162    unsigned int flags;
    169     unsigned int noheader;
    170163} EncodeSwitches;
    171164
     
    174167    {SWITCH_CUSTOM, "-as", "z|b64|zb64",
    175168        offsetof(EncodeSwitches, flags), 0, 0, &asSwitch},
    176     {SWITCH_VALUE, "-no-header", "",
    177         offsetof(EncodeSwitches, noheader), 0, true},
     169    {SWITCH_BITMASK, "-noheader", "",
     170        offsetof(EncodeSwitches, flags), 0, RPENC_RAW},
    178171    {SWITCH_END}
    179172};
    180173
    181174static int
    182 RpTclEncodingEncode (ClientData cdata, Tcl_Interp *interp, int objc,
    183                      Tcl_Obj *const *objv)
     175EncodeCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     176          Tcl_Obj *const *objv)
    184177{
    185178    if (objc < 1) {
    186179        Tcl_AppendResult(interp, "wrong # args: should be \"",
    187180                Tcl_GetString(objv[0]),
    188                 " ?-as z|b64|zb64? ?-no-header? ?--? string\"", (char*)NULL);
     181                " ?-as z|b64|zb64? ?-noheader? ?--? string\"", (char*)NULL);
    189182        return TCL_ERROR;
    190183    }
    191184    EncodeSwitches switches;
    192185    switches.flags = 0;
    193     switches.noheader = 0;
    194186    int n;
    195187    n = Rp_ParseSwitches(interp, encodeSwitches, objc - 1, objv + 1, &switches,
     
    203195        Tcl_AppendResult(interp, "wrong # args: should be \"",
    204196                Tcl_GetString(objv[0]),
    205                 " ?-as z|b64|zb64? ?-no-header? ?--? string\"", (char*)NULL);
     197                " ?-as z|b64|zb64? ?-noheader? ?--? string\"", (char*)NULL);
    206198        return TCL_ERROR;
    207199    }
     
    213205    }
    214206    Rappture::Buffer buf(string, nBytes);
    215     if (!switches.noheader) {
    216         switches.flags |= RPENC_HDR;
    217     }
    218207    Rappture::Outcome status;
    219208    if (!Rappture::encoding::encode(status, buf, switches.flags)) {
     
    227216
    228217/**********************************************************************/
    229 // FUNCTION: RpTclEncodingDecode()
     218// FUNCTION: DecodeCmd()
    230219/// Rappture::encoding::decode function in Tcl, decodes provided string
    231220/**
     
    236225 * Full function call:
    237226 * ::Rappture::encoding::decode ?-as z|b64|zb64? <string>
     227 *
     228 *      I'd rather the interface be
     229 *     
     230 *              decode -b64 -z string
    238231 */
    239232
     
    246239    {SWITCH_CUSTOM, "-as", "z|b64|zb64",
    247240        offsetof(DecodeSwitches, flags), 0, 0, &asSwitch},
     241    {SWITCH_BITMASK, "-raw", "",
     242        offsetof(DecodeSwitches, flags), 0, RPENC_RAW},
    248243    {SWITCH_END}
    249244};
    250245
    251246static int
    252 RpTclEncodingDecode(ClientData clientData, Tcl_Interp *interp, int objc,
    253                     Tcl_Obj *const *objv)
     247DecodeCmd(ClientData clientData, Tcl_Interp *interp, int objc,
     248          Tcl_Obj *const *objv)
    254249{
    255250    if (objc < 1) {
Note: See TracChangeset for help on using the changeset viewer.