Commit e6ffeef8 authored by Linshizhi's avatar Linshizhi

Add Loader.

parent 2f8f5881
...@@ -146,12 +146,12 @@ blink_core_sources_bindings = ...@@ -146,12 +146,12 @@ blink_core_sources_bindings =
"core/v8/v8_idle_task_runner.h", "core/v8/v8_idle_task_runner.h",
"core/v8/v8_initializer.cc", "core/v8/v8_initializer.cc",
"core/v8/v8_initializer.h", "core/v8/v8_initializer.h",
"core/v8/v8_initializer_custom.cc", # "core/v8/v8_initializer_custom.cc",
"core/v8/v8_initializer_custom.h", # "core/v8/v8_initializer_custom.h",
"core/v8/nativeBox.h", # "core/v8/nativeBox.h",
"core/v8/nativeBox.cc", # "core/v8/nativeBox.cc",
"extensions/loadablemodule/src/Loadable.cc", # "extensions/loadablemodule/src/Loadable.cc",
"extensions/loadablemodule/src/Loadable.h", # "extensions/loadablemodule/src/Loadable.h",
"core/v8/v8_intersection_observer_delegate.cc", "core/v8/v8_intersection_observer_delegate.cc",
"core/v8/v8_intersection_observer_delegate.h", "core/v8/v8_intersection_observer_delegate.h",
"core/v8/v8_iterator_result_value.cc", "core/v8/v8_iterator_result_value.cc",
......
#include "nativeBox.h"
#include <dlfcn.h>
#include "third_party/blink/renderer/bindings/extensions/loadablemodule/src/Loadable.h"
#include "v8/include/v8.h"
using v8::Local;
using v8::Value;
using v8::String;
static void LoadeModule(const v8::FunctionCallbackInfo<v8::Value> &args) {
if (args.Length() < 1) return;
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
Local<Value> arg = args[0];
String::Utf8Value moduleName(isolate, arg);
void *symbols = dlopen("liblms.so", RTLD_LAZY);
if (!symbols) {
std::cout << "No Module found" << std::endl;
return;
}
Loadable::LoadableModule *(*load)(std::string);
load = (Loadable::LoadableModule*(*)(std::string))dlsym(symbols, "load");
Loadable::LoadableModule *module = load("MP4Encoder");
NativeBox box {module};
args.GetReturnValue().Set(box.ToObject(isolate));
}
static void Apply(const v8::FunctionCallbackInfo<v8::Value> &args) {
}
static void Done(const v8::FunctionCallbackInfo<v8::Value> &args) {
}
#include "v8/include/v8.h"
#ifndef LOADER_H
#define LOADER_H
static void LoadeModule(const v8::FunctionCallbackInfo<v8::Value> &args);
static void Apply(const v8::FunctionCallbackInfo<v8::Value> &args);
static void Done(const v8::FunctionCallbackInfo<v8::Value> &args);
#endif /* LOADER_H */
...@@ -23,6 +23,8 @@ using v8::Local; ...@@ -23,6 +23,8 @@ using v8::Local;
// Anonymous which contains all transform functions // Anonymous which contains all transform functions
namespace { namespace {
vector<>
typedef void (*V8_Builtin)(const v8::FunctionCallbackInfo<v8::Value>& args); typedef void (*V8_Builtin)(const v8::FunctionCallbackInfo<v8::Value>& args);
V8_Builtin wrapWithTransformLayer(Loadable::Callback callback, V8_Builtin wrapWithTransformLayer(Loadable::Callback callback,
......
#include <string> #include <string>
#include <iostream> #include <iostream>
#include "nativeBox.h"
#include "v8/include/v8.h" #include "v8/include/v8.h"
#include "v8/include/v8-template.h" #include "v8/include/v8-template.h"
#include "v8/include/v8-context.h" #include "v8/include/v8-context.h"
#include "v8/include/v8-object.h" #include "v8/include/v8-object.h"
#include "v8/include/v8-primitive.h" #include "v8/include/v8-primitive.h"
#include "loader.h"
#include "third_party/blink/renderer/bindings/extensions/loadablemodule/src/Loadable.h"
#include <dlfcn.h>
using v8::Local; using v8::Local;
using v8::ObjectTemplate; using v8::ObjectTemplate;
...@@ -20,32 +17,6 @@ using v8::Value; ...@@ -20,32 +17,6 @@ using v8::Value;
using v8::Maybe; using v8::Maybe;
using v8::String; using v8::String;
static void LoadeModule(const v8::FunctionCallbackInfo<v8::Value>& args) {
if (args.Length() < 1) return;;
v8::Isolate* isolate = args.GetIsolate();
v8::HandleScope scope(isolate);
Local<Value> arg = args[0];
String::Utf8Value moduleName(isolate, arg);
void *symbols = dlopen("liblms.so", RTLD_LAZY);
if (!symbols) {
std::cout << "No Module found" << std::endl;
return;
}
Loadable::LoadableModule *(*load)(std::string);
load = (Loadable::LoadableModule*(*)(std::string))dlsym(symbols, "load");
Loadable::LoadableModule *module = load("MP4Encoder");
NativeBox box {module};
args.GetReturnValue().Set(box.ToObject(isolate));
}
void PostInitializeV8(v8::Isolate* isolate) { void PostInitializeV8(v8::Isolate* isolate) {
Local<Context> context = isolate->GetCurrentContext(); Local<Context> context = isolate->GetCurrentContext();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment