1// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_BIN_EXTENSIONS_H_
6#define RUNTIME_BIN_EXTENSIONS_H_
7
8#include "include/dart_api.h"
9#include "platform/globals.h"
10
11namespace dart {
12namespace bin {
13
14class Extensions {
15 public:
16 // TODO(whesse): Make extension load from a relative path relative to
17 // the library it is in. Currently loads from current working directory.
18 static Dart_Handle LoadExtension(const char* extension_directory,
19 const char* extension_name,
20 Dart_Handle parent_library);
21
22 // Platform-specific implementations.
23 // Don't rename LoadExtensionLibrary to LoadLibrary since on Windows it
24 // conflicts with LoadLibraryW after mangling.
25 static void* LoadExtensionLibrary(const char* library_file);
26 static void* ResolveSymbol(void* lib_handle, const char* symbol);
27 static void UnloadLibrary(void* lib_handle);
28
29 private:
30 static Dart_Handle GetError();
31
32 static void* MakePathAndResolve(const char* dir, const char* name);
33 static void* ResolveAbsPathExtension(const char* extension_path);
34 static void* ResolveExtension(const char* extensioion_directory,
35 const char* extension_name);
36
37 // The returned string is scope allocated.
38 static const char* Concatenate(const char** strings);
39
40 DISALLOW_ALLOCATION();
41 DISALLOW_IMPLICIT_CONSTRUCTORS(Extensions);
42};
43
44} // namespace bin
45} // namespace dart
46
47#endif // RUNTIME_BIN_EXTENSIONS_H_
48