[DEV] IOs port

This commit is contained in:
Edouard DUPIN 2014-04-17 01:28:21 +02:00
parent 1bd40ce2d0
commit 659717c9d1
7 changed files with 60 additions and 12 deletions

View File

@ -8,6 +8,7 @@
#include <etk/types.h>
#include <etk/Stream.h>
#include <etk/StreamIOs.h>
#include <etk/debug.h>
#if defined(__TARGET_OS__Linux) && DEBUG_LEVEL > 2
@ -62,7 +63,7 @@ etk::CStart etk::cstart;
etk::CCout& etk::operator <<(etk::CCout &_os, const enum etk::logLevel _obj) {
switch (_obj) {
case logLevelCritical:
#if !defined(__TARGET_OS__Windows)
#if (!defined(__TARGET_OS__Windows) && !defined(__TARGET_OS__IOs))
if (_os.m_enableColor == true) {
_os << ETK_BASH_COLOR_BOLD_RED;
}
@ -74,7 +75,7 @@ etk::CCout& etk::operator <<(etk::CCout &_os, const enum etk::logLevel _obj) {
#endif
break;
case logLevelError:
#if !defined(__TARGET_OS__Windows)
#if (!defined(__TARGET_OS__Windows) && !defined(__TARGET_OS__IOs))
if (_os.m_enableColor == true) {
_os << ETK_BASH_COLOR_RED;
}
@ -86,7 +87,7 @@ etk::CCout& etk::operator <<(etk::CCout &_os, const enum etk::logLevel _obj) {
#endif
break;
case logLevelWarning:
#if !defined(__TARGET_OS__Windows)
#if (!defined(__TARGET_OS__Windows) && !defined(__TARGET_OS__IOs))
if (_os.m_enableColor == true) {
_os << ETK_BASH_COLOR_MAGENTA;
}
@ -98,7 +99,7 @@ etk::CCout& etk::operator <<(etk::CCout &_os, const enum etk::logLevel _obj) {
#endif
break;
case logLevelInfo:
#if !defined(__TARGET_OS__Windows)
#if (!defined(__TARGET_OS__Windows) && !defined(__TARGET_OS__IOs))
if (_os.m_enableColor == true) {
_os << ETK_BASH_COLOR_CYAN;
}
@ -110,7 +111,7 @@ etk::CCout& etk::operator <<(etk::CCout &_os, const enum etk::logLevel _obj) {
#endif
break;
case logLevelDebug:
#if !defined(__TARGET_OS__Windows)
#if (!defined(__TARGET_OS__Windows) && !defined(__TARGET_OS__IOs))
if (_os.m_enableColor == true) {
_os << ETK_BASH_COLOR_YELLOW;
}
@ -122,7 +123,7 @@ etk::CCout& etk::operator <<(etk::CCout &_os, const enum etk::logLevel _obj) {
#endif
break;
case logLevelVerbose:
#if !defined(__TARGET_OS__Windows)
#if (!defined(__TARGET_OS__Windows) && !defined(__TARGET_OS__IOs))
if (_os.m_enableColor == true) {
_os << ETK_BASH_COLOR_WHITE;
}
@ -186,7 +187,7 @@ etk::CCout& etk::CCout::operator << (char32_t _t)
return *this;
}
#if defined(__TARGET_OS__MacOs)
#if (defined(__TARGET_OS__MacOs) || defined(__TARGET_OS__IOs))
etk::CCout& etk::CCout::operator << (size_t _t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", (uint64_t)_t);
@ -314,7 +315,7 @@ etk::CCout& etk::CCout::operator << (CStart _ccc)
etk::CCout& etk::CCout::operator << (etk::CEndl _t)
{
#if !defined(__TARGET_OS__Windows)
#if (!defined(__TARGET_OS__Windows) && !defined(__TARGET_OS__IOs))
if (m_enableColor == true) {
strncat(m_tmpChar, ETK_BASH_COLOR_NORMAL, MAX_LOG_SIZE);
}
@ -323,6 +324,8 @@ etk::CCout& etk::CCout::operator << (etk::CEndl _t)
m_tmpChar[MAX_LOG_SIZE] = '\0';
#if defined(__TARGET_OS__Android)
__android_log_print(m_levelAndroid, "EWOL", "%s", m_tmpChar);
#elif defined(__TARGET_OS__IOs)
iosNSLog(m_tmpChar);
#else
printf("%s", m_tmpChar);
#endif

View File

@ -38,7 +38,7 @@ namespace etk {
CCout(void);
~CCout(void);
CCout& operator << (char32_t _t);
#if defined(__TARGET_OS__MacOs)
#if (defined(__TARGET_OS__MacOs) || defined(__TARGET_OS__IOs))
CCout& operator << (size_t _t);
#endif
CCout& operator << (int8_t _t);

23
etk/StreamIOs.h Normal file
View File

@ -0,0 +1,23 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#ifndef __ETK_STREAM_IOS_H__
#define __ETK_STREAM_IOS_H__
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __TARGET_OS__IOs
void iosNSLog(const char * _value);
#endif
#ifdef __cplusplus
}
#endif
#endif

17
etk/StreamIOs.m Normal file
View File

@ -0,0 +1,17 @@
/**
* @author Edouard DUPIN
*
* @copyright 2011, Edouard DUPIN, all right reserved
*
* @license BSD v3 (see license file)
*/
#import <UIKit/UIKit.h>
#include <etk/StreamIOs.h>
void iosNSLog(const char * _value) {
NSLog(@"%s", _value);
}

View File

@ -55,12 +55,12 @@ void debug::displayTime(void)
}
#ifdef __TARGET_OS__Android
#if (defined(__TARGET_OS__Android) || defined(__TARGET_OS__IOs))
enum etk::logLevel g_requestedLevel = etk::logLevelDebug;
#else
enum etk::logLevel g_requestedLevel = etk::logLevelWarning;
#endif
void debug::setGeneralLevel(enum etk::logLevel _ccc) {
g_requestedLevel = _ccc;
//g_requestedLevel = _ccc;
}

View File

@ -323,8 +323,10 @@ void etk::initDefaultFolder(const char* _applName) {
TK_INFO(" base path is not correct try to find it : (must only appear in test and not when installed) base name : '" << binaryPath << "'");
// remove bin/applName
baseFolderData = binaryPath;
#ifdef __TARGET_OS__MacOs
#if defined(__TARGET_OS__MacOs)
baseFolderData += "/../Resources/";
#elif defined(__TARGET_OS__IOs)
baseFolderData += "/Resources/";
#else
baseFolderData += "/../share";
baseFolderData += binaryName;

View File

@ -37,6 +37,9 @@ def create(target):
myModule.add_src_file('etk/os/Mutex.Generic.cpp')
myModule.add_src_file('etk/os/Semaphore.Generic.cpp')
if target.name=="IOs":
myModule.add_src_file('etk/StreamIOs.m')
# name of the dependency
myModule.add_module_depend('linearmath')
myModule.add_module_depend('minizip')