-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added in basic scripting features to Dolphin #12084
base: master
Are you sure you want to change the base?
Added in basic scripting features to Dolphin #12084
Conversation
9d856f9
to
823ef26
Compare
@phire , @AdmiralCurtiss , @Pokechu22 , @JosJuice , @Hibyehello , @lioncash This is a simplified version of my original large PR from here: #11540 This branch is ready to be tested/merged right now. It designs+implements the APIs for the scripting DLLs to interact with Dolphin, creates the helper classes that are used by scripts, contains the code to handle running script callbacks (ex. OnInstructionHitCallbacks), and contains the code to initialize scripts from a DLL. Additionally, it also contains the Script Manager Window in order to start running scripts. |
205c18d
to
37fc3e8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, guess this ended up being a mostly code-style based review for now.
Theres a whole lot going on, and I think I need to do another pass with a clear head for the nitty-gritty parts.
Some things look odd at first glance, and might make more sense in the big picture, so I tried to not point out all of them here (and, tbf., I stopped looking at the other PR at some point because it just went waaaay out of hand in the number of changes - but for a feature that size, I suppose thats expected)
Source/Core/Core/Scripting/HelperClasses/GCButton_API_Implementations.cpp
Outdated
Show resolved
Hide resolved
Source/Core/Core/Scripting/HelperClasses/GCButton_API_Implementations.cpp
Show resolved
Hide resolved
Source/Core/Core/Scripting/HelperClasses/InstructionBreakpointsHolder.cpp
Outdated
Show resolved
Hide resolved
Source/Core/Core/Scripting/HelperClasses/MemoryAddressBreakpointsHolder.cpp
Outdated
Show resolved
Hide resolved
aae4bb1
to
25ccc70
Compare
@BhaaLseN I cut out the EventCallbackRegistration directory entirely, removed EmuAPI, removed most references to Scripts from outside of the Script directory, and replaced some of the functions in ScriptUtilities.cpp with TODOs in order to cut down on the amount of code in this PR. This has resulted in the PR going from about 7,800 changed lines to about 4,800 changed lines. I'm hopeful that this will make reviewing the PR a bit more manageable. |
It certainly helps, but wasn't my intention to have you cut things out; i mainly meant that I need another pass over it once I cleared my head. Which is hopefully this weekend, but no promises. |
25ccc70
to
1d6f0a3
Compare
It's all good. I was planning to make the PR smaller anyways. @BhaaLseN Btw, I finished making all of the changes you suggested. |
Source/Core/Core/Scripting/HelperClasses/FileUtility_API_Implementations.cpp
Outdated
Show resolved
Hide resolved
Source/Core/Core/Scripting/HelperClasses/FileUtility_API_Implementations.h
Outdated
Show resolved
Hide resolved
void* (*CreateBoolArgHolder)(int); | ||
|
||
// Creates + returns an unsigned_8 ArgHolder* with the specified value. | ||
void* (*CreateU8ArgHolder)(unsigned long long); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe just use uint64_t, etc for the relevant functions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For all of the function pointers which are going to be passed across the DLL boundary (such as this one), I tried to make all integer types in the signature/parameters either unsigned char, signed char, unsigned long long, and signed long long. This way, I could be sure that the data I'm passing would be either 1 byte or the maximum bytesize for the system (realistically, 8 bytes for any computer running Dolphin).
Also, I want to make sure that the type exists in plain C, which is why I tried to avoid including other types (ex. I return ints from functions instead of bool, since C doesn't have a bool type).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry to necro but one thing is that using variable length types I think causes annoying ABI concerns (especially across languages that may not have ULL as an inbuilt type), While ULL (unsigned long long
) is guaranteed to be 64 bits or larger, this makes things incompatible if Dolphin is rebuilt and ULL changes.
And realistically if something doesn't have uint64_t
, it's already a super esoteric implementation of C in the first place.
void* (*CreateBytesArgHolder)(); | ||
|
||
// Takes a std::vector<s16> ArgHolder* as input, and returns the number of bytes in the list. | ||
unsigned long long (*GetSizeOfBytesArgHolder)(void*); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unsigned long long (*GetSizeOfBytesArgHolder)(void*); | |
size_t (*GetSizeOfBytesArgHolder)(void*); |
796df75
to
3eaa045
Compare
@lioncash I added in all of the fixes you suggested, and marked them as resolved. The only 2 changes I didn't do were the ones in ArgHolder_APIs.h, since I want to keep those functions C-compatible. |
03f2389
to
de51495
Compare
de51495
to
ab78787
Compare
I updated the PR to make it even shorter, so that it would be easier to read. I also added 2 new README type files inside of the Source/Core/Core/Scripting folder: ScriptingPlugins_Documentation.md describes how to create a new ScriptingPlugin (to add in support for a new Scripting language), and describes what functions a DLL need to export/implement. It also describes the general process for adding in a new scripting language. Common_Scripting_Functions_Documentation.md describes what the purpose is behind each file in this PR. Both of these files are about 200 lines, so I'm hoping that this short documentation will make it easier to read+understand the components of this PR (which will hopefully lead to this PR being merged). @phire , @Pokechu22 , @AdmiralCurtiss , @Hibyehello , @lioncash , @BhaaLseN , @JosJuice , @CasualPokePlayer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just skimmed over this; and I generally prefer identifiers
to be marked up (or rather, down, using single backticks `); but I also see that this might be quite the effort, so I won't insist on getting that done to the two markdown files.
|
||
bool InstructionBreakpointsHolder::ContainsBreakpoint(unsigned int addr) const | ||
{ | ||
return (std::count(breakpoint_addresses.begin(), breakpoint_addresses.end(), addr) > 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this is better suited as a std::unordered_set
(or std::set
) so we can just use the contains
method that was added with C++20...unless we still have platforms that don't properly support C++20. At least you wouldn't have to worry about duplicates either that way, and it could clean up removal since you can just pass in the value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
C++20 should be fine nowadays.
/ (D) | ||
|
||
----PluginSources (D) | ||
|
||
--------Lua (D) | ||
|
||
------------extensions.txt (F) | ||
|
||
------------Source (D) | ||
|
||
----------------CoreScriptInterface (D) | ||
|
||
----------------<The source code for the DLL> (Multiple files and or directories). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems difficult to read, how about making this a code block instead?
/ (D) | |
----PluginSources (D) | |
--------Lua (D) | |
------------extensions.txt (F) | |
------------Source (D) | |
----------------CoreScriptInterface (D) | |
----------------<The source code for the DLL> (Multiple files and or directories). | |
[/] | |
+- [PluginSources] | |
+- [Lua] | |
+- extensions.txt | |
+- [Source] | |
+- [CoreScriptInterface] | |
+- <The source code for the DLL> (Multiple files and or directories). |
Not really feeling that one either, but maybe we can come up with something more readable together.
Any Update for this PR? Lua Support / a art of scripting would be really nice ... |
Basically, the only person with both the time and scripting knowledge/experience to review this MR would be @phire However, Phire hasn't been online for the last 6 or so months, so it's unclear when this MR will be reviewed+approved. |
Is there a full build with python that I can mess around with somewhere? |
Yes. You can use this project code: https://github.com/Lobsterzelda/lobster-zelda-dolphin/tree/lua-support |
Any update on this? It would be a shame if this never got merged because a single Dolphin developer isn't active enough to look at it... |
This PR adds in basic scripting features to Dolphin.
It removes a lot of the features in my original scripting branch PR, in order to make the code easier to review (which will be added back in in future PRs).