Browse Source

Added simple bbmonkey_c.h so we can us bb_printf in 'C' files, eg: SDL on android.

Mark Sibly 7 years ago
parent
commit
debaecdae9

+ 2 - 0
modules/monkey/monkey.monkey2

@@ -19,6 +19,8 @@ Namespace monkey
 #Import "native/bbtypeinfo.cpp"
 #Import "native/bbdeclinfo.cpp"
 
+#Import "native/bbmonkey_c.c"
+
 #If __TARGET__="macos" Or __TARGET__="ios"
 #Import "native/bbstring.mm"
 #Endif

+ 25 - 0
modules/monkey/native/bbmonkey_c.c

@@ -0,0 +1,25 @@
+
+#include "bbmonkey_c.h"
+
+#if __ANDROID__
+
+#include <android/log.h>
+
+void bb_printf( const char *fmt,... ){
+	va_list args;
+	va_start( args,fmt );
+	__android_log_vprint( ANDROID_LOG_INFO,"MX2",fmt,args );
+	va_end( args );
+}
+
+#else
+
+void bb_printf( const char *fmt,... ){
+	va_list args;
+	va_start( args,fmt );
+	vprintf( fmt,args );
+	va_end( args );
+	fflush( stdout );
+}
+
+#endif

+ 15 - 0
modules/monkey/native/bbmonkey_c.h

@@ -0,0 +1,15 @@
+
+#ifndef BB_MONKEY_C_H
+#define BB_MONKEY_C_H
+
+#ifdef __cplusplus
+extern "C"{
+#endif
+
+extern void bb_printf( const char *fmt,...);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif