Skip to content

Commit 4ced552

Browse files
committed
Started documentation.
1 parent 1c96218 commit 4ced552

File tree

55 files changed

+2002
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2002
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Biohazrd is still under heavy development, documentation and API stability are n
99

1010
Interested in seeing it used? Check out [InfectedImGui](https://github.com/InfectedLibraries/InfectedImGui) or [InfectedPhysX](https://github.com/InfectedLibraries/InfectedPhysX).
1111

12+
We also have peliminary documentation available in [the docs folder](docs/).
13+
1214
## License
1315

1416
This project is licensed under the MIT License. [See the license file for details](LICENSE.txt).
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
`ConstantArrayTypeDeclaration`
2+
===================================================================================================
3+
4+
<small>\[[Transformation Source](../../Biohazrd.CSharp/#Declarations/ConstantArrayTypeDeclaration.cs)\]</small>
5+
6+
TODO
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
`NativeBooleanDeclaration`
2+
===================================================================================================
3+
4+
<small>\[[Transformation Source](../../Biohazrd.CSharp/#Declarations/NativeBooleanDeclaration.cs)\]</small>
5+
6+
This declaration represents the `NativeBoolean` type synthesized as needed by [`WrapNonBlittableTypesWhereNecessaryTransformation`](../BuiltinTransformations/WrapNonBlittableTypesWhereNecessaryTransformation.md).
7+
8+
## Interacting with this declarations
9+
10+
Your can rename this declaration if you wish to rename the generated type.
11+
12+
The emitted declaration is a `partial struct`, so you can add to the default implementation by either emitting or manually writing your own `partial struct` with the same name.
13+
14+
If you wish to modify the implementation at a fundamental level, you can replace this declaration with your own.
15+
16+
## Generated code
17+
18+
At the time of writing, this is the C# code generated for this declaration:
19+
20+
```csharp
21+
[StructLayout(LayoutKind.Sequential)]
22+
public readonly partial struct NativeBoolean : IComparable, IComparable<bool>, IEquatable<bool>, IComparable<NativeBoolean>, IEquatable<NativeBoolean>
23+
{
24+
private readonly byte Value;
25+
26+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
27+
public static implicit operator bool(NativeBoolean b)
28+
=> Unsafe.As<NativeBoolean, bool>(ref b);
29+
30+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
31+
public static implicit operator NativeBoolean(bool b)
32+
=> Unsafe.As<bool, NativeBoolean>(ref b);
33+
34+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
35+
public override int GetHashCode()
36+
=> Unsafe.As<byte, bool>(ref Unsafe.AsRef(in Value)).GetHashCode();
37+
38+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
39+
public override string ToString()
40+
=> Unsafe.As<byte, bool>(ref Unsafe.AsRef(in Value)).ToString();
41+
42+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
43+
public string ToString(IFormatProvider? provider)
44+
=> Unsafe.As<byte, bool>(ref Unsafe.AsRef(in Value)).ToString(provider);
45+
46+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
47+
public bool TryFormat(Span<char> destination, out int charsWritten)
48+
=> Unsafe.As<byte, bool>(ref Unsafe.AsRef(in Value)).TryFormat(destination, out charsWritten);
49+
50+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
51+
public override bool Equals(object? obj)
52+
=> obj switch
53+
{
54+
bool boolean => this == boolean,
55+
NativeBoolean nativeBool => this == nativeBool,
56+
_ => false
57+
};
58+
59+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
60+
public bool Equals(bool other)
61+
=> this == other;
62+
63+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
64+
public bool Equals(NativeBoolean other)
65+
=> this == other;
66+
67+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
68+
public int CompareTo(object? obj)
69+
=> Unsafe.As<byte, bool>(ref Unsafe.AsRef(in Value)).CompareTo(obj);
70+
71+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
72+
public int CompareTo(bool value)
73+
=> Unsafe.As<byte, bool>(ref Unsafe.AsRef(in Value)).CompareTo(value);
74+
75+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
76+
public int CompareTo(NativeBoolean value)
77+
=> CompareTo(Unsafe.As<NativeBoolean, bool>(ref value));
78+
}
79+
```
80+
81+
This implementation is designed to incur as little performance overhead as possible. ([#110](https://github.com/InfectedLibraries/Biohazrd/issues/110) tracks investigating/reporting the .NET runtime failing to enregister this struct when it could/should.)
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
`NativeCharDeclaration`
2+
===================================================================================================
3+
4+
<small>\[[Transformation Source](../../Biohazrd.CSharp/#Declarations/NativeCharDeclaration.cs)\]</small>
5+
6+
This declaration represents the `NativeChar` type synthesized as needed by [`WrapNonBlittableTypesWhereNecessaryTransformation`](../BuiltinTransformations/WrapNonBlittableTypesWhereNecessaryTransformation.md).
7+
8+
## Interacting with this declarations
9+
10+
Your can rename this declaration if you wish to rename the generated type.
11+
12+
The emitted declaration is a `partial struct`, so you can add to the default implementation by either emitting or manually writing your own `partial struct` with the same name.
13+
14+
If you wish to modify the implementation at a fundamental level, you can replace this declaration with your own.
15+
16+
## Generated code
17+
18+
At the time of writing, this is the C# code generated for this declaration:
19+
20+
```csharp
21+
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
22+
public readonly partial struct NativeChar : IComparable, IComparable<char>, IEquatable<char>, IComparable<NativeChar>, IEquatable<NativeChar>
23+
{
24+
private readonly char Value;
25+
26+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
27+
private NativeChar(char value)
28+
=> Value = value;
29+
30+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
31+
public static implicit operator char(NativeChar c)
32+
=> c.Value;
33+
34+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
35+
public static implicit operator NativeChar(char c)
36+
=> new NativeChar(c);
37+
38+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
39+
public static bool operator ==(NativeChar a, NativeChar b)
40+
=> a.Value == b.Value;
41+
42+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
43+
public static bool operator !=(NativeChar a, NativeChar b)
44+
=> a.Value != b.Value;
45+
46+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
47+
public static bool operator ==(char a, NativeChar b)
48+
=> a == b.Value;
49+
50+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
51+
public static bool operator !=(char a, NativeChar b)
52+
=> a != b.Value;
53+
54+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
55+
public static bool operator ==(NativeChar a, char b)
56+
=> a.Value == b;
57+
58+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
59+
public static bool operator !=(NativeChar a, char b)
60+
=> a.Value != b;
61+
62+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
63+
public override int GetHashCode()
64+
=> Value.GetHashCode();
65+
66+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
67+
public override bool Equals(object? obj)
68+
=> obj switch
69+
{
70+
char character => this == character,
71+
NativeChar nativeChar => this == nativeChar,
72+
_ => false
73+
};
74+
75+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
76+
public bool Equals(char other)
77+
=> this == other;
78+
79+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
80+
public bool Equals(NativeChar other)
81+
=> this == other;
82+
83+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
84+
public int CompareTo(object? obj)
85+
=> Value.CompareTo(obj);
86+
87+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
88+
public int CompareTo(char other)
89+
=> Value.CompareTo(other);
90+
91+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
92+
public int CompareTo(NativeChar value)
93+
=> Value.CompareTo(value.Value);
94+
95+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
96+
public override string ToString()
97+
=> Value.ToString();
98+
99+
[MethodImpl(MethodImplOptions.AggressiveInlining)]
100+
public string ToString(IFormatProvider? provider)
101+
=> Value.ToString(provider);
102+
}
103+
```
104+
105+
This implementation is designed to incur as little performance overhead as possible. ([#110](https://github.com/InfectedLibraries/Biohazrd/issues/110) tracks investigating/reporting the .NET runtime failing to enregister this struct when it could/should.)

docs/BuiltInDeclarations/Readme.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
Built-in Declarations
2+
===================================================================================================
3+
4+
Declarations make up the backbone of how Biohazrd translates your C/C++ code, but they also represent your interop library in an abstract manner.
5+
6+
Below is a list of the various declaration types built in to Biohazrd. Entries marked as 🚧 are still a work-in-progress.
7+
8+
* 🚧 [`TranslatedBaseField`](TranslatedBaseField.md)
9+
* 🚧 [`TranslatedBitField`](TranslatedBitField.md)
10+
* 🚧 [`TranslatedDeclaration`](TranslatedDeclaration.md)
11+
* 🚧 [`TranslatedEnum`](TranslatedEnum.md)
12+
* 🚧 [`TranslatedEnumConstant`](TranslatedEnumConstant.md)
13+
* 🚧 [`TranslatedField`](TranslatedField.md)
14+
* 🚧 [`TranslatedFunction`](TranslatedFunction.md)
15+
* 🚧 [`TranslatedNormalField`](TranslatedNormalField.md)
16+
* 🚧 [`TranslatedParameter`](TranslatedParameter.md)
17+
* 🚧 [`TranslatedRecord`](TranslatedRecord.md)
18+
* 🚧 [`TranslatedStaticField`](TranslatedStaticField.md)
19+
* 🚧 [`TranslatedTypedef`](TranslatedTypedef.md)
20+
* 🚧 [`TranslatedUndefinedRecord`](TranslatedUndefinedRecord.md)
21+
* 🚧 [`TranslatedUnimplementedField`](TranslatedUnimplementedField.md)
22+
* 🚧 [`TranslatedUnsupportedDeclaration`](TranslatedUnsupportedDeclaration.md)
23+
* 🚧 [`TranslatedVTable`](TranslatedVTable.md)
24+
* 🚧 [`TranslatedVTableEntry`](TranslatedVTableEntry.md)
25+
* 🚧 [`TranslatedVTableField`](TranslatedVTableField.md)
26+
* **C#-specific**
27+
* 🚧 [`ConstantArrayTypeDeclaration`](ConstantArrayTypeDeclaration.md)
28+
* [`NativeBooleanDeclaration`](NativeBooleanDeclaration.md)
29+
* [`NativeCharDeclaration`](NativeCharDeclaration.md)
30+
* 🚧 [`SynthesizedLooseDeclarationsTypeDeclaration`](SynthesizedLooseDeclarationsTypeDeclaration.md)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
`SynthesizedLooseDeclarationsTypeDeclaration`
2+
===================================================================================================
3+
4+
<small>\[[Transformation Source](../../Biohazrd.CSharp/#Declarations/SynthesizedLooseDeclarationsTypeDeclaration.cs)\]</small>
5+
6+
TODO
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
`TranslatedBaseField`
2+
===================================================================================================
3+
4+
<small>\[[Transformation Source](../../Biohazrd/#Declarations/TranslatedBaseField.cs)\]</small>
5+
6+
TODO
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
`TranslatedBitField`
2+
===================================================================================================
3+
4+
<small>\[[Transformation Source](../../Biohazrd/#Declarations/TranslatedBitField.cs)\]</small>
5+
6+
TODO
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
`TranslatedDeclaration`
2+
===================================================================================================
3+
4+
<small>\[[Transformation Source](../../Biohazrd/#Declarations/TranslatedDeclaration.cs)\]</small>
5+
6+
TODO
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
`TranslatedEnum`
2+
===================================================================================================
3+
4+
<small>\[[Transformation Source](../../Biohazrd/#Declarations/TranslatedEnum.cs)\]</small>
5+
6+
TODO

0 commit comments

Comments
 (0)