1
0
Fork 0

More strictness.

This commit is contained in:
Alan Plum 2015-04-08 16:18:11 +02:00
parent 1961389092
commit 45ff33b404
7 changed files with 273 additions and 345 deletions

View File

@ -1,5 +1,5 @@
/*jshint strict:false */ /*jshint globalstrict:true */
/*global global:true, window */ 'use strict';
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief monkey-patches to built-in prototypes /// @brief monkey-patches to built-in prototypes
@ -33,14 +33,6 @@
// --SECTION-- monkey-patches // --SECTION-- monkey-patches
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
if (typeof global === 'undefined' && typeof window !== 'undefined') {
global = window;
}
global.setInterval = global.setInterval || function () {};
global.clearInterval = global.clearInterval || function () {};
global.setTimeout = global.setTimeout || function () {};
global.clearTimeout = global.clearTimeout || function () {};
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- public functions // --SECTION-- public functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -51,10 +43,9 @@ global.clearTimeout = global.clearTimeout || function () {};
Object.defineProperty(Object.prototype, "_shallowCopy", { Object.defineProperty(Object.prototype, "_shallowCopy", {
get: function () { get: function () {
var that = this; var self = this;
return this.propertyKeys.reduce(function (previous, key) {
return this.propertyKeys.reduce(function (previous, element) { previous[key] = self[key];
previous[element] = that[element];
return previous; return previous;
}, {}); }, {});
} }
@ -66,8 +57,8 @@ Object.defineProperty(Object.prototype, "_shallowCopy", {
Object.defineProperty(Object.prototype, "propertyKeys", { Object.defineProperty(Object.prototype, "propertyKeys", {
get: function () { get: function () {
return Object.keys(this).filter(function (element) { return Object.keys(this).filter(function (key) {
return (element[0] !== '_' && element[0] !== '$'); return (key.charAt(0) !== '_' && key.charAt(0) !== '$');
}); });
} }
}); });

View File

@ -1,5 +1,6 @@
/*jshint unused: false, -W051: true */ /*jshint globalstrict:true, -W051:true */
/*global require, console: true, IS_EXECUTE_SCRIPT, IS_EXECUTE_STRING, IS_CHECK_SCRIPT, IS_UNIT_TESTS, IS_JS_LINT */ /*global global:true, window, require */
'use strict';
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief ArangoShell client API /// @brief ArangoShell client API
@ -28,36 +29,48 @@
/// @author Copyright 2012-2013, triAGENS GmbH, Cologne, Germany /// @author Copyright 2012-2013, triAGENS GmbH, Cologne, Germany
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof global === 'undefined' && typeof window !== 'undefined') {
global = window;
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- global functions // --SECTION-- global functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
// @brief common globals
////////////////////////////////////////////////////////////////////////////////
global.Buffer = require("buffer").Buffer;
global.process = require("process");
global.setInterval = global.setInterval || function () {};
global.clearInterval = global.clearInterval || function () {};
global.setTimeout = global.setTimeout || function () {};
global.clearTimeout = global.clearTimeout || function () {};
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief start paging /// @brief start paging
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function start_pager () { global.start_pager = function start_pager () {
"use strict";
var internal = require("internal"); var internal = require("internal");
internal.startPager(); internal.startPager();
} };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief stop paging /// @brief stop paging
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function stop_pager () { global.stop_pager = function stop_pager () {
"use strict";
var internal = require("internal"); var internal = require("internal");
internal.stopPager(); internal.stopPager();
} };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief print the overall help /// @brief print the overall help
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function help () { global.help = function help () {
"use strict";
var internal = require("internal"); var internal = require("internal");
var arangodb = require("org/arangodb"); var arangodb = require("org/arangodb");
var arangosh = require("org/arangodb/arangosh"); var arangosh = require("org/arangodb/arangosh");
@ -68,67 +81,57 @@ function help () {
arangodb.ArangoStatement.prototype._help(); arangodb.ArangoStatement.prototype._help();
arangodb.ArangoQueryCursor.prototype._help(); arangodb.ArangoQueryCursor.prototype._help();
internal.print(arangosh.helpExtended); internal.print(arangosh.helpExtended);
} };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief clear screen (poor man's way) /// @brief clear screen (poor man's way)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function clear () { global.clear = function clear () {
"use strict";
var internal = require("internal"); var internal = require("internal");
var i;
var result = ''; var result = '';
for (i = 0; i < 100; ++i) { for (var i = 0; i < 100; ++i) {
result += '\n'; result += '\n';
} }
internal.print(result); internal.print(result);
} };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief global 'console' /// @brief global 'console'
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof console === 'undefined') { global.console = global.console || require("console");
console = require("console");
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief global 'db' /// @brief global 'db'
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var db = require("org/arangodb").db; global.db = require("org/arangodb").db;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief global 'arango' /// @brief global 'arango'
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var arango = require("org/arangodb").arango; global.arango = require("org/arangodb").arango;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief global 'fm' /// @brief global 'fm'
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var fm = require("org/arangodb/foxx/manager"); global.fm = require("org/arangodb/foxx/manager");
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief global 'ArangoStatement' /// @brief global 'ArangoStatement'
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var ArangoStatement = require("org/arangodb/arango-statement").ArangoStatement; global.ArangoStatement = require("org/arangodb/arango-statement").ArangoStatement;
////////////////////////////////////////////////////////////////////////////////
/// @brief global 'Buffer'
////////////////////////////////////////////////////////////////////////////////
var Buffer = require("buffer").Buffer;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief shell tutorial /// @brief shell tutorial
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var tutorial = require("org/arangodb/tutorial"); global.tutorial = require("org/arangodb/tutorial");
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- initialise // --SECTION-- initialise
@ -139,53 +142,33 @@ var tutorial = require("org/arangodb/tutorial");
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
(function() { (function() {
"use strict";
var internal = require("internal"); var internal = require("internal");
var arangosh = require("org/arangodb/arangosh");
var special;
if (internal.db !== undefined) { if (internal.db) {
try { try {
internal.db._collections(); internal.db._collections();
} }
catch (err) { catch (e) {}
}
} }
try { if (internal.quiet !== true) {
// these variables don't exist in the browser context if (internal.arango && internal.arango.isConnected && internal.arango.isConnected()) {
special = IS_EXECUTE_SCRIPT || IS_EXECUTE_STRING || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT;
}
catch (err2) {
special = false;
}
if (internal.quiet !== true && ! special) {
if (typeof internal.arango !== "undefined") {
if (typeof internal.arango.isConnected !== "undefined" && internal.arango.isConnected()) {
internal.print("Type 'tutorial' for a tutorial or 'help' to see common examples"); internal.print("Type 'tutorial' for a tutorial or 'help' to see common examples");
} }
} }
}
}());
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief read rc file /// @brief read rc file
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
(function () {
/*jshint strict: false */
var __special__;
try {
// these variables are not defined in the browser context // these variables are not defined in the browser context
__special__ = IS_EXECUTE_SCRIPT || IS_EXECUTE_STRING || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT; if (
} global.IS_EXECUTE_SCRIPT ||
catch (err) { global.IS_EXECUTE_STRING ||
__special__ = true; global.IS_CHECK_SCRIPT ||
} global.IS_UNIT_TESTS ||
global.IS_JS_LINT
if (! __special__) { ) {
try { try {
// this will not work from within a browser // this will not work from within a browser
var __fs__ = require("fs"); var __fs__ = require("fs");
@ -197,20 +180,18 @@ var tutorial = require("org/arangodb/tutorial");
eval(__content__); eval(__content__);
} }
} }
catch (err2) { catch (e) {
require("console").warn("arangosh.rc: %s", String(err2)); require("console").warn("arangosh.rc: %s", String(e));
} }
} }
try { try {
delete IS_EXECUTE_SCRIPT; delete global.IS_EXECUTE_SCRIPT;
delete IS_EXECUTE_STRING; delete global.IS_EXECUTE_STRING;
delete IS_CHECK_SCRIPT; delete global.IS_CHECK_SCRIPT;
delete IS_UNIT_TESTS; delete global.IS_UNIT_TESTS;
delete IS_JS_LINT; delete global.IS_JS_LINT;
} } catch (e) {}
catch (err3) {
}
}()); }());
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -1,5 +1,6 @@
/*jshint unused: false, -W051: true */ /*jshint globalstrict:true, -W051:true */
/*global require, console: true, IS_EXECUTE_SCRIPT, IS_EXECUTE_STRING, IS_CHECK_SCRIPT, IS_UNIT_TESTS, IS_JS_LINT */ /*global global:true, window, require */
'use strict';
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief ArangoShell client API /// @brief ArangoShell client API
@ -28,36 +29,48 @@
/// @author Copyright 2012-2013, triAGENS GmbH, Cologne, Germany /// @author Copyright 2012-2013, triAGENS GmbH, Cologne, Germany
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof global === 'undefined' && typeof window !== 'undefined') {
global = window;
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- global functions // --SECTION-- global functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
// @brief common globals
////////////////////////////////////////////////////////////////////////////////
global.Buffer = require("buffer").Buffer;
global.process = require("process");
global.setInterval = global.setInterval || function () {};
global.clearInterval = global.clearInterval || function () {};
global.setTimeout = global.setTimeout || function () {};
global.clearTimeout = global.clearTimeout || function () {};
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief start paging /// @brief start paging
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function start_pager () { global.start_pager = function start_pager () {
"use strict";
var internal = require("internal"); var internal = require("internal");
internal.startPager(); internal.startPager();
} };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief stop paging /// @brief stop paging
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function stop_pager () { global.stop_pager = function stop_pager () {
"use strict";
var internal = require("internal"); var internal = require("internal");
internal.stopPager(); internal.stopPager();
} };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief print the overall help /// @brief print the overall help
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function help () { global.help = function help () {
"use strict";
var internal = require("internal"); var internal = require("internal");
var arangodb = require("org/arangodb"); var arangodb = require("org/arangodb");
var arangosh = require("org/arangodb/arangosh"); var arangosh = require("org/arangodb/arangosh");
@ -68,67 +81,57 @@ function help () {
arangodb.ArangoStatement.prototype._help(); arangodb.ArangoStatement.prototype._help();
arangodb.ArangoQueryCursor.prototype._help(); arangodb.ArangoQueryCursor.prototype._help();
internal.print(arangosh.helpExtended); internal.print(arangosh.helpExtended);
} };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief clear screen (poor man's way) /// @brief clear screen (poor man's way)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
function clear () { global.clear = function clear () {
"use strict";
var internal = require("internal"); var internal = require("internal");
var i;
var result = ''; var result = '';
for (i = 0; i < 100; ++i) { for (var i = 0; i < 100; ++i) {
result += '\n'; result += '\n';
} }
internal.print(result); internal.print(result);
} };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief global 'console' /// @brief global 'console'
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof console === 'undefined') { global.console = global.console || require("console");
console = require("console");
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief global 'db' /// @brief global 'db'
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var db = require("org/arangodb").db; global.db = require("org/arangodb").db;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief global 'arango' /// @brief global 'arango'
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var arango = require("org/arangodb").arango; global.arango = require("org/arangodb").arango;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief global 'fm' /// @brief global 'fm'
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var fm = require("org/arangodb/foxx/manager"); global.fm = require("org/arangodb/foxx/manager");
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief global 'ArangoStatement' /// @brief global 'ArangoStatement'
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var ArangoStatement = require("org/arangodb/arango-statement").ArangoStatement; global.ArangoStatement = require("org/arangodb/arango-statement").ArangoStatement;
////////////////////////////////////////////////////////////////////////////////
/// @brief global 'Buffer'
////////////////////////////////////////////////////////////////////////////////
var Buffer = require("buffer").Buffer;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief shell tutorial /// @brief shell tutorial
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var tutorial = require("org/arangodb/tutorial"); global.tutorial = require("org/arangodb/tutorial");
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- initialise // --SECTION-- initialise
@ -139,53 +142,33 @@ var tutorial = require("org/arangodb/tutorial");
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
(function() { (function() {
"use strict";
var internal = require("internal"); var internal = require("internal");
var arangosh = require("org/arangodb/arangosh");
var special;
if (internal.db !== undefined) { if (internal.db) {
try { try {
internal.db._collections(); internal.db._collections();
} }
catch (err) { catch (e) {}
}
} }
try { if (internal.quiet !== true) {
// these variables don't exist in the browser context if (internal.arango && internal.arango.isConnected && internal.arango.isConnected()) {
special = IS_EXECUTE_SCRIPT || IS_EXECUTE_STRING || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT;
}
catch (err2) {
special = false;
}
if (internal.quiet !== true && ! special) {
if (typeof internal.arango !== "undefined") {
if (typeof internal.arango.isConnected !== "undefined" && internal.arango.isConnected()) {
internal.print("Type 'tutorial' for a tutorial or 'help' to see common examples"); internal.print("Type 'tutorial' for a tutorial or 'help' to see common examples");
} }
} }
}
}());
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief read rc file /// @brief read rc file
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
(function () {
/*jshint strict: false */
var __special__;
try {
// these variables are not defined in the browser context // these variables are not defined in the browser context
__special__ = IS_EXECUTE_SCRIPT || IS_EXECUTE_STRING || IS_CHECK_SCRIPT || IS_UNIT_TESTS || IS_JS_LINT; if (
} global.IS_EXECUTE_SCRIPT ||
catch (err) { global.IS_EXECUTE_STRING ||
__special__ = true; global.IS_CHECK_SCRIPT ||
} global.IS_UNIT_TESTS ||
global.IS_JS_LINT
if (! __special__) { ) {
try { try {
// this will not work from within a browser // this will not work from within a browser
var __fs__ = require("fs"); var __fs__ = require("fs");
@ -197,20 +180,18 @@ var tutorial = require("org/arangodb/tutorial");
eval(__content__); eval(__content__);
} }
} }
catch (err2) { catch (e) {
require("console").warn("arangosh.rc: %s", String(err2)); require("console").warn("arangosh.rc: %s", String(e));
} }
} }
try { try {
delete IS_EXECUTE_SCRIPT; delete global.IS_EXECUTE_SCRIPT;
delete IS_EXECUTE_STRING; delete global.IS_EXECUTE_STRING;
delete IS_CHECK_SCRIPT; delete global.IS_CHECK_SCRIPT;
delete IS_UNIT_TESTS; delete global.IS_UNIT_TESTS;
delete IS_JS_LINT; delete global.IS_JS_LINT;
} } catch (e) {}
catch (err3) {
}
}()); }());
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@ -699,11 +699,6 @@ function require (path) {
// create a new package and module // create a new package and module
var pkg = new Package(path, desc, currentPackage, path2FileUri(dirname), currentPackage._isSystem); var pkg = new Package(path, desc, currentPackage, path2FileUri(dirname), currentPackage._isSystem);
pkg._environment = {
process: require("process")
};
pkg._packageModule = createModule(currentModule, pkg, description); pkg._packageModule = createModule(currentModule, pkg, description);
return pkg; return pkg;

View File

@ -1,5 +1,5 @@
/*jshint strict:false */ /*jshint globalstrict:true */
/*global global:true, window */ 'use strict';
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief monkey-patches to built-in prototypes /// @brief monkey-patches to built-in prototypes
@ -33,14 +33,6 @@
// --SECTION-- monkey-patches // --SECTION-- monkey-patches
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
if (typeof global === 'undefined' && typeof window !== 'undefined') {
global = window;
}
global.setInterval = global.setInterval || function () {};
global.clearInterval = global.clearInterval || function () {};
global.setTimeout = global.setTimeout || function () {};
global.clearTimeout = global.clearTimeout || function () {};
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- public functions // --SECTION-- public functions
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
@ -51,10 +43,9 @@ global.clearTimeout = global.clearTimeout || function () {};
Object.defineProperty(Object.prototype, "_shallowCopy", { Object.defineProperty(Object.prototype, "_shallowCopy", {
get: function () { get: function () {
var that = this; var self = this;
return this.propertyKeys.reduce(function (previous, key) {
return this.propertyKeys.reduce(function (previous, element) { previous[key] = self[key];
previous[element] = that[element];
return previous; return previous;
}, {}); }, {});
} }
@ -66,8 +57,8 @@ Object.defineProperty(Object.prototype, "_shallowCopy", {
Object.defineProperty(Object.prototype, "propertyKeys", { Object.defineProperty(Object.prototype, "propertyKeys", {
get: function () { get: function () {
return Object.keys(this).filter(function (element) { return Object.keys(this).filter(function (key) {
return (element[0] !== '_' && element[0] !== '$'); return (key.charAt(0) !== '_' && key.charAt(0) !== '$');
}); });
} }
}); });

View File

@ -1,12 +1,6 @@
/*jshint -W051: true */ /*jshint globalstrict:true, -W051:true */
/*global require, db, ArangoCollection, ArangoDatabase, ShapedJson, /*global global, require */
RELOAD_AUTH, SYS_DEFINE_ACTION, SYS_EXECUTE_GLOBAL_CONTEXT_FUNCTION, 'use strict';
WAL_FLUSH, WAL_PROPERTIES,
REPLICATION_LOGGER_STATE, REPLICATION_SERVER_ID,
REPLICATION_APPLIER_CONFIGURE, REPLICATION_APPLIER_START, REPLICATION_APPLIER_SHUTDOWN,
REPLICATION_APPLIER_FORGET, REPLICATION_APPLIER_STATE, REPLICATION_SYNCHRONISE,
ENABLE_STATISTICS, DISPATCHER_THREADS, SYS_CREATE_NAMED_QUEUE, SYS_ADD_JOB,
SYS_RAW_REQUEST_BODY, SYS_REQUEST_PARTS, FE_VERSION_CHECK, SYS_SEND_CHUNK */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief module "internal" /// @brief module "internal"
@ -39,11 +33,9 @@
// --SECTION-- Module "internal" // --SECTION-- Module "internal"
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
(function () { var exports = require("internal");
/*jshint strict: false */ var fs = require("fs");
var internal = require("internal"); var console = require("console");
var fs = require("fs");
var console = require("console");
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- private variables // --SECTION-- private variables
@ -53,50 +45,50 @@
/// @brief db /// @brief db
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
internal.db = db; exports.db = global.db;
delete db; delete global.db;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief ArangoCollection /// @brief ArangoCollection
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
internal.ArangoCollection = ArangoCollection; exports.ArangoCollection = global.ArangoCollection;
delete ArangoCollection; delete global.ArangoCollection;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief ArangoDatabase /// @brief ArangoDatabase
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
internal.ArangoDatabase = ArangoDatabase; exports.ArangoDatabase = global.ArangoDatabase;
delete ArangoDatabase; delete global.ArangoDatabase;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief ShapedJson /// @brief ShapedJson
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
internal.ShapedJson = ShapedJson; exports.ShapedJson = global.ShapedJson;
delete ShapedJson; delete global.ShapedJson;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief enableStatistics /// @brief enableStatistics
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
internal.enableStatistics = ENABLE_STATISTICS; exports.enableStatistics = global.ENABLE_STATISTICS;
delete ENABLE_STATISTICS; delete global.ENABLE_STATISTICS;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief dispatcherThreads /// @brief dispatcherThreads
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
internal.dispatcherThreads = DISPATCHER_THREADS; exports.dispatcherThreads = global.DISPATCHER_THREADS;
delete DISPATCHER_THREADS; delete global.DISPATCHER_THREADS;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief frontendVersionCheck /// @brief frontendVersionCheck
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
internal.frontendVersionCheck = FE_VERSION_CHECK; exports.frontendVersionCheck = global.FE_VERSION_CHECK;
delete FE_VERSION_CHECK; delete global.FE_VERSION_CHECK;
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- private functions // --SECTION-- private functions
@ -106,61 +98,55 @@
/// @brief resets engine in development mode /// @brief resets engine in development mode
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
internal.resetEngine = function () { exports.resetEngine = function () {
'use strict';
require("org/arangodb/actions").reloadRouting(); require("org/arangodb/actions").reloadRouting();
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief rebuilds the authentication cache /// @brief rebuilds the authentication cache
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
internal.reloadAuth = RELOAD_AUTH; exports.reloadAuth = global.RELOAD_AUTH;
delete RELOAD_AUTH; delete global.RELOAD_AUTH;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief write-ahead log object /// @brief write-ahead log object
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
internal.wal = { exports.wal = {
flush: function () { flush: function () {
return WAL_FLUSH.apply(null, arguments); return global.WAL_FLUSH.apply(null, arguments);
}, },
properties: function () { properties: function () {
return WAL_PROPERTIES.apply(null, arguments); return global.WAL_PROPERTIES.apply(null, arguments);
} }
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief defines an action /// @brief defines an action
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof SYS_DEFINE_ACTION !== "undefined") { if (global.SYS_DEFINE_ACTION) {
internal.defineAction = SYS_DEFINE_ACTION; exports.defineAction = global.SYS_DEFINE_ACTION;
delete SYS_DEFINE_ACTION; delete global.SYS_DEFINE_ACTION;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief autoload modules from database /// @brief autoload modules from database
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// autoload specific modules // autoload specific modules
internal.autoloadModules = function () { exports.autoloadModules = function () {
'use strict';
console.debug("autoloading actions"); console.debug("autoloading actions");
var modules = exports.db._collection("_modules");
var modules = internal.db._collection("_modules");
if (modules !== null) { if (modules !== null) {
modules = modules.byExample({ autoload: true }).toArray(); modules = modules.byExample({ autoload: true }).toArray();
modules.forEach(function(module) { modules.forEach(function(module) {
// this module is only meant to be executed in one thread // this module is only meant to be executed in one thread
if (internal.threadNumber !== 0 && ! module.perThread) { if (exports.threadNumber !== 0 && ! module.perThread) {
return; return;
} }
@ -187,164 +173,162 @@
} }
console.debug("autoloading actions finished"); console.debug("autoloading actions finished");
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief executes a string in all V8 contexts /// @brief executes a string in all V8 contexts
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof SYS_EXECUTE_GLOBAL_CONTEXT_FUNCTION === "undefined") { if (global.SYS_EXECUTE_GLOBAL_CONTEXT_FUNCTION) {
internal.executeGlobalContextFunction = function() { exports.executeGlobalContextFunction = global.SYS_EXECUTE_GLOBAL_CONTEXT_FUNCTION;
}
else {
exports.executeGlobalContextFunction = function() {
// nothing to do. we're probably in --no-server mode // nothing to do. we're probably in --no-server mode
}; };
} }
else {
internal.executeGlobalContextFunction = SYS_EXECUTE_GLOBAL_CONTEXT_FUNCTION;
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief reloads the AQL user functions /// @brief reloads the AQL user functions
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof SYS_EXECUTE_GLOBAL_CONTEXT_FUNCTION === "undefined") { if (global.SYS_EXECUTE_GLOBAL_CONTEXT_FUNCTION) {
internal.reloadAqlFunctions = function () { exports.reloadAqlFunctions = function () {
exports.executeGlobalContextFunction("reloadAql");
require("org/arangodb/aql").reload(); require("org/arangodb/aql").reload();
}; };
} delete global.SYS_EXECUTE_GLOBAL_CONTEXT_FUNCTION;
else { }
internal.reloadAqlFunctions = function () { else {
internal.executeGlobalContextFunction("reloadAql"); exports.reloadAqlFunctions = function () {
require("org/arangodb/aql").reload(); require("org/arangodb/aql").reload();
}; };
delete SYS_EXECUTE_GLOBAL_CONTEXT_FUNCTION; }
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief getStateReplicationLogger /// @brief getStateReplicationLogger
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof REPLICATION_LOGGER_STATE !== "undefined") { if (global.REPLICATION_LOGGER_STATE) {
internal.getStateReplicationLogger = REPLICATION_LOGGER_STATE; exports.getStateReplicationLogger = global.REPLICATION_LOGGER_STATE;
delete REPLICATION_LOGGER_STATE; delete global.REPLICATION_LOGGER_STATE;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief configureReplicationApplier /// @brief configureReplicationApplier
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof REPLICATION_APPLIER_CONFIGURE !== "undefined") { if (global.REPLICATION_APPLIER_CONFIGURE) {
internal.configureReplicationApplier = REPLICATION_APPLIER_CONFIGURE; exports.configureReplicationApplier = global.REPLICATION_APPLIER_CONFIGURE;
delete REPLICATION_APPLIER_CONFIGURE; delete global.REPLICATION_APPLIER_CONFIGURE;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief startReplicationApplier /// @brief startReplicationApplier
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof REPLICATION_APPLIER_START !== "undefined") { if (global.REPLICATION_APPLIER_START) {
internal.startReplicationApplier = REPLICATION_APPLIER_START; exports.startReplicationApplier = global.REPLICATION_APPLIER_START;
delete REPLICATION_APPLIER_START; delete global.REPLICATION_APPLIER_START;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief shutdownReplicationApplier /// @brief shutdownReplicationApplier
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof REPLICATION_APPLIER_SHUTDOWN !== "undefined") { if (global.REPLICATION_APPLIER_SHUTDOWN) {
internal.shutdownReplicationApplier = REPLICATION_APPLIER_SHUTDOWN; exports.shutdownReplicationApplier = global.REPLICATION_APPLIER_SHUTDOWN;
delete REPLICATION_APPLIER_SHUTDOWN; delete global.REPLICATION_APPLIER_SHUTDOWN;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief getStateReplicationApplier /// @brief getStateReplicationApplier
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof REPLICATION_APPLIER_STATE !== "undefined") { if (global.REPLICATION_APPLIER_STATE) {
internal.getStateReplicationApplier = REPLICATION_APPLIER_STATE; exports.getStateReplicationApplier = global.REPLICATION_APPLIER_STATE;
delete REPLICATION_APPLIER_STATE; delete global.REPLICATION_APPLIER_STATE;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief forgetStateReplicationApplier /// @brief forgetStateReplicationApplier
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof REPLICATION_APPLIER_FORGET !== "undefined") { if (global.REPLICATION_APPLIER_FORGET) {
internal.forgetStateReplicationApplier = REPLICATION_APPLIER_FORGET; exports.forgetStateReplicationApplier = global.REPLICATION_APPLIER_FORGET;
delete REPLICATION_APPLIER_FORGET; delete global.REPLICATION_APPLIER_FORGET;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief sychroniseReplication /// @brief sychroniseReplication
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof REPLICATION_SYNCHRONISE !== "undefined") { if (global.REPLICATION_SYNCHRONISE) {
internal.synchroniseReplication = REPLICATION_SYNCHRONISE; exports.synchroniseReplication = global.REPLICATION_SYNCHRONISE;
delete REPLICATION_SYNCHRONISE; delete global.REPLICATION_SYNCHRONISE;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief serverId /// @brief serverId
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof REPLICATION_SERVER_ID !== "undefined") { if (global.REPLICATION_SERVER_ID) {
internal.serverId = REPLICATION_SERVER_ID; exports.serverId = global.REPLICATION_SERVER_ID;
delete REPLICATION_SERVER_ID; delete global.REPLICATION_SERVER_ID;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief loadStartup /// @brief loadStartup
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
internal.loadStartup = function (path) { exports.loadStartup = function (path) {
return internal.load(fs.join(internal.startupPath, path)); return exports.load(fs.join(exports.startupPath, path));
}; };
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief createNamedQueue /// @brief createNamedQueue
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof SYS_CREATE_NAMED_QUEUE !== "undefined") { if (global.SYS_CREATE_NAMED_QUEUE) {
internal.createNamedQueue = SYS_CREATE_NAMED_QUEUE; exports.createNamedQueue = global.SYS_CREATE_NAMED_QUEUE;
delete SYS_CREATE_NAMED_QUEUE; delete global.SYS_CREATE_NAMED_QUEUE;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief addJob /// @brief addJob
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof SYS_ADD_JOB !== "undefined") { if (global.SYS_ADD_JOB) {
internal.addJob = SYS_ADD_JOB; exports.addJob = global.SYS_ADD_JOB;
delete SYS_ADD_JOB; delete global.SYS_ADD_JOB;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief raw request body /// @brief raw request body
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof SYS_RAW_REQUEST_BODY !== "undefined") { if (global.SYS_RAW_REQUEST_BODY) {
internal.rawRequestBody = SYS_RAW_REQUEST_BODY; exports.rawRequestBody = global.SYS_RAW_REQUEST_BODY;
delete SYS_RAW_REQUEST_BODY; delete global.SYS_RAW_REQUEST_BODY;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief request parts /// @brief request parts
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof SYS_REQUEST_PARTS !== "undefined") { if (global.SYS_REQUEST_PARTS) {
internal.requestParts = SYS_REQUEST_PARTS; exports.requestParts = global.SYS_REQUEST_PARTS;
delete SYS_REQUEST_PARTS; delete global.SYS_REQUEST_PARTS;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief send chunks /// @brief send chunks
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
if (typeof SYS_SEND_CHUNK !== "undefined") { if (global.SYS_SEND_CHUNK) {
internal.sendChunk = SYS_SEND_CHUNK; exports.sendChunk = global.SYS_SEND_CHUNK;
delete SYS_SEND_CHUNK; delete global.SYS_SEND_CHUNK;
} }
}());
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// --SECTION-- END-OF-FILE // --SECTION-- END-OF-FILE

View File

@ -1,4 +1,4 @@
/*global require, STARTUP_PATH, SYS_LOAD */ /*global global, require */
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
/// @brief basic initialisation /// @brief basic initialisation
@ -35,8 +35,8 @@
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
(function () { (function () {
var startupPath = STARTUP_PATH; var startupPath = global.STARTUP_PATH;
var load = SYS_LOAD; var load = global.SYS_LOAD;
if (startupPath === "") { if (startupPath === "") {
startupPath = "."; startupPath = ".";
@ -51,8 +51,13 @@
load(startupPath + "/server/bootstrap/module-internal.js"); load(startupPath + "/server/bootstrap/module-internal.js");
}()); }());
// global Buffer // globals
var Buffer = require("buffer").Buffer; global.Buffer = require("buffer").Buffer;
global.process = require("process");
global.setInterval = function () {};
global.clearInterval = function () {};
global.setTimeout = function () {};
global.clearTimeout = function () {};
// extend prototypes for internally defined classes // extend prototypes for internally defined classes
require("org/arangodb"); require("org/arangodb");