virtual const zfchar *moduleFilePath(void)
 {
     if(this->_moduleFilePath.isEmpty())
     {
         zfstring tmp;
         #if ZF_ENV_sys_Windows
             zfcharW buf[1024] = {0};
             ::GetModuleFileNameW(zfnull, buf, 1024);
             ZFString::toZFChar(tmp, buf, ZFStringEncodingForZFCharW);
         #elif ZF_ENV_sys_Posix || ZF_ENV_sys_unknown // #if ZF_ENV_sys_Windows
             zfcharA buf[1024] = {0};
             zfint len = (zfint)::readlink(zfTextA("/proc/self/exe"), buf, 1024);
             if(len > 0)
             {
                 buf[len] = '\0';
             }
             else
             {
                 zfscpyA(buf, zfstringWithFormat(zfTextA("./unknown")).cString());
             }
             ZFString::toZFChar(tmp, buf, ZFStringEncoding::e_UTF8);
         #endif // #elif ZF_ENV_sys_Posix || ZF_ENV_sys_unknown
         zfbool result = ZFFile::filePathFormat(this->_moduleFilePath, tmp.cString());
         zfCoreAssert(result);
     }
     return this->_moduleFilePath;
 }
void ZFImpl_sys_Android_ZFUISizeFromZFAndroidSize(ZF_OUT ZFUISize &ret, ZF_IN jobject jobjSize)
{
    JNIEnv *jniEnv = JNIGetJNIEnv();
    jclass jclsSize = ZFImpl_sys_Android_jclassZFAndroidSize();
    static jfieldID jfIdWidth = JNIUtilGetFieldID(jniEnv, jclsSize, zfTextA("width"), JNIType::S_int.getId());
    static jfieldID jfIdHeight = JNIUtilGetFieldID(jniEnv, jclsSize, zfTextA("height"), JNIType::S_int.getId());
    ret.width = JNIUtilGetIntField(jniEnv, jobjSize, jfIdWidth);
    ret.height = JNIUtilGetIntField(jniEnv, jobjSize, jfIdHeight);
}
void ZFImpl_sys_Android_ZFUIPointFromZFAndroidPoint(ZF_OUT ZFUIPoint &ret, ZF_IN jobject jobjPoint)
{
    JNIEnv *jniEnv = JNIGetJNIEnv();
    jclass jclsPoint = ZFImpl_sys_Android_jclassZFAndroidPoint();
    static jfieldID jfIdX = JNIUtilGetFieldID(jniEnv, jclsPoint, zfTextA("x"), JNIType::S_int.getId());
    static jfieldID jfIdY = JNIUtilGetFieldID(jniEnv, jclsPoint, zfTextA("y"), JNIType::S_int.getId());
    ret.x = JNIUtilGetIntField(jniEnv, jobjPoint, jfIdX);
    ret.y = JNIUtilGetIntField(jniEnv, jobjPoint, jfIdY);
}
jobject ZFImpl_sys_Android_ZFUIPointToZFAndroidPoint(ZF_IN const ZFUIPoint &point, ZF_IN_OUT jobject jobjPoint)
{
    JNIEnv *jniEnv = JNIGetJNIEnv();
    jclass jclsPoint = ZFImpl_sys_Android_jclassZFAndroidPoint();
    static jfieldID jfIdX = JNIUtilGetFieldID(jniEnv, jclsPoint, zfTextA("x"), JNIType::S_int.getId());
    static jfieldID jfIdY = JNIUtilGetFieldID(jniEnv, jclsPoint, zfTextA("y"), JNIType::S_int.getId());
    JNIUtilSetIntField(jniEnv, jobjPoint, jfIdX, point.x);
    JNIUtilSetIntField(jniEnv, jobjPoint, jfIdY, point.y);
    return jobjPoint;
}
jobject ZFImpl_sys_Android_ZFUISizeToZFAndroidSize(ZF_IN const ZFUISize &size, ZF_IN_OUT jobject jobjSize)
{
    JNIEnv *jniEnv = JNIGetJNIEnv();
    jclass jclsSize = ZFImpl_sys_Android_jclassZFAndroidSize();
    static jfieldID jfIdWidth = JNIUtilGetFieldID(jniEnv, jclsSize, zfTextA("width"), JNIType::S_int.getId());
    static jfieldID jfIdHeight = JNIUtilGetFieldID(jniEnv, jclsSize, zfTextA("height"), JNIType::S_int.getId());
    JNIUtilSetIntField(jniEnv, jobjSize, jfIdWidth, size.width);
    JNIUtilSetIntField(jniEnv, jobjSize, jfIdHeight, size.height);
    return jobjSize;
}
void ZFImpl_sys_Android_ZFUIMarginFromZFAndroidMargin(ZF_OUT ZFUIMargin &ret, ZF_IN jobject jobjMargin)
{
    JNIEnv *jniEnv = JNIGetJNIEnv();
    jclass jclsMargin = ZFImpl_sys_Android_jclassZFAndroidMargin();
    static jfieldID jfIdLeft = JNIUtilGetFieldID(jniEnv, jclsMargin, zfTextA("left"), JNIType::S_int.getId());
    static jfieldID jfIdTop = JNIUtilGetFieldID(jniEnv, jclsMargin, zfTextA("top"), JNIType::S_int.getId());
    static jfieldID jfIdRight = JNIUtilGetFieldID(jniEnv, jclsMargin, zfTextA("right"), JNIType::S_int.getId());
    static jfieldID jfIdBottom = JNIUtilGetFieldID(jniEnv, jclsMargin, zfTextA("bottom"), JNIType::S_int.getId());
    ret.left = JNIUtilGetIntField(jniEnv, jobjMargin, jfIdLeft);
    ret.top = JNIUtilGetIntField(jniEnv, jobjMargin, jfIdTop);
    ret.right = JNIUtilGetIntField(jniEnv, jobjMargin, jfIdRight);
    ret.bottom = JNIUtilGetIntField(jniEnv, jobjMargin, jfIdBottom);
}
void ZFImpl_sys_Android_ZFUIRectFromZFAndroidRect(ZF_OUT ZFUIRect &ret, ZF_IN jobject jobjRect)
{
    JNIEnv *jniEnv = JNIGetJNIEnv();
    jclass jclsRect = ZFImpl_sys_Android_jclassZFAndroidRect();
    static jfieldID jfIdX = JNIUtilGetFieldID(jniEnv, jclsRect, zfTextA("x"), JNIType::S_int.getId());
    static jfieldID jfIdY = JNIUtilGetFieldID(jniEnv, jclsRect, zfTextA("y"), JNIType::S_int.getId());
    static jfieldID jfIdWidth = JNIUtilGetFieldID(jniEnv, jclsRect, zfTextA("width"), JNIType::S_int.getId());
    static jfieldID jfIdHeight = JNIUtilGetFieldID(jniEnv, jclsRect, zfTextA("height"), JNIType::S_int.getId());
    ret.point.x = JNIUtilGetIntField(jniEnv, jobjRect, jfIdX);
    ret.point.y = JNIUtilGetIntField(jniEnv, jobjRect, jfIdY);
    ret.size.width = JNIUtilGetIntField(jniEnv, jobjRect, jfIdWidth);
    ret.size.height = JNIUtilGetIntField(jniEnv, jobjRect, jfIdHeight);
}
 virtual zfindex outputLog(ZF_IN const zfchar *s, ZF_IN_OPT zfindex count = zfindexMax)
 {
     if(count == zfindexMax)
     {
         printf(zfTextA("%s"), ZFStringZ2A(s));
     }
     else
     {
         zfstring tmp(s, count);
         printf(zfTextA("%s"), ZFStringZ2A(tmp.cString()));
     }
     return zfindexMax;
 }
jobject ZFImpl_sys_Android_ZFUIMarginToZFAndroidMargin(ZF_IN const ZFUIMargin &margin, ZF_IN_OUT jobject jobjMargin)
{
    JNIEnv *jniEnv = JNIGetJNIEnv();
    jclass jclsMargin = ZFImpl_sys_Android_jclassZFAndroidMargin();
    static jfieldID jfIdLeft = JNIUtilGetFieldID(jniEnv, jclsMargin, zfTextA("left"), JNIType::S_int.getId());
    static jfieldID jfIdTop = JNIUtilGetFieldID(jniEnv, jclsMargin, zfTextA("top"), JNIType::S_int.getId());
    static jfieldID jfIdRight = JNIUtilGetFieldID(jniEnv, jclsMargin, zfTextA("right"), JNIType::S_int.getId());
    static jfieldID jfIdBottom = JNIUtilGetFieldID(jniEnv, jclsMargin, zfTextA("bottom"), JNIType::S_int.getId());
    JNIUtilSetIntField(jniEnv, jobjMargin, jfIdLeft, margin.left);
    JNIUtilSetIntField(jniEnv, jobjMargin, jfIdTop, margin.top);
    JNIUtilSetIntField(jniEnv, jobjMargin, jfIdRight, margin.right);
    JNIUtilSetIntField(jniEnv, jobjMargin, jfIdBottom, margin.bottom);
    return jobjMargin;
}
jobject ZFImpl_sys_Android_ZFUIRectToZFAndroidRect(ZF_IN const ZFUIRect &rect, ZF_IN_OUT jobject jobjRect)
{
    JNIEnv *jniEnv = JNIGetJNIEnv();
    jclass jclsRect = ZFImpl_sys_Android_jclassZFAndroidRect();
    static jfieldID jfIdX = JNIUtilGetFieldID(jniEnv, jclsRect, zfTextA("x"), JNIType::S_int.getId());
    static jfieldID jfIdY = JNIUtilGetFieldID(jniEnv, jclsRect, zfTextA("y"), JNIType::S_int.getId());
    static jfieldID jfIdWidth = JNIUtilGetFieldID(jniEnv, jclsRect, zfTextA("width"), JNIType::S_int.getId());
    static jfieldID jfIdHeight = JNIUtilGetFieldID(jniEnv, jclsRect, zfTextA("height"), JNIType::S_int.getId());
    JNIUtilSetIntField(jniEnv, jobjRect, jfIdX, rect.point.x);
    JNIUtilSetIntField(jniEnv, jobjRect, jfIdY, rect.point.y);
    JNIUtilSetIntField(jniEnv, jobjRect, jfIdWidth, rect.size.width);
    JNIUtilSetIntField(jniEnv, jobjRect, jfIdHeight, rect.size.height);
    return jobjRect;
}
ZFUIRect ZFImpl_sys_Android_ZFUIRectFromZFAndroidRect(ZF_IN jobject jobjRect)
{
    JNIEnv *jniEnv = JNIGetJNIEnv();
    jclass jclsRect = ZFImpl_sys_Android_jclassZFAndroidRect();
    static jfieldID jfIdX = JNIUtilGetFieldID(jniEnv, jclsRect, zfTextA("x"), JNIType::S_int.getId());
    static jfieldID jfIdY = JNIUtilGetFieldID(jniEnv, jclsRect, zfTextA("y"), JNIType::S_int.getId());
    static jfieldID jfIdWidth = JNIUtilGetFieldID(jniEnv, jclsRect, zfTextA("width"), JNIType::S_int.getId());
    static jfieldID jfIdHeight = JNIUtilGetFieldID(jniEnv, jclsRect, zfTextA("height"), JNIType::S_int.getId());
    return ZFUIRectMake(
        JNIUtilGetIntField(jniEnv, jobjRect, jfIdX),
        JNIUtilGetIntField(jniEnv, jobjRect, jfIdY),
        JNIUtilGetIntField(jniEnv, jobjRect, jfIdWidth),
        JNIUtilGetIntField(jniEnv, jobjRect, jfIdHeight));
}
예제 #12
0
_ZFP_ZFCoreStringA::_ZFP_ZFCoreStringA(const zfcharA *s)
: d(zfnew(zfstlbasicstring<zfcharA>, s ? s : zfTextA("")))
{
#if _ZFP_ZFCoreStringDebugValue
    v = this->cString();
#endif
}
예제 #13
0
void _ZFP_zfCoreLog(ZF_IN const zfcharA *callerFile,
                    ZF_IN const zfcharA *callerFunction,
                    ZF_IN zfindex callerLine,
                    ZF_IN zfbool isAutoEndl,
                    ZF_IN const zfcharA *format,
                    ...)
{
    if(_ZFP_ZFCoreLogOutputCallback == zfnull)
    {
        return ;
    }

    zfstringA s;

    va_list vaList;
    va_start(vaList, format);
    if(callerFile != zfnull)
    {
        ZF_CALLER_INFO_DETAIL_REF(s, callerFile, callerFunction, callerLine);
        s += ' ';
    }
    zfstringAppendV(s, format, vaList);
    if(isAutoEndl)
    {
        zfstringAppend(s, zfTextA("\n"));
    }
    va_end(vaList);

    _ZFP_ZFCoreLogOutputCallback(zfsCoreZ2A(s.cString()));
}
    virtual void objectOnDeallocPrepare(void)
    {
        this->cls->instanceObserverRemove(this->interceptedAllocListener);

        for(zfindex iObj = 0; iObj < this->observedObjects.count(); ++iObj)
        {
            ZFObject *obj = this->observedObjects[iObj];
            for(zfindex iObserver = 0; iObserver < this->params.count(); ++iObserver)
            {
                const ZFObjectInstanceObserverParam &param = this->params[iObserver];
                obj->observerRemove(param.eventId(), param.observer());
            }
            obj->observerRemove(ZFObject::EventObjectBeforeDealloc(), this->interceptedDeallocListener);
        }
        for(zfindex i = 0; i < this->params.count(); ++i)
        {
            ZFObject *userData = this->params[i].userData();
            if(userData != zfnull)
            {
                ZFLeakTestLogReleaseVerbose(userData, ZF_CALLER_FILE, zfTextA("ZFObjectInstanceObserverStop"), ZF_CALLER_LINE);
            }
        }

        zfsuper::objectOnDeallocPrepare();
    }
예제 #15
0
_ZFP_ZFCoreStringA &_ZFP_ZFCoreStringA::assign(const zfcharA *s, zfindex len)
{
    ((zfstlbasicstring<zfcharA> *)d)->assign(s ? s : zfTextA(""), _ZFP_ZFCoreString_toStlSize(len));
#if _ZFP_ZFCoreStringDebugValue
    v = this->cString();
#endif
    return *this;
}
예제 #16
0
_ZFP_ZFCoreStringA &_ZFP_ZFCoreStringA::assign(const zfcharA *s)
{
    ((zfstlbasicstring<zfcharA> *)d)->assign(s ? s : zfTextA(""));
#if _ZFP_ZFCoreStringDebugValue
    v = this->cString();
#endif
    return *this;
}
예제 #17
0
_ZFP_ZFCoreStringA &_ZFP_ZFCoreStringA::operator += (const zfcharA *s)
{
    *((zfstlbasicstring<zfcharA> *)d) += s ? s : zfTextA("");
#if _ZFP_ZFCoreStringDebugValue
    v = this->cString();
#endif
    return *this;
}
 virtual void timerStop(ZF_IN ZFTimer *timer)
 {
     JNIEnv *jniEnv = JNIGetJNIEnv();
     static jmethodID jmId = JNIUtilGetStaticMethodID(jniEnv, this->jclsOwner, zfTextA("native_timerStop"),
         JNIGetMethodSig(JNIType::S_void, JNIParamTypeContainer()
             .add(JNIType::S_object(ZFImpl_sys_Android_JNI_NAME_Object))
         ).c_str());
     JNIUtilCallStaticVoidMethod(jniEnv, this->jclsOwner, jmId, ZFCastStatic(jobject, timer->nativeTimer()));
 }
예제 #19
0
 inline zfbool operator()(ZFObject *obj1,
                          ZFObject *obj2) const
 {
     ZFCompareResult cmp = ZFObjectCompare(obj1, obj2);
     zfCoreAssertWithMessageTrim(cmp != ZFCompareUncomparable, zfTextA("[ZFMap] key must comparable: %s, %s"),
         zfsCoreZ2A(ZFObjectInfo(obj1).cString()),
         zfsCoreZ2A(ZFObjectInfo(obj2).cString()));
     return (cmp == ZFCompareSmaller);
 }
예제 #20
0
void ZFImpl_sys_Android_stackTracePrint(void)
{
    JNIEnv *jniEnv = JNIGetJNIEnv();
    jclass jcls = JNIUtilFindClass(jniEnv, JNIConvertClassNameForFindClass(ZFImpl_sys_Android_JNI_NAME_ZFAndroidLog).c_str());
    static jmethodID jmId = JNIUtilGetStaticMethodID(jniEnv, jcls, zfTextA("stackTracePrint"),
        JNIGetMethodSig(JNIType::S_void, JNIParamTypeContainer()
        ).c_str());
    JNIUtilCallStaticVoidMethod(jniEnv, jcls, jmId);
}
 virtual void *nativeTimerCreate(ZF_IN ZFTimer *timer)
 {
     JNIEnv *jniEnv = JNIGetJNIEnv();
     static jmethodID jmId = JNIUtilGetStaticMethodID(jniEnv, this->jclsOwner, zfTextA("native_nativeTimerCreate"),
         JNIGetMethodSig(JNIType::S_object(ZFImpl_sys_Android_JNI_NAME_Object), JNIParamTypeContainer()
         ).c_str());
     jobject tmp = JNIUtilCallStaticObjectMethod(jniEnv, this->jclsOwner, jmId);
     jobject ret = JNIUtilNewGlobalRef(jniEnv, tmp);
     JNIUtilDeleteLocalRef(jniEnv, tmp);
     return ret;
 }
 virtual ~ZFPROTOCOL_IMPLEMENTATION_CLASS(ZFOutputImpl_sys_Android)(void)
 {
     {
         zfsynchronizedObject(this->syncObj);
         if(this->savedString.length() > 0)
         {
             _ZFP_ZFImpl_sys_Android_ZFOutput_output(zfTextA("%s"), this->savedString.cString());
         }
     }
     zfReleaseWithoutLeakTest(this->syncObj);
 }
예제 #23
0
void _ZFP_ZFImpl_sys_Android_jniWrap_FuncCalled_action(ZF_IN const zfcharA *callerFile,
                                                      ZF_IN const zfcharA *callerFunction,
                                                      ZF_IN zfindex callerLine,
                                                      ZF_IN const zfcharA *actionName)
{
#if 0
    AndroidLog(zfTextA("JNIFuncCall (%s) %s"),
        actionName,
        ZF_CALLER_INFO(ZF_CALLER_PATH_TO_NAME(callerFile), callerFunction, callerLine));
#endif
}
예제 #24
0
void ZFMutex::mutexLock(void)
{
    if(this->_ZFP_ZFObjectLockIsAvailable())
    {
        this->_ZFP_ZFObjectLock();
    }
    else if(!this->noWarningIfImplementationNotAvailable)
    {
        zfCoreLogTrim(zfTextA("[ZFMutex] try mutexLock a object while no implementation for lock"));
    }
}
 _ZFP_ZFObjectMutexImpl_sys_Android_MutexImpl(ZF_IN jclass jclsOwner)
 : ZFObjectMutexImpl()
 , jclsOwner(jclsOwner)
 , nativeMutex(NULL)
 {
     JNIEnv *jniEnv = JNIGetJNIEnv();
     static jmethodID jmId = JNIUtilGetStaticMethodID(jniEnv, this->jclsOwner, zfTextA("native_nativeMutexCreate"),
         JNIGetMethodSig(JNIType::S_object(ZFImpl_sys_Android_JNI_NAME_Object), JNIParamTypeContainer()
         ).c_str());
     jobject tmp = JNIUtilCallStaticObjectMethod(jniEnv, this->jclsOwner, jmId);
     this->nativeMutex = JNIUtilNewGlobalRef(jniEnv, tmp);
     JNIUtilDeleteLocalRef(jniEnv, tmp);
 }
예제 #26
0
void _ZFP_ZFImpl_sys_Android_jniWrap_Released_action(ZF_IN const void *obj,
                                                    ZF_IN const zfcharA *callerFile,
                                                    ZF_IN const zfcharA *callerFunction,
                                                    ZF_IN zfindex callerLine,
                                                    ZF_IN const zfcharA *actionName)
{
#if 0
    AndroidLog(zfTextA("JNIRelease  %08X (%s) %s"),
        ZFCastReinterpret(zfuint, obj),
        actionName,
        ZF_CALLER_INFO(ZF_CALLER_PATH_TO_NAME(callerFile), callerFunction, callerLine));
#endif
}
void _ZFP_zfautoReleaseAction(ZF_IN ZFObject *obj,
                              ZF_IN const zfcharA *callerFile,
                              ZF_IN const zfcharA *callerFunction,
                              ZF_IN zfindex callerLine,
                              ZF_IN zfbool enableLeakTest)
{
    if(ZFPROTOCOL_IS_AVAILABLE(ZFThread))
    {
        ZFThread *threadCur = ZFThread::currentThread();
        if(threadCur == zfnull)
        {
            zfCoreCriticalMessageTrim(zfTextA("%s current thread is null, make sure the thread is started or registered by ZFThread"),
                ZF_CALLER_INFO_DETAIL(callerFile, callerFunction, callerLine));
            return ;
        }
        threadCur->_ZFP_ZFThreadAutoReleasePoolAdd(obj, callerFile, callerFunction, callerLine, enableLeakTest);
    }
    else
    {
        ZFAutoReleasePool::instance()->poolAdd(obj, callerFile, callerFunction, callerLine, enableLeakTest);

        if(ZFPROTOCOL_IS_AVAILABLE(ZFThreadTaskRequest))
        {
            ZF_GLOBAL_INITIALIZER_CLASS(zfautoRelease_poolDrainDataHolder) *d = ZF_GLOBAL_INITIALIZER_INSTANCE(zfautoRelease_poolDrainDataHolder);
            if(!d->drainTaskRequested)
            {
                d->drainTaskRequested = zftrue;
                ZFThreadTaskRequest(d->drainTask);
            }
        }
        else
        {
            zfCoreLogTrim(zfTextA("%s zfautoRelease called while no auto drain logic support, object %s would not be released normally"),
                ZF_CALLER_INFO_DETAIL(callerFile, callerFunction, callerLine),
                zfsCoreZ2A(obj->objectInfoOfInstance().cString()));
        }
    }
}
예제 #28
0
zfstring ZFImpl_sys_Android_objectInfo(ZF_IN jobject nativeObject)
{
    JNIEnv *jniEnv = JNIGetJNIEnv();
    jclass jcls = JNIUtilFindClass(jniEnv, JNIConvertClassNameForFindClass(ZFImpl_sys_Android_JNI_NAME_ZFAndroidLog).c_str());
    static jmethodID jmId = JNIUtilGetStaticMethodID(jniEnv, jcls, zfTextA("objectInfo"),
        JNIGetMethodSig(JNIType::S_object(ZFImpl_sys_Android_JNI_NAME_String), JNIParamTypeContainer()
            .add(JNIType::S_object(ZFImpl_sys_Android_JNI_NAME_Object))
        ).c_str());
    jstring tmp = ZFCastStatic(jstring, JNIUtilCallStaticObjectMethod(jniEnv, jcls, jmId, nativeObject));
    const char *utf = JNIUtilGetStringUTFChars(jniEnv, tmp, zfnull);
    zfstring ret = utf;
    JNIUtilReleaseStringUTFChars(jniEnv, tmp, utf);
    return ret;
}
예제 #29
0
_ZFP_ZFCoreStringA::_ZFP_ZFCoreStringA(const zfcharA *s, zfindex len)
{
    s = s ? s : zfTextA("");
    if(len == zfindexMax)
    {
        d = zfnew(zfstlbasicstring<zfcharA>, s);
    }
    else
    {
        d = zfnew(zfstlbasicstring<zfcharA>, s, _ZFP_ZFCoreString_toStlSize(len));
    }
#if _ZFP_ZFCoreStringDebugValue
    v = this->cString();
#endif
}
예제 #30
0
void ZFUIScrollerClassSet(ZF_IN const ZFClass *cls)
{
    if(cls != zfnull && !cls->classIsTypeOf(ZFUIScroller::ClassData()))
    {
        zfCoreLog(zfTextA("class %s not type of %s"),
            zfsCoreZ2A(cls->className()),
            zfsCoreZ2A(ZFUIScroller::ClassData()->className()));
        return ;
    }

    if(cls == zfnull)
    {
        cls = ZFUIScrollerDefault::ClassData();
    }
    _ZFP_ZFUIScroller_cls = cls;
}