diff --git a/Cesium.Runtime/StdIoFunctions.cs b/Cesium.Runtime/StdIoFunctions.cs index 5b15dc89..bed592d3 100644 --- a/Cesium.Runtime/StdIoFunctions.cs +++ b/Cesium.Runtime/StdIoFunctions.cs @@ -1,5 +1,3 @@ -using System.IO; -using System.Runtime.InteropServices; #if NETSTANDARD using System.Text; #endif @@ -39,11 +37,11 @@ static StdIoFunctions() }); } - public static int PutS(CPtr str) + public static int PutS(byte* str) { try { - Console.WriteLine(RuntimeHelpers.Unmarshal(str.AsPtr())); + Console.WriteLine(RuntimeHelpers.Unmarshal(str)); return 0; } catch (Exception) // TODO[#154]: Exception handling. @@ -86,9 +84,9 @@ public static int PutC(byte character, void* stream) } } - public static int PrintF(CPtr str, VoidPtr varargs) + public static int PrintF(byte* str, VoidPtr varargs) { - var formatString = RuntimeHelpers.Unmarshal(str.AsPtr()); + var formatString = RuntimeHelpers.Unmarshal(str); if (formatString == null) { return -1; diff --git a/Cesium.Runtime/StdLibFunctions.cs b/Cesium.Runtime/StdLibFunctions.cs index c4880872..1739ef92 100644 --- a/Cesium.Runtime/StdLibFunctions.cs +++ b/Cesium.Runtime/StdLibFunctions.cs @@ -32,9 +32,9 @@ public static void SRand(uint seed) shared = new Random((int)seed); } - public static int System(CPtr command) + public static int System(byte* command) { - string? shellCommand = RuntimeHelpers.Unmarshal(command.AsPtr()); + string? shellCommand = RuntimeHelpers.Unmarshal(command); if (shellCommand is null) { return 8 /*ENOEXEC*/; diff --git a/Cesium.Runtime/StringFunctions.cs b/Cesium.Runtime/StringFunctions.cs index 1735697c..63fffc9f 100644 --- a/Cesium.Runtime/StringFunctions.cs +++ b/Cesium.Runtime/StringFunctions.cs @@ -11,17 +11,17 @@ namespace Cesium.Runtime; /// public static unsafe class StringFunctions { - public static nuint StrLen(CPtr str) + public static nuint StrLen(byte* str) { #if NETSTANDARD - if (str.AsPtr() == null) + if (str == null) { return 0; } Encoding encoding = Encoding.UTF8; int byteLength = 0; - byte* search = str.AsPtr(); + byte* search = str; while (*search != '\0') { byteLength++; @@ -31,7 +31,7 @@ public static nuint StrLen(CPtr str) int stringLength = encoding.GetCharCount(str.AsPtr(), byteLength); return (uint)stringLength; #else - return (uint)(Marshal.PtrToStringUTF8(str.AsIntPtr())?.Length ?? 0); + return (uint)(Marshal.PtrToStringUTF8((IntPtr)str)?.Length ?? 0); #endif } public static byte* StrCpy(byte* dest, byte* src)