Skip to content
Permalink
Browse files

Less compile warnings on OSX

  • Loading branch information...
UnknownShadow200 committed Jul 9, 2019
1 parent 9244323 commit 7753ad80808e1ad092c950ab7641752f60ce2d1d
Showing with 44 additions and 9 deletions.
  1. +19 −2 src/Http.c
  2. +20 −2 src/Logger.c
  3. +1 −1 src/Platform.c
  4. +4 −4 src/Window.c
@@ -723,29 +723,43 @@ static void Http_SysFree(void) {
#elif defined CC_BUILD_ANDROID
#include <android_native_app_glue.h>
#include <jni.h>
struct HttpRequest* java_req;

static void CallJavaVoid(JNIEnv* env, const char* name, const char* sig, jvalue* args) {
jclass clazz = (*env)->FindClass(env, "com/classicube/Wrappers");
jmethodID method = (*env)->GetStaticMethodID(env, clazz, name, sig);
(*env)->CallStaticVoidMethodA(env, clazz, method, args);
}

static int CallJavaInt(JNIEnv* env, const char* name, const char* sig, jvalue* args) {
jclass clazz = (*env)->FindClass(env, "com/classicube/Wrappers");
jmethodID method = (*env)->GetStaticMethodID(env, clazz, name, sig);
return (*env)->CallStaticIntMethodA(env, clazz, method, args);
}

bool Http_DescribeError(ReturnCode res, String* dst) {
jni
}

static void Http_SysInit(void) { }

static void Http_AddHeader(const char* key, const String* value) {
String tmp; char tmpBuffer[1024];
JavaVM* vm = (JavaVM*)VM_Handle;
JNIEnv* env;
jvalue args[2];

String_InitArray_NT(tmp, tmpBuffer);
String_Copy(&tmp, value);
tmp.buffer[tmp.length] = '\0';

(*vm)->AttachCurrentThread(vm, &env, NULL);
args[0].l = (*env)->NewStringUTF(env, key);
jni value
args[1].l = (*env)->NewStringUTF(env, tmp.buffer);

CallJavaVoid(env, "httpSetHeader", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", args);
(*env)->DeleteLocalRef(env, args[0].l);
(*env)->DeleteLocalRef(env, args[1].l);
}

/* Processes a HTTP header downloaded from the server */
@@ -755,13 +769,14 @@ static JNIEXPORT void JNICALL Java_com_classicube_Wrappers_httpParseHeader(JNIEn
jsize length = (*env)->GetStringLength(env, header);

line = String_Init(src, length, length);
Http_ParseHeader(req, &line);
Http_ParseHeader(java_req, &line);
(*env)->ReleaseStringUTFChars(env, header, src);
}

/* Processes a chunk of data downloaded from the web server */
static JNIEXPORT void JNICALL Java_com_classicube_Wrappers_httpAppendData(JNIEnv* env, jclass c, jbyteArray arr, jint len) {
jbyte* src = (*env)->GetByteArrayElements(env, NULL, 0);
struct HttpRequest* req = java_req;

if (!bufferSize) Http_BufferInit(req);
Http_BufferEnsure(req, len);
@@ -778,6 +793,8 @@ static void Http_SetCurlOpts(struct HttpRequest* req) {
}

static ReturnCode Http_SysDo(struct HttpRequest* req) {
static const String userAgent = String_FromConst(GAME_APP_NAME);
java_req = req;
String url = String_FromRawArray(req->URL);
char urlStr[600];
void* post_data = req->Data;
@@ -450,8 +450,8 @@ static void Logger_PrintRegisters(String* str, void* ctx) {
#error "Unknown CPU architecture"
#endif
}
#elif defined CC_BUILD_OSX
/* See /usr/include/mach/i386/_structs.h */
#elif defined CC_BUILD_OSX && __DARWIN_UNIX03
/* See /usr/include/mach/i386/_structs.h (OSX 10.5+) */
static void Logger_PrintRegisters(String* str, void* ctx) {
mcontext_t r = ((ucontext_t*)ctx)->uc_mcontext;
#if defined __i386__
@@ -468,6 +468,24 @@ static void Logger_PrintRegisters(String* str, void* ctx) {
#error "Unknown CPU architecture"
#endif
}
#elif defined CC_BUILD_OSX
/* See /usr/include/mach/i386/thread_status.h (OSX 10.4) */
static void Logger_PrintRegisters(String* str, void* ctx) {
mcontext_t r = ((ucontext_t*)ctx)->uc_mcontext;
#if defined __i386__
#define REG_GET(reg, ign) &r->ss.e##reg
Logger_Dump_X86()
#elif defined __x86_64__
#define REG_GET(reg, ign) &r->ss.r##reg
Logger_Dump_X64()
#elif defined __ppc__
#define REG_GNUM(num) &r->ss.r##num
#define REG_GET(reg, ign) &r->ss.##reg
Logger_Dump_PPC()
#else
#error "Unknown CPU architecture"
#endif
}
#elif defined CC_BUILD_LINUX
/* See /usr/include/sys/ucontext.h */
static void Logger_PrintRegisters(String* str, void* ctx) {
@@ -1694,7 +1694,7 @@ ReturnCode Process_StartShell(void) {

ReturnCode Process_GetExePath(String* path) {
char str[600] = { 0 };
int len = 600;
uint32_t len = 600;
if (_NSGetExecutablePath(str, &len)) return ERR_INVALID_ARGUMENT;

len = String_CalcLen(str, 600);
@@ -1755,7 +1755,7 @@ void Window_Create(int x, int y, int width, int height, struct GraphicsMode* mod
}

void Window_SetTitle(const String* title) {
char str[600];
UInt8 str[600];
CFStringRef titleCF;
int len;

@@ -1809,7 +1809,7 @@ void Clipboard_GetText(String* value) {
void Clipboard_SetText(const String* value) {
PasteboardRef pbRef;
CFDataRef cfData;
char str[800];
UInt8 str[800];
int len;
OSStatus err;

@@ -3044,7 +3044,7 @@ static void GLContext_SetDrawable(void) {
GLContext_Check(code, "Attaching GL context");
}

static void GLContext_GetAttribs(struct GraphicsMode* mode, int* attribs, bool fullscreen) {
static void GLContext_GetAttribs(struct GraphicsMode* mode, GLint* attribs, bool fullscreen) {
int i = 0;

if (!mode->IsIndexed) { attribs[i++] = AGL_RGBA; }
@@ -3106,7 +3106,7 @@ static void GLContext_SetFullscreen(void) {
}

void GLContext_Init(struct GraphicsMode* mode) {
int attribs[20];
GLint attribs[20];
AGLPixelFormat fmt;
GDHandle gdevice;
OSStatus res;

0 comments on commit 7753ad8

Please sign in to comment.
You can’t perform that action at this time.