Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Commit cda7b04

Browse files
committed
update after changes in unmanaged
1 parent fef1e71 commit cda7b04

10 files changed

Lines changed: 179 additions & 83 deletions

File tree

source/JSON/JSONArray.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ private Implementation(List<JSONProperty> elements)
281281
public static Implementation* Allocate()
282282
{
283283
List<JSONProperty> elements = new(4);
284-
ref Implementation value = ref Allocations.Allocate<Implementation>();
284+
ref Implementation value = ref MemoryAddress.Allocate<Implementation>();
285285
value = new(elements);
286286
fixed (Implementation* pointer = &value)
287287
{
@@ -291,7 +291,7 @@ private Implementation(List<JSONProperty> elements)
291291

292292
public static void Free(ref Implementation* array)
293293
{
294-
Allocations.ThrowIfNull(array);
294+
MemoryAddress.ThrowIfDefault(array);
295295

296296
for (uint i = 0; i < array->elements.Count; i++)
297297
{
@@ -300,7 +300,7 @@ public static void Free(ref Implementation* array)
300300
}
301301

302302
array->elements.Dispose();
303-
Allocations.Free(ref array);
303+
MemoryAddress.Free(ref array);
304304
}
305305
}
306306
}

source/JSON/JSONObject.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ private Implementation(List<JSONProperty> properties)
561561
public static Implementation* Allocate()
562562
{
563563
List<JSONProperty> properties = new(4);
564-
ref Implementation value = ref Allocations.Allocate<Implementation>();
564+
ref Implementation value = ref MemoryAddress.Allocate<Implementation>();
565565
value = new(properties);
566566
fixed (Implementation* pointer = &value)
567567
{
@@ -571,7 +571,7 @@ private Implementation(List<JSONProperty> properties)
571571

572572
public static void Free(ref Implementation* obj)
573573
{
574-
Allocations.ThrowIfNull(obj);
574+
MemoryAddress.ThrowIfDefault(obj);
575575

576576
uint count = obj->properties.Count;
577577
for (uint i = 0; i < count; i++)
@@ -581,7 +581,7 @@ public static void Free(ref Implementation* obj)
581581
}
582582

583583
obj->properties.Dispose();
584-
Allocations.Free(ref obj);
584+
MemoryAddress.Free(ref obj);
585585
}
586586
}
587587
}

source/JSON/JSONProperty.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Serialization.JSON
88
public struct JSONProperty : IDisposable
99
{
1010
private readonly Text name;
11-
private Allocation value;
11+
private MemoryAddress value;
1212
private uint length;
1313
private Type type;
1414

@@ -42,7 +42,7 @@ readonly get
4242
uint newLength = value.Length * sizeof(char);
4343
if (length < newLength)
4444
{
45-
Allocation.Resize(ref this.value, newLength);
45+
MemoryAddress.Resize(ref this.value, newLength);
4646
}
4747

4848
length = newLength;
@@ -115,7 +115,7 @@ public JSONProperty(USpan<char> name, USpan<char> text)
115115
{
116116
this.name = new(name);
117117
length = text.Length * sizeof(char);
118-
value = Allocation.Create(length);
118+
value = MemoryAddress.Allocate(length);
119119
value.Write(0, text);
120120
type = Type.Text;
121121
}
@@ -124,7 +124,7 @@ public JSONProperty(USpan<char> name, double number)
124124
{
125125
this.name = new(name);
126126
length = sizeof(double);
127-
value = Allocation.Create(length);
127+
value = MemoryAddress.Allocate(length);
128128
value.Write(0, number);
129129
type = Type.Number;
130130
}
@@ -133,7 +133,7 @@ public JSONProperty(USpan<char> name, bool boolean)
133133
{
134134
this.name = new(name);
135135
length = sizeof(bool);
136-
value = Allocation.Create(length);
136+
value = MemoryAddress.Allocate(length);
137137
value.Write(0, boolean);
138138
type = Type.Boolean;
139139
}
@@ -142,7 +142,7 @@ public unsafe JSONProperty(USpan<char> name, JSONObject obj)
142142
{
143143
this.name = new(name);
144144
length = (uint)sizeof(nint);
145-
value = Allocation.Create(length);
145+
value = MemoryAddress.Allocate(length);
146146
value.Write(0, obj.Address);
147147
type = Type.Object;
148148
}
@@ -151,7 +151,7 @@ public unsafe JSONProperty(USpan<char> name, JSONArray array)
151151
{
152152
this.name = new(name);
153153
length = (uint)sizeof(nint);
154-
value = Allocation.Create(length);
154+
value = MemoryAddress.Allocate(length);
155155
value.Write(0, array.Address);
156156
type = Type.Array;
157157
}

source/XML/ToStringFlags.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
3+
namespace Serialization.XML
4+
{
5+
[Flags]
6+
public enum ToStringFlags : byte
7+
{
8+
None = 0,
9+
CarriageReturn = 1,
10+
LineFeed = 2,
11+
RootSpacing = 4
12+
}
13+
}

source/XML/Token.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public readonly override string ToString()
2222
return $"Token(type: {type} position:{position} length:{length})";
2323
}
2424

25-
public unsafe readonly string ToString(XMLReader reader)
25+
public readonly string ToString(XMLReader reader)
2626
{
2727
using Text buffer = new(0);
2828
ToString(reader, buffer);

source/XML/XMLAttribute.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,8 @@ namespace Serialization.XML
99
private readonly Text name;
1010
private readonly Text value;
1111

12-
public readonly USpan<char> Name
13-
{
14-
get => name.AsSpan();
15-
set => name.CopyFrom(value);
16-
}
17-
18-
public readonly USpan<char> Value
19-
{
20-
get => value.AsSpan();
21-
set => value.CopyFrom(value);
22-
}
23-
12+
public readonly Text.Borrowed Name => name.Borrow();
13+
public readonly Text.Borrowed Value => value.Borrow();
2414
public readonly bool IsDisposed => name.IsDisposed;
2515

2616
public XMLAttribute(USpan<char> name, USpan<char> value)

0 commit comments

Comments
 (0)