Ejemplo n.º 1
0
        public void Initialise(MHParseNode p, MHEngine engine)
        {
            switch (p.GetTagNo())
            {
            case ASN1Codes.C_NEW_GENERIC_BOOLEAN: m_Type = P_Bool; m_BoolVal.Initialise(p.GetArgN(0), engine); break;

            case ASN1Codes.C_NEW_GENERIC_INTEGER: m_Type = P_Int; m_IntVal.Initialise(p.GetArgN(0), engine); break;

            case ASN1Codes.C_NEW_GENERIC_OCTETSTRING: m_Type = P_String; m_StrVal.Initialise(p.GetArgN(0), engine); break;

            case ASN1Codes.C_NEW_GENERIC_OBJECT_REF: m_Type = P_ObjRef; m_ObjRefVal.Initialise(p.GetArgN(0), engine); break;

            case ASN1Codes.C_NEW_GENERIC_CONTENT_REF: m_Type = P_ContentRef; m_ContentRefVal.Initialise(p.GetArgN(0), engine); break;

            default: p.Failure("Expected generic"); break;
            }
        }
Ejemplo n.º 2
0
 public void Initialise(MHParseNode p, MHEngine engine)
 {
     if (p.NodeType == MHParseNode.PNInt)
     {
         m_nObjectNo = p.GetIntValue();
         // Set the group id to the id of this group.
         m_GroupId.Copy(engine.GetGroupId());
     }
     else if (p.NodeType == MHParseNode.PNSeq)
     {
         MHParseNode   pFirst  = p.GetSeqN(0);
         MHOctetString groupId = new MHOctetString();
         pFirst.GetStringValue(m_GroupId);
         m_nObjectNo = p.GetSeqN(1).GetIntValue();
     }
     else
     {
         p.Failure("ObjectRef: Argument is not int or sequence");
     }
 }
Ejemplo n.º 3
0
        protected MHGroup ParseProgram(byte[] text)
        {
            if (text.Length == 0)
            {
                return(null);
            }

            IMHParser   parser = null;
            MHParseNode pTree  = null;
            MHGroup     pRes   = null;

            // Look at the first byte to decide whether this is text or binary.  Binary
            // files will begin with 0xA0 or 0xA1, text files with white space, comment ('/')
            // or curly bracket.
            // This is only there for testing: all downloaded objects will be in ASN1
            byte ch = text[0];

            if (ch >= 128)
            {
                parser = new MHParseBinary(text);
            }
            else
            {
                parser = new MHParseText(text);
            }

            // Parse the binary or text.
            pTree = parser.Parse();

            switch (pTree.GetTagNo())
            { // The parse node should be a tagged item.
            case ASN1Codes.C_APPLICATION: pRes = new MHApplication(); break;

            case ASN1Codes.C_SCENE: pRes = new MHScene(); break;

            default: pTree.Failure("Expected Application or Scene"); break; // throws exception.
            }
            pRes.Initialise(pTree, this);                                   // Convert the parse tree.

            return(pRes);
        }
Ejemplo n.º 4
0
        public override void Initialise(MHParseNode p, MHEngine engine)
        {
            base.Initialise(p, engine);
            // Original box size - two integer arguments.
            MHParseNode pOriginalBox = p.GetNamedArg(ASN1Codes.C_ORIGINAL_BOX_SIZE);
            if (pOriginalBox == null) p.Failure("OriginalBoxSize missing");
            m_nOriginalBoxWidth = pOriginalBox.GetArgN(0).GetIntValue();
            m_nOriginalBoxHeight = pOriginalBox.GetArgN(1).GetIntValue();

            // Original position - two integer arguments.  Optional
            MHParseNode pOriginalPos = p.GetNamedArg(ASN1Codes.C_ORIGINAL_POSITION);
            if (pOriginalPos != null) 
            {
                m_nOriginalPosX = pOriginalPos.GetArgN(0).GetIntValue();
                m_nOriginalPosY = pOriginalPos.GetArgN(1).GetIntValue();
            }

            // OriginalPalette ref - optional. 
            MHParseNode pOriginalPaletteRef = p.GetNamedArg(ASN1Codes.C_ORIGINAL_PALETTE_REF);
            if (pOriginalPaletteRef != null) m_OriginalPaletteRef.Initialise(pOriginalPaletteRef.GetArgN(0), engine);
        }
Ejemplo n.º 5
0
        // Set this up from the parse tree.
        public override void Initialise(MHParseNode p, MHEngine engine)
        {
            // Set to empty before we start (just in case).
            engine.GetGroupId().Copy("");

            base.Initialise(p, engine);

            // Must be an external reference with an object number of zero.
            Logging.Assert(m_ObjectIdentifier.ObjectNo == 0 && m_ObjectIdentifier.GroupId.Size != 0);

            // Set the group id for the rest of the group to this.
            engine.GetGroupId().Copy(m_ObjectIdentifier.GroupId);

            // Some of the information is irrelevant.
            //  MHParseNode pStdId = p.GetNamedArg(C_STANDARD_IDENTIFIER);
            //  MHParseNode pStdVersion = p.GetNamedArg(C_STANDARD_VERSION);
            //  MHParseNode pObjectInfo = p.GetNamedArg(C_OBJECT_INFORMATION);

            MHParseNode pOnStartUp = p.GetNamedArg(ASN1Codes.C_ON_START_UP);

            if (pOnStartUp != null)
            {
                m_StartUp.Initialise(pOnStartUp, engine);
            }
            MHParseNode pOnCloseDown = p.GetNamedArg(ASN1Codes.C_ON_CLOSE_DOWN);

            if (pOnCloseDown != null)
            {
                m_CloseDown.Initialise(pOnCloseDown, engine);
            }
            MHParseNode pOriginalGCPrio = p.GetNamedArg(ASN1Codes.C_ORIGINAL_GC_PRIORITY);

            if (pOriginalGCPrio != null)
            {
                m_nOrigGroupCachePriority = pOriginalGCPrio.GetArgN(0).GetIntValue();
            }

            // Ignore the other stuff at the moment.
            MHParseNode pItems = p.GetNamedArg(ASN1Codes.C_ITEMS);

            if (pItems == null)
            {
                p.Failure("Missing :Items block");
            }
            for (int i = 0; i < pItems.GetArgCount(); i++)
            {
                MHParseNode  pItem       = pItems.GetArgN(i);
                MHIngredient pIngredient = null;

                // Generate the particular kind of ingredient.
                switch (pItem.GetTagNo())
                {
                case ASN1Codes.C_RESIDENT_PROGRAM: pIngredient = new MHResidentProgram(); break;

//  NOT UK                  case ASN1Codes.C_REMOTE_PROGRAM: pIngredient = new MHRemoteProgram(); break;
//  NOT UK                  case ASN1Codes.C_INTERCHANGED_PROGRAM: pIngredient = new MHInterChgProgram(); break;
//  NOT UK                  case ASN1Codes.C_PALETTE: pIngredient = new MHPalette(); break;
//  NOT UK                  case ASN1Codes.C_FONT: pIngredient = new MHFont(); break;
//  NOT UK                  case ASN1Codes.C_CURSOR_SHAPE: pIngredient = new MHCursorShape(); break;
                case ASN1Codes.C_BOOLEAN_VARIABLE: pIngredient = new MHBooleanVar(); break;

                case ASN1Codes.C_INTEGER_VARIABLE: pIngredient = new MHIntegerVar(); break;

                case ASN1Codes.C_OCTET_STRING_VARIABLE: pIngredient = new MHOctetStrVar(); break;

                case ASN1Codes.C_OBJECT_REF_VARIABLE: pIngredient = new MHObjectRefVar(); break;

                case ASN1Codes.C_CONTENT_REF_VARIABLE: pIngredient = new MHContentRefVar(); break;

                case ASN1Codes.C_LINK: pIngredient = new MHLink(); break;

                case ASN1Codes.C_STREAM: pIngredient = new MHStream(); break;

                case ASN1Codes.C_BITMAP: pIngredient = new MHBitmap(); break;

                case ASN1Codes.C_LINE_ART: pIngredient = new MHLineArt(); break;

                case ASN1Codes.C_DYNAMIC_LINE_ART: pIngredient = new MHDynamicLineArt(); break;

                case ASN1Codes.C_RECTANGLE: pIngredient = new MHRectangle(); break;

// NOT UK                   case ASN1Codes.C_HOTSPOT: pIngredient = new MHHotSpot(); break;
// NOT UK                   case ASN1Codes.C_SWITCH_BUTTON: pIngredient = new MHSwitchButton(); break;
// NOT UK                   case ASN1Codes.C_PUSH_BUTTON: pIngredient = new MHPushButton(); break;
                case ASN1Codes.C_TEXT: pIngredient = new MHText(); break;

                case ASN1Codes.C_ENTRY_FIELD: pIngredient = new MHEntryField(); break;

                case ASN1Codes.C_HYPER_TEXT: pIngredient = new MHHyperText(); break;

                case ASN1Codes.C_SLIDER: pIngredient = new MHSlider(); break;

                case ASN1Codes.C_TOKEN_GROUP: pIngredient = new MHTokenGroup(); break;

                case ASN1Codes.C_LIST_GROUP: pIngredient = new MHListGroup(); break;

                default:
                    // So we find out about these when debugging.
                    Logging.Log(Logging.MHLogError, "'" + pItem.GetTagNo() + "' tag not in switch");
                    Logging.Assert(false);

                    // Future proofing: ignore any ingredients that we don't know about.
                    // Obviously these can only arise in the binary coding.
                    break;
                }
                if (pIngredient != null)
                {
                    // Initialise it from its argments.
                    pIngredient.Initialise(pItem, engine);
                    // Remember the highest numbered ingredient
                    if (pIngredient.ObjectIdentifier.ObjectNo > m_nLastId)
                    {
                        m_nLastId = pIngredient.ObjectIdentifier.ObjectNo;
                    }
                    // Add it to the ingedients of this group.
                    m_Items.Append(pIngredient);
                }
            }
        }
Ejemplo n.º 6
0
        // Set this up from the parse tree.
        public override void Initialise(MHParseNode p, MHEngine engine)
        {
            base.Initialise(p, engine);
            // The link condition is encoded differently in the binary and text representations.
            MHParseNode pLinkCond = p.GetNamedArg(ASN1Codes.C_LINK_CONDITION);

            if (pLinkCond != null)
            {                                                           // Only in binary.
                m_EventSource.Initialise(pLinkCond.GetArgN(0), engine); // Event source
                m_nEventType = pLinkCond.GetArgN(1).GetEnumValue();     // Event type
                // The event data is optional and type-dependent.
                if (pLinkCond.GetArgCount() >= 3)
                {
                    MHParseNode pEventData = pLinkCond.GetArgN(2);
                    switch (pEventData.NodeType)
                    {
                    case MHParseNode.PNBool: m_EventData.Bool = pEventData.GetBoolValue(); m_EventData.Type = MHUnion.U_Bool; break;

                    case MHParseNode.PNInt: m_EventData.Int = pEventData.GetIntValue(); m_EventData.Type = MHUnion.U_Int; break;

                    case MHParseNode.PNString: pEventData.GetStringValue(m_EventData.String); m_EventData.Type = MHUnion.U_String; break;

                    default: pEventData.Failure("Unknown type of event data"); break;
                    }
                }
            }
            else
            {                                                                       // Only in text.
                MHParseNode pEventSource = p.GetNamedArg(ASN1Codes.P_EVENT_SOURCE); // Event source
                if (pEventSource == null)
                {
                    p.Failure("Missing :EventSource");
                }
                m_EventSource.Initialise(pEventSource.GetArgN(0), engine);
                MHParseNode pEventType = p.GetNamedArg(ASN1Codes.P_EVENT_TYPE); // Event type
                if (pEventType == null)
                {
                    p.Failure("Missing :EventType");
                }
                m_nEventType = pEventType.GetArgN(0).GetEnumValue();
                MHParseNode pEventData = p.GetNamedArg(ASN1Codes.P_EVENT_DATA); // Event data - optional
                if (pEventData != null)
                {
                    MHParseNode pEventDataArg = pEventData.GetArgN(0);
                    switch (pEventDataArg.NodeType)
                    {
                    case MHParseNode.PNBool: m_EventData.Bool = pEventDataArg.GetBoolValue(); m_EventData.Type = MHUnion.U_Bool; break;

                    case MHParseNode.PNInt: m_EventData.Int = pEventDataArg.GetIntValue(); m_EventData.Type = MHUnion.U_Int; break;

                    case MHParseNode.PNString: pEventDataArg.GetStringValue(m_EventData.String); m_EventData.Type = MHUnion.U_String; break;

                    default: pEventDataArg.Failure("Unknown type of event data"); break;
                    }
                }
            }

            MHParseNode pLinkEffect = p.GetNamedArg(ASN1Codes.C_LINK_EFFECT);

            m_LinkEffect.Initialise(pLinkEffect, engine);
        }