示例#1
0
    BLOCK_EX(fos,mSerialize2ArrayDeclare)
    {
	PreSerialize(fos);
    	for(auto& pBase : Bases())
	{
	   fos<<"target = WireFormatLite::WriteUInt32NoTagToArray((uint32)ByteSizeInternal(static_cast<"<<pBase->Name()<<"&>(obj)),target);"<<std::endl;
	   fos<<"target = Serialize2Array(target,static_cast<"<<pBase->Name()<<"&>(obj));"<<std::endl;
	}

	for(auto& pField : Fields())
	{
	    fos<<"//serialize "<<pField->Name()<<std::endl;
	    pField->CodingSerialize2Array(fos);
	}

	PostSerialize(fos);
	fos<<"return target;"<<std::endl;
    }
示例#2
0
bool
Bindable::CheckForAccessibleEventsWorker
(
    BCSYM *TypePossiblyContainingEvents,
    BCSYM *TypeOfWithEventsVar,
    MembersHashTable *ShadowingMembers,
    bool ConsiderEventSourcePropertiesToo,
    bool &AnyEventDefined
)
{
    VSASSERT( TypePossiblyContainingEvents->IsContainer(),
                    "Looking for events in non-container unexpected!!!");

    // 


    // ---- attributes on all symbols in the EventDecl container. This is needed
    // in order to verify if a property is an EventSource which is determined by
    // an attribute on the property.
    //
    if (ConsiderEventSourcePropertiesToo)
    {
        ----AttributesOnAllSymbolsInContainer(TypePossiblyContainingEvents->PContainer(), m_CompilationCaches);
    }

    BCITER_CHILD ContainerIterator;
    ContainerIterator.Init(TypePossiblyContainingEvents->PContainer());

    for(BCSYM_NamedRoot *EventDecl = ContainerIterator.GetNext();
        EventDecl != NULL;
        EventDecl = ContainerIterator.GetNext())
    {
        // Was the event decl we just found shadowed out by somebody on a nearer base class/interface?
        //
        if (IsMemberShadowed(EventDecl, ShadowingMembers))
            continue;

        bool IsMemberAccessible =
            IsAccessible(
                EventDecl,
                TypePossiblyContainingEvents->IsGenericBinding() ?
                    TypePossiblyContainingEvents->PGenericBinding() :
                    NULL,
                CurrentContainer(),
                TypeOfWithEventsVar);

        // Keep track of who is shadowing in this container - we'll need the info if the event we find is on a derived container
        if (IsMemberAccessible && EventDecl->IsShadowing())
        {
            ShadowingMembers->Add(EventDecl);
        }

        if (ConsiderEventSourcePropertiesToo &&
            EventDecl->IsProperty() &&
            ValidEventSourceProperty(EventDecl->PProperty()))
        {
            IsMemberAccessible =
                IsMemberAccessible &&
                IsAccessible(
                    EventDecl->PProperty()->GetProperty(),
                    TypePossiblyContainingEvents->IsGenericBinding() ?
                        TypePossiblyContainingEvents->PGenericBinding() :
                        NULL,
                    CurrentContainer(),
                    TypeOfWithEventsVar);

            BCSYM *PropertyReturnType = EventDecl->PProperty()->GetType();

            // 


            // We only care about properties returning classes or interfaces
            // because only classes and interfaces can be specified in a
            // handles clause.
            //

            VSASSERT(IsClassOrInterface(PropertyReturnType),
                        "Invalid event source property found. Should have been disallowed earlier!!!");

            // We've come across a Property that returns an Event source.  Dig through it.
            //
            if (CheckForAccessibleEvents(
                    PropertyReturnType,                // Property return type
                    false,                             // i.e. don't consider EventSource properties, because
                                                       //    we only allow at most 3 names i.e. x.y.z in the
                                                       //    handles clause and and only y is allowed to be the
                                                       //    referring event source property.
                    AnyEventDefined))
            {
                // there are events on this WithEvents variable - and they are accessible
            }
            else
            {
                continue;
            }
        }
        else if (EventDecl->IsEventDecl())
        {
            // there are events on this WithEvents variable - whether they are accessible is another matter
            //
            AnyEventDefined = true;
        }
        else
        {
            // Screen out everthing that isn't an Event declaration or possible Event Source
            //
            continue;
        }

        // This assert will guard against any bad changes to the conditions checks above
        VSASSERT( AnyEventDefined,
                        "How can we get here when we have not found any event or event source ?");

        // Determine if the event is accessible
        // It must be visible to the WithEvents container that references the event
        //
        if (IsMemberAccessible)
        {
            return true;
        }

    } // trawl container members looking for events/properties that may return events


    // Look recursively in bases too
    BasesIter Bases(TypePossiblyContainingEvents->PContainer());

    BCSYM_GenericTypeBinding *BaseGenericBinding;
    while (BCSYM_Container *Base = Bases.GetNextBase(&BaseGenericBinding))
    {
        if (Base->IsBad()) continue;

        if (CheckForAccessibleEventsWorker(
                BaseGenericBinding ?
                    (BCSYM *)BaseGenericBinding :
                    Base,
                TypeOfWithEventsVar,
                ShadowingMembers,
                false,  // Don't consider event source properties in based as available
                        // because we don't allow binding to them in the handles clause
                        // (for no other better reason than leaving this implementation
                        //  as it was without complicating things, since this is not a
                        //  user feature anyway.)
                AnyEventDefined))
        {
            return true;
        }
    }

    return false; // no visible events found
}