TEST_F(EventRegistryTest, VerifySimpleLocalRegistration) { // Register two entries statically by uttering the static member's name: (void)RegEvent<Registered<1>>::r; (void)RegEvent<Registered<2>>::r; // Verify that both types exist: bool exists1 = false; bool exists2 = false; // Enumerate, skipping both bounds on this set. Note that the set will contain ALL utterances // of RegType, which means we must enumerate everything, and have to expect a lot of negative // matches. for(auto p = g_pFirstEventEntry; p; p = p->pFlink) { if(p->GetTypeInfo() == typeid(Registered<1>)) exists1 = true; if(p->GetTypeInfo() == typeid(Registered<2>)) exists2 = true; // Negative assertion: ASSERT_NE(p->ti, typeid(Registered<3>)) << "Obtained a registration for a type which was not explicitly registered"; } ASSERT_TRUE(exists1) << "Type one was registered but not found"; ASSERT_TRUE(exists2) << "Type two was registered but not found"; }
STDMETHODIMP CMediaPosition::Invoke( DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo, UINT * puArgErr) { // this parameter is a dead leftover from an earlier interface if (IID_NULL != riid) { return DISP_E_UNKNOWNINTERFACE; } ITypeInfo * pti; HRESULT hr = GetTypeInfo(0, lcid, &pti); if (FAILED(hr)) { return hr; } hr = pti->Invoke( (IMediaPosition *)this, dispidMember, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr); pti->Release(); return hr; }
Dali::TypeInfo TypeRegistry::GetTypeInfo(const Dali::BaseObject * const pBaseObject) { Dali::TypeInfo type; // test for custom actor which has another indirection to get to the type hiearchy we're after const Dali::Internal::CustomActor * const pCustom = dynamic_cast<const Dali::Internal::CustomActor*>(pBaseObject); if(pCustom) { type = GetTypeInfo( typeid( pCustom->GetImplementation() ) ); } else { type = GetTypeInfo( typeid( *pBaseObject ) ); } return type; }
bool TypeRegistry::DoActionTo( BaseObject * const object, const std::string &actionName, const Property::Map &properties) { bool done = false; Dali::TypeInfo type = GetTypeInfo( object ); while( type ) { if(GetImplementation(type).DoActionTo(object, actionName, properties)) { done = true; break; } type = GetTypeInfo( type.GetBaseName() ); } return done; }
bool TypeRegistry::ConnectSignal( BaseObject* object, ConnectionTrackerInterface* connectionTracker, const std::string& signalName, FunctorDelegate* functor ) { bool connected( false ); Dali::TypeInfo type = GetTypeInfo( object ); while( type ) { connected = GetImplementation(type).ConnectSignal( object, connectionTracker, signalName, functor ); if( connected ) { break; } type = GetTypeInfo( type.GetBaseName() ); } if( !connected ) { // Ownership of functor was not passed to Dali::CallbackBase, so clean-up now delete functor; } return connected; }
bool DeclareVar(CompileInstance &inst, const mtlChars &type, const mtlChars &name, const mtlChars &expr) { const TypeInfo *type_info = GetTypeInfo(type); if (type_info == NULL) { AddError(inst, "Unknown type", type); return false; } if (!IsValidName(name)) { AddError(inst, "Invalid name", name); return false; } const Definition *prev_def = GetType(inst, name); if (prev_def != NULL) { AddError(inst, "Redeclaration", name); return false; } const int rel_sptr = inst.scopes.GetLast()->GetItem().rel_sptr; Definition &def = inst.scopes.GetLast()->GetItem().defs.AddLast(); def.name.Copy(name); def.mut = Mutable; def.type = *type_info; def.scope_level = inst.scopes.GetSize() - 1; def.value.var_addr = rel_sptr; //def.values.Create(type_info->size); //for (int addr_offset = 0; addr_offset < type_info->size; ++addr_offset) { // def.values[addr_offset].var_addr = rel_sptr + addr_offset; //} for (int i = 0; i < type_info->size; ++i) { Definition &def = inst.scopes.GetLast()->GetItem().defs.AddLast(); def.name.Copy(name); def.name.Append(Accessor); def.name.Append(Members[i]); def.mut = Mutable; def.type = gSubTypes[type_info->type]; def.scope_level = inst.scopes.GetSize() - 1; def.value.var_addr = rel_sptr + i; } PushStack(inst, type_info->size); return (expr.GetSize() > 0) ? AssignVar(inst, name, expr) : true; }
bool IsValidName(const mtlChars &name) { if (name.GetSize() > 0 && GetTypeInfo(name) == NULL) { if (!mtlChars::IsAlpha(name.GetChars()[0]) && name.GetChars()[0] != '_') { return false; } for (int i = 1; i < name.GetSize(); ++i) { char ch = name.GetChars()[i]; if (!mtlChars::IsAlphanumeric(ch) && ch != '_') { return false; } } return true; } return false; }
STDMETHODIMP CJServer::GetIDsOfNames(REFIID riid , OLECHAR **rgszNames, UINT cNames, LCID lcid, DISPID *rgDispID) { HRESULT hr; ITypeInfo *pTI; if (IID_NULL!=riid) return ResultFromScode(DISP_E_UNKNOWNINTERFACE); //Get the right ITypeInfo for lcid. hr=GetTypeInfo(0, lcid, &pTI); if (SUCCEEDED(hr)) { hr=DispGetIDsOfNames(pTI, rgszNames, cNames, rgDispID); pTI->Release(); } return hr; }
void dlgForeignTable::OnMemberChange(wxCommandEvent &ev) { wxString name = txtMembername->GetValue().Strip(wxString::both); wxString type = cbDatatype->GetValue(); wxString length = wxEmptyString; wxString precision = wxEmptyString; wxString notnull = wxEmptyString; if (txtLength->GetValue() != wxT("") && txtLength->IsEnabled()) length = txtLength->GetValue(); if (txtPrecision->GetValue() != wxT("") && txtPrecision->IsEnabled()) precision = txtPrecision->GetValue(); notnull = chkNotNull->GetValue() ? wxT("NOT NULL") : wxEmptyString; if (!length.IsEmpty()) { type += wxT("(") + length; if (!precision.IsEmpty()) type += wxT(",") + precision; type += wxT(")"); } if (!name.IsEmpty()) { long pos = lstMembers->GetFirstSelected(); if (pos >= 0) { lstMembers->SetItem(pos, 0, name); lstMembers->SetItem(pos, 1, type); lstMembers->SetItem(pos, 2, notnull); memberTypes.Insert(GetTypeInfo(cbDatatype->GetGuessedSelection()), pos); memberLengths.Insert(length, pos); memberPrecisions.Insert(precision, pos); memberNotNulls.Insert(notnull, pos); memberTypes.RemoveAt(pos + 1); memberLengths.RemoveAt(pos + 1); memberPrecisions.RemoveAt(pos + 1); memberNotNulls.RemoveAt(pos + 1); } } CheckChange(); }
void dlgForeignTable::OnMemberAdd(wxCommandEvent &ev) { wxString name = txtMembername->GetValue().Strip(wxString::both); wxString type = cbDatatype->GetValue(); wxString length = wxEmptyString; wxString precision = wxEmptyString; wxString notnull = wxEmptyString; if (txtLength->GetValue() != wxT("") && txtLength->IsEnabled()) length = txtLength->GetValue(); if (txtPrecision->GetValue() != wxT("") && txtPrecision->IsEnabled()) precision = txtPrecision->GetValue(); notnull = chkNotNull->GetValue() ? wxT("NOT NULL") : wxEmptyString; if (!length.IsEmpty()) { type += wxT("(") + length; if (!precision.IsEmpty()) type += wxT(",") + precision; type += wxT(")"); } if (!name.IsEmpty()) { size_t pos = lstMembers->GetItemCount(); lstMembers->InsertItem(pos, name, 0); lstMembers->SetItem(pos, 1, type); lstMembers->SetItem(pos, 2, notnull); memberTypes.Add(GetTypeInfo(cbDatatype->GetGuessedSelection())); memberLengths.Add(length); memberPrecisions.Add(precision); memberNotNulls.Add(notnull); } txtMembername->SetValue(wxEmptyString); cbDatatype->SetValue(wxEmptyString); txtLength->SetValue(wxEmptyString); txtPrecision->SetValue(wxEmptyString); chkNotNull->SetValue(false); CheckChange(); }
STDMETHODIMP CJServer::Invoke(DISPID dispID, REFIID riid , LCID lcid, unsigned short wFlags, DISPPARAMS *pDispParams , VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) { HRESULT hr; ITypeInfo *pTI; LANGID langID=PRIMARYLANGID(lcid); if (IID_NULL!=riid) return DISP_E_UNKNOWNINTERFACE; hr=GetTypeInfo(0, lcid, &pTI); if (FAILED(hr)) return hr; //This is exactly what DispInvoke does--so skip the overhead. hr=pTI->Invoke((SERVERCLASS *)this, dispID, wFlags , pDispParams, pVarResult, pExcepInfo, puArgErr); //Exception handling is done within ITypeInfo::Invoke pTI->Release(); return hr; }
STDMETHODIMP CBaseDispatch::GetIDsOfNames( REFIID riid, OLECHAR ** rgszNames, UINT cNames, LCID lcid, DISPID * rgdispid) { // although the IDispatch riid is dead, we use this to pass from // the interface implementation class to us the iid we are talking about. ITypeInfo * pti; HRESULT hr = GetTypeInfo(riid, 0, lcid, &pti); if (SUCCEEDED(hr)) { hr = pti->GetIDsOfNames(rgszNames, cNames, rgdispid); pti->Release(); } return hr; }
BOOL CTreeItem::ExpandTypeInfo( HTREEITEM hitem ) { ASSERT(m_pTree) ; ASSERT(hitem) ; CTreeItem* pNewItem = NULL ; HRESULT hr = S_OK ; TV_INSERTSTRUCT tvis ; CString strError = "Enumerating TypeInfo" ; TYPEATTR* pattr = NULL ; ITypeInfo* pti = GetTypeInfo() ; ASSERT(pti) ; BOOL fExpand = FALSE ; tvis.hParent = hitem ; tvis.hInsertAfter = TVI_LAST ; tvis.item.mask = TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_CHILDREN ; tvis.item.iImage = typeUnknown ; tvis.item.iSelectedImage = tvis.item.iImage + 1 ; TRY { ENSURE(pti); hr = pti->GetTypeAttr(&pattr) ; if FAILED(hr) { strError.Format(_T("ITypeInfo::GetTypeAttr() failed"), hr ) ; AfxThrowMemoryException() ; } switch(pattr->typekind) { // typedef [attributes] enum [tag] { // enumlist // } enumname; // // "typedef enum enumname" case TKIND_ENUM: fExpand = ExpandVars( hitem ) ; break ; // typedef [attributes] // struct [tag] { // memberlist // } structname; // // "typedef struct structname" case TKIND_RECORD: fExpand = ExpandVars( hitem ) ; break ; // [attributes] // module modulename { // elementlist // }; case TKIND_MODULE: if (pattr->cVars) { // Add "Constants" folder // #pragma warning (suppress: 6211) #pragma warning (suppress: 6014) pNewItem = new CTreeItem(m_pTree) ; pNewItem->m_Type = typeProperties ; pNewItem->SetTypeInfo(pti) ; pti->AddRef() ; tvis.item.cChildren = pattr->cVars ; tvis.item.lParam = (LPARAM)pNewItem ; tvis.item.pszText = _T("Constants") ; tvis.item.iImage = typeConstants ; tvis.item.iSelectedImage = tvis.item.iImage + 1 ; m_pTree->InsertItem( &tvis ) ; fExpand = TRUE ; } if (pattr->cFuncs) { pNewItem = new CTreeItem(m_pTree) ; pNewItem->m_Type = typeMethods ; pNewItem->SetTypeInfo(pti) ; pti->AddRef() ; tvis.item.cChildren = pattr->cFuncs ; tvis.item.lParam = (LPARAM)pNewItem ; tvis.item.pszText = _T("Functions") ; tvis.item.iImage = typeMethods ; tvis.item.iSelectedImage = tvis.item.iImage + 1 ; m_pTree->InsertItem( &tvis ) ; fExpand = TRUE ; } break ; // [attributes] // interface interfacename [:baseinterface] { // functionlist // }; case TKIND_INTERFACE: fExpand = ExpandFuncs( hitem) ; if (pattr->cImplTypes) { pNewItem = new CTreeItem(m_pTree) ; pNewItem->m_Type = typeImplTypes ; pNewItem->SetTypeInfo(pti) ; pti->AddRef() ; tvis.item.pszText = _T("Inherited Interfaces") ; tvis.item.iImage = typeInterface ; tvis.item.cChildren = pattr->cImplTypes ; tvis.item.lParam = (LPARAM)pNewItem ; tvis.item.iSelectedImage = tvis.item.iImage ; m_pTree->InsertItem( &tvis ) ; fExpand = TRUE ; } break ; // [attributes] // dispinterface intfname { // interface interfacename // }; case TKIND_DISPATCH : if (pattr->cVars) { // Add "Constants" folder // pNewItem = new CTreeItem(m_pTree) ; pNewItem->m_Type = typeConstants ; pNewItem->SetTypeInfo(pti) ; pti->AddRef() ; tvis.item.cChildren = pattr->cVars ; tvis.item.lParam = (LPARAM)pNewItem ; tvis.item.pszText = _T("Constants") ; tvis.item.iImage = typeConstants ; tvis.item.iSelectedImage = tvis.item.iImage + 1 ; m_pTree->InsertItem( &tvis ) ; // Add "Properties" folder // pNewItem = new CTreeItem(m_pTree) ; pNewItem->m_Type = typeProperties ; pNewItem->SetTypeInfo(pti) ; pti->AddRef() ; tvis.item.cChildren = pattr->cVars ; tvis.item.lParam = (LPARAM)pNewItem ; tvis.item.pszText = _T("Properties") ; tvis.item.iImage = typeProperties ; tvis.item.iSelectedImage = tvis.item.iImage + 1 ; m_pTree->InsertItem( &tvis ) ; fExpand = TRUE ; } if (pattr->cFuncs) { pNewItem = new CTreeItem(m_pTree) ; pNewItem->m_Type = typeMethods ; pNewItem->SetTypeInfo(pti) ; pti->AddRef() ; tvis.item.cChildren = pattr->cFuncs ; tvis.item.lParam = (LPARAM)pNewItem ; tvis.item.pszText = _T("Methods") ; tvis.item.iImage = typeMethods ; tvis.item.iSelectedImage = tvis.item.iImage + 1 ; m_pTree->InsertItem( &tvis ) ; fExpand = TRUE ; } if (pattr->cImplTypes) { pNewItem = new CTreeItem(m_pTree) ; pNewItem->m_Type = typeImplTypes ; pNewItem->SetTypeInfo(pti) ; pti->AddRef() ; tvis.item.pszText = _T("Inherited Interfaces") ; tvis.item.iImage = typeInterface ; tvis.item.cChildren = pattr->cImplTypes ; tvis.item.lParam = (LPARAM)pNewItem ; tvis.item.iSelectedImage = tvis.item.iImage ; m_pTree->InsertItem( &tvis ) ; fExpand = TRUE ; } break ; // [attributes] // coclass classname { // [attributes2] [interface | dispinterface] interfacename; // ... // }; case TKIND_COCLASS: fExpand = ExpandImplTypes( hitem ) ; break ; // typedef [attributes] basetype aliasname; case TKIND_ALIAS: if (pattr->tdescAlias.vt == VT_USERDEFINED) { ITypeInfo* ptiRefType = NULL ; #pragma warning (suppress: 6246) HRESULT hr = pti->GetRefTypeInfo( pattr->tdescAlias.hreftype, &ptiRefType ) ; if (FAILED(hr)) AfxThrowOleException( hr ) ; pNewItem = new CTreeItem(m_pTree) ; pNewItem->SetTypeInfo( ptiRefType ) ; pNewItem->m_Type = TypeKindToItemType( pNewItem->GetTypeKind() ) ; tvis.item.iImage = TypeKindToItemType( pNewItem->GetTypeKind() ) ; tvis.item.cChildren = 1 ; tvis.item.lParam = (LPARAM)pNewItem ; tvis.item.iSelectedImage = tvis.item.iImage ; CString sName; pNewItem->GetName(sName, TRUE ); tvis.item.pszText = sName.GetBuffer(0) ; m_pTree->InsertItem( &tvis ) ; sName.ReleaseBuffer(); fExpand = TRUE ; } break ; // typedef [attributes] union [tag] { // memberlist // } unionname; case TKIND_UNION: fExpand = ExpandVars( hitem ) ; break ; default: break ; } if (pattr) pti->ReleaseTypeAttr( pattr ) ; } CATCH(CException, pException) { ErrorMessage( strError, hr ) ; if (pNewItem) delete pNewItem ; if (pattr) pti->ReleaseTypeAttr( pattr ) ; return FALSE ; }
int dlgForeignTable::Go(bool modal) { seclabelPage->SetConnection(connection); seclabelPage->SetObject(foreigntable); this->Connect(EVT_SECLABELPANEL_CHANGE, wxCommandEventHandler(dlgForeignTable::OnChange)); // Fill owner combobox if (!foreigntable) cbOwner->Append(wxT("")); AddGroups(); AddUsers(cbOwner); // Fill datatype combobox FillDatatype(cbDatatype); // Initialize options listview and buttons lstOptions->AddColumn(_("Option"), 80); lstOptions->AddColumn(_("Value"), 40); txtOption->SetValue(wxT("")); txtValue->SetValue(wxT("")); btnAdd->Disable(); btnRemove->Disable(); if (foreigntable) { // Edit Mode cbForeignServer->SetValue(foreigntable->GetForeignServer()); cbForeignServer->Disable(); txtMembername->Enable(true); btnAddMember->Enable(true); btnChangeMember->Enable(false); btnRemoveMember->Enable(false); wxArrayString elements = foreigntable->GetTypesArray(); wxString fullType, typeName, typeLength, typePrecision; size_t pos; size_t i; for (i = 0 ; i < elements.GetCount() ; i += 3) { lstMembers->AppendItem(0, elements.Item(i), elements.Item(i + 1), elements.Item(i + 2)); fullType = elements.Item(i + 1); typeName = fullType; typeLength = wxEmptyString; typePrecision = wxEmptyString; if (fullType.Find(wxT("(")) > 0) { // there is at least a length typeName = fullType.BeforeFirst('('); if (fullType.Find(wxT(",")) > 0) { // there is also a precision typeLength = fullType.AfterFirst('(').BeforeFirst(','); typePrecision = fullType.AfterFirst(',').BeforeFirst(')'); } else typeLength = fullType.AfterFirst('(').BeforeFirst(')'); } for (pos = 0; pos < cbDatatype->GetCount() - 1; pos++) { if (cbDatatype->GetString(pos) == typeName) { memberTypes.Add(GetTypeInfo(pos)); break; } } memberLengths.Add(typeLength); memberPrecisions.Add(typePrecision); memberNotNulls.Add(elements.Item(i + 2)); } cbDatatype->Enable(); txtLength->Enable(); wxArrayString options = foreigntable->GetOptionsArray(); wxString optionname, optionvalue; for (unsigned int index = 0; index < options.Count(); index += 2) { optionname = options.Item(index); optionvalue = options.Item(index + 1); lstOptions->AppendItem(optionname, optionvalue); } } else { // Create mode cbOwner->Append(wxEmptyString); cbOwner->Disable(); pgSet *set = connection->ExecuteSet( wxT("SELECT srvname\n") wxT(" FROM pg_foreign_server\n") wxT(" ORDER BY srvname")); if (set) { while (!set->Eof()) { wxString srvname = set->GetVal(wxT("srvname")); cbForeignServer->Append(srvname); set->MoveNext(); } delete set; } cbForeignServer->SetSelection(0); } txtLength->SetValidator(numericValidator); return dlgTypeProperty::Go(modal); }
const Urho3D::String &GameOptionsState::GetTypeName() const { return GetTypeInfo()->GetTypeName(); }
STDMETHODIMP ESource::InitEvent(IDispatch *SourceDispatch, OrxScript *ORexxScript, FILE *LogFile) { ITypeInfo *SourceType; TYPEATTR *TypeAttributes; BSTR SourceName; unsigned int NameCount; int i; FUNCDESC *FuncDesc; char DispIDName[29]; PEMAP NewMap; HRESULT RetCode=S_OK; int EMCount; FPRINTF2(LogFile,"created a new Event Source. %p\n",this); FPRINTF2(DLLlogfile,"created a new Event Source.%p\n",this); EventType = AddScriptlet; Source = SourceDispatch; // Mimick the ParseProcedures "THIS" parameter by returning this pointer. Engine = ORexxScript; Connected = false; ConnectionPoint = NULL; Container = NULL; logfile = LogFile; RetCode = GetTypeInfo(&SourceType); if (SUCCEEDED(RetCode)) { RetCode = SourceType->GetTypeAttr(&TypeAttributes); memcpy(&SourceGUID,&TypeAttributes->guid,sizeof(GUID)); EMCount = TypeAttributes->cFuncs; SourceType->ReleaseTypeAttr(TypeAttributes); OLECHAR lGUID[50]; StringFromGUID2(SourceGUID,lGUID,sizeof(lGUID)); FPRINTF2(logfile,"The GUID is %S and there are %d functions.\n",lGUID,EMCount); /* For each entry in the type library, create an entry on the Event Map chain. * This is a many to one relation. Each of the different Source Disp ID's * will translate to the same Sink Disp ID. There is only one chunk of code * being bound to this Event that the Type Library is describing. So every * Source call must map to the same Sink. */ for (i=0; i<EMCount; i++) { SourceType->GetFuncDesc(i, &FuncDesc); // Despite what the documentation says, this returns Max Names, not Max Names - 1. // The first name is the function name, the remainder if they exist are parameters. SourceType->GetNames(FuncDesc->memid, &SourceName, 1, &NameCount); sprintf(DispIDName,"%d",FuncDesc->memid); // This creates the entry for the function with an invalid DispID to call. RetCode = AddMap(DispIDName,&NewMap); if (FAILED(RetCode)) return RetCode; FPRINTF2(logfile,"ESource::InitEvent - AddScriptlet \"%S\" \n",SourceName); NewMap->SourceEventName = SourceName; SourceType->ReleaseFuncDesc(FuncDesc); } SourceType->Release(); } else { FPRINTF2(logfile,"Could not obtain TypInfo for this event! HRESULT %08x\n",RetCode); } return RetCode; }
/// Get type name /// /// @return /// Type name string const string& GetName(void) const { return GetTypeInfo()->GetName(); }
bool Object::IsInstanceOf(StringHash type) const { return GetTypeInfo()->IsTypeOf(type); }
MagickExport const TypeInfo *GetTypeInfoByFamily(const char *family, const StyleType style,const StretchType stretch,const size_t weight, ExceptionInfo *exception) { typedef struct _Fontmap { const char *name, *substitute; } Fontmap; const TypeInfo *type_info; register const TypeInfo *p; register ssize_t i; ssize_t range; static const Fontmap fontmap[] = { { "fixed", "courier" }, { "modern","courier" }, { "monotype corsiva", "courier" }, { "news gothic", "helvetica" }, { "system", "courier" }, { "terminal", "courier" }, { "wingdings", "symbol" }, { NULL, NULL } }; size_t max_score, score; /* Check for an exact type match. */ (void) GetTypeInfo("*",exception); if (type_list == (SplayTreeInfo *) NULL) return((TypeInfo *) NULL); LockSemaphoreInfo(type_semaphore); ResetSplayTreeIterator(type_list); type_info=(const TypeInfo *) NULL; p=(const TypeInfo *) GetNextValueInSplayTree(type_list); while (p != (const TypeInfo *) NULL) { if (p->family == (char *) NULL) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } if (family == (const char *) NULL) { if ((LocaleCompare(p->family,"arial") != 0) && (LocaleCompare(p->family,"helvetica") != 0)) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } } else if (LocaleCompare(p->family,family) != 0) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } if ((style != UndefinedStyle) && (style != AnyStyle) && (p->style != style)) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } if ((stretch != UndefinedStretch) && (stretch != AnyStretch) && (p->stretch != stretch)) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } if ((weight != 0) && (p->weight != weight)) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } type_info=p; break; } UnlockSemaphoreInfo(type_semaphore); if (type_info != (const TypeInfo *) NULL) return(type_info); /* Check for types in the same family. */ max_score=0; LockSemaphoreInfo(type_semaphore); ResetSplayTreeIterator(type_list); p=(const TypeInfo *) GetNextValueInSplayTree(type_list); while (p != (const TypeInfo *) NULL) { if (p->family == (char *) NULL) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } if (family == (const char *) NULL) { if ((LocaleCompare(p->family,"arial") != 0) && (LocaleCompare(p->family,"helvetica") != 0)) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } } else if (LocaleCompare(p->family,family) != 0) { p=(const TypeInfo *) GetNextValueInSplayTree(type_list); continue; } score=0; if ((style == UndefinedStyle) || (style == AnyStyle) || (p->style == style)) score+=32; else if (((style == ItalicStyle) || (style == ObliqueStyle)) && ((p->style == ItalicStyle) || (p->style == ObliqueStyle))) score+=25; if (weight == 0) score+=16; else score+=(16*(800-((ssize_t) MagickMax(MagickMin(weight,900),p->weight)- (ssize_t) MagickMin(MagickMin(weight,900),p->weight))))/800; if ((stretch == UndefinedStretch) || (stretch == AnyStretch)) score+=8; else { range=(ssize_t) UltraExpandedStretch-(ssize_t) NormalStretch; score+=(8*(range-((ssize_t) MagickMax(stretch,p->stretch)- (ssize_t) MagickMin(stretch,p->stretch))))/range; } if (score > max_score) { max_score=score; type_info=p; } p=(const TypeInfo *) GetNextValueInSplayTree(type_list); } UnlockSemaphoreInfo(type_semaphore); if (type_info != (const TypeInfo *) NULL) return(type_info); /* Check for table-based substitution match. */ for (i=0; fontmap[i].name != (char *) NULL; i++) { if (family == (const char *) NULL) { if ((LocaleCompare(fontmap[i].name,"arial") != 0) && (LocaleCompare(fontmap[i].name,"helvetica") != 0)) continue; } else if (LocaleCompare(fontmap[i].name,family) != 0) continue; type_info=GetTypeInfoByFamily(fontmap[i].substitute,style,stretch,weight, exception); break; } if (type_info != (const TypeInfo *) NULL) { (void) ThrowMagickException(exception,GetMagickModule(),TypeError, "FontSubstitutionRequired","`%s'",type_info->family); return(type_info); } if (family != (const char *) NULL) type_info=GetTypeInfoByFamily((const char *) NULL,style,stretch,weight, exception); return(type_info); }
const Urho3D::String &MainGameState::GetTypeName() const { return GetTypeInfo()->GetTypeName(); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d T T F I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ReadTTFImage() reads a TrueType font file and returns it. It % allocates the memory necessary for the new Image structure and returns a % pointer to the new image. % % The format of the ReadTTFImage method is: % % Image *ReadTTFImage(const ImageInfo *image_info,ExceptionInfo *exception) % % A description of each parameter follows: % % o image_info: the image info. % % o exception: return any errors or warnings in this structure. % */ static Image *ReadTTFImage(const ImageInfo *image_info,ExceptionInfo *exception) { char buffer[MaxTextExtent], *text; const char *Text = (char *) "abcdefghijklmnopqrstuvwxyz\n" "ABCDEFGHIJKLMNOPQRSTUVWXYZ\n" "0123456789.:,;(*!?}^)#${%^&-+@\n"; const TypeInfo *type_info; DrawInfo *draw_info; Image *image; MagickBooleanType status; PixelPacket background_color; register ssize_t i, x; register PixelPacket *q; ssize_t y; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); image=AcquireImage(image_info); image->columns=800; image->rows=480; type_info=GetTypeInfo(image_info->filename,exception); if ((type_info != (const TypeInfo *) NULL) && (type_info->glyphs != (char *) NULL)) (void) CopyMagickString(image->filename,type_info->glyphs,MaxTextExtent); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) { image=DestroyImageList(image); return((Image *) NULL); } /* Color canvas with background color */ background_color=image_info->background_color; for (y=0; y < (ssize_t) image->rows; y++) { q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) break; for (x=0; x < (ssize_t) image->columns; x++) *q++=background_color; if (SyncAuthenticPixels(image,exception) == MagickFalse) break; } (void) CopyMagickString(image->magick,image_info->magick,MaxTextExtent); (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent); /* Prepare drawing commands */ y=20; draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL); draw_info->font=AcquireString(image->filename); ConcatenateString(&draw_info->primitive,"push graphic-context\n"); (void) FormatLocaleString(buffer,MaxTextExtent," viewbox 0 0 %.20g %.20g\n", (double) image->columns,(double) image->rows); ConcatenateString(&draw_info->primitive,buffer); ConcatenateString(&draw_info->primitive," font-size 18\n"); (void) FormatLocaleString(buffer,MaxTextExtent," text 10,%.20g '",(double) y); ConcatenateString(&draw_info->primitive,buffer); text=EscapeString(Text,'"'); ConcatenateString(&draw_info->primitive,text); text=DestroyString(text); (void) FormatLocaleString(buffer,MaxTextExtent,"'\n"); ConcatenateString(&draw_info->primitive,buffer); y+=20*(ssize_t) MultilineCensus((char *) Text)+20; for (i=12; i <= 72; i+=6) { y+=i+12; ConcatenateString(&draw_info->primitive," font-size 18\n"); (void) FormatLocaleString(buffer,MaxTextExtent," text 10,%.20g '%.20g'\n", (double) y,(double) i); ConcatenateString(&draw_info->primitive,buffer); (void) FormatLocaleString(buffer,MaxTextExtent," font-size %.20g\n", (double) i); ConcatenateString(&draw_info->primitive,buffer); (void) FormatLocaleString(buffer,MaxTextExtent," text 50,%.20g " "'That which does not destroy me, only makes me stronger.'\n",(double) y); ConcatenateString(&draw_info->primitive,buffer); if (i >= 24) i+=6; } ConcatenateString(&draw_info->primitive,"pop graphic-context"); (void) DrawImage(image,draw_info); /* Relinquish resources. */ draw_info=DestroyDrawInfo(draw_info); (void) CloseBlob(image); return(GetFirstImageInList(image)); }
void CodeGenerator::ProcessFunctionTerm(int flags) { VarType ret_type; Function *func_ptr; int final = 0; infunc(CodeGenerator::ProcessFunctionTerm); INC_TOKEN; // Check for function modifiers switch (CUR_TOKEN.type) { // Final definition of this function within the hierarchy case (TOKEN_FINAL): ProcessFunctionTerm(flags | FLAGS_FUNCTION_FINAL); return; // This function is externally defined (C++) case (TOKEN_IMPORT): ProcessFunctionTerm(flags | FLAGS_FUNCTION_IMPORT); return; } // Does this specify a return type? if (CUR_TOKEN.Group() == TOKEN_GROUP_KEYWORD) { GetTypeInfo(ret_type, 0); // Check for invalid variable return types on the 2nd pass if (g_Object) if (ret_type.id == VARIABLE_TYPEID_CUSTOM) if (g_Env->GetClass(ret_type.name) == NULL) throw CompileError("(Line %d) Undefined variable type", CUR_TOKEN.type); // Process the array dimensions if it returns an array if (CUR_TOKEN.type == TOKEN_ARRAY_OPEN) { GetArrayInfo(ret_type); } } // No return specified, treat as void else if (CUR_TOKEN.type == TOKEN_NAME) { ret_type.Make(VARIABLE_TYPEID_VOID); } // Error else { throw CompileError("(Line %d) Illegal token after function declaration", CUR_TOKEN.line); } if (CUR_TOKEN.type != TOKEN_NAME) throw CompileError("(Line %d) No name found for function", CUR_TOKEN.line); // Grab the name IsolateTokenString(CUR_TOKEN); INC_TOKEN; if (CUR_TOKEN.type != TOKEN_LEFT_BRACKET) throw CompileError("(Line %d) No opening bracket found", CUR_TOKEN.line); // Move over the open bracket INC_TOKEN; if (g_Object == NULL) { // Create a new function if ((func_ptr = new Function) == NULL) throw CError("Couldn't allocate function structure"); // This is an imported function if (flags & FLAGS_FUNCTION_IMPORT) { // Add it to the imported list cur_class->imp_functions.Add(token_string, func_ptr); // Set function information func_ptr->SetIndex(cur_class->NewImportIndex()); func_ptr->SetFlag(FFLAGS_IMPORTED); func_ptr->SetReturnType(ret_type); } // This is a normal function else { // Add the function to its appropriate list if (flags & FLAGS_IN_STATE) cur_class->cur_state->functions.Add(token_string, func_ptr); else cur_class->functions.Add(token_string, func_ptr); // Set function information func_ptr->SetIndex(cur_class->NewFunctionIndex()); func_ptr->SetFlag((flags & FLAGS_FUNCTION_FINAL) ? FFLAGS_FINAL : 0); func_ptr->SetReturnType(ret_type); // Check to see if this is a constructor definition and set the entry point if (!strcmp(token_string, cur_class->GetName())) cur_class->SetEntryPoint(func_ptr->GetIndex()); } } else { // Imported function if (flags & FLAGS_FUNCTION_IMPORT) { // Function already defined, get it from within the class func_ptr = cur_class->GetImport(token_string); } // Normal function else { // Function already defined, get it from within the class func_ptr = cur_class->GetFunction(token_string, flags); // Safe to set the code location func_ptr->SetCodeLocation(g_Object->GetPosition()); // Enter stack frame if (func_ptr->GetCurAddress() || func_ptr->GetCurPAddress()) g_Object->WriteOp(OPCODE_INSTF); // Allocate some space on the stack if (func_ptr->GetCurAddress()) g_Object->WriteOp(OPCODE_SUBST, func_ptr->GetCurAddress()); } } while (1) { VarType type; Variable *var; // Check for no parameters if (CUR_TOKEN.type == TOKEN_VOID) { // void INC_TOKEN; if (func_ptr->GetNumParams()) throw CompileError("(Line %d) Illegal placement of void type", CUR_TOKEN.line); if (CUR_TOKEN.type != TOKEN_RIGHT_BRACKET) throw CompileError("(Line %d) Expecting closing bracket", CUR_TOKEN.line); // Closing bracket INC_TOKEN; break; } // That's when to end! if (CUR_TOKEN.type == TOKEN_RIGHT_BRACKET) { INC_TOKEN; break; } // Get the variable type GetTypeInfo(type, 0); // Check for invalid variable types on the 2nd pass if (g_Object && type.id == VARIABLE_TYPEID_CUSTOM) if (g_Env->GetClass(type.name) == NULL) throw CompileError("(Line %d) Undefined variable type", CUR_TOKEN.line); if (CUR_TOKEN.type != TOKEN_NAME) throw CompileError("(Line %d) Expecting name", CUR_TOKEN.line); // And the name IsolateTokenString(CUR_TOKEN); INC_TOKEN; // If it's an array, determine the dimensions if (CUR_TOKEN.type == TOKEN_ARRAY_OPEN) GetArrayInfo(type); // Add the parameter if (g_Object == NULL) var = func_ptr->AddParameter(type, token_string); if (CUR_TOKEN.type == TOKEN_RIGHT_BRACKET) { INC_TOKEN; break; } if (CUR_TOKEN.type != TOKEN_COMMA) throw CompileError("(Line %d) Need comma to seperate parameters", CUR_TOKEN.line); // Comma INC_TOKEN; } // Imported functions if (flags & FLAGS_FUNCTION_IMPORT) { if (g_Object == NULL) func_ptr->SingulariseAddresses(); if (CUR_TOKEN.type != TOKEN_END_OF_LINE) throw CompileError("(Line %d) Expecting end of line", CUR_TOKEN.line); } // Normal functions else { if (g_Object == NULL) func_ptr->FixAddresses(); cur_class->cur_function = func_ptr; ProcessBlock(flags | FLAGS_IN_FUNCTION); // Simply write the return code for void functions if (func_ptr->GetReturnType().id == VARIABLE_TYPEID_VOID) { if (g_Object) func_ptr->WriteReturn(g_Object); } else { // If a return type is needed, throw an error if one isn't found last if (!func_ptr->had_return) throw CompileError("(Line %d) Missing return value for function '%s'", CUR_TOKEN.line, func_ptr->GetName()); } } outfunc; }
Error VertexArrayGL::syncIndexData(GLsizei count, GLenum type, const GLvoid *indices, bool attributesNeedStreaming, RangeUI *outIndexRange, const GLvoid **outIndices) const { ASSERT(outIndices); gl::Buffer *elementArrayBuffer = mData.getElementArrayBuffer().get(); // Need to check the range of indices if attributes need to be streamed if (elementArrayBuffer != nullptr) { if (elementArrayBuffer != mAppliedElementArrayBuffer.get()) { const BufferGL *bufferGL = GetImplAs<BufferGL>(elementArrayBuffer); mStateManager->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, bufferGL->getBufferID()); mAppliedElementArrayBuffer.set(elementArrayBuffer); } // Only compute the index range if the attributes also need to be streamed if (attributesNeedStreaming) { ptrdiff_t elementArrayBufferOffset = reinterpret_cast<ptrdiff_t>(indices); Error error = mData.getElementArrayBuffer()->getIndexRange( type, static_cast<size_t>(elementArrayBufferOffset), count, outIndexRange); if (error.isError()) { return error; } } // Indices serves as an offset into the index buffer in this case, use the same value for the draw call *outIndices = indices; } else { // Need to stream the index buffer // TODO: if GLES, nothing needs to be streamed // Only compute the index range if the attributes also need to be streamed if (attributesNeedStreaming) { *outIndexRange = ComputeIndexRange(type, indices, count); } // Allocate the streaming element array buffer if (mStreamingElementArrayBuffer == 0) { mFunctions->genBuffers(1, &mStreamingElementArrayBuffer); mStreamingElementArrayBufferSize = 0; } mStateManager->bindBuffer(GL_ELEMENT_ARRAY_BUFFER, mStreamingElementArrayBuffer); mAppliedElementArrayBuffer.set(nullptr); // Make sure the element array buffer is large enough const Type &indexTypeInfo = GetTypeInfo(type); size_t requiredStreamingBufferSize = indexTypeInfo.bytes * count; if (requiredStreamingBufferSize > mStreamingElementArrayBufferSize) { // Copy the indices in while resizing the buffer mFunctions->bufferData(GL_ELEMENT_ARRAY_BUFFER, requiredStreamingBufferSize, indices, GL_DYNAMIC_DRAW); mStreamingElementArrayBufferSize = requiredStreamingBufferSize; } else { // Put the indices at the beginning of the buffer mFunctions->bufferSubData(GL_ELEMENT_ARRAY_BUFFER, 0, requiredStreamingBufferSize, indices); } // Set the index offset for the draw call to zero since the supplied index pointer is to client data *outIndices = nullptr; } return Error(GL_NO_ERROR); }
void CodeGenerator::GetTypeInfo(VarType &type, int standard_types) { infunc(CodeGenerator::GetTypeInfo); char name[MAX_LABEL_SIZE]; switch (CUR_TOKEN.type) { // These are the standard types that can be mixed with signed/unsigned case (TOKEN_DECLARE_INT): type.Make(VARIABLE_TYPEID_INT); INC_TOKEN; break; case (TOKEN_DECLARE_SHORT): type.Make(VARIABLE_TYPEID_SHORT); INC_TOKEN; break; case (TOKEN_DECLARE_CHAR): type.Make(VARIABLE_TYPEID_CHAR); INC_TOKEN; break; // For signed/unsigned, call the function again for the next token but request // standard types. case (TOKEN_DECLARE_SIGNED): INC_TOKEN; GetTypeInfo(type, 1); break; case (TOKEN_DECLARE_UNSIGNED): INC_TOKEN; GetTypeInfo(type, 1); type.id |= VARIABLE_TYPEID_UNSIGNED; sprintf(name, "unsigned %s", type.name); strcpy(type.name, name); break; // These types cannot be mixed with signed/unsigned so flag errors if they are case (TOKEN_VOID): if (standard_types) throw CompileError("(Line %d) Cannot combine 'void' with signed/unsigned", CUR_TOKEN.line); type.Make(VARIABLE_TYPEID_VOID); INC_TOKEN; break; case (TOKEN_DECLARE_FLOAT): if (standard_types) throw CompileError("(Line %d) Cannot combine 'float' with signed/unsigned", CUR_TOKEN.line); type.Make(VARIABLE_TYPEID_FLOAT); INC_TOKEN; break; case (TOKEN_DECLARE_STRING): if (standard_types) throw CompileError("(Line %d) Cannot combine 'string' with signed/unsigned", CUR_TOKEN.line); type.Make(VARIABLE_TYPEID_STRING); INC_TOKEN; break; // This is a user-defined type, set it to custom and copy the name default: if (standard_types) throw CompileError("(Line %d) Cannot combine type with signed/unsigned", CUR_TOKEN.line); type.id = VARIABLE_TYPEID_CUSTOM; IsolateTokenString(CUR_TOKEN); strcpy(type.name, token_string); INC_TOKEN; break; } // Not an array by default type.array = 0; type.elements = 0; outfunc; }
bool Object::IsInstanceOf(const TypeInfo* typeInfo) const { return GetTypeInfo()->IsTypeOf(typeInfo); }
bool StatementObject::Invoke(NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result) { //sprintf(tmp, "stmt Invoke [%s]\n", NPN_UTF8FromIdentifier(name)); log(tmp); NPError rc; VOID_TO_NPVARIANT(*result); int index = 0; if (name == mc_Init_id) { if (argCount < 2) { NPN_SetException(this, "Too few parameters count"); return true; } #if 0 if (!(NPVARIANT_IS_INT32(args[0]) && NPVARIANT_IS_OBJECT(args[1]))) { NPN_SetException(this, "Wrong argument type"); return true; } SQLHANDLE hdbc = (SQLHANDLE)(long)NPVARIANT_TO_INT32(args[0]); #else if (!(NPVARIANT_IS_OBJECT(args[0]) && NPVARIANT_IS_OBJECT(args[1]))) { NPN_SetException(this, "Wrong argument type"); return true; } SQLHANDLE hdbc = (SQLHANDLE)NPVARIANT_TO_OBJECT(args[0]); #endif Init(hdbc, NPVARIANT_TO_OBJECT(args[1])); return true; } else if (name == mc_AddParameter_id) { if (argCount < 1) { NPN_SetException(this, "Too few parameters count"); return true; } AddParam(args); return true; } else if (name == mc_Execute_id) { if (argCount < 1) { NPN_SetException(this, "Too few parameters count"); return true; } if (!NPVARIANT_IS_STRING(args[0])) { NPN_SetException(this, "Wrong argument type"); return true; } Execute((NPString*)&NPVARIANT_TO_STRING(args[0])); return true; } else if (name == mc_Close_id) { Close(); return true; } else if (name == mc_Fetch_id) { bool ret; rc = Fetch(&ret); if (rc != NPERR_NO_ERROR) return true; BOOLEAN_TO_NPVARIANT(ret, *result); return true; } else if (name == mc_MoreResults_id) { bool ret; rc = MoreResults(&ret); if (rc != NPERR_NO_ERROR) return true; BOOLEAN_TO_NPVARIANT(ret, *result); return true; } else if (name == mc_GetColumnName_id) { const char *ret; if (argCount < 1) { NPN_SetException(this, "Too few parameters count"); return true; } if (NPVARIANT_IS_INT32(args[0])) index = NPVARIANT_TO_INT32(args[0]); else if (NPVARIANT_IS_DOUBLE(args[0])) index = (int)NPVARIANT_TO_DOUBLE(args[0]); else { NPN_SetException(this, "Wrong argument type"); return true; } rc = GetColumnName(index, &ret); if (rc != NPERR_NO_ERROR) return true; STRING_TO_NPVARIANT(ret, *result); return true; } else if (name == mc_GetVariant_id) { if (argCount < 1) { NPN_SetException(this, "Too few parameters count"); return true; } if (NPVARIANT_IS_INT32(args[0])) index = NPVARIANT_TO_INT32(args[0]); else if (NPVARIANT_IS_DOUBLE(args[0])) index = (int)NPVARIANT_TO_DOUBLE(args[0]); else { NPN_SetException(this, "Wrong argument type"); return true; } GetVariant(index, result); return true; } else if (name == mc_GetColumnType_id) { int ret; if (argCount < 1) { NPN_SetException(this, "Too few parameters count"); return true; } if (NPVARIANT_IS_INT32(args[0])) index = NPVARIANT_TO_INT32(args[0]); else if (NPVARIANT_IS_DOUBLE(args[0])) index = (int)NPVARIANT_TO_DOUBLE(args[0]); else { NPN_SetException(this, "Wrong argument type"); return true; } rc = GetColumnType(index, &ret); if (rc != NPERR_NO_ERROR) return true; INT32_TO_NPVARIANT(ret, *result); return true; } else if (name == mc_IsColumnNullable_id) { bool ret; if (argCount < 1) { NPN_SetException(this, "Too few parameters count"); return true; } if (NPVARIANT_IS_INT32(args[0])) index = NPVARIANT_TO_INT32(args[0]); else if (NPVARIANT_IS_DOUBLE(args[0])) index = (int)NPVARIANT_TO_DOUBLE(args[0]); else { NPN_SetException(this, "Wrong argument type"); return true; } rc = IsColumnNullable(index, &ret); if (rc != NPERR_NO_ERROR) return true; BOOLEAN_TO_NPVARIANT(ret, *result); return true; } else if (name == mc_GetTables_id) { if (argCount < 4) { NPN_SetException(this, "Too few parameters count"); return true; } if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) { NPN_SetException(this, "Wrong 1 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) { NPN_SetException(this, "Wrong 2 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) { NPN_SetException(this, "Wrong 3 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[3]) || NPVARIANT_IS_STRING(args[3]))) { NPN_SetException(this, "Wrong 4 argument type"); return true; } GetTables(&args[0], &args[1], &args[2], &args[3]); return true; } else if (name == mc_GetColumns_id) { if (argCount < 4) { NPN_SetException(this, "Too few parameters count"); return true; } if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) { NPN_SetException(this, "Wrong 1 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) { NPN_SetException(this, "Wrong 2 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) { NPN_SetException(this, "Wrong 3 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[3]) || NPVARIANT_IS_STRING(args[3]))) { NPN_SetException(this, "Wrong 4 argument type"); return true; } GetColumns(&args[0], &args[1], &args[2], &args[3]); return true; } else if (name == mc_GetTypeInfo_id) { if (argCount < 1) { NPN_SetException(this, "Too few parameters count"); return true; } if (NPVARIANT_IS_INT32(args[0])) index = NPVARIANT_TO_INT32(args[0]); else if (NPVARIANT_IS_DOUBLE(args[0])) index = (int)NPVARIANT_TO_DOUBLE(args[0]); else { NPN_SetException(this, "Wrong argument type"); return true; } GetTypeInfo(index); return true; } else if (name == mc_GetPrimaryKeys_id) { if (argCount < 3) { NPN_SetException(this, "Too few parameters count"); return true; } if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) { NPN_SetException(this, "Wrong 1 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) { NPN_SetException(this, "Wrong 2 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) { NPN_SetException(this, "Wrong 3 argument type"); return true; } GetPrimaryKeys(&args[0], &args[1], &args[2]); return true; } else if (name == mc_GetForeignKeys_id) { if (argCount < 6) { NPN_SetException(this, "Too few parameters count"); return true; } if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) { NPN_SetException(this, "Wrong 1 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) { NPN_SetException(this, "Wrong 2 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) { NPN_SetException(this, "Wrong 3 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[3]) || NPVARIANT_IS_STRING(args[3]))) { NPN_SetException(this, "Wrong 4 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[4]) || NPVARIANT_IS_STRING(args[4]))) { NPN_SetException(this, "Wrong 5 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[5]) || NPVARIANT_IS_STRING(args[5]))) { NPN_SetException(this, "Wrong 6 argument type"); return true; } GetForeignKeys(&args[0], &args[1], &args[2], &args[3], &args[4], &args[5]); return true; } else if (name == mc_GetProcedures_id) { if (argCount < 3) { NPN_SetException(this, "Too few parameters count"); return true; } if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) { NPN_SetException(this, "Wrong 1 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) { NPN_SetException(this, "Wrong 2 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) { NPN_SetException(this, "Wrong 3 argument type"); return true; } GetProcedures(&args[0], &args[1], &args[2]); return true; } else if (name == mc_GetProcedureColumns_id) { if (argCount < 4) { NPN_SetException(this, "Too few parameters count"); return true; } if (!(NPVARIANT_IS_NULL(args[0]) || NPVARIANT_IS_STRING(args[0]))) { NPN_SetException(this, "Wrong 1 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[1]) || NPVARIANT_IS_STRING(args[1]))) { NPN_SetException(this, "Wrong 2 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[2]) || NPVARIANT_IS_STRING(args[2]))) { NPN_SetException(this, "Wrong 3 argument type"); return true; } if (!(NPVARIANT_IS_NULL(args[3]) || NPVARIANT_IS_STRING(args[3]))) { NPN_SetException(this, "Wrong 4 argument type"); return true; } GetProcedureColumns(&args[0], &args[1], &args[2], &args[3]); return true; } return false; }
Bool CPropertyConcrete<DataType>::CopyFrom( const CPropertyInterface& p ) { DebugAssert( p.GetTypeInfo().IsKindOf( GetTypeInfo() ) ); SetValue( ((const CPropertyConcrete<DataType>&)p).GetValue() ); return TRUE; }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d T T F I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ReadTTFImage() reads a TrueType font file and returns it. It % allocates the memory necessary for the new Image structure and returns a % pointer to the new image. % % The format of the ReadTTFImage method is: % % Image *ReadTTFImage(const ImageInfo *image_info,ExceptionInfo *exception) % % A description of each parameter follows: % % o image_info: The image info. % % o exception: return any errors or warnings in this structure. % % */ static Image *ReadTTFImage(const ImageInfo *image_info,ExceptionInfo *exception) { char buffer[MaxTextExtent]; const char *Text = (char *) "The quick brown fox jumps over the lazy dog 0123456789\n" "ABCDEFGHIJKLMNOPQRSTUVWXYZ &#~\"\\'(-`_^@)=+\260\n" "$\243^\250*\265\371%!\247:/;.,?<> " "\342\352\356\373\364\344\353\357\366\374\377\340\371\351\350\347 "; const TypeInfo *type_info; DrawInfo *draw_info; Image *image; long y; MagickBooleanType status; PixelPacket background_color; register long i, x; register PixelPacket *q; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); image=AllocateImage(image_info); image->columns=800; image->rows=480; type_info=GetTypeInfo(image_info->filename,exception); if ((type_info != (const TypeInfo *) NULL) && (type_info->glyphs != (char *) NULL)) (void) CopyMagickString(image->filename,type_info->glyphs,MaxTextExtent); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) { image=DestroyImageList(image); return((Image *) NULL); } /* Color canvas with background color */ background_color=image_info->background_color; for (y=0; y < (long) image->rows; y++) { q=SetImagePixels(image,0,y,image->columns,1); if (q == (PixelPacket *) NULL) break; for (x=0; x < (long) image->columns; x++) *q++=background_color; if (SyncImagePixels(image) == MagickFalse) break; } (void) CopyMagickString(image->magick,image_info->magick,MaxTextExtent); (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent); /* Prepare drawing commands */ y=20; draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL); draw_info->font=AcquireString(image->filename); draw_info->fill=image_info->pen; ConcatenateString(&draw_info->primitive,"push graphic-context\n"); (void) FormatMagickString(buffer,MaxTextExtent," viewbox 0 0 %lu %lu\n", image->columns,image->rows); ConcatenateString(&draw_info->primitive,buffer); ConcatenateString(&draw_info->primitive," font-size 18\n"); (void) FormatMagickString(buffer,MaxTextExtent," text 10,%ld '",y); ConcatenateString(&draw_info->primitive,buffer); ConcatenateString(&draw_info->primitive,Text); (void) FormatMagickString(buffer,MaxTextExtent,"'\n"); ConcatenateString(&draw_info->primitive,buffer); y+=20*MultilineCensus((char *) Text)+20; for (i=12; i <= 72; i+=6) { y+=i+12; ConcatenateString(&draw_info->primitive," font-size 18\n"); (void) FormatMagickString(buffer,MaxTextExtent," text 10,%ld '%ld'\n",y,i); ConcatenateString(&draw_info->primitive,buffer); (void) FormatMagickString(buffer,MaxTextExtent," font-size %ld\n",i); ConcatenateString(&draw_info->primitive,buffer); (void) FormatMagickString(buffer,MaxTextExtent," text 50,%ld " "'That which does not destroy me, only makes me stronger.'\n",y); ConcatenateString(&draw_info->primitive,buffer); if (i >= 24) i+=6; } ConcatenateString(&draw_info->primitive,"pop graphic-context"); (void) DrawImage(image,draw_info); /* Free resources. */ draw_info=DestroyDrawInfo(draw_info); CloseBlob(image); return(GetFirstImageInList(image)); }
void CodeGenerator::ProcessVarTerm(int flags) { infunc(CodeGenerator::ProcessVarTerm); char name[MAX_LABEL_SIZE]; VarType type; if ((flags & FLAGS_IN_STATE) && !(flags & FLAGS_IN_FUNCTION)) throw CompileError("(Line %d) Not allowed variable declarations inside states, but outside of functions", CUR_TOKEN.line); // Grab the type GetTypeInfo(type, 0); // Loop until the declaration has ended while (CUR_TOKEN.type != TOKEN_END_OF_LINE) { Variable *var; if (CUR_TOKEN.type != TOKEN_NAME) throw CompileError("(Line %d) No name after type declaration", CUR_TOKEN.line); // Get the current variable name IsolateTokenString(CUR_TOKEN); strcpy(name, token_string); INC_TOKEN; // Grab the array dimensions if it's an array if (CUR_TOKEN.type == TOKEN_ARRAY_OPEN) GetArrayInfo(type); if (g_Object == NULL) { if (flags & FLAGS_IN_FUNCTION) { var = cur_class->cur_function->AddLocal(type, name); } else { // Create a new variable if ((var = new Variable) == NULL) throw CError("Couldn't allocate variable structure"); var->SetType(type); var->SetScope(VARIABLE_SCOPE_MEMBER); if (type.array) { var->SetAddress(cur_class->NewAddress(4 + (type.elements << 2), 0)); var->SetArrayElements(type.elements); } else var->SetAddress(cur_class->NewAddress(4, 1)); // Add it to the class list of variables cur_class->variables.Add(name, var); } } else { // Variable already defined, get it from the class var = cur_class->GetVariable(name, flags); // Check for invalid custom variable types if (var->GetType().id == VARIABLE_TYPEID_CUSTOM) if (g_Env->GetClass(var->GetType().name) == NULL) throw CompileError("(Line %d) Undefined variable type", CUR_TOKEN.line); // Local variables that are arrays need to be prepared if (flags & FLAGS_IN_FUNCTION && var->GetType().array) g_Object->WriteOp(OPCODE_ARRAYP, var->GetAddress()); } // Check for initial values if (CUR_TOKEN.type == TOKEN_ASSIGN) { if (type.id == VARIABLE_TYPEID_CUSTOM) throw CompileError("(Line %d) Not allowed immediate assignments on custom variable types", CUR_TOKEN.line); INC_TOKEN; // Is this an array? if (var->GetArrayElements()) { int x = 0, neg; dynamic num; neg = 0; if (CUR_TOKEN.type != TOKEN_BLOCK_OPEN) throw CompileError("(Line %d) Expecting block open for array default value definition", CUR_TOKEN.line); INC_TOKEN; while (1) { // Check for exit if (CUR_TOKEN.type == TOKEN_BLOCK_CLOSE) { INC_TOKEN; break; } // Check for too many variables if (x == var->GetArrayElements()) throw CompileError("(Line %d) Too many initialisers for array", CUR_TOKEN.line); // Read the value ReadConstant(&num, type, TOKEN_COMMA, TOKEN_BLOCK_CLOSE); if (g_Object == NULL) var->SetElementValue(x, &num); x++; // Check for the comma if (CUR_TOKEN.type != TOKEN_BLOCK_CLOSE) { if (CUR_TOKEN.type != TOKEN_COMMA) throw CompileError("(Line %d) Expecting comma seperator", CUR_TOKEN.line); INC_TOKEN; // Check for situations like = { 4, }; if (CUR_TOKEN.type == TOKEN_BLOCK_CLOSE) throw CompileError("(Line %d) Expecting array element", CUR_TOKEN.line); } } } // No else { dynamic num; ReadConstant(&num, type, TOKEN_END_OF_LINE, TOKEN_COMMA); if (g_Object == NULL) var->SetDefaultValue(&num); } } // Check for multiple variable declarations if (CUR_TOKEN.type == TOKEN_COMMA) { INC_TOKEN; if (CUR_TOKEN.type == TOKEN_END_OF_LINE) throw CompileError("(Line %d) Unexpected end of line", CUR_TOKEN.line); } else if (CUR_TOKEN.type != TOKEN_END_OF_LINE) throw CompileError("(Line %d) Illegal token after variable declaration", CUR_TOKEN.line); } outfunc; }
void RendererBasePimpl::InitDomainUniformAndSamplers(ShaderProgram * resource, unsigned int domain, GLuint program) { char uniform_name[1000]; GLsizei name_length; GLint uniform_size; GLenum uniform_type; GLint uniform_count; GLuint uniform_location; glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &uniform_count); std::vector<std::pair<std::string, int> > uniform_names; std::vector<std::pair<std::string, int> > sampler_names; std::vector<UniformParam> uniform_vector; std::vector<GLuint> uniform_locations; std::vector<SamplerParam> sampler_vector; std::vector<GLuint> sampler_locations; unsigned int next_offset = 0; for (int i = 0; i < uniform_count; ++i) { glGetActiveUniform(program, i, 1000, &name_length, &uniform_size, &uniform_type, uniform_name); uniform_location = glGetUniformLocation(program, uniform_name); unsigned char rows = 1; unsigned char columns = 1; unsigned char type = 0; bool sampler = false; GetTypeInfo(uniform_type, type, rows, columns, sampler); if (sampler) { sampler_names.push_back(std::make_pair(uniform_name, sampler_names.size())); sampler_vector.push_back(SamplerParam()); sampler_vector.back().type = type; sampler_locations.push_back(uniform_location); } else { uniform_names.push_back(std::make_pair(uniform_name, uniform_names.size())); uniform_vector.push_back(UniformParam()); uniform_vector.back().array_length = uniform_size; uniform_vector.back().row_major = false; uniform_vector.back().type = type; uniform_vector.back().rows = rows; uniform_vector.back().columns = columns; uniform_vector.back().uniform_buffer_index = 0; uniform_vector.back().uniform_buffer_offset = next_offset; uniform_vector.back().uniform_buffer_array_stride = 0; uniform_vector.back().uniform_buffer_matrix_stride = rows > 1 ? rows : 0; uniform_locations.push_back(uniform_location); switch(type) { case DT_FLOAT: next_offset = next_offset + (sizeof(float) * rows * columns * uniform_size); break; default: std::cout << "Other types not supported yet." << std::endl; break; } } } std::sort(uniform_names.begin(), uniform_names.end()); std::sort(sampler_names.begin(), sampler_names.end()); resource->uniforms.Set(uniform_names.size()); resource->samplers.Set(sampler_names.size()); GLint uniformblock_count = 0; if (GLEW_ARB_uniform_buffer_object) { char uniformblock_name[1000]; GLint name_length; GLint block_binding; GLint block_data_size; GLint block_active_uniforms; glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &uniformblock_count); resource->uniform_blocks.Set(uniform_names.size() > 0 ? uniformblock_count + 1 : uniformblock_count); //Add one because we make "no ubo" as 0 index. unsigned int total_uniforms_in_blocks = 0; for (int i = 0; i < uniformblock_count; ++i) { glGetActiveUniformBlockName(program, i, 1000, &name_length, uniformblock_name); GLint params; glGetActiveUniformBlockiv(program, i, GL_UNIFORM_BLOCK_BINDING, &block_binding); glGetActiveUniformBlockiv(program, i, GL_UNIFORM_BLOCK_DATA_SIZE, &block_data_size); glGetActiveUniformBlockiv(program, i, GL_UNIFORM_BLOCK_NAME_LENGTH, ¶ms); glGetActiveUniformBlockiv(program, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &block_active_uniforms); std::vector<GLuint> uniform_indices(block_active_uniforms, 0); glGetActiveUniformBlockiv(program, i, GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, reinterpret_cast<GLint*>(&uniform_indices[0])); std::vector<GLuint> uniform_offsets(block_active_uniforms, 0); glGetActiveUniformsiv(program, block_active_uniforms, &uniform_indices[0], GL_UNIFORM_OFFSET, reinterpret_cast<GLint*>(&uniform_offsets[0])); std::vector<GLuint> uniform_arraystrides(block_active_uniforms, 0); glGetActiveUniformsiv(program, block_active_uniforms, &uniform_indices[0], GL_UNIFORM_ARRAY_STRIDE, reinterpret_cast<GLint*>(&uniform_arraystrides[0])); std::vector<GLuint> uniform_matrixstrides(block_active_uniforms, 0); glGetActiveUniformsiv(program, block_active_uniforms, &uniform_indices[0], GL_UNIFORM_MATRIX_STRIDE, reinterpret_cast<GLint*>(&uniform_matrixstrides[0])); std::vector<GLuint> uniform_rowmajor(block_active_uniforms, 0); glGetActiveUniformsiv(program, block_active_uniforms, &uniform_indices[0], GL_UNIFORM_IS_ROW_MAJOR, reinterpret_cast<GLint*>(&uniform_rowmajor[0])); unsigned int block_index = uniform_names.size() > 0 ? (i + 1) : i;//Add one because we make "no ubo" as 0 index. resource->uniform_blocks[block_index].name = uniformblock_name; resource->uniform_blocks[block_index].byte_count = block_data_size; resource->uniform_blocks[block_index].uniform_indices.Set(block_active_uniforms); total_uniforms_in_blocks += block_active_uniforms; for (unsigned int p = 0; p < uniform_indices.size(); ++p) { uniform_vector[uniform_indices[p]].uniform_buffer_index = block_index; uniform_vector[uniform_indices[p]].uniform_buffer_offset = uniform_offsets[p]; uniform_vector[uniform_indices[p]].uniform_buffer_array_stride = uniform_arraystrides[p]; uniform_vector[uniform_indices[p]].uniform_buffer_matrix_stride = uniform_matrixstrides[p]; uniform_vector[uniform_indices[p]].row_major = uniform_rowmajor[p]; } //std::cout << " Location: " << glGetUniformLocation(pimpl->combined, uniformblock_name) << std::endl; } resource->uniform_blocks[0].uniform_indices.Set(uniform_names.size() - total_uniforms_in_blocks); } else { if (uniform_names.size() > 0) { resource->uniform_blocks.Set(1); resource->uniform_blocks[0].uniform_indices.Set(uniform_names.size()); } } if (uniform_names.size() > 0) { std::vector<unsigned int> block_param_count(resource->uniform_blocks.GetSize(), 0); unsigned int block_zero_size = 0; //Loop through all uniforms sorted by names. for (unsigned int i = 0; i < uniform_names.size(); ++i) { //Set uniform info in ShaderProgram.domains[domain].uniforms. int index = uniform_names[i].second; resource->uniforms[i] = uniform_vector[index]; resource->uniforms[i].name = uniform_names[i].first; //Put index in the parameter's block in ShaderProgram.domains[domain].uniform_blocks. int uniform_block_index = uniform_vector[index].uniform_buffer_index; resource->uniform_blocks[uniform_block_index].uniform_indices[block_param_count[uniform_block_index]] = i; block_param_count[uniform_block_index] += 1; //For block zero, calculate size. if (uniform_block_index == 0) { block_zero_size = std::max<unsigned int>( block_zero_size, uniform_vector[index].uniform_buffer_offset + uniform_vector[index].rows * uniform_vector[index].columns * sizeof(float) * uniform_vector[index].array_length); //Only for DT_FLOAT. Fix later. } } resource->uniform_blocks[0].byte_count = block_zero_size; } for (unsigned int i = 0; i < sampler_names.size(); ++i) { int index = sampler_names[i].second; resource->samplers[i] = sampler_vector[index]; resource->samplers[i].name = sampler_names[i].first; } ShaderProgramPimpl * program_pimpl = (ShaderProgramPimpl *) resource->PRIVATE; program_pimpl->uniform_locations.Set(uniform_names.size()); program_pimpl->sampler_locations.Set(sampler_names.size()); program_pimpl->sampler_units.Set(sampler_names.size()); program_pimpl->block_bind_points.Set(uniform_names.size() > 0 ? (uniformblock_count + 1) : uniformblock_count); program_pimpl->bound_uniform_buffers.Set(uniformblock_count + 1, 0); }