Skip to content

Commit d7d7f60

Browse files
committed
* code reformat
1 parent 6401078 commit d7d7f60

File tree

12 files changed

+614
-558
lines changed

12 files changed

+614
-558
lines changed

.lvimrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ packadd termdebug
2020
let g:termdebug_wide=1
2121

2222
nnoremap <leader>c :call asyncrun#run('',
23-
\ {'mode':'terminal','cwd':g:build_dir,'save':2},
23+
\ {'mode':'terminal','save':2},
2424
\ 'cmake -B '.g:build_dir.' -DCMAKE_BUILD_TYPE='.g:build_type.' -DBUILD_TESTS='.g:build_tests
2525
\ .' -DCMAKE_CXX_COMPILER='.g:cxx.' -DCMAKE_C_COMPILER='.g:cc
2626
\ .' -DCMAKE_EXPORT_COMPILE_COMMANDS=ON'

src/bindings/ejdb2_dart/lib/ejdb2_dart.c

+33-33
Original file line numberDiff line numberDiff line change
@@ -85,51 +85,51 @@ static void ejd_rename_wrapped(Dart_Port receive_port, Dart_CObject *msg, Dart_P
8585
static void ejd_bkp_wrapped(Dart_Port receive_port, Dart_CObject *msg, Dart_Port reply_port);
8686

8787
static struct NativeFunctionLookup k_scoped_functions[] = {
88-
{ "port", ejd_port },
89-
{ "exec", ejd_exec },
90-
{ "check_exec", ejd_exec_check },
91-
{ "jql_set", ejd_jql_set },
88+
{ "port", ejd_port },
89+
{ "exec", ejd_exec },
90+
{ "check_exec", ejd_exec_check },
91+
{ "jql_set", ejd_jql_set },
9292
{ "jql_get_limit", ejd_jql_get_limit },
93-
{ "create_query", ejd_create_query },
94-
{ "set_handle", ejd_set_handle },
95-
{ "get_handle", ejd_get_handle },
96-
{ "explain_rc", ejd_explain_rc },
97-
{ 0, 0 }
93+
{ "create_query", ejd_create_query },
94+
{ "set_handle", ejd_set_handle },
95+
{ "get_handle", ejd_get_handle },
96+
{ "explain_rc", ejd_explain_rc },
97+
{ 0, 0 }
9898
};
9999

100100
static struct WrapperFunctionLookup k_wrapped_functions[] = {
101-
{ "get", ejd_get_wrapped },
102-
{ "put", ejd_put_wrapped },
103-
{ "del", ejd_del_wrapped },
101+
{ "get", ejd_get_wrapped },
102+
{ "put", ejd_put_wrapped },
103+
{ "del", ejd_del_wrapped },
104104
{ "rename", ejd_rename_wrapped },
105-
{ "patch", ejd_patch_wrapped },
106-
{ "idx", ejd_idx_wrapped },
107-
{ "rmi", ejd_rmi_wrapped },
108-
{ "rmc", ejd_rmc_wrapped },
109-
{ "info", ejd_info_wrapped },
110-
{ "open", ejd_open_wrapped },
111-
{ "close", ejd_close_wrapped },
112-
{ "bkp", ejd_bkp_wrapped },
113-
{ 0, 0 }
105+
{ "patch", ejd_patch_wrapped },
106+
{ "idx", ejd_idx_wrapped },
107+
{ "rmi", ejd_rmi_wrapped },
108+
{ "rmc", ejd_rmc_wrapped },
109+
{ "info", ejd_info_wrapped },
110+
{ "open", ejd_open_wrapped },
111+
{ "close", ejd_close_wrapped },
112+
{ "bkp", ejd_bkp_wrapped },
113+
{ 0, 0 }
114114
};
115115

116116
#define EJTH(h_) ejd_error_check_propagate(h_)
117117

118-
#define EJGO(h_, rh_, label_) \
119-
if (Dart_IsError(h_)) { \
120-
rh_ = (h_); \
121-
goto label_; \
122-
}
118+
#define EJGO(h_, rh_, label_) \
119+
if (Dart_IsError(h_)) { \
120+
rh_ = (h_); \
121+
goto label_; \
122+
}
123123

124124
#define EJLIB() EJTH(Dart_LookupLibrary(Dart_NewStringFromCString("package:ejdb2_dart/ejdb2_dart.dart")))
125125

126-
#define EJPORT_RC(co_, rc_) \
127-
if (rc_) { \
128-
(co_)->type = Dart_CObject_kInt64; \
129-
(co_)->value.as_int64 = (rc_); \
130-
}
126+
#define EJPORT_RC(co_, rc_) \
127+
if (rc_) { \
128+
(co_)->type = Dart_CObject_kInt64; \
129+
(co_)->value.as_int64 = (rc_); \
130+
}
131131

132-
IW_INLINE char *cobject_str(Dart_CObject *co, bool nulls, iwrc *rcp) {
132+
IW_INLINE char* cobject_str(Dart_CObject *co, bool nulls, iwrc *rcp) {
133133
*rcp = 0;
134134
if (co) {
135135
if (co->type == Dart_CObject_kString) {
@@ -1452,7 +1452,7 @@ static void ejd_get_wrapped(Dart_Port receive_port, Dart_CObject *msg, Dart_Port
14521452
//
14531453
///////////////////////////////////////////////////////////////////////////
14541454

1455-
static const char *ejd_ecodefn(locale_t locale, uint32_t ecode) {
1455+
static const char* ejd_ecodefn(locale_t locale, uint32_t ecode) {
14561456
if (!((ecode > _EJD_ERROR_START) && (ecode < _EJD_ERROR_END))) {
14571457
return 0;
14581458
}

src/bindings/ejdb2_jni/src/ejdb2jni.c

+18-20
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ static jfieldID k_JQL_collection_fid;
4141
static jfieldID k_JQL_skip_fid;
4242
static jfieldID k_JQL_limit_fid;
4343

44-
#define JBNFIELD(fid_, env_, clazz_, name_, type_) \
45-
fid_ = (*(env_))->GetFieldID(env_, clazz_, name_, type_);
44+
#define JBNFIELD(fid_, env_, clazz_, name_, type_) \
45+
fid_ = (*(env_))->GetFieldID(env_, clazz_, name_, type_);
4646

47-
#define JBNFIELD2(fid_, env_, clazz_, name_, type_, label_) \
48-
fid_ = (*(env_))->GetFieldID(env_, clazz_, name_, type_); \
49-
if (!fid_) goto label_;
47+
#define JBNFIELD2(fid_, env_, clazz_, name_, type_, label_) \
48+
fid_ = (*(env_))->GetFieldID(env_, clazz_, name_, type_); \
49+
if (!fid_) goto label_;
5050

5151
typedef struct JBN_JSPRINT_CTX {
5252
int flush_buffer_sz;
@@ -582,7 +582,6 @@ JNIEXPORT void JNICALL Java_com_softmotions_ejdb2_EJDB2__1ensure_1index(
582582
jstring coll_,
583583
jstring path_,
584584
jint mode) {
585-
586585
iwrc rc;
587586
EJDB db;
588587
const char *coll = (*env)->GetStringUTFChars(env, coll_, 0);
@@ -782,7 +781,7 @@ JNIEXPORT void JNICALL Java_com_softmotions_ejdb2_JQL__1execute(
782781
RCGO(rc, finish);
783782

784783
JBN_EXEC_CTX ectx = {
785-
.env = env,
784+
.env = env,
786785
.cbObj = cbObj
787786
};
788787

@@ -805,13 +804,13 @@ JNIEXPORT void JNICALL Java_com_softmotions_ejdb2_JQL__1execute(
805804
}
806805

807806
EJDB_EXEC ux = {
808-
.db = db,
809-
.q = q,
810-
.skip = skip > 0 ? skip : 0,
811-
.limit = limit > 0 ? limit : 0,
812-
.opaque = &ectx,
807+
.db = db,
808+
.q = q,
809+
.skip = skip > 0 ? skip : 0,
810+
.limit = limit > 0 ? limit : 0,
811+
.opaque = &ectx,
813812
.visitor = cbObj ? jbn_exec_visitor : 0,
814-
.log = log
813+
.log = log
815814
};
816815

817816
rc = ejdb_exec(&ux);
@@ -875,11 +874,11 @@ JNIEXPORT jlong JNICALL Java_com_softmotions_ejdb2_JQL__1execute_1scalar_1long(
875874
}
876875

877876
EJDB_EXEC ux = {
878-
.db = db,
879-
.q = q,
880-
.skip = skip > 0 ? skip : 0,
877+
.db = db,
878+
.q = q,
879+
.skip = skip > 0 ? skip : 0,
881880
.limit = limit > 0 ? limit : 0,
882-
.log = log
881+
.log = log
883882
};
884883

885884
rc = ejdb_exec(&ux);
@@ -1005,7 +1004,6 @@ JNIEXPORT void JNICALL Java_com_softmotions_ejdb2_JQL__1set_1long(
10051004
jint pos,
10061005
jstring placeholder_,
10071006
jlong val) {
1008-
10091007
JQL q;
10101008
iwrc rc;
10111009
const char *placeholder = 0;
@@ -1139,7 +1137,7 @@ JNIEXPORT jlong JNICALL Java_com_softmotions_ejdb2_JQL__1get_1skip(JNIEnv *env,
11391137
return (jlong) skip;
11401138
}
11411139

1142-
static const char *jbn_ecodefn(locale_t locale, uint32_t ecode) {
1140+
static const char* jbn_ecodefn(locale_t locale, uint32_t ecode) {
11431141
if (!((ecode > _JBN_ERROR_START) && (ecode < _JBN_ERROR_END))) {
11441142
return 0;
11451143
}
@@ -1225,4 +1223,4 @@ JNIEXPORT void JNI_OnUnload(JavaVM *vm, void *reserved) { // Not really useless
12251223
if (k_EJDB2Exception_clazz) {
12261224
(*env)->DeleteGlobalRef(env, k_EJDB2Exception_clazz);
12271225
}
1228-
}
1226+
}

src/bindings/ejdb2_node/ejdb2_node.c

+31-32
Original file line numberDiff line numberDiff line change
@@ -26,44 +26,44 @@ IW_INLINE bool jn_is_exception_pending(napi_env env) {
2626
}
2727

2828
#define JNTHROW(env, rc, message) \
29-
jn_throw_error(env, rc, "ejdb2_node.c" ":" STR(__LINE__), message)
29+
jn_throw_error(env, rc, "ejdb2_node.c" ":" STR(__LINE__), message)
3030

31-
#define JNTHROW_LAST(env) do { \
32-
const napi_extended_error_info *info = 0; \
33-
napi_get_last_error_info((env), &info); \
34-
if (info) JNTHROW((env), 0, info->error_message); \
31+
#define JNTHROW_LAST(env) do { \
32+
const napi_extended_error_info *info = 0; \
33+
napi_get_last_error_info((env), &info); \
34+
if (info) JNTHROW((env), 0, info->error_message); \
3535
} while (0)
3636

37-
#define JNCHECK(ns, env) do { \
38-
if (ns && ns != napi_pending_exception) { \
39-
JNTHROW_LAST(env); \
40-
} \
37+
#define JNCHECK(ns, env) do { \
38+
if (ns && ns != napi_pending_exception) { \
39+
JNTHROW_LAST(env); \
40+
} \
4141
} while (0)
4242

43-
#define JNRC(env, rc) do { \
44-
if (rc && !jn_is_exception_pending(env)) { \
45-
JNTHROW(env, rc, 0); \
46-
} \
43+
#define JNRC(env, rc) do { \
44+
if (rc && !jn_is_exception_pending(env)) { \
45+
JNTHROW(env, rc, 0); \
46+
} \
4747
} while (0)
4848

4949
#define JNRET(ns, env, call, res) do { \
50-
ns = (call); \
51-
if (ns) { \
52-
if (ns != napi_pending_exception) { \
53-
JNTHROW_LAST(env); \
54-
} \
55-
return (res); \
56-
} \
50+
ns = (call); \
51+
if (ns) { \
52+
if (ns != napi_pending_exception) { \
53+
JNTHROW_LAST(env); \
54+
} \
55+
return (res); \
56+
} \
5757
} while (0)
5858

5959
#define JNGO(ns, env, call, label) do { \
60-
ns = (call); \
61-
if (ns) { \
62-
if (ns != napi_pending_exception) { \
63-
JNTHROW_LAST(env); \
64-
} \
65-
goto label; \
66-
} \
60+
ns = (call); \
61+
if (ns) { \
62+
if (ns != napi_pending_exception) { \
63+
JNTHROW_LAST(env); \
64+
} \
65+
goto label; \
66+
} \
6767
} while (0)
6868

6969
static napi_value jn_create_error(napi_env env, iwrc rc, const char *location, const char *msg) {
@@ -203,7 +203,7 @@ IW_INLINE napi_value jn_create_int64(napi_env env, int64_t val) {
203203
return ret;
204204
}
205205

206-
static char *jn_string(napi_env env, napi_value val_, IWPOOL *pool, bool nulls, bool coerce, iwrc *rcp) {
206+
static char* jn_string(napi_env env, napi_value val_, IWPOOL *pool, bool nulls, bool coerce, iwrc *rcp) {
207207
*rcp = 0;
208208
size_t len = 0;
209209
napi_status ns = 0;
@@ -242,7 +242,7 @@ static char *jn_string(napi_env env, napi_value val_, IWPOOL *pool, bool nulls,
242242
return buf;
243243
}
244244

245-
static char *jn_string_at(
245+
static char* jn_string_at(
246246
napi_env env, IWPOOL *pool, napi_value arr,
247247
bool nulls, bool coerce, uint32_t idx, iwrc *rcp) {
248248
*rcp = 0;
@@ -410,7 +410,7 @@ static JNWORK jn_work_create(iwrc *rcp) {
410410
return w;
411411
}
412412

413-
static void *jn_work_alloc_data(size_t siz, JNWORK work, iwrc *rcp) {
413+
static void* jn_work_alloc_data(size_t siz, JNWORK work, iwrc *rcp) {
414414
*rcp = 0;
415415
work->data = iwpool_calloc(siz, work->pool);
416416
if (!work->data) {
@@ -1445,7 +1445,6 @@ static void jn_resultset_tsf(
14451445
napi_value js_add_stream,
14461446
void *context,
14471447
void *data) {
1448-
14491448
if (!env) { // shutdown pending
14501449
JNCS cs = data;
14511450
jn_cs_destroy(&cs);
@@ -2008,7 +2007,7 @@ static napi_value jn_jql_limit(napi_env env, napi_callback_info info) {
20082007

20092008
// ----------------
20102009

2011-
static const char *jn_ecodefn(locale_t locale, uint32_t ecode) {
2010+
static const char* jn_ecodefn(locale_t locale, uint32_t ecode) {
20122011
if (!((ecode > _JN_ERROR_START) && (ecode < _JN_ERROR_END))) {
20132012
return 0;
20142013
}

src/ejdb2.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -1205,8 +1205,7 @@ iwrc ejdb_ensure_index(EJDB db, const char *coll, const char *path, ejdb_idx_mod
12051205

12061206
static iwrc _jb_patch(
12071207
EJDB db, const char *coll, int64_t id, bool upsert,
1208-
const char *patchjson, JBL_NODE patchjbn, JBL patchjbl
1209-
) {
1208+
const char *patchjson, JBL_NODE patchjbn, JBL patchjbl) {
12101209
int rci;
12111210
JBCOLL jbc;
12121211
struct jbl sjbl;

src/examples/example1.c

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
/// Sample records put/query example
22
#include <ejdb2.h>
33

4-
#define CHECK(rc_) \
5-
if (rc_) { \
6-
iwlog_ecode_error3(rc_); \
7-
return 1; \
8-
}
4+
#define CHECK(rc_) \
5+
if (rc_) { \
6+
iwlog_ecode_error3(rc_); \
7+
return 1; \
8+
}
99

1010
static iwrc documents_visitor(EJDB_EXEC *ctx, const EJDB_DOC doc, int64_t *step) {
1111
// Print document to stderr
1212
return jbl_as_json(doc->raw, jbl_fstream_json_printer, stderr, JBL_PRINT_PRETTY);
1313
}
1414

1515
int main() {
16-
1716
EJDB_OPTS opts = {
18-
.kv = {
19-
.path = "example.db",
17+
.kv = {
18+
.path = "example.db",
2019
.oflags = IWKV_TRUNC
2120
}
2221
};
@@ -50,8 +49,8 @@ int main() {
5049
RCGO(rc, finish);
5150

5251
EJDB_EXEC ux = {
53-
.db = db,
54-
.q = q,
52+
.db = db,
53+
.q = q,
5554
.visitor = documents_visitor
5655
};
5756

src/jbi/jbi_selection.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,7 @@ static iwrc _jbi_collect_indexes(
268268
JBEXEC *ctx,
269269
const struct jqp_expr_node *en,
270270
struct _JBMIDX marr[static JB_SOLID_EXPRNUM],
271-
size_t *snp
272-
) {
271+
size_t *snp) {
273272
iwrc rc = 0;
274273
if (*snp >= JB_SOLID_EXPRNUM - 1) {
275274
return 0;

src/jbi/jbi_sorter_consumer.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,7 @@ static iwrc _jbi_scan_sorter_init(struct _JBSSC *ssc, off_t initial_size) {
172172

173173
iwrc jbi_sorter_consumer(
174174
struct _JBEXEC *ctx, IWKV_cursor cur, int64_t id,
175-
int64_t *step, bool *matched, iwrc err
176-
) {
175+
int64_t *step, bool *matched, iwrc err) {
177176
if (!id) {
178177
// End of scan
179178
if (err) {

0 commit comments

Comments
 (0)