ネイティブレーンで文字列パラメータをobjへ展開

このコミットが含まれているのは:
routersys committed 2026-06-30 23:38:26 +09:00
1 親 95598b1a88
コミット 58a5f59b19
4ファイル変更
+87 -25

検索条件に一致するファイルはありません

+24
ファイルの表示
@@ -43,6 +43,7 @@ namespace LuaScript.Engine
public bool Execute(
string script,
double[] fields,
IReadOnlyDictionary<string, string> stringParameters,
byte[] pixels,
int width,
int height,
@@ -79,6 +80,7 @@ namespace LuaScript.Engine
var view = _view!;
view.WriteArray(NativeProtocol.FieldsOffset, fields, 0, NativeProtocol.FieldCount);
WriteStringParameters(view, stringParameters);
view.Write(NativeProtocol.OffWidth, width);
view.Write(NativeProtocol.OffHeight, height);
view.Write(NativeProtocol.OffScriptLen, scriptBytes.Length);
@@ -147,6 +149,28 @@ namespace LuaScript.Engine
return true;
}
private static void WriteStringParameters(MemoryMappedViewAccessor view, IReadOnlyDictionary<string, string> stringParameters)
{
long basePos = NativeProtocol.StringParamsOffset;
long limit = basePos + NativeProtocol.StringParamsMax;
long pos = basePos + 4;
int count = 0;
foreach (var pair in stringParameters)
{
byte[] name = Encoding.UTF8.GetBytes(pair.Key);
byte[] value = Encoding.UTF8.GetBytes(pair.Value ?? string.Empty);
if (pos + 8 + name.Length + value.Length > limit)
break;
view.Write(pos, name.Length); pos += 4;
view.WriteArray(pos, name, 0, name.Length); pos += name.Length;
view.Write(pos, value.Length); pos += 4;
view.WriteArray(pos, value, 0, value.Length); pos += value.Length;
count++;
}
view.Write(basePos, count);
view.Write(NativeProtocol.OffStringParamsLen, (int)(pos - basePos));
}
private void DispatchCallback(
MemoryMappedViewAccessor view,
Func<string, int, SceneObjectInfo?> resolveObject,
+1 -1
ファイルの表示
@@ -621,7 +621,7 @@ namespace LuaScript
byte[] buffer = LoadInputPixels(bounds, imgW, imgH);
bool ok = _nativeWorker.Execute(
script, _nativeFields, buffer, imgW, imgH, NativeTimeoutMilliseconds,
script, _nativeFields, ctx.StringParameters, buffer, imgW, imgH, NativeTimeoutMilliseconds,
(tag, frame) => ctx.ResolveObject(tag, frame, out var info) ? info : null,
NativeLoadFigure,
NativeLoadText,