Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / clr / src / BCL / System / ArgIterator.cs / 1 / ArgIterator.cs
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
namespace System {
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
// This class will not be marked serializable
[StructLayout(LayoutKind.Auto)]
public struct ArgIterator
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern ArgIterator(IntPtr arglist);
// create an arg iterator that points at the first argument that
// is not statically declared (that is the first ... arg)
// 'arglist' is the value returned by the ARGLIST instruction
public ArgIterator(RuntimeArgumentHandle arglist) : this(arglist.Value)
{
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private unsafe extern ArgIterator(IntPtr arglist, void *ptr);
// create an arg iterator that points just past 'firstArg'.
// 'arglist' is the value returned by the ARGLIST instruction
// This is much like the C va_start macro
[CLSCompliant(false)]
public unsafe ArgIterator(RuntimeArgumentHandle arglist, void* ptr) : this(arglist.Value, ptr)
{
}
// Fetch an argument as a typed referece, advance the iterator.
// Throws an exception if past end of argument list
[CLSCompliant(false)]
public TypedReference GetNextArg()
{
TypedReference result = new TypedReference ();
// reference to TypedReference is banned, so have to pass result as pointer
unsafe
{
FCallGetNextArg (&result);
}
return result;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
// reference to TypedReference is banned, so have to pass result as void pointer
private unsafe extern void FCallGetNextArg(void * result);
// Alternate version of GetNextArg() intended primarily for IJW code
// generated by VC's "va_arg()" construct.
[CLSCompliant(false)]
public TypedReference GetNextArg(RuntimeTypeHandle rth)
{
if (sigPtr != IntPtr.Zero)
{
// This is an ordinary ArgIterator capable of determining
// types from a signature. Just do a regular GetNextArg.
return GetNextArg();
}
else
{
// Prevent abuse of this API with a default ArgIterator (it
// doesn't require permission to create a zero-inited value
// type). Check that ArgPtr isn't zero or this API will allow a
// malicious caller to increment the pointer to an arbitrary
// location in memory and read the contents.
if (ArgPtr == IntPtr.Zero)
throw new ArgumentNullException();
TypedReference result = new TypedReference ();
// reference to TypedReference is banned, so have to pass result as pointer
unsafe
{
InternalGetNextArg(&result, rth);
}
return result;
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
// reference to TypedReference is banned, so have to pass result as void pointer
private unsafe extern void InternalGetNextArg(void * result, RuntimeTypeHandle rth);
// This method should invalidate the iterator (va_end). It is not supported yet.
public void End()
{
}
// How many arguments are left in the list
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int GetRemainingCount();
// Gets the type of the current arg, does NOT advance the iterator
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern unsafe void* _GetNextArgType();
public unsafe RuntimeTypeHandle GetNextArgType()
{
return new RuntimeTypeHandle(_GetNextArgType());
}
public override int GetHashCode()
{
return unchecked((int)((long)ArgCookie));
}
// Inherited from object
public override bool Equals(Object o)
{
throw new NotSupportedException(Environment.GetResourceString("NotSupported_NYI"));
}
private IntPtr ArgCookie; // Cookie from the EE.
// The SigPtr structure consists of the following members
private IntPtr sigPtr; // Pointer to remaining signature.
private IntPtr sigPtrLen; // Remaining length of the pointer
// Note, sigPtrLen is actually a DWORD, but on 64bit systems this structure becomes
// 8-byte aligned, which requires us to pad it.
private IntPtr ArgPtr; // Pointer to remaining args.
private int RemainingArgs; // # of remaining args.
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// ==++==
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// ==--==
namespace System {
using System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
// This class will not be marked serializable
[StructLayout(LayoutKind.Auto)]
public struct ArgIterator
{
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern ArgIterator(IntPtr arglist);
// create an arg iterator that points at the first argument that
// is not statically declared (that is the first ... arg)
// 'arglist' is the value returned by the ARGLIST instruction
public ArgIterator(RuntimeArgumentHandle arglist) : this(arglist.Value)
{
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private unsafe extern ArgIterator(IntPtr arglist, void *ptr);
// create an arg iterator that points just past 'firstArg'.
// 'arglist' is the value returned by the ARGLIST instruction
// This is much like the C va_start macro
[CLSCompliant(false)]
public unsafe ArgIterator(RuntimeArgumentHandle arglist, void* ptr) : this(arglist.Value, ptr)
{
}
// Fetch an argument as a typed referece, advance the iterator.
// Throws an exception if past end of argument list
[CLSCompliant(false)]
public TypedReference GetNextArg()
{
TypedReference result = new TypedReference ();
// reference to TypedReference is banned, so have to pass result as pointer
unsafe
{
FCallGetNextArg (&result);
}
return result;
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
// reference to TypedReference is banned, so have to pass result as void pointer
private unsafe extern void FCallGetNextArg(void * result);
// Alternate version of GetNextArg() intended primarily for IJW code
// generated by VC's "va_arg()" construct.
[CLSCompliant(false)]
public TypedReference GetNextArg(RuntimeTypeHandle rth)
{
if (sigPtr != IntPtr.Zero)
{
// This is an ordinary ArgIterator capable of determining
// types from a signature. Just do a regular GetNextArg.
return GetNextArg();
}
else
{
// Prevent abuse of this API with a default ArgIterator (it
// doesn't require permission to create a zero-inited value
// type). Check that ArgPtr isn't zero or this API will allow a
// malicious caller to increment the pointer to an arbitrary
// location in memory and read the contents.
if (ArgPtr == IntPtr.Zero)
throw new ArgumentNullException();
TypedReference result = new TypedReference ();
// reference to TypedReference is banned, so have to pass result as pointer
unsafe
{
InternalGetNextArg(&result, rth);
}
return result;
}
}
[MethodImplAttribute(MethodImplOptions.InternalCall)]
// reference to TypedReference is banned, so have to pass result as void pointer
private unsafe extern void InternalGetNextArg(void * result, RuntimeTypeHandle rth);
// This method should invalidate the iterator (va_end). It is not supported yet.
public void End()
{
}
// How many arguments are left in the list
[MethodImplAttribute(MethodImplOptions.InternalCall)]
public extern int GetRemainingCount();
// Gets the type of the current arg, does NOT advance the iterator
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern unsafe void* _GetNextArgType();
public unsafe RuntimeTypeHandle GetNextArgType()
{
return new RuntimeTypeHandle(_GetNextArgType());
}
public override int GetHashCode()
{
return unchecked((int)((long)ArgCookie));
}
// Inherited from object
public override bool Equals(Object o)
{
throw new NotSupportedException(Environment.GetResourceString("NotSupported_NYI"));
}
private IntPtr ArgCookie; // Cookie from the EE.
// The SigPtr structure consists of the following members
private IntPtr sigPtr; // Pointer to remaining signature.
private IntPtr sigPtrLen; // Remaining length of the pointer
// Note, sigPtrLen is actually a DWORD, but on 64bit systems this structure becomes
// 8-byte aligned, which requires us to pad it.
private IntPtr ArgPtr; // Pointer to remaining args.
private int RemainingArgs; // # of remaining args.
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DbConnectionPoolIdentity.cs
- OracleBoolean.cs
- CompilerGlobalScopeAttribute.cs
- NavigationWindow.cs
- RankException.cs
- BaseValidator.cs
- CompiledELinqQueryState.cs
- RowsCopiedEventArgs.cs
- PointHitTestResult.cs
- ProxySimple.cs
- CorrelationToken.cs
- ConstrainedDataObject.cs
- WebPartConnectionsCloseVerb.cs
- BrushMappingModeValidation.cs
- ContainerUtilities.cs
- ProxyAttribute.cs
- SAPIEngineTypes.cs
- WorkflowInstanceProxy.cs
- XmlSchemaType.cs
- Screen.cs
- DataAdapter.cs
- StateWorkerRequest.cs
- EntityDesignerBuildProvider.cs
- TopClause.cs
- OracleColumn.cs
- UpDownBase.cs
- GlyphCache.cs
- Interlocked.cs
- DrawTreeNodeEventArgs.cs
- ImageIndexConverter.cs
- ListContractAdapter.cs
- ViewGenerator.cs
- FixedTextView.cs
- HttpCachePolicy.cs
- IsolatedStorage.cs
- OdbcConnectionOpen.cs
- CatalogZoneBase.cs
- SapiRecoInterop.cs
- DataGridViewDataConnection.cs
- ElementNotEnabledException.cs
- PropertyMapper.cs
- CodeGroup.cs
- HuffCodec.cs
- AttributeUsageAttribute.cs
- SoapInteropTypes.cs
- METAHEADER.cs
- TabControl.cs
- XmlSortKey.cs
- NamedPipeConnectionPool.cs
- DiagnosticsConfigurationHandler.cs
- VirtualDirectoryMapping.cs
- PersonalizableAttribute.cs
- XmlSchemaCompilationSettings.cs
- SystemIcmpV6Statistics.cs
- Translator.cs
- SemaphoreSecurity.cs
- RegexStringValidator.cs
- WeakHashtable.cs
- CellQuery.cs
- DropDownButton.cs
- UTF7Encoding.cs
- UIElementParaClient.cs
- ICollection.cs
- InheritanceRules.cs
- LoadRetryConstantStrategy.cs
- PropertyIDSet.cs
- BinaryKeyIdentifierClause.cs
- StylusPointDescription.cs
- GlobalEventManager.cs
- Missing.cs
- ColumnResizeUndoUnit.cs
- SiteMapPath.cs
- OleDbPropertySetGuid.cs
- XmlFormatExtensionPointAttribute.cs
- ReaderWriterLock.cs
- RoleServiceManager.cs
- IHttpResponseInternal.cs
- SystemInformation.cs
- CodeMemberProperty.cs
- RemoteEndpointMessageProperty.cs
- DetailsViewRowCollection.cs
- StringKeyFrameCollection.cs
- UnsafeNativeMethodsCLR.cs
- BinaryWriter.cs
- ManualResetEvent.cs
- ElementMarkupObject.cs
- Annotation.cs
- MetadataUtil.cs
- Vector3DAnimationUsingKeyFrames.cs
- PaperSize.cs
- BoolLiteral.cs
- WindowsFormsEditorServiceHelper.cs
- GlyphRunDrawing.cs
- DbUpdateCommandTree.cs
- QueryOutputWriter.cs
- XmlnsDefinitionAttribute.cs
- IdentityManager.cs
- HMACMD5.cs
- ExpanderAutomationPeer.cs
- ToolStripAdornerWindowService.cs