Skip to content

Commit de8e2d1

Browse files
committed
Clang format GNU minus includes sort
1 parent 2a2439e commit de8e2d1

File tree

308 files changed

+68113
-77226
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

308 files changed

+68113
-77226
lines changed

src/java/nxt_jni.c

Lines changed: 101 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -11,165 +11,137 @@
1111

1212
#include "nxt_jni.h"
1313

14-
15-
static jclass nxt_java_NoSuchElementException_class;
16-
static jclass nxt_java_IOException_class;
17-
static jclass nxt_java_IllegalStateException_class;
18-
static jclass nxt_java_File_class;
19-
static jmethodID nxt_java_File_ctor;
14+
static jclass nxt_java_NoSuchElementException_class;
15+
static jclass nxt_java_IOException_class;
16+
static jclass nxt_java_IllegalStateException_class;
17+
static jclass nxt_java_File_class;
18+
static jmethodID nxt_java_File_ctor;
2019

2120
static inline char nxt_java_lowcase(char c);
2221

23-
24-
int
25-
nxt_java_jni_init(JNIEnv *env)
26-
{
27-
jclass cls;
28-
29-
cls = (*env)->FindClass(env, "java/util/NoSuchElementException");
30-
if (cls == NULL) {
31-
return NXT_UNIT_ERROR;
32-
}
33-
34-
nxt_java_NoSuchElementException_class = (*env)->NewGlobalRef(env, cls);
35-
(*env)->DeleteLocalRef(env, cls);
36-
37-
38-
cls = (*env)->FindClass(env, "java/io/IOException");
39-
if (cls == NULL) {
40-
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
41-
return NXT_UNIT_ERROR;
42-
}
43-
44-
nxt_java_IOException_class = (*env)->NewGlobalRef(env, cls);
45-
(*env)->DeleteLocalRef(env, cls);
46-
47-
48-
cls = (*env)->FindClass(env, "java/lang/IllegalStateException");
49-
if (cls == NULL) {
50-
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
51-
(*env)->DeleteGlobalRef(env, nxt_java_IOException_class);
52-
return NXT_UNIT_ERROR;
53-
}
54-
55-
nxt_java_IllegalStateException_class = (*env)->NewGlobalRef(env, cls);
56-
(*env)->DeleteLocalRef(env, cls);
57-
58-
59-
cls = (*env)->FindClass(env, "java/io/File");
60-
if (cls == NULL) {
61-
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
62-
(*env)->DeleteGlobalRef(env, nxt_java_IOException_class);
63-
(*env)->DeleteGlobalRef(env, nxt_java_IllegalStateException_class);
64-
return NXT_UNIT_ERROR;
65-
}
66-
67-
nxt_java_File_class = (*env)->NewGlobalRef(env, cls);
68-
(*env)->DeleteLocalRef(env, cls);
69-
70-
71-
nxt_java_File_ctor = (*env)->GetMethodID(env, nxt_java_File_class, "<init>",
72-
"(Ljava/lang/String;)V");
73-
if (nxt_java_File_ctor == NULL) {
74-
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
75-
(*env)->DeleteGlobalRef(env, nxt_java_IOException_class);
76-
(*env)->DeleteGlobalRef(env, nxt_java_IllegalStateException_class);
77-
(*env)->DeleteGlobalRef(env, nxt_java_File_class);
78-
return NXT_UNIT_ERROR;
79-
}
80-
81-
return NXT_UNIT_OK;
22+
int nxt_java_jni_init(JNIEnv *env) {
23+
jclass cls;
24+
25+
cls = (*env)->FindClass(env, "java/util/NoSuchElementException");
26+
if (cls == NULL) {
27+
return NXT_UNIT_ERROR;
28+
}
29+
30+
nxt_java_NoSuchElementException_class = (*env)->NewGlobalRef(env, cls);
31+
(*env)->DeleteLocalRef(env, cls);
32+
33+
cls = (*env)->FindClass(env, "java/io/IOException");
34+
if (cls == NULL) {
35+
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
36+
return NXT_UNIT_ERROR;
37+
}
38+
39+
nxt_java_IOException_class = (*env)->NewGlobalRef(env, cls);
40+
(*env)->DeleteLocalRef(env, cls);
41+
42+
cls = (*env)->FindClass(env, "java/lang/IllegalStateException");
43+
if (cls == NULL) {
44+
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
45+
(*env)->DeleteGlobalRef(env, nxt_java_IOException_class);
46+
return NXT_UNIT_ERROR;
47+
}
48+
49+
nxt_java_IllegalStateException_class = (*env)->NewGlobalRef(env, cls);
50+
(*env)->DeleteLocalRef(env, cls);
51+
52+
cls = (*env)->FindClass(env, "java/io/File");
53+
if (cls == NULL) {
54+
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
55+
(*env)->DeleteGlobalRef(env, nxt_java_IOException_class);
56+
(*env)->DeleteGlobalRef(env, nxt_java_IllegalStateException_class);
57+
return NXT_UNIT_ERROR;
58+
}
59+
60+
nxt_java_File_class = (*env)->NewGlobalRef(env, cls);
61+
(*env)->DeleteLocalRef(env, cls);
62+
63+
nxt_java_File_ctor = (*env)->GetMethodID(env, nxt_java_File_class, "<init>",
64+
"(Ljava/lang/String;)V");
65+
if (nxt_java_File_ctor == NULL) {
66+
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
67+
(*env)->DeleteGlobalRef(env, nxt_java_IOException_class);
68+
(*env)->DeleteGlobalRef(env, nxt_java_IllegalStateException_class);
69+
(*env)->DeleteGlobalRef(env, nxt_java_File_class);
70+
return NXT_UNIT_ERROR;
71+
}
72+
73+
return NXT_UNIT_OK;
8274
}
8375

84-
85-
void
86-
nxt_java_throw_NoSuchElementException(JNIEnv *env, const char *msg)
87-
{
88-
(*env)->ThrowNew(env, nxt_java_NoSuchElementException_class, msg);
76+
void nxt_java_throw_NoSuchElementException(JNIEnv *env, const char *msg) {
77+
(*env)->ThrowNew(env, nxt_java_NoSuchElementException_class, msg);
8978
}
9079

91-
92-
void
93-
nxt_java_throw_IOException(JNIEnv *env, const char *msg)
94-
{
95-
(*env)->ThrowNew(env, nxt_java_IOException_class, msg);
80+
void nxt_java_throw_IOException(JNIEnv *env, const char *msg) {
81+
(*env)->ThrowNew(env, nxt_java_IOException_class, msg);
9682
}
9783

98-
99-
void
100-
nxt_java_throw_IllegalStateException(JNIEnv *env, const char *msg)
101-
{
102-
(*env)->ThrowNew(env, nxt_java_IllegalStateException_class, msg);
84+
void nxt_java_throw_IllegalStateException(JNIEnv *env, const char *msg) {
85+
(*env)->ThrowNew(env, nxt_java_IllegalStateException_class, msg);
10386
}
10487

88+
nxt_unit_field_t *nxt_java_findHeader(nxt_unit_field_t *f,
89+
nxt_unit_field_t *end, const char *name,
90+
uint8_t name_len) {
91+
const char *field_name;
10592

106-
nxt_unit_field_t *
107-
nxt_java_findHeader(nxt_unit_field_t *f, nxt_unit_field_t *end,
108-
const char *name, uint8_t name_len)
109-
{
110-
const char *field_name;
111-
112-
for (/* void */ ; f < end; f++) {
113-
if (f->skip != 0 || f->name_length != name_len) {
114-
continue;
115-
}
93+
for (/* void */; f < end; f++) {
94+
if (f->skip != 0 || f->name_length != name_len) {
95+
continue;
96+
}
11697

117-
field_name = nxt_unit_sptr_get(&f->name);
98+
field_name = nxt_unit_sptr_get(&f->name);
11899

119-
if (nxt_java_strcaseeq(name, field_name, name_len)) {
120-
return f;
121-
}
100+
if (nxt_java_strcaseeq(name, field_name, name_len)) {
101+
return f;
122102
}
103+
}
123104

124-
return NULL;
105+
return NULL;
125106
}
126107

108+
int nxt_java_strcaseeq(const char *str1, const char *str2, int len) {
109+
char c1, c2;
110+
const char *end1;
127111

128-
int
129-
nxt_java_strcaseeq(const char *str1, const char *str2, int len)
130-
{
131-
char c1, c2;
132-
const char *end1;
112+
end1 = str1 + len;
133113

134-
end1 = str1 + len;
114+
while (str1 < end1) {
115+
c1 = nxt_java_lowcase(*str1++);
116+
c2 = nxt_java_lowcase(*str2++);
135117

136-
while (str1 < end1) {
137-
c1 = nxt_java_lowcase(*str1++);
138-
c2 = nxt_java_lowcase(*str2++);
139-
140-
if (c1 != c2) {
141-
return 0;
142-
}
118+
if (c1 != c2) {
119+
return 0;
143120
}
121+
}
144122

145-
return 1;
123+
return 1;
146124
}
147125

148-
149-
static inline char
150-
nxt_java_lowcase(char c)
151-
{
152-
return (c >= 'A' && c <= 'Z') ? c | 0x20 : c;
126+
static inline char nxt_java_lowcase(char c) {
127+
return (c >= 'A' && c <= 'Z') ? c | 0x20 : c;
153128
}
154129

130+
jstring nxt_java_newString(JNIEnv *env, char *str, uint32_t len) {
131+
char tmp;
132+
jstring res;
155133

156-
jstring
157-
nxt_java_newString(JNIEnv *env, char *str, uint32_t len)
158-
{
159-
char tmp;
160-
jstring res;
134+
tmp = str[len];
161135

162-
tmp = str[len];
136+
if (tmp != '\0') {
137+
str[len] = '\0';
138+
}
163139

164-
if (tmp != '\0') {
165-
str[len] = '\0';
166-
}
167-
168-
res = (*env)->NewStringUTF(env, str);
140+
res = (*env)->NewStringUTF(env, str);
169141

170-
if (tmp != '\0') {
171-
str[len] = tmp;
172-
}
142+
if (tmp != '\0') {
143+
str[len] = tmp;
144+
}
173145

174-
return res;
146+
return res;
175147
}

src/java/nxt_jni.h

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@
66
#ifndef _NXT_JAVA_JNI_H_INCLUDED_
77
#define _NXT_JAVA_JNI_H_INCLUDED_
88

9-
109
#include <jni.h>
1110
#include <nxt_unit_typedefs.h>
1211

13-
1412
int nxt_java_jni_init(JNIEnv *env);
1513

1614
void nxt_java_throw_NoSuchElementException(JNIEnv *env, const char *msg);
@@ -20,36 +18,26 @@ void nxt_java_throw_IOException(JNIEnv *env, const char *msg);
2018
void nxt_java_throw_IllegalStateException(JNIEnv *env, const char *msg);
2119

2220
nxt_unit_field_t *nxt_java_findHeader(nxt_unit_field_t *f, nxt_unit_field_t *e,
23-
const char *name, uint8_t name_len);
21+
const char *name, uint8_t name_len);
2422

2523
int nxt_java_strcaseeq(const char *str1, const char *str2, int len);
2624

2725
jstring nxt_java_newString(JNIEnv *env, char *str, uint32_t len);
2826

29-
3027
typedef struct {
31-
uint32_t header_size;
32-
uint32_t buf_size;
28+
uint32_t header_size;
29+
uint32_t buf_size;
3330

34-
jobject jreq;
35-
jobject jresp;
31+
jobject jreq;
32+
jobject jresp;
3633

37-
nxt_unit_buf_t *first;
38-
nxt_unit_buf_t *buf;
34+
nxt_unit_buf_t *first;
35+
nxt_unit_buf_t *buf;
3936

4037
} nxt_java_request_data_t;
4138

39+
static inline jlong nxt_ptr2jlong(void *ptr) { return (jlong)(intptr_t)ptr; }
4240

43-
static inline jlong
44-
nxt_ptr2jlong(void *ptr)
45-
{
46-
return (jlong) (intptr_t) ptr;
47-
}
48-
49-
static inline void *
50-
nxt_jlong2ptr(jlong l)
51-
{
52-
return (void *) (intptr_t) l;
53-
}
41+
static inline void *nxt_jlong2ptr(jlong l) { return (void *)(intptr_t)l; }
5442

55-
#endif /* _NXT_JAVA_JNI_H_INCLUDED_ */
43+
#endif /* _NXT_JAVA_JNI_H_INCLUDED_ */

0 commit comments

Comments
 (0)