1
0
Fork 0

fixed layout and memory bug

This commit is contained in:
Frank Celler 2012-03-13 01:25:43 +01:00
parent 2d13901c2f
commit decb5ede0f
32 changed files with 346 additions and 44 deletions

View File

@ -38,8 +38,10 @@ sbin_PROGRAMS = avocado
bin_PROGRAMS = avocsh
nobase_pkgdata_DATA = \
$(shell find @srcdir@/js/system -name "*.js" -print) \
$(shell find @srcdir@/js/modules -name "*.js" -print) \
$(shell find @srcdir@/js/actions/system -name "*.js" -print) \
$(shell find @srcdir@/js/common/modules -name "*.js" -print) \
$(shell find @srcdir@/js/server/modules -name "*.js" -print) \
$(shell find @srcdir@/js/client/modules -name "*.js" -print) \
$(shell find @srcdir@/html -name "*.css" -print) \
$(shell find @srcdir@/html -name "*.gif" -print) \
$(shell find @srcdir@/html -name "*.html" -print) \

View File

@ -215,13 +215,10 @@ avocsh_SOURCES = \
################################################################################
JAVASCRIPT_HEADER = \
js/bootstrap/js-modules.h \
js/bootstrap/js-print.h \
js/common/bootstrap/js-modules.h \
js/common/bootstrap/js-print.h \
js/client/js-client.h \
js/server/js-modules.h \
js/server/js-aql.h \
js/server/js-json.h \
js/server/js-shell.h
js/server/js-server.h
BUILT_SOURCES += $(JAVASCRIPT_HEADER)
@ -268,8 +265,8 @@ BUILT_SOURCES += $(BISONXX_FILES)
################################################################################
DOXYGEN = \
Doxygen/js/bootstrap/modules.c \
Doxygen/js/bootstrap/print.c \
Doxygen/js/common/bootstrap/modules.c \
Doxygen/js/common/bootstrap/print.c \
Doxygen/js/modules/actions.c \
Doxygen/js/modules/graph.c \
Doxygen/js/modules/jsunity.c \
@ -277,8 +274,8 @@ DOXYGEN = \
Doxygen/js/server/modules.c \
Doxygen/js/server/json.c \
Doxygen/js/server/shell.c \
Doxygen/js/system/collections.c \
Doxygen/js/system/indexes.c
Doxygen/js/actions/system/collections.c \
Doxygen/js/actions/system/indexes.c
################################################################################
## wiki

View File

@ -522,8 +522,10 @@ CLEANUP = $(DOXYGEN) $(WIKI) $(subst Doxygen/xml,Doxygen/wiki,$(WIKI)) \
$(JAVASCRIPT_HEADER) $(am__append_1) $(am__append_2)
noinst_LIBRARIES = libavocado.a
nobase_pkgdata_DATA = \
$(shell find @srcdir@/js/system -name "*.js" -print) \
$(shell find @srcdir@/js/modules -name "*.js" -print) \
$(shell find @srcdir@/js/actions/system -name "*.js" -print) \
$(shell find @srcdir@/js/common/modules -name "*.js" -print) \
$(shell find @srcdir@/js/server/modules -name "*.js" -print) \
$(shell find @srcdir@/js/client/modules -name "*.js" -print) \
$(shell find @srcdir@/html -name "*.css" -print) \
$(shell find @srcdir@/html -name "*.gif" -print) \
$(shell find @srcdir@/html -name "*.html" -print) \
@ -737,13 +739,10 @@ avocsh_SOURCES = \
################################################################################
################################################################################
JAVASCRIPT_HEADER = \
js/bootstrap/js-modules.h \
js/bootstrap/js-print.h \
js/common/bootstrap/js-modules.h \
js/common/bootstrap/js-print.h \
js/client/js-client.h \
js/server/js-modules.h \
js/server/js-aql.h \
js/server/js-json.h \
js/server/js-shell.h
js/server/js-server.h
################################################################################
@ -775,8 +774,8 @@ BISONXX_FILES = \
################################################################################
################################################################################
DOXYGEN = \
Doxygen/js/bootstrap/modules.c \
Doxygen/js/bootstrap/print.c \
Doxygen/js/common/bootstrap/modules.c \
Doxygen/js/common/bootstrap/print.c \
Doxygen/js/modules/actions.c \
Doxygen/js/modules/graph.c \
Doxygen/js/modules/jsunity.c \
@ -784,8 +783,8 @@ DOXYGEN = \
Doxygen/js/server/modules.c \
Doxygen/js/server/json.c \
Doxygen/js/server/shell.c \
Doxygen/js/system/collections.c \
Doxygen/js/system/indexes.c
Doxygen/js/actions/system/collections.c \
Doxygen/js/actions/system/indexes.c
################################################################################
@ -2430,7 +2429,7 @@ wiki: $(WIKI)
js/js-%.h: @srcdir@/js/%.js .setup-directories
@top_srcdir@/config/js2c.sh $< > $@
js/bootstrap/js-%.h: @srcdir@/js/bootstrap/%.js .setup-directories
js/common/bootstrap/js-%.h: @srcdir@/js/common/bootstrap/%.js .setup-directories
@top_srcdir@/config/js2c.sh $< > $@
js/client/js-%.h: @srcdir@/js/client/%.js .setup-directories

View File

@ -16,7 +16,7 @@ BUILT_SOURCES += .setup-directories
js/js-%.h: @srcdir@/js/%.js .setup-directories
@top_srcdir@/config/js2c.sh $< > $@
js/bootstrap/js-%.h: @srcdir@/js/bootstrap/%.js .setup-directories
js/common/bootstrap/js-%.h: @srcdir@/js/common/bootstrap/%.js .setup-directories
@top_srcdir@/config/js2c.sh $< > $@
js/client/js-%.h: @srcdir@/js/client/%.js .setup-directories

View File

@ -65,12 +65,9 @@ using namespace triagens::rest;
using namespace triagens::admin;
using namespace triagens::avocado;
#include "js/bootstrap/js-modules.h"
#include "js/bootstrap/js-print.h"
#include "js/server/js-aql.h"
#include "js/server/js-json.h"
#include "js/server/js-modules.h"
#include "js/server/js-shell.h"
#include "js/common/bootstrap/js-modules.h"
#include "js/common/bootstrap/js-print.h"
#include "js/server/js-server.h"
// -----------------------------------------------------------------------------
// --SECTION-- private variables
@ -372,12 +369,9 @@ void AvocadoServer::buildApplicationServer () {
if (_startupPath.empty()) {
LOGGER_INFO << "using built-in JavaScript startup files";
StartupLoader.defineScript("bootstrap/modules.js", JS_bootstrap_modules);
StartupLoader.defineScript("bootstrap/print.js", JS_bootstrap_print);
StartupLoader.defineScript("server/modules.js", JS_server_modules);
StartupLoader.defineScript("server/aql.js", JS_server_aql);
StartupLoader.defineScript("server/json.js", JS_server_json);
StartupLoader.defineScript("server/shell.js", JS_server_shell);
StartupLoader.defineScript("common/bootstrap/modules.js", JS_common_bootstrap_modules);
StartupLoader.defineScript("common/bootstrap/print.js", JS_common_bootstrap_print);
StartupLoader.defineScript("server/server.js", JS_server_server);
}
else {
LOGGER_INFO << "using JavaScript startup files at '" << _startupPath << "'";

View File

@ -54,8 +54,8 @@ using namespace triagens::httpclient;
using namespace triagens::v8client;
using namespace triagens::avocado;
#include "js/bootstrap/js-print.h"
#include "js/bootstrap/js-modules.h"
#include "js/common/bootstrap/js-print.h"
#include "js/common/bootstrap/js-modules.h"
#include "js/client/js-client.h"
// -----------------------------------------------------------------------------
@ -950,8 +950,8 @@ int main (int argc, char* argv[]) {
// load java script from js/bootstrap/*.h files
if (StartupPath.empty()) {
StartupLoader.defineScript("bootstrap/modules.js", JS_bootstrap_modules);
StartupLoader.defineScript("bootstrap/print.js", JS_bootstrap_print);
StartupLoader.defineScript("common/bootstrap/modules.js", JS_common_bootstrap_modules);
StartupLoader.defineScript("common/bootstrap/print.js", JS_common_bootstrap_print);
StartupLoader.defineScript("client/client.js", JS_client_client);
}
else {

View File

@ -1,4 +1,4 @@
static string JS_bootstrap_modules =
static string JS_common_bootstrap_modules =
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief JavaScript server functions\n"
"///\n"

View File

@ -1,4 +1,4 @@
static string JS_bootstrap_print =
static string JS_common_bootstrap_print =
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief printing\n"
"///\n"

156
js/server/js-server.h Normal file
View File

@ -0,0 +1,156 @@
static string JS_server_server =
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief JavaScript server functions\n"
"///\n"
"/// @file\n"
"///\n"
"/// DISCLAIMER\n"
"///\n"
"/// Copyright 2011-2012 triagens GmbH, Cologne, Germany\n"
"///\n"
"/// Licensed under the Apache License, Version 2.0 (the \"License\");\n"
"/// you may not use this file except in compliance with the License.\n"
"/// You may obtain a copy of the License at\n"
"///\n"
"/// http://www.apache.org/licenses/LICENSE-2.0\n"
"///\n"
"/// Unless required by applicable law or agreed to in writing, software\n"
"/// distributed under the License is distributed on an \"AS IS\" BASIS,\n"
"/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n"
"/// See the License for the specific language governing permissions and\n"
"/// limitations under the License.\n"
"///\n"
"/// Copyright holder is triAGENS GmbH, Cologne, Germany\n"
"///\n"
"/// @author Dr. Frank Celler\n"
"/// @author Copyright 2011-2012, triAGENS GmbH, Cologne, Germany\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @page JSModuleAvocadoTOC\n"
"///\n"
"/// <ol>\n"
"/// <li>@ref JSModuleAvocadoDefineHttpSystemAction \"avocado.defineHttpSystemAction\"</li>\n"
"/// </ol>\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @page JSModuleAvocado Module \"avocado\"\n"
"///\n"
"/// The following functions are used avocadoly.\n"
"///\n"
"/// <hr>\n"
"/// @copydoc JSModuleAvocadoTOC\n"
"/// <hr>\n"
"///\n"
"/// @anchor JSModuleAvocadoDefineHttpSystemAction\n"
"/// @copydetails JS_DefineSystemAction\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"// -----------------------------------------------------------------------------\n"
"// --SECTION-- Module \"internal\"\n"
"// -----------------------------------------------------------------------------\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @addtogroup V8ModuleInternal\n"
"/// @{\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief internal module\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"ModuleCache[\"/internal\"].exports.db = db;\n"
"ModuleCache[\"/internal\"].exports.edges = edges;\n"
"ModuleCache[\"/internal\"].exports.AvocadoCollection = AvocadoCollection;\n"
"ModuleCache[\"/internal\"].exports.AvocadoEdgesCollection = AvocadoEdgesCollection;\n"
"\n"
"if (typeof SYS_DEFINE_ACTION === \"undefined\") {\n"
" ModuleCache[\"/internal\"].exports.defineAction = function() {\n"
" console.error(\"SYS_DEFINE_ACTION not available\");\n"
" }\n"
"}\n"
"else {\n"
" ModuleCache[\"/internal\"].exports.defineAction = SYS_DEFINE_ACTION;\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @}\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"// -----------------------------------------------------------------------------\n"
"// --SECTION-- Module \"avocado\"\n"
"// -----------------------------------------------------------------------------\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @addtogroup V8ModuleAvocado\n"
"/// @{\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief avocado module\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"ModuleCache[\"/avocado\"] = new Module(\"/avocado\");\n"
"\n"
"if (typeof defineSystemAction == \"function\") {\n"
" ModuleCache[\"/avocado\"].exports.defineHttpSystemAction = defineSystemAction;\n"
"}\n"
"\n"
"avocado = ModuleCache[\"/avocado\"].exports;\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @}\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"// -----------------------------------------------------------------------------\n"
"// --SECTION-- Module \"simple-query\"\n"
"// -----------------------------------------------------------------------------\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @addtogroup V8ModuleSimpleQuery\n"
"/// @{\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"try {\n"
" require(\"simple-query\");\n"
"}\n"
"catch (err) {\n"
" console.error(\"while loading 'simple-query' module: %s\", err);\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @}\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"// -----------------------------------------------------------------------------\n"
"// --SECTION-- PRINT\n"
"// -----------------------------------------------------------------------------\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @addtogroup V8Shell\n"
"/// @{\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @brief prints a shaped json\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"ShapedJson.prototype._PRINT = function(seen, path, names) {\n"
" if (this instanceof ShapedJson) {\n"
" PRINT_OBJECT(this, seen, path, names);\n"
" }\n"
" else {\n"
" internal.output(this.toString());\n"
" }\n"
"}\n"
"\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"/// @}\n"
"////////////////////////////////////////////////////////////////////////////////\n"
"\n"
"// Local Variables:\n"
"// mode: outline-minor\n"
"// outline-regexp: \"^\\\\(/// @brief\\\\|/// @addtogroup\\\\|// --SECTION--\\\\|/// @page\\\\|/// @}\\\\)\"\n"
"// End:\n"
;

154
js/server/server.js Normal file
View File

@ -0,0 +1,154 @@
////////////////////////////////////////////////////////////////////////////////
/// @brief JavaScript server functions
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2011-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.
/// 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-2012, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @page JSModuleAvocadoTOC
///
/// <ol>
/// <li>@ref JSModuleAvocadoDefineHttpSystemAction "avocado.defineHttpSystemAction"</li>
/// </ol>
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @page JSModuleAvocado Module "avocado"
///
/// The following functions are used avocadoly.
///
/// <hr>
/// @copydoc JSModuleAvocadoTOC
/// <hr>
///
/// @anchor JSModuleAvocadoDefineHttpSystemAction
/// @copydetails JS_DefineSystemAction
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- Module "internal"
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup V8ModuleInternal
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief internal module
////////////////////////////////////////////////////////////////////////////////
ModuleCache["/internal"].exports.db = db;
ModuleCache["/internal"].exports.edges = edges;
ModuleCache["/internal"].exports.AvocadoCollection = AvocadoCollection;
ModuleCache["/internal"].exports.AvocadoEdgesCollection = AvocadoEdgesCollection;
if (typeof SYS_DEFINE_ACTION === "undefined") {
ModuleCache["/internal"].exports.defineAction = function() {
console.error("SYS_DEFINE_ACTION not available");
}
}
else {
ModuleCache["/internal"].exports.defineAction = SYS_DEFINE_ACTION;
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- Module "avocado"
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup V8ModuleAvocado
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief avocado module
////////////////////////////////////////////////////////////////////////////////
ModuleCache["/avocado"] = new Module("/avocado");
if (typeof defineSystemAction == "function") {
ModuleCache["/avocado"].exports.defineHttpSystemAction = defineSystemAction;
}
avocado = ModuleCache["/avocado"].exports;
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- Module "simple-query"
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup V8ModuleSimpleQuery
/// @{
////////////////////////////////////////////////////////////////////////////////
try {
require("simple-query");
}
catch (err) {
console.error("while loading 'simple-query' module: %s", err);
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// --SECTION-- PRINT
// -----------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////////
/// @addtogroup V8Shell
/// @{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief prints a shaped json
////////////////////////////////////////////////////////////////////////////////
ShapedJson.prototype._PRINT = function(seen, path, names) {
if (this instanceof ShapedJson) {
PRINT_OBJECT(this, seen, path, names);
}
else {
internal.output(this.toString());
}
}
////////////////////////////////////////////////////////////////////////////////
/// @}
////////////////////////////////////////////////////////////////////////////////
// Local Variables:
// mode: outline-minor
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
// End: