Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C#] Flatc enhancement: Expose table offsets and lengths by name #8571

Open
njannink opened this issue Apr 4, 2025 · 1 comment
Open

[C#] Flatc enhancement: Expose table offsets and lengths by name #8571

njannink opened this issue Apr 4, 2025 · 1 comment

Comments

@njannink
Copy link

njannink commented Apr 4, 2025

I would be great if the internal offsets would also be exposed in the generated code as named constants and that these are also actually used by the generated code. This makes things a lot more readable and gives devs the option to also reuse these consts instead of magic numbers:

current

public float3? Vertices(int j) { int o = __p.__offset(4); return o != 0 ? (float3?) (new float3()).__assign(__p.__vector(o) + j * 12, __p.bb) : null; }
public int VerticesLength { get { int o = __p.__offset(4); return o != 0 ? __p.__vector_len(o) : 0; } }
public int Tris(int j) { int o = __p.__offset(6); return o != 0 ? __p.bb.GetInt(__p.__vector(o) + j * 4) : (int) 0; }
public int TrisLength { get { int o = __p.__offset(6); return o != 0 ? __p.__vector_len(o) : 0; } }

proposed

public class TrimeshTable
{
  public const int VerticesOffset = 4;
  public const int VerticesLen = 12;
  public const int TrisOffset = 6;
  public const int TrisLen = 4;
}
public float3? Vertices(int j) { int o = __p.__offset(TrimeshTable.VerticesOffset); return o != 0 ? (float3?) (new float3()).__assign(__p.__vector(o) + j * TrimeshTable.VerticesLen, __p.bb) : null; }
public int VerticesLength { get { int o = __p.__offset(TrimeshTable.VerticesOffset); return o != 0 ? __p.__vector_len(o) : 0; } }
public int Tris(int j) { int o = __p.__offset(TrimeshTable.TrisOffset); return o != 0 ? __p.bb.GetInt(__p.__vector(o) + j * TrimeshTable.TrisLen) : (int) 0; }
public int TrisLength { get { int o = __p.__offset(TrimeshTable.TrisOffset); return o != 0 ? __p.__vector_len(o) : 0; } }
@njannink
Copy link
Author

njannink commented Apr 4, 2025

Maybe even dictionary access by name would be very helpfull

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant