本文整理汇总了C++中Tcl_NewListObj函数的典型用法代码示例。如果您正苦于以下问题:C++ Tcl_NewListObj函数的具体用法?C++ Tcl_NewListObj怎么用?C++ Tcl_NewListObj使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Tcl_NewListObj函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: methodToListObj
static TclObject
methodToListObj (const Method &method)
{
TclObject list(Tcl_NewListObj(0, 0));
// Put member id.
list.lappend(Tcl_NewIntObj(method.memberid()));
// Put return type.
list.lappend(typeToListObj(method.type()));
// Put method name.
list.lappend(
Tcl_NewStringObj(const_cast<char *>(method.name().c_str()), -1));
// Put parameters.
TclObject parameterList(Tcl_NewListObj(0, 0));
const Method::Parameters ¶meters = method.parameters();
for (Method::Parameters::const_iterator p = parameters.begin();
p != parameters.end(); ++p) {
parameterList.lappend(parameterToListObj(*p));
}
list.lappend(parameterList);
return list;
}
示例2: _get
static int _get(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj* const *objv) {
if (argc != 2)
return fw_error_obj(interp, Tcl_ObjPrintf("usage: %s get", Tcl_GetString(objv[0])));
_t *data = (_t *)clientData;
if ( ! data->started)
return fw_error_obj(interp, Tcl_ObjPrintf("audio-tap %s is not running", Tcl_GetString(objv[0])));
// figure out where to read from
while (1) {
// start with no choice
buffer_t *choice = NULL;
// look for the oldest unread buffer
for (int i = 0; i < data->buff_n; i += 1)
if ( ! data->buffs[i].bread && (choice == NULL || choice->bframe > data->buffs[i].bframe))
choice = &data->buffs[i];
// if nothing was found, return an empty string
if (choice == NULL) {
Tcl_Obj *result[] = { Tcl_NewLongObj(0), Tcl_NewStringObj("", -1), NULL };
return fw_success_obj(interp, Tcl_NewListObj(2, result));
}
// attempt to grab the choice
Tcl_IncrRefCount(choice->buff);
// if it's now marked as read, then the process callback grabbed it
// loop back and try again
if (choice->bread) {
Tcl_DecrRefCount(choice->buff);
continue;
}
// it's ours now that the ref count incremented
Tcl_Obj *result[] = { Tcl_NewLongObj(choice->bframe), choice->buff, NULL };
Tcl_SetObjResult(interp, Tcl_NewListObj(2, result));
Tcl_DecrRefCount(choice->buff);
choice->bread = 1;
return TCL_OK;
}
}
示例3: TkpGetSubFonts
void
TkpGetSubFonts(
Tcl_Interp *interp,
Tk_Font tkfont)
{
Tcl_Obj *objv[3], *listPtr, *resultPtr;
UnixFtFont *fontPtr = (UnixFtFont *) tkfont;
FcPattern *pattern;
char *family = "Unknown", **familyPtr = &family;
char *foundry = "Unknown", **foundryPtr = &foundry;
char *encoding = "Unknown", **encodingPtr = &encoding;
int i;
resultPtr = Tcl_NewListObj(0, NULL);
for (i = 0; i < fontPtr->nfaces ; ++i) {
pattern = FcFontRenderPrepare(0, fontPtr->pattern,
fontPtr->faces[i].source);
XftPatternGetString(pattern, XFT_FAMILY, 0, familyPtr);
XftPatternGetString(pattern, XFT_FOUNDRY, 0, foundryPtr);
XftPatternGetString(pattern, XFT_ENCODING, 0, encodingPtr);
objv[0] = Tcl_NewStringObj(family, -1);
objv[1] = Tcl_NewStringObj(foundry, -1);
objv[2] = Tcl_NewStringObj(encoding, -1);
listPtr = Tcl_NewListObj(3, objv);
Tcl_ListObjAppendElement(NULL, resultPtr, listPtr);
}
Tcl_SetObjResult(interp, resultPtr);
}
示例4: parameterToListObj
static TclObject
parameterToListObj (const Parameter ¶meter)
{
TclObject list(Tcl_NewListObj(0, 0));
// Put parameter passing modes.
TclObject modes(Tcl_NewListObj(0, 0));
if (parameter.flags() & PARAMFLAG_FIN) {
modes.lappend(Tcl_NewStringObj("in", -1));
}
if (parameter.flags() & PARAMFLAG_FOUT) {
modes.lappend(Tcl_NewStringObj("out", -1));
}
list.lappend(modes);
// Put parameter type.
list.lappend(typeToListObj(parameter.type()));
// Put parameter name.
list.lappend(
Tcl_NewStringObj(const_cast<char *>(parameter.name().c_str()), -1));
return list;
}
示例5: Tcl_NewListObj
void TclTextInterp::graph_label_cb(const char *type, const int *ids, int n) {
Tcl_Obj *itemlist = Tcl_NewListObj(0, NULL);
for (int i=0; i<n; i++) {
Tcl_Obj *item = Tcl_NewListObj(0, NULL);
Tcl_ListObjAppendElement(interp, item, Tcl_NewStringObj(type, -1));
Tcl_ListObjAppendElement(interp, item, Tcl_NewIntObj(ids[i]));
Tcl_ListObjAppendElement(interp, itemlist, item);
}
Tcl_Obj *varname = Tcl_NewStringObj("vmd_graph_label", -1);
if (!Tcl_ObjSetVar2(interp, varname, NULL, itemlist,
TCL_LEAVE_ERR_MSG | TCL_GLOBAL_ONLY)) {
msgErr << "Error graphing labels: " << Tcl_GetStringResult(interp) << sendmsg;
}
}
示例6: TkpGetFontFamilies
void
TkpGetFontFamilies(
Tcl_Interp *interp, /* Interp to hold result. */
Tk_Window tkwin) /* For display to query. */
{
Tcl_Obj *resultPtr;
XftFontSet *list;
int i;
resultPtr = Tcl_NewListObj(0, NULL);
list = XftListFonts(Tk_Display(tkwin), Tk_ScreenNumber(tkwin),
(char*)0, /* pattern elements */
XFT_FAMILY, (char*)0); /* fields */
for (i = 0; i < list->nfont; i++) {
char *family, **familyPtr = &family;
if (XftPatternGetString(list->fonts[i], XFT_FAMILY, 0, familyPtr)
== XftResultMatch)
{
Tcl_Obj *strPtr = Tcl_NewStringObj(family, -1);
Tcl_ListObjAppendElement(NULL, resultPtr, strPtr);
}
}
XftFontSetDestroy(list);
Tcl_SetObjResult(interp, resultPtr);
}
示例7: Async_Exec_Names_Cmd
/* usage: async_exec_names
Return list of names of registered async executors
*/
static int
Async_Exec_Names_Cmd(ClientData cdata, Tcl_Interp* interp,
int objc, Tcl_Obj* const objv[])
{
TCL_ARGS(1);
turbine_code tc;
const int names_size = TURBINE_ASYNC_EXEC_LIMIT;
const char *names[names_size];
int n;
tc = turbine_async_exec_names(names, names_size, &n);
TCL_CONDITION(tc == TURBINE_SUCCESS, "Error enumerating executors");
assert(n >= 0 && n <= names_size);
Tcl_Obj * name_objs[n];
for (int i = 0; i < n; i++)
{
const char *exec_name = names[i];
assert(exec_name != NULL);
name_objs[i] = Tcl_NewStringObj(exec_name, -1);
TCL_CONDITION(name_objs[i] != NULL, "Error allocating string");
}
Tcl_SetObjResult(interp, Tcl_NewListObj(n, name_objs));
return TCL_OK;
}
示例8: alsa_pcm_list
static int alsa_pcm_list(ClientData clientData, Tcl_Interp *interp)
{
void **hints, **n;
Tcl_Obj *pcm = Tcl_NewListObj(0, NULL);
if (snd_device_name_hint(-1, "pcm", &hints) >= 0) {
n = hints;
while (*n != NULL) {
char *name, *descr, *io;
name = snd_device_name_get_hint(*n, "NAME");
descr = snd_device_name_get_hint(*n, "DESC");
io = snd_device_name_get_hint(*n, "IOID");
Tcl_ListObjAppendElement(interp, pcm, Tcl_ObjPrintf("%s %s %s", name?name:"(null)", descr?descr:"(null)", io?io:"(null)"));
if (name != NULL)
free(name);
if (descr != NULL)
free(descr);
if (io != NULL)
free(io);
n++;
}
snd_device_name_free_hint(hints);
}
Tcl_SetObjResult(interp, pcm);
return TCL_OK;
}
示例9: _list_ports
static int _list_ports(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj* const *objv) {
if (argc != 2) return fw_error_str(interp, "jack-client list-ports");
_t *dp = (_t *)clientData;
Tcl_Obj *dict = Tcl_NewDictObj();
const char **portv[] = {
jack_get_ports (dp->fw.client, NULL, JACK_DEFAULT_AUDIO_TYPE, 0),
jack_get_ports (dp->fw.client, NULL, JACK_DEFAULT_MIDI_TYPE, 0)
};
for (int p = 0; p < 2; p += 1)
if (portv[p] != NULL) {
for (int i = 0; portv[p][i] != NULL; i += 1) {
jack_port_t *port = jack_port_by_name(dp->fw.client, portv[p][i]);
if (port != NULL) {
Tcl_Obj *pdict = Tcl_NewDictObj();
int flags = jack_port_flags(port);
Tcl_DictObjPut(interp, pdict, Tcl_NewStringObj("direction", -1), flags & JackPortIsInput ? Tcl_NewStringObj("input", -1) : Tcl_NewStringObj("output", -1) );
Tcl_DictObjPut(interp, pdict, Tcl_NewStringObj("physical", -1), Tcl_NewIntObj(flags & JackPortIsPhysical ? 1 : 0));
Tcl_DictObjPut(interp, pdict, Tcl_NewStringObj("type", -1), p == 0 ? Tcl_NewStringObj("audio", -1) : Tcl_NewStringObj("midi", -1));
const char **connv = jack_port_get_all_connections(dp->fw.client, port);
Tcl_Obj *list = Tcl_NewListObj(0, NULL);
if (connv != NULL) {
for (int j = 0; connv[j] != NULL; j += 1)
Tcl_ListObjAppendElement(interp, list, Tcl_NewStringObj(connv[j], -1));
jack_free(connv);
}
Tcl_DictObjPut(interp, pdict, Tcl_NewStringObj("connections", -1), list);
Tcl_DictObjPut(interp, dict, Tcl_NewStringObj(portv[p][i], -1), pdict);
}
}
jack_free(portv[p]);
}
Tcl_SetObjResult(interp, dict);
return TCL_OK;
}
示例10: Tcl_NewWideIntObj
static Tcl_Obj *ObjFromPtr(void *p, char *name)
{
Tcl_Obj *objs[2];
objs[0] = Tcl_NewWideIntObj((Tcl_WideInt)p);
objs[1] = Tcl_NewStringObj(name ? name : "void*", -1);
return Tcl_NewListObj(2, objs);
}
示例11: xFilter
int xFilter(sqlite3_vtab_cursor *cursorP, int idx, const char *idxstrP,
int argc, sqlite3_value **argv)
{
VTableInfo *vtabP = (VTableInfo *) cursorP->pVtab;
Tcl_Obj *objv[4];
Tcl_Interp *interp;
int i;
if (vtabP->vtdbP == NULL || (interp = vtabP->vtdbP->vticP->interp) == NULL) {
/* Should not really happen */
SetVTableError(vtabP, gNullInterpError);
return SQLITE_ERROR;
}
objv[0] = ObjFromPtr(cursorP, "sqlite3_vtab_cursor*");
objv[1] = Tcl_NewIntObj(idx);
objv[2] = Tcl_NewStringObj(idxstrP ? idxstrP : "", -1);
objv[3] = Tcl_NewListObj(0, NULL);
for (i = 0; i < argc; ++i) {
Tcl_ListObjAppendElement(NULL, objv[3], ObjFromSqliteValue(argv[i], vtabP->vtdbP));
}
if (VTableInvokeCmd(interp, vtabP, "xFilter", 4 , objv) != TCL_OK) {
SetVTableErrorFromInterp(vtabP, interp);
return SQLITE_ERROR;
}
return SQLITE_OK;
}
示例12: StyleElementOptionsCmd
/* + style element options $element --
* Return list of element options for specified element
*/
static int StyleElementOptionsCmd(
ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *const objv[])
{
StylePackageData *pkgPtr = clientData;
Ttk_Theme theme = pkgPtr->currentTheme;
const char *elementName;
Ttk_ElementClass *elementClass;
if (objc != 4) {
Tcl_WrongNumArgs(interp, 3, objv, "element");
return TCL_ERROR;
}
elementName = Tcl_GetString(objv[3]);
elementClass = Ttk_GetElement(theme, elementName);
if (elementClass) {
Ttk_ElementSpec *specPtr = elementClass->specPtr;
Ttk_ElementOptionSpec *option = specPtr->options;
Tcl_Obj *result = Tcl_NewListObj(0,0);
while (option->optionName) {
Tcl_ListObjAppendElement(
interp, result, Tcl_NewStringObj(option->optionName,-1));
++option;
}
Tcl_SetObjResult(interp, result);
return TCL_OK;
}
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"element %s not found", elementName));
Tcl_SetErrorCode(interp, "TTK", "LOOKUP", "ELEMENT", elementName, NULL);
return TCL_ERROR;
}
示例13: Sv_RegisterListCommands
void
Sv_RegisterListCommands(void)
{
static int initialized = 0;
if (initialized == 0) {
Tcl_MutexLock(&initMutex);
if (initialized == 0) {
/* Create list with 1 empty element. */
Tcl_Obj *listobj = Tcl_NewObj();
listobj = Tcl_NewListObj(1, &listobj);
Sv_RegisterObjType(listobj->typePtr, DupListObjShared);
Tcl_DecrRefCount(listobj);
Sv_RegisterCommand("lpop", SvLpopObjCmd, NULL, 0);
Sv_RegisterCommand("lpush", SvLpushObjCmd, NULL, 0);
Sv_RegisterCommand("lappend", SvLappendObjCmd, NULL, 0);
Sv_RegisterCommand("lreplace", SvLreplaceObjCmd, NULL, 0);
Sv_RegisterCommand("linsert", SvLinsertObjCmd, NULL, 0);
Sv_RegisterCommand("llength", SvLlengthObjCmd, NULL, 0);
Sv_RegisterCommand("lindex", SvLindexObjCmd, NULL, 0);
Sv_RegisterCommand("lrange", SvLrangeObjCmd, NULL, 0);
Sv_RegisterCommand("lsearch", SvLsearchObjCmd, NULL, 0);
Sv_RegisterCommand("lset", SvLsetObjCmd, NULL, 0);
initialized = 1;
}
Tcl_MutexUnlock(&initMutex);
}
}
示例14: tclShape2List
/****
* implementation of shape2list (from RFshape creates a list { {a p} {a p} ... }
****/
int tclShape2List(ClientData data,Tcl_Interp* interp,int argc, char *argv[])
{
Tcl_Obj *lptr1, *lptr2;
Tcl_Obj *elemptr[2];
int i, slot;
if (argc != 2)
return TclError(interp,"Usage: <list> shape2list <RFshape>");
if (Tcl_GetInt(interp,argv[1],&slot) == TCL_ERROR)
return TclError(interp,"shape2list: argument must be integer <RFshape>");
/* check for RFshape existence */
if (!RFshapes[slot])
return TclError(interp,"shape2list: trying to acces non-existing RFshape");
/* create list objects */
lptr1 = Tcl_NewListObj(0,NULL);
if (!lptr1) return TclError(interp,"shape2list unable to create outer list");
for (i=1; i<=RFshapes_len(slot); i++) {
elemptr[0] = Tcl_NewDoubleObj(RFshapes[slot][i].ampl);
if (!elemptr[0]) {
/* Tcl_Free(lptr2);
Tcl_Free(lptr1); */
return TclError(interp,"shape2list unable to create double from RFshape amplitude element %d",i);
}
elemptr[1] = Tcl_NewDoubleObj(RFshapes[slot][i].phase);
if (!elemptr[1]) {
/* Tcl_Free(lptr2);
Tcl_Free(lptr1); */
return TclError(interp,"shape2list unable to create double from RFshape amplitude element %d",i);
}
lptr2 = Tcl_NewListObj(2,elemptr);
if (!lptr2) return TclError(interp,"shape2list unable to create inner list");
if ( Tcl_ListObjAppendElement(interp,lptr1,lptr2) != TCL_OK ) {
/* Tcl_Free(lptr2);
Tcl_Free(lptr1); */
return TclError(interp,"shape2list unable to append element %d to oute list",i);
}
}
Tcl_SetObjResult(interp,lptr1);
return TCL_OK;
}
示例15: Tcl_NewListObj
Tcl_Obj* TclUtils::toListOfDouble(Tcl_Interp *interp, const std::vector<double>& v) {
Tcl_Obj *ret = Tcl_NewListObj(0, NULL);
for (std::vector<double>::const_iterator i = v.begin(), end = v.end(); i != end; ++i) {
Tcl_ListObjAppendElement(interp, ret, Tcl_NewDoubleObj(*i));
}
return ret;
}