| Index: sky/engine/bindings-dart/core/dart/shared_lib/DartNativeExtensionsPosix.cpp
|
| diff --git a/sky/engine/core/html/imports/HTMLImportState.h b/sky/engine/bindings-dart/core/dart/shared_lib/DartNativeExtensionsPosix.cpp
|
| similarity index 53%
|
| copy from sky/engine/core/html/imports/HTMLImportState.h
|
| copy to sky/engine/bindings-dart/core/dart/shared_lib/DartNativeExtensionsPosix.cpp
|
| index 66e9bcc4cf6fa8fc9936e9f990e6ed36b534bc94..9cc1e4c28385daa2e054da55f7215c901f2f109f 100644
|
| --- a/sky/engine/core/html/imports/HTMLImportState.h
|
| +++ b/sky/engine/bindings-dart/core/dart/shared_lib/DartNativeExtensionsPosix.cpp
|
| @@ -28,50 +28,53 @@
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
|
|
| -#ifndef SKY_ENGINE_CORE_HTML_IMPORTS_HTMLIMPORTSTATE_H_
|
| -#define SKY_ENGINE_CORE_HTML_IMPORTS_HTMLIMPORTSTATE_H_
|
| +#include "config.h"
|
| +#include "bindings/core/dart/shared_lib/DartNativeExtensions.h"
|
|
|
| -#include "sky/engine/wtf/Assertions.h"
|
| +#if defined(ENABLE_DART_NATIVE_EXTENSIONS)
|
| +#if OS(POSIX)
|
| +#include "wtf/text/StringUTF8Adaptor.h"
|
| +#include <dlfcn.h>
|
| +#include <string>
|
|
|
| -namespace blink {
|
| -
|
| -class HTMLImportState {
|
| -public:
|
| - enum Value {
|
| - BlockingScriptExecution = 0,
|
| - Active,
|
| - Ready,
|
| - Invalid
|
| - };
|
|
|
| - explicit HTMLImportState(Value value = BlockingScriptExecution)
|
| - : m_value(value)
|
| - { }
|
| -
|
| - bool shouldBlockScriptExecution() const { return checkedValue() <= BlockingScriptExecution; }
|
| - bool isReady() const { return checkedValue() == Ready; }
|
| - bool isValid() const { return m_value != Invalid; }
|
| - bool operator==(const HTMLImportState& other) const { return m_value == other.m_value; }
|
| - bool operator!=(const HTMLImportState& other) const { return !(*this == other); }
|
| - bool operator<=(const HTMLImportState& other) const { return m_value <= other.m_value; }
|
| +namespace blink {
|
|
|
| -#if !defined(NDEBUG)
|
| - Value peekValueForDebug() const { return m_value; }
|
| +Dart_Handle DartNativeExtensions::loadExtensionLibrary(const String& libraryPath, const String& libraryName, void** libraryHandle)
|
| +{
|
| + String libraryFile = libraryPath;
|
| +#if OS(MACOSX)
|
| + libraryFile.append("lib");
|
| + libraryFile.append(libraryName);
|
| + libraryFile.append(".dylib");
|
| +#else
|
| + libraryFile.append("lib");
|
| + libraryFile.append(libraryName);
|
| + libraryFile.append(".so");
|
| #endif
|
| + StringUTF8Adaptor utf8LibraryFile(libraryFile);
|
| + std::string utf8LibraryFileStr(utf8LibraryFile.data(), utf8LibraryFile.length());
|
| + *libraryHandle = dlopen(utf8LibraryFileStr.c_str(), RTLD_LAZY);
|
| + if (!*libraryHandle) {
|
| + return Dart_NewApiError(dlerror());
|
| + }
|
| + return Dart_Null();
|
| +}
|
|
|
| - static HTMLImportState invalidState() { return HTMLImportState(Invalid); }
|
| - static HTMLImportState blockedState() { return HTMLImportState(BlockingScriptExecution); }
|
| -private:
|
| - Value checkedValue() const;
|
| - Value m_value;
|
| -};
|
| -
|
| -inline HTMLImportState::Value HTMLImportState::checkedValue() const
|
| +Dart_Handle DartNativeExtensions::resolveSymbol(void* libHandle, const String& symbolName, void** symbol)
|
| {
|
| - ASSERT(isValid());
|
| - return m_value;
|
| + StringUTF8Adaptor utf8Symbol(symbolName);
|
| + std::string utf8SymbolStr(utf8Symbol.data(), utf8Symbol.length());
|
| + dlerror();
|
| + *symbol = dlsym(libHandle, utf8SymbolStr.c_str());
|
| + const char* error = dlerror();
|
| + if (error) {
|
| + return Dart_NewApiError(error);
|
| + }
|
| + return Dart_Null();
|
| }
|
|
|
| }
|
|
|
| -#endif // SKY_ENGINE_CORE_HTML_IMPORTS_HTMLIMPORTSTATE_H_
|
| +#endif // OS(POSIX)
|
| +#endif // defined(ENABLE_DART_NATIVE_EXTENSIONS)
|
|
|