mirror of https://gitee.com/bigwinds/arangodb
361 lines
14 KiB
C
361 lines
14 KiB
C
static string JS_shell =
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief JavaScript server functions\n"
|
|
"///\n"
|
|
"/// @file\n"
|
|
"///\n"
|
|
"/// DISCLAIMER\n"
|
|
"///\n"
|
|
"/// Copyright by triAGENS GmbH - All rights reserved.\n"
|
|
"///\n"
|
|
"/// The Programs (which include both the software and documentation)\n"
|
|
"/// contain proprietary information of triAGENS GmbH; they are\n"
|
|
"/// provided under a license agreement containing restrictions on use and\n"
|
|
"/// disclosure and are also protected by copyright, patent and other\n"
|
|
"/// intellectual and industrial property laws. Reverse engineering,\n"
|
|
"/// disassembly or decompilation of the Programs, except to the extent\n"
|
|
"/// required to obtain interoperability with other independently created\n"
|
|
"/// software or as specified by law, is prohibited.\n"
|
|
"///\n"
|
|
"/// The Programs are not intended for use in any nuclear, aviation, mass\n"
|
|
"/// transit, medical, or other inherently dangerous applications. It shall\n"
|
|
"/// be the licensee's responsibility to take all appropriate fail-safe,\n"
|
|
"/// backup, redundancy, and other measures to ensure the safe use of such\n"
|
|
"/// applications if the Programs are used for such purposes, and triAGENS\n"
|
|
"/// GmbH disclaims liability for any damages caused by such use of\n"
|
|
"/// the Programs.\n"
|
|
"///\n"
|
|
"/// This software is the confidential and proprietary information of\n"
|
|
"/// triAGENS GmbH. You shall not disclose such confidential and\n"
|
|
"/// proprietary information and shall use it only in accordance with the\n"
|
|
"/// terms of the license agreement you entered into with triAGENS GmbH.\n"
|
|
"///\n"
|
|
"/// Copyright holder is triAGENS GmbH, Cologne, Germany\n"
|
|
"///\n"
|
|
"/// @author Dr. Frank Celler\n"
|
|
"/// @author Copyright 2011, triAGENS GmbH, Cologne, Germany\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"// --SECTION-- Array\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @addtogroup V8Shell V8 Shell\n"
|
|
"/// @{\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief JSON representation of an array\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"Array.prototype.print = function() {\n"
|
|
" if (this.length == 0) {\n"
|
|
" output(\"[ ]\");\n"
|
|
" }\n"
|
|
" else {\n"
|
|
" var sep = \" \";\n"
|
|
"\n"
|
|
" output(\"[\");\n"
|
|
"\n"
|
|
" for (var i = 0; i < this.length; i++) {\n"
|
|
" output(sep);\n"
|
|
" print(this[i]);\n"
|
|
" sep = \", \";\n"
|
|
" }\n"
|
|
"\n"
|
|
" output(\" ]\");\n"
|
|
" }\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @}\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"// --SECTION-- Function\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @addtogroup V8Shell V8 Shell\n"
|
|
"/// @{\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief JSON representation of a function\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"Function.prototype.print = function() {\n"
|
|
" output(this.toString());\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @}\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"// --SECTION-- Object\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @addtogroup V8Shell V8 Shell\n"
|
|
"/// @{\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief string representation of an object\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"Object.prototype.print = function() {\n"
|
|
" var sep = \" \";\n"
|
|
"\n"
|
|
" output(\"{\");\n"
|
|
"\n"
|
|
" for (var k in this) {\n"
|
|
" if (this.hasOwnProperty(k)) {\n"
|
|
" var val = this[k];\n"
|
|
"\n"
|
|
" output(sep, k, \" : \");\n"
|
|
" print(val);\n"
|
|
" sep = \", \";\n"
|
|
" }\n"
|
|
" }\n"
|
|
"\n"
|
|
" output(\" }\");\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @}\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"// --SECTION-- AvocadoCollection\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @addtogroup V8Shell V8 Shell\n"
|
|
"/// @{\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief prints a collection\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"AvocadoCollection.prototype.print = function() {\n"
|
|
" if (this instanceof AvocadoCollection) {\n"
|
|
" status = this.status();\n"
|
|
"\n"
|
|
" if (status == 1) {\n"
|
|
" output(\"[new born collection \", toJson(this._name), \"]\");\n"
|
|
" }\n"
|
|
" else if (status == 2) {\n"
|
|
" output(\"[unloaded collection \", toJson(this._name), \"]\");\n"
|
|
" }\n"
|
|
" else if (status == 3) {\n"
|
|
" output(\"[collection \", toJson(this._name), \"]\");\n"
|
|
" }\n"
|
|
" else {\n"
|
|
" output(\"[corrupted collection \", toJson(this._name), \"]\");\n"
|
|
" }\n"
|
|
" }\n"
|
|
" else {\n"
|
|
" output(this.toString(), \"\\n\");\n"
|
|
" }\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief string representation of a collection\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"AvocadoCollection.prototype.toString = function() {\n"
|
|
" var status;\n"
|
|
"\n"
|
|
" if (this instanceof AvocadoCollection) {\n"
|
|
" status = this.status();\n"
|
|
"\n"
|
|
" if (status == 1) {\n"
|
|
" return \"[new born collection at \" + toJson(this._name) + \"]\";\n"
|
|
" }\n"
|
|
" else if (status == 2) {\n"
|
|
" return \"[unloaded collection at \" + toJson(this._name) + \"]\";\n"
|
|
" }\n"
|
|
" else if (status == 3) {\n"
|
|
" return \"[collection at \" + toJson(this._name) + \"]\";\n"
|
|
" }\n"
|
|
" else {\n"
|
|
" return \"[corrupted collection at \" + toJson(this._name) + \"]\";\n"
|
|
" }\n"
|
|
" }\n"
|
|
" else {\n"
|
|
" return \"[object]\";\n"
|
|
" }\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @}\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"// --SECTION-- AvocadoDatabase\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @addtogroup V8Shell V8 Shell\n"
|
|
"/// @{\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief prints the vocbase\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"AvocadoDatabase.prototype.print = function() {\n"
|
|
" if (this instanceof AvocadoDatabase) {\n"
|
|
" output(\"[vocbase at \", toJson(this._path), \"]\");\n"
|
|
" }\n"
|
|
" else {\n"
|
|
" output(this.toString(), \"\\n\");\n"
|
|
" }\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief string representation of a vocbase\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"AvocadoDatabase.prototype.toString = function() {\n"
|
|
" if (this instanceof AvocadoDatabase) {\n"
|
|
" return \"[vocbase at \" + toJson(this._path) + \"]\";\n"
|
|
" }\n"
|
|
" else {\n"
|
|
" return \"[object]\";\n"
|
|
" }\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @}\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"// --SECTION-- AvocadoEdges\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @addtogroup V8Shell V8 Shell\n"
|
|
"/// @{\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief prints the edges base\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"AvocadoEdges.prototype.print = function() {\n"
|
|
" if (this instanceof AvocadoEdges) {\n"
|
|
" output(\"[edges at \", toJson(this._path), \"]\");\n"
|
|
" }\n"
|
|
" else {\n"
|
|
" output(this.toString(), \"\\n\");\n"
|
|
" }\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief string representation of a vocbase\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"AvocadoEdges.prototype.toString = function() {\n"
|
|
" if (this instanceof AvocadoEdges) {\n"
|
|
" return \"[edges at \" + toJson(this._path) + \"]\";\n"
|
|
" }\n"
|
|
" else {\n"
|
|
" return \"[object]\";\n"
|
|
" }\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @}\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"// --SECTION-- AvocadoEdgesCollection\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @addtogroup V8Shell V8 Shell\n"
|
|
"/// @{\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief prints an edges collection\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"AvocadoEdgesCollection.prototype.print = function() {\n"
|
|
" if (this instanceof AvocadoEdgesCollection) {\n"
|
|
" output(\"[edges collection \", toJson(this._name), \"]\");\n"
|
|
" }\n"
|
|
" else {\n"
|
|
" output(this.toString(), \"\\n\");\n"
|
|
" }\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @}\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"// --SECTION-- AvocadoQuery\n"
|
|
"// -----------------------------------------------------------------------------\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @addtogroup V8Shell V8 Shell\n"
|
|
"/// @{\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief global variable holding the current printed query\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"var it = undefined;\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief number of results to print\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"var queryLimit = 20;\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @brief prints a query\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"AvocadoQuery.prototype.print = function() {\n"
|
|
" if (this instanceof AvocadoQuery) {\n"
|
|
" var count = 0;\n"
|
|
"\n"
|
|
" try {\n"
|
|
" while (this.hasNext() && count++ < queryLimit) {\n"
|
|
" print(this.next());\n"
|
|
" output(\"\\n\");\n"
|
|
" }\n"
|
|
"\n"
|
|
" if (this.hasNext()) {\n"
|
|
" output(\"...more results...\");\n"
|
|
" }\n"
|
|
"\n"
|
|
" it = this;\n"
|
|
" }\n"
|
|
" catch (e) {\n"
|
|
" output(\"encountered error while printing: \" + e);\n"
|
|
" }\n"
|
|
" }\n"
|
|
" else {\n"
|
|
" output(this.toString(), \"\\n\");\n"
|
|
" }\n"
|
|
"}\n"
|
|
"\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"/// @}\n"
|
|
"////////////////////////////////////////////////////////////////////////////////\n"
|
|
"\n"
|
|
"// Local Variables:\n"
|
|
"// mode: outline-minor\n"
|
|
"// outline-regexp: \"^\\\\(/// @brief\\\\|/// @addtogroup\\\\|// --SECTION--\\\\)\"\n"
|
|
"// End:\n"
|
|
;
|