mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-17 02:39:41 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
47 lines
1.0 KiB
C#
47 lines
1.0 KiB
C#
using System.Collections.Generic;
|
|
using System.Text.RegularExpressions;
|
|
|
|
namespace Facepunch.InteropGen;
|
|
|
|
public class Variable
|
|
{
|
|
public bool Native { get; set; }
|
|
public bool Static { get; private set; }
|
|
public string Name { get; set; }
|
|
public Arg Return { get; set; }
|
|
public Class Class { get; set; }
|
|
public string MangledName { get; set; }
|
|
|
|
internal static Variable Parse( string line )
|
|
{
|
|
Match m = Regex.Match( line, @"^[\s+]?(static)?[\s+]?(.+?)\s+([a-zA-Z0-9_]+?);", RegexOptions.IgnoreCase );
|
|
if ( !m.Success )
|
|
{
|
|
return null;
|
|
}
|
|
|
|
Variable f = new()
|
|
{
|
|
Native = true,
|
|
Static = m.Groups[1].Success,
|
|
Name = m.Groups[3].Value.Trim(),
|
|
Return = Arg.Parse( m.Groups[2].Value + " returnvalue" )
|
|
};
|
|
|
|
return f;
|
|
}
|
|
|
|
internal string GetManagedName()
|
|
{
|
|
return Name == "GetType" ? "GetType_Native" : Name == "params" ? $"@{Name}" : Name;
|
|
}
|
|
|
|
private readonly List<string> attr = [];
|
|
|
|
internal void TakeAttributes( List<string> attributes )
|
|
{
|
|
attr.AddRange( attributes );
|
|
attributes.Clear();
|
|
}
|
|
}
|