Skip to content

Commit

Permalink
Clang format GNU minus includes sort
Browse files Browse the repository at this point in the history
  • Loading branch information
javorszky committed Oct 24, 2024
1 parent 2a2439e commit de8e2d1
Show file tree
Hide file tree
Showing 308 changed files with 68,113 additions and 77,226 deletions.
230 changes: 101 additions & 129 deletions src/java/nxt_jni.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,165 +11,137 @@

#include "nxt_jni.h"


static jclass nxt_java_NoSuchElementException_class;
static jclass nxt_java_IOException_class;
static jclass nxt_java_IllegalStateException_class;
static jclass nxt_java_File_class;
static jmethodID nxt_java_File_ctor;
static jclass nxt_java_NoSuchElementException_class;
static jclass nxt_java_IOException_class;
static jclass nxt_java_IllegalStateException_class;
static jclass nxt_java_File_class;
static jmethodID nxt_java_File_ctor;

static inline char nxt_java_lowcase(char c);


int
nxt_java_jni_init(JNIEnv *env)
{
jclass cls;

cls = (*env)->FindClass(env, "java/util/NoSuchElementException");
if (cls == NULL) {
return NXT_UNIT_ERROR;
}

nxt_java_NoSuchElementException_class = (*env)->NewGlobalRef(env, cls);
(*env)->DeleteLocalRef(env, cls);


cls = (*env)->FindClass(env, "java/io/IOException");
if (cls == NULL) {
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
return NXT_UNIT_ERROR;
}

nxt_java_IOException_class = (*env)->NewGlobalRef(env, cls);
(*env)->DeleteLocalRef(env, cls);


cls = (*env)->FindClass(env, "java/lang/IllegalStateException");
if (cls == NULL) {
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
(*env)->DeleteGlobalRef(env, nxt_java_IOException_class);
return NXT_UNIT_ERROR;
}

nxt_java_IllegalStateException_class = (*env)->NewGlobalRef(env, cls);
(*env)->DeleteLocalRef(env, cls);


cls = (*env)->FindClass(env, "java/io/File");
if (cls == NULL) {
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
(*env)->DeleteGlobalRef(env, nxt_java_IOException_class);
(*env)->DeleteGlobalRef(env, nxt_java_IllegalStateException_class);
return NXT_UNIT_ERROR;
}

nxt_java_File_class = (*env)->NewGlobalRef(env, cls);
(*env)->DeleteLocalRef(env, cls);


nxt_java_File_ctor = (*env)->GetMethodID(env, nxt_java_File_class, "<init>",
"(Ljava/lang/String;)V");
if (nxt_java_File_ctor == NULL) {
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
(*env)->DeleteGlobalRef(env, nxt_java_IOException_class);
(*env)->DeleteGlobalRef(env, nxt_java_IllegalStateException_class);
(*env)->DeleteGlobalRef(env, nxt_java_File_class);
return NXT_UNIT_ERROR;
}

return NXT_UNIT_OK;
int nxt_java_jni_init(JNIEnv *env) {
jclass cls;

cls = (*env)->FindClass(env, "java/util/NoSuchElementException");
if (cls == NULL) {
return NXT_UNIT_ERROR;
}

nxt_java_NoSuchElementException_class = (*env)->NewGlobalRef(env, cls);
(*env)->DeleteLocalRef(env, cls);

cls = (*env)->FindClass(env, "java/io/IOException");
if (cls == NULL) {
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
return NXT_UNIT_ERROR;
}

nxt_java_IOException_class = (*env)->NewGlobalRef(env, cls);
(*env)->DeleteLocalRef(env, cls);

cls = (*env)->FindClass(env, "java/lang/IllegalStateException");
if (cls == NULL) {
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
(*env)->DeleteGlobalRef(env, nxt_java_IOException_class);
return NXT_UNIT_ERROR;
}

nxt_java_IllegalStateException_class = (*env)->NewGlobalRef(env, cls);
(*env)->DeleteLocalRef(env, cls);

cls = (*env)->FindClass(env, "java/io/File");
if (cls == NULL) {
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
(*env)->DeleteGlobalRef(env, nxt_java_IOException_class);
(*env)->DeleteGlobalRef(env, nxt_java_IllegalStateException_class);
return NXT_UNIT_ERROR;
}

nxt_java_File_class = (*env)->NewGlobalRef(env, cls);
(*env)->DeleteLocalRef(env, cls);

nxt_java_File_ctor = (*env)->GetMethodID(env, nxt_java_File_class, "<init>",
"(Ljava/lang/String;)V");
if (nxt_java_File_ctor == NULL) {
(*env)->DeleteGlobalRef(env, nxt_java_NoSuchElementException_class);
(*env)->DeleteGlobalRef(env, nxt_java_IOException_class);
(*env)->DeleteGlobalRef(env, nxt_java_IllegalStateException_class);
(*env)->DeleteGlobalRef(env, nxt_java_File_class);
return NXT_UNIT_ERROR;
}

return NXT_UNIT_OK;
}


void
nxt_java_throw_NoSuchElementException(JNIEnv *env, const char *msg)
{
(*env)->ThrowNew(env, nxt_java_NoSuchElementException_class, msg);
void nxt_java_throw_NoSuchElementException(JNIEnv *env, const char *msg) {
(*env)->ThrowNew(env, nxt_java_NoSuchElementException_class, msg);
}


void
nxt_java_throw_IOException(JNIEnv *env, const char *msg)
{
(*env)->ThrowNew(env, nxt_java_IOException_class, msg);
void nxt_java_throw_IOException(JNIEnv *env, const char *msg) {
(*env)->ThrowNew(env, nxt_java_IOException_class, msg);
}


void
nxt_java_throw_IllegalStateException(JNIEnv *env, const char *msg)
{
(*env)->ThrowNew(env, nxt_java_IllegalStateException_class, msg);
void nxt_java_throw_IllegalStateException(JNIEnv *env, const char *msg) {
(*env)->ThrowNew(env, nxt_java_IllegalStateException_class, msg);
}

nxt_unit_field_t *nxt_java_findHeader(nxt_unit_field_t *f,
nxt_unit_field_t *end, const char *name,
uint8_t name_len) {
const char *field_name;

nxt_unit_field_t *
nxt_java_findHeader(nxt_unit_field_t *f, nxt_unit_field_t *end,
const char *name, uint8_t name_len)
{
const char *field_name;

for (/* void */ ; f < end; f++) {
if (f->skip != 0 || f->name_length != name_len) {
continue;
}
for (/* void */; f < end; f++) {
if (f->skip != 0 || f->name_length != name_len) {
continue;
}

field_name = nxt_unit_sptr_get(&f->name);
field_name = nxt_unit_sptr_get(&f->name);

if (nxt_java_strcaseeq(name, field_name, name_len)) {
return f;
}
if (nxt_java_strcaseeq(name, field_name, name_len)) {
return f;
}
}

return NULL;
return NULL;
}

int nxt_java_strcaseeq(const char *str1, const char *str2, int len) {
char c1, c2;
const char *end1;

int
nxt_java_strcaseeq(const char *str1, const char *str2, int len)
{
char c1, c2;
const char *end1;
end1 = str1 + len;

end1 = str1 + len;
while (str1 < end1) {
c1 = nxt_java_lowcase(*str1++);
c2 = nxt_java_lowcase(*str2++);

while (str1 < end1) {
c1 = nxt_java_lowcase(*str1++);
c2 = nxt_java_lowcase(*str2++);

if (c1 != c2) {
return 0;
}
if (c1 != c2) {
return 0;
}
}

return 1;
return 1;
}


static inline char
nxt_java_lowcase(char c)
{
return (c >= 'A' && c <= 'Z') ? c | 0x20 : c;
static inline char nxt_java_lowcase(char c) {
return (c >= 'A' && c <= 'Z') ? c | 0x20 : c;
}

jstring nxt_java_newString(JNIEnv *env, char *str, uint32_t len) {
char tmp;
jstring res;

jstring
nxt_java_newString(JNIEnv *env, char *str, uint32_t len)
{
char tmp;
jstring res;
tmp = str[len];

tmp = str[len];
if (tmp != '\0') {
str[len] = '\0';
}

if (tmp != '\0') {
str[len] = '\0';
}

res = (*env)->NewStringUTF(env, str);
res = (*env)->NewStringUTF(env, str);

if (tmp != '\0') {
str[len] = tmp;
}
if (tmp != '\0') {
str[len] = tmp;
}

return res;
return res;
}
32 changes: 10 additions & 22 deletions src/java/nxt_jni.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
#ifndef _NXT_JAVA_JNI_H_INCLUDED_
#define _NXT_JAVA_JNI_H_INCLUDED_


#include <jni.h>
#include <nxt_unit_typedefs.h>


int nxt_java_jni_init(JNIEnv *env);

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

nxt_unit_field_t *nxt_java_findHeader(nxt_unit_field_t *f, nxt_unit_field_t *e,
const char *name, uint8_t name_len);
const char *name, uint8_t name_len);

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

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


typedef struct {
uint32_t header_size;
uint32_t buf_size;
uint32_t header_size;
uint32_t buf_size;

jobject jreq;
jobject jresp;
jobject jreq;
jobject jresp;

nxt_unit_buf_t *first;
nxt_unit_buf_t *buf;
nxt_unit_buf_t *first;
nxt_unit_buf_t *buf;

} nxt_java_request_data_t;

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

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

static inline void *
nxt_jlong2ptr(jlong l)
{
return (void *) (intptr_t) l;
}
static inline void *nxt_jlong2ptr(jlong l) { return (void *)(intptr_t)l; }

#endif /* _NXT_JAVA_JNI_H_INCLUDED_ */
#endif /* _NXT_JAVA_JNI_H_INCLUDED_ */
Loading

0 comments on commit de8e2d1

Please sign in to comment.