[banjo] add script to regenerate banjo golden files
Test: fx run-host-tests banjo_unittests_lib_test
Change-Id: Idce0a9b3ebdc91fff244ce2edf12be100f0cc163
diff --git a/tools/banjo/banjo/test/banjo/test.test.banjo b/tools/banjo/banjo/test/banjo/test.test.banjo
deleted file mode 100644
index b2f0d1e..0000000
--- a/tools/banjo/banjo/test/banjo/test.test.banjo
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright 2018 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-library banjo.examples.test;
-
-struct Point {
- int32 x;
- int32 y;
-};
-
-enum Direction : uint32 {
- Up = 0;
- Down = 1;
- Left = 2;
- Right = 3;
-};
-
-struct ArraysOfPoints {
- array<Point>:4 p;
- ArraysOfPoints? more_points;
-};
-
-struct VectorOfPoints {
- vector<Point>:4 p;
-};
-
-struct VectorOfDirections {
- vector<Direction>:4 d;
-};
-
-union Points {
- Point one_point;
- ArraysOfPoints many_points;
-};
-
-const uint32 NumberOfDirections = 4;
-
-interface Drawing {
- Draw(Point p, Direction d);
- DrawLots(Points ps);
- -> DrawSucceeded(uint32 draws);
-};
diff --git a/tools/banjo/banjo/test/c/empty.h b/tools/banjo/banjo/test/c/empty.h
index f83a970..3142c82 100644
--- a/tools/banjo/banjo/test/c/empty.h
+++ b/tools/banjo/banjo/test/c/empty.h
@@ -7,6 +7,7 @@
#pragma once
+
#include <zircon/compiler.h>
#include <zircon/types.h>
@@ -17,4 +18,5 @@
// Declarations
+
__END_CDECLS;
diff --git a/tools/banjo/banjo/test/c/example-1.h b/tools/banjo/banjo/test/c/example-1.h
index 3af881d..2c1cbda8 100644
--- a/tools/banjo/banjo/test/c/example-1.h
+++ b/tools/banjo/banjo/test/c/example-1.h
@@ -7,20 +7,20 @@
#pragma once
+
#include <zircon/compiler.h>
#include <zircon/types.h>
__BEGIN_CDECLS;
// Forward declarations
-
typedef struct point point_t;
// Declarations
-
struct point {
float x;
float y;
};
+
__END_CDECLS;
diff --git a/tools/banjo/banjo/test/c/example-2.h b/tools/banjo/banjo/test/c/example-2.h
index 84bf328..24d79d7 100644
--- a/tools/banjo/banjo/test/c/example-2.h
+++ b/tools/banjo/banjo/test/c/example-2.h
@@ -7,20 +7,20 @@
#pragma once
+
#include <zircon/compiler.h>
#include <zircon/types.h>
__BEGIN_CDECLS;
// Forward declarations
-
typedef struct point point_t;
// Declarations
-
struct point {
float x;
float y;
};
+
__END_CDECLS;
diff --git a/tools/banjo/banjo/test/c/example-3.h b/tools/banjo/banjo/test/c/example-3.h
index 1b18aa5..312dd68 100644
--- a/tools/banjo/banjo/test/c/example-3.h
+++ b/tools/banjo/banjo/test/c/example-3.h
@@ -7,20 +7,20 @@
#pragma once
+
#include <zircon/compiler.h>
#include <zircon/types.h>
__BEGIN_CDECLS;
// Forward declarations
-
typedef struct point point_t;
// Declarations
-
struct point {
int64_t x;
int64_t y;
};
+
__END_CDECLS;
diff --git a/tools/banjo/banjo/test/c/example-7.h b/tools/banjo/banjo/test/c/example-7.h
index 729f60f..99db346 100644
--- a/tools/banjo/banjo/test/c/example-7.h
+++ b/tools/banjo/banjo/test/c/example-7.h
@@ -7,21 +7,21 @@
#pragma once
+
#include <zircon/compiler.h>
#include <zircon/types.h>
__BEGIN_CDECLS;
// Forward declarations
-
typedef struct hello_protocol hello_protocol_t;
// Declarations
-
typedef struct hello_protocol_ops {
void (*say)(void* ctx, const char* req, char* out_response, size_t response_capacity);
} hello_protocol_ops_t;
+
struct hello_protocol {
hello_protocol_ops_t* ops;
void* ctx;
@@ -31,4 +31,6 @@
proto->ops->say(proto->ctx, req, out_response, response_capacity);
}
+
+
__END_CDECLS;
diff --git a/tools/banjo/banjo/test/c/example-8.h b/tools/banjo/banjo/test/c/example-8.h
index 894d5c8d..47c4f1a 100644
--- a/tools/banjo/banjo/test/c/example-8.h
+++ b/tools/banjo/banjo/test/c/example-8.h
@@ -7,21 +7,21 @@
#pragma once
+
#include <zircon/compiler.h>
#include <zircon/types.h>
__BEGIN_CDECLS;
// Forward declarations
-
typedef struct foo foo_t;
// Declarations
-
struct foo {
uint8_t u8_0;
uint64_t u64_0;
uint8_t u8_1;
};
+
__END_CDECLS;
diff --git a/tools/banjo/banjo/test/c/point.h b/tools/banjo/banjo/test/c/point.h
index 1cd332e..685b507 100644
--- a/tools/banjo/banjo/test/c/point.h
+++ b/tools/banjo/banjo/test/c/point.h
@@ -7,20 +7,20 @@
#pragma once
+
#include <zircon/compiler.h>
#include <zircon/types.h>
__BEGIN_CDECLS;
// Forward declarations
-
typedef struct point point_t;
// Declarations
-
struct point {
float x;
float y;
};
+
__END_CDECLS;
diff --git a/tools/banjo/banjo/test/c/types.h b/tools/banjo/banjo/test/c/types.h
new file mode 100644
index 0000000..18b0d2c
--- /dev/null
+++ b/tools/banjo/banjo/test/c/types.h
@@ -0,0 +1,455 @@
+// Copyright 2018 The Fuchsia Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// WARNING: THIS FILE IS MACHINE GENERATED. DO NOT EDIT.
+// Generated from the banjo.examples.types banjo file
+
+#pragma once
+
+
+#include <zircon/compiler.h>
+#include <zircon/types.h>
+
+__BEGIN_CDECLS;
+
+// Forward declarations
+typedef struct arrays arrays_t;
+typedef struct default_values default_values_t;
+typedef struct primitive_types primitive_types_t;
+typedef struct strings strings_t;
+typedef struct this_is_a_struct this_is_a_struct_t;
+typedef struct vectors vectors_t;
+typedef struct handles handles_t;
+typedef union this_is_a_union this_is_a_union_t;
+typedef uint32_t default_enum_t;
+#define DEFAULT_ENUM_X UINT32_C(23)
+typedef int16_t i16_enum_t;
+#define I16_ENUM_X INT16_C(23)
+typedef int32_t i32_enum_t;
+#define I32_ENUM_X INT32_C(23)
+typedef int64_t i64_enum_t;
+#define I64_ENUM_X INT64_C(23)
+typedef int8_t i8_enum_t;
+#define I8_ENUM_X INT8_C(23)
+typedef uint16_t u16_enum_t;
+#define U16_ENUM_X UINT16_C(23)
+typedef uint32_t u32_enum_t;
+#define U32_ENUM_X UINT32_C(23)
+typedef uint64_t u64_enum_t;
+#define U64_ENUM_X UINT64_C(23)
+typedef uint8_t u8_enum_t;
+#define U8_ENUM_X UINT8_C(23)
+#define arrays_size UINT32_C(32)
+#define strings_size UINT32_C(32)
+#define vectors_size UINT32_C(32)
+typedef struct this_is_an_interface_protocol this_is_an_interface_protocol_t;
+typedef struct structs structs_t;
+typedef struct unions unions_t;
+typedef struct interfaces interfaces_t;
+typedef struct interfaces interfaces_t;
+
+// Declarations
+struct arrays {
+ bool b_0[1];
+ int8_t i8_0[1];
+ int16_t i16_0[1];
+ int32_t i32_0[1];
+ int64_t i64_0[1];
+ uint8_t u8_0[1];
+ uint16_t u16_0[1];
+ uint32_t u32_0[1];
+ uint64_t u64_0[1];
+ float f32_0[1];
+ double f64_0[1];
+ zx_handle_t handle_0[1];
+ bool b_1[arrays_size];
+ int8_t i8_1[arrays_size];
+ int16_t i16_1[arrays_size];
+ int32_t i32_1[arrays_size];
+ int64_t i64_1[arrays_size];
+ uint8_t u8_1[arrays_size];
+ uint16_t u16_1[arrays_size];
+ uint32_t u32_1[arrays_size];
+ uint64_t u64_1[arrays_size];
+ float f32_1[arrays_size];
+ double f64_1[arrays_size];
+ zx_handle_t handle_1[arrays_size];
+ bool b_2[arrays_size][4];
+ int8_t i8_2[arrays_size][4];
+ int16_t i16_2[arrays_size][4];
+ int32_t i32_2[arrays_size][4];
+ int64_t i64_2[arrays_size][4];
+ uint8_t u8_2[arrays_size][4];
+ uint16_t u16_2[arrays_size][4];
+ uint32_t u32_2[arrays_size][4];
+ uint64_t u64_2[arrays_size][4];
+ float f32_2[arrays_size][4];
+ double f64_2[arrays_size][4];
+ zx_handle_t handle_2[arrays_size][4];
+};
+
+struct default_values {
+ bool b1;
+ bool b2;
+ int8_t i8;
+ int16_t i16;
+ int32_t i32;
+ int64_t i64;
+ uint8_t u8;
+ uint16_t u16;
+ uint32_t u32;
+ uint64_t u64;
+ const char* s;
+};
+
+struct primitive_types {
+ bool b;
+ int8_t i8;
+ int16_t i16;
+ int32_t i32;
+ int64_t i64;
+ uint8_t u8;
+ uint16_t u16;
+ uint32_t u32;
+ uint64_t u64;
+ float f32;
+ double f64;
+};
+
+struct strings {
+ const char* s;
+ char* nullable_s;
+ char size_0_s[4];
+ char size_1_s[strings_size];
+ char nullable_size_0_s[4];
+ char nullable_size_1_s[strings_size];
+};
+
+struct this_is_a_struct {
+ const char* s;
+};
+
+struct vectors {
+ const bool* b_0_list;
+ size_t b_0_count;
+ const int8_t* i8_0_list;
+ size_t i8_0_count;
+ const int16_t* i16_0_list;
+ size_t i16_0_count;
+ const int32_t* i32_0_list;
+ size_t i32_0_count;
+ const int64_t* i64_0_list;
+ size_t i64_0_count;
+ const uint8_t* u8_0_list;
+ size_t u8_0_count;
+ const uint16_t* u16_0_list;
+ size_t u16_0_count;
+ const uint32_t* u32_0_list;
+ size_t u32_0_count;
+ const uint64_t* u64_0_list;
+ size_t u64_0_count;
+ const float* f32_0_list;
+ size_t f32_0_count;
+ const double* f64_0_list;
+ size_t f64_0_count;
+ const zx_handle_t* handle_0_list;
+ size_t handle_0_count;
+ const bool* b_1_list;
+ size_t b_1_count;
+ const int8_t* i8_1_list;
+ size_t i8_1_count;
+ const int16_t* i16_1_list;
+ size_t i16_1_count;
+ const int32_t* i32_1_list;
+ size_t i32_1_count;
+ const int64_t* i64_1_list;
+ size_t i64_1_count;
+ const uint8_t* u8_1_list;
+ size_t u8_1_count;
+ const uint16_t* u16_1_list;
+ size_t u16_1_count;
+ const uint32_t* u32_1_list;
+ size_t u32_1_count;
+ const uint64_t* u64_1_list;
+ size_t u64_1_count;
+ const float* f32_1_list;
+ size_t f32_1_count;
+ const double* f64_1_list;
+ size_t f64_1_count;
+ const zx_handle_t* handle_1_list;
+ size_t handle_1_count;
+ const bool* b_sized_0_list;
+ size_t b_sized_0_count;
+ const int8_t* i8_sized_0_list;
+ size_t i8_sized_0_count;
+ const int16_t* i16_sized_0_list;
+ size_t i16_sized_0_count;
+ const int32_t* i32_sized_0_list;
+ size_t i32_sized_0_count;
+ const int64_t* i64_sized_0_list;
+ size_t i64_sized_0_count;
+ const uint8_t* u8_sized_0_list;
+ size_t u8_sized_0_count;
+ const uint16_t* u16_sized_0_list;
+ size_t u16_sized_0_count;
+ const uint32_t* u32_sized_0_list;
+ size_t u32_sized_0_count;
+ const uint64_t* u64_sized_0_list;
+ size_t u64_sized_0_count;
+ const float* f32_sized_0_list;
+ size_t f32_sized_0_count;
+ const double* f64_sized_0_list;
+ size_t f64_sized_0_count;
+ const zx_handle_t* handle_sized_0_list;
+ size_t handle_sized_0_count;
+ const bool* b_sized_1_list;
+ size_t b_sized_1_count;
+ const int8_t* i8_sized_1_list;
+ size_t i8_sized_1_count;
+ const int16_t* i16_sized_1_list;
+ size_t i16_sized_1_count;
+ const int32_t* i32_sized_1_list;
+ size_t i32_sized_1_count;
+ const int64_t* i64_sized_1_list;
+ size_t i64_sized_1_count;
+ const uint8_t* u8_sized_1_list;
+ size_t u8_sized_1_count;
+ const uint16_t* u16_sized_1_list;
+ size_t u16_sized_1_count;
+ const uint32_t* u32_sized_1_list;
+ size_t u32_sized_1_count;
+ const uint64_t* u64_sized_1_list;
+ size_t u64_sized_1_count;
+ const float* f32_sized_1_list;
+ size_t f32_sized_1_count;
+ const double* f64_sized_1_list;
+ size_t f64_sized_1_count;
+ const zx_handle_t* handle_sized_1_list;
+ size_t handle_sized_1_count;
+ const bool* b_sized_2_list;
+ size_t b_sized_2_count;
+ const int8_t* i8_sized_2_list;
+ size_t i8_sized_2_count;
+ const int16_t* i16_sized_2_list;
+ size_t i16_sized_2_count;
+ const int32_t* i32_sized_2_list;
+ size_t i32_sized_2_count;
+ const int64_t* i64_sized_2_list;
+ size_t i64_sized_2_count;
+ const uint8_t* u8_sized_2_list;
+ size_t u8_sized_2_count;
+ const uint16_t* u16_sized_2_list;
+ size_t u16_sized_2_count;
+ const uint32_t* u32_sized_2_list;
+ size_t u32_sized_2_count;
+ const uint64_t* u64_sized_2_list;
+ size_t u64_sized_2_count;
+ const float* f32_sized_2_list;
+ size_t f32_sized_2_count;
+ const double* f64_sized_2_list;
+ size_t f64_sized_2_count;
+ const zx_handle_t* handle_sized_2_list;
+ size_t handle_sized_2_count;
+ bool* b_nullable_0_list;
+ size_t b_nullable_0_count;
+ int8_t* i8_nullable_0_list;
+ size_t i8_nullable_0_count;
+ int16_t* i16_nullable_0_list;
+ size_t i16_nullable_0_count;
+ int32_t* i32_nullable_0_list;
+ size_t i32_nullable_0_count;
+ int64_t* i64_nullable_0_list;
+ size_t i64_nullable_0_count;
+ uint8_t* u8_nullable_0_list;
+ size_t u8_nullable_0_count;
+ uint16_t* u16_nullable_0_list;
+ size_t u16_nullable_0_count;
+ uint32_t* u32_nullable_0_list;
+ size_t u32_nullable_0_count;
+ uint64_t* u64_nullable_0_list;
+ size_t u64_nullable_0_count;
+ float* f32_nullable_0_list;
+ size_t f32_nullable_0_count;
+ double* f64_nullable_0_list;
+ size_t f64_nullable_0_count;
+ zx_handle_t* handle_nullable_0_list;
+ size_t handle_nullable_0_count;
+ bool* b_nullable_1_list;
+ size_t b_nullable_1_count;
+ int8_t* i8_nullable_1_list;
+ size_t i8_nullable_1_count;
+ int16_t* i16_nullable_1_list;
+ size_t i16_nullable_1_count;
+ int32_t* i32_nullable_1_list;
+ size_t i32_nullable_1_count;
+ int64_t* i64_nullable_1_list;
+ size_t i64_nullable_1_count;
+ uint8_t* u8_nullable_1_list;
+ size_t u8_nullable_1_count;
+ uint16_t* u16_nullable_1_list;
+ size_t u16_nullable_1_count;
+ uint32_t* u32_nullable_1_list;
+ size_t u32_nullable_1_count;
+ uint64_t* u64_nullable_1_list;
+ size_t u64_nullable_1_count;
+ float* f32_nullable_1_list;
+ size_t f32_nullable_1_count;
+ double* f64_nullable_1_list;
+ size_t f64_nullable_1_count;
+ zx_handle_t* handle_nullable_1_list;
+ size_t handle_nullable_1_count;
+ bool* b_nullable_sized_0_list;
+ size_t b_nullable_sized_0_count;
+ int8_t* i8_nullable_sized_0_list;
+ size_t i8_nullable_sized_0_count;
+ int16_t* i16_nullable_sized_0_list;
+ size_t i16_nullable_sized_0_count;
+ int32_t* i32_nullable_sized_0_list;
+ size_t i32_nullable_sized_0_count;
+ int64_t* i64_nullable_sized_0_list;
+ size_t i64_nullable_sized_0_count;
+ uint8_t* u8_nullable_sized_0_list;
+ size_t u8_nullable_sized_0_count;
+ uint16_t* u16_nullable_sized_0_list;
+ size_t u16_nullable_sized_0_count;
+ uint32_t* u32_nullable_sized_0_list;
+ size_t u32_nullable_sized_0_count;
+ uint64_t* u64_nullable_sized_0_list;
+ size_t u64_nullable_sized_0_count;
+ float* f32_nullable_sized_0_list;
+ size_t f32_nullable_sized_0_count;
+ double* f64_nullable_sized_0_list;
+ size_t f64_nullable_sized_0_count;
+ zx_handle_t* handle_nullable_sized_0_list;
+ size_t handle_nullable_sized_0_count;
+ bool* b_nullable_sized_1_list;
+ size_t b_nullable_sized_1_count;
+ int8_t* i8_nullable_sized_1_list;
+ size_t i8_nullable_sized_1_count;
+ int16_t* i16_nullable_sized_1_list;
+ size_t i16_nullable_sized_1_count;
+ int32_t* i32_nullable_sized_1_list;
+ size_t i32_nullable_sized_1_count;
+ int64_t* i64_nullable_sized_1_list;
+ size_t i64_nullable_sized_1_count;
+ uint8_t* u8_nullable_sized_1_list;
+ size_t u8_nullable_sized_1_count;
+ uint16_t* u16_nullable_sized_1_list;
+ size_t u16_nullable_sized_1_count;
+ uint32_t* u32_nullable_sized_1_list;
+ size_t u32_nullable_sized_1_count;
+ uint64_t* u64_nullable_sized_1_list;
+ size_t u64_nullable_sized_1_count;
+ float* f32_nullable_sized_1_list;
+ size_t f32_nullable_sized_1_count;
+ double* f64_nullable_sized_1_list;
+ size_t f64_nullable_sized_1_count;
+ zx_handle_t* handle_nullable_sized_1_list;
+ size_t handle_nullable_sized_1_count;
+ bool* b_nullable_sized_2_list;
+ size_t b_nullable_sized_2_count;
+ int8_t* i8_nullable_sized_2_list;
+ size_t i8_nullable_sized_2_count;
+ int16_t* i16_nullable_sized_2_list;
+ size_t i16_nullable_sized_2_count;
+ int32_t* i32_nullable_sized_2_list;
+ size_t i32_nullable_sized_2_count;
+ int64_t* i64_nullable_sized_2_list;
+ size_t i64_nullable_sized_2_count;
+ uint8_t* u8_nullable_sized_2_list;
+ size_t u8_nullable_sized_2_count;
+ uint16_t* u16_nullable_sized_2_list;
+ size_t u16_nullable_sized_2_count;
+ uint32_t* u32_nullable_sized_2_list;
+ size_t u32_nullable_sized_2_count;
+ uint64_t* u64_nullable_sized_2_list;
+ size_t u64_nullable_sized_2_count;
+ float* f32_nullable_sized_2_list;
+ size_t f32_nullable_sized_2_count;
+ double* f64_nullable_sized_2_list;
+ size_t f64_nullable_sized_2_count;
+ zx_handle_t* handle_nullable_sized_2_list;
+ size_t handle_nullable_sized_2_count;
+};
+
+struct handles {
+ zx_handle_t handle_handle;
+ zx_handle_t process_handle;
+ zx_handle_t thread_handle;
+ zx_handle_t vmo_handle;
+ zx_handle_t channel_handle;
+ zx_handle_t event_handle;
+ zx_handle_t port_handle;
+ zx_handle_t interrupt_handle;
+ zx_handle_t debuglog_handle;
+ zx_handle_t socket_handle;
+ zx_handle_t resource_handle;
+ zx_handle_t eventpair_handle;
+ zx_handle_t job_handle;
+ zx_handle_t vmar_handle;
+ zx_handle_t fifo_handle;
+ zx_handle_t guest_handle;
+ zx_handle_t timer_handle;
+ zx_handle_t profile_handle;
+ zx_handle_t nullable_handle_handle;
+ zx_handle_t nullable_process_handle;
+ zx_handle_t nullable_thread_handle;
+ zx_handle_t nullable_vmo_handle;
+ zx_handle_t nullable_channel_handle;
+ zx_handle_t nullable_event_handle;
+ zx_handle_t nullable_port_handle;
+ zx_handle_t nullable_interrupt_handle;
+ zx_handle_t nullable_debuglog_handle;
+ zx_handle_t nullable_socket_handle;
+ zx_handle_t nullable_resource_handle;
+ zx_handle_t nullable_eventpair_handle;
+ zx_handle_t nullable_job_handle;
+ zx_handle_t nullable_vmar_handle;
+ zx_handle_t nullable_fifo_handle;
+ zx_handle_t nullable_guest_handle;
+ zx_handle_t nullable_timer_handle;
+ zx_handle_t nullable_profile_handle;
+};
+
+union this_is_a_union {
+ char* s;
+};
+
+typedef struct this_is_an_interface_protocol_ops {
+ void (*copy)(void* ctx, const char* s, uint32_t count, char* out_s, size_t s_capacity);
+} this_is_an_interface_protocol_ops_t;
+
+
+struct this_is_an_interface_protocol {
+ this_is_an_interface_protocol_ops_t* ops;
+ void* ctx;
+};
+
+static inline void this_is_an_interface_copy(const this_is_an_interface_protocol_t* proto, const char* s, uint32_t count, char* out_s, size_t s_capacity) {
+ proto->ops->copy(proto->ctx, s, count, out_s, s_capacity);
+}
+
+
+struct structs {
+ this_is_a_struct_t s;
+ this_is_a_struct_t nullable_s;
+};
+
+struct unions {
+ this_is_a_union_t s;
+ this_is_a_union_t nullable_u;
+};
+
+struct interfaces {
+ this_is_an_interface_t nonnullable_interface;
+ this_is_an_interface_t nullable_interface;
+};
+
+struct interfaces {
+ this_is_an_interface_t i;
+ this_is_an_interface_t nullable_i;
+};
+
+
+__END_CDECLS;
diff --git a/tools/banjo/banjo/test/c/view.h b/tools/banjo/banjo/test/c/view.h
index fa2b621..5d47bb3 100644
--- a/tools/banjo/banjo/test/c/view.h
+++ b/tools/banjo/banjo/test/c/view.h
@@ -14,15 +14,14 @@
__BEGIN_CDECLS;
// Forward declarations
-
typedef struct view_protocol view_protocol_t;
// Declarations
-
typedef struct view_protocol_ops {
void (*move_to)(void* ctx, const point_t* p);
} view_protocol_ops_t;
+
struct view_protocol {
view_protocol_ops_t* ops;
void* ctx;
@@ -32,4 +31,6 @@
proto->ops->move_to(proto->ctx, p);
}
+
+
__END_CDECLS;
diff --git a/tools/banjo/banjo/test/codegen_tests.rs b/tools/banjo/banjo/test/codegen_tests.rs
index 8afdb57..465bd9d 100644
--- a/tools/banjo/banjo/test/codegen_tests.rs
+++ b/tools/banjo/banjo/test/codegen_tests.rs
@@ -25,6 +25,7 @@
codegen_test!(table, CBackend, ["banjo/tables.test.banjo"], "c/tables.h");
codegen_test!(simple, CBackend, ["../zx.banjo", "banjo/simple.test.banjo"], "c/simple.h");
codegen_test!(view, CBackend, ["banjo/point.test.banjo", "banjo/view.test.banjo"], "c/view.h");
+ codegen_test!(types, CBackend, ["banjo/types.test.banjo"], "c/types.h");
codegen_test!(
protocol_primitive,
CBackend,
diff --git a/tools/banjo/banjo/test/cpp/callback-internal.h b/tools/banjo/banjo/test/cpp/callback-internal.h
index c8c4575..ba3f2fb 100644
--- a/tools/banjo/banjo/test/cpp/callback-internal.h
+++ b/tools/banjo/banjo/test/cpp/callback-internal.h
@@ -52,5 +52,6 @@
}
+
} // namespace internal
} // namespace ddk
diff --git a/tools/banjo/banjo/test/cpp/empty.h b/tools/banjo/banjo/test/cpp/empty.h
index 15ed72d..0c40755 100644
--- a/tools/banjo/banjo/test/cpp/empty.h
+++ b/tools/banjo/banjo/test/cpp/empty.h
@@ -18,6 +18,7 @@
// DDK empty-protocol support
//
+
namespace ddk {
} // namespace ddk
diff --git a/tools/banjo/banjo/test/cpp/example-4-internal.h b/tools/banjo/banjo/test/cpp/example-4-internal.h
index 38ea243..8f8aa23 100644
--- a/tools/banjo/banjo/test/cpp/example-4-internal.h
+++ b/tools/banjo/banjo/test/cpp/example-4-internal.h
@@ -15,12 +15,15 @@
DECLARE_HAS_MEMBER_FN_WITH_SIGNATURE(has_interface_protocol_func, Interfacefunc,
void (C::*)(bool x));
+
template <typename D>
constexpr void CheckInterfaceProtocolSubclass() {
static_assert(internal::has_interface_protocol_func<D>::value,
"InterfaceProtocol subclasses must implement "
"void Interfacefunc(bool x);");
+
}
+
} // namespace internal
} // namespace ddk
diff --git a/tools/banjo/banjo/test/cpp/example-4.h b/tools/banjo/banjo/test/cpp/example-4.h
index 3e2e914..027bfa1 100644
--- a/tools/banjo/banjo/test/cpp/example-4.h
+++ b/tools/banjo/banjo/test/cpp/example-4.h
@@ -101,6 +101,7 @@
ctx_ = nullptr;
ops_ = nullptr;
}
+
void func(bool x) const {
ops_->func(ctx_, x);
}
diff --git a/tools/banjo/banjo/test/cpp/example-6-internal.h b/tools/banjo/banjo/test/cpp/example-6-internal.h
index 31b188a..1246b43 100644
--- a/tools/banjo/banjo/test/cpp/example-6-internal.h
+++ b/tools/banjo/banjo/test/cpp/example-6-internal.h
@@ -15,12 +15,15 @@
DECLARE_HAS_MEMBER_FN_WITH_SIGNATURE(has_hello_protocol_say, HelloSay,
void (C::*)(const char* req, char* out_response, size_t response_capacity));
+
template <typename D>
constexpr void CheckHelloProtocolSubclass() {
static_assert(internal::has_hello_protocol_say<D>::value,
"HelloProtocol subclasses must implement "
"void HelloSay(const char* req, char* out_response, size_t response_capacity);");
+
}
+
} // namespace internal
} // namespace ddk
diff --git a/tools/banjo/banjo/test/cpp/example-6.h b/tools/banjo/banjo/test/cpp/example-6.h
index 003456c..93a3586 100644
--- a/tools/banjo/banjo/test/cpp/example-6.h
+++ b/tools/banjo/banjo/test/cpp/example-6.h
@@ -101,6 +101,7 @@
ctx_ = nullptr;
ops_ = nullptr;
}
+
void Say(const char* req, char* out_response, size_t response_capacity) const {
ops_->say(ctx_, req, out_response, response_capacity);
}
diff --git a/tools/banjo/banjo/test/cpp/example-7-internal.h b/tools/banjo/banjo/test/cpp/example-7-internal.h
index f6afba8..cc5a7e0 100644
--- a/tools/banjo/banjo/test/cpp/example-7-internal.h
+++ b/tools/banjo/banjo/test/cpp/example-7-internal.h
@@ -15,12 +15,15 @@
DECLARE_HAS_MEMBER_FN_WITH_SIGNATURE(has_hello_protocol_say, HelloSay,
void (C::*)(const char* req, char* out_response, size_t response_capacity));
+
template <typename D>
constexpr void CheckHelloProtocolSubclass() {
static_assert(internal::has_hello_protocol_say<D>::value,
"HelloProtocol subclasses must implement "
"void HelloSay(const char* req, char* out_response, size_t response_capacity);");
+
}
+
} // namespace internal
} // namespace ddk
diff --git a/tools/banjo/banjo/test/cpp/example-7.h b/tools/banjo/banjo/test/cpp/example-7.h
index 395af12..9e4ae6c 100644
--- a/tools/banjo/banjo/test/cpp/example-7.h
+++ b/tools/banjo/banjo/test/cpp/example-7.h
@@ -101,6 +101,7 @@
ctx_ = nullptr;
ops_ = nullptr;
}
+
void Say(const char* req, char* out_response, size_t response_capacity) const {
ops_->say(ctx_, req, out_response, response_capacity);
}
diff --git a/tools/banjo/banjo/test/cpp/example-9-internal.h b/tools/banjo/banjo/test/cpp/example-9-internal.h
index 09aa36c..706bebf 100644
--- a/tools/banjo/banjo/test/cpp/example-9-internal.h
+++ b/tools/banjo/banjo/test/cpp/example-9-internal.h
@@ -14,38 +14,51 @@
DECLARE_HAS_MEMBER_FN_WITH_SIGNATURE(has_echo_protocol_echo32, EchoEcho32,
uint32_t (C::*)(uint32_t uint32));
+
DECLARE_HAS_MEMBER_FN_WITH_SIGNATURE(has_echo_protocol_echo64, EchoEcho64,
uint64_t (C::*)(uint64_t uint64));
+
DECLARE_HAS_MEMBER_FN_WITH_SIGNATURE(has_echo_protocol_echo_enum, EchoEchoEnum,
echo_me_t (C::*)(echo_me_t req));
+
DECLARE_HAS_MEMBER_FN_WITH_SIGNATURE(has_echo_protocol_echo_handle, EchoEchoHandle,
void (C::*)(zx::handle req, zx::handle* out_response));
+
DECLARE_HAS_MEMBER_FN_WITH_SIGNATURE(has_echo_protocol_echo_channel, EchoEchoChannel,
void (C::*)(zx::channel req, zx::channel* out_response));
+
DECLARE_HAS_MEMBER_FN_WITH_SIGNATURE(has_echo_protocol_echo_struct, EchoEchoStruct,
void (C::*)(const echo_more_t* req, echo_more_t* out_response));
+
template <typename D>
constexpr void CheckEchoProtocolSubclass() {
static_assert(internal::has_echo_protocol_echo32<D>::value,
"EchoProtocol subclasses must implement "
"uint32_t EchoEcho32(uint32_t uint32);");
+
static_assert(internal::has_echo_protocol_echo64<D>::value,
"EchoProtocol subclasses must implement "
"uint64_t EchoEcho64(uint64_t uint64);");
+
static_assert(internal::has_echo_protocol_echo_enum<D>::value,
"EchoProtocol subclasses must implement "
"echo_me_t EchoEchoEnum(echo_me_t req);");
+
static_assert(internal::has_echo_protocol_echo_handle<D>::value,
"EchoProtocol subclasses must implement "
"void EchoEchoHandle(zx::handle req, zx::handle* out_response);");
+
static_assert(internal::has_echo_protocol_echo_channel<D>::value,
"EchoProtocol subclasses must implement "
"void EchoEchoChannel(zx::channel req, zx::channel* out_response);");
+
static_assert(internal::has_echo_protocol_echo_struct<D>::value,
"EchoProtocol subclasses must implement "
"void EchoEchoStruct(const echo_more_t* req, echo_more_t* out_response);");
+
}
+
} // namespace internal
} // namespace ddk
diff --git a/tools/banjo/banjo/test/cpp/example-9.h b/tools/banjo/banjo/test/cpp/example-9.h
index a6db3c8..14a80659 100644
--- a/tools/banjo/banjo/test/cpp/example-9.h
+++ b/tools/banjo/banjo/test/cpp/example-9.h
@@ -140,21 +140,27 @@
ctx_ = nullptr;
ops_ = nullptr;
}
+
uint32_t Echo32(uint32_t uint32) const {
return ops_->echo32(ctx_, uint32);
}
+
uint64_t Echo64(uint64_t uint64) const {
return ops_->echo64(ctx_, uint64);
}
+
echo_me_t EchoEnum(echo_me_t req) const {
return ops_->echo_enum(ctx_, req);
}
+
void EchoHandle(zx::handle req, zx::handle* out_response) const {
ops_->echo_handle(ctx_, req.release(), out_response->reset_and_get_address());
}
+
void EchoChannel(zx::channel req, zx::channel* out_response) const {
ops_->echo_channel(ctx_, req.release(), out_response->reset_and_get_address());
}
+
void EchoStruct(const echo_more_t* req, echo_more_t* out_response) const {
ops_->echo_struct(ctx_, req, out_response);
}
diff --git a/tools/banjo/banjo/test/cpp/protocol-array-internal.h b/tools/banjo/banjo/test/cpp/protocol-array-internal.h
index f1474d1..42b1c2f 100644
--- a/tools/banjo/banjo/test/cpp/protocol-array-internal.h
+++ b/tools/banjo/banjo/test/cpp/protocol-array-internal.h
@@ -279,5 +279,6 @@
}
+
} // namespace internal
} // namespace ddk
diff --git a/tools/banjo/banjo/test/cpp/protocol-base-internal.h b/tools/banjo/banjo/test/cpp/protocol-base-internal.h
index 59de990..3bc9f6e 100644
--- a/tools/banjo/banjo/test/cpp/protocol-base-internal.h
+++ b/tools/banjo/banjo/test/cpp/protocol-base-internal.h
@@ -148,5 +148,6 @@
}
+
} // namespace internal
} // namespace ddk
diff --git a/tools/banjo/banjo/test/cpp/protocol-handle-internal.h b/tools/banjo/banjo/test/cpp/protocol-handle-internal.h
index 7e0ebc0..fe3fa94 100644
--- a/tools/banjo/banjo/test/cpp/protocol-handle-internal.h
+++ b/tools/banjo/banjo/test/cpp/protocol-handle-internal.h
@@ -274,5 +274,6 @@
}
+
} // namespace internal
} // namespace ddk
diff --git a/tools/banjo/banjo/test/cpp/protocol-other-types-internal.h b/tools/banjo/banjo/test/cpp/protocol-other-types-internal.h
index 6388072..0a7d989 100644
--- a/tools/banjo/banjo/test/cpp/protocol-other-types-internal.h
+++ b/tools/banjo/banjo/test/cpp/protocol-other-types-internal.h
@@ -219,5 +219,6 @@
}
+
} // namespace internal
} // namespace ddk
diff --git a/tools/banjo/banjo/test/cpp/protocol-primitive-internal.h b/tools/banjo/banjo/test/cpp/protocol-primitive-internal.h
index a4f65d9..99e85bb1 100644
--- a/tools/banjo/banjo/test/cpp/protocol-primitive-internal.h
+++ b/tools/banjo/banjo/test/cpp/protocol-primitive-internal.h
@@ -176,5 +176,6 @@
}
+
} // namespace internal
} // namespace ddk
diff --git a/tools/banjo/banjo/test/cpp/simple-internal.h b/tools/banjo/banjo/test/cpp/simple-internal.h
index bc74c1d..85f2398 100644
--- a/tools/banjo/banjo/test/cpp/simple-internal.h
+++ b/tools/banjo/banjo/test/cpp/simple-internal.h
@@ -14,28 +14,37 @@
DECLARE_HAS_MEMBER_FN_WITH_SIGNATURE(has_drawing_protocol_draw, DrawingDraw,
void (C::*)(const point_t* p, direction_t d));
+
DECLARE_HAS_MEMBER_FN_WITH_SIGNATURE(has_drawing_protocol_draw_lots, DrawingDrawLots,
zx_status_t (C::*)(zx::vmo commands, point_t* out_p));
+
DECLARE_HAS_MEMBER_FN_WITH_SIGNATURE(has_drawing_protocol_draw_array, DrawingDrawArray,
zx_status_t (C::*)(const point_t points[4]));
+
DECLARE_HAS_MEMBER_FN_WITH_SIGNATURE(has_drawing_protocol_describe, DrawingDescribe,
void (C::*)(const char* one, char* out_two, size_t two_capacity));
+
template <typename D>
constexpr void CheckDrawingProtocolSubclass() {
static_assert(internal::has_drawing_protocol_draw<D>::value,
"DrawingProtocol subclasses must implement "
"void DrawingDraw(const point_t* p, direction_t d);");
+
static_assert(internal::has_drawing_protocol_draw_lots<D>::value,
"DrawingProtocol subclasses must implement "
"zx_status_t DrawingDrawLots(zx::vmo commands, point_t* out_p);");
+
static_assert(internal::has_drawing_protocol_draw_array<D>::value,
"DrawingProtocol subclasses must implement "
"zx_status_t DrawingDrawArray(const point_t points[4]);");
+
static_assert(internal::has_drawing_protocol_describe<D>::value,
"DrawingProtocol subclasses must implement "
"void DrawingDescribe(const char* one, char* out_two, size_t two_capacity);");
+
}
+
} // namespace internal
} // namespace ddk
diff --git a/tools/banjo/banjo/test/cpp/simple.h b/tools/banjo/banjo/test/cpp/simple.h
index d60dc03..d8ee026 100644
--- a/tools/banjo/banjo/test/cpp/simple.h
+++ b/tools/banjo/banjo/test/cpp/simple.h
@@ -122,15 +122,19 @@
ctx_ = nullptr;
ops_ = nullptr;
}
+
void Draw(const point_t* p, direction_t d) const {
ops_->draw(ctx_, p, d);
}
+
zx_status_t DrawLots(zx::vmo commands, point_t* out_p) const {
return ops_->draw_lots(ctx_, commands.release(), out_p);
}
+
zx_status_t DrawArray(const point_t points[4]) const {
return ops_->draw_array(ctx_, points);
}
+
void Describe(const char* one, char* out_two, size_t two_capacity) const {
ops_->describe(ctx_, one, out_two, two_capacity);
}
diff --git a/tools/banjo/banjo/test/cpp/view-internal.h b/tools/banjo/banjo/test/cpp/view-internal.h
index f786ac5..1aeae98 100644
--- a/tools/banjo/banjo/test/cpp/view-internal.h
+++ b/tools/banjo/banjo/test/cpp/view-internal.h
@@ -15,12 +15,15 @@
DECLARE_HAS_MEMBER_FN_WITH_SIGNATURE(has_view_protocol_move_to, ViewMoveTo,
void (C::*)(const point_t* p));
+
template <typename D>
constexpr void CheckViewProtocolSubclass() {
static_assert(internal::has_view_protocol_move_to<D>::value,
"ViewProtocol subclasses must implement "
"void ViewMoveTo(const point_t* p);");
+
}
+
} // namespace internal
} // namespace ddk
diff --git a/tools/banjo/banjo/test/cpp/view.h b/tools/banjo/banjo/test/cpp/view.h
index f4b0ba1..693e92b 100644
--- a/tools/banjo/banjo/test/cpp/view.h
+++ b/tools/banjo/banjo/test/cpp/view.h
@@ -102,6 +102,7 @@
ctx_ = nullptr;
ops_ = nullptr;
}
+
void MoveTo(const point_t* p) const {
ops_->move_to(ctx_, p);
}
diff --git a/tools/banjo/regen_banjo_tests.sh b/tools/banjo/regen_banjo_tests.sh
new file mode 100755
index 0000000..028fa4c
--- /dev/null
+++ b/tools/banjo/regen_banjo_tests.sh
@@ -0,0 +1,49 @@
+#!/bin/bash
+# Copyright 2019 The Fuchsia Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+FUCHSIA="$SCRIPT_DIR/../../"
+BANJO_DIR="$FUCHSIA/tools/banjo/banjo/"
+BANJO_FILES="$BANJO_DIR/test/banjo"
+C_FILES="$BANJO_DIR/test/c"
+CPP_FILES="$BANJO_DIR/test/cpp"
+RUST_FILES="$BANJO_DIR/test/rust"
+BANJO_BIN="$FUCHSIA/zircon/prebuilt/downloads/banjo/banjo_bin"
+
+for f in $BANJO_FILES/*
+do
+ filename=$(basename -- "$f")
+ extension="${filename##*.*.}"
+ filename="${filename%.*.*}"
+
+ dependencies=""
+ zx="--omit-zx"
+ type_only=false
+ if [ "$filename" = "callback" ] || [ "$filename" = "simple" ] || [ "$filename" = "interface" ] \
+ || [ "$filename" = "protocol-base" ] ; then
+ zx=""
+ fi
+
+ if [ "$filename" = "view" ]; then
+ dependencies="$dependencies --files $BANJO_FILES/point.test.banjo"
+ fi
+
+ if [ "$filename" = "enums" ] || [ "$filename" = "types" ] || [ "$filename" = "example-0" ] \
+ || [ "$filename" = "example-1" ] || [ "$filename" = "example-2" ] \
+ || [ "$filename" = "example-3" ] || [ "$filename" = "alignment" ] \
+ || [ "$filename" = "example-8" ] || [ "$filename" = "point" ] \
+ || [ "$filename" = "tables" ]; then
+ type_only=true
+ fi
+
+ echo "Regenerating $filename"
+ $BANJO_BIN --backend C $zx --output "$C_FILES/$filename.h" $dependencies --files $f
+ if [ $type_only = false ]; then
+ $BANJO_BIN --backend cpp $zx --output "$CPP_FILES/$filename.h" $dependencies --files $f
+ $BANJO_BIN --backend cpp_i $zx --output "$CPP_FILES/$filename-internal.h" $dependencies --files $f
+ fi
+ # $BANJO_BIN --backend rust $zx --output "$RUST_FILES/$filename.rs" $dependencies --files $f
+done
+