Changeset 2046 for branches/blt4/lang


Ignore:
Timestamp:
Jan 18, 2011, 7:18:39 PM (14 years ago)
Author:
gah
Message:

update from r6 branch

Location:
branches/blt4/lang
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/blt4/lang/octave/octave2/Makefile.in

    r1948 r2046  
    3838                rpLibElement.oct \
    3939                rpLibGet.oct \
     40                rpLibGetData.oct \
    4041                rpLibGetString.oct \
    4142                rpLibGetDouble.oct \
  • branches/blt4/lang/octave/octave3/Makefile.in

    r1948 r2046  
    3838                rpLibElement.oct \
    3939                rpLibGet.oct \
     40                rpLibGetData.oct \
    4041                rpLibGetString.oct \
    4142                rpLibGetDouble.oct \
  • branches/blt4/lang/python/Rappture/PyRpEncode.cc

    r1384 r2046  
    3030
    3131    static char *kwlist[] = {
    32         (char *)"data",
    33         NULL
     32        (char *)"data",
     33        NULL
    3434    };
    3535
     
    6565
    6666    static char *kwlist[] = {
    67         (char *)"data",
    68         (char *)"flags",
    69         NULL
     67        (char *)"data",
     68        (char *)"flags",
     69        NULL
    7070    };
    7171
     
    8383    Rappture::Buffer buf(data, dlen);
    8484    if (!Rappture::encoding::encode(err, buf, flags)) {
    85         std::string outStr;
     85        std::string outStr;
    8686
    8787        outStr = err.remark();
    88         outStr += "\n";
    89         outStr += err.context();
     88        outStr += "\n";
     89        outStr += err.context();
    9090        PyErr_SetString(PyExc_RuntimeError, outStr.c_str());
    9191        buf.clear();
     
    112112
    113113    static char *kwlist[] = {
    114         (char *)"data",
    115         (char *)"flags",
    116         NULL
     114        (char *)"data",
     115        (char *)"flags",
     116        NULL
    117117    };
    118118
     
    130130    Rappture::Buffer buf(data, dlen);
    131131    if (!Rappture::encoding::decode(err, buf, flags)) {
    132         std::string outStr;
     132        std::string outStr;
    133133
    134134        outStr = err.remark();
    135         outStr += "\n";
    136         outStr += err.context();
     135        outStr += "\n";
     136        outStr += err.context();
    137137        PyErr_SetString(PyExc_RuntimeError,outStr.c_str());
    138138        return NULL;
     
    173173    if (ErrorObject == NULL) {
    174174        ErrorObject = PyErr_NewException((char *)"Rappture.encoding.error",
    175                 NULL, NULL);
     175                NULL, NULL);
    176176        if (ErrorObject == NULL) {
    177177            return;
    178         }
     178        }
    179179    }
    180180    Py_INCREF(ErrorObject);
  • branches/blt4/lang/tcl/Makefile.in

    r1948 r2046  
    3636RM              = rm -f
    3737
    38 tcllib          = $$RAPPTURE_INSTALL_DIR/lib/tcl$(TCL_VERSION)
    39 tklib           = $$RAPPTURE_INSTALL_DIR/lib/tk$(TK_VERSION)
    40 
    4138# The script directory is moved from src/tcl.
    4239
  • branches/blt4/lang/tcl/src/RpEncodeTclInterface.cc

    r1409 r2046  
    8181        string = (Rappture::encoding::isBinary(buf, bufLen)) ? "yes" : "no";
    8282    } else if (('e' == *type) && (strcmp(type,"encoded") == 0)) {
    83         bool isEncoded;
     83        bool isEncoded;
    8484
    8585        isEncoded = (Rappture::encoding::headerFlags(buf, bufLen) != 0);
    86         string = (isEncoded) ? "yes" : "no" ;
     86        string = (isEncoded) ? "yes" : "no" ;
    8787    } else {
    88         Tcl_AppendResult(interp, "bad option \"", type,
    89                 "\": should be binary or encoded", (char*)NULL);
    90         return TCL_ERROR;
     88        Tcl_AppendResult(interp, "bad option \"", type,
     89                "\": should be binary or encoded", (char*)NULL);
     90        return TCL_ERROR;
    9191    }
    9292    Tcl_SetResult(interp, (char *)string, TCL_STATIC);
     
    114114 * AsSwitch --
    115115 *
    116  *      Convert a string represent a node number into its integer
    117  *      value.
     116 *        Convert a string represent a node number into its integer
     117 *        value.
    118118 *
    119119 * Results:
    120  *      The return value is a standard Tcl result.
     120 *        The return value is a standard Tcl result.
    121121 *
    122122 *---------------------------------------------------------------------------
     
    125125static int
    126126AsSwitch(
    127     ClientData clientData,      /* Not used. */
    128     Tcl_Interp *interp,         /* Interpreter to send results back to */
    129     const char *switchName,     /* Not used. */
    130     Tcl_Obj *objPtr,            /* String representation */
    131     char *record,               /* Structure record */
    132     int offset,                 /* Offset to field in structure */
    133     int flags)                  /* Not used. */
     127    ClientData clientData,        /* Not used. */
     128    Tcl_Interp *interp,                /* Interpreter to send results back to */
     129    const char *switchName,        /* Not used. */
     130    Tcl_Obj *objPtr,                /* String representation */
     131    char *record,                /* Structure record */
     132    int offset,                        /* Offset to field in structure */
     133    int flags)                        /* Not used. */
    134134{
    135135    int *flagsPtr = (int *)(record + offset);
     
    140140    c = string[0];
    141141    if ((c == 'b') && (strcmp(string, "b64") == 0)) {
    142         *flagsPtr = RPENC_B64;
     142        *flagsPtr = RPENC_B64;
    143143    } else if ((c == 'z') && (strcmp(string, "zb64") == 0)) {
    144         *flagsPtr = RPENC_Z  | RPENC_B64;
     144        *flagsPtr = RPENC_Z  | RPENC_B64;
    145145    } else if ((c == 'z') && (strcmp(string, "z") == 0)) {
    146         *flagsPtr = RPENC_Z;
     146        *flagsPtr = RPENC_Z;
    147147    } else {
    148         Tcl_AppendResult(interp, "bad value \"", string,
    149                 "\": should be b64, zb64, or z", (char *)NULL);
    150         return TCL_ERROR;
     148        Tcl_AppendResult(interp, "bad value \"", string,
     149                "\": should be b64, zb64, or z", (char *)NULL);
     150        return TCL_ERROR;
    151151    }
    152152    return TCL_OK;
     
    165165{
    166166    {SWITCH_CUSTOM, "-as", "z|b64|zb64",
    167         offsetof(EncodeSwitches, flags), 0, 0, &asSwitch},
     167        offsetof(EncodeSwitches, flags), 0, 0, &asSwitch},
    168168    {SWITCH_BITMASK, "-noheader", "",
    169         offsetof(EncodeSwitches, flags), 0, RPENC_RAW},
     169        offsetof(EncodeSwitches, flags), 0, RPENC_RAW},
    170170    {SWITCH_END}
    171171};
     
    173173static int
    174174EncodeCmd(ClientData clientData, Tcl_Interp *interp, int objc,
    175           Tcl_Obj *const *objv)
     175          Tcl_Obj *const *objv)
    176176{
    177177    if (objc < 1) {
    178178        Tcl_AppendResult(interp, "wrong # args: should be \"",
    179                 Tcl_GetString(objv[0]),
    180                 " ?-as z|b64|zb64? ?-noheader? ?--? string\"", (char*)NULL);
     179                Tcl_GetString(objv[0]),
     180                " ?-as z|b64|zb64? ?-noheader? ?--? string\"", (char*)NULL);
    181181        return TCL_ERROR;
    182182    }
     
    185185    int n;
    186186    n = Rp_ParseSwitches(interp, encodeSwitches, objc - 1, objv + 1, &switches,
    187                         SWITCH_OBJV_PARTIAL);
     187                        SWITCH_OBJV_PARTIAL);
    188188    if (n < 0) {
    189         return TCL_ERROR;
     189        return TCL_ERROR;
    190190    }
    191191    int last;
     
    193193    if ((objc - last) != 1) {
    194194        Tcl_AppendResult(interp, "wrong # args: should be \"",
    195                 Tcl_GetString(objv[0]),
    196                 " ?-as z|b64|zb64? ?-noheader? ?--? string\"", (char*)NULL);
     195                Tcl_GetString(objv[0]),
     196                " ?-as z|b64|zb64? ?-noheader? ?--? string\"", (char*)NULL);
    197197        return TCL_ERROR;
    198198    }
     
    201201    string = (const char*)Tcl_GetByteArrayFromObj(objv[last], &nBytes);
    202202    if (nBytes <= 0) {
    203         return TCL_OK;          // Nothing to encode.
     203        return TCL_OK;                // Nothing to encode.
    204204    }
    205205    Rappture::Buffer buf(string, nBytes);
     
    207207    if (!Rappture::encoding::encode(status, buf, switches.flags)) {
    208208        Tcl_AppendResult(interp, status.remark(), "\n", status.context(), NULL);
    209         return TCL_ERROR;
     209        return TCL_ERROR;
    210210    }
    211211    Tcl_SetByteArrayObj(Tcl_GetObjResult(interp),
    212                 (const unsigned char*)buf.bytes(), buf.size());
     212                (const unsigned char*)buf.bytes(), buf.size());
    213213    return TCL_OK;
    214214}
     
    225225 * ::Rappture::encoding::decode ?-as z|b64|zb64? <string>
    226226 *
    227  *      I'd rather the interface be
    228  *     
    229  *              decode -b64 -z string
     227 *        I'd rather the interface be
     228 *       
     229 *                decode -b64 -z string
    230230 */
    231231
     
    237237{
    238238    {SWITCH_CUSTOM, "-as", "z|b64|zb64",
    239         offsetof(DecodeSwitches, flags), 0, 0, &asSwitch},
     239        offsetof(DecodeSwitches, flags), 0, 0, &asSwitch},
    240240    {SWITCH_BITMASK, "-noheader", "",
    241         offsetof(DecodeSwitches, flags), 0, RPENC_RAW},
     241        offsetof(DecodeSwitches, flags), 0, RPENC_RAW},
    242242    {SWITCH_END}
    243243};
     
    245245static int
    246246DecodeCmd(ClientData clientData, Tcl_Interp *interp, int objc,
    247           Tcl_Obj *const *objv)
     247          Tcl_Obj *const *objv)
    248248{
    249249    if (objc < 1) {
    250250        Tcl_AppendResult(interp, "wrong # args: should be \"",
    251                 Tcl_GetString(objv[0]),
     251                Tcl_GetString(objv[0]),
    252252                " ?-as z|b64|zb64? ?--? <string>\"", (char*)NULL);
    253253        return TCL_ERROR;
     
    258258    int n;
    259259    n = Rp_ParseSwitches(interp, decodeSwitches, objc - 1, objv + 1, &switches,
    260                         SWITCH_OBJV_PARTIAL);
     260                        SWITCH_OBJV_PARTIAL);
    261261    if (n < 0) {
    262         return TCL_ERROR;
     262        return TCL_ERROR;
    263263    }
    264264    int last;
     
    266266    if ((objc - last) != 1) {
    267267        Tcl_AppendResult(interp, "wrong # args: should be \"",
    268                 Tcl_GetString(objv[0]),
    269                 " ?-as z|b64|zb64? ?--? string\"", (char*)NULL);
     268                Tcl_GetString(objv[0]),
     269                " ?-as z|b64|zb64? ?--? string\"", (char*)NULL);
    270270        return TCL_ERROR;
    271271    }
     
    274274    string = (const char*)Tcl_GetByteArrayFromObj(objv[last], &nBytes);
    275275    if (nBytes <= 0) {
    276         return TCL_OK;          // Nothing to decode.
     276        return TCL_OK;                // Nothing to decode.
    277277    }
    278278    Rappture::Buffer buf(string, nBytes);
     
    280280    if (!Rappture::encoding::decode(status, buf, switches.flags)) {
    281281        Tcl_AppendResult(interp, status.remark(), "\n", status.context(), NULL);
    282         return TCL_ERROR;
     282        return TCL_ERROR;
    283283    }
    284284    Tcl_SetByteArrayObj(Tcl_GetObjResult(interp),
    285                 (const unsigned char*)buf.bytes(), buf.size());
    286     return TCL_OK;
    287 }
     285                (const unsigned char*)buf.bytes(), buf.size());
     286    return TCL_OK;
     287}
  • branches/blt4/lang/tcl/src/RpVideoTclInterface.cc

    r1932 r2046  
    2828static Tcl_ObjCmdProc SizeOp;
    2929static Tcl_ObjCmdProc ReleaseOp;
     30static Tcl_ObjCmdProc FilenameOp;
     31static Tcl_ObjCmdProc FramerateOp;
     32static Tcl_ObjCmdProc AspectOp;
    3033
    3134static Rp_OpSpec rpVideoOps[] = {
    32     {"get",  1, (void *)GetOp, 3, 5, "[image ?width height?]|[position cur|end]|[framerate]",},
    33     {"next",  1, (void *)NextOp, 2, 2, "",},
    34     {"seek",  1, (void *)SeekOp, 3, 3, "+n|-n|n",},
    35     {"size",  1, (void *)SizeOp, 2, 2, "",},
    36     {"release", 1, (void *)ReleaseOp, 2, 2, "",},
     35    {"aspect",    1, (void *)AspectOp, 3, 3, "type",},
     36    {"filename",  1, (void *)FilenameOp, 2, 2, "",},
     37    {"framerate", 1, (void *)FramerateOp, 2, 2, "",},
     38    {"get",       1, (void *)GetOp, 3, 5, "[image ?width height?]|[position cur|end]",},
     39    {"next",      1, (void *)NextOp, 2, 2, "",},
     40    {"release",   1, (void *)ReleaseOp, 2, 2, "",},
     41    {"seek",      1, (void *)SeekOp, 3, 3, "+n|-n|n",},
     42    {"size",      1, (void *)SizeOp, 2, 2, "",},
    3743};
    3844
     
    8187    // create a new command
    8288    VideoObj *movie = NULL;
    83     movie = VideoInitCmd();
     89    movie = VideoInit();
    8490    if (movie == NULL) {
    8591        Tcl_AppendResult(interp, "error while creating movie object", "\n",
    86                          "VideoInitCmd(movie);", (char*)NULL);
     92                         "VideoInit(movie);", (char*)NULL);
    8793        return TCL_ERROR;
    8894    }
     
    9096    if ((*type == 'd') && (strcmp(type,"data") == 0)) {
    9197        Tcl_AppendResult(interp, "error while creating movie: type == data not supported",
    92                          "\n", "VideoInitCmd(movie);", (char*)NULL);
     98                         "\n", "VideoInit(movie);", (char*)NULL);
    9399        return TCL_ERROR;
    94100    } else if ((*type == 'f') && (strcmp(type,"file") == 0)) {
     
    96102        if (err) {
    97103            Tcl_AppendResult(interp, "error while creating movie object: ",
    98                              "\n", "VideoInitCmd(movie);", (char*)NULL);
     104                             "\n", "VideoInit(movie);", (char*)NULL);
    99105            return TCL_ERROR;
    100106        }
     
    137143 * get image ?width height?
    138144 * get framerate
     145 * get filename
     146 * get aspectratio
    139147 *
    140148 */
     
    200208                            (const unsigned char*)img, bufSize);
    201209    }
     210/*
    202211    else if ((*info == 'f') && (strcmp(info,"framerate") == 0)) {
    203212        if (objc != 3) {
     
    218227        Tcl_SetObjResult(interp, Tcl_NewDoubleObj(fr));
    219228    }
     229    else if ((*info == 'f') && (strcmp(info,"filename") == 0)) {
     230        if (objc != 3) {
     231            Tcl_AppendResult(interp, "wrong # args: should be \"", cmd,
     232                " filename\"", (char*)NULL);
     233            return TCL_ERROR;
     234        }
     235
     236        const char *fname = NULL;
     237        int err = 0;
     238
     239        err = VideoGetFileName((VideoObj *)clientData, &fname);
     240        if (err) {
     241            Tcl_AppendResult(interp, "error while retrieving filename",
     242                (char*)NULL);
     243            return TCL_ERROR;
     244        }
     245        Tcl_AppendResult(interp, fname, (char*)NULL);
     246    }
     247    else if ((*info == 'a') && (strcmp(info,"aspectratio") == 0)) {
     248        if (objc != 3) {
     249            Tcl_AppendResult(interp, "wrong # args: should be \"", cmd,
     250                " aspectratio\"", (char*)NULL);
     251            return TCL_ERROR;
     252        }
     253
     254        int num = 0;
     255        int den = 0;
     256        int err = 0;
     257
     258        err = VideoGetAspectRatio((VideoObj *)clientData, &num, &den);
     259        if (err) {
     260            Tcl_AppendResult(interp, "error while retrieving aspectratio",
     261                (char*)NULL);
     262            return TCL_ERROR;
     263        }
     264
     265        Tcl_Obj *dim = NULL;
     266        dim = Tcl_NewListObj(0, NULL);
     267        Tcl_ListObjAppendElement(interp, dim, Tcl_NewIntObj(num));
     268        Tcl_ListObjAppendElement(interp, dim, Tcl_NewIntObj(den));
     269        Tcl_SetObjResult(interp, dim);
     270    }
     271*/
    220272    else {
    221273        Tcl_AppendResult(interp, "unrecognized command \"", info, "\": should be \"", cmd,
     
    243295         Tcl_Obj *const *objv)
    244296{
    245 
    246 //    void *img = NULL;
    247 //    int width = 960;
    248 //    int height = 540;
    249 //    int bufSize = 0;
    250 
    251297    int pos = 0;
    252298    VideoGoNext((VideoObj *)clientData);
    253299    VideoGetPositionCur((VideoObj *)clientData,&pos);
    254300    Tcl_SetObjResult(interp, Tcl_NewIntObj(pos));
    255 //    VideoGetImage((VideoObj *)clientData, width, height, &img, &bufSize);
    256 
    257 //    Tcl_SetByteArrayObj(Tcl_GetObjResult(interp),
    258 //                        (const unsigned char*)img, bufSize);
    259301
    260302    return TCL_OK;
     
    277319         Tcl_Obj *const *objv)
    278320{
    279 
    280 //    void *img = NULL;
    281 //    int width = 960;
    282 //    int height = 540;
    283 //    int bufSize = 0;
    284321    const char *val_s = NULL;
    285322    int val = 0;
     
    311348        int c = 0;
    312349        c = VideoGoToN((VideoObj *)clientData, val);
    313         // printf("c = %d\tval = %d\n",c,val);
    314     }
    315 
    316 //    VideoGetImage((VideoObj *)clientData, width, height, &img, &bufSize);
    317 
    318 //    if (img == NULL) {
    319 //        printf("img is null\n");
    320 //    }
    321 
    322 //    Tcl_SetByteArrayObj(Tcl_GetObjResult(interp),
    323 //                        (const unsigned char*)img, bufSize);
     350    }
    324351
    325352    VideoGetPositionCur((VideoObj *)clientData,&pos);
     
    331358/**********************************************************************/
    332359// FUNCTION: SizeOp()
    333 /// Get the size of the video
    334 /**
    335  * Return the original size of the video frame
     360/// Get the width height of the video
     361/**
     362 * Return the original width and height of the video frame
    336363 *
    337364 * Full function call:
     
    351378
    352379
    353     err = VideoSizeCmd((VideoObj *)clientData,&width,&height);
     380    err = VideoSize((VideoObj *)clientData,&width,&height);
    354381
    355382    if (err) {
     
    369396
    370397/**********************************************************************/
     398// FUNCTION: FilenameOp()
     399/// Get the filename of the video
     400/**
     401 * Return the original filename of the video
     402 *
     403 * Full function call:
     404 *
     405 * filename
     406 *
     407 */
     408static int
     409FilenameOp (ClientData clientData, Tcl_Interp *interp, int objc,
     410         Tcl_Obj *const *objv)
     411{
     412    const char *fname = NULL;
     413    int err = 0;
     414
     415    err = VideoFileName((VideoObj *)clientData, &fname);
     416    if (err) {
     417        Tcl_AppendResult(interp, "error while retrieving filename",
     418            (char*)NULL);
     419        return TCL_ERROR;
     420    }
     421    Tcl_AppendResult(interp, fname, (char*)NULL);
     422
     423    return TCL_OK;
     424}
     425
     426/**********************************************************************/
     427// FUNCTION: FramerateOp()
     428/// Get the framerate of the video
     429/**
     430 * Return the framerate of the video
     431 *
     432 * Full function call:
     433 *
     434 * framerate
     435 *
     436 */
     437static int
     438FramerateOp (ClientData clientData, Tcl_Interp *interp, int objc,
     439         Tcl_Obj *const *objv)
     440{
     441    double fr = 0;
     442    int err = 0;
     443
     444    err = VideoFrameRate((VideoObj *)clientData, &fr);
     445    if (err) {
     446        Tcl_AppendResult(interp, "error while calculating framerate",
     447            (char*)NULL);
     448        return TCL_ERROR;
     449    }
     450    Tcl_SetObjResult(interp, Tcl_NewDoubleObj(fr));
     451
     452    return TCL_OK;
     453}
     454
     455/**********************************************************************/
     456// FUNCTION: AspectOp()
     457/// Get the aspect ratio of the video
     458/**
     459 * Return either the pixel or display aspect ratio of the video
     460 * Full function call:
     461 *
     462 * aspect pixel
     463 * aspect display
     464 *
     465 */
     466static int
     467AspectOp (ClientData clientData, Tcl_Interp *interp, int objc,
     468         Tcl_Obj *const *objv)
     469{
     470    int err = 0;
     471    int num = 0;
     472    int den = 1;
     473    Tcl_Obj *dim = NULL;
     474
     475    const char *cmd = Tcl_GetString(objv[1]);
     476    const char *info = Tcl_GetString(objv[2]);
     477
     478    if ((*cmd == 'p') && (strcmp(info,"pixel") == 0)) {
     479        err = VideoPixelAspectRatio((VideoObj *)clientData, &num, &den);
     480    }
     481    else if ((*info == 'd') && (strcmp(info,"display") == 0)) {
     482        err = VideoDisplayAspectRatio((VideoObj *)clientData, &num, &den);
     483    }
     484    else {
     485        Tcl_AppendResult(interp, "unrecognized command \"", info, "\": should be \"", cmd,
     486            " pixel|display\"", (char*)NULL);
     487        return TCL_ERROR;
     488    }
     489
     490    if (err) {
     491        Tcl_AppendResult(interp, "error while retrieving ", info,
     492            " aspect ratio", (char*)NULL);
     493        return TCL_ERROR;
     494    }
     495
     496    dim = Tcl_NewListObj(0, NULL);
     497    Tcl_ListObjAppendElement(interp, dim, Tcl_NewIntObj(num));
     498    Tcl_ListObjAppendElement(interp, dim, Tcl_NewIntObj(den));
     499    Tcl_SetObjResult(interp, dim);
     500
     501    return TCL_OK;
     502}
     503/**********************************************************************/
    371504// FUNCTION: ReleaseOp()
    372505/// Clean up memory from an open video in a movie player object
Note: See TracChangeset for help on using the changeset viewer.