-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathModule#FFI.verified.cs
More file actions
740 lines (649 loc) · 25.7 KB
/
Module#FFI.verified.cs
File metadata and controls
740 lines (649 loc) · 25.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
//HintName: FFI.cs
// <auto-generated />
#nullable enable
// The runtime already defines SpacetimeDB.Internal.LocalReadOnly in Runtime\Internal\Module.cs as an empty partial type.
// This is needed so every module build doesn't generate a full LocalReadOnly type, but just adds on to the existing.
// We extend it here with generated table accessors, and just need to suppress the duplicate-type warning.
#pragma warning disable CS0436
#pragma warning disable STDB_UNSTABLE
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Internal = SpacetimeDB.Internal;
using TxContext = SpacetimeDB.Internal.TxContext;
namespace SpacetimeDB
{
public readonly struct DemoTableCols
{
public readonly global::SpacetimeDB.Col<global::DemoTable, int> Id;
public readonly global::SpacetimeDB.Col<global::DemoTable, int> Value;
internal DemoTableCols(string tableName)
{
Id = new global::SpacetimeDB.Col<global::DemoTable, int>(tableName, "Id");
Value = new global::SpacetimeDB.Col<global::DemoTable, int>(tableName, "Value");
}
}
public readonly struct DemoTableIxCols
{
public readonly global::SpacetimeDB.IxCol<global::DemoTable, int> Id;
internal DemoTableIxCols(string tableName)
{
Id = new global::SpacetimeDB.IxCol<global::DemoTable, int>(tableName, "Id");
}
}
public readonly partial struct QueryBuilder
{
public global::SpacetimeDB.Table<
global::DemoTable,
DemoTableCols,
DemoTableIxCols
> DemoTable() =>
new("DemoTable", new DemoTableCols("DemoTable"), new DemoTableIxCols("DemoTable"));
}
public static class Handlers { }
public sealed record ReducerContext : DbContext<Local>, Internal.IReducerContext
{
public readonly Identity Sender;
public readonly ConnectionId? ConnectionId;
public readonly Random Rng;
public readonly Timestamp Timestamp;
public readonly AuthCtx SenderAuth;
// **Note:** must be 0..=u32::MAX
internal int CounterUuid;
public Identity DatabaseIdentity => Internal.IReducerContext.GetDatabaseIdentity();
// We keep this property for compatibility with existing module code.
[global::System.Obsolete(
"ReducerContext.Identity is deprecated. Use DatabaseIdentity instead."
)]
public Identity Identity => DatabaseIdentity;
internal ReducerContext(
Identity identity,
ConnectionId? connectionId,
Random random,
Timestamp time,
AuthCtx? senderAuth = null
)
{
Sender = identity;
ConnectionId = connectionId;
Rng = random;
Timestamp = time;
SenderAuth = senderAuth ?? AuthCtx.BuildFromSystemTables(connectionId, identity);
CounterUuid = 0;
}
/// <summary>
/// Create a new random <see cref="Uuid"/> `v4` using the built-in RNG.
/// </summary>
/// <remarks>
/// This method fills the random bytes using the context RNG.
/// </remarks>
/// <example>
/// <code>
/// var uuid = ctx.NewUuidV4();
/// Log.Info(uuid);
/// </code>
/// </example>
public Uuid NewUuidV4()
{
var bytes = new byte[16];
Rng.NextBytes(bytes);
return Uuid.FromRandomBytesV4(bytes);
}
/// <summary>
/// Create a new sortable <see cref="Uuid"/> `v7` using the built-in RNG, monotonic counter,
/// and timestamp.
/// </summary>
/// <returns>
/// A newly generated <see cref="Uuid"/> `v7` that is monotonically ordered
/// and suitable for use as a primary key or for ordered storage.
/// </returns>
/// <exception cref="Exception">
/// Thrown if <see cref="Uuid"/> generation fails.
/// </exception>
/// <example>
/// <code>
/// [SpacetimeDB.Reducer]
/// public static Guid GenerateUuidV7(ReducerContext ctx)
/// {
/// Guid uuid = ctx.NewUuidV7();
/// Log.Info(uuid);
/// }
/// </code>
/// </example>
public Uuid NewUuidV7()
{
var bytes = new byte[4];
Rng.NextBytes(bytes);
return Uuid.FromCounterV7(ref CounterUuid, Timestamp, bytes);
}
}
public sealed partial class ProcedureContext : global::SpacetimeDB.ProcedureContextBase
{
private readonly Local _db = new();
internal ProcedureContext(
Identity identity,
ConnectionId? connectionId,
Random random,
Timestamp time
)
: base(identity, connectionId, random, time) { }
protected override global::SpacetimeDB.LocalBase CreateLocal() => _db;
protected override global::SpacetimeDB.ProcedureTxContextBase CreateTxContext(
Internal.TxContext inner
) => _cached ??= new ProcedureTxContext(inner);
private ProcedureTxContext? _cached;
[Experimental("STDB_UNSTABLE")]
public Local Db => _db;
[Experimental("STDB_UNSTABLE")]
public TResult WithTx<TResult>(Func<ProcedureTxContext, TResult> body) =>
base.WithTx(tx => body((ProcedureTxContext)tx));
[Experimental("STDB_UNSTABLE")]
public TxOutcome<TResult> TryWithTx<TResult, TError>(
Func<ProcedureTxContext, Result<TResult, TError>> body
)
where TError : Exception => base.TryWithTx(tx => body((ProcedureTxContext)tx));
/// <summary>
/// Create a new random <see cref="Uuid"/> `v4` using the built-in RNG.
/// </summary>
/// <remarks>
/// This method fills the random bytes using the context RNG.
/// </remarks>
/// <example>
/// <code>
/// var uuid = ctx.NewUuidV4();
/// Log.Info(uuid);
/// </code>
/// </example>
public Uuid NewUuidV4()
{
var bytes = new byte[16];
Rng.NextBytes(bytes);
return Uuid.FromRandomBytesV4(bytes);
}
/// <summary>
/// Create a new sortable <see cref="Uuid"/> `v7` using the built-in RNG, monotonic counter,
/// and timestamp.
/// </summary>
/// <returns>
/// A newly generated <see cref="Uuid"/> `v7` that is monotonically ordered
/// and suitable for use as a primary key or for ordered storage.
/// </returns>
/// <exception cref="Exception">
/// Thrown if UUID generation fails.
/// </exception>
/// <example>
/// <code>
/// [SpacetimeDB.Procedure]
/// public static Guid GenerateUuidV7(ReducerContext ctx)
/// {
/// Guid uuid = ctx.NewUuidV7();
/// Log.Info(uuid);
/// }
/// </code>
/// </example>
public Uuid NewUuidV7()
{
var bytes = new byte[4];
Rng.NextBytes(bytes);
return Uuid.FromCounterV7(ref CounterUuid, Timestamp, bytes);
}
}
public sealed partial class HandlerContext : global::SpacetimeDB.HandlerContextBase
{
private readonly Local _db = new();
internal HandlerContext(Random random, Timestamp time)
: base(random, time) { }
protected override global::SpacetimeDB.LocalBase CreateLocal() => _db;
protected override global::SpacetimeDB.HandlerTxContextBase CreateTxContext(
Internal.TxContext inner
) => _cached ??= new HandlerTxContext(inner);
private HandlerTxContext? _cached;
[Experimental("STDB_UNSTABLE")]
public TResult WithTx<TResult>(Func<HandlerTxContext, TResult> body) =>
base.WithTx(tx => body((HandlerTxContext)tx));
[Experimental("STDB_UNSTABLE")]
public TxOutcome<TResult> TryWithTx<TResult, TError>(
Func<HandlerTxContext, Result<TResult, TError>> body
)
where TError : Exception => base.TryWithTx(tx => body((HandlerTxContext)tx));
public Uuid NewUuidV4()
{
var bytes = new byte[16];
Rng.NextBytes(bytes);
return Uuid.FromRandomBytesV4(bytes);
}
public Uuid NewUuidV7()
{
var bytes = new byte[4];
Rng.NextBytes(bytes);
return Uuid.FromCounterV7(ref CounterUuid, Timestamp, bytes);
}
}
[Experimental("STDB_UNSTABLE")]
public sealed class ProcedureTxContext : global::SpacetimeDB.ProcedureTxContextBase
{
internal ProcedureTxContext(Internal.TxContext inner)
: base(inner) { }
public new Local Db => (Local)base.Db;
}
[Experimental("STDB_UNSTABLE")]
public sealed class HandlerTxContext : global::SpacetimeDB.HandlerTxContextBase
{
internal HandlerTxContext(Internal.TxContext inner)
: base(inner) { }
public new Local Db => (Local)base.Db;
}
public sealed class Local : global::SpacetimeDB.LocalBase
{
public global::SpacetimeDB.Internal.TableHandles.DemoTable DemoTable => new();
}
public sealed record ViewContext : DbContext<Internal.LocalReadOnly>, Internal.IViewContext
{
public Identity Sender { get; }
public QueryBuilder From => default;
internal ViewContext(Identity sender, Internal.LocalReadOnly db)
: base(db)
{
Sender = sender;
}
}
public sealed record AnonymousViewContext
: DbContext<Internal.LocalReadOnly>,
Internal.IAnonymousViewContext
{
public QueryBuilder From => default;
internal AnonymousViewContext(Internal.LocalReadOnly db)
: base(db) { }
}
}
namespace SpacetimeDB.Internal.TableHandles
{
public readonly struct DemoTable
: global::SpacetimeDB.Internal.ITableView<DemoTable, global::DemoTable>
{
public static global::DemoTable ReadGenFields(
System.IO.BinaryReader reader,
global::DemoTable row
)
{
return row;
}
public static SpacetimeDB.Internal.RawTableDefV10 MakeTableDesc(
SpacetimeDB.BSATN.ITypeRegistrar registrar
) =>
new(
SourceName: nameof(DemoTable),
ProductTypeRef: (uint)
new global::DemoTable.BSATN().GetAlgebraicType(registrar).Ref_,
PrimaryKey: [0],
Indexes:
[
new(
SourceName: "DemoTable_Id_idx_btree",
AccessorName: "Id",
Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0])
),
new(
SourceName: "DemoTable_Id_idx_btree",
AccessorName: "ById",
Algorithm: new SpacetimeDB.Internal.RawIndexAlgorithm.BTree([0])
)
],
Constraints:
[
global::SpacetimeDB.Internal.ITableView<
DemoTable,
global::DemoTable
>.MakeUniqueConstraint(0)
],
Sequences: [],
TableType: SpacetimeDB.Internal.TableType.User,
TableAccess: SpacetimeDB.Internal.TableAccess.Public,
DefaultValues: [],
IsEvent: false
);
public static SpacetimeDB.Internal.RawScheduleDefV10? MakeScheduleDesc() => null;
/// <summary>
/// Returns the number of rows in this table.
///
/// This reads datastore metadata, so it runs in constant time.
/// It also takes into account modifications by the current transaction.
/// </summary>
public ulong Count =>
global::SpacetimeDB.Internal.ITableView<DemoTable, global::DemoTable>.DoCount();
public IEnumerable<global::DemoTable> Iter() =>
global::SpacetimeDB.Internal.ITableView<DemoTable, global::DemoTable>.DoIter();
public global::DemoTable Insert(global::DemoTable row) =>
global::SpacetimeDB.Internal.ITableView<DemoTable, global::DemoTable>.DoInsert(row);
public bool Delete(global::DemoTable row) =>
global::SpacetimeDB.Internal.ITableView<DemoTable, global::DemoTable>.DoDelete(row);
public ulong Clear() =>
global::SpacetimeDB.Internal.ITableView<DemoTable, global::DemoTable>.DoClear();
public sealed class IdUniqueIndex
: UniqueIndex<DemoTable, global::DemoTable, int, SpacetimeDB.BSATN.I32>
{
internal IdUniqueIndex()
: base("DemoTable_Id_idx_btree") { }
// Important: don't move this to the base class.
// C# generics don't play well with nullable types and can't accept both struct-type-based and class-type-based
// `globalName` in one generic definition, leading to buggy `Row?` expansion for either one or another.
public global::DemoTable? Find(int key) => FindSingle(key);
public global::DemoTable Update(global::DemoTable row) => DoUpdate(row);
}
public IdUniqueIndex Id => new();
public sealed class ByIdIndex()
: SpacetimeDB.Internal.IndexBase<global::DemoTable>("DemoTable_Id_idx_btree")
{
public IEnumerable<global::DemoTable> Filter(int Id) =>
DoFilter(new SpacetimeDB.Internal.BTreeIndexBounds<int, SpacetimeDB.BSATN.I32>(Id));
public ulong Delete(int Id) =>
DoDelete(new SpacetimeDB.Internal.BTreeIndexBounds<int, SpacetimeDB.BSATN.I32>(Id));
public IEnumerable<global::DemoTable> Filter(global::SpacetimeDB.Bound<int> Id) =>
DoFilter(new SpacetimeDB.Internal.BTreeIndexBounds<int, SpacetimeDB.BSATN.I32>(Id));
public ulong Delete(global::SpacetimeDB.Bound<int> Id) =>
DoDelete(new SpacetimeDB.Internal.BTreeIndexBounds<int, SpacetimeDB.BSATN.I32>(Id));
}
public ByIdIndex ById => new();
}
}
sealed class demo_viewViewDispatcher : global::SpacetimeDB.Internal.IView
{
public SpacetimeDB.Internal.RawViewDefV10 MakeViewDef(
SpacetimeDB.BSATN.ITypeRegistrar registrar
) =>
new global::SpacetimeDB.Internal.RawViewDefV10(
SourceName: "demo_view",
Index: 0,
IsPublic: true,
IsAnonymous: false,
Params: [],
ReturnType: new SpacetimeDB.BSATN.List<DemoTable, DemoTable.BSATN>().GetAlgebraicType(
registrar
)
);
public byte[] Invoke(
System.IO.BinaryReader reader,
global::SpacetimeDB.Internal.IViewContext ctx
)
{
try
{
var returnValue = Reducers.DemoView((SpacetimeDB.ViewContext)ctx);
var listSerializer = new SpacetimeDB.BSATN.List<DemoTable, DemoTable.BSATN>();
var listValue = global::System.Linq.Enumerable.ToList(returnValue);
var header = new global::SpacetimeDB.Internal.ViewResultHeader.RowData(default);
var headerRW = new global::SpacetimeDB.Internal.ViewResultHeader.BSATN();
using var output = new System.IO.MemoryStream();
using var writer = new System.IO.BinaryWriter(output);
headerRW.Write(writer, header);
listSerializer.Write(writer, listValue);
return output.ToArray();
}
catch (System.Exception e)
{
global::SpacetimeDB.Log.Error("Error in view 'demo_view': " + e);
throw;
}
}
}
namespace SpacetimeDB.Internal.ViewHandles
{
public sealed class DemoTableReadOnly
: global::SpacetimeDB.Internal.ReadOnlyTableView<global::DemoTable>
{
internal DemoTableReadOnly()
: base("DemoTable") { }
/// <summary>
/// Returns the number of rows in this table.
///
/// This reads datastore metadata, so it runs in constant time.
/// It also takes into account modifications by the current transaction.
/// </summary>
public ulong Count => DoCount();
public sealed class IdIndex
: global::SpacetimeDB.Internal.ReadOnlyUniqueIndex<
global::SpacetimeDB.Internal.ViewHandles.DemoTableReadOnly,
global::DemoTable,
int,
SpacetimeDB.BSATN.I32
>
{
internal IdIndex()
: base("DemoTable_Id_idx_btree") { }
public global::DemoTable? Find(int key) => FindSingle(key);
}
public IdIndex Id => new();
public sealed class ByIdIndex
: global::SpacetimeDB.Internal.ReadOnlyIndexBase<global::DemoTable>
{
internal ByIdIndex()
: base("DemoTable_Id_idx_btree") { }
public IEnumerable<global::DemoTable> Filter(int Id) =>
DoFilter(
new global::SpacetimeDB.Internal.BTreeIndexBounds<int, SpacetimeDB.BSATN.I32>(
Id
)
);
public IEnumerable<global::DemoTable> Filter(global::SpacetimeDB.Bound<int> Id) =>
DoFilter(
new global::SpacetimeDB.Internal.BTreeIndexBounds<int, SpacetimeDB.BSATN.I32>(
Id
)
);
}
public ByIdIndex ById => new();
}
}
namespace SpacetimeDB.Internal
{
public sealed partial class LocalReadOnly
{
public global::SpacetimeDB.Internal.ViewHandles.DemoTableReadOnly DemoTable => new();
}
}
static class ModuleRegistration
{
class DemoReducer : SpacetimeDB.Internal.IReducer
{
private static readonly SpacetimeDB.BSATN.I32 valueRW = new();
public SpacetimeDB.Internal.RawReducerDefV10 MakeReducerDef(
SpacetimeDB.BSATN.ITypeRegistrar registrar
) =>
new(
SourceName: nameof(DemoReducer),
Params: [new("value", valueRW.GetAlgebraicType(registrar))],
Visibility: SpacetimeDB.Internal.FunctionVisibility.ClientCallable,
OkReturnType: SpacetimeDB.BSATN.AlgebraicType.Unit,
ErrReturnType: new SpacetimeDB.BSATN.AlgebraicType.String(default)
);
public SpacetimeDB.Internal.Lifecycle? Lifecycle => null;
public void Invoke(BinaryReader reader, SpacetimeDB.Internal.IReducerContext ctx)
{
Reducers.DemoReducer((SpacetimeDB.ReducerContext)ctx, valueRW.Read(reader));
}
}
class DemoProcedure : SpacetimeDB.Internal.IProcedure
{
public SpacetimeDB.Internal.RawProcedureDefV10 MakeProcedureDef(
SpacetimeDB.BSATN.ITypeRegistrar registrar
) =>
new(
SourceName: nameof(DemoProcedure),
Params: [],
ReturnType: SpacetimeDB.BSATN.AlgebraicType.Unit,
Visibility: SpacetimeDB.Internal.FunctionVisibility.ClientCallable
);
public byte[] Invoke(BinaryReader reader, SpacetimeDB.Internal.IProcedureContext ctx)
{
Reducers.DemoProcedure((SpacetimeDB.ProcedureContext)ctx);
return System.Array.Empty<byte>();
}
}
public static List<T> ToListOrEmpty<T>(T? value)
where T : struct => value is null ? new List<T>() : new List<T> { value.Value };
public static List<T> ToListOrEmpty<T>(T? value)
where T : class => value is null ? new List<T>() : new List<T> { value };
#if EXPERIMENTAL_WASM_AOT
// In AOT mode we're building a library.
// Main method won't be called automatically, so we need to export it as a preinit function.
[UnmanagedCallersOnly(EntryPoint = "__preinit__10_init_csharp")]
#else
// Prevent trimming of FFI exports that are invoked from C and not visible to C# trimmer.
[DynamicDependency(
DynamicallyAccessedMemberTypes.PublicMethods,
typeof(SpacetimeDB.Internal.Module)
)]
#endif
public static void Main()
{
SpacetimeDB.Internal.Module.SetReducerContextConstructor(
(identity, connectionId, random, time) =>
new SpacetimeDB.ReducerContext(identity, connectionId, random, time)
);
SpacetimeDB.Internal.Module.SetViewContextConstructor(
identity => new SpacetimeDB.ViewContext(
identity,
new SpacetimeDB.Internal.LocalReadOnly()
)
);
SpacetimeDB.Internal.Module.SetAnonymousViewContextConstructor(
() => new SpacetimeDB.AnonymousViewContext(new SpacetimeDB.Internal.LocalReadOnly())
);
SpacetimeDB.Internal.Module.SetProcedureContextConstructor(
(identity, connectionId, random, time) =>
new SpacetimeDB.ProcedureContext(identity, connectionId, random, time)
);
SpacetimeDB.Internal.Module.SetCaseConversionPolicy(
SpacetimeDB.CaseConversionPolicy.SnakeCase
);
SpacetimeDB.Internal.Module.RegisterExplicitTableName("DemoTable", "canonical_table");
SpacetimeDB.Internal.Module.RegisterExplicitFunctionName(
"DemoReducer",
"canonical_reducer"
);
SpacetimeDB.Internal.Module.RegisterExplicitFunctionName(
"DemoProcedure",
"canonical_procedure"
);
SpacetimeDB.Internal.Module.RegisterExplicitFunctionName("demo_view", "canonical_view");
SpacetimeDB.Internal.Module.RegisterExplicitIndexName(
"DemoTable_Id_idx_btree",
"canonical_index"
);
SpacetimeDB.Internal.Module.SetHandlerContextConstructor(
(random, time) => new SpacetimeDB.HandlerContext(random, time)
);
var __memoryStream = new MemoryStream();
var __writer = new BinaryWriter(__memoryStream);
SpacetimeDB.Internal.Module.RegisterReducer<DemoReducer>();
SpacetimeDB.Internal.Module.RegisterProcedure<DemoProcedure>();
// IMPORTANT: The order in which we register views matters.
// It must correspond to the order in which we call `GenerateDispatcherClass`.
// See the comment on `GenerateDispatcherClass` for more explanation.
SpacetimeDB.Internal.Module.RegisterView<demo_viewViewDispatcher>();
SpacetimeDB.Internal.Module.RegisterTable<
global::DemoTable,
SpacetimeDB.Internal.TableHandles.DemoTable
>();
}
// Exports only work from the main assembly, so we need to generate forwarding methods.
#if EXPERIMENTAL_WASM_AOT
[UnmanagedCallersOnly(EntryPoint = "__describe_module__")]
public static void __describe_module__(SpacetimeDB.Internal.BytesSink d) =>
SpacetimeDB.Internal.Module.__describe_module__(d);
[UnmanagedCallersOnly(EntryPoint = "__call_reducer__")]
public static SpacetimeDB.Internal.Errno __call_reducer__(
uint id,
ulong sender_0,
ulong sender_1,
ulong sender_2,
ulong sender_3,
ulong conn_id_0,
ulong conn_id_1,
SpacetimeDB.Timestamp timestamp,
SpacetimeDB.Internal.BytesSource args,
SpacetimeDB.Internal.BytesSink error
) =>
SpacetimeDB.Internal.Module.__call_reducer__(
id,
sender_0,
sender_1,
sender_2,
sender_3,
conn_id_0,
conn_id_1,
timestamp,
args,
error
);
[UnmanagedCallersOnly(EntryPoint = "__call_procedure__")]
public static SpacetimeDB.Internal.Errno __call_procedure__(
uint id,
ulong sender_0,
ulong sender_1,
ulong sender_2,
ulong sender_3,
ulong conn_id_0,
ulong conn_id_1,
SpacetimeDB.Timestamp timestamp,
SpacetimeDB.Internal.BytesSource args,
SpacetimeDB.Internal.BytesSink result_sink
) =>
SpacetimeDB.Internal.Module.__call_procedure__(
id,
sender_0,
sender_1,
sender_2,
sender_3,
conn_id_0,
conn_id_1,
timestamp,
args,
result_sink
);
[UnmanagedCallersOnly(EntryPoint = "__call_http_handler__")]
public static SpacetimeDB.Internal.Errno __call_http_handler__(
uint id,
SpacetimeDB.Timestamp timestamp,
SpacetimeDB.Internal.BytesSource request,
SpacetimeDB.Internal.BytesSource request_body,
SpacetimeDB.Internal.BytesSink response_sink,
SpacetimeDB.Internal.BytesSink response_body_sink
) =>
SpacetimeDB.Internal.Module.__call_http_handler__(
id,
timestamp,
request,
request_body,
response_sink,
response_body_sink
);
[UnmanagedCallersOnly(EntryPoint = "__call_view__")]
public static SpacetimeDB.Internal.Errno __call_view__(
uint id,
ulong sender_0,
ulong sender_1,
ulong sender_2,
ulong sender_3,
SpacetimeDB.Internal.BytesSource args,
SpacetimeDB.Internal.BytesSink sink
) =>
SpacetimeDB.Internal.Module.__call_view__(
id,
sender_0,
sender_1,
sender_2,
sender_3,
args,
sink
);
[UnmanagedCallersOnly(EntryPoint = "__call_view_anon__")]
public static SpacetimeDB.Internal.Errno __call_view_anon__(
uint id,
SpacetimeDB.Internal.BytesSource args,
SpacetimeDB.Internal.BytesSink sink
) => SpacetimeDB.Internal.Module.__call_view_anon__(id, args, sink);
#endif
}
#pragma warning restore STDB_UNSTABLE
#pragma warning restore CS0436