Skip to content

Commit

Permalink
Add platform.h APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
kostya9 committed Oct 4, 2023
1 parent a36f19e commit a285b70
Show file tree
Hide file tree
Showing 13 changed files with 382 additions and 8 deletions.
2 changes: 1 addition & 1 deletion NetObsBindings/NetObsBindings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<PropertyGroup>
<PackageVersion>0.0.1.36-alpha</PackageVersion>
<PackageVersion>0.0.1.37-alpha</PackageVersion>

<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<ProjectUrl>https://github.com/kostya9/NetObsBindings</ProjectUrl>
Expand Down
6 changes: 3 additions & 3 deletions NetObsBindings/ObsInterop/ObsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ public static unsafe partial class ObsBase
public static extern void bcrash([NativeTypeName("const char *")] sbyte* format, __arglist);

[NativeTypeName("#define S__LINE__ STRINGIFY_(__LINE__)")]
public static ReadOnlySpan<byte> S__LINE__ => "7"u8;
public static ReadOnlySpan<byte> S__LINE__ => "9"u8;

[NativeTypeName("#define INT_CUR_LINE __LINE__")]
public const int INT_CUR_LINE = 9;
public const int INT_CUR_LINE = 11;

[NativeTypeName("#define FILE_LINE __FILE__ \" (\" S__LINE__ \"): \"")]
public static ReadOnlySpan<byte> FILE_LINE => ".\\generate\\util\\obs-util.h (11): "u8;
public static ReadOnlySpan<byte> FILE_LINE => ".\\generate\\util\\obs-util.h (13): "u8;
}
15 changes: 15 additions & 0 deletions NetObsBindings/ObsInterop/ObsPlatform.Manual.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System.Diagnostics;

namespace ObsInterop;

/// <summary>
/// This method contains bindings generated form platform.h header file in the OBS library.
/// <para />
/// [IMPORTANT] Please use with care and prefer .NET APIs whenever possible.
/// <para />
/// For example, the os_cpu_usage_info_start() method returns a pointer to the struct that has different layout in different systems.
/// </summary>
public partial class ObsPlatform
{
public static readonly unsafe int ARCH_BITS = sizeof(nint) * 8;
}
302 changes: 302 additions & 0 deletions NetObsBindings/ObsInterop/ObsPlatform.cs

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions NetObsBindings/ObsInterop/os_cpu_usage_info.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace ObsInterop;

public partial struct os_cpu_usage_info
{
}
5 changes: 5 additions & 0 deletions NetObsBindings/ObsInterop/os_dir.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace ObsInterop;

public partial struct os_dir
{
}
10 changes: 10 additions & 0 deletions NetObsBindings/ObsInterop/os_dirent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace ObsInterop;

public unsafe partial struct os_dirent
{
[NativeTypeName("char[256]")]
public fixed sbyte d_name[256];

[NativeTypeName("bool")]
public byte directory;
}
10 changes: 10 additions & 0 deletions NetObsBindings/ObsInterop/os_glob_info.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace ObsInterop;

public unsafe partial struct os_glob_info
{
[NativeTypeName("size_t")]
public nuint gl_pathc;

[NativeTypeName("struct os_globent *")]
public os_globent* gl_pathv;
}
10 changes: 10 additions & 0 deletions NetObsBindings/ObsInterop/os_globent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace ObsInterop;

public unsafe partial struct os_globent
{
[NativeTypeName("char *")]
public sbyte* path;

[NativeTypeName("bool")]
public byte directory;
}
5 changes: 5 additions & 0 deletions NetObsBindings/ObsInterop/os_inhibit_info.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
namespace ObsInterop;

public partial struct os_inhibit_info
{
}
10 changes: 10 additions & 0 deletions NetObsBindings/ObsInterop/os_proc_memory_usage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace ObsInterop;

public partial struct os_proc_memory_usage
{
[NativeTypeName("uint64_t")]
public ulong resident_size;

[NativeTypeName("uint64_t")]
public ulong virtual_size;
}
3 changes: 2 additions & 1 deletion generate/util/obs-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
#include <util/text-lookup.h>
#include <util/profiler.h>
#include <util/base.h>
#include <util/bmem.h>
#include <util/bmem.h>
#include <util/platform.h>
7 changes: 4 additions & 3 deletions generate_bindings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ function Get-ObsClassName {
}

$config = "multi-file", "generate-file-scoped-namespaces", "generate-helper-types", "exclude-funcs-with-body", "generate-macro-bindings", "latest-codegen"
$replacements = "[email protected]", "[email protected]", "[email protected]", "half=@Half", "[email protected]<Single>", "[email protected]"
$excludes = "blogva", "blog"
$replacements = "[email protected]", "[email protected]", "[email protected]", "half=@Half", "[email protected]<Single>", "[email protected]", "_iobuf*=@nint","stat*=@nint"
$excludes = "blogva", "blog", "ARCH_BITS"

$obsModuleTracersals = @(
".\obs-studio\libobs\obs-source.h",
Expand Down Expand Up @@ -124,7 +124,8 @@ $utilLibraries = @(
".\obs-studio\libobs\util\text-lookup.h",
".\obs-studio\libobs\util\profiler.h",
".\obs-studio\libobs\util\base.h",
".\obs-studio\libobs\util\bmem.h"
".\obs-studio\libobs\util\bmem.h",
".\obs-studio\libobs\util\platform.h"
);

foreach ($utilLibrary in $utilLibraries)
Expand Down

0 comments on commit a285b70

Please sign in to comment.