Add support for using DEPRECATED to mark scripting API as obsolete
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
#define ALIGN_BEGIN(_align)
|
||||
#define ALIGN_END(_align) __attribute__( (aligned(_align) ) )
|
||||
#define OFFSET_OF(X, Y) __builtin_offsetof(X, Y)
|
||||
#define DEPRECATED
|
||||
#define DEPRECATED [[deprecated]]
|
||||
|
||||
#pragma clang diagnostic ignored "-Wswitch"
|
||||
#pragma clang diagnostic ignored "-Wmacro-redefined"
|
||||
@@ -44,7 +44,7 @@
|
||||
#define ALIGN_BEGIN(_align)
|
||||
#define ALIGN_END(_align) __attribute__( (aligned(_align) ) )
|
||||
#define OFFSET_OF(X, Y) __builtin_offsetof(X, Y)
|
||||
#define DEPRECATED __attribute__((deprecated))
|
||||
#define DEPRECATED [[deprecated]]
|
||||
|
||||
#elif defined(__INTEL_COMPILER)
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ namespace Flax.Build.Bindings
|
||||
public string Attributes;
|
||||
public string[] Comment;
|
||||
public bool IsInBuild;
|
||||
public bool IsDeprecated;
|
||||
internal bool IsInited;
|
||||
|
||||
public virtual bool IsClass => false;
|
||||
@@ -107,6 +108,7 @@ namespace Flax.Build.Bindings
|
||||
BindingsGenerator.Write(writer, Attributes);
|
||||
BindingsGenerator.Write(writer, Comment);
|
||||
writer.Write(IsInBuild);
|
||||
writer.Write(IsDeprecated);
|
||||
BindingsGenerator.Write(writer, Children);
|
||||
}
|
||||
|
||||
@@ -118,6 +120,7 @@ namespace Flax.Build.Bindings
|
||||
Attributes = BindingsGenerator.Read(reader, Attributes);
|
||||
Comment = BindingsGenerator.Read(reader, Comment);
|
||||
IsInBuild = reader.ReadBoolean();
|
||||
IsDeprecated = reader.ReadBoolean();
|
||||
Children = BindingsGenerator.Read(reader, Children);
|
||||
|
||||
// Fix hierarchy
|
||||
|
||||
@@ -475,7 +475,7 @@ namespace Flax.Build.Bindings
|
||||
}
|
||||
}
|
||||
|
||||
private static void GenerateCSharpAttributes(BuildData buildData, StringBuilder contents, string indent, ApiTypeInfo apiTypeInfo, string attributes, string[] comment, bool canUseTooltip, bool useUnmanaged, string defaultValue = null)
|
||||
private static void GenerateCSharpAttributes(BuildData buildData, StringBuilder contents, string indent, ApiTypeInfo apiTypeInfo, string attributes, string[] comment, bool canUseTooltip, bool useUnmanaged, string defaultValue = null, bool isDeprecated = false)
|
||||
{
|
||||
var writeTooltip = true;
|
||||
var writeDefaultValue = true;
|
||||
@@ -492,6 +492,11 @@ namespace Flax.Build.Bindings
|
||||
// Write attribute for C++ calling code
|
||||
contents.Append(indent).AppendLine("[Unmanaged]");
|
||||
}
|
||||
if (isDeprecated || apiTypeInfo.IsDeprecated)
|
||||
{
|
||||
// Deprecated type
|
||||
contents.Append(indent).AppendLine("[Obsolete]");
|
||||
}
|
||||
|
||||
if (canUseTooltip &&
|
||||
writeTooltip &&
|
||||
@@ -537,7 +542,7 @@ namespace Flax.Build.Bindings
|
||||
|
||||
private static void GenerateCSharpAttributes(BuildData buildData, StringBuilder contents, string indent, ApiTypeInfo apiTypeInfo, MemberInfo memberInfo, bool useUnmanaged, string defaultValue = null)
|
||||
{
|
||||
GenerateCSharpAttributes(buildData, contents, indent, apiTypeInfo, memberInfo.Attributes, memberInfo.Comment, true, useUnmanaged, defaultValue);
|
||||
GenerateCSharpAttributes(buildData, contents, indent, apiTypeInfo, memberInfo.Attributes, memberInfo.Comment, true, useUnmanaged, defaultValue, memberInfo.IsDeprecated);
|
||||
}
|
||||
|
||||
private static void GenerateCSharpClass(BuildData buildData, StringBuilder contents, string indent, ClassInfo classInfo)
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Flax.Build.Bindings
|
||||
partial class BindingsGenerator
|
||||
{
|
||||
private static readonly Dictionary<string, Type> TypeCache = new Dictionary<string, Type>();
|
||||
private const int CacheVersion = 9;
|
||||
private const int CacheVersion = 10;
|
||||
|
||||
internal static void Write(BinaryWriter writer, string e)
|
||||
{
|
||||
|
||||
@@ -2062,6 +2062,8 @@ namespace Flax.Build.Bindings
|
||||
|
||||
contents.AppendLine("// This code was auto-generated. Do not modify it.");
|
||||
contents.AppendLine();
|
||||
if (buildData.Platform is Platforms.WindowsPlatformBase)
|
||||
contents.AppendLine("#pragma warning(disable: 4996)").AppendLine(); // Ignore deprecated warnings
|
||||
contents.AppendLine("#include \"Engine/Scripting/Scripting.h\"");
|
||||
contents.AppendLine("#include \"Engine/Scripting/InternalCalls.h\"");
|
||||
contents.AppendLine("#include \"Engine/Scripting/ManagedCLR/MUtils.h\"");
|
||||
|
||||
@@ -496,6 +496,21 @@ namespace Flax.Build.Bindings
|
||||
if (token.Value != "class")
|
||||
throw new Exception($"Invalid API_CLASS usage (expected 'class' keyword but got '{token.Value} {context.Tokenizer.NextToken().Value}').");
|
||||
|
||||
// Read specifiers
|
||||
while (true)
|
||||
{
|
||||
token = context.Tokenizer.NextToken();
|
||||
if (!desc.IsDeprecated && token.Value == "DEPRECATED")
|
||||
{
|
||||
desc.IsDeprecated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Tokenizer.PreviousToken();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Read name
|
||||
desc.Name = desc.NativeName = ParseName(ref context);
|
||||
|
||||
@@ -574,6 +589,21 @@ namespace Flax.Build.Bindings
|
||||
if (token.Value != "class")
|
||||
throw new Exception($"Invalid API_INTERFACE usage (expected 'class' keyword but got '{token.Value} {context.Tokenizer.NextToken().Value}').");
|
||||
|
||||
// Read specifiers
|
||||
while (true)
|
||||
{
|
||||
token = context.Tokenizer.NextToken();
|
||||
if (!desc.IsDeprecated && token.Value == "DEPRECATED")
|
||||
{
|
||||
desc.IsDeprecated = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Tokenizer.PreviousToken();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Read name
|
||||
desc.Name = desc.NativeName = ParseName(ref context);
|
||||
|
||||
@@ -629,7 +659,7 @@ namespace Flax.Build.Bindings
|
||||
var tagParams = ParseTagParameters(ref context);
|
||||
context.Tokenizer.SkipUntil(TokenType.Identifier);
|
||||
|
||||
// Read 'static' or 'FORCE_INLINE' or 'virtual'
|
||||
// Read specifiers
|
||||
var isForceInline = false;
|
||||
while (true)
|
||||
{
|
||||
@@ -649,6 +679,11 @@ namespace Flax.Build.Bindings
|
||||
desc.IsVirtual = true;
|
||||
context.Tokenizer.NextToken();
|
||||
}
|
||||
else if (!desc.IsDeprecated && token.Value == "DEPRECATED")
|
||||
{
|
||||
desc.IsDeprecated = true;
|
||||
context.Tokenizer.NextToken();
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Tokenizer.PreviousToken();
|
||||
@@ -781,6 +816,7 @@ namespace Flax.Build.Bindings
|
||||
propertyInfo.Getter = functionInfo;
|
||||
else
|
||||
propertyInfo.Setter = functionInfo;
|
||||
propertyInfo.IsDeprecated |= functionInfo.IsDeprecated;
|
||||
|
||||
if (propertyInfo.Getter != null && propertyInfo.Setter != null)
|
||||
{
|
||||
@@ -1044,9 +1080,9 @@ namespace Flax.Build.Bindings
|
||||
var tagParams = ParseTagParameters(ref context);
|
||||
context.Tokenizer.SkipUntil(TokenType.Identifier);
|
||||
|
||||
// Read 'static' or 'mutable'
|
||||
// Read specifiers
|
||||
Token token;
|
||||
var isMutable = false;
|
||||
bool isMutable = false, isVolatile = false;
|
||||
while (true)
|
||||
{
|
||||
token = context.Tokenizer.CurrentToken;
|
||||
@@ -1060,6 +1096,16 @@ namespace Flax.Build.Bindings
|
||||
isMutable = true;
|
||||
context.Tokenizer.NextToken();
|
||||
}
|
||||
else if (!isVolatile && token.Value == "volatile")
|
||||
{
|
||||
isVolatile = true;
|
||||
context.Tokenizer.NextToken();
|
||||
}
|
||||
else if (!desc.IsDeprecated && token.Value == "DEPRECATED")
|
||||
{
|
||||
desc.IsDeprecated = true;
|
||||
context.Tokenizer.NextToken();
|
||||
}
|
||||
else
|
||||
{
|
||||
context.Tokenizer.PreviousToken();
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace Flax.Build.Bindings
|
||||
public string Name;
|
||||
public string[] Comment;
|
||||
public bool IsStatic;
|
||||
public bool IsDeprecated;
|
||||
public AccessLevel Access;
|
||||
public string Attributes;
|
||||
|
||||
@@ -25,6 +26,7 @@ namespace Flax.Build.Bindings
|
||||
writer.Write(Name);
|
||||
BindingsGenerator.Write(writer, Comment);
|
||||
writer.Write(IsStatic);
|
||||
writer.Write(IsDeprecated);
|
||||
writer.Write((byte)Access);
|
||||
BindingsGenerator.Write(writer, Attributes);
|
||||
}
|
||||
@@ -34,6 +36,7 @@ namespace Flax.Build.Bindings
|
||||
Name = reader.ReadString();
|
||||
Comment = BindingsGenerator.Read(reader, Comment);
|
||||
IsStatic = reader.ReadBoolean();
|
||||
IsDeprecated = reader.ReadBoolean();
|
||||
Access = (AccessLevel)reader.ReadByte();
|
||||
Attributes = BindingsGenerator.Read(reader, Attributes);
|
||||
}
|
||||
|
||||
@@ -455,10 +455,6 @@ namespace Flax.Build.Platforms
|
||||
if (compileEnvironment.RuntimeChecks && !compileEnvironment.CompileAsWinRT)
|
||||
commonArgs.Add("/RTC1");
|
||||
|
||||
// Enable Additional Security Checks
|
||||
if (compileEnvironment.RuntimeChecks)
|
||||
commonArgs.Add("/sdl");
|
||||
|
||||
// Inline Function Expansion
|
||||
if (compileEnvironment.Inlining)
|
||||
commonArgs.Add("/Ob2");
|
||||
@@ -548,7 +544,6 @@ namespace Flax.Build.Platforms
|
||||
commonArgs.Add("/WX-");
|
||||
|
||||
// Show warnings
|
||||
// TODO: compile with W4 and fix all warnings
|
||||
commonArgs.Add("/W3");
|
||||
|
||||
// Silence macro redefinition warning
|
||||
|
||||
Reference in New Issue
Block a user