* fixed scripted uint64 appending to bytebuffer, patch by bLuma, thx!
This commit is contained in:
parent
cf7758074a
commit
6ccd48f719
@ -11,7 +11,8 @@ using namespace DefScriptTools;
|
||||
|
||||
// Helper macros for insert/extract various datatypes that need type casting
|
||||
#define BB_CAN_READ(bytebuffer, _ty) ((*(bytebuffer)).size() - (*(bytebuffer)).rpos() >= sizeof(_ty))
|
||||
#define BB_MACRO_INSERT(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) ) { *(bytebuffer) << (_ty)toNumber(Set.defaultarg); return true; }
|
||||
#define BB_MACRO_INSERT_I(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) ) { *(bytebuffer) << (_ty)toUint64(Set.defaultarg); return true; }
|
||||
#define BB_MACRO_INSERT_F(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) ) { *(bytebuffer) << (_ty)toNumber(Set.defaultarg); return true; }
|
||||
#define BB_MACRO_EXTRACT_I(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) && BB_CAN_READ(bytebuffer,_ty) ) {_ty _var; *(bytebuffer) >> _var; return DefScriptTools::toString((uint64)_var); }
|
||||
#define BB_MACRO_EXTRACT_F(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) && BB_CAN_READ(bytebuffer,_ty) ) {_ty _var; *(bytebuffer) >> _var; return DefScriptTools::toString((ldbl)_var); }
|
||||
|
||||
@ -56,12 +57,12 @@ DefReturnResult DefScriptPackage::func_bbappend(CmdSet& Set)
|
||||
return true;
|
||||
}
|
||||
|
||||
BB_MACRO_INSERT(bb, dtype, uint8);
|
||||
BB_MACRO_INSERT(bb, dtype, uint16);
|
||||
BB_MACRO_INSERT(bb, dtype, uint32);
|
||||
BB_MACRO_INSERT(bb, dtype, uint64);
|
||||
BB_MACRO_INSERT(bb, dtype, float);
|
||||
BB_MACRO_INSERT(bb, dtype, double);
|
||||
BB_MACRO_INSERT_I(bb, dtype, uint8);
|
||||
BB_MACRO_INSERT_I(bb, dtype, uint16);
|
||||
BB_MACRO_INSERT_I(bb, dtype, uint32);
|
||||
BB_MACRO_INSERT_I(bb, dtype, uint64);
|
||||
BB_MACRO_INSERT_F(bb, dtype, float);
|
||||
BB_MACRO_INSERT_F(bb, dtype, double);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -110,7 +110,7 @@ bool DefScriptTools::isTrue(std::string s)
|
||||
uint64 DefScriptTools::toUint64(std::string str)
|
||||
{
|
||||
bool negative=false;
|
||||
uint64 num;
|
||||
uint64 num = 0;
|
||||
if(str.empty())
|
||||
return 0;
|
||||
if(str[0]=='-')
|
||||
@ -157,4 +157,4 @@ inline long double DefScriptTools::Round(long double z,unsigned int n)
|
||||
{
|
||||
static long double v[] = { 1, 10, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16 };
|
||||
return floor(z * v[n] + 0.5) / v[n];
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user