Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ZSaberLv0 committed Jun 27, 2024
1 parent 28a451d commit 735bcbb
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 19 deletions.
3 changes: 3 additions & 0 deletions ZF/ZFCore/zfsrc/ZFCore/ZFObjectDef/ZFCallback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@ ZFMETHOD_USER_REGISTER_FOR_WRAPPER_FUNC_0(v_ZFCallback, const ZFMethod *, callba
ZFMETHOD_USER_REGISTER_FOR_WRAPPER_FUNC_0(v_ZFCallback, ZFFuncAddrType, callbackRawFunction)
ZFMETHOD_USER_REGISTER_FOR_WRAPPER_FUNC_0(v_ZFCallback, void, callbackOwnerObjectRetain)
ZFMETHOD_USER_REGISTER_FOR_WRAPPER_FUNC_0(v_ZFCallback, void, callbackOwnerObjectRelease)
ZFMETHOD_USER_REGISTER_FOR_WRAPPER_FUNC_1(v_ZFCallback, void, callbackInfoCopy
, ZFMP_IN(const ZFCallback &, src)
)
ZFMETHOD_USER_REGISTER_FOR_WRAPPER_FUNC_1(v_ZFCallback, void, callbackSerializeCustomType
, ZFMP_IN(const zfchar *, customType)
)
Expand Down
17 changes: 17 additions & 0 deletions ZF/ZFCore/zfsrc/ZFCore/ZFObjectDef/ZFCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,23 @@ zfclassLikePOD ZFLIB_ZFCore ZFCallback {
*/
zffinal void callbackOwnerObjectRelease(void) const;

// ============================================================
public:
/**
* @brief util method to copy callback info from another callback
*/
zffinal void callbackInfoCopy(ZF_IN const ZFCallback &src) {
this->callbackId(src.callbackId());
if(src.callbackSerializeCustomDisabled()) {
this->callbackSerializeCustomDisable(zftrue);
}
else {
this->callbackSerializeCustomType(src.callbackSerializeCustomType());
this->callbackSerializeCustomData(src.callbackSerializeCustomData());
}
this->pathInfo(src.pathInfo());
}

// ============================================================
// callback serialize logic
public:
Expand Down
12 changes: 6 additions & 6 deletions ZF/ZFCore/zfsrc/ZFCore/ZFObjectDef/ZFClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1388,12 +1388,12 @@ ZFObject *ZFClass::_ZFP_ZFClass_objectCast(
) const {
obj = obj->_ZFP_ZFObject_ZFImplementDynamicOwnerOrSelf();
_ZFP_ZFClassPrivate *d = obj->classData()->d;
if(d->parentClassCache.find(objectClass) != d->parentClassCache.end()) {
return obj;
}
else if(d->ZFImplementDynamicCache.find(objectClass) != d->ZFImplementDynamicCache.end()) {
if(d->ZFImplementDynamicCache.find(objectClass) != d->ZFImplementDynamicCache.end()) {
return obj->_ZFP_ZFObject_ZFImplementDynamicHolder(objectClass);
}
else if(d->parentClassCache.find(objectClass) != d->parentClassCache.end()) {
return obj;
}
else {
return zfnull;
}
Expand All @@ -1405,11 +1405,11 @@ zfbool ZFClass::_ZFP_ZFClass_ZFImplementDynamicRegister(ZF_IN const ZFClass *cls
return zffalse;
}
if(this->classIsAbstract()) {
zfCoreLogTrim("[ZFImplementDynamicRegister] cls must not abstract: %s", this, clsToImplement);
zfCoreLogTrim("[ZFImplementDynamicRegister] cls must not abstract: %s", this);
return zffalse;
}
if(clsToImplement->classIsAbstract()) {
zfCoreLogTrim("[ZFImplementDynamicRegister] clsToImplement must not abstract: %s", this, clsToImplement);
zfCoreLogTrim("[ZFImplementDynamicRegister] clsToImplement must not abstract: %s", clsToImplement);
return zffalse;
}
d->ZFImplementDynamicMap[clsToImplement] = zftrue;
Expand Down
4 changes: 4 additions & 0 deletions ZF/ZFCore/zfsrc/ZFCore/ZFObjectDef/ZFEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ zfabstract ZFLIB_ZFCore ZFEnum : zfextend ZFTypeIdWrapper {
zfoverride
virtual zfbool wrappedValueIsInit(void);
public:
zfoverride
virtual zfbool wrappedValuePreferStringConverter(void) {
return zftrue;
}
zfoverride
virtual zfbool wrappedValueFromData(
ZF_IN const ZFSerializableData &serializableData
Expand Down
23 changes: 10 additions & 13 deletions ZF/ZFUtility/zfsrc/ZFUtility/ZFIOCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ zfclass _ZFP_I_ZFIOCacheLoadTask : zfextend ZFObject {
{
ZFInput cacheSrc = ZFInputForPathInfo(localPathInfo);
if(cacheSrc) {
cacheSrc.callbackInfoCopy(this->src);
_loadImplAction(cacheSrc);
if(_result) {
return;
Expand All @@ -216,10 +217,8 @@ zfclass _ZFP_I_ZFIOCacheLoadTask : zfextend ZFObject {
}

// read src and write to local cache file
ZFPathInfo tmpPathInfo = ZFIOCache::instance()->localCachePathInfoFixed();
ZFPathInfoToChild(tmpPathInfo, zfstr(".%s", ZFMd5(_callbackId)));
{
ZFOutput tmpDst = ZFOutputForPathInfo(tmpPathInfo);
ZFOutput tmpDst = ZFOutputForPathInfo(localPathInfo);
zfbool success = zffalse;
if(tmpDst) {
const zfindex sizeToRead = 1024;
Expand All @@ -232,27 +231,25 @@ zfclass _ZFP_I_ZFIOCacheLoadTask : zfextend ZFObject {
}
if(!success) {
tmpDst = zfnull;
ZFPathInfoRemove(tmpPathInfo);
ZFPathInfoRemove(localPathInfo);
return;
}
}

// local from cache
{
ZFInput cacheSrc = ZFInputForPathInfo(tmpPathInfo);
_loadImplAction(cacheSrc);
cacheSrc = zfnull;
ZFInput cacheSrc = ZFInputForPathInfo(localPathInfo);
if(cacheSrc) {
cacheSrc.callbackInfoCopy(this->src);
_loadImplAction(cacheSrc);
cacheSrc = zfnull;
}
}
if(!_result) {
ZFPathInfoRemove(localPathInfo);
return;
}

// load success, move to cache
if(!ZFPathInfoMove(tmpPathInfo, localPathInfo.pathData)) {
ZFPathInfoCopy(tmpPathInfo, localPathInfo);
ZFPathInfoRemove(tmpPathInfo);
}

// add cache and limit cache size
{
ZF_GLOBAL_INITIALIZER_CLASS(ZFIOCacheLoadTaskMap) *d = ZF_GLOBAL_INITIALIZER_INSTANCE(ZFIOCacheLoadTaskMap);
Expand Down

0 comments on commit 735bcbb

Please sign in to comment.