Skip to content

Commit c0fd9a0

Browse files
committed
fix code style
1 parent 8c41b00 commit c0fd9a0

File tree

20 files changed

+109
-105
lines changed

20 files changed

+109
-105
lines changed

cli/main.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
typedef struct
1414
{
1515
const char *cmd;
16-
bool optHelp;
17-
bool optVersion;
18-
bool optEval;
19-
bool optAnalyze;
20-
bool optDump;
21-
bool optCompile;
22-
bool optRun;
23-
int stackSize;
16+
bool optHelp;
17+
bool optVersion;
18+
bool optEval;
19+
bool optAnalyze;
20+
bool optDump;
21+
bool optCompile;
22+
bool optRun;
23+
int stackSize;
2424
const char *input;
2525
const char *output;
2626
const char **args;
27-
int numArgs;
27+
int numArgs;
2828
} ParsedArgs;
2929

3030
static inline void fatal_error(const char *fmt, ...);

core/lists.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ typedef struct LinkedListNode
1010
{
1111
struct LinkedListNode *next;
1212
struct LinkedListNode *prev;
13-
HkValue elem;
13+
HkValue elem;
1414
} LinkedListNode;
1515

1616
typedef struct
1717
{
1818
HK_USERDATA_HEADER
19-
int length;
19+
int length;
2020
LinkedListNode *head;
2121
LinkedListNode *tail;
2222
} LinkedList;

core/socket.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@
3434
typedef struct
3535
{
3636
HK_USERDATA_HEADER
37-
int domain;
38-
int type;
39-
int protocol;
37+
int domain;
38+
int type;
39+
int protocol;
4040
Socket sock;
4141
} SocketUserdata;
4242

extensions/curl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
typedef struct
1010
{
1111
HK_USERDATA_HEADER
12-
CURL *curl;
12+
CURL *curl;
1313
CURLcode res;
1414
HkString *url;
15-
HkArray *headers;
15+
HkArray *headers;
1616
} CurlWrapper;
1717

1818
static int initialized = 0;

include/hook/array.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
typedef struct
1818
{
1919
HK_OBJECT_HEADER
20-
int capacity;
21-
int length;
20+
int capacity;
21+
int length;
2222
HkValue *elements;
2323
} HkArray;
2424

include/hook/callable.h

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,34 +9,36 @@
99
#include "chunk.h"
1010
#include "string.h"
1111

12-
typedef struct hk_function
12+
typedef struct HkFunction
1313
{
1414
HK_OBJECT_HEADER
15-
int arity;
16-
HkString *name;
17-
HkString *file;
18-
HkChunk chunk;
19-
uint8_t functionsCapacity;
20-
uint8_t functionsLength;
21-
struct hk_function **functions;
22-
uint8_t numNonlocals;
15+
int arity;
16+
HkString *name;
17+
HkString *file;
18+
HkChunk chunk;
19+
uint8_t functionsCapacity;
20+
uint8_t functionsLength;
21+
struct HkFunction **functions;
22+
uint8_t numNonlocals;
2323
} HkFunction;
2424

2525
typedef struct
2626
{
2727
HK_OBJECT_HEADER
2828
HkFunction *fn;
29-
HkValue nonlocals[1];
29+
HkValue nonlocals[1];
3030
} HkClosure;
3131

32-
struct hk_state;
32+
struct HkState;
33+
34+
typedef void (*HkCallFn)(struct HkState *, HkValue *);
3335

3436
typedef struct
3537
{
3638
HK_OBJECT_HEADER
37-
int arity;
39+
int arity;
3840
HkString *name;
39-
void (*call)(struct hk_state *, HkValue *);
41+
HkCallFn call;
4042
} HkNative;
4143

4244
HkFunction *hk_function_new(int arity, HkString *name, HkString *file);
@@ -48,7 +50,7 @@ HkFunction *hk_function_deserialize(FILE *stream);
4850
HkClosure *hk_closure_new(HkFunction *fn);
4951
void hk_closure_free(HkClosure *cl);
5052
void hk_closure_release(HkClosure *cl);
51-
HkNative *hk_native_new(HkString *name, int arity, void (*call)(struct hk_state *, HkValue *));
53+
HkNative *hk_native_new(HkString *name, int arity, HkCallFn call);
5254
void hk_native_free(HkNative *native);
5355
void hk_native_release(HkNative *native);
5456

include/hook/chunk.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ typedef struct
4343

4444
typedef struct
4545
{
46-
int codeCapacity;
47-
int codeLength;
46+
int codeCapacity;
47+
int codeLength;
4848
uint8_t *code;
49-
int linesCapacity;
50-
int linesLength;
51-
HkLine *lines;
49+
int linesCapacity;
50+
int linesLength;
51+
HkLine *lines;
5252
HkArray *consts;
5353
} HkChunk;
5454

include/hook/iterator.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@
99
#include "value.h"
1010

1111
#define HK_ITERATOR_HEADER HK_OBJECT_HEADER \
12-
void (*deinit)(struct hk_iterator *); \
13-
bool (*isValid)(struct hk_iterator *); \
14-
HkValue (*getCurrent)(struct hk_iterator *); \
15-
struct hk_iterator *(*next)(struct hk_iterator *); \
16-
void (*inplaceNext)(struct hk_iterator *);
12+
void (*deinit)(struct HkIterator *); \
13+
bool (*isValid)(struct HkIterator *); \
14+
HkValue (*getCurrent)(struct HkIterator *); \
15+
struct HkIterator *(*next)(struct HkIterator *); \
16+
void (*inplaceNext)(struct HkIterator *);
1717

18-
typedef struct hk_iterator
18+
typedef struct HkIterator
1919
{
2020
HK_ITERATOR_HEADER
2121
} HkIterator;
2222

23-
void hk_iterator_init(HkIterator *it, void (*deinit)(struct hk_iterator *),
24-
bool (*isValid)(struct hk_iterator *), HkValue (*getCurrent)(struct hk_iterator *),
25-
struct hk_iterator *(*next)(struct hk_iterator *), void (*inplaceNext)(struct hk_iterator *));
23+
void hk_iterator_init(HkIterator *it, void (*deinit)(HkIterator *),
24+
bool (*isValid)(HkIterator *), HkValue (*getCurrent)(HkIterator *),
25+
HkIterator *(*next)(HkIterator *), void (*inplaceNext)(HkIterator *));
2626
void hk_iterator_free(HkIterator *it);
2727
void hk_iterator_release(HkIterator *it);
2828
bool hk_iterator_is_valid(HkIterator *it);

include/hook/range.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
typedef struct
1313
{
1414
HK_OBJECT_HEADER
15-
int step;
15+
int step;
1616
int64_t start;
1717
int64_t end;
1818
} HkRange;

include/hook/state.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ typedef enum
3535
HK_STATE_STATUS_ERROR
3636
} HkSateStatus;
3737

38-
typedef struct hk_state
38+
typedef struct HkState
3939
{
40-
int stackEnd;
41-
int stackTop;
42-
HkValue *stackSlots;
43-
int flags;
40+
int stackEnd;
41+
int stackTop;
42+
HkValue *stackSlots;
43+
int flags;
4444
HkSateStatus status;
4545
} HkState;
4646

@@ -74,7 +74,8 @@ void hk_state_push_instance(HkState *state, HkInstance *inst);
7474
void hk_state_push_iterator(HkState *state, HkIterator *it);
7575
void hk_state_push_closure(HkState *state, HkClosure *cl);
7676
void hk_state_push_native(HkState *state, HkNative *native);
77-
void hk_state_push_new_native(HkState *state, const char *name, int arity, void (*call)(HkState *, HkValue *));
77+
void hk_state_push_new_native(HkState *state, const char *name, int arity,
78+
HkCallFn call);
7879
void hk_state_push_userdata(HkState *state, HkUserdata *udata);
7980
void hk_state_array(HkState *state, int length);
8081
void hk_state_struct(HkState *state, int length);

0 commit comments

Comments
 (0)