Ejemplo n.º 1
0
        private bool GetKeyProc(IntPtr descriptor, ref uint key, ref uint type, ref int flags)
        {
#if DEBUG
            DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Empty);
#endif

            if (descriptor != IntPtr.Zero)
            {
                ReadDescriptorState state = readDescriptors[descriptor];

                if (state.keyIndex >= state.keyCount)
                {
                    return(false);
                }

                state.currentKey = key = state.keys[state.keyIndex];
                state.keyIndex++;

                // When a plug-in expects specific keys to be returned this method is documented
                // to set each key it finds to the null descriptor type before returning it to the plug-in.
                // The plug-in can use this information to determine if any required keys are missing.
                if (state.expectedKeys != IntPtr.Zero)
                {
                    int offset;
                    if (state.expectedKeyOffsets.TryGetValue(key, out offset))
                    {
                        Marshal.WriteInt32(state.expectedKeys, offset, unchecked ((int)DescriptorTypes.Null));
                    }
                }

                AETEValue item = state.items[key];
                try
                {
                    // If the value is a sub-descriptor it must be retrieved with GetObjectProc.
                    if (item.Value is Dictionary <uint, AETEValue> )
                    {
                        type = DescriptorTypes.Object;
                    }
                    else
                    {
                        type = item.Type;
                    }
                }
                catch (NullReferenceException)
                {
                }

                try
                {
                    flags = item.Flags;
                }
                catch (NullReferenceException)
                {
                }

                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        private short GetPinnedFloatProc(IntPtr descriptor, ref double min, ref double max, ref double floatNumber)
        {
            ReadDescriptorState state = readDescriptors[descriptor];

#if DEBUG
            DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: 0x{0:X4}", state.currentKey));
#endif
            short descErr = PSError.noErr;

            AETEValue item = state.items[state.currentKey];

            double amount = (double)item.Value;
            if (amount < min)
            {
                amount              = min;
                descErr             = PSError.coercedParamErr;
                state.lastReadError = descErr;
            }
            else if (amount > max)
            {
                amount              = max;
                descErr             = PSError.coercedParamErr;
                state.lastReadError = descErr;
            }
            floatNumber = amount;

            return(descErr);
        }
Ejemplo n.º 3
0
        private short GetCountProc(IntPtr descriptor, ref uint count)
        {
            ReadDescriptorState state = readDescriptors[descriptor];

#if DEBUG
            DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: 0x{0:X4}", state.currentKey));
#endif

            count = (uint)state.items.Count;

            return(PSError.noErr);
        }
Ejemplo n.º 4
0
        private short GetSimpleReferenceProc(IntPtr descriptor, ref PIDescriptorSimpleReference data)
        {
            ReadDescriptorState state = readDescriptors[descriptor];

#if DEBUG
            DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: 0x{0:X4}", state.currentKey));
#endif
            AETEValue item = state.items[state.currentKey];

            data = (PIDescriptorSimpleReference)item.Value;

            return(PSError.noErr);
        }
Ejemplo n.º 5
0
        private short GetClassProc(IntPtr descriptor, ref uint type)
        {
            ReadDescriptorState state = readDescriptors[descriptor];

#if DEBUG
            DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: 0x{0:X4}", state.currentKey));
#endif
            AETEValue item = state.items[state.currentKey];

            type = (uint)item.Value;

            return(PSError.noErr);
        }
Ejemplo n.º 6
0
        private short GetStringProc(IntPtr descriptor, IntPtr data)
        {
            ReadDescriptorState state = readDescriptors[descriptor];

#if DEBUG
            DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: 0x{0:X4}", state.currentKey));
#endif
            AETEValue item = state.items[state.currentKey];

            int size = item.Size;

            Marshal.WriteByte(data, (byte)size);

            Marshal.Copy((byte[])item.Value, 0, new IntPtr(data.ToInt64() + 1L), size);
            return(PSError.noErr);
        }
Ejemplo n.º 7
0
        private short GetObjectProc(IntPtr descriptor, ref uint retType, ref IntPtr descriptorHandle)
        {
            ReadDescriptorState state = readDescriptors[descriptor];

#if DEBUG
            DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: 0x{0:X4}", state.currentKey));
#endif
            AETEValue item = state.items[state.currentKey];

            uint type = item.Type;

            try
            {
                retType = type;
            }
            catch (NullReferenceException)
            {
                // ignore it
            }

            Dictionary <uint, AETEValue> value = item.Value as Dictionary <uint, AETEValue>;
            if (value != null)
            {
                descriptorHandle = HandleSuite.Instance.NewHandle(0);                 // assign a zero byte handle to allow it to work correctly in the OpenReadDescriptorProc().
                if (descriptorHandle == IntPtr.Zero)
                {
                    state.lastReadError = PSError.memFullErr;
                    return(PSError.memFullErr);
                }
                descriptorHandles.Add(descriptorHandle, value);
            }
            else
            {
                state.lastReadError = PSError.paramErr;
                return(PSError.paramErr);
            }

            return(PSError.noErr);
        }
Ejemplo n.º 8
0
        private short GetAliasProc(IntPtr descriptor, ref IntPtr data)
        {
            ReadDescriptorState state = readDescriptors[descriptor];

#if DEBUG
            DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: 0x{0:X4}", state.currentKey));
#endif
            AETEValue item = state.items[state.currentKey];

            int size = item.Size;
            data = HandleSuite.Instance.NewHandle(size);

            if (data == IntPtr.Zero)
            {
                state.lastReadError = PSError.memFullErr;
                return(PSError.memFullErr);
            }

            Marshal.Copy((byte[])item.Value, 0, HandleSuite.Instance.LockHandle(data, 0), size);
            HandleSuite.Instance.UnlockHandle(data);

            return(PSError.noErr);
        }
Ejemplo n.º 9
0
        private short GetUnitFloatProc(IntPtr descriptor, ref uint unit, ref double data)
        {
            ReadDescriptorState state = readDescriptors[descriptor];

#if DEBUG
            DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: 0x{0:X4}", state.currentKey));
#endif
            AETEValue item = state.items[state.currentKey];

            UnitFloat unitFloat = (UnitFloat)item.Value;

            try
            {
                unit = unitFloat.Unit;
            }
            catch (NullReferenceException)
            {
            }

            data = unitFloat.Value;

            return(PSError.noErr);
        }