Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(640)

Unified Diff: sky/engine/bindings-dart/core/dart/DartJsInteropData.cpp

Issue 875013003: Import Dart bindings as of Blink r188698. This merely copies the files over and does not attach any… (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/engine/bindings-dart/core/dart/DartJsInteropData.cpp
diff --git a/sky/engine/bindings/core/v8/ScriptString.cpp b/sky/engine/bindings-dart/core/dart/DartJsInteropData.cpp
similarity index 53%
copy from sky/engine/bindings/core/v8/ScriptString.cpp
copy to sky/engine/bindings-dart/core/dart/DartJsInteropData.cpp
index 845be34d17dbacccf2c692f78dbb8089ea812a2b..ddad8454cfe4cbfd15fe5a12e62484bead3e6e8b 100644
--- a/sky/engine/bindings/core/v8/ScriptString.cpp
+++ b/sky/engine/bindings-dart/core/dart/DartJsInteropData.cpp
@@ -27,57 +27,50 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#include "config.h"
-#include "sky/engine/config.h"
-#include "sky/engine/bindings/core/v8/ScriptString.h"
+#include "bindings/core/dart/DartJsInteropData.h"
-#include "sky/engine/bindings/core/v8/V8Binding.h"
+#include <string.h>
namespace blink {
-ScriptString::ScriptString()
- : m_isolate(0)
+v8::Local<v8::Function> DartJsInteropData::cacheFunction(v8::Persistent<v8::Function>* cache, const char* scriptSrc)
{
-}
-
-ScriptString::ScriptString(v8::Isolate* isolate, v8::Handle<v8::String> string)
- : m_isolate(isolate)
- , m_string(SharedPersistent<v8::String>::create(string, m_isolate))
-{
-}
-
-ScriptString& ScriptString::operator=(const ScriptString& string)
-{
- if (this != &string) {
- m_isolate = string.m_isolate;
- m_string = string.m_string;
+ v8::Isolate* v8Isolate = v8::Isolate::GetCurrent();
+ if (cache->IsEmpty()) {
+ v8::Local<v8::Function> localFunction = v8::Local<v8::Function>::Cast(v8::Script::Compile(v8::String::NewFromUtf8(v8Isolate, scriptSrc))->Run());
+ cache->Reset(v8Isolate, localFunction);
+ return localFunction;
}
- return *this;
+ return v8::Local<v8::Function>::New(v8Isolate, *cache);
}
-v8::Handle<v8::String> ScriptString::v8Value()
+v8::Local<v8::Function> DartJsInteropData::captureThisFunction()
{
- if (isEmpty())
- return v8::Handle<v8::String>();
- return m_string->newLocal(isolate());
+ const char* scriptSrc = "(function () {"
+ " var func = this;"
+ " return function () {"
+ " return func(this, Array.prototype.slice.apply(arguments));"
+ " };"
+ "})";
+ return cacheFunction(&m_captureThisFunction, scriptSrc);
}
-ScriptString ScriptString::concatenateWith(const String& string)
+v8::Local<v8::Function> DartJsInteropData::wrapDartFunction()
{
- v8::Isolate* nonNullIsolate = isolate();
- v8::HandleScope handleScope(nonNullIsolate);
- v8::Handle<v8::String> targetString = v8String(nonNullIsolate, string);
- if (isEmpty())
- return ScriptString(nonNullIsolate, targetString);
- return ScriptString(nonNullIsolate, v8::String::Concat(v8Value(), targetString));
+ const char* scriptSrc = "(function () {"
+ " var func = this;"
+ " return function () {"
+ " return func(Array.prototype.slice.apply(arguments));"
+ " };"
+ "})";
+ return cacheFunction(&m_wrapDartFunction, scriptSrc);
}
-String ScriptString::flattenToString()
+v8::Local<v8::Function> DartJsInteropData::instanceofFunction()
{
- if (isEmpty())
- return String();
- v8::HandleScope handleScope(isolate());
- return v8StringToWebCoreString<String>(v8Value(), Externalize);
+ return cacheFunction(&m_instanceofFunction, "(function (type) { return this instanceof type; })");
}
-} // namespace blink
+}
« no previous file with comments | « sky/engine/bindings-dart/core/dart/DartJsInteropData.h ('k') | sky/engine/bindings-dart/core/dart/DartLibraryIds.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698