Skip to content

generated docs improvements: add vector, fntype, anytype type-printing; bool, function value-printing #6678

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 29, 2020

Conversation

s-ol
Copy link
Contributor

@s-ol s-ol commented Oct 14, 2020

See #3404.

I think that some of these aren't currently used in (tested parts of) the stdlib, so this patch can be used to see them in action:

diff --git a/lib/std/meta.zig b/lib/std/meta.zig
index 79b0424e9..719fe1f65 100644
--- a/lib/std/meta.zig
+++ b/lib/std/meta.zig
@@ -702,6 +702,41 @@ pub fn Vector(comptime len: u32, comptime child: type) type {
     });
 }

+pub fn dummy_vec() Vector(3, f32) {
+    var asd : Vector(3, f32) = undefined;
+    return asd;
+}
+
+const OpaqueType = opaque {};
+pub fn dummy_opaque() *OpaqueType {
+    return @intToPtr(*OpaqueType, 1234);
+}
+
+pub fn dummy_fnframe() @Frame(dummy_vec) {
+    return undefined;
+}
+
+pub fn dummy_anyframe() anyframe {
+    return @frame();
+}
+
+pub fn dummy_anyframe_ret() anyframe->f32 {
+    return undefined;
+}
+
+pub fn DummyTypeFnArg(arg: @TypeOf(dummy_opaque)) type {
+    return i8;
+}
+
+test "test vector" {
+    _ = dummy_vec();
+    _ = dummy_opaque();
+    _ = dummy_fnframe();
+    _ = dummy_anyframe();
+    _ = dummy_anyframe_ret();
+    _ = DummyTypeFnArg(dummy_opaque);
+}
+
 /// Given a type and value, cast the value to the type as c would.
 /// This is for translate-c and is not intended for general use.
 pub fn cast(comptime DestType: type, target: anytype) DestType {

@s-ol s-ol changed the title generated docs: add vector type support generated docs: add vector, anytype support Oct 14, 2020
@s-ol s-ol changed the title generated docs: add vector, anytype support generated docs: add vector, fntype, anytype support Oct 14, 2020
@s-ol
Copy link
Contributor Author

s-ol commented Oct 15, 2020

I just found out way too late about getCanonDeclPath, which I essentially reimplemented by exposing parent/container on struct-types and decls respectively. It seems that my new method catches some things getCanonDeclPath doesn't, but I'm not convinced it's any better. I'll have to refactor some of the last commits to merge the two approaches one way or another.

EDIT: dropped my appraoch and switched to using getCanonDeclPath in all cases. If anyone is interested in looking into the other approach, its still visible here: s-ol@a506269

@s-ol s-ol changed the title generated docs: add vector, fntype, anytype support generated docs improvements: add vector, fntype, anytype type printing, bool, function value printing Oct 22, 2020
@s-ol s-ol changed the title generated docs improvements: add vector, fntype, anytype type printing, bool, function value printing generated docs improvements: add vector, fntype, anytype type-printing; bool, function value-printing Oct 22, 2020
@andrewrk
Copy link
Member

Thanks for the patch! The changes look good to me, but the CI failures are legit. Have a look there, looks like some pretty straightforward compile errors.

@s-ol
Copy link
Contributor Author

s-ol commented Oct 23, 2020

@andrewrk thanks for the reminder, I hadn't checked them again after rebasing, and before that it was masked by the LLVM version change breaking CI.

Passing the pointer instead of the value to jw_bool inline 711 was a legit mistake, but I can't figure out where the duplicate case ZigTypeIdBool: is supposed to come from. My code doesn't have it, and I also don't see any such code added to master that could clash in a merge?

@s-ol
Copy link
Contributor Author

s-ol commented Oct 23, 2020

Strange. I can't build locally right now because LLVM hasn't landed on Arch yet, so maybe this has to wait until I can see what's happening for myself.

@LemonBoy
Copy link
Contributor

My code doesn't have it, and I also don't see any such code added to master that could clash in a merge?

#6736 was merged a few days ago and it added the ZigTypeIdBool case.

@Vexu Vexu merged commit 85dd574 into ziglang:master Oct 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants