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); }
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); }
public void Add(uint key, AETEValue value) { if (parameters.ContainsKey(key)) { parameters[key] = value; } else { parameters.Add(key, value); keys.Add(key); } }
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); }
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); }
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); }
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); }
private int GetType(IntPtr descriptor, uint key, ref uint type) { #if DEBUG DebugUtils.Ping(DebugFlags.DescriptorParameters, string.Format("key: 0x{0:X4}({1})", key, DebugUtils.PropToString(key))); #endif AETEValue item = null; if (actionDescriptors[descriptor].TryGetValue(key, out item)) { // If the value is a sub-descriptor it must be retrieved with GetObject. if (item.Value is ScriptingParameters) { type = DescriptorTypes.Object; } else { type = item.Type; } return(PSError.kSPNoError); } return(PSError.errMissingParameter); }
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); }
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); }
public bool TryGetValue(uint key, out AETEValue value) { return(parameters.TryGetValue(key, out value)); }