本文整理汇总了C#中DeclarationContext类的典型用法代码示例。如果您正苦于以下问题:C# DeclarationContext类的具体用法?C# DeclarationContext怎么用?C# DeclarationContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DeclarationContext类属于命名空间,在下文中一共展示了DeclarationContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsNameSpaceStd
private static bool IsNameSpaceStd(DeclarationContext declarationContext)
{
if (declarationContext == null)
return false;
var @namespace = declarationContext as Namespace;
if (@namespace != null && @namespace.IsInline)
return IsNameSpaceStd(declarationContext.Namespace);
return declarationContext.OriginalName == "std";
}
示例2: CheckType
/// <summary>
/// Generates a new typedef for the given type if necessary and returns the new type.
/// </summary>
/// <param name="namespace">The namespace the typedef will be added to.</param>
/// <param name="type">The type to check.</param>
/// <returns>The new type.</returns>
private QualifiedType CheckType(DeclarationContext @namespace, QualifiedType type)
{
if (type.Type.IsDependent)
return type;
var pointerType = type.Type as PointerType;
if (pointerType == null)
return type;
var functionType = pointerType.Pointee as FunctionType;
if (functionType == null)
return type;
List<Typedef> typedefs;
if (!allTypedefs.TryGetValue(@namespace.QualifiedName, out typedefs))
{
typedefs = new List<Typedef>();
allTypedefs.Add(@namespace.QualifiedName, typedefs);
}
var typedef = FindMatchingTypedef(typedefs, functionType);
if (typedef == null)
{
for (int i = 0; i < functionType.Parameters.Count; i++)
{
functionType.Parameters[i].Name = string.Format("_{0}", i);
}
typedef = new TypedefDecl
{
Access = AccessSpecifier.Public,
Name = string.Format("__AnonymousDelegate{0}", typedefs.Count),
Namespace = @namespace,
QualifiedType = type,
IsSynthetized = true
};
typedefs.Add(new Typedef
{
Context = @namespace,
Declaration = typedef
});
}
var typedefType = new TypedefType
{
Declaration = typedef
};
return new QualifiedType(typedefType);
}
示例3: GenerateProperty
private static void GenerateProperty(DeclarationContext context, Method getter, Method setter = null)
{
Class type = (Class) context;
if (type.Properties.All(p => getter.Name != p.Name ||
p.ExplicitInterfaceImpl != getter.ExplicitInterfaceImpl))
{
Property property = new Property();
property.Name = GetPropertyName(getter.Name);
property.Namespace = type;
property.QualifiedType = getter.OriginalReturnType;
if (getter.IsOverride || (setter != null && setter.IsOverride))
{
Property baseVirtualProperty = type.GetRootBaseProperty(property);
if (baseVirtualProperty.SetMethod == null)
setter = null;
}
property.GetMethod = getter;
property.SetMethod = setter;
property.ExplicitInterfaceImpl = getter.ExplicitInterfaceImpl;
if (property.ExplicitInterfaceImpl == null && setter != null)
{
property.ExplicitInterfaceImpl = setter.ExplicitInterfaceImpl;
}
if (getter.Comment != null)
{
var comment = new RawComment();
comment.Kind = getter.Comment.Kind;
comment.BriefText = getter.Comment.BriefText;
comment.Text = getter.Comment.Text;
comment.FullComment = new FullComment();
comment.FullComment.Blocks.AddRange(getter.Comment.FullComment.Blocks);
if (setter != null && setter.Comment != null)
{
comment.BriefText += Environment.NewLine + setter.Comment.BriefText;
comment.Text += Environment.NewLine + setter.Comment.Text;
comment.FullComment.Blocks.AddRange(setter.Comment.FullComment.Blocks);
}
property.Comment = comment;
}
type.Properties.Add(property);
getter.IsGenerated = false;
if (setter != null)
setter.IsGenerated = false;
}
}
示例4: VisitDeclarationContext
public override bool VisitDeclarationContext(DeclarationContext context)
{
return context.IsGenerated && !context.TranslationUnit.IsSystemHeader && base.VisitDeclarationContext(context);
}
示例5: DeclarationContext
internal DeclarationContext(DeclarationContext.Internal native)
: this(__CopyValue(native))
{
}
示例6: DeclarationContext
private DeclarationContext(DeclarationContext.Internal native)
: this(__CopyValue(native))
{
__ownsNativeInstance = true;
NativeToManagedMap[__Instance] = this;
}
示例7: HandleQSignal
private void HandleQSignal(DeclarationContext @class, Method method)
{
var expansions = method.AccessDecl.PreprocessedEntities.OfType<MacroExpansion>();
if (expansions.All(e => e.Text != "Q_SIGNALS"))
{
return;
}
if (method.Parameters.Any())
{
Class decl;
if (method.Parameters.Last().Type.TryGetClass(out decl) && decl.Name == "QPrivateSignal")
{
method.Parameters.RemoveAt(method.Parameters.Count - 1);
}
}
var functionType = method.GetFunctionType();
var @event = new Event
{
OriginalDeclaration = method,
Name = method.Name,
OriginalName = method.OriginalName,
Namespace = method.Namespace,
QualifiedType = new QualifiedType(functionType),
Parameters = method.Parameters
};
method.GenerationKind = GenerationKind.None;
@class.Events.Add(@event);
this.events.Add(@event);
}
示例8: VisitDeclarationContext
public override bool VisitDeclarationContext(DeclarationContext context)
{
return context.IsGenerated && base.VisitDeclarationContext(context);
}
示例9: __CreateInstance
public static DeclarationContext __CreateInstance(DeclarationContext.Internal native)
{
return new DeclarationContext(native);
}
示例10: CreateInterfaceProperty
private static Property CreateInterfaceProperty(Property property, DeclarationContext @namespace)
{
var interfaceProperty = new Property(property) { Namespace = @namespace };
if (property.GetMethod != null)
interfaceProperty.GetMethod = new Method(property.GetMethod)
{
OriginalFunction = property.GetMethod,
Namespace = @namespace
};
if (property.SetMethod != null)
// handle indexers
interfaceProperty.SetMethod = property.GetMethod == property.SetMethod ?
interfaceProperty.GetMethod : new Method(property.SetMethod)
{
OriginalFunction = property.SetMethod,
Namespace = @namespace
};
return interfaceProperty;
}
示例11: DeclarationContext
internal DeclarationContext(DeclarationContext.Internal native)
: this(&native)
{
}
示例12: GenerateProperty
private static void GenerateProperty(DeclarationContext context, Method getter, Method setter = null)
{
var type = (Class) context;
if (type.Properties.All(p => getter.Name != p.Name ||
p.ExplicitInterfaceImpl != getter.ExplicitInterfaceImpl))
{
var property = new Property
{
Access = getter.Access == AccessSpecifier.Public ||
(setter != null && setter.Access == AccessSpecifier.Public)
? AccessSpecifier.Public
: AccessSpecifier.Protected,
Name = GetPropertyName(getter.Name),
Namespace = type,
QualifiedType = getter.OriginalReturnType,
OriginalNamespace = getter.OriginalNamespace
};
if (getter.IsOverride || (setter != null && setter.IsOverride))
{
var baseVirtualProperty = type.GetBaseProperty(property, getTopmost: true);
if (baseVirtualProperty.SetMethod == null)
setter = null;
}
property.GetMethod = getter;
property.SetMethod = setter;
property.ExplicitInterfaceImpl = getter.ExplicitInterfaceImpl;
if (property.ExplicitInterfaceImpl == null && setter != null)
{
property.ExplicitInterfaceImpl = setter.ExplicitInterfaceImpl;
}
if (getter.Comment != null)
{
property.Comment = CombineComments(getter, setter);
}
type.Properties.Add(property);
getter.GenerationKind = GenerationKind.Internal;
if (setter != null)
setter.GenerationKind = GenerationKind.Internal;
}
}
示例13: GetFileForDeclarationContext
private static string GetFileForDeclarationContext(DeclarationContext declarationContext)
{
if (string.IsNullOrEmpty(declarationContext.Name))
{
return "qtglobal.html";
}
StringBuilder fileNameBuilder = new StringBuilder(declarationContext.Name.ToLowerInvariant());
if (declarationContext is Class && ((Class) declarationContext).IsInterface)
{
fileNameBuilder.Remove(0, 1);
}
Class parentClass = declarationContext.Namespace as Class;
if (parentClass != null)
{
fileNameBuilder.Insert(0, string.Format("{0}-", parentClass.Name.ToLowerInvariant()));
}
fileNameBuilder.Append(".html");
return fileNameBuilder.ToString();
}
示例14: GenerateProperty
private static void GenerateProperty(DeclarationContext context, Method getter, Method setter = null)
{
var type = (Class) context;
var name = GetPropertyName(getter.Name);
if (type.Properties.Any(p => p.Name == name &&
p.ExplicitInterfaceImpl == getter.ExplicitInterfaceImpl))
return;
var property = new Property
{
Access = getter.Access == AccessSpecifier.Public ||
(setter != null && setter.Access == AccessSpecifier.Public) ?
AccessSpecifier.Public : AccessSpecifier.Protected,
Name = name,
Namespace = type,
QualifiedType = getter.OriginalReturnType,
OriginalNamespace = getter.OriginalNamespace
};
if (getter.IsOverride || (setter != null && setter.IsOverride))
{
var baseVirtualProperty = type.GetBaseProperty(property, getTopmost: true);
if (baseVirtualProperty == null && type.GetBaseMethod(getter, getTopmost: true).IsGenerated)
throw new Exception(string.Format(
"Property {0} has a base property null but its getter has a generated base method.",
getter.QualifiedOriginalName));
if (baseVirtualProperty != null && !baseVirtualProperty.IsVirtual)
{
// the only way the above can happen is if we are generating properties in abstract implementations
// in which case we can have less naming conflicts since the abstract base can also contain non-virtual properties
if (getter.SynthKind == FunctionSynthKind.AbstractImplCall)
return;
throw new Exception(string.Format(
"Base of property {0} is not virtual while the getter is.",
getter.QualifiedOriginalName));
}
if (baseVirtualProperty != null && baseVirtualProperty.SetMethod == null)
setter = null;
}
property.GetMethod = getter;
property.SetMethod = setter;
property.ExplicitInterfaceImpl = getter.ExplicitInterfaceImpl;
if (property.ExplicitInterfaceImpl == null && setter != null)
{
property.ExplicitInterfaceImpl = setter.ExplicitInterfaceImpl;
}
if (getter.Comment != null)
{
property.Comment = CombineComments(getter, setter);
}
type.Properties.Add(property);
getter.GenerationKind = GenerationKind.Internal;
if (setter != null)
setter.GenerationKind = GenerationKind.Internal;
}
示例15: HandleQSignal
private void HandleQSignal(DeclarationContext @class, Method method)
{
AccessSpecifierDecl access = method.AccessDecl;
IEnumerable<MacroExpansion> expansions = access.PreprocessedEntities.OfType<MacroExpansion>();
if (expansions.All(e => e.Text != "Q_SIGNALS"))
{
return;
}
if (method.Parameters.Any())
{
Declaration decl;
if (method.Parameters.Last().Type.IsTagDecl(out decl) && decl.Name == "QPrivateSignal")
{
method.Parameters.RemoveAt(method.Parameters.Count - 1);
}
}
FunctionType functionType = method.GetFunctionType();
Event @event = new Event
{
OriginalDeclaration = method,
Name = method.Name,
OriginalName = method.OriginalName,
Namespace = method.Namespace,
QualifiedType = new QualifiedType(functionType),
Parameters = method.Parameters
};
method.IsGenerated = false;
@class.Events.Add(@event);
this.events.Add(@event);
}