Go to file
Madpwnhammer 667040ea35 Using special case when initializing []any in bindings 2023-03-21 15:40:29 +03:00
src aMaking bhl_type_ref a bit more generic and uglier 2023-03-02 12:33:43 +03:00
tpl Using special case when initializing []any in bindings 2023-03-21 15:40:29 +03:00
.gitignore Adding README and ignores file 2022-12-03 17:18:25 +03:00
README.md Изменил(а) на 'README.md' 2022-12-30 14:52:39 +03:00
composer.json Experimenting with composer deps 2022-12-14 16:39:10 +03:00

README.md

This package is used for code generation of bhl2 bindings for C# using Twig templates

Here the example of bindings declaration:

func Debug(
  @bhl_native_prefix:BitGames.Logs.Log.Debug(..)
  msg : string
)

func Error(
  @bhl_native_prefix:BitGames.Logs.Log.Error(..)
  msg : string
)

func Time(
  @bhl_native_prefix:Time.time
) : float

struct Vector2
  @bhl_native_class:Vector2 @bhl_custom_rw @bhl_no_itype

  x : float
  y : float

  magnitude     : float @bhl_set:0
  sqrMagnitude  : float @bhl_set:0
  normalized    : Vector2 @bhl_set:0

  func Mult(
    @bhl_bin_op:"*" @bhl_static
    self : Vector2
    v : float
  ) : Vector2
end

Usage example:

$twig = \bhl_bind\get_twig();
$meta = \bhl_bind\prepare_meta($meta);

file_put_contents('autobind.cs', 
  $twig->render("codegen_autobind.twig", 
    [
     'imports' => ['UnityEngine'], 
     'meta' => $meta
    ]
  )
);

file_put_contents('types.cs', 
  $twig->render("codegen_types.twig", 
    [
     'meta' => $meta
    ]
  )
);