This commit is contained in:
Michael Fabian Dirks
2016-03-11 14:15:12 +01:00
parent e49ae6fbcd
commit 2b82733b4b
15 changed files with 1194 additions and 1417 deletions
+83 -149
View File
@@ -14,175 +14,109 @@
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "Double.h"
#include <list>
#include "Long.h"
// Templates
template< typename T >
std::string int_to_hex(T i) {
std::stringstream stream;
stream
<< std::setfill('0')
<< std::setw(sizeof(T) * 2)
<< std::hex
<< i;
return stream.str();
}
template< typename T >
T hex_to_int(std::string t) {
T x;
std::stringstream stream;
stream
<< std::hex
<< t;
stream
>> x;
return x;
}
std::list<double_t*> BU_DoubleTemporary;
DLL_FUNCTION(double_t*) BU_Double_Create() {
DLL_FUNCTION(double_t*) BU_Double_New() {
return new double_t;
}
DLL_FUNCTION(void) BU_Double_Destroy(double_t* pthis) {
delete pthis;
DLL_FUNCTION(double_t*) BU_Double_Copy(double_t* pOther) {
return new double_t(*pOther);
}
DLL_FUNCTION(void) BU_Double_Destroy(double_t* pThis) {
delete pThis;
}
DLL_FUNCTION(double_t*) BU_Double_Copy(double_t* other) {
double_t* pthis = new double_t;
*pthis = *other;
return pthis;
char* BU_Double_Buffer = new char[32];
DLL_FUNCTION(const char*) BU_Double_ToString(double_t* pThis) {
std::stringstream myStream;
myStream << (*pThis);
const char* myBuffer = myStream.str().c_str();
strcpy_s(BU_Double_Buffer, 32, myBuffer);
return BU_Double_Buffer;
}
DLL_FUNCTION(double_t*) BU_Double_FromString(const char* pString) {
double_t* pThis = new double_t;
std::stringstream myStream = std::stringstream(pString);
myStream >> *pThis;
return pThis;
}
DLL_FUNCTION(double_t*) BU_Double_TempCreate() {
double_t* val = new double_t;
BU_DoubleTemporary.push_back(val);
return val;
DLL_FUNCTION(double_t*) BU_Double_FromF(float_t fOther) {
return new double_t(fOther);
}
DLL_FUNCTION(float_t) BU_Double_ToF(double_t* pThis) {
return (float_t)*pThis;
}
DLL_FUNCTION(double_t*) BU_Double_TempCopy(double_t* other) {
double_t* val = new double_t(*other);
BU_DoubleTemporary.push_back(val);
return val;
DLL_FUNCTION(double_t*) BU_Double_FromI(int32_t iOther) {
return new double_t(iOther);
}
DLL_FUNCTION(int32_t) BU_Double_ToI(double_t* pThis) {
return (int32_t)*pThis;
}
DLL_FUNCTION(void) BU_Double_SetTemp(double_t* pthis) {
BU_DoubleTemporary.push_back(pthis);
DLL_FUNCTION(double_t*) BU_Double_FromL(int64_t* pOther) {
return new double_t((double_t)*pOther);
}
DLL_FUNCTION(int64_t*) BU_Double_ToL(double_t* pThis) {
return new int64_t((int64_t)*pThis);
}
DLL_FUNCTION(void) BU_Double_UnsetTemp(double_t* pthis) {
BU_DoubleTemporary.remove(pthis);
DLL_FUNCTION(int32_t) BU_Double_Compare(double_t* pThis, double_t* pOther) {
return /* It can either be Equal (0) or Smaller or Greater. Easy to check. */
/* Greater */
(*pThis > *pOther ? 1 : 0) +
/* Smaller */
(*pThis < *pOther ? -1 : 0);
}
DLL_FUNCTION(void) BU_Double_TempCleanup() {
auto iterEnd = BU_DoubleTemporary.end();
for (auto iter = BU_DoubleTemporary.begin(); iter != iterEnd; ++iter) {
delete *iter;
}
BU_DoubleTemporary.clear();
DLL_FUNCTION(double_t*) BU_Double_Set(double_t* pThis, double_t* pOther) {
*pThis = *pOther;
return pThis;
}
DLL_FUNCTION(double_t*) BU_Double_Add(double_t* pThis, double_t* pOther) {
*pThis += *pOther;
return pThis;
}
DLL_FUNCTION(double_t*) BU_Double_Sub(double_t* pThis, double_t* pOther) {
*pThis -= *pOther;
return pThis;
}
DLL_FUNCTION(double_t*) BU_Double_Div(double_t* pThis, double_t* pOther) {
*pThis /= *pOther;
return pThis;
}
DLL_FUNCTION(double_t*) BU_Double_Mul(double_t* pThis, double_t* pOther) {
*pThis *= *pOther;
return pThis;
}
DLL_FUNCTION(double_t*) BU_Double_Mod(double_t* pThis, double_t* pOther) {
*pThis = fmod(*pThis, *pOther);
return pThis;
}
DLL_FUNCTION(void) BU_Double_Set(double_t* pthis, double_t* other) {
*pthis = *other;
DLL_FUNCTION(double_t*) BU_Double_SetF(double_t* pThis, float_t fOther) {
*pThis = fOther;
return pThis;
}
DLL_FUNCTION(void) BU_Double_SetF(double_t* pthis, float_t other) {
*pthis = other;
DLL_FUNCTION(double_t*) BU_Double_AddF(double_t* pThis, float_t fOther) {
*pThis += fOther;
return pThis;
}
DLL_FUNCTION(void) BU_Double_Add(double_t* pthis, double_t* other) {
*pthis += *other;
DLL_FUNCTION(double_t*) BU_Double_SubF(double_t* pThis, float_t fOther) {
*pThis -= fOther;
return pThis;
}
DLL_FUNCTION(void) BU_Double_AddF(double_t* pthis, float_t other) {
*pthis += other;
DLL_FUNCTION(double_t*) BU_Double_DivF(double_t* pThis, float_t fOther) {
*pThis /= fOther;
return pThis;
}
DLL_FUNCTION(void) BU_Double_Sub(double_t* pthis, double_t* other) {
*pthis -= *other;
DLL_FUNCTION(double_t*) BU_Double_MulF(double_t* pThis, float_t fOther) {
*pThis *= fOther;
return pThis;
}
DLL_FUNCTION(void) BU_Double_SubF(double_t* pthis, float_t other) {
*pthis -= other;
}
DLL_FUNCTION(void) BU_Double_Mul(double_t* pthis, double_t* other) {
*pthis *= *other;
}
DLL_FUNCTION(void) BU_Double_MulF(double_t* pthis, float_t other) {
*pthis *= other;
}
DLL_FUNCTION(void) BU_Double_Div(double_t* pthis, double_t* other) {
*pthis /= *other;
}
DLL_FUNCTION(void) BU_Double_DivF(double_t* pthis, float_t other) {
*pthis /= other;
}
DLL_FUNCTION(uint32_t) BU_Double_Compare(double_t* pthis, double_t* other) {
return (*pthis == *other ? 1 : 0) + (*pthis < *other ? 2 : 0) + (*pthis > *other ? 4 : 0);
}
DLL_FUNCTION(uint32_t) BU_Double_CompareF(double_t* pthis, float_t other) {
return ((float_t)*pthis == other ? 1 : 0) + ((float_t)*pthis < other ? 2 : 0) + ((float_t)*pthis > other ? 4 : 0);
}
DLL_FUNCTION(const char*) BU_Double_ToString(double_t* pthis) {
std::stringstream stream;
stream << *pthis;
return stream.str().c_str();
}
DLL_FUNCTION(double_t*) BU_Double_FromString(const char* text) {
std::stringstream stream = std::stringstream(text);
double_t* doublePtr = new double_t;
stream >> *doublePtr;
return doublePtr;
}
DLL_FUNCTION(float_t) BU_Double_ToFloat(double_t* pthis) {
return (float_t)*pthis;
}
DLL_FUNCTION(double_t*) BU_Double_FromFloat(float_t other) {
double_t* val = new double_t;
*val = (double_t)other;
return val;
}
DLL_FUNCTION(int64_t*) BU_Double_ToLongLong(double_t* pthis) {
int64_t* val = new int64_t;
*val = (int64_t)*pthis;
return val;
}
DLL_FUNCTION(double_t*) BU_Double_FromLongLong(int64_t* other) {
double_t* val = new double_t;
*val = (double_t)*other;
return val;
}
DLL_FUNCTION(const char*) BU_Double_Serialize(double_t* pthis) {
union {
double_t real;
int64_t integer;
} myval;
myval.real = *pthis;
return int_to_hex<int64_t>(myval.integer).c_str();
}
DLL_FUNCTION(double_t*) BU_Double_Deserialize(const char* text) {
union {
double_t real;
int64_t integer;
} myval;
myval.integer = hex_to_int<int64_t>(std::string(text));
return BU_Double_Copy(&myval.real);
DLL_FUNCTION(double_t*) BU_Double_ModF(double_t* pThis, float_t fOther) {
*pThis = fmod(*pThis, fOther);
return pThis;
}
+27 -73
View File
@@ -16,82 +16,36 @@
#pragma once
#include "BlitzUtility.h"
#include "LongLong.h"
#include <iomanip>
#include <sstream>
#pragma region Constructor & Destructor
DLL_FUNCTION(double_t*) BU_Double_Create();
DLL_FUNCTION(void) BU_Double_Destroy(double_t* pthis);
DLL_FUNCTION(double_t*) BU_Double_Copy(double_t* other);
#pragma comment(linker, "/EXPORT:BU_Double_Create=_BU_Double_Create@0")
#pragma comment(linker, "/EXPORT:BU_Double_Destroy=_BU_Double_Destroy@4")
#pragma comment(linker, "/EXPORT:BU_Double_Copy=_BU_Double_Copy@4")
#pragma endregion Constructor & Destructor
DLL_FUNCTION(double_t*) BU_Double_New();
DLL_FUNCTION(double_t*) BU_Double_Copy(double_t* pRight);
DLL_FUNCTION(void) BU_Double_Destroy(double_t* pThis);
#pragma region Temporary Objects
DLL_FUNCTION(double_t*) BU_Double_TempCreate();
DLL_FUNCTION(double_t*) BU_Double_TempCopy(double_t* other);
DLL_FUNCTION(void) BU_Double_SetTemp(double_t* pthis);
DLL_FUNCTION(void) BU_Double_UnsetTemp(double_t* pthis);
DLL_FUNCTION(void) BU_Double_TempCleanup();
#pragma comment(linker, "/EXPORT:BU_Double_TempCreate=_BU_Double_TempCreate@0")
#pragma comment(linker, "/EXPORT:BU_Double_TempCopy=_BU_Double_TempCopy@4")
#pragma comment(linker, "/EXPORT:BU_Double_SetTemp=_BU_Double_SetTemp@4")
#pragma comment(linker, "/EXPORT:BU_Double_UnsetTemp=_BU_Double_UnsetTemp@4")
#pragma comment(linker, "/EXPORT:BU_Double_TempCleanup=_BU_Double_TempCleanup@0")
#pragma endregion Temporary Objects
DLL_FUNCTION(const char*) BU_Double_ToString(double_t* pThis);
DLL_FUNCTION(double_t*) BU_Double_FromString(const char* pString);
#pragma region Math
DLL_FUNCTION(void) BU_Double_Set(double_t* pthis, double_t* other);
DLL_FUNCTION(void) BU_Double_SetF(double_t* pthis, float_t other);
#pragma comment(linker, "/EXPORT:BU_Double_Set=_BU_Double_Set@8")
#pragma comment(linker, "/EXPORT:BU_Double_SetF=_BU_Double_SetF@8")
DLL_FUNCTION(void) BU_Double_Add(double_t* pthis, double_t* other);
DLL_FUNCTION(void) BU_Double_AddF(double_t* pthis, float_t other);
#pragma comment(linker, "/EXPORT:BU_Double_Add=_BU_Double_Add@8")
#pragma comment(linker, "/EXPORT:BU_Double_AddF=_BU_Double_AddF@8")
DLL_FUNCTION(void) BU_Double_Sub(double_t* pthis, double_t* other);
DLL_FUNCTION(void) BU_Double_SubF(double_t* pthis, float_t other);
#pragma comment(linker, "/EXPORT:BU_Double_Sub=_BU_Double_Sub@8")
#pragma comment(linker, "/EXPORT:BU_Double_SubF=_BU_Double_SubF@8")
DLL_FUNCTION(void) BU_Double_Mul(double_t* pthis, double_t* other);
DLL_FUNCTION(void) BU_Double_MulF(double_t* pthis, float_t other);
#pragma comment(linker, "/EXPORT:BU_Double_Mul=_BU_Double_Mul@8")
#pragma comment(linker, "/EXPORT:BU_Double_MulF=_BU_Double_MulF@8")
DLL_FUNCTION(void) BU_Double_Div(double_t* pthis, double_t* other);
DLL_FUNCTION(void) BU_Double_DivF(double_t* pthis, float_t other);
#pragma comment(linker, "/EXPORT:BU_Double_Div=_BU_Double_Div@8")
#pragma comment(linker, "/EXPORT:BU_Double_DivF=_BU_Double_DivF@8")
#pragma endregion Math
DLL_FUNCTION(double_t*) BU_Double_FromF(float_t fOther);
DLL_FUNCTION(float_t) BU_Double_ToF(double_t* pThis);
#pragma region Comparision
DLL_FUNCTION(uint32_t) BU_Double_Compare(double_t* pthis, double_t* other);
DLL_FUNCTION(uint32_t) BU_Double_CompareF(double_t* pthis, float_t other);
#pragma comment(linker, "/EXPORT:BU_Double_Compare=_BU_Double_Compare@8")
#pragma comment(linker, "/EXPORT:BU_Double_CompareF=_BU_Double_CompareF@8")
#pragma endregion Comparision
DLL_FUNCTION(double_t*) BU_Double_FromI(int32_t iOther);
DLL_FUNCTION(int32_t) BU_Double_ToI(double_t* pThis);
#pragma region Conversion
// String conversion
DLL_FUNCTION(const char*) BU_Double_ToString(double_t* pthis);
DLL_FUNCTION(double_t*) BU_Double_FromString(const char* text);
#pragma comment(linker, "/EXPORT:BU_Double_ToString=_BU_Double_ToString@4")
#pragma comment(linker, "/EXPORT:BU_Double_FromString=_BU_Double_FromString@4")
// 32-Bit Floating Point
DLL_FUNCTION(float_t) BU_Double_ToFloat(double_t* pthis);
DLL_FUNCTION(double_t*) BU_Double_FromFloat(float_t other);
#pragma comment(linker, "/EXPORT:BU_Double_ToFloat=_BU_Double_ToFloat@4")
#pragma comment(linker, "/EXPORT:BU_Double_FromFloat=_BU_Double_FromFloat@4")
// 64-Bit Integer
DLL_FUNCTION(int64_t*) BU_Double_ToLongLong(double_t* pthis);
DLL_FUNCTION(double_t*) BU_Double_FromLongLong(int64_t* other);
#pragma comment(linker, "/EXPORT:BU_Double_ToLongLong=_BU_Double_ToLongLong@4")
#pragma comment(linker, "/EXPORT:BU_Double_FromLongLong=_BU_Double_FromLongLong@4")
#pragma endregion Conversion
DLL_FUNCTION(double_t*) BU_Double_FromL(int64_t* pOther);
DLL_FUNCTION(int64_t*) BU_Double_ToL(double_t* pThis);
#pragma region Serialization
DLL_FUNCTION(const char*) BU_Double_Serialize(double_t* pthis);
DLL_FUNCTION(double_t*) BU_Double_Deserialize(const char* text);
#pragma comment(linker, "/EXPORT:BU_Double_Serialize=_BU_Double_Serialize@4")
#pragma comment(linker, "/EXPORT:BU_Double_Deserialize=_BU_Double_Deserialize@4")
#pragma endregion Serialization
DLL_FUNCTION(int32_t) BU_Double_Compare(double_t* pThis, double_t* pOther);
DLL_FUNCTION(double_t*) BU_Double_Set(double_t* pThis, double_t* pOther);
DLL_FUNCTION(double_t*) BU_Double_Add(double_t* pThis, double_t* pOther);
DLL_FUNCTION(double_t*) BU_Double_Sub(double_t* pThis, double_t* pOther);
DLL_FUNCTION(double_t*) BU_Double_Div(double_t* pThis, double_t* pOther);
DLL_FUNCTION(double_t*) BU_Double_Mul(double_t* pThis, double_t* pOther);
DLL_FUNCTION(double_t*) BU_Double_Mod(double_t* pThis, double_t* pOther);
DLL_FUNCTION(double_t*) BU_Double_SetF(double_t* pThis, float_t fOther);
DLL_FUNCTION(double_t*) BU_Double_AddF(double_t* pThis, float_t fOther);
DLL_FUNCTION(double_t*) BU_Double_SubF(double_t* pThis, float_t fOther);
DLL_FUNCTION(double_t*) BU_Double_DivF(double_t* pThis, float_t fOther);
DLL_FUNCTION(double_t*) BU_Double_MulF(double_t* pThis, float_t fOther);
DLL_FUNCTION(double_t*) BU_Double_ModF(double_t* pThis, float_t fOther);
+167
View File
@@ -0,0 +1,167 @@
// Blitz - Steam wrapper for Blitz.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "Long.h"
DLL_FUNCTION(int64_t*) BU_Long_New() {
return new int64_t;
}
DLL_FUNCTION(int64_t*) BU_Long_Copy(int64_t* pOther) {
return new int64_t(*pOther);
}
DLL_FUNCTION(void) BU_Long_Destroy(int64_t* pThis) {
delete pThis;
}
char* BU_Long_Buffer = new char[32];
DLL_FUNCTION(const char*) BU_Long_ToString(int64_t* pThis) {
std::stringstream myStream;
myStream << (*pThis);
const char* myBuffer = myStream.str().c_str();
strcpy_s(BU_Long_Buffer, 32, myBuffer);
return BU_Long_Buffer;
}
DLL_FUNCTION(int64_t*) BU_Long_FromString(const char* pString) {
int64_t* pThis = new int64_t;
std::stringstream myStream = std::stringstream(pString);
myStream >> *pThis;
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_FromI(int32_t iRight) {
return new int64_t(iRight);
}
DLL_FUNCTION(int64_t*) BU_Long_FromII(int32_t iLeft, int32_t iRight) {
return new int64_t(((int64_t)(iLeft) << 32) + iRight);
}
DLL_FUNCTION(int32_t) BU_Long_ToI(int64_t* pThis, int32_t iShift) {
if (iShift >= 0)
return (int32_t)(*pThis >> iShift);
else
return (int32_t)(*pThis << -iShift);
}
DLL_FUNCTION(int32_t) BU_Long_ToIH(int64_t* pThis) {
return (int32_t)(*pThis >> 32);
}
DLL_FUNCTION(int32_t) BU_Long_ToIL(int64_t* pThis) {
return (int32_t)*pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_FromF(float_t fOther) {
return new int64_t((int64_t)fOther);
}
DLL_FUNCTION(float_t) BU_Long_ToF(int64_t* pThis) {
return (float_t)*pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_FromD(double_t* pOther) {
return new int64_t((int64_t)*pOther);
}
DLL_FUNCTION(double_t*) BU_Long_ToD(int64_t* pThis) {
return new double_t((double_t)*pThis);
}
DLL_FUNCTION(int32_t) BU_Long_Compare(int64_t* pThis, int64_t* pOther) {
return /* It can either be Equal (0) or Smaller or Greater. Easy to check. */
/* Greater */
(*pThis > *pOther ? 1 : 0) +
/* Smaller */
(*pThis < *pOther ? -1 : 0);
}
DLL_FUNCTION(int64_t*) BU_Long_Set(int64_t* pThis, int64_t* pOther) {
*pThis = *pOther;
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_Add(int64_t* pThis, int64_t* pOther) {
*pThis += *pOther;
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_Sub(int64_t* pThis, int64_t* pOther) {
*pThis -= *pOther;
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_Div(int64_t* pThis, int64_t* pOther) {
*pThis /= *pOther;
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_Mul(int64_t* pThis, int64_t* pOther) {
*pThis *= *pOther;
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_Mod(int64_t* pThis, int64_t* pOther) {
*pThis %= *pOther;
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_SetI(int64_t* pThis, int32_t iRight) {
*pThis = iRight;
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_AddI(int64_t* pThis, int32_t iRight) {
*pThis += iRight;
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_SubI(int64_t* pThis, int32_t iRight) {
*pThis -= iRight;
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_DivI(int64_t* pThis, int32_t iRight) {
*pThis /= iRight;
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_MulI(int64_t* pThis, int32_t iRight) {
*pThis *= iRight;
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_ModI(int64_t* pThis, int32_t iRight) {
*pThis %= iRight;
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_SetII(int64_t* pThis, int32_t iLeft, int32_t iRight) {
*pThis = (((int64_t)iLeft << 32) + iRight);
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_AddII(int64_t* pThis, int32_t iLeft, int32_t iRight) {
*pThis += (((int64_t)iLeft << 32) + iRight);
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_SubII(int64_t* pThis, int32_t iLeft, int32_t iRight) {
*pThis -= (((int64_t)iLeft << 32) + iRight);
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_DivII(int64_t* pThis, int32_t iLeft, int32_t iRight) {
*pThis /= (((int64_t)iLeft << 32) + iRight);
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_MulII(int64_t* pThis, int32_t iLeft, int32_t iRight) {
*pThis *= (((int64_t)iLeft << 32) + iRight);
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_ModII(int64_t* pThis, int32_t iLeft, int32_t iRight) {
*pThis %= (((int64_t)iLeft << 32) + iRight);
return pThis;
}
DLL_FUNCTION(int64_t*) BU_Long_Shift(int64_t* pThis, int32_t iRight) {
if (iRight >= 0)
*pThis >>= iRight;
else
*pThis <<= -iRight;
return pThis;
}
+63
View File
@@ -0,0 +1,63 @@
// Blitz - Steam wrapper for Blitz.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "BlitzUtility.h"
#include <sstream>
DLL_FUNCTION(int64_t*) BU_Long_New();
DLL_FUNCTION(int64_t*) BU_Long_Copy(int64_t* pRight);
DLL_FUNCTION(void) BU_Long_Destroy(int64_t* pThis);
DLL_FUNCTION(const char*) BU_Long_ToString(int64_t* pThis);
DLL_FUNCTION(int64_t*) BU_Long_FromString(const char* pString);
DLL_FUNCTION(int64_t*) BU_Long_FromI(int32_t iRight);
DLL_FUNCTION(int64_t*) BU_Long_FromII(int32_t iLeft, int32_t iRight);
DLL_FUNCTION(int32_t) BU_Long_ToI(int64_t* pThis, int32_t iShift);
DLL_FUNCTION(int32_t) BU_Long_ToIH(int64_t* pThis);
DLL_FUNCTION(int32_t) BU_Long_ToIL(int64_t* pThis);
DLL_FUNCTION(int64_t*) BU_Long_FromF(float_t fOther);
DLL_FUNCTION(float_t) BU_Long_ToF(int64_t* pThis);
DLL_FUNCTION(int64_t*) BU_Long_FromD(double_t* pOther);
DLL_FUNCTION(double_t*) BU_Long_ToD(int64_t* pThis);
DLL_FUNCTION(int32_t) BU_Long_Compare(int64_t* pThis, int64_t* pOther);
DLL_FUNCTION(int64_t*) BU_Long_Set(int64_t* pThis, int64_t* pOther);
DLL_FUNCTION(int64_t*) BU_Long_Add(int64_t* pThis, int64_t* pOther);
DLL_FUNCTION(int64_t*) BU_Long_Sub(int64_t* pThis, int64_t* pOther);
DLL_FUNCTION(int64_t*) BU_Long_Div(int64_t* pThis, int64_t* pOther);
DLL_FUNCTION(int64_t*) BU_Long_Mul(int64_t* pThis, int64_t* pOther);
DLL_FUNCTION(int64_t*) BU_Long_Mod(int64_t* pThis, int64_t* pOther);
DLL_FUNCTION(int64_t*) BU_Long_SetI(int64_t* pThis, int32_t iRight);
DLL_FUNCTION(int64_t*) BU_Long_AddI(int64_t* pThis, int32_t iRight);
DLL_FUNCTION(int64_t*) BU_Long_SubI(int64_t* pThis, int32_t iRight);
DLL_FUNCTION(int64_t*) BU_Long_DivI(int64_t* pThis, int32_t iRight);
DLL_FUNCTION(int64_t*) BU_Long_MulI(int64_t* pThis, int32_t iRight);
DLL_FUNCTION(int64_t*) BU_Long_ModI(int64_t* pThis, int32_t iRight);
DLL_FUNCTION(int64_t*) BU_Long_SetII(int64_t* pThis, int32_t iLeft, int32_t iRight);
DLL_FUNCTION(int64_t*) BU_Long_AddII(int64_t* pThis, int32_t iLeft, int32_t iRight);
DLL_FUNCTION(int64_t*) BU_Long_SubII(int64_t* pThis, int32_t iLeft, int32_t iRight);
DLL_FUNCTION(int64_t*) BU_Long_DivII(int64_t* pThis, int32_t iLeft, int32_t iRight);
DLL_FUNCTION(int64_t*) BU_Long_MulII(int64_t* pThis, int32_t iLeft, int32_t iRight);
DLL_FUNCTION(int64_t*) BU_Long_ModII(int64_t* pThis, int32_t iLeft, int32_t iRight);
DLL_FUNCTION(int64_t*) BU_Long_Shift(int64_t* pThis, int32_t iShift);
-256
View File
@@ -1,256 +0,0 @@
// Blitz - Steam wrapper for Blitz.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "LongLong.h"
#include <list>
// Templates
template< typename T >
std::string int_to_hex(T i) {
std::stringstream stream;
stream
<< std::setfill('0')
<< std::setw(sizeof(T) * 2)
<< std::hex
<< i;
return stream.str();
}
template< typename T >
T hex_to_int(std::string t) {
T x;
std::stringstream stream;
stream
<< std::hex
<< t;
stream
>> x;
return x;
}
std::list<int64_t*> blitzLLTemporary;
DLL_FUNCTION(int64_t*) BU_LongLong_Create() {
#pragma comment(linker, "/EXPORT:BU_LongLong_Create=_BU_LongLong_Create@0")
return new int64_t;
}
DLL_FUNCTION(void) BU_LongLong_Destroy(int64_t* pthis) {
#pragma comment(linker, "/EXPORT:BU_LongLong_Destroy=_BU_LongLong_Destroy@4")
delete pthis;
}
DLL_FUNCTION(int64_t*) BU_LongLong_Copy(int64_t* other) {
#pragma comment(linker, "/EXPORT:BU_LongLong_Copy=_BU_LongLong_Copy@4")
return new int64_t(*other);
}
DLL_FUNCTION(int64_t*) BU_LongLong_TempCreate() {
#pragma comment(linker, "/EXPORT:BU_LongLong_TempCreate=_BU_LongLong_TempCreate@0")
int64_t* val = new int64_t;
blitzLLTemporary.push_back(val);
return val;
}
DLL_FUNCTION(int64_t*) BU_LongLong_TempCopy(int64_t* other) {
#pragma comment(linker, "/EXPORT:BU_LongLong_TempCopy=_BU_LongLong_TempCopy@4")
int64_t* val = new int64_t(*other);
blitzLLTemporary.push_back(val);
return val;
}
DLL_FUNCTION(void) BU_LongLong_SetTemp(int64_t* pthis) {
#pragma comment(linker, "/EXPORT:BU_LongLong_SetTemp=_BU_LongLong_SetTemp@4")
blitzLLTemporary.push_back(pthis);
}
DLL_FUNCTION(void) BU_LongLong_UnsetTemp(int64_t* pthis) {
#pragma comment(linker, "/EXPORT:BU_LongLong_UnsetTemp=_BU_LongLong_UnsetTemp@4")
blitzLLTemporary.remove(pthis);
}
DLL_FUNCTION(void) BU_LongLong_TempCleanup() {
#pragma comment(linker, "/EXPORT:BU_LongLong_TempCleanup=_BU_LongLong_TempCleanup@0")
auto iterEnd = blitzLLTemporary.end();
for (auto iter = blitzLLTemporary.begin(); iter != iterEnd; ++iter) {
delete *iter;
}
blitzLLTemporary.clear();
}
DLL_FUNCTION(void) BU_LongLong_Set(int64_t* pthis, int64_t* other) {
#pragma comment(linker, "/EXPORT:BU_LongLong_Set=_BU_LongLong_Set@8")
*pthis = *other;
}
DLL_FUNCTION(void) BU_LongLong_SetV(int64_t* pthis, int32_t left, int32_t right) {
#pragma comment(linker, "/EXPORT:BU_LongLong_SetV=_BU_LongLong_SetV@12")
*pthis = ((int64_t)left << 32) + right;
}
DLL_FUNCTION(void) BU_LongLong_Add(int64_t* pthis, int64_t* other) {
#pragma comment(linker, "/EXPORT:BU_LongLong_Add=_BU_LongLong_Add@8")
*pthis += *other;
}
DLL_FUNCTION(void) BU_LongLong_AddV(int64_t* pthis, int32_t left, int32_t right) {
#pragma comment(linker, "/EXPORT:BU_LongLong_AddV=_BU_LongLong_AddV@12")
*pthis += ((int64_t)left << 32) + right;
}
DLL_FUNCTION(void) BU_LongLong_Sub(int64_t* pthis, int64_t* other) {
#pragma comment(linker, "/EXPORT:BU_LongLong_Sub=_BU_LongLong_Sub@8")
*pthis -= *other;
}
DLL_FUNCTION(void) BU_LongLong_SubV(int64_t* pthis, int32_t left, int32_t right) {
#pragma comment(linker, "/EXPORT:BU_LongLong_SubV=_BU_LongLong_SubV@12")
*pthis -= ((int64_t)left << 32) + right;
}
DLL_FUNCTION(void) BU_LongLong_Mul(int64_t* pthis, int64_t* other) {
#pragma comment(linker, "/EXPORT:BU_LongLong_Mul=_BU_LongLong_Mul@8")
*pthis *= *other;
}
DLL_FUNCTION(void) BU_LongLong_MulV(int64_t* pthis, int32_t left, int32_t right) {
#pragma comment(linker, "/EXPORT:BU_LongLong_MulV=_BU_LongLong_MulV@12")
*pthis *= ((int64_t)left << 32) + right;
}
DLL_FUNCTION(void) BU_LongLong_Div(int64_t* pthis, int64_t* other) {
#pragma comment(linker, "/EXPORT:BU_LongLong_Div=_BU_LongLong_Div@8")
*pthis /= *other;
}
DLL_FUNCTION(void) BU_LongLong_DivV(int64_t* pthis, int32_t left, int32_t right) {
#pragma comment(linker, "/EXPORT:BU_LongLong_DivV=_BU_LongLong_DivV@12")
*pthis /= ((int64_t)left << 32) + right;
}
DLL_FUNCTION(void) BU_LongLong_Modulo(int64_t* pThis, int64_t* pOther) {
#pragma comment(linker, "/EXPORT:BU_LongLong_Modulo=_BU_LongLong_Modulo@8")
*pThis %= *pOther;
}
DLL_FUNCTION(void) BU_LongLong_ModuloV(int64_t* pThis, int32_t left, int32_t right) {
#pragma comment(linker, "/EXPORT:BU_LongLong_ModuloV=_BU_LongLong_ModuloV@12")
*pThis %= (((uint64_t)left << 32) + (uint64_t)right);
}
DLL_FUNCTION(void) BU_LongLong_ShiftLeft(int64_t* pThis, int32_t left) {
#pragma comment(linker, "/EXPORT:BU_LongLong_ShiftLeft=_BU_LongLong_ShiftLeft@8")
*pThis <<= left;
}
DLL_FUNCTION(void) BU_LongLong_ShiftRight(int64_t* pThis, int32_t right) {
#pragma comment(linker, "/EXPORT:BU_LongLong_ShiftRight=_BU_LongLong_ShiftRight@8")
*pThis >>= right;
}
DLL_FUNCTION(int32_t) BU_LongLong_Compare(int64_t* pthis, int64_t* other) {
#pragma comment(linker, "/EXPORT:BU_LongLong_Compare=_BU_LongLong_Compare@8")
return (*pthis == *other ? 1 : 0) + (*pthis < *other ? 2 : 0) + (*pthis > *other ? 4 : 0);
}
DLL_FUNCTION(int32_t) BU_LongLong_CompareV(int64_t* pthis, int32_t left, int32_t right) {
#pragma comment(linker, "/EXPORT:BU_LongLong_CompareV=_BU_LongLong_CompareV@12")
int64_t other = ((int64_t)left << 32) + right;
return (*pthis == other ? 1 : 0) + (*pthis < other ? 2 : 0) + (*pthis > other ? 4 : 0);
}
DLL_FUNCTION(const char*) BU_LongLong_ToString(int64_t* pthis) {
#pragma comment(linker, "/EXPORT:BU_LongLong_ToString=_BU_LongLong_ToString@4")
std::stringstream stream;
stream << (*pthis);
return stream.str().c_str();
}
DLL_FUNCTION(int64_t*) BU_LongLong_FromString(const char* text) {
#pragma comment(linker, "/EXPORT:BU_LongLong_FromString=_BU_LongLong_FromString@4")
std::stringstream stream = std::stringstream(text);
int64_t* val = new int64_t;
stream >> (*val);
return val;
}
DLL_FUNCTION(int32_t) BU_LongLong_ToLong(int64_t* pthis, int32_t _modulus) {
#pragma comment(linker, "/EXPORT:BU_LongLong_ToLong=_BU_LongLong_ToLong@8")
return *pthis % _modulus;
}
DLL_FUNCTION(int64_t*) BU_LongLong_FromLong(int32_t left, int32_t right) {
#pragma comment(linker, "/EXPORT:BU_LongLong_FromLong=_BU_LongLong_FromLong@8")
int64_t* val = new int64_t;
*val = ((int64_t)left << 32) + right;
return val;
}
DLL_FUNCTION(int32_t) BU_LongLong_ToLongHigh(int64_t* pthis) {
#pragma comment(linker, "/EXPORT:BU_LongLong_ToLongHigh=_BU_LongLong_ToLongHigh@4")
return (int32_t)((*pthis) >> 32);
}
DLL_FUNCTION(int32_t) BU_LongLong_ToLongLow(int64_t* pthis) {
#pragma comment(linker, "/EXPORT:BU_LongLong_ToLongLow=_BU_LongLong_ToLongLow@4")
return (int32_t)((*pthis) && 0xFFFFFFFF);
}
DLL_FUNCTION(float_t) BU_LongLong_ToFloat(int64_t* pthis) {
#pragma comment(linker, "/EXPORT:BU_LongLong_ToFloat=_BU_LongLong_ToFloat@4")
return (float)*pthis;
}
DLL_FUNCTION(int64_t*) BU_LongLong_FromFloat(float_t other) {
#pragma comment(linker, "/EXPORT:BU_LongLong_FromFloat=_BU_LongLong_FromFloat@4")
int64_t val = (int64_t)other;
return BU_LongLong_Copy(&val);
}
DLL_FUNCTION(double_t*) BU_LongLong_ToDouble(int64_t* pthis) {
#pragma comment(linker, "/EXPORT:BU_LongLong_ToDouble=_BU_LongLong_ToDouble@4")
double_t* val = new double_t;
*val = (double_t)*pthis;
return val;
}
DLL_FUNCTION(int64_t*) BU_LongLong_FromDouble(double_t* other) {
#pragma comment(linker, "/EXPORT:BU_LongLong_FromDouble=_BU_LongLong_FromDouble@4")
int64_t* val = new int64_t;
*val = (int64_t)*other;
return val;
}
DLL_FUNCTION(const char*) BU_LongLong_Serialize(int64_t* pthis) {
#pragma comment(linker, "/EXPORT:BU_LongLong_Serialize=_BU_LongLong_Serialize@4")
return int_to_hex<int64_t>(*pthis).c_str();
}
DLL_FUNCTION(int64_t*) BU_LongLong_Deserialize(const char* text) {
#pragma comment(linker, "/EXPORT:BU_LongLong_Deserialize=_BU_LongLong_Deserialize@4")
int64_t val = hex_to_int<int64_t>(std::string(text));
return new int64_t(val);
}
-87
View File
@@ -1,87 +0,0 @@
// Blitz - Steam wrapper for Blitz.
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once
#include "BlitzUtility.h"
#include "Double.h"
#include <string>
#include <sstream>
#include <iomanip>
#pragma region Constructor & Destructor
DLL_FUNCTION(int64_t*) BU_LongLong_Create();
DLL_FUNCTION(void) BU_LongLong_Destroy(int64_t* pthis);
DLL_FUNCTION(int64_t*) BU_LongLong_Copy(int64_t* other);
#pragma endregion Constructor & Destructor
#pragma region Temporary Objects
DLL_FUNCTION(int64_t*) BU_LongLong_TempCreate();
DLL_FUNCTION(int64_t*) BU_LongLong_TempCopy(int64_t* other);
DLL_FUNCTION(void) BU_LongLong_SetTemp(int64_t* pthis);
DLL_FUNCTION(void) BU_LongLong_UnsetTemp(int64_t* pthis);
DLL_FUNCTION(void) BU_LongLong_TempCleanup();
#pragma endregion Temporary Objects
#pragma region Math
DLL_FUNCTION(void) BU_LongLong_Set(int64_t* pthis, int64_t* other);
DLL_FUNCTION(void) BU_LongLong_SetV(int64_t* pthis, int32_t left, int32_t right);
DLL_FUNCTION(void) BU_LongLong_Add(int64_t* pthis, int64_t* other);
DLL_FUNCTION(void) BU_LongLong_AddV(int64_t* pthis, int32_t left, int32_t right);
DLL_FUNCTION(void) BU_LongLong_Sub(int64_t* pthis, int64_t* other);
DLL_FUNCTION(void) BU_LongLong_SubV(int64_t* pthis, int32_t left, int32_t right);
DLL_FUNCTION(void) BU_LongLong_Mul(int64_t* pthis, int64_t* other);
DLL_FUNCTION(void) BU_LongLong_MulV(int64_t* pthis, int32_t left, int32_t right);
DLL_FUNCTION(void) BU_LongLong_Div(int64_t* pthis, int64_t* other);
DLL_FUNCTION(void) BU_LongLong_DivV(int64_t* pthis, int32_t left, int32_t right);
#pragma endregion Math
#pragma region Advanced Math
DLL_FUNCTION(void) BU_LongLong_Modulo(int64_t* pThis, int64_t* pOther);
DLL_FUNCTION(void) BU_LongLong_ModuloV(int64_t* pThis, int32_t left, int32_t right);
DLL_FUNCTION(void) BU_LongLong_ShiftLeft(int64_t* pThis, int32_t left);
DLL_FUNCTION(void) BU_LongLong_ShiftRight(int64_t* pThis, int32_t right);
#pragma endregion Advanced Math
#pragma region Comparison
DLL_FUNCTION(int32_t) BU_LongLong_Compare(int64_t* pthis, int64_t* other);
DLL_FUNCTION(int32_t) BU_LongLong_CompareV(int64_t* pthis, int32_t left, int32_t right);
#pragma endregion Comparison
#pragma region Conversion
DLL_FUNCTION(const char*) BU_LongLong_ToString(int64_t* pthis);
DLL_FUNCTION(int64_t*) BU_LongLong_FromString(const char* text);
DLL_FUNCTION(int32_t) BU_LongLong_ToLong(int64_t* pthis, int32_t _modulus);
DLL_FUNCTION(int64_t*) BU_LongLong_FromLong(int32_t left, int32_t right);
DLL_FUNCTION(int32_t) BU_LongLong_ToLongHigh(int64_t* pthis);
DLL_FUNCTION(int32_t) BU_LongLong_ToLongLow(int64_t* pthis);
DLL_FUNCTION(float_t) BU_LongLong_ToFloat(int64_t* pthis);
DLL_FUNCTION(int64_t*) BU_LongLong_FromFloat(float_t other);
DLL_FUNCTION(double_t*) BU_LongLong_ToDouble(int64_t* pthis);
DLL_FUNCTION(int64_t*) BU_LongLong_FromDouble(double_t* pthis);
#pragma endregion Conversion
#pragma region Serialization
DLL_FUNCTION(const char*) BU_LongLong_Serialize(int64_t* pthis);
DLL_FUNCTION(int64_t*) BU_LongLong_Deserialize(const char* text);
#pragma endregion Serialization