bool flext_obj::GetParamSym(t_atom &dst,const t_symbol *sym,t_canvas *c) { #if FLEXT_SYS == FLEXT_SYS_PD && defined(PD_MINOR_VERSION) && PD_MINOR_VERSION >= 37 if(!c) c = canvas_getcurrent(); const char *s = GetString(sym); if((s[0] == '$' || s[0] == '#') && isdigit(s[1])) { const t_symbol *res; // patcher parameter detected... get value! if(s[0] != '$') { char tmp[MAXPDSTRING]; strcpy(tmp,s); tmp[0] = '$'; res = canvas_realizedollar(c,const_cast<t_symbol *>(MakeSymbol(tmp))); } else res = canvas_realizedollar(c,const_cast<t_symbol *>(sym)); // check for number const char *c = GetString(res); while(*c && (isdigit(*c) || *c == '.')) ++c; if(!*c) SetFloat(dst,(float)atof(GetString(res))); else SetSymbol(dst,res); return true; } else #else #pragma message("Not implemented") #endif SetSymbol(dst,sym); return true; }
PyrObject* ConvertOSCMessage(int inSize, char *inData) { char *cmdName = inData; int cmdNameLen = OSCstrlen(cmdName); sc_msg_iter msg(inSize - cmdNameLen, inData + cmdNameLen); int numElems; if (inSize == cmdNameLen) { numElems = 0; } else { if (!msg.tags) { numElems = 0; error("OSC messages must have type tags. %s\n", cmdName); } else { numElems = strlen(msg.tags); } } //post("tags %s %d\n", msg.tags, numElems); VMGlobals *g = gMainVMGlobals; PyrObject *obj = newPyrArray(g->gc, numElems + 1, 0, false); PyrSlot *slots = obj->slots; SetSymbol(slots+0, getsym(cmdName)); for (int i=0; i<numElems; ++i) { char tag = msg.nextTag(); //post("%d %c\n", i, tag); switch (tag) { case 'i' : SetInt(slots+i+1, msg.geti()); break; case 'f' : SetFloat(slots+i+1, msg.getf()); break; case 'd' : SetFloat(slots+i+1, msg.getd()); break; case 's' : SetSymbol(slots+i+1, getsym(msg.gets())); //post("sym '%s'\n", slots[i+1].us->name); break; case 'b' : SetObject(slots+i+1, (PyrObject*)MsgToInt8Array(msg)); break; case 'c': SetChar(slots+i+1, (char)msg.geti()); break; // else add the type tag as a char (jrhb 2009) default: SetChar(slots+i+1, tag); msg.gets(); } } obj->size = numElems + 1; return obj; }
Trade( VERYLONG timestamp, std::string symbol, VERYLONG quantity, unsigned int price ) { SetPrice( price ); SetQuantity( quantity ); SetSymbol( symbol ); SetTimestamp( timestamp ); }
static void _doc_traverse(struct VMGlobals* g, DocNode *n, PyrObject *parent, PyrSlot *slot) { PyrObject *result = instantiateObject( g->gc, s_scdoc_node->u.classobj, 0, false, false ); result->size = 0; SetObject(slot, result); if(parent) g->gc->GCWrite(parent, result); PyrSymbol *id = getsym(n->id); SetSymbol(result->slots+result->size++, id); if(n->text) { PyrObject *str = (PyrObject*) newPyrString(g->gc, n->text, 0, true); SetObject(result->slots+result->size++, str); g->gc->GCWrite(result, str); } else { SetNil(result->slots+result->size++); } if(n->n_childs) { PyrObject *array = newPyrArray(g->gc, n->n_childs, 0, true); array->size = 0; SetObject(result->slots+result->size++, array); g->gc->GCWrite(result, array); for(int i=0; i<n->n_childs; i++) { array->size++; _doc_traverse(g, n->children[i], array, array->slots+i); } } else { SetNil(result->slots+result->size++); } result->size += 3; // makeDiv, notPrivOnly, sort }
int ScIDE_GetQUuid(struct VMGlobals *g, int numArgsPushed) { PyrSlot * returnSlot = g->sp - numArgsPushed + 1; SetSymbol(returnSlot, getsym(QUuid::createUuid().toString().toLatin1().constData())); return errNone; }
int prEvent_IsRest(struct VMGlobals *g, int numArgsPushed) { PyrSlot *dictslots = slotRawObject(g->sp)->slots; PyrSlot *arraySlot = dictslots + ivxIdentDict_array; if (isKindOfSlot(arraySlot, class_array)) { PyrSlot key, typeSlot; static PyrSymbol *s_type = getsym("type"); static PyrSymbol *s_rest = getsym("rest"); PyrSymbol *typeSym; // test 'this[\type] == \rest' first SetSymbol(&key, s_type); identDict_lookup(slotRawObject(g->sp), &key, calcHash(&key), &typeSlot); if(!slotSymbolVal(&typeSlot, &typeSym) && typeSym == s_rest) { SetBool(g->sp, 1); return errNone; } else { PyrObject *array = slotRawObject(arraySlot); PyrSymbol *slotSym; static PyrSymbol *s_empty = getsym(""); static PyrSymbol *s_r = getsym("r"); static PyrClass *class_rest = getsym("Rest")->u.classobj; static PyrClass *class_metarest = getsym("Meta_Rest")->u.classobj; PyrSlot *slot; int32 size = array->size; int32 i; slot = array->slots + 1; // scan only the odd items for (i = 1; i < size; i += 2, slot += 2) { if (isKindOfSlot(slot, class_rest) || isKindOfSlot(slot, class_metarest) ) { SetBool(g->sp, 1); return errNone; } else if(!slotSymbolVal(slot, &slotSym)) { if(slotSym == s_empty || slotSym == s_r || slotSym == s_rest ) { SetBool(g->sp, 1); return errNone; } } // why no 'else'? // slotSymbolVal nonzero return = not a symbol; // non-symbols don't indicate rests, so, ignore them. } } } else { return errWrongType; } SetBool(g->sp, 0); return errNone; }
void VariateManagerWithHorizonHeader::UpdateWidget(const std::shared_ptr<TVariate> newVariate, QTreeWidget* treeWidget, QTreeWidgetItem* variateItem) { assert(typeid(*variateItem) == typeid(TreeWidgetItemWithSymbol)); auto item = dynamic_cast<TreeWidgetItemWithSymbol*>(variateItem); assert(newVariate->GetTypeName() == item->GetSymbol().GetTypeName()); variateItem->setText(1, newVariate->GetName()); item->SetSymbol(newVariate->GetSymbol()); VariateWidgetMap::GetVariateWidget(newVariate->GetTypeName())->UpdateWidgetValue(newVariate, treeWidget, variateItem); }
void SegmentDisplay::Poll() { m_currentSegment++; if (m_currentSegment >= m_segmentsCount) { m_currentSegment = 0; } //reset: Reset(); SetSegment(m_currentSegment); SetSymbol(m_segments[m_currentSegment]); }
int prEvent_Delta(struct VMGlobals *g, int numArgsPushed) { PyrSlot *a, key, dur, stretch, delta; double fdur, fstretch; int err; a = g->sp; // dict SetSymbol(&key, s_delta); identDict_lookup(slotRawObject(a), &key, calcHash(&key), &delta); if (NotNil(&delta)) { slotCopy(a,&delta); } else { SetSymbol(&key, s_dur); identDict_lookup(slotRawObject(a), &key, calcHash(&key), &dur); err = slotDoubleVal(&dur, &fdur); if (err) { if (NotNil(&dur)) return err; SetNil(a); return errNone; } SetSymbol(&key, s_stretch); identDict_lookup(slotRawObject(a), &key, calcHash(&key), &stretch); err = slotDoubleVal(&stretch, &fstretch); if (err) { if (NotNil(&stretch)) return err; SetFloat(a, fdur); return errNone; } SetFloat(a, fdur * fstretch ); } return errNone; }
int prLID_GetInfo(VMGlobals* g, int numArgsPushed) { PyrSlot* args = g->sp - 1; int err; PyrObject* obj = SC_LID::getObject(args+0); if (!obj) return errWrongType; if (!isKindOfSlot(args+1, s_inputDeviceInfoClass->u.classobj)) return errWrongType; PyrObject* infoObj = slotRawObject(&args[1]); SC_LID* dev = SC_LID::getDevice(obj); if (!dev) return errFailed; char name[128]; err = dev->getName(name, sizeof(name)); if (err) return err; struct input_id info; char namePhys[128]; char nameUniq[128]; err = dev->getInfo(&info, namePhys, sizeof( namePhys ), nameUniq, sizeof( nameUniq ) ); if (err) return err; SetSymbol(infoObj->slots+0, getsym(name)); SetInt(infoObj->slots+1, info.bustype); SetInt(infoObj->slots+2, info.vendor); SetInt(infoObj->slots+3, info.product); SetInt(infoObj->slots+4, info.version); SetSymbol(infoObj->slots+5, getsym(namePhys)); SetSymbol(infoObj->slots+6, getsym(nameUniq)); slotCopy(&args[0], &args[1]); return errNone; }
int processsymbol(char *s) { PyrSlot slot; PyrSlotNode *node; PyrSymbol *sym; #if DEBUGLEX if (gDebugLexer) postfl("processsymbol: '%s'\n",s); #endif sym = getsym(s+1); SetSymbol(&slot, sym); node = newPyrSlotNode(&slot); zzval = (long)node; return SYMBOL; }
int prEvent_IsRest(struct VMGlobals *g, int numArgsPushed) { PyrSlot *dictslots = slotRawObject(g->sp)->slots; PyrSlot *arraySlot = dictslots + ivxIdentDict_array; static int isRestCount = 0; if (!isKindOfSlot(arraySlot, class_array)) { return errWrongType; } PyrSlot key, typeSlot; PyrSymbol *typeSym; // easy tests first: 'this[\type] == \rest' SetSymbol(&key, s_type); identDict_lookup(slotRawObject(g->sp), &key, calcHash(&key), &typeSlot); if(!slotSymbolVal(&typeSlot, &typeSym) && typeSym == s_rest) { SetBool(g->sp, 1); return errNone; } // and, 'this[\isRest] == true' SetSymbol(&key, s_isRest); identDict_lookup(slotRawObject(g->sp), &key, calcHash(&key), &typeSlot); if(IsTrue(&typeSlot)) { if (isRestCount == 0) post("\nWARNING: Setting isRest to true in an event is deprecated. See the Rest helpfile for supported ways to specify rests.\n\n"); isRestCount = (isRestCount + 1) % 100; SetBool(g->sp, 1); return errNone; } // failing those, scan slot values for something rest-like PyrObject *array = slotRawObject(arraySlot); SetBool(g->sp, dictHasRestlikeValue(array) ? 1 : 0); return errNone; }
inline int prOpFloat(VMGlobals *g, int numArgsPushed) { PyrSlot *a, *b; PyrSymbol *msg; a = g->sp - 1; b = g->sp; switch (GetTag(b)) { case tagInt : SetRaw(a, Functor::run(slotRawFloat(a), (double)slotRawInt(b))); break; case tagChar : case tagPtr : case tagNil : case tagFalse : case tagTrue : goto send_normal_2; case tagSym : SetSymbol(a, slotRawSymbol(b)); break; case tagObj : if (isKindOf(slotRawObject(b), class_signal)) SetObject(a, Functor::signal_fx(g, slotRawFloat(a), slotRawObject(b))); else goto send_normal_2; break; default : SetRaw(a, Functor::run(slotRawFloat(a), slotRawFloat(b))); break; } g->sp-- ; // drop g->numpop = 0; #if TAILCALLOPTIMIZE g->tailCall = 0; #endif return errNone; send_normal_2: if (numArgsPushed != -1) // special case flag meaning it is a primitive return errFailed; // arguments remain on the stack msg = gSpecialBinarySelectors[g->primitiveIndex]; sendMessage(g, msg, 2); return errNone; }
int processkeywordbinop(char *token) { PyrSymbol *sym; PyrSlot slot; PyrSlotNode *node; //post("'%s' file '%s'\n", token, curfilename); #if DEBUGLEX if (gDebugLexer) postfl("processkeywordbinop: '%s'\n",token); #endif token[strlen(token)-1] = 0; // strip off colon sym = getsym(token); SetSymbol(&slot, sym); node = newPyrSlotNode(&slot); zzval = (long)node; return KEYBINOP; }
int processbinop(char *token) { PyrSymbol *sym; PyrSlot slot; PyrSlotNode *node; #if DEBUGLEX if (gDebugLexer) postfl("processbinop: '%s'\n",token); #endif sym = getsym(token); SetSymbol(&slot, sym); node = newPyrSlotNode(&slot); zzval = (long)node; if (strcmp(token, "<-")==0) return LEFTARROW; if (strcmp(token, "<>")==0) return READWRITEVAR; if (strcmp(token, "|")==0) return '|'; if (strcmp(token, "<")==0) return '<'; if (strcmp(token, ">")==0) return '>'; if (strcmp(token, "-")==0) return '-'; if (strcmp(token, "*")==0) return '*'; if (strcmp(token, "+")==0) return '+'; return BINOP; }
int processident(char *token) { char c; PyrSymbol *sym; PyrSlot slot; PyrParseNode *node; c = token[0]; zzval = -1; #if DEBUGLEX if (gDebugLexer) postfl("word: '%s'\n",token); #endif /* strcpy(uptoken, token); for (str = uptoken; *str; ++str) { if (*str >= 'a' && *str <= 'z') *str += 'A' - 'a'; }*/ if (token[0] == '_') { if (token[1] == 0) { node = newPyrCurryArgNode(); zzval = (long)node; return CURRYARG; } else { sym = getsym(token); SetSymbol(&slot, sym); node = newPyrSlotNode(&slot); zzval = (long)node; return PRIMITIVENAME; } } if (token[0] >= 'A' && token[0] <= 'Z') { sym = getsym(token); SetSymbol(&slot, sym); node = newPyrSlotNode(&slot); zzval = (long)node; #if DEBUGLEX if (gDebugLexer) postfl("CLASSNAME: '%s'\n",token); #endif return CLASSNAME; } if (strcmp("var",token) ==0) return VAR; if (strcmp("arg",token) ==0) return ARG; if (strcmp("classvar",token) ==0) return CLASSVAR; if (strcmp("const",token) ==0) return SC_CONST; if (strcmp("while",token) ==0) { sym = getsym(token); SetSymbol(&slot, sym); node = newPyrSlotNode(&slot); zzval = (long)node; return WHILE; } if (strcmp("pi",token) ==0) { SetFloat(&slot, pi); node = newPyrSlotNode(&slot); zzval = (long)node; return PIE; } if (strcmp("true",token) ==0) { SetTrue(&slot); node = newPyrSlotNode(&slot); zzval = (long)node; return TRUEOBJ; } if (strcmp("false",token) ==0) { SetFalse(&slot); node = newPyrSlotNode(&slot); zzval = (long)node; return FALSEOBJ; } if (strcmp("nil",token) ==0) { SetNil(&slot); node = newPyrSlotNode(&slot); zzval = (long)node; return NILOBJ; } if (strcmp("inf",token) ==0) { SetFloat(&slot, std::numeric_limits<double>::infinity()); node = newPyrSlotNode(&slot); zzval = (long)node; return SC_FLOAT; } sym = getsym(token); SetSymbol(&slot, sym); node = newPyrSlotNode(&slot); zzval = (long)node; return NAME; }
inline MsgBundle &Add(flext_base *th,int o,const t_symbol *dt) { t_atom at; SetSymbol(at,dt); return Add(th,o,sym_symbol,1,&at); }
void flext_base::px_object::px_symbol(px_object *obj,const t_symbol *s) { t_atom a; SetSymbol(a,s); Locker lock(obj->base); obj->base->CbMethodHandler(obj->index,sym_symbol,1,&a); }
void flext_base::cb_symbol(flext_hdr *c,const t_symbol *s) { t_atom a; SetSymbol(a,s); Locker lock(c); thisObject(c)->CbMethodHandler(0,sym_symbol,1,&a); }
void CComplexSymbolLayerCtrl::UpDataCSLC(Display::ISymbolPtr pSymbol, SYMBOL_TYPE enumSymbolType) { this->DeleteAllItems(); m_arState.RemoveAll(); SetSymbol(pSymbol,enumSymbolType); }
void doesNotUnderstand(VMGlobals *g, PyrSymbol *selector, long numArgsPushed) { PyrSlot *qslot, *pslot, *pend; long i, index; PyrSlot *uniqueMethodSlot, *arraySlot, *recvrSlot, *selSlot, *slot; PyrClass *classobj; PyrMethod *meth; PyrObject *array; #ifdef GC_SANITYCHECK g->gc->SanityCheck(); #endif // move args up by one to make room for selector qslot = g->sp + 1; pslot = g->sp + 2; pend = pslot - numArgsPushed + 1; while (pslot > pend) *--pslot = *--qslot; selSlot = g->sp - numArgsPushed + 2; SetSymbol(selSlot, selector); g->sp++; recvrSlot = selSlot - 1; classobj = classOfSlot(recvrSlot); index = slotRawInt(&classobj->classIndex) + s_nocomprendo->u.index; meth = gRowTable[index]; if (slotRawClass(&meth->ownerclass) == class_object) { // lookup instance specific method uniqueMethodSlot = &g->classvars->slots[cvxUniqueMethods]; if (isKindOfSlot(uniqueMethodSlot, class_identdict)) { arraySlot = slotRawObject(uniqueMethodSlot)->slots + ivxIdentDict_array; if ((IsObj(arraySlot) && (array = slotRawObject(arraySlot))->classptr == class_array)) { i = arrayAtIdentityHashInPairs(array, recvrSlot); if (i >= 0) { slot = array->slots + i; if (NotNil(slot)) { ++slot; if (isKindOfSlot(slot, class_identdict)) { arraySlot = slotRawObject(slot)->slots + ivxIdentDict_array; if ((IsObj(arraySlot) && (array = slotRawObject(arraySlot))->classptr == class_array)) { i = arrayAtIdentityHashInPairs(array, selSlot); if (i >= 0) { slot = array->slots + i; if (NotNil(slot)) { ++slot; slotCopy(selSlot, recvrSlot); slotCopy(recvrSlot, slot); blockValue(g, (int)numArgsPushed+1); return; } } } } } } } } } executeMethod(g, meth, numArgsPushed+1); #ifdef GC_SANITYCHECK g->gc->SanityCheck(); #endif }
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_base))::cb_symbol(flext_hdr *c,const t_symbol *s) { t_atom a; SetSymbol(a,s); Locker lock(c); thisObject(c)->CbMethodHandler(0,sym_symbol,1,&a); }
int prEvent_Delta(struct VMGlobals *g, int numArgsPushed) { PyrSlot *a, key, dur, stretch, delta; double fdur, fstretch; int err; PyrClass *restClass = getsym("Rest")->u.classobj; PyrSlot *slot; a = g->sp; // dict SetSymbol(&key, s_delta); identDict_lookup(slotRawObject(a), &key, calcHash(&key), &delta); if (NotNil(&delta)) { if (isKindOfSlot(&delta, restClass)) { slot = slotRawObject(&delta)->slots; err = slotDoubleVal(slot, &fdur); } else { err = slotDoubleVal(&delta, &fdur); } if (err) { return err; } else { SetFloat(a, fdur); return errNone; } } else { SetSymbol(&key, s_dur); identDict_lookup(slotRawObject(a), &key, calcHash(&key), &dur); err = slotDoubleVal(&dur, &fdur); if (err) { if (IsNil(&dur)) { SetNil(g->sp); return errNone; } else if (isKindOfSlot(&dur, restClass)) { slot = slotRawObject(&dur)->slots; err = slotDoubleVal(slot, &fdur); if (err) return err; } else { return errWrongType; } } SetSymbol(&key, s_stretch); identDict_lookup(slotRawObject(a), &key, calcHash(&key), &stretch); err = slotDoubleVal(&stretch, &fstretch); if (err) { if (NotNil(&stretch)) { if (isKindOfSlot(&stretch, restClass)) { slot = slotRawObject(&stretch)->slots; err = slotDoubleVal(slot, &fstretch); if (err) return err; } else { return errWrongType; } } else { SetFloat(a, fdur); return errNone; } } SetFloat(a, fdur * fstretch); } return errNone; }
FLEXT_TEMPIMPL(void FLEXT_CLASSDEF(flext_base))::px_object::px_symbol(px_object *obj,const t_symbol *s) { t_atom a; SetSymbol(a,s); Locker lock(obj->base); obj->base->CbMethodHandler(obj->index,sym_symbol,1,&a); }