diff --git a/CMakeLists.txt b/CMakeLists.txt index fd39dd30da..012ad075aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,17 +172,17 @@ else() COMPILE_FLAGS ${ZIG_LLD_COMPILE_FLAGS} LINK_FLAGS " " ) - target_include_directories(embedded_lld_lib PUBLIC + target_include_directories(embedded_lld_lib PRIVATE "${CMAKE_SOURCE_DIR}/deps/lld/include" "${CMAKE_SOURCE_DIR}/deps/lld-prebuilt" ) - target_include_directories(embedded_lld_elf PUBLIC + target_include_directories(embedded_lld_elf PRIVATE "${CMAKE_SOURCE_DIR}/deps/lld/ELF" "${CMAKE_SOURCE_DIR}/deps/lld/include" "${CMAKE_SOURCE_DIR}/deps/lld-prebuilt/ELF" "${CMAKE_SOURCE_DIR}/deps/lld-prebuilt" ) - target_include_directories(embedded_lld_coff PUBLIC + target_include_directories(embedded_lld_coff PRIVATE "${CMAKE_SOURCE_DIR}/deps/lld/COFF" "${CMAKE_SOURCE_DIR}/deps/lld/include" "${CMAKE_SOURCE_DIR}/deps/lld-prebuilt/COFF" @@ -439,10 +439,10 @@ set(ZIG_STD_FILES "os/darwin_errno.zig" "os/get_user_id.zig" "os/index.zig" - "os/linux.zig" - "os/linux_errno.zig" - "os/linux_i386.zig" - "os/linux_x86_64.zig" + "os/linux/index.zig" + "os/linux/errno.zig" + "os/linux/i386.zig" + "os/linux/x86_64.zig" "os/path.zig" "os/windows/error.zig" "os/windows/index.zig" diff --git a/doc/langref.html.in b/doc/langref.html.in index 9e224b2e7d..31a2f6a6c9 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -134,16 +134,6 @@ pub fn main() void {
{#see_also|Values|@import|Errors|Root Source File#} {#header_close#} - {#header_open|Source Encoding#} -Zig source code is encoded in UTF-8. An invalid UTF-8 byte sequence results in a compile error.
-Throughout all zig source code (including in comments), some codepoints are never allowed:
-The codepoint U+000a (LF) (which is encoded as the single-byte value 0x0a) is the line terminator character. This character always terminates a line of zig source code (except possbly the last line of the file).
-For some discussion on the rationale behind these design decisions, see issue #663
- {#header_close#} {#header_open|Values#} {#code_begin|exe|values#} const std = @import("std"); @@ -2780,6 +2770,16 @@ test "implicitly cast to const pointer" { use the C calling convention may pass structs and unions by value. {#header_close#} + {#header_open|Function Reflection#} + {#code_begin|test#} +const assert = @import("std").debug.assert; + +test "fn reflection" { + assert(@typeOf(assert).ReturnType == void); + assert(@typeOf(assert).is_var_args == false); +} + {#code_end#} + {#header_close#} {#header_close#} {#header_open|Errors#}@@ -2986,6 +2986,32 @@ fn createFoo(param: i32) !Foo { {#see_also|defer|if|switch#} + {#header_open|Error Union Type#} +
An error union is created with the ! binary operator.
+ You can use compile-time reflection to access the child type of an error union:
TODO
+ {#header_close#} {#header_close#} {#header_open|Nullables#}@@ -3087,6 +3113,24 @@ fn doAThing(nullable_foo: ?&Foo) void { The optimizer can sometimes make better decisions knowing that pointer arguments cannot be null.
+ {#header_open|Nullable Type#} +A nullable is created by putting ? in front of a type. You can use compile-time
+ reflection to access the child type of a nullable:
TODO: explain implicit vs explicit casting
@@ -3822,6 +3866,17 @@ comptime {@cInclude, @cDefine, and @cUndef work
within this expression, appending to a temporary buffer which is then parsed as C code.
+
+ Usually you should only have one @cImport in your entire application, because it saves the compiler
+ from invoking clang multiple times, and prevents inline functions from being duplicated.
+
+ Reasons for having multiple @cImport expressions would be:
+
#define CONNECTION_COUNT@memberCount(comptime T: type) -> (number literal)
- This function returns the number of enum values in an enum type. + This function returns the number of members in a struct, enum, or union type.
The result is a compile time constant.
++ It does not include functions, variables, or constants. +
{#header_close#} {#header_open|@memberName#} -TODO
+@memberName(comptime T: type, comptime index: usize) -> [N]u8
+ Returns the field name of a struct, union, or enum.
++ The result is a compile time constant. +
++ It does not include functions, variables, or constants. +
{#header_close#} {#header_open|@memberType#} -TODO
+@memberType(comptime T: type, comptime index: usize) -> type
+ Returns the field type of a struct or union.
{#header_close#} {#header_open|@memcpy#}@memcpy(noalias dest: &u8, noalias source: &const u8, byte_count: usize)
@@ -5546,6 +5612,16 @@ fn readU32Be() u32 {}
{#header_close#}
{#header_close#}
+ {#header_open|Source Encoding#}
+ Zig source code is encoded in UTF-8. An invalid UTF-8 byte sequence results in a compile error.
+Throughout all zig source code (including in comments), some codepoints are never allowed:
+The codepoint U+000a (LF) (which is encoded as the single-byte value 0x0a) is the line terminator character. This character always terminates a line of zig source code (except possbly the last line of the file).
+For some discussion on the rationale behind these design decisions, see issue #663
+ {#header_close#} {#header_open|Grammar#}Root = many(TopLevelItem) EOF
@@ -5716,9 +5792,6 @@ ContainerDecl = option("extern" | "packed")
Together we serve end users.
{#header_close#}
- {#header_open|TODO#}
- TODO: document changes from a31b23c46ba2a8c28df01adc1aa0b4d878b9a5cf (compile time reflection additions)
- {#header_close#}