forked from ElementsProject/lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add parsing know-how for enum fields. This is necessary for internally defined wire generators. Enums are denoted by prefixing the field with an `e:`. Ex: msgdata,msg_name,field_name,e:enum_type,
- Loading branch information
1 parent
cfd56d8
commit b30d7d2
Showing
5 changed files
with
46 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "enum.h" | ||
#include <stdio.h> | ||
|
||
void towire_test_enum(u8 **pptr, const enum test_enum test_enum) | ||
{ | ||
printf("this would have been the towire for enum %u\n", test_enum); | ||
} | ||
|
||
enum test_enum fromwire_test_enum(const u8 **cursor, size_t *max) | ||
{ | ||
printf("fromwire_test_enum at %ld\n", *max); | ||
return TEST_ONE; | ||
} | ||
|
||
void printwire_test_enum(const char *fieldname, const enum test_enum *test_enum) | ||
{ | ||
printf("%u\n", *test_enum); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#ifndef LIGHTNING_TOOLS_TEST_ENUM_H | ||
#define LIGHTNING_TOOLS_TEST_ENUM_H | ||
#include <ccan/short_types/short_types.h> | ||
#include <stdlib.h> | ||
|
||
enum test_enum { | ||
TEST_ONE, | ||
TEST_TWO, | ||
}; | ||
|
||
void towire_test_enum(u8 **pptr, const enum test_enum test_enum); | ||
enum test_enum fromwire_test_enum(const u8 **cursor, size_t *max); | ||
void printwire_test_enum(const char *fieldname, const enum test_enum *test_enum); | ||
|
||
#endif /* LIGHTNING_TOOLS_TEST_ENUM_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters