Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: compiled/bindings/runtime_utils.cpp

Issue 29410617: Issue 5131 - [emscripten] Clean separation of bindings code and runtime code (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore
Patch Set: Created April 12, 2017, 2:07 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« compiled/bindings/generator.cpp ('K') | « compiled/bindings/main.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiled/bindings/runtime_utils.cpp
===================================================================
new file mode 100644
--- /dev/null
+++ b/compiled/bindings/runtime_utils.cpp
@@ -0,0 +1,39 @@
+#include <emscripten.h>
+
+#include "../intrusive_ptr.h"
+#include "../String.h"
+
+extern "C"
+{
+ void EMSCRIPTEN_KEEPALIVE InitString(DependentString* str,
+ String::value_type* data, String::size_type len)
+ {
+ // String is already allocated on stack, we merely need to call
+ // constructor.
+ new (str) DependentString(data, len);
+ }
+
+ void EMSCRIPTEN_KEEPALIVE DestroyString(OwnedString* str)
+ {
+ // Stack memory will be freed automatically, we need to call
+ // destructor explicitly however.
+ str->~OwnedString();
+ }
+
+ String::size_type EMSCRIPTEN_KEEPALIVE GetStringLength(
+ const String& str)
+ {
+ return str.length();
+ }
+
+ const String::value_type* EMSCRIPTEN_KEEPALIVE GetStringData(
+ const String& str)
+ {
+ return str.data();
+ }
+
+ void EMSCRIPTEN_KEEPALIVE ReleaseRef(ref_counted* ptr)
+ {
+ ptr->ReleaseRef();
+ }
+}
« compiled/bindings/generator.cpp ('K') | « compiled/bindings/main.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld