text: /*
     This source is part of libobdref
  
     Copyright (C) 2012,2013 Preet Desai (preet.desai@gmail.com)
  
     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.
  */
  
  const char * globals_js =
          "\n"
          "// ================================================================ //\n"
          "// ================================================================ //\n"
          "\n"
          "function LiteralDataObj()\n"
          "{\n"
          "    this.value = false;\n"
          "    this.valueIfFalse = \"\";\n"
          "    this.valueIfTrue = \"\";\n"
          "    this.property = \"\";\n"
          "}\n"
          "\n"
          "function NumericalDataObj()\n"
          "{\n"
          "    this.value = 0;\n"
          "    this.min = 0;\n"
          "    this.max = 0;\n"
          "    this.units = \"\";\n"
          "    this.property = \"\";\n"
          "}\n"
          "\n"
          "function ListDataObj()\n"
          "{\n"
          "    this.listData = [];\n"
          "\n"
          "    this.appendData = function(newData)\n"
          "    {   this.listData.push(newData);   }\n"
          "\n"
          "    this.clearData = function()\n"
          "    {   this.listData.length = 0;   }\n"
          "}\n"
          "\n"
          "var global_list_num_data = new ListDataObj();\n"
          "\n"
          "var global_list_lit_data = new ListDataObj();\n"
          "\n"
          "function saveNumericalData(numDataObj)\n"
          "{   global_list_num_data.appendData(numDataObj);   }\n"
          "\n"
          "function saveLiteralData(litDataObj)\n"
          "{   global_list_lit_data.appendData(litDataObj);   }\n"
          "\n"
          "function __private_get_num_data()\n"
          "{\n"
          "   return global_list_num_data.listData;\n"
          "}\n"
          "\n"
          "function __private_get_lit_data()\n"
          "{\n"
          "   return global_list_lit_data.listData;\n"
          "}\n"
          "\n"
          "// ================================================================ //\n"
          "// ================================================================ //\n"
          "\n"
          "function DataBytesObj()\n"
          "{\n"
          "    this.bytes = [];\n"
          "\n"
          "    this.BYTE = function(bytePos)   {\n"
          "        return this.bytes[bytePos];\n"
          "    }\n"
          "\n"
          "    this.BIT = function(bytePos,bitPos)   {\n"
          "        var byteVal = this.bytes[bytePos];\n"
          "        if((byteVal & (1 << bitPos)) > 0)   {\n"
          "            return 1;\n"
          "        }\n"
          "        return 0;\n"
          "    }\n"
          "\n"
          "    this.LENGTH = function()\n"
          "    {   return this.bytes.length;   }\n"
          "}\n"
          "\n"
          "function MessageDataObj()\n"
          "{\n"
          "    this.listHeaderBytes = [];\n"
          "    this.listDataBytes = [];\n"
          "\n"
          "    this.setListHeaderBytes = function(list_headerbytes)   {\n"
          "        for(var i=0; i < list_headerbytes.length; i++)   {\n"
          "            var headerBytes = new DataBytesObj();\n"
          "            headerBytes.bytes = list_headerbytes[i];\n"
          "            this.listHeaderBytes.push(headerBytes);\n"
          "        }\n"
          "    }\n"
          "\n"
          "    this.setListDataBytes = function(list_databytes)   {\n"
          "        for(var i=0; i < list_databytes.length; i++)   {\n"
          "            var dataBytes = new DataBytesObj();\n"
          "            dataBytes.bytes = list_databytes[i];\n"
          "            this.listDataBytes.push(dataBytes);\n"
          "        }\n"
          "    }\n"
          "    \n"
          "    this.HEADER = function(headerIdx)   {\n"
          "       return this.listHeaderBytes[headerIdx];\n"
          "    }\n"
          "    \n"
          "    this.DATA = function(dataIdx)   {\n"
          "       return this.listDataBytes[dataIdx];\n"
          "    }\n"
          "}\n"
          "\n"
          "function ParameterObj()\n"
          "{\n"
          "    this.listMessageData = [];\n"
          "\n"
          "    this.appendMessageData = function(msg)   {\n"
          "        this.listMessageData.push(msg);\n"
          "    }\n"
          "\n"
          "    this.clearAll = function()   {\n"
          "        this.listMessageData.length = 0;\n"
          "    }\n"
          "}\n"
          "\n"
          "var global_param = new ParameterObj();\n"
          "\n"
          "function REQ(idx)   {\n"
          "    return global_param.listMessageData[idx];\n"
          "}\n"
          "\n"
          "function NUM_REQ()   {\n"
          "   return global_param.listMessageData.length;\n"
          "}\n"
          "\n"
          "function NUM_RESP(idx)   {\n"
          "   return REQ(idx).listDataBytes.length;\n"
          "}\n"
          "\n"
          "function HEADER(idx)   {\n"
          "    return REQ(0).listHeaderBytes[idx];\n"
          "}\n"
          "\n"
          "function DATA(idx)   {\n"
          "    return REQ(0).listDataBytes[idx];\n"
          "}\n"
          "\n"
          "function BYTE(bytePos)   {\n"
          "    return DATA(0).BYTE(bytePos);\n"
          "}\n"
          "\n"
          "function BIT(bytePos,bitPos)   {\n"
          "    return DATA(0).BIT(bytePos,bitPos);\n"
          "}\n"
          "\n"
          "function LENGTH()   {\n"
          "    return DATA(0).LENGTH();\n"
          "}\n"
          "\n"
          "// ================================================================ //\n"
          "// ================================================================ //\n"
          "\n"
          "// where list_databytes is a 2d array that looks like:\n"
          "// list_databytes[0]: 0xAA 0xBB 0xCC ...\n"
          "// list_databytes[1]: 0xDD 0xEE 0xFF ...\n"
          "// list_databytes[2]: 0x00 0x11 0x22 ... etc\n"
          "function __private__add_list_databytes(list_databytes)\n"
          "{\n"
          "    var msg = new MessageDataObj();\n"
          "    msg.setListDataBytes(list_databytes);\n"
          "    global_param.appendMessageData(msg);\n"
          "}\n"
          "\n"
          "function __private__add_msg_data(list_headerbytes,list_databytes)\n"
          "{\n"
          "    var msg = new MessageDataObj();\n"
          "    msg.setListHeaderBytes(list_headerbytes);\n"
          "    msg.setListDataBytes(list_databytes);\n"
          "    global_param.appendMessageData(msg);\n"
          "}\n"
          "\n"
          "function __private__clear_all_data()\n"
          "{\n"
          "   global_list_num_data.clearData();\n"
          "   global_list_lit_data.clearData();\n"
          "   global_param.clearAll();\n"
          "}\n"
          "\n"
          "// ================================================================ //\n"
          "// ================================================================ //\n"
          "";
  