Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ Change any of the following values by passing `-option="Value"` CLI flag to `web
| `-client` | generate client declarations and runtime | `true` | v0.0.1 |
| `-emit=<mode>` | emit either `header` or `impl` | `header` | v0.0.1 |
| `-header=<file>` | header include used by `impl` output | `<prefix>.h` | v0.0.1 |
| `-schemaHash=false` | omit the schema hash from generated output | `true` | v0.1.6 |

## Notes

Expand Down
31 changes: 30 additions & 1 deletion _examples/smoke/example.gen.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// smoke v1.0.0 6dc82371b24d044c3b3e2bd4cf5d92af46788fff
// smoke v1.0.0 4f8e43ea7aa717c9a0a6cdfcff7f798e159e25b1
// --
// Code generated by webrpc-gen@v0.37.2 with .. generator. DO NOT EDIT.
//
Expand Down Expand Up @@ -556,6 +556,17 @@ static SMOKE_JSON_UNUSED cJSON *smoke_profile_to_json(const smoke_profile *value
{
cJSON *field_json = NULL;


field_json = cJSON_CreateNumber((double)value->user_id);
if (!field_json) goto fail;
if (!cJSON_AddItemToObject(root, "userId", field_json)) {
cJSON_Delete(field_json);
goto fail;
}
}
{
cJSON *field_json = NULL;

field_json = value->name ? cJSON_CreateString(value->name) : cJSON_CreateNull();
if (!field_json) goto fail;
if (!cJSON_AddItemToObject(root, "name", field_json)) {
Expand Down Expand Up @@ -659,6 +670,24 @@ static SMOKE_JSON_UNUSED int smoke_profile_from_json(const cJSON *json, smoke_pr
goto fail;
}
}
{
cJSON *field_json = cJSON_GetObjectItemCaseSensitive(json, "userId");
int field_present = field_json != NULL;
if (!field_present || cJSON_IsNull(field_json)) {
smoke_set_error(error, 0, 0, "DecodeError", "missing required field userId", NULL);
goto fail;
}


{
uint64_t parsed = 0;
if (!smoke_cjson_get_uint64_exact(field_json, &parsed)) {
smoke_set_error(error, 0, 0, "DecodeError", "expected uint64 number", NULL);
goto fail;
}
out->user_id = parsed;
}
}
{
cJSON *field_json = cJSON_GetObjectItemCaseSensitive(json, "name");
int field_present = field_json != NULL;
Expand Down
5 changes: 4 additions & 1 deletion _examples/smoke/example.gen.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SMOKE_SMOKE_HEADER_H
#define SMOKE_SMOKE_HEADER_H

// smoke v1.0.0 6dc82371b24d044c3b3e2bd4cf5d92af46788fff
// smoke v1.0.0 4f8e43ea7aa717c9a0a6cdfcff7f798e159e25b1
// --
// Code generated by webrpc-gen@v0.37.2 with .. generator. DO NOT EDIT.
//
Expand Down Expand Up @@ -246,6 +246,7 @@ static inline int smoke_role_from_string(const char *value, smoke_role *out) {
}
struct smoke_profile {
smoke_bigint id;
uint64_t user_id;
char * name;
smoke_role role;
bool has_tags;
Expand All @@ -271,6 +272,8 @@ static inline void smoke_profile_free(smoke_profile *value) {

smoke_bigint_free(&value->id);



free(value->name);
value->name = NULL;

Expand Down
3 changes: 3 additions & 0 deletions _examples/smoke/example.ridl
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ enum Role: uint32
- USER
- ADMIN

type UserID: uint64

struct Profile
- id: bigint
- userId: UserID
- name: string
- role: Role
- tags?: []string
Expand Down
Loading