本文整理汇总了C#中TypeQualifiers类的典型用法代码示例。如果您正苦于以下问题:C# TypeQualifiers类的具体用法?C# TypeQualifiers怎么用?C# TypeQualifiers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeQualifiers类属于命名空间,在下文中一共展示了TypeQualifiers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitArrayType
public override bool VisitArrayType(ArrayType array, TypeQualifiers quals)
{
TypeMap typeMap;
if (TypeMapDatabase.FindTypeMap(array, out typeMap) && typeMap.IsIgnored)
{
Ignore();
return false;
}
if (array.SizeType != ArrayType.ArraySize.Constant)
return true;
var arrayElemType = array.Type.Desugar();
Class @class;
if (arrayElemType.TryGetClass(out @class) && @class.IsRefType)
return true;
PrimitiveType primitive;
if ((arrayElemType.IsPrimitiveType(out primitive) && primitive != PrimitiveType.LongDouble) ||
arrayElemType.IsPointerToPrimitiveType())
return true;
Ignore();
return false;
}
示例2: VisitPrimitiveType
public override bool VisitPrimitiveType(PrimitiveType type, TypeQualifiers quals)
{
// we do not support long double yet because its high-level representation is often problematic
if (type == PrimitiveType.LongDouble)
{
Ignore();
return false;
}
return base.VisitPrimitiveType(type, quals);
}
示例3: VisitTypedefType
public override bool VisitTypedefType(TypedefType typedef,
TypeQualifiers quals)
{
TypeMap typeMap;
if (TypeMapDatabase.FindTypeMap(typedef, out typeMap)
&& typeMap.IsIgnored)
{
Ignore();
return false;
}
return base.VisitTypedefType(typedef, quals);
}
示例4: VisitTemplateSpecializationType
public override bool VisitTemplateSpecializationType(TemplateSpecializationType template, TypeQualifiers quals)
{
if (AlreadyVisited(template) || template.Template.Access == AccessSpecifier.Private)
return false;
if (template.Arguments.Select(a => a.Type.Type.Desugar()).All(t => t.IsAddress() && !t.GetFinalPointee().IsDependent))
{
var cppTypePrinter = new CppTypePrinter { PrintScopeKind = CppTypePrintScopeKind.Qualified };
templateInstantiations.Add(string.Format("{0}<{1}>", template.Template.Name,
string.Join(", ", template.Arguments.Select(a => a.Type.Type.Visit(cppTypePrinter)))));
}
return true;
}
示例5: VisitArrayType
public override bool VisitArrayType(ArrayType array, TypeQualifiers quals)
{
if (!VisitType(array, quals))
return false;
switch (array.SizeType)
{
case ArrayType.ArraySize.Constant:
var supportBefore = Context.SupportBefore;
supportBefore.WriteLine("if ({0} != nullptr)", Context.ArgName);
supportBefore.WriteStartBraceIndent();
supportBefore.WriteLine("for (int i = 0; i < {0}; i++)", array.Size);
supportBefore.WriteLineIndent("{0}[i] = {1}[i]{2};",
Context.ReturnVarName, Context.ArgName,
array.Type.IsPointerToPrimitiveType(PrimitiveType.Void) ? ".ToPointer()" : string.Empty);
supportBefore.WriteCloseBraceIndent();
break;
default:
Context.Return.Write("null");
break;
}
return true;
}
示例6: TypeQualifiers
private TypeQualifiers(TypeQualifiers.Internal native)
: this(__CopyValue(native))
{
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
}
示例7: __CreateInstance
public static TypeQualifiers __CreateInstance(TypeQualifiers.Internal native)
{
return new TypeQualifiers(native);
}
示例8: TypeQualifiers
private TypeQualifiers(TypeQualifiers.Internal native, bool skipVTables = false)
: this(__CopyValue(native), skipVTables)
{
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
}
示例9: __CopyValue
private static void* __CopyValue(TypeQualifiers.__Internal native)
{
var ret = Marshal.AllocHGlobal(3);
*(TypeQualifiers.__Internal*) ret = native;
return ret.ToPointer();
}
示例10: TypeQualifiers
internal TypeQualifiers(TypeQualifiers.Internal* native)
: this(new global::System.IntPtr(native))
{
}
示例11: TypeQualifiers
internal TypeQualifiers(TypeQualifiers.Internal native)
: this(__CopyValue(native))
{
}
示例12: VisitArrayType
public override bool VisitArrayType(ArrayType array, TypeQualifiers quals)
{
if (!VisitType(array, quals))
return false;
Class @class;
switch (array.SizeType)
{
case ArrayType.ArraySize.Constant:
var supportBefore = Context.SupportBefore;
string value = Generator.GeneratedIdentifier("value");
supportBefore.WriteLine("{0}[] {1} = null;", array.Type, value, array.Size);
supportBefore.WriteLine("if ({0} != null)", Context.ReturnVarName);
supportBefore.WriteStartBraceIndent();
supportBefore.WriteLine("{0} = new {1}[{2}];", value, array.Type, array.Size);
supportBefore.WriteLine("for (int i = 0; i < {0}; i++)", array.Size);
if (array.Type.IsPointerToPrimitiveType(PrimitiveType.Void))
supportBefore.WriteLineIndent("{0}[i] = new global::System.IntPtr({1}[i]);",
value, Context.ReturnVarName);
else if (array.Type.Desugar().TryGetClass(out @class) && @class.IsRefType)
supportBefore.WriteLineIndent("{0}[i] = {1}.{2}(*(({1}.Internal*)&({3}[i * sizeof({1}.Internal)])));",
value, array.Type, Helpers.CreateInstanceIdentifier, Context.ReturnVarName);
else
supportBefore.WriteLineIndent("{0}[i] = {1}[i];", value, Context.ReturnVarName);
supportBefore.WriteCloseBraceIndent();
Context.Return.Write(value);
break;
case ArrayType.ArraySize.Variable:
Context.Return.Write("null");
break;
}
return true;
}
示例13: VisitTypedefType
public override bool VisitTypedefType(TypedefType typedef, TypeQualifiers quals)
{
if (!VisitType(typedef, quals))
return false;
var decl = typedef.Declaration;
FunctionType func;
if (decl.Type.IsPointerTo<FunctionType>(out func))
{
VisitDelegateType(func, typedef.Declaration.OriginalName);
return true;
}
return decl.Type.Visit(this);
}
示例14: VisitTemplateParameterType
public override bool VisitTemplateParameterType(TemplateParameterType param, TypeQualifiers quals)
{
Context.Return.Write(param.Parameter.Name);
return true;
}
示例15: VisitPointerType
public override bool VisitPointerType(PointerType pointer, TypeQualifiers quals)
{
if (!VisitType(pointer, quals))
return false;
var param = Context.Parameter;
var isRefParam = param != null && (param.IsInOut || param.IsOut);
var pointee = pointer.Pointee.Desugar();
bool marshalPointeeAsString = CSharpTypePrinter.IsConstCharString(pointee) && isRefParam;
if (CSharpTypePrinter.IsConstCharString(pointer) || marshalPointeeAsString)
{
if (param.IsOut)
{
Context.Return.Write("IntPtr.Zero");
CSharpContext.ArgumentPrefix.Write("&");
}
else if (param.IsInOut)
{
Context.Return.Write(MarshalStringToUnmanaged(Context.Parameter.Name));
CSharpContext.ArgumentPrefix.Write("&");
}
else
{
Context.Return.Write(MarshalStringToUnmanaged(Context.Parameter.Name));
CSharpContext.Cleanup.WriteLine("Marshal.FreeHGlobal({0});", Context.ArgName);
}
return true;
}
if (pointee is FunctionType)
{
var function = pointee as FunctionType;
return VisitDelegateType(function, function.ToString());
}
Class @class;
if (pointee.TryGetClass(out @class) && @class.IsValueType)
{
if (Context.Parameter.Usage == ParameterUsage.Out)
{
Context.SupportBefore.WriteLine("var {0} = new {1}.Internal();",
Generator.GeneratedIdentifier(Context.ArgName), @class.Name);
}
else
{
Context.SupportBefore.WriteLine("var {0} = {1}.{2};",
Generator.GeneratedIdentifier(Context.ArgName),
Context.Parameter.Name,
Helpers.InstanceIdentifier);
}
Context.Return.Write("new global::System.IntPtr(&{0})",
Generator.GeneratedIdentifier(Context.ArgName));
return true;
}
var finalPointee = pointer.GetFinalPointee();
PrimitiveType primitive;
if (finalPointee.IsPrimitiveType(out primitive) || finalPointee.IsEnumType())
{
// From MSDN: "note that a ref or out parameter is classified as a moveable
// variable". This means we must create a local variable to hold the result
// and then assign this value to the parameter.
if (isRefParam)
{
var typeName = Type.TypePrinterDelegate(finalPointee);
if (param.IsInOut)
Context.SupportBefore.WriteLine("{0} _{1} = {1};", typeName, param.Name);
else
Context.SupportBefore.WriteLine("{0} _{1};", typeName, param.Name);
Context.Return.Write("&_{0}", param.Name);
}
else
Context.Return.Write(Context.Parameter.Name);
return true;
}
return pointer.Pointee.Visit(this, quals);
}