本文整理汇总了C#中CppSharp.AST.Method类的典型用法代码示例。如果您正苦于以下问题:C# Method类的具体用法?C# Method怎么用?C# Method使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Method类属于CppSharp.AST命名空间,在下文中一共展示了Method类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VisitMethodDecl
public override bool VisitMethodDecl(Method method)
{
if (!base.VisitMethodDecl(method))
{
return false;
}
if (!method.IsConstructor && (method.Name.EndsWith("Event", StringComparison.Ordinal) || method.Name == "event") &&
method.Parameters.Count == 1)
{
var type = method.Parameters[0].Type;
type = type.GetFinalPointee() ?? type;
Class @class;
if (type.TryGetClass(out @class) && @class.Name.EndsWith("Event", StringComparison.Ordinal))
{
var name = char.ToUpperInvariant(method.Name[0]) + method.Name.Substring(1);
method.Name = "on" + name;
Method baseMethod;
if (!method.IsOverride ||
(baseMethod = ((Class) method.Namespace).GetBaseMethod(method, true, true)) == null ||
baseMethod.IsPure)
{
this.events.Add(method);
this.Context.Options.ExplicitlyPatchedVirtualFunctions.Add(method.QualifiedOriginalName);
}
}
}
return true;
}
示例2: CanOverride
static bool CanOverride(Method method, Method @override)
{
return method.OriginalName == @override.OriginalName &&
method.ReturnType == @override.ReturnType &&
method.Parameters.SequenceEqual(@override.Parameters,
new ParameterTypeComparer());
}
示例3: VisitMethodDecl
public override bool VisitMethodDecl(Method method)
{
if (!method.IsConstructor && (method.Name.EndsWith("Event") || method.Name == "event") &&
method.Parameters.Count == 1 && method.Parameters[0].Type.ToString().EndsWith("Event") &&
method.OriginalName != "widgetEvent")
{
Event @event = new Event();
if (method.Name.StartsWith("on"))
{
@event.Name = method.Name.Substring(2);
}
else
{
@event.Name = method.Name;
}
@event.OriginalDeclaration = method;
@event.Namespace = method.Namespace;
@event.Parameters.AddRange(method.Parameters);
method.Namespace.Events.Add(@event);
this.events.Add(@event);
if (!method.Name.StartsWith("on"))
method.Name = "on" + char.ToUpperInvariant(method.Name[0]) + method.Name.Substring(1);
}
return base.VisitMethodDecl(method);
}
示例4: CheckNonVirtualInheritedFunctions
public void CheckNonVirtualInheritedFunctions(Class @class, Class originalClass = null)
{
if (originalClass == null)
originalClass = @class;
foreach (BaseClassSpecifier baseSpecifier in @class.Bases)
{
var @base = baseSpecifier.Class;
if (@base.IsInterface) continue;
var nonVirtualOffset = ComputeNonVirtualBaseClassOffset(originalClass, @base);
if (nonVirtualOffset == 0)
continue;
foreach (var method in @base.Methods.Where(method =>
!method.IsVirtual && (method.Kind == CXXMethodKind.Normal)))
{
Console.WriteLine(method);
var adjustedMethod = new Method(method)
{
SynthKind = FunctionSynthKind.AdjustedMethod,
AdjustedOffset = nonVirtualOffset,
};
originalClass.Methods.Add(adjustedMethod);
}
CheckNonVirtualInheritedFunctions(@base, originalClass);
}
}
示例5: GenerateToString
void GenerateToString(Class @class, Block block, Method method)
{
needsStreamInclude = true;
block.WriteLine("std::ostringstream os;");
block.WriteLine("os << *NativePtr;");
block.Write("return clix::marshalString<clix::E_UTF8>(os.str());");
}
示例6: CanOverride
public static bool CanOverride(this Method @override, Method method)
{
return (method.OriginalName == @override.OriginalName &&
method.ReturnType == @override.ReturnType &&
method.Parameters.SequenceEqual(@override.Parameters, ParameterTypeComparer.Instance)) ||
(@override.IsDestructor && method.IsDestructor && method.IsVirtual);
}
示例7: VisitMethodDecl
public override bool VisitMethodDecl(Method method)
{
if (!method.IsConstructor && !method.IsDestructor && !method.IsOperator &&
!method.Ignore)
DistributeMethod(method);
return base.VisitMethodDecl(method);
}
示例8: VisitMethodDecl
public override bool VisitMethodDecl(Method method)
{
if (!method.IsConstructor && !method.IsDestructor && !method.IsOperator &&
method.IsGenerated && !method.IsSynthetized)
DistributeMethod(method);
return base.VisitMethodDecl(method);
}
示例9: VisitFunctionDecl
public override bool VisitFunctionDecl(Function function)
{
if (function.Ignore || !function.IsOperator)
return false;
var param = function.Parameters[0];
Class @class;
if (!FunctionToInstanceMethodPass.GetClassParameter(param, out @class))
return false;
// Create a new fake method so it acts as a static method.
var method = new Method(function)
{
Namespace = @class,
Kind = CXXMethodKind.Operator,
OperatorKind = function.OperatorKind,
SynthKind = FunctionSynthKind.NonMemberOperator,
OriginalFunction = null,
IsStatic = true
};
function.ExplicityIgnored = true;
@class.Methods.Add(method);
Driver.Diagnostics.Debug("Function converted to operator: {0}::{1}",
@class.Name, function.Name);
return true;
}
示例10: VisitMethodDecl
public override bool VisitMethodDecl(Method method)
{
if (!base.VisitMethodDecl(method))
return false;
if (method.IsPure && method.IsOperator)
method.ExplicitlyIgnore();
return true;
}
示例11: VisitMethodDecl
public override bool VisitMethodDecl(Method decl)
{
if (ASTUtils.CheckIgnoreMethod(decl))
return false;
if (!AlreadyVisited(decl) && decl.ExplicitInterfaceImpl == null)
CheckDuplicate(decl);
return false;
}
示例12: VisitFunctionDecl
public override bool VisitFunctionDecl(Function function)
{
if (!function.IsGenerated)
return false;
// Check if this function can be converted.
if (function.Parameters.Count == 0)
return false;
var classParam = function.Parameters[0];
Class @class;
if (!GetClassParameter(classParam, out @class))
return false;
// If we reach here, it means the first parameter is of class type.
// This means we can change the function to be an instance method.
// Clean up the name of the function now that it will be an instance method.
if (!function.Name.StartsWith(@class.Name))
return false;
function.Name = function.Name.Substring(@class.Name.Length);
function.ExplicitlyIgnore();
// Create a new fake method so it acts as an instance method.
var method = new Method
{
Namespace = @class,
OriginalNamespace = function.Namespace,
Name = function.Name,
OriginalName = function.OriginalName,
Mangled = function.Mangled,
Access = AccessSpecifier.Public,
Kind = CXXMethodKind.Normal,
ReturnType = function.ReturnType,
Parameters = function.Parameters,
CallingConvention = function.CallingConvention,
IsVariadic = function.IsVariadic,
IsInline = function.IsInline,
Conversion = MethodConversionKind.FunctionToInstanceMethod
};
if (Options.GeneratorKind == GeneratorKind.CSharp)
method.Parameters = method.Parameters.Skip(1).ToList();
@class.Methods.Add(method);
Diagnostics.Debug("Function converted to instance method: {0}::{1}", @class.Name,
function.Name);
return true;
}
示例13: VisitMethodDecl
public override bool VisitMethodDecl(Method method)
{
if (!VisitDeclaration(method))
return false;
if (ASTUtils.CheckIgnoreMethod(method, Driver.Options))
return false;
var @class = method.Namespace as Class;
if (@class == null || @class.IsIncomplete)
return false;
if (method.IsConstructor)
return false;
if (method.IsSynthetized)
return false;
if (IsGetter(method))
{
var name = method.Name.Substring("get".Length);
var prop = GetOrCreateProperty(@class, name, method.ReturnType);
prop.GetMethod = method;
prop.Access = method.Access;
// Do not generate the original method now that we know it is a getter.
method.GenerationKind = GenerationKind.Internal;
Driver.Diagnostics.Debug("Getter created: {0}::{1}", @class.Name, name);
return false;
}
if (IsSetter(method) && IsValidSetter(method))
{
var name = method.Name.Substring("set".Length);
var type = method.Parameters[0].QualifiedType;
var prop = GetOrCreateProperty(@class, name, type);
prop.SetMethod = method;
prop.Access = method.Access;
// Ignore the original method now that we know it is a setter.
method.GenerationKind = GenerationKind.Internal;
Driver.Diagnostics.Debug("Setter created: {0}::{1}", @class.Name, name);
return false;
}
return false;
}
示例14: VisitMethodDecl
public override bool VisitMethodDecl(Method method)
{
if (method.IsOverride && !method.IsSynthetized)
{
Method rootBaseMethod = ((Class) method.Namespace).GetBaseMethod(method);
for (int i = 0; i < method.Parameters.Count; i++)
{
method.Parameters[i].DefaultArgument = rootBaseMethod.Parameters[i].DefaultArgument;
}
}
return base.VisitMethodDecl(method);
}
示例15: VisitMethodDecl
public override bool VisitMethodDecl(Method decl)
{
if (!VisitDeclaration(decl))
return false;
if (ASTUtils.CheckIgnoreMethod(decl, Driver.Options))
return false;
if (decl.ExplicitInterfaceImpl == null)
CheckDuplicate(decl);
return false;
}