Skip to content

Commit 1af0b3a

Browse files
committed
fix error of DT_USERDATA
Former-commit-id: eddb5efac4ae593d7bd5299a84301e530f5874f9 Former-commit-id: 93d03030cff39de4507c5c1d2466fd67b0538773
1 parent ca92da5 commit 1af0b3a

File tree

4 files changed

+25
-79
lines changed

4 files changed

+25
-79
lines changed

Frame/SDK/Base/AFCData.h

+11-65
Original file line numberDiff line numberDiff line change
@@ -343,105 +343,57 @@ class AFBaseData : public AFIData
343343
//Get data
344344
virtual bool GetBool() const
345345
{
346-
assert(mnType == DT_BOOLEAN);
347-
348-
if(mnType != DT_BOOLEAN)
349-
{
350-
return NULL_BOOLEAN;
351-
}
352-
346+
ARK_ASSERT_RET_VAL(mnType == DT_BOOLEAN, NULL_BOOLEAN);
353347
return mbValue;
354348
}
355349

356350
virtual int GetInt() const
357351
{
358-
assert(mnType == DT_INT);
359-
360-
if(mnType != DT_INT)
361-
{
362-
return NULL_INT;
363-
}
364-
352+
ARK_ASSERT_RET_VAL(mnType == DT_INT, NULL_INT);
365353
return mnValue;
366354
}
367355

368356
virtual int64_t GetInt64() const
369357
{
370-
assert(mnType == DT_INT64);
371-
372-
if(mnType != DT_INT64)
373-
{
374-
return NULL_INT64;
375-
}
376-
358+
ARK_ASSERT_RET_VAL(mnType == DT_INT64, NULL_INT64);
377359
return mn64Value;
378360
}
379361

380362
virtual float GetFloat() const
381363
{
382-
assert(mnType == DT_FLOAT);
383-
384-
if(mnType != DT_FLOAT)
385-
{
386-
return NULL_FLOAT;
387-
}
388-
364+
ARK_ASSERT_RET_VAL(mnType == DT_FLOAT, NULL_FLOAT);
389365
return mfValue;
390366
}
391367

392368
virtual double GetDouble() const
393369
{
394-
assert(mnType == DT_DOUBLE);
395-
396-
if(mnType != DT_DOUBLE)
397-
{
398-
return NULL_DOUBLE;
399-
}
400-
370+
ARK_ASSERT_RET_VAL(mnType == DT_DOUBLE, NULL_DOUBLE);
401371
return mdValue;
402372
}
403373

404374
virtual const char* GetString() const
405375
{
406-
assert(mnType == DT_STRING);
407-
408-
if(mnType != DT_STRING)
409-
{
410-
return NULL_STR.c_str();
411-
}
412-
376+
ARK_ASSERT_RET_VAL(mnType == DT_STRING, NULL_STR.c_str());
413377
return mstrValue;
414378
}
415379

416380
virtual AFGUID GetObject() const
417381
{
418-
assert(mnType == DT_OBJECT);
419-
420-
if(mnType != DT_OBJECT)
421-
{
422-
return NULL_GUID;
423-
}
424-
382+
ARK_ASSERT_RET_VAL(mnType == DT_OBJECT, NULL_GUID);
425383
return AFGUID(mnHigh, mnLow);
426384
}
427385

428386
virtual void* GetPointer() const
429387
{
430-
assert(mnType == DT_POINTER);
431-
432-
if(mnType != DT_POINTER)
433-
{
434-
return NULL;
435-
}
436-
388+
ARK_ASSERT_RET_VAL(mnType == DT_POINTER, NULL);
437389
return mpVaule;
438390
}
439391

440392
virtual const void* GetUserData(size_t& size) const
441393
{
442-
assert(mnType == DT_POINTER);
394+
assert(mnType == DT_USERDATA);
443395

444-
if(mnType != DT_POINTER)
396+
if(mnType != DT_USERDATA)
445397
{
446398
size = 0;
447399
return NULL;
@@ -453,13 +405,7 @@ class AFBaseData : public AFIData
453405

454406
virtual void* GetRawUserData() const
455407
{
456-
assert(mnType == DT_POINTER);
457-
458-
if(mnType != DT_POINTER)
459-
{
460-
return NULL;
461-
}
462-
408+
ARK_ASSERT_RET_VAL(mnType == DT_USERDATA, NULL);
463409
return mpUserData;
464410
}
465411

Frame/SDK/Base/AFIData.h

+12-12
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525

2626
enum AF_DATA_TYPE
2727
{
28-
DT_UNKNOWN, //unknown type
29-
DT_BOOLEAN, //bool
30-
DT_INT, //int32_t
31-
DT_INT64, //int64_t
32-
DT_FLOAT, //float
33-
DT_DOUBLE, //double
34-
DT_STRING, //string(char*)
35-
DT_OBJECT, //object(ident + serial)
36-
DT_POINTER, //pointer(void*)
37-
DT_USERDATA, //user data(char*)
38-
DT_TABLE, //table
39-
DT_MAX, //max
28+
DT_UNKNOWN, //unknown type
29+
DT_BOOLEAN, //bool
30+
DT_INT, //int32_t
31+
DT_INT64, //int64_t
32+
DT_FLOAT, //float
33+
DT_DOUBLE, //double
34+
DT_STRING, //string(char*)
35+
DT_OBJECT, //object(ident + serial)
36+
DT_POINTER, //pointer(void*)
37+
DT_USERDATA, //user data(char*)
38+
DT_TABLE, //table
39+
DT_MAX, //max
4040
};
4141

4242
const static bool NULL_BOOLEAN = false;

Frame/SDK/Core/AFCEntity.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ bool AFCEntity::Execute()
6161

6262
bool AFCEntity::AddHeartBeat(const std::string& strHeartBeatName, const HEART_BEAT_FUNCTOR_PTR& cb, const int64_t nTime, const int nCount, const bool bForever)
6363
{
64-
return GetHeartBeatManager()->AddHeartBeat(mSelf, strHeartBeatName, cb, nTime, nCount, bForever);
64+
return GetHeartBeatManager()->AddHeartBeat(mSelf, strHeartBeatName, cb, nTime, nCount, bForever);
6565
}
6666

6767
bool AFCEntity::FindHeartBeat(const std::string& strHeartBeatName)

Frame/SDK/Core/AFCPropertyMgr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ size_t AFCPropertyMgr::GetPropertyCount()
8484

8585
AFProperty* AFCPropertyMgr::GetPropertyByIndex(size_t index)
8686
{
87-
ARK_ASSERT_RET_VAL(index > 0 && index <= mxPropertys.size(), NULL);
87+
ARK_ASSERT_RET_VAL(index >= 0 && index <= mxPropertys.size(), NULL);
8888

8989
return mxPropertys[index];
9090
}

0 commit comments

Comments
 (0)