void TForm_Main::AdjustProperty(float fAmount) { if (!m_hSample) return; // Get the current value float fValue = atof(c_Edit_Value->Text.c_str()); // Adjust fValue += fAmount; // Tell Miles AIL_set_filter_sample_preference(m_hSample, c_ComboBox_Property->Text.c_str(), &fValue); // Get it back out in case we hit a max/min fValue = ReadProperty(); // Put it back in the edit AnsiString holdString; holdString.printf("%0.4f", fValue); c_Edit_Value->Text = holdString; // Update the property cache int iCurProperty = 0; RIB_INTERFACE_ENTRY ribAttrib; HINTENUM enumerator(HINTENUM_FIRST); while ((iCurProperty < m_iNumProperties) && AIL_enumerate_filter_sample_attributes(m_hCurFilter, &enumerator, &ribAttrib)) { AIL_filter_sample_attribute(m_hSample, ribAttrib.entry_name, &m_fProperties[iCurProperty]); ++iCurProperty; } }
Ptr<GuiImageData> GuiBindableTreeView::ItemSource::GetNodeImage(tree::INodeProvider* node) { if (auto itemSourceNode = dynamic_cast<ItemSourceNode*>(node)) { return ReadProperty(itemSourceNode->GetItemSource(), imageProperty); } return nullptr; }
const Variant& FileFormatImplementation::GetImageProperty( const IsoString& id ) { IsoString tid = id.Trimmed(); FileFormatPropertyArray::const_iterator i = m_data->properties.Search( tid ); if ( i != m_data->properties.End() ) return i->value; m_data->properties.Append( FileFormatProperty( tid, ReadProperty( tid ) ) ); return m_data->properties.Search( tid )->value; }
//////////////////////////////////////////////////////////////////// // Core PropertySet Functions // //////////////////////////////////////////////////////////////////// // OpenPropertyStorage // // Function takes a PropertySetStorage and returns the desired // PropertyStorage for the FMTID. The function will create a storage // if one does not exist (and flags allow). // STDAPI OpenPropertyStorage(IPropertySetStorage* pPropSS, REFFMTID fmtid, BOOL fReadOnly, DWORD dwFlags, IPropertyStorage** ppPropStg) { HRESULT hr; DWORD dwMode; BOOL fNoCreate = ((dwFlags & dsoOptionDontAutoCreate) == dsoOptionDontAutoCreate); BOOL fUseANSI = ((dwFlags & dsoOptionUseMBCStringsForNewSets) == dsoOptionUseMBCStringsForNewSets); ASSERT(pPropSS); ASSERT(ppPropStg); if ((pPropSS == NULL) || (ppPropStg == NULL)) return E_UNEXPECTED; *ppPropStg = NULL; // Set the access mode for read/write access... dwMode = (fReadOnly ? (STGM_READ | STGM_SHARE_EXCLUSIVE) : (STGM_READWRITE | STGM_SHARE_EXCLUSIVE)); // We try to open the property set. If this fails, it may be beacuse // it doesn't exist so we'll try to create the set... hr = pPropSS->Open(fmtid, dwMode, ppPropStg); if ((hr == STG_E_FILENOTFOUND) && !fReadOnly && !fNoCreate) { // FIX -- ADDED BY REQUEST - Feb 1, 2001 // Outlook 2000/XP doesn't handle Unicode property sets very well. So if we need to // create a propset for the caller, allow the caller the ability to set the // PROPSETFLAG_ANSI flag on the new set. // // The ANSI flag was the default in File 1.0, but this was changed to Unicode // for version 1.2 to meet request by ASIA/EMEA clients. Unicode should work // but there have been reported problems (in Outlook, Win2K SP2) that indicate // clients may want to use the ANSI flag (so it is passed here)... hr = pPropSS->Create(fmtid, NULL, (fUseANSI ? PROPSETFLAG_ANSI : 0), dwMode, ppPropStg); // If we created with ANSI flag, we must set the code page value to match ACP... if (SUCCEEDED(hr) && (fUseANSI) && (*ppPropStg)) { VARIANT vtT; PROPSPEC spc; spc.ulKind = PRSPEC_PROPID; spc.propid = PID_CODEPAGE; // FIX -- ADDED BY REQUEST - Oct 30, 2001 // Check for CodePage first. It appears certain configurations choke on modification // of the code page. This appears to be a change in OLE32 behavior. Workaround is to // check to see if OLE32 has added the code page already during the create, and if so // we can skip out on adding it ourselves... if (FAILED(ReadProperty(*ppPropStg, spc, 0, &vtT))) { // If not, we should add it... vtT.vt = VT_I4; vtT.lVal = GetACP(); WriteProperty(*ppPropStg, spc, 0, &vtT); } } } return hr; }
Ptr<GuiImageData> GuiBindableListView::ItemSource::GetLargeImage(vint itemIndex) { if (itemSource) { if (0 <= itemIndex && itemIndex < itemSource->GetCount()) { return ReadProperty(itemSource->Get(itemIndex), largeImageProperty); } } return nullptr; }
WString GuiBindableListView::ItemSource::GetSubItem(vint itemIndex, vint index) { if (itemSource) { if (0 <= itemIndex && itemIndex < itemSource->GetCount() && 0 <= index && index < columns.Count() - 1) { return ReadProperty(itemSource->Get(itemIndex), columns[index + 1]->GetTextProperty()); } } return L""; }
WString GuiBindableListView::ItemSource::GetText(vint itemIndex) { if (itemSource) { if (0 <= itemIndex && itemIndex < itemSource->GetCount() && columns.Count()>0) { return ReadProperty(itemSource->Get(itemIndex), columns[0]->GetTextProperty()); } } return L""; }
LONG ReadPropertyValue( char *objectName, WORD objectType, char *propertyName, int segmentNumber, BYTE *propertyValue ) { LONG rc; LONG objectID; char name_buff[48]; BYTE moreSegmentsT, propertyFlagsT; ASCIIZToLenStr( name_buff, objectName ); MapNameToID( 0, (BYTE *)name_buff, objectType, &objectID, NOCHECK ); ASCIIZToLenStr( name_buff, propertyName ); rc = ReadProperty( 0, objectID, (BYTE *)name_buff, (LONG)segmentNumber, propertyValue, &moreSegmentsT, &propertyFlagsT, CHECK ); if( rc != 0 ) return( rc ); return( 0 ); }
void asCRestore::ReadObjectTypeDeclaration(asCObjectType *ot) { // name ReadString(&ot->name); // size int size; READ_NUM(size); ot->size = size; // properties[] READ_NUM(size); ot->properties.Allocate(size,0); for( int n = 0; n < size; n++ ) { asCProperty *prop = new asCProperty; ReadProperty(prop); ot->properties.PushLast(prop); } // Use the default script struct behaviours ot->beh.construct = engine->scriptTypeBehaviours.beh.construct; ot->beh.constructors.PushLast(ot->beh.construct); ot->beh.addref = engine->scriptTypeBehaviours.beh.addref; ot->beh.release = engine->scriptTypeBehaviours.beh.release; ot->beh.copy = engine->scriptTypeBehaviours.beh.copy; ot->beh.operators.PushLast(ttAssignment); ot->beh.operators.PushLast(ot->beh.copy); // Some implicit values ot->tokenType = ttIdentifier; ot->arrayType = 0; ot->flags = asOBJ_CLASS_CDA | asOBJ_SCRIPT_STRUCT; // TODO: The flag asOBJ_POTENTIAL_CIRCLE must be saved // TODO: What about the arrays? the flag must be saved as well // TODO: // methods[] }
Ptr<description::IValueReadonlyList> GuiBindableTreeView::ItemSourceNode::PrepareValueList(const description::Value& inputItemSource) { if (auto value = ReadProperty(inputItemSource, rootProvider->childrenProperty)) { if (auto ol = value.Cast<IValueObservableList>()) { return ol; } else if (auto rl = value.Cast<IValueReadonlyList>()) { return rl; } else { return IValueList::Create(GetLazyList<Value>(value)); } } else { return IValueList::Create(); } }
void ParseStream(POLE::Stream* stream) { POLE::uint64 size = stream->size(); unsigned char* buffer = new unsigned char[size]; unsigned int currentIndex = 0; if (stream->read(buffer, size) == size) { PropertySetStreamHeader* pssh = (PropertySetStreamHeader*)buffer; for (unsigned int propertySetIndex = 0; propertySetIndex < pssh->NumPropertySets; propertySetIndex++) { currentIndex = sizeof(PropertySetStreamHeader) + (propertySetIndex * sizeof(PropertySetIdAndOffset)); PropertySetIdAndOffset* iao = (PropertySetIdAndOffset*)(buffer + currentIndex); currentIndex = iao->Offset; PropertySetHeader* psh = (PropertySetHeader*)(buffer + currentIndex); currentIndex += sizeof(PropertySetHeader); for (unsigned int pidaoIndex = 0; pidaoIndex < psh->NumProperties; pidaoIndex++) { PropertyIdentifierAndOffset* piao = (PropertyIdentifierAndOffset*)(buffer + currentIndex); currentIndex += sizeof(PropertyIdentifierAndOffset); ReadProperty(buffer, iao->Offset + piao->Offset, piao->PropertyId); } } } }
SEntityDef* CDefParser::ParseDef(const char* pszDefFn) { TiXmlDocument doc; if(!doc.LoadFile(pszDefFn)) { ThrowException(-1, "Failed to parse def file: %s.", pszDefFn); } TiXmlElement* root = doc.RootElement(); SEntityDef* pDef = new SEntityDef; pDef->m_bHasCellClient = false; //parent TiXmlElement* parent = root->FirstChildElement("parent"); if(parent) { pDef->m_parent.assign(parent->GetText()); } else { pDef->m_parent = ""; } //Properties TiXmlElement* props = root->FirstChildElement("Properties"); if(props) { TiXmlElement* field = props->FirstChildElement(); for(; field != NULL; field = field->NextSiblingElement()) { _SEntityDefProperties* pProp = ReadProperty(pDef, field); //todo,检查有无重复的字段名 pDef->m_properties.insert(make_pair(pProp->m_name, pProp)); pDef->m_propertiesList.push_back(pProp); pDef->m_propertiesMap.AddNewString(field->Value()); } } //ClientMethods TiXmlElement* methods = root->FirstChildElement("ClientMethods"); if(methods) { TiXmlElement* m = methods->FirstChildElement(); for(; m != NULL; m = m->NextSiblingElement()) { _SEntityDefMethods* p = ReadMethod(m); p->m_nServerId = SERVER_CLIENT; pDef->m_clientMethods.insert(make_pair(p->m_funcName, p)); pDef->m_clientMethodsMap.AddNewString(p->m_funcName); } } //BaseMethods methods = root->FirstChildElement("BaseMethods"); if(methods) { TiXmlElement* m = methods->FirstChildElement(); for(; m != NULL; m = m->NextSiblingElement()) { _SEntityDefMethods* p = ReadMethod(m); p->m_nServerId = SERVER_BASEAPP; pDef->m_baseMethods.insert(make_pair(p->m_funcName, p)); pDef->m_baseMethodsMap.AddNewString(p->m_funcName); } } //CellMethods methods = root->FirstChildElement("CellMethods"); if(methods) { TiXmlElement* m = methods->FirstChildElement(); for(; m != NULL; m = m->NextSiblingElement()) { _SEntityDefMethods* p = ReadMethod(m); p->m_nServerId = SERVER_CELLAPP; pDef->m_cellMethods.insert(make_pair(p->m_funcName, p)); pDef->m_cellMethodsMap.AddNewString(p->m_funcName); } } return pDef; }
// NEXT: Must go through the bytecode and set the correct objecttype pointer where used int asCRestore::Restore() { // Before starting the load, make sure that // any existing resources have been freed module->Reset(); unsigned long i, count; asCScriptFunction* func; asCProperty* prop; asCString *cstr; // structTypes[] READ_NUM(count); module->structTypes.Allocate(count, 0); for( i = 0; i < count; ++i ) { asCObjectType *ot = new asCObjectType(engine); ReadObjectTypeDeclaration(ot); engine->structTypes.PushLast(ot); module->structTypes.PushLast(ot); ot->refCount++; } // usedTypes[] READ_NUM(count); module->usedTypes.Allocate(count, 0); for( i = 0; i < count; ++i ) { asCObjectType *ot = ReadObjectType(); module->usedTypes.PushLast(ot); ot->refCount++; } // scriptGlobals[] READ_NUM(count); module->scriptGlobals.Allocate(count, 0); for( i = 0; i < count; ++i ) { prop = new asCProperty; ReadProperty(prop); module->scriptGlobals.PushLast(prop); } // globalMem size READ_NUM(count); module->globalMem.SetLength(count); // globalVarPointers[] ReadGlobalVarPointers(); // initFunction ReadFunction(&module->initFunction); // scriptFunctions[] READ_NUM(count); module->scriptFunctions.Allocate(count, 0); for( i = 0; i < count; ++i ) { func = new asCScriptFunction; ReadFunction(func); module->scriptFunctions.PushLast(func); } // stringConstants[] READ_NUM(count); module->stringConstants.Allocate(count, 0); for(i=0;i<count;++i) { cstr = new asCString(); ReadString(cstr); module->stringConstants.PushLast(cstr); } // importedFunctions[] and bindInformations[] READ_NUM(count); module->importedFunctions.Allocate(count, 0); module->bindInformations.SetLength(count); for(i=0;i<count;++i) { func = new asCScriptFunction; ReadFunction(func); module->importedFunctions.PushLast(func); READ_NUM(module->bindInformations[i].importFrom); module->bindInformations[i].importedFunction = -1; } // usedTypeIds[] ReadUsedTypeIds(); // Fake building module->isBuildWithoutErrors = true; // Init system functions properly engine->PrepareEngine(); module->CallInit(); return 0; }
void CallJavascriptFunction(Handle<Context> context, Handle<Value> This, UFunction* SignatureFunction, Handle<Function> func, void* Parms) { SCOPE_CYCLE_COUNTER(STAT_JavascriptFunctionCallToJavascript); auto isolate = context->GetIsolate(); HandleScope handle_scope(isolate); auto Buffer = reinterpret_cast<uint8*>(Parms); enum { MaxArgs = 32 }; Handle<Value> argv[MaxArgs]; int argc = 0; TFieldIterator<UProperty> Iter(SignatureFunction); for (; Iter && argc < MaxArgs && (Iter->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm; ++Iter) { UProperty* Param = *Iter; argv[argc++] = ReadProperty(isolate, Param, Buffer, FNoPropertyOwner()); } UProperty* ReturnParam = nullptr; for (; Iter; ++Iter) { UProperty* Param = *Iter; if (Param->GetPropertyFlags() & CPF_ReturnParm) { ReturnParam = Param; break; } } TryCatch try_catch; auto value = func->Call(This, argc, argv); if (try_catch.HasCaught()) { FV8Exception::Report(try_catch); } bool bHasAnyOutParams = false; if (SignatureFunction && SignatureFunction->HasAnyFunctionFlags(FUNC_HasOutParms)) { // Iterate over input parameters for (TFieldIterator<UProperty> It(SignatureFunction); It && (It->PropertyFlags & (CPF_Parm | CPF_ReturnParm)) == CPF_Parm; ++It) { // This is 'out ref'! if ((It->PropertyFlags & (CPF_ConstParm | CPF_OutParm)) == CPF_OutParm) { bHasAnyOutParams = true; break; } } } if (bHasAnyOutParams) { FIsolateHelper I(isolate); if (value.IsEmpty() || !value->IsObject()) { I.Throw(TEXT("...")); return; } auto Object = value->ToObject(); // Iterate over parameters again for (TFieldIterator<UProperty> It(SignatureFunction); It; ++It) { UProperty* Param = *It; auto PropertyFlags = Param->GetPropertyFlags(); // pass return parameter as '$' if (PropertyFlags & CPF_ReturnParm) { auto sub_value = Object->Get(I.Keyword("$")); WriteProperty(isolate, ReturnParam, Buffer, sub_value); } // rejects 'const T&' and pass 'T&' as its name else if ((PropertyFlags & (CPF_ConstParm | CPF_OutParm)) == CPF_OutParm) { auto sub_value = Object->Get(I.Keyword(Param->GetName())); if (!sub_value.IsEmpty()) { // value can be null if isolate is in trouble WriteProperty(isolate, Param, Buffer, sub_value); } } } } else { if (ReturnParam) { WriteProperty(isolate, ReturnParam, Buffer, value); } } }
//--------------------------------------------------------------------------- void __fastcall TForm_Main::c_ComboBox_PropertyChange(TObject *Sender) { AnsiString holdString; holdString.printf("%0.4f", ReadProperty()); c_Edit_Value->Text = holdString; }
// ReadLines //------------------------------------------------------------------------------ bool TextReader::ReadLines() { for ( ;; ) { // Skip Leading AStackString<> token; if ( !GetToken( token ) ) { return true; } // object? if ( token == "object" ) { if ( !ReadObject() ) { return false; } continue; } // struct? if ( token == "struct" ) { if ( !ReadStruct() ) { return false; } continue; } // ref? if ( token == "ref" ) { if ( !ReadRef() ) { return false; } continue; } // children? if ( token == "children" ) { if ( !ReadChildren() ) { return false; } continue; } // begin object properties? if ( token == "{" ) { continue; } // end object/struct properties? if ( token == "}" ) { m_DeserializationStack.Pop(); continue; } // assume property PropertyType pt; pt = GetPropertyTypeFromString( token ); if ( pt != PT_NONE ) { if ( !ReadProperty( pt ) ) { return false; } continue; } if ( token == "weakRef" ) { if ( !ReadWeakRef() ) { return false; } continue; } if ( token == "array<" ) { if ( !ReadArray() ) { return false; } continue; } if ( token == "arrayOfStruct<" ) { if ( !ReadArrayOfStruct() ) { return false; } continue; } Error( "Unkown token" ); return false; } }
WString GuiBindableTreeView::ItemSource::GetTextValue(tree::INodeProvider* node) { return ReadProperty(GetBindingValue(node), textProperty); }