mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Move all extension C and JavaScript code into native/v8_extensions
This commit is contained in:
9
Rakefile
9
Rakefile
@@ -63,15 +63,16 @@ task :"copy-files-to-bundle" => :"verify-prerequisites" do
|
||||
|
||||
dest = File.join(built_dir, contents_dir, "Resources")
|
||||
|
||||
mkdir_p "#{dest}/v8_extensions"
|
||||
cp Dir.glob("#{project_dir}/native/v8_extensions/*.js"), "#{dest}/v8_extensions/"
|
||||
|
||||
if resource_path = ENV['RESOURCE_PATH']
|
||||
sh "coffee -c -o #{dest}/src/stdlib #{resource_path}/src/stdlib/require.coffee"
|
||||
sh "coffee -c -o '#{dest}/src/stdlib' '#{resource_path}/src/stdlib/require.coffee'"
|
||||
cp_r "#{resource_path}/static", dest
|
||||
cp "#{resource_path}/src/stdlib/onig-reg-exp-extension.js", "#{dest}/src/stdlib"
|
||||
cp "#{resource_path}/src/stdlib/native-handler.js", "#{dest}/src/stdlib"
|
||||
else
|
||||
# TODO: Restore this list when we add in all of atoms source
|
||||
#%w(src static vendor spec benchmark bundles themes).each do |dir|
|
||||
%w(src static vendor).each do |dir|
|
||||
%w(src static vendor bundles themes).each do |dir|
|
||||
dest_path = File.join(dest, dir)
|
||||
rm_rf dest_path
|
||||
cp_r dir, dest_path
|
||||
|
||||
16
atom.gyp
16
atom.gyp
@@ -66,8 +66,8 @@
|
||||
'native/util.h',
|
||||
'native/path_watcher.mm',
|
||||
'native/path_watcher.h',
|
||||
'native/v8_extensions/native_handler.mm',
|
||||
'native/v8_extensions/native_handler.h',
|
||||
'native/v8_extensions/native.mm',
|
||||
'native/v8_extensions/native.h',
|
||||
],
|
||||
'mac_bundle_resources': [
|
||||
'native/mac/atom.icns',
|
||||
@@ -279,8 +279,8 @@
|
||||
'native/util.h',
|
||||
'native/path_watcher.mm',
|
||||
'native/path_watcher.h',
|
||||
'native/v8_extensions/native_handler.mm',
|
||||
'native/v8_extensions/native_handler.h',
|
||||
'native/v8_extensions/native.mm',
|
||||
'native/v8_extensions/native.h',
|
||||
],
|
||||
# TODO(mark): For now, don't put any resources into this app. Its
|
||||
# resources directory will be a symbolic link to the browser app's
|
||||
@@ -307,6 +307,14 @@
|
||||
'${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}'
|
||||
],
|
||||
},
|
||||
{
|
||||
'postbuild_name': 'Copy and Compile Static Files',
|
||||
'action': [
|
||||
'rake',
|
||||
'--trace',
|
||||
'copy-files-to-bundle',
|
||||
],
|
||||
},
|
||||
],
|
||||
}, # target cefclient_helper_app
|
||||
],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "atom_cef_app.h"
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "native/v8_extensions/native_handler.h"
|
||||
#import "native/v8_extensions/native.h"
|
||||
|
||||
|
||||
void AtomCefApp::OnWebKitInitialized() {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#import <CommonCrypto/CommonDigest.h>
|
||||
|
||||
#import "atom_application.h"
|
||||
#import "native_handler.h"
|
||||
#import "native.h"
|
||||
#import "include/cef_base.h"
|
||||
#import "path_watcher.h"
|
||||
|
||||
@@ -25,19 +25,9 @@ void throwException(const CefRefPtr<CefV8Value>& global, CefRefPtr<CefV8Exceptio
|
||||
}
|
||||
|
||||
NativeHandler::NativeHandler() : CefV8Handler() {
|
||||
std::string extensionCode = "var $native = {}; (function() {";
|
||||
|
||||
const char *functionNames[] = {"exists", "alert", "read", "write", "absolute", "list", "isFile", "isDirectory", "remove", "asyncList", "open", "openDialog", "quit", "writeToPasteboard", "readFromPasteboard", "showDevTools", "toggleDevTools", "newWindow", "saveDialog", "exit", "watchPath", "unwatchPath", "makeDirectory", "move", "moveToTrash", "reload", "lastModified", "md5ForPath", "exec", "getPlatform"};
|
||||
NSUInteger arrayLength = sizeof(functionNames) / sizeof(const char *);
|
||||
for (NSUInteger i = 0; i < arrayLength; i++) {
|
||||
std::string functionName = std::string(functionNames[i]);
|
||||
extensionCode += "native function " + functionName + "(); $native." + functionName + " = " + functionName + ";";
|
||||
}
|
||||
|
||||
extensionCode += "})();";
|
||||
|
||||
// Register the extension.
|
||||
CefRegisterExtension("v8/test", extensionCode, this);
|
||||
NSString *filePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"v8_extensions/native.js"];
|
||||
NSString *extensionCode = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
|
||||
CefRegisterExtension("v8/native", [extensionCode UTF8String], this);
|
||||
}
|
||||
|
||||
bool NativeHandler::Execute(const CefString& name,
|
||||
Reference in New Issue
Block a user