static bool GetNullInfo(Cursor* cur, Py_ssize_t index, ParamInfo& info) { if (!GetParamType(cur, index, info.ParameterType)) return false; info.ValueType = SQL_C_DEFAULT; info.ColumnSize = 1; info.StrLen_or_Ind = SQL_NULL_DATA; info.fnToPyObject = ToNullInfo; return true; }
FFMixed CFFGLPluginManager::GetParamDefault( unsigned int dwIndex ) const { FFMixed result; result.UIntValue = FF_FAIL; const ParamInfo* paramInfo = FindParamInfo( dwIndex ); if( paramInfo == nullptr ) return result; if( GetParamType( dwIndex ) == FF_TYPE_TEXT ) result.PointerValue = (void*)paramInfo->StrDefaultValue; else result.UIntValue = *(unsigned int*)¶mInfo->DefaultValue; return result; }
bool CFunctionHandler::GetParamAny( int nIdx,ScriptAnyValue &any ) { int nRealIdx = nIdx+m_paramIdOffset; bool bRes = m_pSS->ToAny(any,nRealIdx); if (!bRes) { ScriptVarType paramType = GetParamType(nIdx); const char *sParamType = ScriptVarTypeAsCStr(paramType); const char *sType = ScriptAnyTypeToString(any.type); // Report wrong param. ScriptWarning( "[Script Error] Wrong parameter type. Function %s expect parameter %d of type %s (Provided type %s)",m_sFuncName,nIdx,sType,sParamType ); m_pSS->LogStackTrace(); } return bRes; }
FFMixed CFFGLPluginManager::GetParamDefault(unsigned int dwIndex) const { FFMixed result; ParamInfo* pCurr = m_pFirst; bool bFound = false; while (pCurr != NULL) { if (pCurr->ID == dwIndex) { bFound = true; break; } pCurr = pCurr->pNext; } if (bFound) { if (GetParamType(dwIndex) == FF_TYPE_TEXT) result.PointerValue = (void*)pCurr->StrDefaultValue; else result.UIntValue = *(unsigned int*)&pCurr->DefaultValue; } else { result.UIntValue = FF_FAIL; } return result; }
HPARAM CParams::Add(DWORD function, LPCTSTR pParams) {_STT(); // Allocate memory LPPARAMINFO node = (LPPARAMINFO)New(); if ( node == NULL ) return NULL; // Copy the function id node->function = function; // Copy description if any if ( pParams != NULL ) { strcpy_sz( node->pdesc, pParams ); } else return node; char type[ 512 ]; char size[ 512 ]; char name[ 512 ]; char min[ 512 ]; char max[ 512 ]; char def[ 512 ]; char step[ 512 ]; DWORD i = 0; node->n = 0; // Calculate total size needed DWORD sz = 0; while( ( sz = GetParam( &node->pdesc[ i ], type, size, NULL, NULL, NULL, NULL, NULL ) ) != 0 ) { node->n++; node->size += GetParamSize( GetParamType( type ), strtoul( size, NULL, 10 ) ); i += sz; } // end while // Anything to allocate? if ( node->size == 0 || node->n == 0 ) { node->n = 0; node->size = 0; return node; } // end if // Allocate memory for param data node->pdata = new BYTE[ node->size + 1 ]; if ( node->pdata == NULL ) { DeleteObject( node ); return NULL; } // end if ZeroMemory( node->pdata, node->size + 1 ); // Allocate memory for param index node->param = new PARAM[ node->n ]; if ( node->param == NULL ) { DeleteObject( node ); return NULL; } // end if ZeroMemory( node->param, sizeof( PARAM ) * node->n ); // Save param info so it's easy to index i = 0; DWORD p = 0, o = 0; while( ( sz = GetParam( &node->pdesc[ i ], type, size, name, min, max, def, step ) ) != 0 ) { node->param[ p ].type = GetParamType( type ); node->param[ p ].data = &node->pdata[ o ]; node->param[ p ].size = GetParamSize( node->param[ p ].type, strtoul( size, NULL, 10 ) ); o += node->param[ p ].size; strcpy_sz( node->param[ p ].name, name ); if ( *min ) { node->param[ p ].flags |= PFLAG_MIN; node->param[ p ].min = strtod( min, NULL ); } else node->param[ p ].min = 0; strcpy_sz( node->param[ p ].pmin, min ); if ( *max ) { node->param[ p ].flags |= PFLAG_MAX; node->param[ p ].max = strtod( max, NULL ); } else node->param[ p ].max = 0; strcpy_sz( node->param[ p ].pmax, max ); if ( *def ) { node->param[ p ].flags |= PFLAG_DEF; node->param[ p ].def = strtod( def, NULL ); } else node->param[ p ].def = 0; strcpy_sz( node->param[ p ].pdef, def ); if ( *step ) { node->param[ p ].flags |= PFLAG_STEP; node->param[ p ].step = strtod( step, NULL ); } else node->param[ p ].step = 0; strcpy_sz( node->param[ p ].pstep, step ); // Set default value SetValue( node, p, GetDef( node, p ) ); p++; i += sz; } // end while // We're ready return node; }
void CParser::ParseComment(const char *line) { param p; if(!line) return; line++; if(strncasecmp(line,"var",3)==0) { char *token = SkipSpaces(strtok((char*)(line+3)," :")); p.type = GetParamType(token); p.is_const = 0; p.is_internal = 0; p.is_output = 0; p.count = 1; p.name = SkipSpaces(strtok(NULL," :")); token = SkipSpaces(strtok(NULL," :")); if(strstr(token,"$vin")) { token = SkipSpaces(strtok(NULL," :")); if(strncasecmp(token,"ATTR",4)==0) p.index = atoi(token+4); else p.index = ConvertInputReg(token); } else if(strstr(token,"texunit")) { token = SkipSpaces(strtok(NULL," :")); p.index = atoi(token); } else if(token[0]=='c') { p.is_const = 1; p.index = atoi(token+2); token = strtok(NULL," ,"); if(isdigit(*token)) p.count = atoi(token); } else if(strstr(token,"$vout")) { p.is_output = 1; token = SkipSpaces(strtok(NULL," :")); s32 idx = -1; if(strncasecmp(token,"ATTR",4)==0) p.index = atoi(token+4); else p.index = ConvertOutputReg(token); } else return; InitParameter(&p); m_lParameters.push_back(p); } else if(strncasecmp(line,"const",5)==0) { char *token = SkipSpaces(strtok((char*)(line+5)," ")); p.is_const = 1; p.is_internal = 1; p.type = PARAM_FLOAT4; p.count = 1; InitParameter(&p); if(token[0]=='c' && token[1]=='[') { u32 i; f32 *pVal = p.values[0]; p.index = atoi(token+2); for(i=0;i<4;i++) { token = strtok(NULL," ="); if(token) pVal[i] = (f32)atof(token); else pVal[i] = 0.0f; } } else return; m_lParameters.push_back(p); } }