Tavisynth::Tavisynth(void):Tdll(dllname,NULL) { loadFunction(CreateScriptEnvironment,"CreateScriptEnvironment"); }
bool FunctionCallTip::getCursorFunction() { int line = _pEditView->execute(SCI_LINEFROMPOSITION, _curPos); int startpos = _pEditView->execute(SCI_POSITIONFROMLINE, line); int endpos = _pEditView->execute(SCI_GETLINEENDPOSITION, line); int len = endpos - startpos + 3; //also take CRLF in account, even if not there int offset = _curPos - startpos; //offset is cursor location, only stuff before cursor has influence const int maxLen = 128; if ((offset < 2) || (len >= maxLen)) { reset(); return false; //cannot be a func, need name and separator } TCHAR lineData[maxLen] = TEXT(""); _pEditView->getLine(line, lineData, len); //line aquired, find the functionname //first split line into tokens to parse //token is identifier or some expression, whitespace is ignored std::vector< Token > tokenVector; int tokenLen = 0; TCHAR ch; for (int i = 0; i < offset; i++) //we dont care about stuff after the offset { //tokenVector.push_back(pair(lineData+i, len)); ch = lineData[i]; if (isBasicWordChar(ch) || isAdditionalWordChar(ch)) //part of identifier { tokenLen = 0; TCHAR * begin = lineData+i; while ((isBasicWordChar(ch) || isAdditionalWordChar(ch)) && i < offset) { tokenLen++; i++; ch = lineData[i]; } tokenVector.push_back(Token(begin, tokenLen, true)); i--; //correct overshooting of while loop } else { if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\r') //whitespace { //do nothing } else { tokenLen = 1; tokenVector.push_back(Token(lineData+i, tokenLen, false)); } } } size_t vsize = tokenVector.size(); //mind nested funcs, like |blblb a (x, b(), c);| //therefore, use stack std::vector<FunctionValues> valueVec; FunctionValues curValue, newValue; int scopeLevel = 0; for (size_t i = 0; i < vsize; i++) { Token & curToken = tokenVector.at(i); if (curToken.isIdentifier) { curValue.lastIdentifier = i; } else { if (curToken.token[0] == _start) { scopeLevel++; newValue = curValue; valueVec.push_back(newValue); //store the current settings, so when this new function doesnt happen to be the 'real' one, we can restore everything curValue.scopeLevel = scopeLevel; if (i > 0 && curValue.lastIdentifier == int(i)-1) { //identifier must be right before (, else we have some expression like "( x + y() )" curValue.lastFunctionIdentifier = curValue.lastIdentifier; curValue.param = 0; } else { //some expression curValue.lastFunctionIdentifier = -1; } } else if (curToken.token[0] == _param && curValue.lastFunctionIdentifier > -1) { curValue.param++; } else if (curToken.token[0] == _stop) { if (scopeLevel) //scope cannot go below -1 scopeLevel--; if (valueVec.size() > 0) { //only pop level if scope was of actual function curValue = valueVec.back(); valueVec.pop_back(); } else { //invalidate curValue curValue = FunctionValues(); } } else if (curToken.token[0] == _terminal) { //invalidate everything valueVec.clear(); curValue = FunctionValues(); } } } bool res = false; if (curValue.lastFunctionIdentifier == -1) { //not in direct function. Start popping the stack untill we empty it, or a func IS found while(curValue.lastFunctionIdentifier == -1 && valueVec.size() > 0) { curValue = valueVec.back(); valueVec.pop_back(); } } if (curValue.lastFunctionIdentifier > -1) { Token funcToken = tokenVector.at(curValue.lastFunctionIdentifier); funcToken.token[funcToken.length] = 0; _currentParam = curValue.param; bool same = false; if (_funcName) { if(_ignoreCase) same = testNameNoCase(_funcName, funcToken.token, lstrlen(_funcName)) == 0; else same = generic_strncmp(_funcName, funcToken.token, lstrlen(_funcName)) == 0; } if (!same) { //check if we need to reload data if (_funcName) { delete [] _funcName; } _funcName = new TCHAR[funcToken.length+1]; lstrcpy(_funcName, funcToken.token); res = loadFunction(); } else { res = true; } } return res; }
Tavisynth_c::Tavisynth_c(void):Tdll(dllname,NULL) { loadFunction(avs_create_script_environment,"avs_create_script_environment"); }
bool loadPeople (FILE * fp) { onScreenPerson * * pointy = & allPeople; onScreenPerson * me; scaleHorizon = getSigned (fp); scaleDivide = getSigned (fp); int countPeople = get2bytes (fp); int a; allPeople = NULL; for (a = 0; a < countPeople; a ++) { me = new onScreenPerson; if (! checkNew (me)) return false; me -> myPersona = new persona; if (! checkNew (me -> myPersona)) return false; me -> myAnim = new personaAnimation; if (! checkNew (me -> myAnim)) return false; me -> x = getFloat (fp); me -> y = getFloat (fp); loadCostume (me -> myPersona, fp); loadAnim (me -> myAnim, fp); me -> lastUsedAnim = fgetc (fp) ? me -> myAnim : NULL; me -> scale = getFloat (fp); me -> extra = get2bytes (fp); me -> height = get2bytes (fp); me -> walkToX = get2bytes (fp); me -> walkToY = get2bytes (fp); me -> thisStepX = get2bytes (fp); me -> thisStepY = get2bytes (fp); me -> frameNum = get2bytes (fp); me -> frameTick = get2bytes (fp); me -> walkSpeed = get2bytes (fp); me -> spinSpeed = get2bytes (fp); me -> floaty = getSigned (fp); me -> show = fgetc (fp); me -> walking = fgetc (fp); me -> spinning = fgetc (fp); if (fgetc (fp)) { me -> continueAfterWalking = loadFunction (fp); if (! me -> continueAfterWalking) return false; } else { me -> continueAfterWalking = NULL; } me -> direction = get2bytes(fp); me -> angle = get2bytes(fp); if (ssgVersion >= VERSION(2,0)) { me -> angleOffset = get2bytes(fp); } else { me -> angleOffset = 0; } me -> wantAngle = get2bytes(fp); me -> directionWhenDoneWalking = getSigned(fp); me -> inPoly = getSigned(fp); me -> walkToPoly = getSigned(fp); if (ssgVersion >= VERSION(2,0)) { me -> r = fgetc (fp); me -> g = fgetc (fp); me -> b = fgetc (fp); me -> colourmix = fgetc (fp); me -> transparency = fgetc (fp); } else { setMyDrawMode(me, get2bytes(fp)); } me -> thisType = loadObjectRef (fp); // Anti-aliasing settings if (ssgVersion >= VERSION(1,6)) { if (ssgVersion < VERSION (2,0)) { // aaLoad fgetc (fp); getFloat (fp); getFloat (fp); } } me -> next = NULL; * pointy = me; pointy = & (me -> next); } // db ("End of loadPeople"); return true; }