virtual void stackTrace(ZF_IN_OUT zfstring &ret,
                            ZF_IN_OPT const zfchar *prefix = zfnull,
                            ZF_IN_OPT zfindex ignoreLevel = 0,
                            ZF_IN_OPT zfindex maxLevel = 20)
    {
        const zfchar *fixedPrefix = ((prefix == zfnull) ? zfText("") : prefix);
        if(maxLevel > 200)
        {
            maxLevel = 200;
        }

        void **array = (void **)zfmalloc(sizeof(void *) * (maxLevel + 1));
        zfindex size = backtrace(array, (int)(maxLevel + 1));
        zfcharA **strings = backtrace_symbols(array, (int)size);

        ret += fixedPrefix;
        ret += zfText("======================== stack begin =======================");
        ret += '\n';
        for(zfindex i = ignoreLevel; i < size; ++i)
        {
            ret += fixedPrefix;
            ret += strings[i];
            ret += '\n';
        }
        ret += fixedPrefix;
        ret += zfText("========================  stack end  =======================");

        zffree(strings);
        zffree(array);
    }
Exemple #2
0
ZF_NAMESPACE_GLOBAL_BEGIN

void ZFRegExpResult::objectInfoT(ZF_IN_OUT zfstring &ret) const
{
    ret += ZFTOKEN_ZFObjectInfoLeft;
    if(this->matched)
    {
        ret += zfText("matched");
        if(this->matchedRange != zfindexRangeZero)
        {
            ret += zfText(" in ");
            zfindexRangeToString(ret, this->matchedRange);
        }
        if(!this->namedGroups.isEmpty())
        {
            ret += zfText(", named groups: ");
            for(zfindex i = 0; i < this->namedGroups.count(); ++i)
            {
                if(i != 0)
                {
                    ret += zfText(", ");
                }
                zfindexRangeToString(ret, this->namedGroups[i]);
            }
        }
    }
    else
    {
        ret += zfText("no match");
    }
    ret += ZFTOKEN_ZFObjectInfoRight;
}
ZF_NAMESPACE_GLOBAL_BEGIN

// ============================================================
// ZFListenerData
void ZFListenerData::objectInfoT(ZF_IN_OUT zfstring &ret) const
{
    ret += ZFTOKEN_ZFObjectInfoLeft;
    zfstringAppend(ret, zfText("ZFListenerData(%p)"), this);
    const zfchar *eventName = ZFObserverEventGetName(this->eventId);
    if(eventName != zfnull)
    {
        ret += zfText(", event: ");
        ret += eventName;
    }
    if(this->sender != zfnull)
    {
        ret += zfText(", sender: ");
        ZFobjectInfoT(ret, this->sender);
    }
    if(this->param0 != zfnull)
    {
        ret += zfText(", param0: ");
        ZFobjectInfoT(ret, this->param0);
    }
    if(this->param1 != zfnull)
    {
        ret += zfText(", param1: ");
        ZFobjectInfoT(ret, this->param1);
    }
    ret += ZFTOKEN_ZFObjectInfoRight;
}
    void prepareChildren(ZF_IN ZFUILinearLayout *layout)
    {
        for(zfindex i = 0; i < 3; ++i)
        {
            zfblockedAlloc(ZFUITextView, child);
            layout->childAdd(child);
            child->textContentStringSet(zfstringWithFormat(zfText("text %zi"), i));
            child->textAlignSet(ZFUIAlign::e_Center);
            child->viewBackgroundColorSet(ZFUIColorRandom(255));
        }

        layout->childAtIndex(1)->layoutParam<ZFUILinearLayoutParam *>()->layoutWeightSet(1);
        layout->childAtIndex(2)->layoutParam<ZFUILinearLayoutParam *>()->layoutWeightSet(2);

        zfblockedAlloc(ZFUILinearLayout, l);
        layout->childAdd(l);
        l->layoutOrientationSet(ZFUIOrientation::e_Bottom);
        for(zfindex i = 0; i < 3; ++i)
        {
            zfblockedAlloc(ZFUITextView, child);
            l->childAdd(child);
            child->textContentStringSet(zfstringWithFormat(zfText("text %zi"), 3 + i));
            child->textAlignSet(ZFUIAlign::e_Center);
            child->viewBackgroundColorSet(ZFUIColorRandom(255));
        }
    }
 void test(void)
 {
     this->testCaseOutput(zfLang(zfText("hello")));
     this->testCaseOutput(zfLang(zfText("hello with no localized string")));
     this->testCaseOutput(zfLang(zfText("hello in default only")));
     this->testCaseOutput(zfLang(zfText("hello in custom only")));
     this->testCaseOutput(zfstringWithFormat(zfLang(zfText("hello with format: %s")).cString(), zfText("i'm passed string")));
 }
Exemple #6
0
void zfLangDebug(ZF_IN_OPT const ZFOutputCallback &output /* = ZFOutputCallbackDefault */)
{
    _ZFP_ZFLangMapType &m = _ZFP_ZFLangMapGlobal();
    for(_ZFP_ZFLangMapType::iterator it = m.begin(); it != m.end(); ++it)
    {
        output << it->first << zfText(" = \"") << it->second << zfText("\"\n");
    }
}
Exemple #7
0
ZF_GLOBAL_INITIALIZER_INIT_WITH_LEVEL(_ZFP_ZFJsonOutputFlagsInit, ZFLevelZFFrameworkNormal)
{
    _ZFP_ZFJsonOutputFlagsTrimInstance.jsonToken.jsonNewLineToken.removeAll();
    _ZFP_ZFJsonOutputFlagsTrimInstance.jsonToken.jsonIndentToken.removeAll();
    _ZFP_ZFJsonOutputFlagsTrimInstance.jsonToken.jsonValueSeparatorToken = zfText(":");
    _ZFP_ZFJsonOutputFlagsTrimInstance.jsonToken.jsonSeparatorInSameLineToken = zfText(",");
    _ZFP_ZFJsonOutputFlagsTrimInstance.jsonObjectAddNewLineForContent = zffalse;
    _ZFP_ZFJsonOutputFlagsTrimInstance.jsonArrayAddNewLineForContent = zffalse;
}
ZFPROPERTY_TYPE_DECLARE_SERIALIZE_TO_DEFINE(ZFCallback, ZFCallback)
{
    if(v.callbackSerializeCustomType() != zfnull)
    {
        if(v.callbackSerializeCustomData() == zfnull)
        {
            ZFSerializableUtil::errorOccurred(outErrorHintToAppend, zfText("missing callback serialize custom data"));
            return zffalse;
        }
        serializableData.itemClassSet(ZFPropertyTypeId_ZFCallback);

        serializableData.attributeSet(ZFSerializableKeyword_ZFCallback_callbackType, v.callbackSerializeCustomType());

        ZFSerializableData customData = v.callbackSerializeCustomData()->copy();
        customData.categorySet(ZFSerializableKeyword_ZFCallback_callbackData);
        serializableData.elementAdd(customData);

        return zftrue;
    }

    switch(v.callbackType())
    {
        case ZFCallbackTypeDummy:
            serializableData.itemClassSet(ZFSerializableKeyword_null);
            break;
        case ZFCallbackTypeMethod:
        {
            serializableData.itemClassSet(ZFPropertyTypeId_ZFCallback);
            ZFSerializableData methodData;
            if(!ZFMethodToSerializableData(methodData, v.callbackMethod(), outErrorHintToAppend))
            {
                return zffalse;
            }
            methodData.categorySet(ZFSerializableKeyword_ZFCallback_method);
            serializableData.elementAdd(methodData);
        }
            break;
        case ZFCallbackTypeMemberMethod:
        {
            ZFSerializableUtil::errorOccurred(outErrorHintToAppend,
                zfText("member method callback is not supported"));
            return zffalse;
        }
            break;
        case ZFCallbackTypeRawFunction:
            serializableData.itemClassSet(ZFPropertyTypeId_ZFCallback);
            ZFSerializableUtil::errorOccurred(outErrorHintToAppend,
                zfText("raw function is not supported"));
            return zffalse;
        default:
            zfCoreCriticalShouldNotGoHere();
            return zffalse;
    }

    return zftrue;
}
void ZFClassFilter::objectInfoVerboseT(ZF_IN_OUT zfstring &ret) const
{
    this->_ZFP_ZFClassFilter_filters.objectInfoOfContentT(ret,
        zfHint("max count")zfindexMax,
        zfText("["),
        zfText("]"),
        zfText(", "),
        zfText("..."),
        _ZFP_ZFClassFilter_contentInfoGetter);
}
Exemple #10
0
void ZFUIKeyEvent::objectInfoVerboseT(ZF_IN_OUT zfstring &ret)
{
    ret += ZFTOKEN_ZFObjectInfoLeft;
    ret += zfsFromIntStr(this->keyId);
    ret += zfText(" ");
    ret += ZFUIKeyAction::EnumNameForValue(this->keyAction);
    ret += zfText(" ");
    ret += ZFUIKeyCode::EnumNameForValue(this->keyCode);
    ret += ZFTOKEN_ZFObjectInfoRight;
}
ZF_GLOBAL_INITIALIZER_INIT_WITH_LEVEL(ZFTextTemplateRunParamDefaultSetting, ZFLevelZFFrameworkNormal)
{
#if 0
    _ZFP_ZFTextTemplateRunParamDefault_folderNameFilterRule = zfAlloc(ZFRegExp);
    ZFTextTemplateRunParamDefault.folderNameFilter.customFilterCallbackAdd(_ZFP_ZFTextTemplateRunParamDefault_folderNameFilter);
    _ZFP_ZFTextTemplateRunParamDefault_folderNameFilterRule->regExpCompile(zfText(
                ""
            ));
#endif

    _ZFP_ZFTextTemplateRunParamDefault_folderContentFilterRule = zfAlloc(ZFRegExp);
    ZFTextTemplateRunParamDefault.folderContentFilter.customFilterCallbackAdd(_ZFP_ZFTextTemplateRunParamDefault_folderContentFilter);
    _ZFP_ZFTextTemplateRunParamDefault_folderContentFilterRule->regExpCompile(zfText(
                "(^\\.git$)"
                "|(^\\.svn$)"
                "|(^\\.hg$)"
            ));

#if 0
    _ZFP_ZFTextTemplateRunParamDefault_fileNameFilterRule = zfAlloc(ZFRegExp);
    ZFTextTemplateRunParamDefault.fileNameFilter.customFilterCallbackAdd(_ZFP_ZFTextTemplateRunParamDefault_fileNameFilter);
    _ZFP_ZFTextTemplateRunParamDefault_fileNameFilterRule->regExpCompile(zfText(
                ""
            ));
#endif

    _ZFP_ZFTextTemplateRunParamDefault_fileContentFilterRule = zfAlloc(ZFRegExp);
    ZFTextTemplateRunParamDefault.fileContentFilter.customFilterCallbackAdd(_ZFP_ZFTextTemplateRunParamDefault_fileContentFilter);
    _ZFP_ZFTextTemplateRunParamDefault_fileContentFilterRule->regExpCompile(zfText(
                "(\\.ico$)"
                "|(\\.icns$)"

                "|(\\.png$)"
                "|(\\.jpg$)"
                "|(\\.jpeg$)"
                "|(\\.gif$)"

                "|(\\.mp2$)"
                "|(\\.mp3$)"
                "|(\\.mp4$)"
                "|(\\.wav$)"
                "|(\\.ogg$)"

                "|(\\.db$)"
                "|(\\.rar$)"
                "|(\\.zip$)"
                "|(\\.7z$)"

                "|(\\.a(\\..*)*$)"
                "|(\\.o(\\..*)*$)"
                "|(\\.so(\\..*)*$)"
                "|(\\.dll(\\..*)*$)"
                "|(\\.dylib(\\..*)*$)"
            ));
}
void ZFUIOnScreenKeyboardState::objectInfoOnAppend(ZF_IN_OUT zfstring &ret)
{
    zfsFromPointerT(ret, this->ownerSysWindow());
    if(this->keyboardShowing())
    {
        ret += zfText(" keyboardFrame: ");
        ZFUIRectToString(ret, this->keyboardFrame());
    }
    else
    {
        ret += zfText(" keyboardNotShow");
    }
}
Exemple #13
0
const zfchar *ZFMethod::methodPrivilegeTypeString(void) const
{
    switch(this->_ZFP_ZFMethod_privilegeType)
    {
        case ZFMethodPrivilegeTypePublic:
            return zfText("public");
        case ZFMethodPrivilegeTypeProtected:
            return zfText("protected");
        case ZFMethodPrivilegeTypePrivate:
            return zfText("private");
    }
    return zfText("<UnknownPrivilegeType>");
}
 zfoverride
 virtual void protocolOnInit(void)
 {
     zfsuper::protocolOnInit();
     this->_resRootPath = ZFFile::modulePath();
     this->_resRootPath += ZFFile::fileSeparator;
     #if ZF_ENV_sys_MacOS
         this->_resRootPath += zfText("..");
         this->_resRootPath += ZFFile::fileSeparator;
         this->_resRootPath += zfText("Resources");
         this->_resRootPath += ZFFile::fileSeparator;
     #endif
     this->_resRootPath += zfText("res");
     this->_resRootPath += ZFFile::fileSeparator;
 }
Exemple #15
0
void ZFMethod::objectInfoT(ZF_IN_OUT zfstring &ret) const
{
    if(this->methodType() == ZFMethodTypeRawFunction)
    {
        ret += this->methodNamespace();
        ret += zfText("::");
        ret += this->methodName();
    }
    else
    {
        ret += this->ownerClass()->className();
        ret += zfText("::");
        ret += this->methodName();
    }
}
 ZFMETHOD_DECLARE_1(void, methodParamIsReference
                           , zfstring &, param0
                           )
 {
     zfLogT();
     param0 = zfText("newString");
 }
void ZFPointerHolder::objectInfoVerboseT(ZF_IN_OUT zfstring &ret)
{
    ret += ZFTOKEN_ZFObjectInfoLeft;
    ret += ZFPointerHolder::ClassData()->className();
    ret += zfstringWithFormat(zfText("(%p) %p"), this, this->holdedData);
    ret += ZFTOKEN_ZFObjectInfoRight;
}
Exemple #18
0
 zfbool onVisitXmlProcessingInstruction(ZF_IN const ZFXmlVisitData &data)
 {
     switch(data.xmlVisitType)
     {
         case ZFXmlVisitType::e_Enter:
             if(data.depth > 0 || data.siblingIndex > 0)
             {
                 this->add(flags.xmlToken.xmlNewLineToken);
             }
             this->add(flags.xmlGlobalLineBeginToken);
             this->addIndent(flags.xmlToken.xmlIndentToken, data.depth);
             this->add(flags.xmlToken.xmlPITagLeft);
             this->add(data.xmlItem->xmlName());
             this->add(zfText(" "));
             this->add(data.xmlItem->xmlValue());
             break;
         case ZFXmlVisitType::e_Exit:
             this->add(flags.xmlToken.xmlPITagRight);
             break;
         case ZFXmlVisitType::e_ExitChildren:
         default:
             zfCoreCriticalShouldNotGoHere();
             break;
     }
     return zftrue;
 }
void ZFPointerHolder::objectInfoT(ZF_IN_OUT zfstring &ret)
{
    ret += ZFTOKEN_ZFObjectInfoLeft;
    ret += ZFPointerHolder::ClassData()->className();
    ret += zfText(" ");
    ret += zfsFromPointer(this->holdedData);
    ret += ZFTOKEN_ZFObjectInfoRight;
}
void ZFTypeHolder::objectInfoVerboseT(ZF_IN_OUT zfstring &ret)
{
    ret += ZFTOKEN_ZFObjectInfoLeft;
    ret += ZFTypeHolder::ClassData()->className();
    ret += zfstringWithFormat(zfText("(%p) %p %p"),
        this, this->holdedData, ZFCastReinterpret(void *, this->deleteCallback));
    ret += ZFTOKEN_ZFObjectInfoRight;
}
void zfSkinDebug(ZF_IN_OPT const ZFOutputCallback &output /* = ZFOutputCallbackDefault */)
{
    _ZFP_ZFSkinMapType &m = _ZFP_ZFSkinMapGlobal;
    for(_ZFP_ZFSkinMapType::iterator it = m.begin(); it != m.end(); ++it)
    {
        output << it->first << zfText(" = ") << it->second.toObject()->objectInfoOfInstance() << zfText("\n");
    }
}
Exemple #22
0
void ZFEnum::objectInfoVerboseT(ZF_IN_OUT zfstring &ret)
{
    ret += ZFTOKEN_ZFObjectInfoLeft;
    ret += this->classData()->className();
    ret += zfText("::");
    ret += this->enumName();
    ret += zfText("(");
    ret += zfsFromInt(this->enumValue());
    ret += zfText(")");
    ret += zfText(", count: ");
    ret += zfsFromInt(this->enumCount());

    ret += zfText(", content: ");
    const zfchar *dotToken = zfText(", ");
    for(zfindex i = 0; i < this->enumCount(); ++i)
    {
        ret += this->enumNameAtIndex(i);
        ret += zfText("=");
        ret += zfsFromInt(this->enumValueAtIndex(i));
        ret += dotToken;
    }
    if(this->enumCount() > 0)
    {
        ret.remove(ret.length() - zfslen(dotToken));
    }

    ret += ZFTOKEN_ZFObjectInfoRight;
}
Exemple #23
0
static ZFArrayEditable *_ZFP_ZFUIHint_hintListForWrite(ZF_IN ZFUISysWindow *inSysWindow)
{
    if(inSysWindow == zfnull)
    {
        inSysWindow = ZFUISysWindow::mainWindow();
    }
    if(inSysWindow == zfnull)
    {
        return zfnull;
    }
    ZFArrayEditable *hintList = inSysWindow->tagGet<ZFArrayEditable *>(zfText("_ZFP_ZFUIHint_hintList"));
    if(hintList == zfnull)
    {
        zfblockedAllocWithoutLeakTest(ZFArrayEditable, hintListTmp);
        hintList = hintListTmp;
        inSysWindow->tagSet(zfText("_ZFP_ZFUIHint_hintList"), hintList);
    }
    return hintList;
}
    virtual void stackTrace(ZF_IN_OUT zfstring &ret,
                            ZF_IN_OPT const zfchar *prefix = zfnull,
                            ZF_IN_OPT zfindex ignoreLevel = 0,
                            ZF_IN_OPT zfindex maxLevel = 20)
    {
        const zfchar *fixedPrefix = ((prefix == zfnull) ? zfText("") : prefix);

        ret += fixedPrefix;
        ret += zfText("======================== stack begin =======================");
        ret += '\n';

        ret += fixedPrefix;
        ret += zfText("| zfLogStackTrace is currently unsupported");
        ret += '\n';

        ret += fixedPrefix;
        ret += zfText("========================  stack end  =======================");
        ret += '\n';
    }
jobject ZFImpl_sys_Android_zfstringToString(ZF_IN const zfchar *s)
{
    ZFSTRINGENCODING_SENSITIVE("use UTF8")
    JNIEnv *jniEnv = JNIGetJNIEnv();
    if(s == zfnull)
    {
        s = zfText("");
    }
    return JNIUtilNewStringUTF(jniEnv, s);
}
 virtual const zfchar *settingPath(void)
 {
     if(this->_settingPath.isEmpty())
     {
         this->_settingPath = this->modulePath();
         this->_settingPath += ZFFile::fileSeparator;
         this->_settingPath += zfText("zfsetting");
     }
     return this->_settingPath;
 }
 virtual const zfchar *storageSharedPath(void)
 {
     if(this->_storageSharedPath.isEmpty())
     {
         this->_storageSharedPath = this->modulePath();
         this->_storageSharedPath += ZFFile::fileSeparator;
         this->_storageSharedPath += zfText("zfstorageshared");
     }
     return this->_storageSharedPath;
 }
void ZFCoreArgMerge(ZF_OUT zfstring &result,
                    ZF_IN const ZFCoreArray<zfstring> &argList)
{
    for(zfindex i = 0; i < argList.count(); ++i)
    {
        const zfstring &s = argList.get(i);

        if(i != 0)
        {
            result += ' ';
        }

        zfbool containSpace = (zfstringFind(s, ' ') != zfindexMax);
        if(containSpace)
        {
            result += '\"';
        }

        const zfchar *p = s.cString();
        while(*p != '\0')
        {
            if(*p == '\\')
            {
                result += zfText("\\\\");
            }
            else if(*p == '\"')
            {
                result += zfText("\\\"");
            }
            else
            {
                zfcharAppendAndMoveNext(result, p);
                continue;
            }
            ++p;
        }

        if(containSpace)
        {
            result += '\"';
        }
    }
}
void ZFJsonPrint(ZF_IN const ZFSerializableData &serializableData,
                 ZF_IN_OPT const ZFOutputCallback &outputCallback /* = ZFOutputCallbackDefault */,
                 ZF_IN_OPT const ZFJsonOutputFlags &flags /* = ZFJsonOutputFlagsDefault */)
{
    ZFJsonItem jsonObject = ZFJsonFromSerializableData(serializableData);
    if(jsonObject.jsonType() != ZFJsonType::e_JsonNull)
    {
        ZFJsonToOutput(outputCallback, jsonObject, flags);
        outputCallback.execute(zfText("\n"));
    }
}
    zfoverride
    virtual void objectOnInitFinish(void)
    {
        zfsuper::objectOnInitFinish();

        this->layoutOrientationSet(ZFUIOrientation::e_Top);
        this->layoutChildSpaceSet(ZFUIGlobalStyle::DefaultStyle()->itemSpace());

        this->childAdd(this->hintText());
        this->hintText()->layoutParam()->layoutAlignSet(ZFUIAlign::e_LeftInner);
        zfLangApplyZFUITextViewText(this->hintText(), zfText("ZF2048AutoMoveDialog_hint"));

        this->childAdd(this->actionList());
        this->actionList()->cellSizeHintSet(-1);
        this->actionList()->viewSizeMinSet(ZFUISizeMake(0, 120));
        this->actionList()->layoutParam()->sizeParamSet(ZFUISizeParamFillWidthFillHeight);
        this->actionList()->layoutParam()->sizeHintSet(ZFUISizeMake(200, 150));

        this->actionList()->listAdapterSet(this->actionListAdapter());
        this->actionList()->cellUpdater()->add(zflineAlloc(ZFUIListCellUpdaterBasic));

        this->childAdd(this->addActionLayout());
        this->addActionLayout()->layoutOrientationSet(ZFUIOrientation::e_Left);
        this->addActionLayout()->layoutChildSpaceSet(ZFUIGlobalStyle::DefaultStyle()->itemSpace());
        this->addActionLayout()->childAdd(this->addAction_left());
        this->addActionLayout()->childAdd(this->addAction_top());
        this->addActionLayout()->childAdd(this->addAction_right());
        this->addActionLayout()->childAdd(this->addAction_bottom());
        this->addActionLayout()->childAdd(this->addAction_random());

        this->childAdd(this->buttonLayout());
        this->buttonLayout()->layoutChildSpaceSet(ZFUIGlobalStyle::DefaultStyle()->itemSpace());
        this->buttonLayout()->layoutOrientationSet(ZFUIOrientation::e_Left);
        this->buttonLayout()->childAdd(this->confirmButton());
        zfLangApplyZFUIButtonBasicTextNormal(this->confirmButton(), zfText("ZF2048AutoMoveDialog_confirm"));
        this->buttonLayout()->childAdd(this->cancelButton());
        zfLangApplyZFUIButtonBasicTextNormal(this->cancelButton(), zfText("ZF2048AutoMoveDialog_cancel"));

        this->addActionButtonSetup();
        this->buttonSetup();
    }