mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-01-11 07:48:36 -05:00
This commit imports the C# engine code and game files, excluding C++ source code. [Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
namespace Facepunch.InteropGen;
|
|
|
|
/// <summary>
|
|
/// Qt defines some things as regular classes that contain nothing but a smart pointer to the
|
|
/// real data. Marking a class as [SharedDataPointer] will:
|
|
///
|
|
/// 1. Always return as a new Class()
|
|
/// 2. Pass to native as a pointer to that class
|
|
/// 3. Pass to the native function as a instance to that class (*) ptr
|
|
/// </summary>
|
|
public class ArgSharedDataPointer : ArgDefinedClass
|
|
{
|
|
|
|
public ArgSharedDataPointer( Class c, string name, string[] flags ) : base( c, name, flags )
|
|
{
|
|
|
|
}
|
|
|
|
public override string FromInterop( bool native, string code = null )
|
|
{
|
|
return native ? "*" + (code ?? Name) : base.FromInterop( native, code );
|
|
}
|
|
|
|
public override string ToInterop( bool native, string code = null )
|
|
{
|
|
return !native ? $"{code ?? Name}.GetPointerAssertIfNull()" : base.ToInterop( native, code );
|
|
}
|
|
|
|
public override string ReturnWrapCall( string functionCall, bool native )
|
|
{
|
|
return native
|
|
? $"return new {Class.NativeNameWithNamespace}( {functionCall} );"
|
|
: $"return new {Class.ManagedNameWithNamespace}( {functionCall} );";
|
|
}
|
|
|
|
}
|