Skip to content

Commit

Permalink
Update plugin docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Feb 23, 2024
1 parent e23d2a7 commit d867860
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 39 deletions.
48 changes: 21 additions & 27 deletions DocGen/source/tutorials/plugins/plugin-cpp.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,33 @@ main.h

struct __attribute__((__packed__)) TSimbaMethods
{
void (*RunOnMainThread)(void(*Method)(void*), void* data);
void (*RunOnMainThread)(void(*TMainThreadMethod)(void*), void* data);
void* (*GetMem)(std::size_t size);
void (*FreeMem)(void* ptr);
void* (*AllocMem)(std::size_t size);
void* (*ReAllocMem)(void** ptr, std::size_t size);
std::size_t (*MemSize)(void* ptr);

void* (*GetMem)(NativeUInt size);
void (*FreeMem)(void* ptr);
void* (*AllocMem)(NativeUInt Size);
void* (*ReAllocMem)(void** ptr, NativeUInt size);
NativeUInt (*MemSize)(void* ptr);
void(*RaiseException)(const char* message);

void (*RaiseException)(char* Message);
void* (*GetTypeInfo)(void* Compiler, char* Typ);
NativeUInt (*GetTypeInfoSize)(void* TypeInfo);
NativeInt (*GetTypeInfoFieldOffset)(void* TypeInfo, char* FieldName);
void* (*GetTypeInfo)(void* Compiler, const char* Type);
void* (*GetTypeInfoSize)(void* TypeInfo);
std::size_t (*GetTypeInfoFieldOffset)(void* TypeInfo, const char* FieldName);

void* (*AllocateRawArray)(NativeInt ElementSize, NativeUInt Len);
void (*ReAllocateRawArray)(void** ptr, NativeInt ElementSize, NativeUInt Len);
void* (*AllocateRawArray)(std::size_t element_size, std::size_t length);
void (*ReAllocateRawArray)(void** array, std::size_t element_size, std::size_t new_length);

void* (*AllocateArray)(void* TypeInfo, NativeUInt Len);
void* (*AllocateString)(void* Data);
void* (*AllocateUnicodeString)(void* Data);

void (*SetArrayLength)(void* TypeInfo, void**ptr, NativeInt NewLen);
NativeInt (*GetArrayLength)(void* AVar);
void* (*AllocateArray)(void* TypeInfo, std::size_t length);
void* (*AllocateString)(const char* data);
void* (*AllocateUnicodeString)(const wchar_t* data);
void (*SetArrayLength)(void* TypeInfo, void** var, std::size_t new_len);
std::size_t (*GetArrayLength)(void* array);

void* (*ExternalImage_Create)(bool FreeOnTerminate);
void (*ExternalImage_SetMemory)(void* img, void* data, int width, int height);
bool (*ExternalImage_TryLock)(void* img);
void (*ExternalImage_Lock)(void* img);
void (*ExternalImage_UnLock)(void* img);

void (*ExternalImage_AddCallbackOnUnlock)(void* img, void(*callback)(void*)(void*));
void (*ExternalImage_RemoveCallbackOnUnlock)(void* img, void(*callback)(void*)(void*));

void (*ExternalImage_SetUserData)(void* img, void* USerData);
void (*ExternalImage_SetMemory)(void* img, void* bgra_data, std::int32_t width, std::int32_t height);
void (*ExternalImage_Resize)(void* img, std::int32_t new_width, std::int32_t new_height);
void (*ExternalImage_SetUserData)(void* img, void* userdata);
void* (*ExternalImage_GetUserData)(void* img);
};

Expand Down
7 changes: 3 additions & 4 deletions DocGen/source/tutorials/plugins/plugin-target.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ Will load :code:`myplugin.dll` expecting these exports:
SimbaPluginTarget_GetImageData: function(Target: Pointer; X, Y, Width, Height: Int32; var Data: PColorBGRA; var DataWidth: Int32): Boolean; cdecl;
SimbaPluginTarget_MousePressed: function(Target: Pointer; Button: Int32): Boolean; cdecl;
SimbaPluginTarget_MousePosition: function(Target: Pointer): TPoint; cdecl;
SimbaPluginTarget_MouseTeleport: procedure(Target: Pointer; P: TPoint); cdecl;
SimbaPluginTarget_MousePosition: procedure(Target: Pointer; out X, Y: Integer); cdecl;
SimbaPluginTarget_MouseTeleport: procedure(Target: Pointer; X, Y: Int32); cdecl;
SimbaPluginTarget_MouseUp: procedure(Target: Pointer; Button: Int32); cdecl;
SimbaPluginTarget_MouseDown: procedure(Target: Pointer; Button: Int32); cdecl;
SimbaPluginTarget_MouseScroll: procedure(Target: Pointer; Scrolls: Int32); cdecl;
Expand All @@ -38,7 +38,7 @@ KeySend

The plugins KeySend is responsible for holding down modifiers (such as shift).

:code:`SleepTimes` is a Int32 array which is graciously overallocated :code:`(TextLen*5)` of sleep times which should be performed after every keydown/keyrelease which is used to control the speed of typing.
:code:`SleepTimes` is a Int32 array which is graciously overallocated :code:`(TextLen*4)` of sleep times which should be performed after every keydown/keyrelease which is used to control the speed of typing.

Something like:

Expand All @@ -62,7 +62,6 @@ Something like:
ReleaseTheKey();
DoSleep();
end;
end;
.. note::
Expand Down
12 changes: 4 additions & 8 deletions DocGen/source/tutorials/plugins/writing-plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,13 @@ These pointers are provided to these structures:
ExternalImage_Create: function(FreeOnTerminate: Boolean): Pointer; cdecl;
ExternalImage_SetMemory: procedure(Img: Pointer; Data: PColorBGRA; AWidth, AHeight: Integer); cdecl;
ExternalImage_TryLock: function(Img: Pointer): Boolean; cdecl;
ExternalImage_Lock: procedure(Img: Pointer); cdecl;
ExternalImage_UnLock: procedure(Img: Pointer); cdecl;
ExternalImage_AddCallbackOnUnlock: procedure(Img: Pointer; Callback: TSimbaExternalImageCallback); cdecl;
ExternalImage_RemoveCallbackOnUnlock: procedure(Img: Pointer; Callback: TSimbaExternalImageCallback); cdecl;
ExternalImage_Resize: procedure(Img: Pointer; NewWidth, NewHeight: Integer); cdecl;
ExternalImage_SetUserData: procedure(Img: Pointer; UserData: Pointer); cdecl;
ExternalImage_GetUserData: function(Img: Pointer): Pointer; cdecl;
end;
See the `Example C++ plugin <plugin-cpp.html>`_ to see how TypeInfo is used to allocate custom records & arrays.

.. note::

`RunOnMainThread` is available for creating forms, installing windows hooks and other things that must be done on the main thread.
Simba scripts are not ran on the processes main thread for this reason.
Scripts are not ran on the process main thread so `RunOnMainThread` is available for creating forms, installing windows hooks that must be executed on the main thread.

0 comments on commit d867860

Please sign in to comment.