aboutsummaryrefslogtreecommitdiffstatsci
diff options
context:
space:
mode:
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>2020-03-02 11:29:11 +0100
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>2020-03-02 11:29:11 +0100
commit392b9e451e2828badbb4db364f5790f5629dba7f (patch)
tree6151fb157b3420754106c4bbb387282568198bdb
parent1f224658732670624334d73de79353283e48440f (diff)
add public string property to fetch utf8 string stored as private fixed byte array
-rw-r--r--VK/vulkan.csproj2
-rw-r--r--vk.generator/Program.cs24
2 files changed, 19 insertions, 7 deletions
diff --git a/VK/vulkan.csproj b/VK/vulkan.csproj
index 823f6b7..7573b6a 100644
--- a/VK/vulkan.csproj
+++ b/VK/vulkan.csproj
@@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
- <AssemblyVersion>0.2.2</AssemblyVersion>
+ <AssemblyVersion>0.2.2.1</AssemblyVersion>
<AssemblyName>VK</AssemblyName>
<Description>Low level vulkan bindings for .net</Description>
<Product>VK</Product>
diff --git a/vk.generator/Program.cs b/vk.generator/Program.cs
index f1c2026..43fa2a0 100644
--- a/vk.generator/Program.cs
+++ b/vk.generator/Program.cs
@@ -427,12 +427,24 @@ namespace vk.generator {
if (!string.IsNullOrEmpty (mb.fixedArray)) {
int dim = 0;
- if (valueTypes.Contains (typeStr)) {
- if (int.TryParse (mb.fixedArray, out dim)) {
- tw.WriteLine ($"public fixed {typeStr} {mb.Name}[{dim}];");
- } else {
- tw.WriteLine ($"public fixed {typeStr} {mb.Name}[(int)Vk.{EnumerantValue.GetCSName(mb.fixedArray,null)}];");
- }
+ if (valueTypes.Contains (typeStr)) {
+ string strSize = int.TryParse (mb.fixedArray, out dim) ? dim.ToString() : $"(int)Vk.{EnumerantValue.GetCSName (mb.fixedArray, null)}";
+ if (mb.typedef.Name == "char") {
+ tw.WriteLine ($"fixed {typeStr} _{mb.Name}[{strSize}];");
+ tw.WriteLine ($"public string {mb.Name} {{");
+ tw.Indent++;
+ tw.WriteLine ($"get {{");
+ tw.Indent++;
+ tw.WriteLine ($"fixed ({typeStr}* tmp = _{mb.Name})");
+ tw.Indent++;
+ tw.WriteLine ($"return System.Text.Encoding.UTF8.GetString (tmp, {strSize});");
+ //tw.WriteLine ($"set {{ _{mb.Name} = ({typeStr})value; }}");
+ tw.Indent-=2;
+ tw.WriteLine (@"}");
+ tw.Indent--;
+ tw.WriteLine (@"}");
+ } else
+ tw.WriteLine ($"public fixed {typeStr} {mb.Name}[{strSize}];");
continue;
}
if (int.TryParse (mb.fixedArray, out dim)) {