diff --git a/BlitzUtility.decls b/BlitzUtility.decls index 9727cee..4b2cac9 100644 --- a/BlitzUtility.decls +++ b/BlitzUtility.decls @@ -1,93 +1,146 @@ -.lib "User32.dll" -BlitzUtility_User32_ClientToScreen%(hwnd%, point*) : "ClientToScreen" -BlitzUtility_User32_ClipCursor%(rect*) : "ClipCursor" -BlitzUtility_User32_ClipCursorI%(ptr%) : "ClipCursor" -BlitzUtility_User32_GetActiveWindow%() : "GetActiveWindow" -BlitzUtility_User32_GetSystemMetrics%(index%) : "GetSystemMetrics" -BlitzUtility_User32_SetWindowLong%(hwnd%, nIndex%, dwNewLong%) : "SetWindowLongA" -BlitzUtility_User32_GetWindowLong%(hwnd%, index%) : "GetWindowLongA" -BlitzUtility_User32_GetWindowRect%(hwnd%, rect*) : "GetWindowRect" -BlitzUtility_User32_GetClientRect%(hwnd%, rect*) : "GetClientRect" -BlitzUtility_User32_SetWindowPos%(hwnd%, hWndInsertAfter%, x%, y%, cx%, cy%, wFlags%) : "SetWindowPos" - -.lib "Kernel32.dll" -BlitzUtility_Kernel32_FlushFileBuffers%(hFile%) : "FlushFileBuffers" - .lib "BlitzUtility.dll" -; Containers - BlitzList +; Math ------------------------------------------------------------------------- +; -- 2D Vector +Vector2_Set(vector*, value#) : "Vector2_Set" +Vector2_SetP(vector*, x#, y#) : "Vector2_SetP" +Vector2_SetV(vector*, other*) : "Vector2_SetV" +Vector2_Add(vector*, value#) : "Vector2_Add" +Vector2_AddP(vector*, x#, y#) : "Vector2_AddP" +Vector2_AddV(vector*, other*) : "Vector2_AddV" +Vector2_Sub(vector*, value#) : "Vector2_Sub" +Vector2_SubP(vector*, x#, y#) : "Vector2_SubP" +Vector2_SubV(vector*, other*) : "Vector2_SubV" +Vector2_Mul(vector*, value#) : "Vector2_Mul" +Vector2_MulP(vector*, x#, y#) : "Vector2_MulP" +Vector2_MulV(vector*, other*) : "Vector2_MulV" +Vector2_Div(vector*, value#) : "Vector2_Div" +Vector2_DivP(vector*, x#, y#) : "Vector2_DivP" +Vector2_DivV(vector*, other*) : "Vector2_DivV" +Vector2_Length#(vector*) : "Vector2_Length" +Vector2_DistanceP#(vector*, x#, y#) : "Vector2_DistanceP" +Vector2_DistanceV#(vector*, other*) : "Vector2_DistanceV" +Vector2_DotP#(vector*, x#, y#) : "Vector2_DotP" +Vector2_DotV#(vector*, other*) : "Vector2_DotV" +Vector2_Normalize(vector*) : "Vector2_Normalize" +Vector2_Rotate(vector*, rotation#) : "Vector2_Rotate" +Vector2_RotateAroundP(vector*, x#, y#, rotation#) : "Vector2_RotateAroundP" +Vector2_RotateAroundV(vector*, other*, rotation#) : "Vector2_RotateAroundV" +Vector2_DeltaRotation#(vector*) : "Vector2_DeltaRotation" +Vector2_DeltaRotationP#(vector*, x#, y#) : "Vector2_DeltaRotationP" +Vector2_DeltaRotationV#(vector*, other*) : "Vector2_DeltaRotationV" +Vector2_Serialize$(vector*) : "Vector2_Serialize" +Vector2_Deserialize(vector*, serial$) : "Vector2_Deserialize" +; -- 3D Vector +Vector3_Set(vector*, value#) : "Vector3_Set" +Vector3_SetP(vector*, x#, y#, z#) : "Vector3_SetP" +Vector3_SetV(vector*, other*) : "Vector3_SetV" +Vector3_Add(vector*, value#) : "Vector3_Add" +Vector3_AddP(vector*, x#, y#, z#) : "Vector3_AddP" +Vector3_AddV(vector*, other*) : "Vector3_AddV" +Vector3_Sub(vector*, value#) : "Vector3_Sub" +Vector3_SubP(vector*, x#, y#, z#) : "Vector3_SubP" +Vector3_SubV(vector*, other*) : "Vector3_SubV" +Vector3_Mul(vector*, value#) : "Vector3_Mul" +Vector3_MulP(vector*, x#, y#, z#) : "Vector3_MulP" +Vector3_MulV(vector*, other*) : "Vector3_MulV" +Vector3_Div(vector*, value#) : "Vector3_Div" +Vector3_DivP(vector*, x#, y#, z#) : "Vector3_DivP" +Vector3_DivV(vector*, other*) : "Vector3_DivV" +Vector3_Length#(vector*) : "Vector3_Length" +Vector3_DistanceP#(vector*, x#, y#, z#) : "Vector3_DistanceP" +Vector3_DistanceV#(vector*, other*) : "Vector3_DistanceV" +Vector3_DotP#(vector*, x#, y#, z#) : "Vector3_DotP" +Vector3_DotV#(vector*, other*) : "Vector3_DotV" +Vector3_CrossP(vector*, x#, y#, z#, out*) : "Vector3_CrossP" +Vector3_CrossV(vector*, other*, out*) : "Vector3_CrossV" +Vector3_Normalize(vector*) : "Vector3_Normalize" +Vector3_Rotate(vector*, pitch#, yaw#, roll#) : "Vector3_Rotate" +Vector3_RotateAroundP(vector*, x#, y#, z#, pitch#, yaw#, roll#) : "Vector3_RotateAroundP" +Vector3_RotateAroundV(vector*, other*, pitch#, yaw#, roll#) : "Vector3_RotateAroundV" +Vector3_DeltaPitch#(vector*) : "Vector3_DeltaPitch" +Vector3_DeltaPitchP#(vector*, x#, y#, z#) : "Vector3_DeltaPitchP" +Vector3_DeltaPitchV#(vector*, other*) : "Vector3_DeltaPitchV" +Vector3_DeltaYaw#(vector*) : "Vector3_DeltaYaw" +Vector3_DeltaYawP#(vector*, x#, y#, z#) : "Vector3_DeltaYawP" +Vector3_DeltaYawV#(vector*, other*) : "Vector3_DeltaYawV" +Vector3_Serialize$(vector*) : "Vector3_Serialize" +Vector3_Deserialize(vector*, serial$) : "Vector3_Deserialize" + +; Containers ------------------------------------------------------------------- +; -- Native Blitz List (Not Threadsafe) BU_BlitzList_New%(obj*) : "BlitzList_New" BU_BlitzList_Activate(list%) : "BlitzList_Activate" BU_BlitzList_Deactivate(list%) : "BlitzList_Deactivate" BU_BlitzList_Destroy(list%) : "BlitzList_Delete" -; Containers - BlitzList - Backward Compatability -BlitzUtility_List_New%(obj*) : "BlitzList_New" -BlitzUtility_List_Activate(list%) : "BlitzList_Activate" -BlitzUtility_List_Deactivate(list%) : "BlitzList_Deactivate" -BlitzUtility_List_Destroy(list%) : "BlitzList_Delete" -; Database - SQLite3 +; Utility ---------------------------------------------------------------------- +; -- Monitor/Display Enumeration +BU_Display_Enumerate() : "Display_Enumerate" +BU_Display_Count%() : "Display_Count" +BU_Display_Get(id%, rectangle*) : "Display_Get" +; -- Fast Indexing V1 (Array-based) +BU_IndexerV1_Create%() : "IndexerV1_Create" +BU_IndexerV1_Destroy(indexer%) : "IndexerV1_Destroy" +BU_IndexerV1_GetIndex%(indexer%) : "IndexerV1_GetFreeIndex" +BU_IndexerV1_MarkIndex(indexer%, index%) : "IndexerV1_MarkFreeIndex" +; -- Fast Indexing V2 (Vector-based) +BU_IndexerV2_Create%() : "IndexerV2_Create" +BU_IndexerV2_Destroy(indexer%) : "IndexerV2_Destroy" +BU_IndexerV2_GetIndex%(indexer%) : "IndexerV2_GetIndex" +BU_IndexerV2_MarkIndex(indexer%, index%) : "IndexerV2_MarkIndex" +BU_IndexerV2_IsFree%(indexer%, index%) : "IndexerV2_IsFree" +BU_IndexerV2_IsUsed%(indexer%, index%) : "IndexerV2_IsUsed" +; -- Window Message Handler +BU_WindowMessageHandler_InstallHandler(hwnd%) : "WindowMessageHandler_Install" +BU_WindowMessageHandler_UninstallHandler(hwnd%) : "WindowMessageHandler_Uninstall" +BU_WindowMessageHandler_Message_Close%(hwnd%) : "WindowMessageHandler_Message_Close" +BU_WindowMessageHandler_Message_Destroy%(hwnd%) : "WindowMessageHandler_Message_Destroy" +BU_WindowMessageHandler_Message_Resize%(hwnd%, point*) : "WindowMessageHandler_Message_Resize" + +; Databases -------------------------------------------------------------------- +; -- SQLite3 SQLite3_LibVersion$() : "sqlite3_libversion" -; Opening and Closing ------------------------------------------------ SQLite3_Open%(Filename$, DatabaseHandle*) : "sqlite3_open" SQLite3_Open_V2%(Filename$, DatabaseHandle*, Flags%, VFS%) : "sqlite3_open_v2" SQLite3_Close%(DatabaseHandle) : "sqlite3_close" -; Misc --------------------------------------------------------------- SQLite3_Busy_TimeOut%(DatabaseHandle, TimeOut) : "sqlite3_busy_timeout" SQLite3_Get_AutoCommit%(DatabaseHandle) : "sqlite3_get_autocommit" SQLite3_Interrupt(DatabaseHandle) : "sqlite3_interrupt" -; Errors ------------------------------------------------------------- SQLite3_ErrCode%(DatabaseHandle) : "sqlite3_errcode" SQLite3_ErrMsg$(DatabaseHandle) : "sqlite3_errmsg" -; Executing SQL without results -------------------------------------- -; As Blitz3D doesn't have function pointers the CallBack is pointless -; and this can only really be used for result-less SQL statements. -; Also, I've never got the Error return to work. So just pass in -; zeros for the last three parameters and use SQLite3_ErrMsg if you -; need to get the error message. SQLite3_Exec%(DatabaseHandle, SQL$, CallBack, FirstParam, Error) : "sqlite3_exec" SQLite3_Changes%(DatabaseHandle) : "sqlite3_changes" SQLite3_Total_Changes%(DatabaseHandle) : "sqlite3_total_changes" SQLite3_Last_Insert_RowID%(DatabaseHandle) : "sqlite3_last_insert_rowid" -; Executing SQL with results ----------------------------------------- -; Never got the SQLTail to work so just pass in a zero. SQLite3_Prepare%(DatabaseHandle, SQL$, LengthOfSQL, StatementHandle*, SQLTail) : "sqlite3_prepare" SQLite3_Step%(StatementHandle) : "sqlite3_step" SQLite3_Reset%(StatementHandle) : "sqlite3_reset" SQLite3_Finalize%(StatementHandle) : "sqlite3_finalize" SQLite3_Data_Count%(StatementHandle) : "sqlite3_data_count" SQLite3_DB_Handle%(StatementHandle) : "sqlite3_db_handle" -; SQL Parameter Binding ---------------------------------------------- SQLite3_Bind_Parameter_Count%(StatementHandle) : "sqlite3_bind_parameter_count" SQLite3_Bind_Parameter_Index%(StatementHandle, ParameterName$) : "sqlite3_bind_parameter_index" SQLite3_Bind_Parameter_Name$(StatementHandle, ParameterIndex) : "sqlite3_bind_parameter_name" -; Never tested this for real, but it should work. SQLite3_Transfer_Bindings%(StatementHandle1, StatementHandle2) : "sqlite3_transfer_bindings" SQLite3_Bind_Null%(StatementHandle, Index) : "sqlite3_bind_null" SQLite3_Bind_Int%(StatementHandle, Index, Value) : "sqlite3_bind_int" -; If you pass -1 for LengthOfText it will work it out for itself. Pass a zero in for Destructor. -SQLite3_Bind_Text%(StatementHandle, Index, Value$, LengthOfText, Destructor) : "sqlite3_bind_text" -; Never tried this so it probably won't work. Pass a zero in for Destructor. -SQLite3_Bind_Blob%(StatementHandle, Index, Value, LengthOfBlob, Destructor) : "sqlite3_bind_blob" -; Doesn't seem to work unfortunately. -SQLite3_Bind_Double%(StatementHandle, Index, Value#) : "sqlite3_bind_double" -; Helpers SQLite3_Bind_Int64%(StatementHandle, Index, Left, Right) : "sqlite3_bind_int64_ex" SQLite3_Bind_Float%(StatementHandle, Index, Value#) : "sqlite3_bind_float" -; Getting values from executed SQL ---------------------------------- +SQLite3_Bind_Double%(StatementHandle, Index, Value#) : "sqlite3_bind_double" +SQLite3_Bind_Text%(StatementHandle, Index, Value$, LengthOfText, Destructor) : "sqlite3_bind_text" +SQLite3_Bind_Blob%(StatementHandle, Index, Value, LengthOfBlob, Destructor) : "sqlite3_bind_blob" SQLite3_Column_Count%(StatementHandle) : "sqlite3_column_count" SQLite3_Column_Name$(StatementHandle, ColumnIndex) : "sqlite3_column_name" SQLite3_Column_Type%(StatementHandle, ColumnIndex) : "sqlite3_column_type" SQLite3_Column_DeclType$(StatementHandle, ColumnIndex) : "sqlite3_column_decltype" SQLite3_Column_Int%(StatementHandle, ColumnIndex) : "sqlite3_column_int" +SQLite3_Column_Int64(StatementHandle, ColumnIndex, outPtr*) : "sqlite3_column_int64_ex" +SQLite3_Column_Float#(StatementHandle, ColumnIndex) : "sqlite3_column_float" SQLite3_Column_Double#(StatementHandle, ColumnIndex) : "sqlite3_column_double" SQLite3_Column_Text$(StatementHandle, ColumnIndex) : "sqlite3_column_text" SQLite3_Column_Bytes%(StatementHandle, ColumnIndex) : "sqlite3_column_bytes" -; Never tried this so it probably won't work. SQLite3_Column_Blob%(StatementHandle, ColumnIndex) : "sqlite3_column_blob" -; Helpers -SQLite3_Column_Int64(StatementHandle, ColumnIndex, outPtr*) : "sqlite3_column_int64_ex" -SQLite3_Column_Float#(StatementHandle, ColumnIndex) : "sqlite3_column_float" -; Helpers ------------------------------------------------------------ +; SQLite3 Wrapped SQLite_Version$() : "sqlite3_libversion" SQLite_Close%(DatabaseHandle) : "sqlite3_close" SQLite_SetTimeOut%(DatabaseHandle, TimeOut) : "sqlite3_busy_timeout" @@ -125,100 +178,39 @@ SQLite_Column_Bytes%(StatementHandle, ColumnIndex) : "sqlite3_column_by SQLite_Column_Blob%(StatementHandle, ColumnIndex) : "sqlite3_column_blob" SQLite_Column_Float#(StatementHandle, ColumnIndex) : "sqlite3_column_float" -; Math - Vector2 -Vector2_Set(vector*, value#) : "Vector2_Set" -Vector2_SetP(vector*, x#, y#) : "Vector2_SetP" -Vector2_SetV(vector*, other*) : "Vector2_SetV" -Vector2_Add(vector*, value#) : "Vector2_Add" -Vector2_AddP(vector*, x#, y#) : "Vector2_AddP" -Vector2_AddV(vector*, other*) : "Vector2_AddV" -Vector2_Sub(vector*, value#) : "Vector2_Sub" -Vector2_SubP(vector*, x#, y#) : "Vector2_SubP" -Vector2_SubV(vector*, other*) : "Vector2_SubV" -Vector2_Mul(vector*, value#) : "Vector2_Mul" -Vector2_MulP(vector*, x#, y#) : "Vector2_MulP" -Vector2_MulV(vector*, other*) : "Vector2_MulV" -Vector2_Div(vector*, value#) : "Vector2_Div" -Vector2_DivP(vector*, x#, y#) : "Vector2_DivP" -Vector2_DivV(vector*, other*) : "Vector2_DivV" -Vector2_Length#(vector*) : "Vector2_Length" -Vector2_DistanceP#(vector*, x#, y#) : "Vector2_DistanceP" -Vector2_DistanceV#(vector*, other*) : "Vector2_DistanceV" -Vector2_DotP#(vector*, x#, y#) : "Vector2_DotP" -Vector2_DotV#(vector*, other*) : "Vector2_DotV" -Vector2_Normalize(vector*) : "Vector2_Normalize" -Vector2_Rotate(vector*, rotation#) : "Vector2_Rotate" -Vector2_RotateAroundP(vector*, x#, y#, rotation#) : "Vector2_RotateAroundP" -Vector2_RotateAroundV(vector*, other*, rotation#) : "Vector2_RotateAroundV" -Vector2_DeltaRotation#(vector*) : "Vector2_DeltaRotation" -Vector2_DeltaRotationP#(vector*, x#, y#) : "Vector2_DeltaRotationP" -Vector2_DeltaRotationV#(vector*, other*) : "Vector2_DeltaRotationV" -Vector2_Serialize$(vector*) : "Vector2_Serialize" -Vector2_Deserialize(vector*, serial$) : "Vector2_Deserialize" - -; Math - Vector3 -Vector3_Set(vector*, value#) : "Vector3_Set" -Vector3_SetP(vector*, x#, y#, z#) : "Vector3_SetP" -Vector3_SetV(vector*, other*) : "Vector3_SetV" -Vector3_Add(vector*, value#) : "Vector3_Add" -Vector3_AddP(vector*, x#, y#, z#) : "Vector3_AddP" -Vector3_AddV(vector*, other*) : "Vector3_AddV" -Vector3_Sub(vector*, value#) : "Vector3_Sub" -Vector3_SubP(vector*, x#, y#, z#) : "Vector3_SubP" -Vector3_SubV(vector*, other*) : "Vector3_SubV" -Vector3_Mul(vector*, value#) : "Vector3_Mul" -Vector3_MulP(vector*, x#, y#, z#) : "Vector3_MulP" -Vector3_MulV(vector*, other*) : "Vector3_MulV" -Vector3_Div(vector*, value#) : "Vector3_Div" -Vector3_DivP(vector*, x#, y#, z#) : "Vector3_DivP" -Vector3_DivV(vector*, other*) : "Vector3_DivV" -Vector3_Length#(vector*) : "Vector3_Length" -Vector3_DistanceP#(vector*, x#, y#, z#) : "Vector3_DistanceP" -Vector3_DistanceV#(vector*, other*) : "Vector3_DistanceV" -Vector3_DotP#(vector*, x#, y#, z#) : "Vector3_DotP" -Vector3_DotV#(vector*, other*) : "Vector3_DotV" -Vector3_CrossP(vector*, x#, y#, z#, out*) : "Vector3_CrossP" -Vector3_CrossV(vector*, other*, out*) : "Vector3_CrossV" -Vector3_Normalize(vector*) : "Vector3_Normalize" -Vector3_Rotate(vector*, pitch#, yaw#, roll#) : "Vector3_Rotate" -Vector3_RotateAroundP(vector*, x#, y#, z#, pitch#, yaw#, roll#) : "Vector3_RotateAroundP" -Vector3_RotateAroundV(vector*, other*, pitch#, yaw#, roll#) : "Vector3_RotateAroundV" -Vector3_DeltaPitch#(vector*) : "Vector3_DeltaPitch" -Vector3_DeltaPitchP#(vector*, x#, y#, z#) : "Vector3_DeltaPitchP" -Vector3_DeltaPitchV#(vector*, other*) : "Vector3_DeltaPitchV" -Vector3_DeltaYaw#(vector*) : "Vector3_DeltaYaw" -Vector3_DeltaYawP#(vector*, x#, y#, z#) : "Vector3_DeltaYawP" -Vector3_DeltaYawV#(vector*, other*) : "Vector3_DeltaYawV" -Vector3_Serialize$(vector*) : "Vector3_Serialize" -Vector3_Deserialize(vector*, serial$) : "Vector3_Deserialize" - -; Utility - Displays -BU_Display_Enumerate() : "Display_Enumerate" -BU_Display_Count%() : "Display_Count" -BU_Display_Get(id%, rectangle*) : "Display_Get" -; Utility - Displays - Backward Compatability +; Backwards Compatability - Containers ----------------------------------------- +; -- Lists +BlitzUtility_List_New%(obj*) : "BlitzList_New" +BlitzUtility_List_Activate(list%) : "BlitzList_Activate" +BlitzUtility_List_Deactivate(list%) : "BlitzList_Deactivate" +BlitzUtility_List_Destroy(list%) : "BlitzList_Delete" +; Backwards Compatability - Utility -------------------------------------------- +; -- Monitor/Display Enumeration BlitzUtility_EnumerateDisplays() : "Display_Enumerate" BlitzUtility_GetDisplayCount%() : "Display_Count" BlitzUtility_GetDisplay(id%, rectangle*) : "Display_Get" +; -- Fast Indexing V1 (Array-based) +Indexer_Create%() : "IndexerV1_Create" +Indexer_GetFreeIndex%(indexer%) : "IndexerV1_GetFreeIndex" +Indexer_MarkFreeIndex(indexer%, index%) : "IndexerV1_MarkFreeIndex" +Indexer_Destroy(indexer%) : "IndexerV1_Destroy" +; -- Window Message Handler +BlitzUtility_InstallCloseHandler(hwnd%) : "WindowMessageHandler_Install" +BlitzUtility_UninstallCloseHandler(hwnd%) : "WindowMessageHandler_Uninstall" +BlitzUtility_GetCloseCount%(hwnd%) : "WindowMessageHandler_Message_Close" -; Utility - Indexing -BU_Indexer_Create%() : "Indexer_Create" -BU_Indexer_GetFreeIndex%(indexer%) : "Indexer_GetFreeIndex" -BU_Indexer_MarkFreeIndex(indexer%, index%) : "Indexer_MarkFreeIndex" -BU_Indexer_Destroy(indexer%) : "Indexer_Destroy" -; Utility - Indexing - Backward Compatability -Indexer_Create%() : "Indexer_Create" -Indexer_GetFreeIndex%(indexer%) : "Indexer_GetFreeIndex" -Indexer_MarkFreeIndex(indexer%, index%) : "Indexer_MarkFreeIndex" -Indexer_Destroy(indexer%) : "Indexer_Destroy" +; Internal --------------------------------------------------------------------- +.lib "User32.dll" +BlitzUtility_User32_ClientToScreen%(hwnd%, point*) : "ClientToScreen" +BlitzUtility_User32_ClipCursor%(rect*) : "ClipCursor" +BlitzUtility_User32_ClipCursorI%(ptr%) : "ClipCursor" +BlitzUtility_User32_GetActiveWindow%() : "GetActiveWindow" +BlitzUtility_User32_GetSystemMetrics%(index%) : "GetSystemMetrics" +BlitzUtility_User32_SetWindowLong%(hwnd%, nIndex%, dwNewLong%) : "SetWindowLongA" +BlitzUtility_User32_GetWindowLong%(hwnd%, index%) : "GetWindowLongA" +BlitzUtility_User32_GetWindowRect%(hwnd%, rect*) : "GetWindowRect" +BlitzUtility_User32_GetClientRect%(hwnd%, rect*) : "GetClientRect" +BlitzUtility_User32_SetWindowPos%(hwnd%, hWndInsertAfter%, x%, y%, cx%, cy%, wFlags%) : "SetWindowPos" -; Utility - Window Messages -BU_WindowMessageHandler_InstallHandler(hwnd%) : "WindowMessageHandler_Install" -BU_WindowMessageHandler_UninstallHandler(hwnd%) : "WindowMessageHandler_Uninstall" -BU_WindowMessageHandler_Message_Close%(hwnd%) : "WindowMessageHandler_Message_Close" -BU_WindowMessageHandler_Message_Destroy%(hwnd%) : "WindowMessageHandler_Message_Destroy" -BU_WindowMessageHandler_Message_Resize%(hwnd%, point*) : "WindowMessageHandler_Message_Resize" -; Utility - Window Messages - Backward Compatability -BlitzUtility_InstallCloseHandler(hwnd%) : "WindowMessageHandler_InstallHandler" -BlitzUtility_UninstallCloseHandler(hwnd%) : "WindowMessageHandler_UninstallHandler" -BlitzUtility_GetCloseCount%(hwnd%) : "WindowMessageHandler_CountCloseMessages" +.lib "Kernel32.dll" +BlitzUtility_Kernel32_FlushFileBuffers%(hFile%) : "FlushFileBuffers" \ No newline at end of file diff --git a/BlitzUtility.vcxproj b/BlitzUtility.vcxproj index 5ae5c0e..d4f2345 100644 --- a/BlitzUtility.vcxproj +++ b/BlitzUtility.vcxproj @@ -129,13 +129,14 @@ - + + @@ -146,13 +147,14 @@ Cdecl CompileAsC - + + diff --git a/BlitzUtility.vcxproj.filters b/BlitzUtility.vcxproj.filters index b3b4796..7dc11ec 100644 --- a/BlitzUtility.vcxproj.filters +++ b/BlitzUtility.vcxproj.filters @@ -43,15 +43,18 @@ Source Files\Utility - - Source Files\Utility - Source Files\Utility Source Files\Database\SQLite + + Source Files\Utility + + + Source Files\Utility + @@ -78,10 +81,13 @@ Source Files\Utility - + Source Files\Utility - + + Source Files\Utility + + Source Files\Utility diff --git a/Containers/BlitzList.cpp b/Containers/BlitzList.cpp index 4c463be..c6e11d3 100644 --- a/Containers/BlitzList.cpp +++ b/Containers/BlitzList.cpp @@ -1,4 +1,3 @@ -#pragma once #include "BlitzList.h" std::list* BlitzUtility_Lists; @@ -12,9 +11,9 @@ void BlitzList_OnProcessDetach() { delete BlitzUtility_Lists; } -DLL_EXPORT void* BlitzList_New(void* elementPtr) { - BBVarElement* element = (BBVarElement*)(((int*)elementPtr) - 5); - BBVarType* type = (BBVarType*)(*(((int*)elementPtr) - 2)); +DLL_EXPORT void* BlitzList_New(uint32_t* elementPtr) { + BBVarElement* element = (BBVarElement*)(((uint32_t*)elementPtr) - 5); + BBVarType* type = (BBVarType*)(*(((uint32_t*)elementPtr) - 2)); // Create and initialize structure to hold information about this change. BlitzTypeInfo* bti = new BlitzTypeInfo(); @@ -29,14 +28,15 @@ DLL_EXPORT void* BlitzList_New(void* elementPtr) { element->nextPtr->prevPtr = element->prevPtr; // Correct element next/prev pointers to no longer be inside the old list. - element->prevPtr = (BBVarElement*)((int*)type + 1); - element->nextPtr = (BBVarElement*)((int*)type + 1); + element->prevPtr = (BBVarElement*)((uint32_t*)type + 1); + element->nextPtr = (BBVarElement*)((uint32_t*)type + 1); BlitzUtility_Lists->push_back(bti); return bti; } +#pragma comment(linker, "/EXPORT:BlitzList_New=_BlitzList_New@4") -DLL_EXPORT void BlitzList_Activate(void* list) { +DLL_EXPORT void BlitzList_Activate(uint32_t* list) { BlitzTypeInfo* bti = (BlitzTypeInfo*)list; // Store current pointers @@ -47,8 +47,9 @@ DLL_EXPORT void BlitzList_Activate(void* list) { bti->type->used.nextPtr = bti->ourNextPtr; bti->type->used.prevPtr = bti->ourPrevPtr; } +#pragma comment(linker, "/EXPORT:BlitzList_Activate=_BlitzList_Activate@4") -DLL_EXPORT void BlitzList_Deactivate(void* list) { +DLL_EXPORT void BlitzList_Deactivate(uint32_t* list) { BlitzTypeInfo* bti = (BlitzTypeInfo*)list; // Store current pointers @@ -59,9 +60,11 @@ DLL_EXPORT void BlitzList_Deactivate(void* list) { bti->type->used.nextPtr = bti->lastNextPtr; bti->type->used.prevPtr = bti->lastPrevPtr; } +#pragma comment(linker, "/EXPORT:BlitzList_Deactivate=_BlitzList_Deactivate@4") -DLL_EXPORT void BlitzList_Delete(void* list) { +DLL_EXPORT void BlitzList_Delete(uint32_t* list) { BlitzTypeInfo* bti = (BlitzTypeInfo*)list; BlitzUtility_Lists->remove(bti); delete bti; } +#pragma comment(linker, "/EXPORT:BlitzList_Delete=_BlitzList_Delete@4") \ No newline at end of file diff --git a/Containers/BlitzList.h b/Containers/BlitzList.h index 401d559..cf05af1 100644 --- a/Containers/BlitzList.h +++ b/Containers/BlitzList.h @@ -39,9 +39,4 @@ struct BlitzTypeInfo { }; void BlitzList_OnProcessAttach(); -void BlitzList_OnProcessDetach(); - -DLL_EXPORT void* BlitzList_New(void* type); -DLL_EXPORT void BlitzList_Activate(void* list); -DLL_EXPORT void BlitzList_Deactivate(void* list); -DLL_EXPORT void BlitzList_Delete(void* list); +void BlitzList_OnProcessDetach(); \ No newline at end of file diff --git a/Database/SQLite/SQLite.cpp b/Database/SQLite/SQLite.cpp index 36db496..48aad72 100644 --- a/Database/SQLite/SQLite.cpp +++ b/Database/SQLite/SQLite.cpp @@ -1,4 +1,3 @@ -#pragma once #include "SQLite.h" void SQLite3_OnProcessAttach() { @@ -9,22 +8,55 @@ void SQLite3_OnProcessDetach() { sqlite3_shutdown(); } +/*DLL_EXPORT const char* SQLite_LibVersion() { + return sqlite3_libversion(); +} + +DLL_EXPORT uint32_t SQLite_LibVersionNumber() { + return sqlite3_libversion_number(); +} + +DLL_EXPORT uint32_t* SQLite_Open(char* dbFilename) { + sqlite3* dbHandle; + sqlite3_open(dbFilename, &dbHandle); + return (uint32_t*)dbHandle; +} + +DLL_EXPORT uint32_t* SQLite_Open_V2(char* dbFilename, uint32_t flags) { + sqlite3* dbHandle; + sqlite3_open_v2(dbFilename, &dbHandle, flags, nullptr); + return (uint32_t*)dbHandle; +} + +DLL_EXPORT void SQLite_Close(uint32_t* dbHandlePtr) { + sqlite3* dbHandle = (sqlite3*)dbHandlePtr; + sqlite3_close(dbHandle); +} + +DLL_EXPORT int SQLite_Busy_TimeOut() { + +}*/ + DLL_EXPORT int sqlite3_bind_int64_ex(void* stmtPtr, uint32_t index, uint32_t low, uint32_t high) { return sqlite3_bind_int64((sqlite3_stmt*)stmtPtr, index, (((uint64_t)low << 32) + (uint64_t)high)); } +#pragma comment(linker, "/EXPORT:sqlite3_bind_int64_ex=_sqlite3_bind_int64_ex@16") DLL_EXPORT int sqlite3_bind_float(void* stmtPtr, uint32_t index, float value) { return sqlite3_bind_double((sqlite3_stmt*)stmtPtr, index, (double)value); } +#pragma comment(linker, "/EXPORT:sqlite3_bind_float=_sqlite3_bind_float@12") DLL_EXPORT void sqlite3_column_int64_ex(void* stmtPtr, uint32_t index, void* outPtr) { sqlite3_int64 out = sqlite3_column_int64((sqlite3_stmt*)stmtPtr, index); - int* ourPtr = (int*)outPtr; - (*ourPtr) = (int)(out & 0xFFFFFFFF); - (*(ourPtr + 1)) = (int)(out >> 32); + uint32_t* ourPtr = (uint32_t*)outPtr; + (*ourPtr) = (uint32_t)(out & 0xFFFFFFFF); + (*(ourPtr + 1)) = (uint32_t)(out >> 32); } +#pragma comment(linker, "/EXPORT:sqlite3_column_int64_ex=_sqlite3_column_int64_ex@12") DLL_EXPORT float sqlite3_column_float(void* stmtPtr, uint32_t index) { double out = sqlite3_column_double((sqlite3_stmt*)stmtPtr, index); return (float)out; -} \ No newline at end of file +} +#pragma comment(linker, "/EXPORT:sqlite3_column_float=_sqlite3_column_float@8") \ No newline at end of file diff --git a/Database/SQLite/SQLite.h b/Database/SQLite/SQLite.h index 91ebde1..9c51e20 100644 --- a/Database/SQLite/SQLite.h +++ b/Database/SQLite/SQLite.h @@ -1,14 +1,7 @@ +#pragma once #include "dllmain.h" -#include #include "sqlite3.h" +#include void SQLite3_OnProcessAttach(); void SQLite3_OnProcessDetach(); - -extern "C" { - DLL_EXPORT int sqlite3_bind_int64_ex(void* stmtPtr, uint32_t index, uint32_t low, uint32_t high); - DLL_EXPORT int sqlite3_bind_float(void* stmtPtr, uint32_t index, float value); - - DLL_EXPORT void sqlite3_column_int64_ex(void* stmtPtr, uint32_t index, void* outPtr); - DLL_EXPORT float sqlite3_column_float(void* stmtPtr, uint32_t index); -} \ No newline at end of file diff --git a/Database/SQLite/sqlite3.c b/Database/SQLite/sqlite3.c index 66fbec6..20d2147 100644 --- a/Database/SQLite/sqlite3.c +++ b/Database/SQLite/sqlite3.c @@ -259,7 +259,7 @@ extern "C" { # define SQLITE_API #endif #ifndef SQLITE_CDECL -# define SQLITE_CDECL +# define SQLITE_CDECL __cdecl #endif #ifndef SQLITE_STDCALL # define SQLITE_STDCALL __cdecl diff --git a/Database/SQLite/sqlite3.h b/Database/SQLite/sqlite3.h index 5039b75..4c79b34 100644 --- a/Database/SQLite/sqlite3.h +++ b/Database/SQLite/sqlite3.h @@ -46,13 +46,13 @@ extern "C" { ** Provide the ability to override linkage features of the interface. */ #ifndef SQLITE_EXTERN -# define SQLITE_EXTERN extern "C" __declspec(dllexport) +# define SQLITE_EXTERN #endif #ifndef SQLITE_API -# define SQLITE_API +# define SQLITE_API extern "C" __declspec(dllexport) #endif #ifndef SQLITE_CDECL -# define SQLITE_CDECL +# define SQLITE_CDECL __cdecl #endif #ifndef SQLITE_STDCALL # define SQLITE_STDCALL __cdecl diff --git a/Math/Matrix3.cpp b/Math/Matrix3.cpp index 69ba6cd..4d438b4 100644 --- a/Math/Matrix3.cpp +++ b/Math/Matrix3.cpp @@ -1,7 +1,5 @@ -#pragma once #include "Matrix3.h" - void Matrix3::set(Matrix3 &M) { if (this != &M) { diff --git a/Math/Vector2.cpp b/Math/Vector2.cpp index e8b3c5c..fe0b540 100644 --- a/Math/Vector2.cpp +++ b/Math/Vector2.cpp @@ -1,4 +1,3 @@ -#pragma once #include "Vector2.h" void Vector2::set(const float &o) @@ -172,6 +171,9 @@ DLL_EXPORT void Vector2_SetP(Vector2* a, float x, float y) { DLL_EXPORT void Vector2_SetV(Vector2* a, Vector2* b) { a->set(*b); } +#pragma comment(linker, "/EXPORT:Vector2_Set=_Vector2_Set@8") +#pragma comment(linker, "/EXPORT:Vector2_SetP=_Vector2_SetP@12") +#pragma comment(linker, "/EXPORT:Vector2_SetV=_Vector2_SetV@8") DLL_EXPORT void Vector2_Add(Vector2* a, float o) { a->add(o); @@ -182,6 +184,9 @@ DLL_EXPORT void Vector2_AddP(Vector2* a, float x, float y) { DLL_EXPORT void Vector2_AddV(Vector2* a, Vector2* b) { a->add(*b); } +#pragma comment(linker, "/EXPORT:Vector2_Add=_Vector2_Add@8") +#pragma comment(linker, "/EXPORT:Vector2_AddP=_Vector2_AddP@12") +#pragma comment(linker, "/EXPORT:Vector2_AddV=_Vector2_AddV@8") DLL_EXPORT void Vector2_Sub(Vector2* a, float o) { a->sub(o); @@ -192,6 +197,9 @@ DLL_EXPORT void Vector2_SubP(Vector2* a, float x, float y) { DLL_EXPORT void Vector2_SubV(Vector2* a, Vector2* b) { a->sub(*b); } +#pragma comment(linker, "/EXPORT:Vector2_Sub=_Vector2_Sub@8") +#pragma comment(linker, "/EXPORT:Vector2_SubP=_Vector2_SubP@12") +#pragma comment(linker, "/EXPORT:Vector2_SubV=_Vector2_SubV@8") DLL_EXPORT void Vector2_Mul(Vector2* a, float o) { a->mul(o); @@ -202,6 +210,9 @@ DLL_EXPORT void Vector2_MulP(Vector2* a, float x, float y) { DLL_EXPORT void Vector2_MulV(Vector2* a, Vector2* b) { a->mul(*b); } +#pragma comment(linker, "/EXPORT:Vector2_Mul=_Vector2_Mul@8") +#pragma comment(linker, "/EXPORT:Vector2_MulP=_Vector2_MulP@12") +#pragma comment(linker, "/EXPORT:Vector2_MulV=_Vector2_MulV@8") DLL_EXPORT void Vector2_Div(Vector2* a, float o) { a->div(o); @@ -212,6 +223,9 @@ DLL_EXPORT void Vector2_DivP(Vector2* a, float x, float y) { DLL_EXPORT void Vector2_DivV(Vector2* a, Vector2* b) { a->div(*b); } +#pragma comment(linker, "/EXPORT:Vector2_Div=_Vector2_Div@8") +#pragma comment(linker, "/EXPORT:Vector2_DivP=_Vector2_DivP@12") +#pragma comment(linker, "/EXPORT:Vector2_DivV=_Vector2_DivV@8") DLL_EXPORT float Vector2_Length(Vector2* a) { return (float)a->length(); @@ -222,6 +236,9 @@ DLL_EXPORT float Vector2_DistanceP(Vector2* a, float x, float y) { DLL_EXPORT float Vector2_DistanceV(Vector2* a, Vector2* b) { return (float)a->distance(*b); } +#pragma comment(linker, "/EXPORT:Vector2_Length=_Vector2_Length@4") +#pragma comment(linker, "/EXPORT:Vector2_DistanceP=_Vector2_DistanceP@12") +#pragma comment(linker, "/EXPORT:Vector2_DistanceV=_Vector2_DistanceV@8") DLL_EXPORT float Vector2_DotP(Vector2* a, float x, float y) { return (float)a->dot(x, y); @@ -232,6 +249,9 @@ DLL_EXPORT float Vector2_DotV(Vector2* a, Vector2* b) { DLL_EXPORT void Vector2_Normalize(Vector2* a) { a->normalize(); } +#pragma comment(linker, "/EXPORT:Vector2_DotP=_Vector2_DotP@12") +#pragma comment(linker, "/EXPORT:Vector2_DotV=_Vector2_DotV@8") +#pragma comment(linker, "/EXPORT:Vector2_Normalize=_Vector2_Normalize@4") DLL_EXPORT void Vector2_Rotate(Vector2* a, float rotation) { a->rotate(rotation); @@ -242,6 +262,9 @@ DLL_EXPORT void Vector2_RotateAroundP(Vector2* a, float x, float y, float rotati DLL_EXPORT void Vector2_RotateAroundV(Vector2* a, Vector2* b, float rotation) { a->rotateAround(*b, rotation); } +#pragma comment(linker, "/EXPORT:Vector2_Rotate=_Vector2_Rotate@8") +#pragma comment(linker, "/EXPORT:Vector2_RotateAroundP=_Vector2_RotateAroundP@16") +#pragma comment(linker, "/EXPORT:Vector2_RotateAroundV=_Vector2_RotateAroundV@12") DLL_EXPORT float Vector2_DeltaRotation(Vector2* a) { return (float)a->deltaRotation(); @@ -252,6 +275,9 @@ DLL_EXPORT float Vector2_DeltaRotationP(Vector2* a, float x, float y) { DLL_EXPORT float Vector2_DeltaRotationV(Vector2* a, Vector2* b) { return (float)a->deltaRotation(*b); } +#pragma comment(linker, "/EXPORT:Vector2_DeltaRotation=_Vector2_DeltaRotation@4") +#pragma comment(linker, "/EXPORT:Vector2_DeltaRotationP=_Vector2_DeltaRotationP@12") +#pragma comment(linker, "/EXPORT:Vector2_DeltaRotationV=_Vector2_DeltaRotationV@8") DLL_EXPORT char* Vector2_Serialize(Vector2* a) { return a->serialize(); @@ -259,3 +285,5 @@ DLL_EXPORT char* Vector2_Serialize(Vector2* a) { DLL_EXPORT void Vector2_Deserialize(Vector2* a, char* o) { a->deserialize(o); } +#pragma comment(linker, "/EXPORT:Vector2_Serialize=_Vector2_Serialize@4") +#pragma comment(linker, "/EXPORT:Vector2_Deserialize=_Vector2_Deserialize@8") diff --git a/Math/Vector3.cpp b/Math/Vector3.cpp index 42772a4..92441f6 100644 --- a/Math/Vector3.cpp +++ b/Math/Vector3.cpp @@ -1,4 +1,3 @@ -#pragma once #include "Vector3.h" void Vector3::set(const float &o) @@ -226,6 +225,9 @@ DLL_EXPORT void Vector3_SetP(Vector3* a, float x, float y, float z) { DLL_EXPORT void Vector3_SetV(Vector3* a, Vector3* b) { a->set(*b); } +#pragma comment(linker, "/EXPORT:Vector3_Set=_Vector3_Set@8") +#pragma comment(linker, "/EXPORT:Vector3_SetP=_Vector3_SetP@16") +#pragma comment(linker, "/EXPORT:Vector3_SetV=_Vector3_SetV@8") DLL_EXPORT void Vector3_Add(Vector3* a, float o) { a->add(o); @@ -236,6 +238,9 @@ DLL_EXPORT void Vector3_AddP(Vector3* a, float x, float y, float z) { DLL_EXPORT void Vector3_AddV(Vector3* a, Vector3* b) { a->add(*b); } +#pragma comment(linker, "/EXPORT:Vector3_Add=_Vector3_Add@8") +#pragma comment(linker, "/EXPORT:Vector3_AddP=_Vector3_AddP@16") +#pragma comment(linker, "/EXPORT:Vector3_AddV=_Vector3_AddV@8") DLL_EXPORT void Vector3_Sub(Vector3* a, float o) { a->sub(o); @@ -246,6 +251,9 @@ DLL_EXPORT void Vector3_SubP(Vector3* a, float x, float y, float z) { DLL_EXPORT void Vector3_SubV(Vector3* a, Vector3* b) { a->sub(*b); } +#pragma comment(linker, "/EXPORT:Vector3_Sub=_Vector3_Sub@8") +#pragma comment(linker, "/EXPORT:Vector3_SubP=_Vector3_SubP@16") +#pragma comment(linker, "/EXPORT:Vector3_SubV=_Vector3_SubV@8") DLL_EXPORT void Vector3_Mul(Vector3* a, float o) { a->mul(o); @@ -256,6 +264,9 @@ DLL_EXPORT void Vector3_MulP(Vector3* a, float x, float y, float z) { DLL_EXPORT void Vector3_MulV(Vector3* a, Vector3* b) { a->mul(*b); } +#pragma comment(linker, "/EXPORT:Vector3_Mul=_Vector3_Mul@8") +#pragma comment(linker, "/EXPORT:Vector3_MulP=_Vector3_MulP@16") +#pragma comment(linker, "/EXPORT:Vector3_MulV=_Vector3_MulV@8") DLL_EXPORT void Vector3_Div(Vector3* a, float o) { a->div(o); @@ -266,6 +277,9 @@ DLL_EXPORT void Vector3_DivP(Vector3* a, float x, float y, float z) { DLL_EXPORT void Vector3_DivV(Vector3* a, Vector3* b) { a->div(*b); } +#pragma comment(linker, "/EXPORT:Vector3_Div=_Vector3_Div@8") +#pragma comment(linker, "/EXPORT:Vector3_DivP=_Vector3_DivP@16") +#pragma comment(linker, "/EXPORT:Vector3_DivV=_Vector3_DivV@8") DLL_EXPORT float Vector3_Length(Vector3* a) { return (float)a->length(); @@ -276,6 +290,9 @@ DLL_EXPORT float Vector3_DistanceP(Vector3* a, float x, float y, float z) { DLL_EXPORT float Vector3_DistanceV(Vector3* a, Vector3* b) { return (float)a->distance(*b); } +#pragma comment(linker, "/EXPORT:Vector3_Length=_Vector3_Length@4") +#pragma comment(linker, "/EXPORT:Vector3_DistanceP=_Vector3_DistanceP@16") +#pragma comment(linker, "/EXPORT:Vector3_DistanceV=_Vector3_DistanceV@8") DLL_EXPORT float Vector3_DotP(Vector3* a, float x, float y, float z) { return (float)a->dot(x, y, z); @@ -294,6 +311,11 @@ DLL_EXPORT void Vector3_CrossV(Vector3* a, Vector3* b, Vector3* out) { DLL_EXPORT void Vector3_Normalize(Vector3* a) { a->normalize(); } +#pragma comment(linker, "/EXPORT:Vector3_DotP=_Vector3_DotP@16") +#pragma comment(linker, "/EXPORT:Vector3_DotV=_Vector3_DotV@8") +#pragma comment(linker, "/EXPORT:Vector3_CrossP=_Vector3_CrossP@20") +#pragma comment(linker, "/EXPORT:Vector3_CrossV=_Vector3_CrossV@12") +#pragma comment(linker, "/EXPORT:Vector3_Normalize=_Vector3_Normalize@4") DLL_EXPORT void Vector3_Rotate(Vector3* a, float pitch, float yaw, float roll) { a->rotate(pitch, yaw, roll); @@ -304,6 +326,9 @@ DLL_EXPORT void Vector3_RotateAroundP(Vector3* a, float x, float y, float z, flo DLL_EXPORT void Vector3_RotateAroundV(Vector3* a, Vector3* b, float pitch, float yaw, float roll) { a->rotateAround(*b, pitch, yaw, roll); } +#pragma comment(linker, "/EXPORT:Vector3_Rotate=_Vector3_Rotate@16") +#pragma comment(linker, "/EXPORT:Vector3_RotateAroundP=_Vector3_RotateAroundP@28") +#pragma comment(linker, "/EXPORT:Vector3_RotateAroundV=_Vector3_RotateAroundV@20") DLL_EXPORT float Vector3_DeltaPitchP(Vector3* a, float x, float y, float z) { return (float)a->deltaPitch(x, y, z); @@ -317,10 +342,16 @@ DLL_EXPORT float Vector3_DeltaYawP(Vector3* a, float x, float y, float z) { DLL_EXPORT float Vector3_DeltaYawV(Vector3* a, Vector3* b) { return (float)a->deltaYaw(*b); } +#pragma comment(linker, "/EXPORT:Vector3_DeltaPitchP=_Vector3_DeltaPitchP@16") +#pragma comment(linker, "/EXPORT:Vector3_DeltaPitchV=_Vector3_DeltaPitchV@8") +#pragma comment(linker, "/EXPORT:Vector3_DeltaYawP=_Vector3_DeltaYawP@16") +#pragma comment(linker, "/EXPORT:Vector3_DeltaYawV=_Vector3_DeltaYawV@8") DLL_EXPORT char* Vector3_Serialize(Vector3* a) { return a->serialize(); } DLL_EXPORT void Vector3_Deserialize(Vector3* a, char* s) { a->deserialize(s); -} \ No newline at end of file +} +#pragma comment(linker, "/EXPORT:Vector3_Serialize=_Vector3_Serialize@4") +#pragma comment(linker, "/EXPORT:Vector3_Deserialize=_Vector3_Deserialize@8") diff --git a/Utility/Display.cpp b/Utility/Display.cpp index 20014bb..5c9d3d8 100644 --- a/Utility/Display.cpp +++ b/Utility/Display.cpp @@ -19,6 +19,7 @@ DLL_EXPORT void Display_Enumerate() { EnumDisplayMonitors(NULL, NULL, Display_EnumerateProcedure, 0); } +#pragma comment(linker, "/EXPORT:Display_Enumerate=_Display_Enumerate@0") BOOL CALLBACK Display_EnumerateProcedure(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData) { Display *thisDisplay = new Display; @@ -36,9 +37,10 @@ BOOL CALLBACK Display_EnumerateProcedure(HMONITOR hMonitor, HDC hdcMonitor, LPRE DLL_EXPORT int Display_Count() { return Display_List->size(); } +#pragma comment(linker, "/EXPORT:Display_Count=_Display_Count@0") -DLL_EXPORT void Display_Get(int displayId, LPRECT display) { - if (Display_List->size() > (unsigned)displayId) { +DLL_EXPORT void Display_Get(uint32_t displayId, LPRECT display) { + if (Display_List->size() > displayId) { auto iterator = Display_List->begin(); std::advance(iterator, displayId); @@ -51,4 +53,5 @@ DLL_EXPORT void Display_Get(int displayId, LPRECT display) { } } } +#pragma comment(linker, "/EXPORT:Display_Get=_Display_Get@8") diff --git a/Utility/Display.h b/Utility/Display.h index bd2c400..e9c147f 100644 --- a/Utility/Display.h +++ b/Utility/Display.h @@ -12,10 +12,4 @@ struct Display { void Display_OnProcessAttach(); void Display_OnProcessDetach(); -BOOL CALLBACK Display_EnumerateProcedure(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData); - -extern "C" { - DLL_EXPORT void Display_Enumerate(); - DLL_EXPORT int Display_Count(); - DLL_EXPORT void Display_Get(int displayId, LPRECT display); -} \ No newline at end of file +BOOL CALLBACK Display_EnumerateProcedure(HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData); \ No newline at end of file diff --git a/Utility/Indexer.cpp b/Utility/IndexerV1.cpp similarity index 61% rename from Utility/Indexer.cpp rename to Utility/IndexerV1.cpp index d44e859..49ca512 100644 --- a/Utility/Indexer.cpp +++ b/Utility/IndexerV1.cpp @@ -1,5 +1,5 @@ #pragma once -#include "Indexer.h" +#include "IndexerV1.h" #define INDEX_OFF_0 0x00000000 #define INDEX_OFF_1 0x10000000 @@ -18,7 +18,7 @@ #define INDEX_OFF_E 0xE0000000 #define INDEX_OFF_F 0xF0000000 -unsigned int Indexer::GetFreeIndex() +unsigned int IndexerV1::GetFreeIndex() { unsigned int index = lastAssignedIndex + 1; @@ -46,7 +46,7 @@ unsigned int Indexer::GetFreeIndex() return lastAssignedIndex; } -void Indexer::MarkFreeIndex(int index) +void IndexerV1::MarkFreeIndex(int index) { unsigned short bitFlip = index % 64; @@ -54,22 +54,26 @@ void Indexer::MarkFreeIndex(int index) this->indexes[index >> 6] &= ~(1ULL << bitFlip); } -DLL_EXPORT void* Indexer_Create() { - Indexer* indexer = new Indexer(); +DLL_EXPORT void* IndexerV1_Create() { + IndexerV1* indexer = new IndexerV1(); return indexer; } +#pragma comment(linker, "/EXPORT:IndexerV1_Create=_IndexerV1_Create@0") -DLL_EXPORT int Indexer_GetFreeIndex(void* indexerPtr) { - Indexer* indexer = (Indexer*)indexerPtr; +DLL_EXPORT int IndexerV1_GetFreeIndex(uint32_t* indexerPtr) { + IndexerV1* indexer = (IndexerV1*)indexerPtr; return indexer->GetFreeIndex(); } +#pragma comment(linker, "/EXPORT:IndexerV1_GetFreeIndex=_IndexerV1_GetFreeIndex@4") -DLL_EXPORT void Indexer_MarkFreeIndex(void* indexerPtr, int Index) { - Indexer* indexer = (Indexer*)indexerPtr; +DLL_EXPORT void IndexerV1_MarkFreeIndex(uint32_t* indexerPtr, uint32_t Index) { + IndexerV1* indexer = (IndexerV1*)indexerPtr; indexer->MarkFreeIndex(Index); } +#pragma comment(linker, "/EXPORT:IndexerV1_MarkFreeIndex=_IndexerV1_MarkFreeIndex@8") -DLL_EXPORT void Indexer_Destroy(void* indexerPtr) { - Indexer* indexer = (Indexer*)indexerPtr; +DLL_EXPORT void IndexerV1_Destroy(uint32_t* indexerPtr) { + IndexerV1* indexer = (IndexerV1*)indexerPtr; delete indexer; -} \ No newline at end of file +} +#pragma comment(linker, "/EXPORT:IndexerV1_Destroy=_IndexerV1_Destroy@4") diff --git a/Utility/Indexer.h b/Utility/IndexerV1.h similarity index 63% rename from Utility/Indexer.h rename to Utility/IndexerV1.h index 02b562b..3cab83e 100644 --- a/Utility/Indexer.h +++ b/Utility/IndexerV1.h @@ -9,17 +9,10 @@ /** Indexer structure helps with getting unique, unused Indexes (Ids). * Doing this natively would be too slow, so I'm using a DLL for this. */ -struct Indexer { +struct IndexerV1 { uint64_t indexes[67108864]; uint32_t lastAssignedIndex; unsigned int GetFreeIndex(); void MarkFreeIndex(int index); }; - -extern "C" { - DLL_EXPORT void* Indexer_Create(); - DLL_EXPORT int Indexer_GetFreeIndex(void* index); - DLL_EXPORT void Indexer_MarkFreeIndex(void* index, int Index); - DLL_EXPORT void Indexer_Destroy(void* index); -} \ No newline at end of file diff --git a/Utility/IndexerV2.cpp b/Utility/IndexerV2.cpp new file mode 100644 index 0000000..67152b7 --- /dev/null +++ b/Utility/IndexerV2.cpp @@ -0,0 +1,118 @@ +#include "IndexerV2.h" + +IndexerV2::IndexerV2() { + this->range.reserve(32); +} + + +IndexerV2::~IndexerV2() { + this->range.clear(); +} + +uint32_t IndexerV2::GetIndex() { + uint32_t index = 0; + + if (this->range.size() == 0) { + this->range.push_back(IndexerV2Range(0, 0)); + } else { + auto range = this->range[0]; + + if (range.min > 0) { + index = --range.min; + } else { + index = ++range.max; + } + + // Combine the next and current element if we need to. + if (this->range.size() > 1) { + auto rangeNext = this->range[1]; + + if (rangeNext.min == (index + 1)) { + uint32_t newMin, newMax; + newMin = range.min; + newMax = rangeNext.max; + + this->range.erase(this->range.begin(), this->range.begin() + 1); + this->range.insert(this->range.begin(), IndexerV2Range(newMin, newMax)); + } + } + } + + return index; +} + +void IndexerV2::MarkIndex(uint32_t index) { + IndexerV2Range* rangePtr; + uint32_t rangePtrPos; + + uint32_t rangeSize = this->range.size(); + for (uint32_t rangePos = 0; rangePos < rangeSize; rangePos++) { + auto range = this->range[rangePos]; + + if (index >= range.min && index <= range.max) { + rangePtr = ⦥ + rangePtrPos = rangePos; + break; + } + } + + // Temporarily store the values needed for swapping. + uint32_t leftMin, leftMax, rightMin, rightMax; + leftMin = rangePtr->min; leftMax = index - 1; + rightMin = index + 1; rightMax = rangePtr->max; + + // Due to us doing this instead of push_back, our vector is always sorted. + auto rangeIter = this->range.begin() + rangePtrPos; + this->range.erase(rangeIter); + this->range.insert(rangeIter, IndexerV2Range(leftMin, leftMax)); + this->range.insert(rangeIter + 1, IndexerV2Range(rightMin, rightMax)); +} + +bool IndexerV2::IsFree(uint32_t index) { + uint32_t rangeSize = this->range.size(); + for (uint32_t rangePos = 0; rangePos < rangeSize; rangePos++) { + auto range = this->range[rangePos]; + if (index >= range.min && index <= range.max) + return false; + } + return true; +} + +bool IndexerV2::IsUsed(uint32_t index) { + return !IsFree(index); +} + +IndexerV2::IndexerV2Range::IndexerV2Range(uint32_t min, uint32_t max) { + this->min = min; + this->max = max; +} + +DLL_EXPORT void* IndexerV2_Create() { + IndexerV2* indexerPtr = new IndexerV2(); + return indexerPtr; +} +#pragma comment(linker, "/EXPORT:IndexerV2_Create=_IndexerV2_Create@0") + +DLL_EXPORT void IndexerV2_Destroy(uint32_t indexerIntPtr) { + IndexerV2* indexerPtr = (IndexerV2*)indexerIntPtr; + delete indexerPtr; +} +#pragma comment(linker, "/EXPORT:IndexerV2_Destroy=_IndexerV2_Destroy@4") + +DLL_EXPORT uint32_t IndexerV2_GetIndex(uint32_t indexerIntPtr) { + IndexerV2* indexerPtr = (IndexerV2*)indexerIntPtr; + return indexerPtr->GetIndex(); +} +#pragma comment(linker, "/EXPORT:IndexerV2_GetIndex=_IndexerV2_GetIndex@4") + +DLL_EXPORT uint32_t IndexerV2_IsFree(uint32_t indexerIntPtr, uint32_t index) { + IndexerV2* indexerPtr = (IndexerV2*)indexerIntPtr; + return indexerPtr->IsFree(index); +} +#pragma comment(linker, "/EXPORT:IndexerV2_IsFree=_IndexerV2_IsFree@8") + +DLL_EXPORT uint32_t IndexerV2_IsUsed(uint32_t indexerIntPtr, uint32_t index) { + IndexerV2* indexerPtr = (IndexerV2*)indexerIntPtr; + return indexerPtr->IsUsed(index); +} +#pragma comment(linker, "/EXPORT:IndexerV2_IsUsed=_IndexerV2_IsUsed@8") diff --git a/Utility/IndexerV2.h b/Utility/IndexerV2.h new file mode 100644 index 0000000..e15b212 --- /dev/null +++ b/Utility/IndexerV2.h @@ -0,0 +1,24 @@ +#pragma once +#include "dllmain.h" +#include + +class IndexerV2 { + public: + IndexerV2(); + ~IndexerV2(); + + uint32_t GetIndex(); + void MarkIndex(uint32_t index); + + bool IsFree(uint32_t index); + bool IsUsed(uint32_t index); + private: + struct IndexerV2Range { + uint32_t min, max; + + IndexerV2Range(uint32_t pmin, uint32_t pmax); + }; + + std::vector range; +}; + diff --git a/Utility/WindowMessageHandler.h b/Utility/WindowMessageHandler.h index 36b3480..8252c50 100644 --- a/Utility/WindowMessageHandler.h +++ b/Utility/WindowMessageHandler.h @@ -21,11 +21,5 @@ void WindowMessageHandler_OnProcessAttach(); void WindowMessageHandler_OnProcessDetach(); LRESULT CALLBACK WindowMessageHandler_Procedure(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); - -extern "C" { - DLL_EXPORT void WindowMessageHandler_Install(HWND hwnd); - DLL_EXPORT void WindowMessageHandler_Uninstall(HWND hwnd); - DLL_EXPORT int WindowMessageHandler_Message_Resize(HWND hwnd, LPPOINT point); - DLL_EXPORT int WindowMessageHandler_Message_Destroy(HWND hwnd); - DLL_EXPORT int WindowMessageHandler_Message_Close(HWND hwnd); -} \ No newline at end of file +DLL_EXPORT void WindowMessageHandler_Install(HWND hwnd); +DLL_EXPORT void WindowMessageHandler_Uninstall(HWND hwnd); \ No newline at end of file diff --git a/dllmain.cpp b/dllmain.cpp index 95ec954..509c082 100644 --- a/dllmain.cpp +++ b/dllmain.cpp @@ -1,4 +1,3 @@ -#pragma once #include "dllmain.h" #include @@ -8,7 +7,7 @@ #include "Math\Vector3.h" #include "Math\Matrix3.h" #include "Utility\Display.h" -#include "Utility\Indexer.h" +#include "Utility\IndexerV1.h" #include "Utility\WindowMessageHandler.h" bool WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { diff --git a/dllmain.h b/dllmain.h index 6b340d7..e789929 100644 --- a/dllmain.h +++ b/dllmain.h @@ -1,3 +1,5 @@ +#pragma once + // STL Exceptions #include #include @@ -9,4 +11,4 @@ #include // Macros -#define DLL_EXPORT extern "C" __declspec(dllexport) \ No newline at end of file +#define DLL_EXPORT extern "C" //__declspec(dllexport) \ No newline at end of file