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" "var internal = require(\"internal\");\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- printing\n" "// -----------------------------------------------------------------------------\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @addtogroup V8Shell\n" "/// @{\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief prints objects to standard output\n" "///\n" "/// @FUN{print(@FA{arg1}, @FA{arg2}, @FA{arg3}, ...)}\n" "///\n" "/// Only available in shell mode.\n" "///\n" "/// Prints the arguments. If an argument is an object having a\n" "/// function @FN{PRINT}, then this function is called. Otherwise @FN{toJson} is\n" "/// used. A final newline is printed\n" "///\n" "/// @verbinclude fluent40\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "function print () {\n" " for (var i = 0; i < arguments.length; ++i) {\n" " if (0 < i) {\n" " internal.output(\" \");\n" " }\n" "\n" " PRINT(arguments[i], [], \"~\", []);\n" " }\n" "\n" " internal.output(\"\\n\");\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief prints objects to standard output without a new-line\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "function PRINT (value, seen, path, names) {\n" " var p;\n" "\n" " if (seen === undefined) {\n" " seen = [];\n" " names = [];\n" " }\n" "\n" " p = seen.indexOf(value);\n" "\n" " if (0 <= p) {\n" " internal.output(names[p]);\n" " }\n" " else {\n" " seen.push(value);\n" " names.push(path);\n" "\n" " if (value instanceof Object) {\n" " if ('PRINT' in value) {\n" " value.PRINT(seen, path, names);\n" " }\n" " else if (value.__proto__ === Object.prototype) {\n" " PRINT_OBJECT(value, seen, path, names);\n" " }\n" " else if ('toString' in value) {\n" " internal.output(value.toString());\n" " }\n" " else {\n" " PRINT_OBJECT(value, seen, path, names);\n" " }\n" " }\n" " else if (value === undefined) {\n" " internal.output(\"undefined\");\n" " }\n" " else {\n" " internal.output(\"\" + value);\n" " }\n" " }\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- Array\n" "// -----------------------------------------------------------------------------\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @addtogroup V8Shell\n" "/// @{\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief JSON representation of an array\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Array.prototype.PRINT = function(seen, path, names) {\n" " if (this.length == 0) {\n" " internal.output(\"[ ]\");\n" " }\n" " else {\n" " var sep = \" \";\n" "\n" " internal.output(\"[\");\n" "\n" " for (var i = 0; i < this.length; i++) {\n" " internal.output(sep);\n" " PRINT(this[i], seen, path + \"[\" + i + \"]\", names);\n" " sep = \", \";\n" " }\n" "\n" " internal.output(\" ]\");\n" " }\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- Function\n" "// -----------------------------------------------------------------------------\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @addtogroup V8Shell\n" "/// @{\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief prints a function\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "Function.prototype.PRINT = function() {\n" " internal.output(this.toString());\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- Object\n" "// -----------------------------------------------------------------------------\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @addtogroup V8Shell\n" "/// @{\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @brief string representation of an object\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "function PRINT_OBJECT (object, seen, path, names) {\n" " var sep = \" \";\n" "\n" " internal.output(\"{\");\n" "\n" " for (var k in object) {\n" " if (object.hasOwnProperty(k)) {\n" " var val = object[k];\n" "\n" " internal.output(sep, k, \" : \");\n" " PRINT(val, seen, path + \"[\" + k + \"]\", names);\n" " sep = \", \";\n" " }\n" " }\n" "\n" " internal.output(\" }\");\n" "}\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @}\n" "////////////////////////////////////////////////////////////////////////////////\n" "\n" "// -----------------------------------------------------------------------------\n" "// --SECTION-- AvocadoQuery\n" "// -----------------------------------------------------------------------------\n" "\n" "////////////////////////////////////////////////////////////////////////////////\n" "/// @addtogroup V8Shell\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" " internal.output(JSON.stringify(this.next()), \"\\n\");\n" " }\n" "\n" " if (this.hasNext()) {\n" " internal.output(\"...more results...\");\n" " }\n" "\n" " it = this;\n" " }\n" " catch (e) {\n" " internal.output(\"encountered error while printing: \" + e);\n" " }\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" ;