Browse Source

Document `offset_of`

Closes #2419
Jeroen van Rijn 2 years ago
parent
commit
692764aad3
1 changed files with 8 additions and 1 deletions
  1. 8 1
      core/builtin/builtin.odin

+ 8 - 1
core/builtin/builtin.odin

@@ -94,7 +94,14 @@ cap :: proc(array: Array_Type) -> int ---
 
 
 size_of      :: proc($T: typeid) -> int ---
 size_of      :: proc($T: typeid) -> int ---
 align_of     :: proc($T: typeid) -> int ---
 align_of     :: proc($T: typeid) -> int ---
-offset_of    :: proc($T: typeid) -> uintptr ---
+// e.g. offset_of(t.f), where t is an instance of the type T
+offset_of_selector :: proc(selector: $T) -> int ---
+// e.g. offset_of(T, f), where T can be the type instead of a variable
+offset_of_member   :: proc($T: typeid, member: $M) -> int ---
+offset_of :: proc{offset_of_selector, offset_of_member}
+// e.g. offset_of(T, "f"), where T can be the type instead of a variable
+offset_of_by_string :: proc($T: typeid, member: string) -> ---
+
 type_of      :: proc(x: expr) -> type ---
 type_of      :: proc(x: expr) -> type ---
 type_info_of :: proc($T: typeid) -> ^runtime.Type_Info ---
 type_info_of :: proc($T: typeid) -> ^runtime.Type_Info ---
 typeid_of    :: proc($T: typeid) -> typeid ---
 typeid_of    :: proc($T: typeid) -> typeid ---