1
0
Fork 0

splitted JS files

This commit is contained in:
Frank Celler 2012-02-04 15:50:18 +01:00
parent 38900e755e
commit 4bde2ae5f8
17 changed files with 203 additions and 154 deletions

View File

@ -22,13 +22,21 @@ include Makefile.files
.setup-directories:
@test -d js || mkdir js
@test -d Doxygen/js || mkdir Doxygen/js
@test -d Doxygen/js/system || mkdir Doxygen/js/system
@test -d Doxygen/js/bootstrap || mkdir Doxygen/js/bootstrap
@test -d Doxygen/js/modules || mkdir Doxygen/js/modules
@test -d Doxygen/js/server || mkdir Doxygen/js/server
@test -d Doxygen/js/system || mkdir Doxygen/js/system
@touch $@
js/js-%.h: @srcdir@/js/%.js .setup-directories
@top_srcdir@/config/js2c.sh $< > $@
js/bootstrap/js-%.h: @srcdir@/js/bootstrap/%.js .setup-directories
@top_srcdir@/config/js2c.sh $< > $@
js/server/js-%.h: @srcdir@/js/server/%.js .setup-directories
@top_srcdir@/config/js2c.sh $< > $@
################################################################################
## FLEX
################################################################################

View File

@ -225,11 +225,12 @@ avocado_SOURCES = \
################################################################################
BUILT_SOURCES += \
js/js-modules.h \
js/js-actions.h \
js/js-aql.h \
js/js-json.h \
js/js-shell.h
js/bootstrap/js-modules.h \
js/bootstrap/js-print.h \
js/server/js-actions.h \
js/server/js-aql.h \
js/server/js-json.h \
js/server/js-shell.h
################################################################################
## FLEX
@ -266,12 +267,12 @@ BUILT_SOURCES += \
################################################################################
DOXYGEN = \
Doxygen/js/actions.c \
Doxygen/js/json.c \
Doxygen/js/modules.c \
Doxygen/js/bootstrap/modules.c \
Doxygen/js/modules/graph.c \
Doxygen/js/modules/jsunity.c \
Doxygen/js/shell.c \
Doxygen/js/server/actions.c \
Doxygen/js/server/json.c \
Doxygen/js/server/shell.c \
Doxygen/js/system/collections.c \
Doxygen/js/system/indexes.c

View File

@ -32,6 +32,7 @@
#include "Logger/Logger.h"
#include "Rest/Initialise.h"
#include "V8/v8-actions.h"
#include "V8/v8-conv.h"
#include "V8/v8-globals.h"
#include "V8/v8-shell.h"
#include "V8/v8-utils.h"
@ -227,7 +228,13 @@ JSLoader* ActionDisptacherThread::actionLoader () {
void ActionDisptacherThread::initialise () {
bool ok;
char const* files[] = { "modules.js", "actions.js", "json.js" };
char const* files[] = { "bootstrap/modules.js",
"bootstrap/print.js",
"server/json.js",
"server/actions.js",
"server/aql.js",
"server/shell.js"
};
size_t i;
// enter a new isolate
@ -248,6 +255,7 @@ void ActionDisptacherThread::initialise () {
TRI_InitV8VocBridge(_context, _vocbase);
TRI_InitV8Actions(_context);
TRI_InitV8Conversions(_context);
TRI_InitV8Utils(_context, _startupModules);
TRI_InitV8Shell(_context);

View File

@ -52,6 +52,7 @@
#include "RestServer/JSLoader.h"
#include "RestServer/SystemActionDispatcherThread.h"
#include "V8/v8-actions.h"
#include "V8/v8-conv.h"
#include "V8/v8-globals.h"
#include "V8/v8-line-editor.h"
#include "V8/v8-shell.h"
@ -64,11 +65,12 @@ using namespace triagens::rest;
using namespace triagens::admin;
using namespace triagens::avocado;
#include "js/js-actions.h"
#include "js/js-aql.h"
#include "js/js-json.h"
#include "js/js-modules.h"
#include "js/js-shell.h"
#include "js/bootstrap/js-print.h"
#include "js/bootstrap/js-modules.h"
#include "js/server/js-actions.h"
#include "js/server/js-aql.h"
#include "js/server/js-json.h"
#include "js/server/js-shell.h"
// -----------------------------------------------------------------------------
// --SECTION-- private variables
@ -298,11 +300,12 @@ void AvocadoServer::buildApplicationServer () {
}
if (_startupPath.empty()) {
StartupLoader.defineScript("modules.js", JS_modules);
StartupLoader.defineScript("actions.js", JS_actions);
StartupLoader.defineScript("json.js", JS_json);
StartupLoader.defineScript("aql.js", JS_aql);
StartupLoader.defineScript("shell.js", JS_shell);
StartupLoader.defineScript("bootstrap/modules.js", JS_bootstrap_modules);
StartupLoader.defineScript("bootstrap/print.js", JS_bootstrap_print);
StartupLoader.defineScript("server/actions.js", JS_server_actions);
StartupLoader.defineScript("server/aql.js", JS_server_aql);
StartupLoader.defineScript("server/json.js", JS_server_json);
StartupLoader.defineScript("server/shell.js", JS_server_shell);
}
else {
StartupLoader.setDirectory(_startupPath);
@ -517,7 +520,12 @@ void AvocadoServer::executeShell () {
v8::Isolate* isolate;
v8::Persistent<v8::Context> context;
bool ok;
char const* files[] = { "modules.js", "json.js", "aql.js", "shell.js" };
char const* files[] = { "bootstrap/modules.js",
"bootstrap/print.js",
"server/json.js",
"server/aql.js",
"server/shell.js"
};
size_t i;
// only simple logging
@ -547,6 +555,7 @@ void AvocadoServer::executeShell () {
context->Enter();
TRI_InitV8VocBridge(context, _vocbase);
TRI_InitV8Conversions(context);
TRI_InitV8Utils(context, _startupModules);
TRI_InitV8Shell(context);

View File

@ -1463,7 +1463,7 @@ v8::Handle<v8::Value> TRI_JsonShapeData (TRI_shaper_t* shaper,
/// @brief initialises the V8 conversion module
////////////////////////////////////////////////////////////////////////////////
void TRI_InitV8Conversions (v8::Handle<v8::Context> context, string const& path) {
void TRI_InitV8Conversions (v8::Handle<v8::Context> context) {
v8::HandleScope scope;
// check the isolate

View File

@ -133,7 +133,7 @@ v8::Handle<v8::Value> TRI_JsonShapeData (TRI_shaper_t* shaper,
/// @brief initialises the V8 conversion module
////////////////////////////////////////////////////////////////////////////////
void TRI_InitV8Conversions (v8::Handle<v8::Context> context, std::string const& path);
void TRI_InitV8Conversions (v8::Handle<v8::Context> context);
////////////////////////////////////////////////////////////////////////////////
/// @}

View File

@ -204,12 +204,15 @@ int main (int argc, char* argv[]) {
TRI_InitV8VocBridge(context, VocBase);
TRI_InitV8Actions(context);
TRI_InitV8Conversions(context);
TRI_InitV8Utils(context, ".");
TRI_InitV8Shell(context);
char const* files[] = {
"js/modules.js",
"js/shell.js"
"js/bootstrap/modules.js",
"js/bootstrap/print.js",
"js/modules/shell.js",
"js/modules/json.js"
};
for (size_t i = 0; i < sizeof(files) / sizeof(files[0]); ++i) {

View File

@ -326,15 +326,6 @@ static v8::Handle<v8::Value> JS_ProcessJsonFile (v8::Arguments const& argv) {
void TRI_InitV8Shell (v8::Handle<v8::Context> context) {
v8::HandleScope scope;
// check the isolate
v8::Isolate* isolate = v8::Isolate::GetCurrent();
TRI_v8_global_t* v8g = (TRI_v8_global_t*) isolate->GetData();
if (v8g == 0) {
v8g = new TRI_v8_global_t;
isolate->SetData(v8g);
}
// .............................................................................
// create the global functions
// .............................................................................

View File

@ -253,7 +253,7 @@ JOIN_REPEAT:
assert(false);
JOIN_END:
// printf("JOIN NUM EVAL: %lu\n",numEval);
printf("JOIN NUM EVAL: %lu\n",numEval);
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -1 +1 @@
#define TRIAGENS_VERSION "0.0.8 [1309M]"
#define TRIAGENS_VERSION "0.0.8 [1311M]"

View File

@ -1,5 +1,5 @@
#!/bin/bash
NAME=`basename $1 .js`
NAME=`echo $1 | sed -e 's:^\(.*/\)*js/\(.*\)\.js$:\2:' | tr "/" "_"`
cat $1 \
| sed -e 's:\(["\]\):\\\1:g' \

View File

@ -303,10 +303,6 @@ fs = ModuleCache["/fs"].exports;
////////////////////////////////////////////////////////////////////////////////
ModuleCache["/internal"] = new Module("/internal");
ModuleCache["/internal"].exports.AvocadoCollection = AvocadoCollection;
ModuleCache["/internal"].exports.AvocadoEdgesCollection = AvocadoEdgesCollection;
ModuleCache["/internal"].exports.db = db;
ModuleCache["/internal"].exports.edges = edges;
ModuleCache["/internal"].exports.execute = SYS_EXECUTE;
ModuleCache["/internal"].exports.load = SYS_LOAD;
ModuleCache["/internal"].exports.log = SYS_LOG;

View File

@ -1,11 +1,11 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief JavaScript server functions
/// @brief printing
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
@ -22,7 +22,7 @@
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2011, triAGENS GmbH, Cologne, Germany
/// @author Copyright 2011-2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
var internal = require("internal");
@ -204,115 +204,6 @@ function PRINT_OBJECT (object, seen, path, names) {
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- AvocadoFluentQuery
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup V8Shell
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief global variable holding the current printed query
////////////////////////////////////////////////////////////////////////////////
var it = undefined;
////////////////////////////////////////////////////////////////////////////////
/// @brief number of results to print
////////////////////////////////////////////////////////////////////////////////
var queryLimit = 20;
////////////////////////////////////////////////////////////////////////////////
/// @brief prints a query
////////////////////////////////////////////////////////////////////////////////
AvocadoFluentQuery.prototype.PRINT = function() {
if (this instanceof AvocadoFluentQuery) {
var count = 0;
try {
while (this.hasNext() && count++ < queryLimit) {
internal.output(JSON.stringify(this.next()), "\n");
}
if (this.hasNext()) {
internal.output("...more results...");
}
it = this;
}
catch (e) {
internal.output("encountered error while printing: " + e);
}
}
else {
internal.output(this.toString());
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief prints a query
////////////////////////////////////////////////////////////////////////////////
AvocadoFluentQuery2.prototype.PRINT = function() {
if (this instanceof AvocadoFluentQuery2) {
var count = 0;
try {
while (this.hasNext() && count++ < queryLimit) {
internal.output(JSON.stringify(this.next()), "\n");
}
if (this.hasNext()) {
internal.output("...more results...");
}
it = this;
}
catch (e) {
internal.output("encountered error while printing: " + e);
}
}
else {
internal.output(this.toString());
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief prints a query
////////////////////////////////////////////////////////////////////////////////
AvocadoCursor.prototype.PRINT = function() {
if (this instanceof AvocadoCursor) {
var count = 0;
try {
while (this.hasNext() && count++ < queryLimit) {
internal.output(JSON.stringify(this.next()), "\n");
}
if (this.hasNext()) {
internal.output("...more results...");
}
it = this;
}
catch (e) {
internal.output("encountered error while printing: " + e);
}
}
else {
internal.output(this.toString());
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"

142
js/server/shell.js Normal file
View File

@ -0,0 +1,142 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief JavaScript server functions
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-2011 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is triAGENS GmbH, Cologne, Germany
///
/// @author Dr. Frank Celler
/// @author Copyright 2011, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
var internal = require("internal");
// -----------------------------------------------------------------------------
// --SECTION-- AvocadoFluentQuery
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup V8Shell
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief global variable holding the current printed query
////////////////////////////////////////////////////////////////////////////////
var it = undefined;
////////////////////////////////////////////////////////////////////////////////
/// @brief number of results to print
////////////////////////////////////////////////////////////////////////////////
var queryLimit = 20;
////////////////////////////////////////////////////////////////////////////////
/// @brief prints a query
////////////////////////////////////////////////////////////////////////////////
AvocadoFluentQuery.prototype.PRINT = function() {
if (this instanceof AvocadoFluentQuery) {
var count = 0;
try {
while (this.hasNext() && count++ < queryLimit) {
internal.output(JSON.stringify(this.next()), "\n");
}
if (this.hasNext()) {
internal.output("...more results...");
}
it = this;
}
catch (e) {
internal.output("encountered error while printing: " + e);
}
}
else {
internal.output(this.toString());
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief prints a query
////////////////////////////////////////////////////////////////////////////////
AvocadoFluentQuery2.prototype.PRINT = function() {
if (this instanceof AvocadoFluentQuery2) {
var count = 0;
try {
while (this.hasNext() && count++ < queryLimit) {
internal.output(JSON.stringify(this.next()), "\n");
}
if (this.hasNext()) {
internal.output("...more results...");
}
it = this;
}
catch (e) {
internal.output("encountered error while printing: " + e);
}
}
else {
internal.output(this.toString());
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief prints a query
////////////////////////////////////////////////////////////////////////////////
AvocadoCursor.prototype.PRINT = function() {
if (this instanceof AvocadoCursor) {
var count = 0;
try {
while (this.hasNext() && count++ < queryLimit) {
internal.output(JSON.stringify(this.next()), "\n");
}
if (this.hasNext()) {
internal.output("...more results...");
}
it = this;
}
catch (e) {
internal.output("encountered error while printing: " + e);
}
}
else {
internal.output(this.toString());
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
// End: