Ejemplo n.º 1
0
        public SFCommand GetCommandData(IntPtr pqueue)
        {
            SFCommand command = new SFCommand();
            // Marshal.PtrToStructure(pqueue, command); // Works on Windows, unsupported on iOS due to aot compilation.
            IntPtr ptr = new IntPtr(pqueue.ToInt32()); // Workaround for iOS.

            command.MovieID     = Marshal.ReadInt64(ptr);
            ptr                 = new IntPtr(ptr.ToInt32() + Marshal.SizeOf(typeof(long)));
            command.ArgCount    = Marshal.ReadInt32(ptr);
            ptr                 = new IntPtr(ptr.ToInt32() + Marshal.SizeOf(typeof(int)));
            command.pMethodName = Marshal.ReadIntPtr(ptr);
            return(command);
        }
Ejemplo n.º 2
0
        // Delegates don't work in an iOS environment. In order to get around this limitation, we put
        // ExternalInterface notifications in a queue which is preallocated in the constructor of SFManager.
        public void ProcessCommands()
        {
            // Deal with AS Traces:
            HandleASTraces();

            int numCommands = Marshal.ReadInt32(pCommandOffset);

            if (numCommands == 0)
            {
                return;
            }

            int    commandSize = Marshal.SizeOf(typeof(SFCommand));
            int    sfValueSize = Marshal.SizeOf(typeof(Value));
            IntPtr pqueue      = new IntPtr(pCommandQueue.ToInt32());
            IntPtr pargs       = new IntPtr(pValueQueue.ToInt32());

            int cumNumArgs = 0;

            for (int i = 0; i < numCommands; i++)
            {
                pqueue = new IntPtr(pCommandQueue.ToInt32() + commandSize * i);
                SFCommand command = GetCommandData(pqueue);
                int       numArgs = command.ArgCount;
                long      MovieID = command.MovieID;

                String methodName = Marshal.PtrToStringAnsi(command.pMethodName);
                OnExternalInterface(MovieID, methodName, pargs, numArgs, sfValueSize);

                cumNumArgs += numArgs;
                pargs       = new IntPtr(pValueQueue.ToInt32() + sfValueSize * cumNumArgs);
            }

            SF_ClearCommandBuffer(numCommands);
            Marshal.WriteInt32(pCommandOffset, 0);
            Marshal.WriteInt32(pValueOffset, 0);
        }
Ejemplo n.º 3
0
 public SFCommand GetCommandData(IntPtr pqueue)
 {    
     SFCommand command = new SFCommand();
     // Marshal.PtrToStructure(pqueue, command); // Works on Windows, unsupported on iOS due to aot compilation.
     IntPtr  ptr = new IntPtr(pqueue.ToInt32()); // Workaround for iOS.
     command.MovieID = Marshal.ReadInt64(ptr);
     ptr = new IntPtr(ptr.ToInt32() + Marshal.SizeOf(typeof(long)));
     command.ArgCount = Marshal.ReadInt32(ptr);  
     ptr = new IntPtr(ptr.ToInt32() + Marshal.SizeOf(typeof(int)));
     command.pMethodName = Marshal.ReadIntPtr(ptr);
     return command;
 }