Skip to content

Commit

Permalink
Add pluginInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
dedmen committed Dec 19, 2017
1 parent 7236dff commit 492c135
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 5 deletions.
2 changes: 1 addition & 1 deletion intercept
Submodule intercept updated 38 files
+20 −20 rv/addons/core/boot.sqf
+1 −1 rv/addons/core/config.cpp
+5 −4 rv/addons/core/initFunctionsWrapper.sqf
+9 −9 rv/addons/core/lib.sqf
+4 −4 src/Intercept.natvis
+82 −2 src/client/headers/client/eventhandlers.hpp
+4 −4 src/client/headers/client/pointers.hpp
+2 −0 src/client/headers/client/sqf/core.hpp
+3 −2 src/client/headers/intercept.hpp
+1,307 −0 src/client/headers/shared/containers.hpp
+107 −1,293 src/client/headers/shared/types.hpp
+2 −2 src/client/headers/shared/vector.hpp
+5 −3 src/client/intercept/client/client.cpp
+86 −4 src/client/intercept/client/eventhandlers.cpp
+14 −5 src/client/intercept/client/sqf/core.cpp
+1 −1 src/client/intercept/client/sqf/ctrl.cpp
+2 −2 src/client/intercept/client/sqf/curator.cpp
+1 −1 src/client/intercept/client/sqf/deprecated.cpp
+6 −6 src/client/intercept/client/sqf/position.cpp
+3 −3 src/client/intercept/client/sqf/units.cpp
+0 −1 src/client/intercept/client/sqf/world.cpp
+3 −3 src/client/intercept/shared/client_types.cpp
+125 −0 src/client/intercept/shared/containers.cpp
+83 −171 src/client/intercept/shared/types.cpp
+4 −4 src/host/common/shared.hpp
+2 −2 src/host/controller/controller.cpp
+1 −1 src/host/controller/controller.hpp
+6 −3 src/host/extensions/extensions.cpp
+1 −0 src/host/extensions/extensions.hpp
+1 −1 src/host/extensions/signing.cpp
+25 −20 src/host/intercept_dll/intercept_dll.cpp
+55 −51 src/host/invoker/eventhandlers.cpp
+1 −0 src/host/invoker/eventhandlers.hpp
+16 −4 src/host/invoker/invoker.cpp
+3 −3 src/host/invoker/invoker.hpp
+4 −5 src/host/invoker/sqf_functions.cpp
+1 −1 src/host/loader/CMakeLists.txt
+36 −36 src/host/loader/loader.cpp
1 change: 1 addition & 0 deletions src/ArmaScriptProfiler.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
<ClCompile Include="..\intercept\src\client\intercept\client\sqf\waypoint.cpp" />
<ClCompile Include="..\intercept\src\client\intercept\client\sqf\world.cpp" />
<ClCompile Include="..\intercept\src\client\intercept\shared\client_types.cpp" />
<ClCompile Include="..\intercept\src\client\intercept\shared\containers.cpp" />
<ClCompile Include="..\intercept\src\client\intercept\shared\types.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="scriptProfiler.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions src/ArmaScriptProfiler.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,8 @@
<ClCompile Include="main.cpp">
<Filter>Quelldateien</Filter>
</ClCompile>
<ClCompile Include="..\intercept\src\client\intercept\shared\containers.cpp">
<Filter>intercept_client\shared</Filter>
</ClCompile>
</ItemGroup>
</Project>
4 changes: 4 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ int __cdecl intercept::api_version() {
// return true;
//}

void intercept::register_interfaces() {
profiler.registerInterfaces();
}

void __cdecl intercept::pre_start() {
profiler.preStart();
}
Expand Down
29 changes: 26 additions & 3 deletions src/scriptProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ game_data* createGameDataProfileScope(param_archive* ar) {
return x;
}





game_value createProfileScope(uintptr_t, game_value_parameter name) {
if (sqf::can_suspend()) return {};
auto data = std::make_shared<GameDataProfileScope::scopeData>(name, std::chrono::high_resolution_clock::now(), profiler.startNewScope());
Expand Down Expand Up @@ -246,13 +250,13 @@ void scriptProfiler::endScope(uint64_t scopeID, intercept::types::r_string&& nam
}

void scriptProfiler::addLog(intercept::types::r_string msg) {
auto newLog = std::make_shared<profileLog>(msg);
auto newLog = std::make_shared<profileLog>(std::move(msg));
if (currentScope) {
currentScope->subelements.emplace_back(std::move(newLog));
newLog->parent = currentScope;
currentScope->subelements.emplace_back(std::move(newLog));
//currentScope->runtime -= chrono::microseconds(1.5); //try to compensate the calltime for log command
} else {
frames[currentFrame].elements.push_back(std::move(newLog));
frames[currentFrame].elements.emplace_back(std::move(newLog));
}
}

Expand Down Expand Up @@ -385,3 +389,22 @@ void scriptProfiler::capture() {
}
waitingForCapture = false;
}




class ArmaScriptProfiler_ProfInterface {
public:
virtual game_value createScope(r_string name) {
auto data = std::make_shared<GameDataProfileScope::scopeData>(name, std::chrono::high_resolution_clock::now(), profiler.startNewScope());

return game_value(new GameDataProfileScope(std::move(data)));
}
};

static ArmaScriptProfiler_ProfInterface profIface;


void scriptProfiler::registerInterfaces() {
client::host::register_plugin_interface("ArmaScriptProfilerProfIFace"sv, 1, &profIface);
}
3 changes: 2 additions & 1 deletion src/scriptProfiler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class profileScope : public profileElement {

class profileLog : public profileElement {
public:
explicit profileLog(intercept::types::r_string _message) : profileElement(profileElementType::log), message(_message) {}
explicit profileLog(intercept::types::r_string&& _message) : profileElement(profileElementType::log), message(_message) {}
~profileLog() override {};
intercept::types::r_string getAsString() override { return message; }
chrono::microseconds getRunTime() override { return chrono::microseconds(0); }
Expand Down Expand Up @@ -76,6 +76,7 @@ class scriptProfiler {
chrono::milliseconds totalScriptRuntime();
bool shouldCapture();
void capture();
void registerInterfaces();


std::vector<frameData> frames;
Expand Down

0 comments on commit 492c135

Please sign in to comment.