protected bool GetNativeExternName(IMethodSymbol method, NativeTarget target, out string name) { var attribute = GetNativeExternAttribute(method, target); if (attribute != null) { var constant = attribute.ConstructorArguments[1]; if (constant.Value == null) { name = method.Name; } else { name = constant.Value.ToString(); } return(true); } else if (!IsInternalCall(method)) { throw new NotSupportedException("Unsupported extern method invoke: " + method.FullName()); } name = null; return(false); }
protected AttributeData GetCS2XAttribute(ISymbol symbol, NativeTarget target, string attributeTypeName) { foreach (var attribute in symbol.GetAttributes()) { var type = attribute.AttributeClass; if (type.ContainingNamespace.Name == "CS2X" && type.Name == attributeTypeName) { if (!attribute.ConstructorArguments.Any(x => ((int)x.Value & 1) == (int)target)) { throw new NotImplementedException($"NativeTarget not set for '{target}': " + symbol.FullName()); } return(attribute); } } return(null); }
protected bool GetNativeTypeName(ITypeSymbol type, NativeTarget target, out string name) { if (GetNativeTypeAttribute(type, target, out var attribute)) { var constant = attribute.ConstructorArguments[1]; if (constant.Value == null) { name = type.Name; } else { name = constant.Value.ToString(); } return(true); } name = null; return(false); }
protected bool GetNativeExternName(IMethodSymbol method, NativeTarget target, out string name) { if (GetNativeExternAttribute(method, target, out var nativeExternAttribute)) { var constant = nativeExternAttribute.ConstructorArguments[1]; if (constant.Value == null) { name = method.Name; } else { name = constant.Value.ToString(); } return(true); } name = null; return(false); }
protected bool GetNativeTypeAttribute(ITypeSymbol type, NativeTarget target, out AttributeData attribute) { return(GetCS2XAttribute(type, target, "NativeTypeAttribute", out attribute)); }
protected bool GetNativeExternAttribute(IMethodSymbol method, NativeTarget target, out AttributeData attribute) { return(GetCS2XAttribute(method, target, "NativeExternAttribute", out attribute)); }
protected AttributeData GetNativeTypeAttribute(ITypeSymbol type, NativeTarget target) { return(GetCS2XAttribute(type, target, "NativeTypeAttribute")); }
protected AttributeData GetNativeExternAttribute(IMethodSymbol method, NativeTarget target) { return(GetCS2XAttribute(method, target, "NativeExternAttribute")); }
public NativeExternAttribute(NativeTarget target, string methodName = null) { this.target = target; this.methodName = methodName; }
public NativeTypeAttribute(NativeTarget target, string typeName = null) { this.target = target; this.typeName = typeName; }