本文整理汇总了C#中System.Function.ExplicitlyIgnore方法的典型用法代码示例。如果您正苦于以下问题:C# Function.ExplicitlyIgnore方法的具体用法?C# Function.ExplicitlyIgnore怎么用?C# Function.ExplicitlyIgnore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Function
的用法示例。
在下文中一共展示了Function.ExplicitlyIgnore方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateName
private bool UpdateName(Function function)
{
if (function.TranslationUnit.Module != null)
Generator.CurrentOutputNamespace = function.TranslationUnit.Module.OutputNamespace;
var @params = function.Parameters.Where(p => p.Kind != ParameterKind.IndirectReturnType)
.Select(p => p.QualifiedType.ToString());
// Include the conversion type in case of conversion operators
var method = function as Method;
if (method != null &&
method.IsOperator &&
(method.OperatorKind == CXXOperatorKind.Conversion ||
method.OperatorKind == CXXOperatorKind.ExplicitConversion))
@params = @params.Concat(new[] { method.ConversionType.ToString() });
var signature = string.Format("{0}({1})", function.Name, string.Join( ", ", @params));
signature = FixSignatureForConversions(function, signature);
if (Count == 0)
Count++;
if (!methodSignatures.ContainsKey(signature))
{
methodSignatures.Add(signature, 0);
return false;
}
var methodCount = ++methodSignatures[signature];
if (Count < methodCount + 1)
Count = methodCount + 1;
if (function.IsOperator)
{
// TODO: turn into a method; append the original type (say, "signed long")
// of the last parameter to the type so that the user knows which overload is called
diagnostics.Warning("Duplicate operator {0} ignored", function.Name);
function.ExplicitlyIgnore();
}
else if (method != null && method.IsConstructor)
{
diagnostics.Warning("Duplicate constructor {0} ignored", function.Name);
function.ExplicitlyIgnore();
}
else
function.Name += methodCount.ToString(CultureInfo.InvariantCulture);
return true;
}
示例2: VisitFunctionDecl
public override bool VisitFunctionDecl(Function function)
{
if (function.GenerationKind == GenerationKind.None)
return false;
if (function.Parameters.Any(param => IsStdType(param.QualifiedType)))
{
function.ExplicitlyIgnore();
return false;
}
return true;
}
示例3: CheckDefaultParameters
static bool CheckDefaultParameters(Function function, Function overload)
{
var commonParameters = Math.Min(function.Parameters.Count, overload.Parameters.Count);
var i = 0;
for (; i < commonParameters; ++i)
{
var funcParam = function.Parameters[i];
var overloadParam = overload.Parameters[i];
if (!funcParam.QualifiedType.Equals(overloadParam.QualifiedType))
return false;
}
for (; i < function.Parameters.Count; ++i)
{
var funcParam = function.Parameters[i];
if (!funcParam.HasDefaultValue)
return false;
}
for (; i < overload.Parameters.Count; ++i)
{
var overloadParam = overload.Parameters[i];
if (!overloadParam.HasDefaultValue)
return false;
}
if (function.Parameters.Count > overload.Parameters.Count)
overload.ExplicitlyIgnore();
else
function.ExplicitlyIgnore();
return true;
}
示例4: VisitFunctionDecl
public override bool VisitFunctionDecl(Function function)
{
if (!VisitDeclaration(function))
return false;
var ret = function.ReturnType;
string msg;
if (HasInvalidType(ret.Type, out msg))
{
function.ExplicitlyIgnore();
Log.Debug("Function '{0}' was ignored due to {1} return decl",
function.Name, msg);
return false;
}
foreach (var param in function.Parameters)
{
if (HasInvalidDecl(param, out msg))
{
function.ExplicitlyIgnore();
Log.Debug("Function '{0}' was ignored due to {1} param",
function.Name, msg);
return false;
}
if (HasInvalidType(param.Type, out msg))
{
function.ExplicitlyIgnore();
Log.Debug("Function '{0}' was ignored due to {1} param",
function.Name, msg);
return false;
}
var decayedType = param.Type.Desugar() as DecayedType;
if (decayedType != null)
{
function.ExplicitlyIgnore();
Log.Debug("Function '{0}' was ignored due to unsupported decayed type param",
function.Name);
return false;
}
if (param.Kind == ParameterKind.IndirectReturnType)
{
Class retClass;
param.Type.Desugar().TryGetClass(out retClass);
if (retClass == null)
{
function.ExplicitlyIgnore();
Log.Debug(
"Function '{0}' was ignored due to an indirect return param not of a tag type",
function.Name);
return false;
}
}
}
return true;
}
示例5: CheckSingleParameterPointerConstnessForAmbiguity
private static bool CheckSingleParameterPointerConstnessForAmbiguity(
Function function, Function overload)
{
var functionParams = function.Parameters.Where(
p => p.Kind == ParameterKind.Regular).ToList();
// It's difficult to handle this case for more than one parameter
// For example, if we have:
// void f(float&, const int&);
// void f(const float&, int&);
// what should we do? Generate both? Generate the first one encountered?
// Generate the one with the least amount of "complex" parameters?
// So let's just start with the simplest case for the time being
if (functionParams.Count != 1)
return false;
var overloadParams = overload.Parameters.Where(
p => p.Kind == ParameterKind.Regular).ToList();
if (overloadParams.Count != 1)
return false;
var parameterFunction = functionParams[0];
var parameterOverload = overloadParams[0];
var pointerParamFunction = parameterFunction.Type.Desugar() as PointerType;
var pointerParamOverload = parameterOverload.Type.Desugar() as PointerType;
if (pointerParamFunction == null || pointerParamOverload == null)
return false;
if (!pointerParamFunction.GetPointee().Equals(pointerParamOverload.GetPointee()))
return false;
if (parameterFunction.IsConst && !parameterOverload.IsConst)
{
function.ExplicitlyIgnore();
return true;
}
if (parameterOverload.IsConst && !parameterFunction.IsConst)
{
overload.ExplicitlyIgnore();
return true;
}
if (pointerParamFunction.Modifier == PointerType.TypeModifier.RVReference &&
pointerParamOverload.Modifier != PointerType.TypeModifier.RVReference)
{
function.ExplicitlyIgnore();
return true;
}
if (pointerParamFunction.Modifier != PointerType.TypeModifier.RVReference &&
pointerParamOverload.Modifier == PointerType.TypeModifier.RVReference)
{
overload.ExplicitlyIgnore();
return true;
}
return false;
}