void buildCellProcessList(table_cell *cell, cell_process **HEAD) { char *fnString; int size; int i = 0; fnString = getCellStringValue(cell, &size); while(i<size) { fnString[i] = toupper(fnString[i]); i++; } if (!buildFunction(fnString,size,1,cell,HEAD,-1)) { setCellValue(cell,createExccelVarFromString("#NÉV?\0")); } }
void DxBuilder::buildVertexShader(const ASTEffect& effect, ASTTechnique& technique) { const ASTFunction* pfunction = effect.findFunction(technique.mVertex.mEntry); if ( pfunction->mArguments.size() == 1 && pfunction->mArguments[0]->mpType->isStruct() ) { const ASTStruct& input = pfunction->mArguments[0]->mpType->getStruct(); technique.mpLayout = buildInputLayout(input); } String code = UTEXT("// generated vertex shader\n\n"); String num; NumberConverter& conv = NumberConverter::getInstance(); for ( std::size_t index = 0; index < effect.mBuffers.size(); ++index ) { const ASTBuffer* pbuffer = effect.mBuffers[index]; code += UTEXT("cbuffer ") + pbuffer->mName; int reg = pbuffer->mRegister; if ( reg == -1 ) reg = (int) index; code += UTEXT(" : register(b") + conv.format(num, reg) + UTEXT(")\n{") + pbuffer->mBody + UTEXT("};\n\n"); } code += buildStructs(effect, *pfunction); code += buildFunction(*pfunction); std::string data = code.toUtf8(); std::string entry = technique.mVertex.mEntry.toUtf8(); std::string target = technique.mVertex.mTarget.toUtf8(); uint32_t flags = D3DCOMPILE_ENABLE_STRICTNESS; ID3DBlob *presult, *perror; HRESULT hr = D3DCompile(data.c_str(), data.length(), NULL, NULL, D3D_COMPILE_STANDARD_FILE_INCLUDE, entry.c_str(), target.c_str(), flags, 0, &presult, &perror); if ( FAILED(hr) ) { std::string d3derror = "Shader compile error: " + std::string((const char*)perror->GetBufferPointer()); throw std::exception(d3derror.c_str()); } technique.mVertex.mCompiledCode.writeBlob(presult->GetBufferPointer(), presult->GetBufferSize()); }
int buildFunction(char *fnString, int n, int offset, table_cell *cell, cell_process **LIST, int paramPos) { char *fnName, *fnParam; int fnNameLength; int *fnSig; int fnSigN; int fnSigI; int sig; exccel_var *vtmp; exccel_function *ftmp; cell_process *ptmp; char **parameters; int *fnIndexes; int paramsCount; int paramI; fnName = readFnName(fnString,n,offset,&fnNameLength); ftmp = getExccelFunction(fnName); if (ftmp == NULL) { return 0; } free(fnName); ptmp = (cell_process*)malloc(sizeof(cell_process)); ptmp->cell = cell; ptmp->func = ftmp; ptmp->paramPos = paramPos; ptmp->t = _processing; ptmp->childs = NULL; ptmp->proceed = 0; addProcess(LIST,ptmp); parameters = readFnParams(fnString,n,¶msCount,&fnIndexes); paramI = 0; fnSig = ftmp->signature; fnSigN = fnSig[0]; fnSigI = 1; if (paramsCount < fnSigN) { return 0; } while(fnSigI <= fnSigN) { sig = fnSig[fnSigI]; if (sig == FN_SIG_RANGE) { fnParam = parameters[paramI]; vtmp = createExccelRangeVarFromString(fnParam); addParamToFunction(ftmp,vtmp,paramI); free(fnParam); paramI++; } else if (sig == FN_SIG_LITERAL) { fnParam = parameters[paramI]; if (fnIndexes[paramI] == 1) { if (!buildFunction(fnParam,strlen(fnParam),0,cell,&((*LIST)->childs),paramI)) { return 0; } } else { vtmp = createExccelVarFromString(fnParam); addParamToFunction(ftmp,vtmp,paramI); free(fnParam); } paramI++; } else if (sig == FN_SIG_LIST) { while(paramI<paramsCount) { fnParam = parameters[paramI]; if (fnIndexes[paramI] == 1) { if (!buildFunction(fnParam,strlen(fnParam),0,cell,&((*LIST)->childs),paramI)) { return 0; } } else { vtmp = createExccelVarFromString(fnParam); addParamToFunction(ftmp,vtmp,paramI); free(fnParam); } paramI++; } } else { printf("Invalid signature %d\n",sig); exit(1); } fnSigI++; } free(parameters); free(fnIndexes); return 1; }