mirror of
https://github.com/roc-lang/roc.git
synced 2024-10-05 14:47:18 +03:00
Update more examples to stop using Nat
This commit is contained in:
parent
47561266d4
commit
6f354b9678
@ -29,8 +29,8 @@ hosted Effect
|
||||
generates Effect with [after, always, map]
|
||||
|
||||
# TODO: private types
|
||||
NodeId : Nat
|
||||
HandlerId : Nat
|
||||
NodeId : U64
|
||||
HandlerId : U64
|
||||
|
||||
# TODO: make these tag unions to avoid encoding/decoding standard names
|
||||
# but for now, this is much easier to code and debug!
|
||||
|
@ -131,7 +131,7 @@ initClientAppHelp = \json, app ->
|
||||
# In Roc, we maintain a matching List of virtual DOM nodes with the same indices.
|
||||
# They are both initialised separately, but use the same indexing algorithm.
|
||||
# (We *could* pass this data in as JSON from the HTML file, but it would roughly double the size of that HTML file!)
|
||||
indexNodes : { nodes : List RenderedNode, siblingIds : List Nat }, Html state -> { nodes : List RenderedNode, siblingIds : List Nat }
|
||||
indexNodes : { nodes : List RenderedNode, siblingIds : List U64 }, Html state -> { nodes : List RenderedNode, siblingIds : List U64 }
|
||||
indexNodes = \{ nodes, siblingIds }, unrendered ->
|
||||
when unrendered is
|
||||
Text content ->
|
||||
@ -667,11 +667,11 @@ expect
|
||||
html =
|
||||
Element "a" 43 [HtmlAttr "href" "https://www.roc-lang.org/"] [Text "Roc"]
|
||||
|
||||
actual : { nodes : List RenderedNode, siblingIds : List Nat }
|
||||
actual : { nodes : List RenderedNode, siblingIds : List U64 }
|
||||
actual =
|
||||
indexNodes { nodes: [], siblingIds: [] } html
|
||||
|
||||
expected : { nodes : List RenderedNode, siblingIds : List Nat }
|
||||
expected : { nodes : List RenderedNode, siblingIds : List U64 }
|
||||
expected = {
|
||||
nodes: [
|
||||
RenderedText "Roc",
|
||||
|
@ -32,7 +32,7 @@ Html state : [
|
||||
]
|
||||
|
||||
# The pre-calculated byte size of the rendered HTML string
|
||||
Size : Nat
|
||||
Size : U64
|
||||
|
||||
Attribute state : [
|
||||
EventListener Str (List CyclicStructureAccessor) (Handler state),
|
||||
@ -74,14 +74,14 @@ text = \content -> Text content
|
||||
none : Html state
|
||||
none = None
|
||||
|
||||
nodeSize : Html state -> Nat
|
||||
nodeSize : Html state -> U64
|
||||
nodeSize = \node ->
|
||||
when node is
|
||||
Text content -> Str.countUtf8Bytes content
|
||||
Element _ size _ _ -> size
|
||||
None -> 0
|
||||
|
||||
attrSize : Attribute state -> Nat
|
||||
attrSize : Attribute state -> U64
|
||||
attrSize = \attr ->
|
||||
when attr is
|
||||
EventListener _ _ _ -> 0
|
||||
|
@ -11,7 +11,7 @@ platform "client-side"
|
||||
|
||||
# Fields sorted by alignment, then alphabetically
|
||||
FromHost state initData : {
|
||||
eventHandlerId : Nat,
|
||||
eventHandlerId : U64,
|
||||
eventJsonList : List (List U8),
|
||||
eventPlatformState : Box (PlatformState state initData),
|
||||
initJson : List U8,
|
||||
|
@ -54,7 +54,7 @@ const RocList = extern struct {
|
||||
};
|
||||
|
||||
const FromHost = extern struct {
|
||||
eventHandlerId: usize,
|
||||
eventHandlerId: u64,
|
||||
eventJsonList: ?RocList,
|
||||
eventPlatformState: ?*anyopaque,
|
||||
initJson: RocList,
|
||||
@ -79,7 +79,7 @@ export fn roc_vdom_init(init_pointer: ?[*]u8, init_length: usize, init_capacity:
|
||||
.capacity = init_capacity,
|
||||
};
|
||||
const from_host = FromHost{
|
||||
.eventHandlerId = std.math.maxInt(usize),
|
||||
.eventHandlerId = std.math.maxInt(u64),
|
||||
.eventJsonList = null,
|
||||
.eventPlatformState = null,
|
||||
.initJson = init_json,
|
||||
@ -90,7 +90,7 @@ export fn roc_vdom_init(init_pointer: ?[*]u8, init_length: usize, init_capacity:
|
||||
}
|
||||
|
||||
// Called from JS
|
||||
export fn roc_dispatch_event(list_ptr: ?[*]u8, list_length: usize, handler_id: usize) usize {
|
||||
export fn roc_dispatch_event(list_ptr: ?[*]u8, list_length: usize, handler_id: u64) usize {
|
||||
const json_list = RocList{
|
||||
.bytes = list_ptr,
|
||||
.length = list_length,
|
||||
|
Loading…
Reference in New Issue
Block a user