text:
package com.amazonaws.services.xray.model;

import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;

/**
 *

 * A configuration document that specifies encryption configuration settings.
 *

 *
 * @see AWS API
 *      Documentation
 */
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class EncryptionConfig implements Serializable, Cloneable, StructuredPojo {

    /**
     *

     * The ID of the KMS key used for encryption, if applicable.
     *

     */
    private String keyId;
    /**
     *

     * The encryption status. While the status is UPDATING, X-Ray may encrypt data with a combination of
     * the new and old settings.
     *

     */
    private String status;
    /**
     *

     * The type of encryption. Set to KMS for encryption with KMS keys. Set to NONE for
     * default encryption.
     *

     */
    private String type;

    /**
     *

     * The ID of the KMS key used for encryption, if applicable.
     *

     *
     * @param keyId
     *        The ID of the KMS key used for encryption, if applicable.
     */

    public void setKeyId(String keyId) {
        this.keyId = keyId;
    }

    /**
     *

     * The ID of the KMS key used for encryption, if applicable.
     *

     *
     * @return The ID of the KMS key used for encryption, if applicable.
     */

    public String getKeyId() {
        return this.keyId;
    }

    /**
     *

     * The ID of the KMS key used for encryption, if applicable.
     *

     *
     * @param keyId
     *        The ID of the KMS key used for encryption, if applicable.
     * @return Returns a reference to this object so that method calls can be chained together.
     */

    public EncryptionConfig withKeyId(String keyId) {
        setKeyId(keyId);
        return this;
    }

    /**
     *

     * The encryption status. While the status is UPDATING, X-Ray may encrypt data with a combination of
     * the new and old settings.
     *

     *
     * @param status
     *        The encryption status. While the status is UPDATING, X-Ray may encrypt data with a
     *        combination of the new and old settings.
     * @see EncryptionStatus
     */

    public void setStatus(String status) {
        this.status = status;
    }

    /**
     *

     * The encryption status. While the status is UPDATING, X-Ray may encrypt data with a combination of
     * the new and old settings.
     *

     *
     * @return The encryption status. While the status is UPDATING, X-Ray may encrypt data with a
     *         combination of the new and old settings.
     * @see EncryptionStatus
     */

    public String getStatus() {
        return this.status;
    }

    /**
     *

     * The encryption status. While the status is UPDATING, X-Ray may encrypt data with a combination of
     * the new and old settings.
     *

     *
     * @param status
     *        The encryption status. While the status is UPDATING, X-Ray may encrypt data with a
     *        combination of the new and old settings.
     * @return Returns a reference to this object so that method calls can be chained together.
     * @see EncryptionStatus
     */

    public EncryptionConfig withStatus(String status) {
        setStatus(status);
        return this;
    }

    /**
     *

     * The encryption status. While the status is UPDATING, X-Ray may encrypt data with a combination of
     * the new and old settings.
     *

     *
     * @param status
     *        The encryption status. While the status is UPDATING, X-Ray may encrypt data with a
     *        combination of the new and old settings.
     * @return Returns a reference to this object so that method calls can be chained together.
     * @see EncryptionStatus
     */

    public EncryptionConfig withStatus(EncryptionStatus status) {
        this.status = status.toString();
        return this;
    }

    /**
     *

     * The type of encryption. Set to KMS for encryption with KMS keys. Set to NONE for
     * default encryption.
     *

     *
     * @param type
     *        The type of encryption. Set to KMS for encryption with KMS keys. Set to NONE for
     *        default encryption.
     * @see EncryptionType
     */

    public void setType(String type) {
        this.type = type;
    }

    /**
     *

     * The type of encryption. Set to KMS for encryption with KMS keys. Set to NONE for
     * default encryption.
     *

     *
     * @return The type of encryption. Set to KMS for encryption with KMS keys. Set to NONE
     *         for default encryption.
     * @see EncryptionType
     */

    public String getType() {
        return this.type;
    }

    /**
     *

     * The type of encryption. Set to KMS for encryption with KMS keys. Set to NONE for
     * default encryption.
     *

     *
     * @param type
     *        The type of encryption. Set to KMS for encryption with KMS keys. Set to NONE for
     *        default encryption.
     * @return Returns a reference to this object so that method calls can be chained together.
     * @see EncryptionType
     */

    public EncryptionConfig withType(String type) {
        setType(type);
        return this;
    }

    /**
     *

     * The type of encryption. Set to KMS for encryption with KMS keys. Set to NONE for
     * default encryption.
     *

     *
     * @param type
     *        The type of encryption. Set to KMS for encryption with KMS keys. Set to NONE for
     *        default encryption.
     * @return Returns a reference to this object so that method calls can be chained together.
     * @see EncryptionType
     */

    public EncryptionConfig withType(EncryptionType type) {
        this.type = type.toString();
        return this;
    }

    /**
     * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
     * redacted from this string using a placeholder value.
     *
     * @return A string representation of this object.
     *
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("{");
        if (getKeyId() != null)
            sb.append("KeyId: ").append(getKeyId()).append(",");
        if (getStatus() != null)
            sb.append("Status: ").append(getStatus()).append(",");
        if (getType() != null)
            sb.append("Type: ").append(getType());
        sb.append("}");
        return sb.toString();
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;

        if (obj instanceof EncryptionConfig == false)
            return false;
        EncryptionConfig other = (EncryptionConfig) obj;
        if (other.getKeyId() == null ^ this.getKeyId() == null)
            return false;
        if (other.getKeyId() != null && other.getKeyId().equals(this.getKeyId()) == false)
            return false;
        if (other.getStatus() == null ^ this.getStatus() == null)
            return false;
        if (other.getStatus() != null && other.getStatus().equals(this.getStatus()) == false)
            return false;
        if (other.getType() == null ^ this.getType() == null)
            return false;
        if (other.getType() != null && other.getType().equals(this.getType()) == false)
            return false;
        return true;
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int hashCode = 1;

        hashCode = prime * hashCode + ((getKeyId() == null) ? 0 : getKeyId().hashCode());
        hashCode = prime * hashCode + ((getStatus() == null) ? 0 : getStatus().hashCode());
        hashCode = prime * hashCode + ((getType() == null) ? 0 : getType().hashCode());
        return hashCode;
    }

    @Override
    public EncryptionConfig clone() {
        try {
            return (EncryptionConfig) super.clone();
        } catch (CloneNotSupportedException e) {
            throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
        }
    }

    @com.amazonaws.annotation.SdkInternalApi
    @Override
    public void marshall(ProtocolMarshaller protocolMarshaller) {
        com.amazonaws.services.xray.model.transform.EncryptionConfigMarshaller.getInstance().marshall(this, protocolMarshaller);
    }
}


text:
<?php
/**
 * Author: Maxim
 * Date: 20/07/2014
 * Time: 21:48
 * Property of MCSuite
 */

namespace Maxim\ModularBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;

class Server
{
    protected $id;

    protected $name;
    protected $ip;
    protected $port;
    protected $user;

    protected $createdAt;
    protected $updatedAt;

    protected $hub = false;
    protected $parent;
    protected $subServers;

    public function __construct($name = NULL, $user = NULL)
    {
        $this->subServers = new ArrayCollection();
        $this->name = $name;
        $this->user = $user;
    }

    public function prePersist()
    {
        $this->createdAt = new \DateTime();
        $this->updatedAt = new \DateTime();
    }

    public function preUpdate()
    {
        $this->updatedAt = new \DateTime();
    }

    /**
     * @return mixed
     */
    public function getCreatedAt()
    {
        return $this->createdAt;
    }

    /**
     * @param mixed $createdAt
     */
    public function setCreatedAt($createdAt)
    {
        $this->createdAt = $createdAt;
    }

    /**
     * @return mixed
     */
    public function isHub()
    {
        return $this->hub;
    }

    /**
     * @param mixed $hub
     */
    public function setHub($hub)
    {
        $this->hub = $hub;
    }

    /**
     * @return mixed
     */
    public function getIp()
    {
        return $this->ip;
    }

    /**
     * @param mixed $ip
     */
    public function setIp($ip)
    {
        $this->ip = $ip;
    }

    /**
     * @return mixed
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @param mixed $name
     */
    public function setName($name)
    {
        $this->name = $name;
    }

    /**
     * @return mixed
     */
    public function getParent()
    {
        return $this->parent;
    }

    /**
     * @param mixed $parent
     */
    public function setParent($parent)
    {
        $this->parent = $parent;
    }

    /**
     * @return mixed
     */
    public function getPort()
    {
        return $this->port;
    }

    /**
     * @param mixed $port
     */
    public function setPort($port)
    {
        $this->port = $port;
    }

    /**
     * @return mixed
     */
    public function getSubServers()
    {
        return $this->subServers;
    }

    /**
     * @param mixed $subServers
     */
    public function setSubServers($subServers)
    {
        $this->subServers = $subServers;
    }

    public function addSubServer($subServer)
    {
        $this->subServers->add($subServer);
    }

    /**
     * @return mixed
     */
    public function getUpdatedAt()
    {
        return $this->updatedAt;
    }

    /**
     * @param mixed $updatedAt
     */
    public function setUpdatedAt($updatedAt)
    {
        $this->updatedAt = $updatedAt;
    }

    /**
     * @return mixed
     */
    public function getUser()
    {
        return $this->user;
    }

    /**
     * @param mixed $user
     */
    public function setUser($user)
    {
        $this->user = $user;
    }

    /**
     * @return mixed
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * @param mixed $id
     */
    public function setId($id)
    {
        $this->id = $id;
    }

}

redpajama_set_name: RedPajamaGithub


text:
<?php
class Admin_Driver extends CI_Driver_Library
{
    public function sessionVali()
    {
        if (array_key_exists('permission', $_SESSION)) {
            return $_SESSION['permission'];
        } else {
            return 0;
        }
    }

    public function sessionExist()
    {
        if (array_key_exists('permission', $_SESSION)) {
            return 1;
        } else {
            return 0;
        }
    }
}


text:
namespace boost {
template<class T>
class shared_ptr;

namespace serialization {
    class extended_type_info;
} // namespace serialization

namespace archive {
namespace detail {

class basic_iarchive_impl;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iserializer;
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_pointer_iserializer;
//////////////////////////////////////////////////////////////////////
// class basic_iarchive - read serialized objects from a input stream
class BOOST_ARCHIVE_DECL(BOOST_PP_EMPTY()) basic_iarchive
{
    friend class basic_iarchive_impl;
    // hide implementation of this class to minimize header conclusion
    // in client code. I couldn't used scoped pointer with borland
    // boost::scoped_ptr<basic_iarchive_impl> pimpl;
    basic_iarchive_impl * pimpl;

    virtual void vload(version_type &t) =  0;
    virtual void vload(object_id_type &t) =  0;
    virtual void vload(class_id_type &t) =  0;
    virtual void vload(class_id_optional_type &t) = 0;
    virtual void vload(class_name_type &t) = 0;
    virtual void vload(tracking_type &t) = 0;
protected:
    basic_iarchive(unsigned int flags);
    // account for bogus gcc warning
    #if defined(__GNUC__)
    virtual
    #endif
    ~basic_iarchive();
public:
    // note: NOT part of the public API.
    void next_object_pointer(void *t);
    void register_basic_serializer(
        const basic_iserializer & bis
    );
    void load_object(
        void *t,
        const basic_iserializer & bis
    );
    const basic_pointer_iserializer *
    load_pointer(
        void * & t,
        const basic_pointer_iserializer * bpis_ptr,
        const basic_pointer_iserializer * (*finder)(
            const boost::serialization::extended_type_info & eti
        )
    );
    // real public API starts here
    void
    set_library_version(unsigned int archive_library_version);
    unsigned int
    get_library_version() const;
    unsigned int
    get_flags() const;
    void
    reset_object_address(const void * new_address, const void * old_address);
    void
    delete_created_pointers();
};

} // namespace detail
} // namespace archive
} // namespace boost

// required by smart_cast for compilers not implementing
// partial template specialization
BOOST_BROKEN_COMPILER_TYPE_TRAITS_SPECIALIZATION(
    boost::archive::detail::basic_iarchive
)

#include <boost/archive/detail/abi_suffix.hpp> // pops abi_suffix.hpp pragmas

#endif //BOOST_ARCHIVE_DETAIL_BASIC_IARCHIVE_HPP


text:
using System;
using Famoser.SyncApi.Enums;
using Famoser.SyncApi.Models.Interfaces;

namespace Famoser.Bookmarked.Business.Entity
{
    public class DebugSyncModel : ISyncActionInformation
    {
        public void SetSyncActionResult(SyncActionError result)
        {
            result.ToString();
        }

        public void SetSyncActionException(Exception exception)
        {
            exception.ToString();
        }
    }
}


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Statistics of root in UD_Old_Church_Slavonic</title>
    <link rel="root" href=""/>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="../../css/jquery-ui-redmond.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style-vis.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/hint.css"/>

          home

          edit page
          issue tracker

          <gcse:search></gcse:search>

        This page pertains to UD version 2.

            It appears that you have Javascript disabled.
            Please consider enabling Javascript for this page to see the visualizations.

Treebank Statistics: UD_Old_Church_Slavonic: Relations: root

This relation is universal.

6337 nodes (11%) are attached to their parents as root.

6337 instances of root (100%) are left-to-right (parent precedes child).
Average distance between parent and child is 3.69701751617485.

The following 10 pairs of parts of speech are connected with root: -<tt>VERB</tt> (6092; 96% instances), -<tt>ADJ</tt> (67; 1% instances), -<tt>NOUN</tt> (58; 1% instances), -<tt>CCONJ</tt> (30; 0% instances), -<tt>INTJ</tt> (29; 0% instances), -<tt>ADV</tt> (28; 0% instances), -<tt>NUM</tt> (10; 0% instances), -<tt>PRON</tt> (10; 0% instances), -<tt>PROPN</tt> (9; 0% instances), -<tt>X</tt> (4; 0% instances).

# visual-style 2	bgColor:blue
# visual-style 2	fgColor:white
# visual-style 0	bgColor:blue
# visual-style 0	fgColor:white
# visual-style 0 2 root	color:blue
1	аминь	аминъ	INTJ	I-	_	2	vocative	_	ref=MATT_5.26
2	г҃лѭ	глаголати	VERB	V-	Mood=Ind|Number=Sing|Person=1|Tense=Pres|VerbForm=Fin|Voice=Act	0	root	_	ref=MATT_5.26
3	тебѣ	тꙑ	PRON	Pp	Case=Dat|Number=Sing|Person=2|PronType=Prs	2	iobj	_	ref=MATT_5.26

# visual-style 1	bgColor:blue
# visual-style 1	fgColor:white
# visual-style 0	bgColor:blue
# visual-style 0	fgColor:white
# visual-style 0 1 root	color:blue
1	пръвꙑ	прьвъ	ADJ	Mo	Case=Nom|Gender=Masc|Number=Sing	0	root	_	ref=MATT_21.31

# visual-style 1	bgColor:blue
# visual-style 1	fgColor:white
# visual-style 0	bgColor:blue
# visual-style 0	fgColor:white
# visual-style 0 1 root	color:blue
1	око	око	NOUN	Nb	Case=Acc|Gender=Neut|Number=Sing	0	root	_	ref=MATT_5.38
2	за	за	ADP	R-	_	3	case	_	ref=MATT_5.38
3	око	око	NOUN	Nb	Case=Acc|Gender=Neut|Number=Sing	1	obl	_	ref=MATT_5.38
4	и	и	CCONJ	C-	_	1	cc	_	ref=MATT_5.38
5	зѫбъ	зѫбъ	NOUN	Nb	Case=Acc|Gender=Masc|Number=Sing	1	conj	_	ref=MATT_5.38
6	за	за	ADP	R-	_	7	case	_	ref=MATT_5.38
7	зѫбъ	зѫбъ	NOUN	Nb	Case=Acc|Gender=Masc|Number=Sing	5	orphan	_	ref=MATT_5.38

© 2014–2021
            Universal Dependencies contributors.
            Site powered by Annodoc and brat
.


text:
var _ = require('ep_etherpad-lite/static/js/underscore');
// CommonJS
if (typeof (require) != 'undefined') {
  if (typeof (Changeset) == 'undefined') {
    Changeset = require('ep_etherpad-lite/static/js/Changeset');
  }
}

var $tblContextMenu;

// Bind the event handler to the toolbar buttons
exports.postAceInit = function (hook, context) {

  openContextMenu = function (init) {
    if (!$tblContextMenu) initContextMenu();
    $tblContextMenu.css({'top': $('#editbar').outerHeight(), 'left': $('#table-menu-button').offset().left - 12}).toggle();
  };

   hideContextMenu = function() {
    $tblContextMenu.hide();
  }

  initContextMenu = function() {
    $tblContextMenu = $('#table-context-menu').appendTo('body');

    // Displaying the matrix to choose the new table size
    $('#tbl_prop_create_table').hover(function() {
      $('#create-table-container').show();
    });
    $tblContextMenu.find('.menu-item:not(#tbl_prop_create_table)').hover(function() {
      $('#create-table-container').hide();
    });

    // Selecting the size of the table to create
    var timerSelectedOnHover;
    $('#new-table-size-selector td').hover(function () {
      clearTimeout(timerSelectedOnHover);
      $('#new-table-size-selector td').removeClass('selected');
      for (var x = 0; x <= $(this).index(); x++) {
        for (var y = 0; y <= $(this).parent().index(); y++) {
          $(this).parent().parent().children().eq(y).children().eq(x).addClass('selected');
        }
      }
    }, function () {
      timerSelectedOnHover = setTimeout(function() { $('#new-table-size-selector td').removeClass('selected'); }, 200);
    });
    $('#new-table-size-selector td').hover(function () {
      xVal = this.getAttribute('value')
      yVal = $(this).closest("tr")[0].getAttribute("value");
      $("#new-table-size").html(xVal + " X " + yVal);
    });
    $("td", "#new-table-size-selector").click(function (e) {
      context.ace.callWithAce(function (ace) {
        ace.ace_doDatatableOptions('addTbl', 'addTblX' + $("#new-table-size").text());
      }, 'tblOptions', true);
      hideContextMenu();
      return false;
    });

    // Handle menu action click
    $tblContextMenu.find('.menu-item[data-action]').click(function() {
      var action = $(this).attr('data-action');
      context.ace.callWithAce(function (ace) {
        ace.ace_doDatatableOptions(action);
      }, 'tblOptions', true);
      hideContextMenu();
      return false;
    });
  }

  $('#table-menu-button').click(openContextMenu);

};
// Once ace is initialized, we set ace_doDatatableOptions and bind it to the context
exports.aceInitialized = function (hook, context) {
  var editorInfo = context.editorInfo;
  editorInfo.ace_doDatatableOptions = _(Datatables.doDatatableOptions).bind(context);
};
exports.acePostWriteDomLineHTML = function (hook_name, args, cb) {
  // Iterate through the child nodes (spans) and point SyntaxHighlighter at them

  // Do nothing if the line is not a table line (args.node.tagName -> to check if in timeslider page)
  if(!args.node.tagName && args.node.innerHTML.indexOf("data-tables") == -1) return;

  if (!args.node.tagName && args.node.innerHTML && args.node.innerHTML.indexOf("data-tables") != -1){
    // For the Timeslider
    var dtAttrs = typeof (exports.Datatables) != 'undefined' ? exports.Datatables.attributes : null;
    DatatablesRenderer.render("timeslider", args.node, dtAttrs);
  } else {
    // For the Pad
    var children = args.node.children;

    lineText = args.node.children[0].innerText?args.node.children[0].innerText:args.node.children[0].textContent;
    lineText_end  = args.node.children[0].innerText?args.node.children[children.length -1].innerText:args.node.children[children.length -1].textContent;

    // Case when etherpad interact with the content of a cell and breaks the table line into several lines (like when writing an url inside a cell)
    // In that case, we have to regroup everything before rendering the line.
    if (children.length > 1 && lineText.indexOf("payload") != -1 && lineText_end.indexOf("data-tables") != -1) {
    for (var i = 1; i < children.length; i++) {

      if (args.node.children[0].innerText) {
      args.node.children[0].innerText += args.node.children[i].innerText;
      args.node.children[i].innerText = "";
      } else {
      args.node.children[0].textContent += args.node.children[i].textContent;
      args.node.children[i].textContent = "";
      }
      args.node.children[i] = null;
    }

    var dtAttrs = typeof (exports.Datatables) != 'undefined' ? exports.Datatables.attributes : null;
    dtAttrs = dtAttrs || "";
    DatatablesRenderer.render({}, args.node.children[0], dtAttrs);
    exports.Datatables.attributes = null;

    } else {
    for (var i = 0; i < children.length; i++) {
      if (args.node.children[i].className.indexOf("list") != -1 || args.node.children[i].className.indexOf("tag") != -1 || args.node.children[i].className.indexOf("url") != -1) continue;
      var lineText = "";
      if (args.node.children[i].innerText) lineText = args.node.children[i].innerText;
      else lineText = args.node.children[i].textContent;
      if (lineText && lineText.indexOf("data-tables") != -1) {
        var dtAttrs = typeof (exports.Datatables) != 'undefined' ? exports.Datatables.attributes : null;
        dtAttrs = dtAttrs || "";
        DatatablesRenderer.render({}, args.node.children[i], dtAttrs);
        exports.Datatables.attributes = null;
      }
    }
    }
  }
}
exports.eejsBlock_timesliderScripts = function (hook_name, args, cb) {
  args.content = args.content + require('ep_etherpad-lite/node/eejs/').require("ep_tables2/templates/datatablesScriptsTimeslider.ejs");
}
exports.eejsBlock_scripts = function (hook_name, args, cb) {
  args.content = args.content + require('ep_etherpad-lite/node/eejs/').require("ep_tables2/templates/datatablesScripts.ejs");
}
exports.eejsBlock_editbarMenuLeft = function (hook_name, args, cb) {
  args.content = args.content + require('ep_etherpad-lite/node/eejs/').require("ep_tables2/templates/datatablesEditbarButtons.ejs");
}
exports.eejsBlock_styles = function (hook_name, args, cb) {
  args.content = require('ep_etherpad-lite/node/eejs/').require("ep_tables2/templates/styles.ejs") + args.content;
}
// Our heading attribute will result in a heaading:h1... :h6 class
exports.aceAttribsToClasses = function (hook, context) {
  Datatables.attributes = null;
  if (context.key == 'tblProp') {
    Datatables.attributes = context.value;
    return ['tblProp:' + context.value];
  }
}
exports.aceEditEvent = function (hook, context) {
/*  console.log("---------------------------");
  console.log(context);*/
}
exports.aceStartLineAndCharForPoint = function (hook, context) {
	var selStart = null;
  try {
    Datatables.context = context;
    if (Datatables.isFocused()) {
      selStart = Datatables.getLineAndCharForPoint();
      return selStart;
    }
  } catch (error) {
    console.log('error ' + error);
  }
};

exports.aceEndLineAndCharForPoint = function (hook, context) {
	var selEndLine = null;
  try {
    Datatables.context = context;
    if (Datatables.isFocused()) {
      selEndLine =   Datatables.getLineAndCharForPoint();
      return selEndLine;
    }
  } catch (error) {
    console.log('error ' + error);
  }
};
exports.aceKeyEvent = function (hook, context) {
  var specialHandled = false;

  var currLineNumber = context.rep.selStart[0];
  // if trying to delete the line after table, we prevent this, refs Issue #22
  if (context.evt.key == "Backspace" && currLineNumber > 0) {
    var currentLine = context.rep.lines.atIndex(currLineNumber);
    var previousLine = context.rep.lines.atIndex(currLineNumber -1);

    // if current line is empty and previous line is a Table, then we prevent the backspace action
    if (currentLine.text.length < 1 && previousLine.text.indexOf("data-tables") != -1) {
      context.evt.preventDefault();
      return true;
    }
  }

  try {
    Datatables.context = context;
    if (Datatables.isFocused()) {
      var evt = context.evt;
      var type = evt.type;
      var keyCode = evt.keyCode;
      var isTypeForSpecialKey = (type == "keydown" || type == "keypress");
      var which = evt.which;
      if ((!specialHandled) && isTypeForSpecialKey && keyCode == 9 && !(evt.metaKey || evt.ctrlKey)) {
        context.editorInfo.ace_fastIncorp(5);
        evt.preventDefault();
        Datatables.performDocumentTableTabKey();
        specialHandled = true;
      }
      if ((!specialHandled) && isTypeForSpecialKey && keyCode == 13) {
        // return key, handle specially;
        context.editorInfo.ace_fastIncorp(5);
        evt.preventDefault();
        Datatables.doReturnKey();
        specialHandled = true;
      }
      if ((!specialHandled) && isTypeForSpecialKey && ((type == "keydown" && keyCode == Datatables.vars.JS_KEY_CODE_DEL) || keyCode == Datatables.vars.JS_KEY_CODE_BS || (String.fromCharCode(which).toLowerCase() == "h" && (evt.ctrlKey)))) {
        context.editorInfo.ace_fastIncorp(20);
        evt.preventDefault();
        specialHandled = true;
        if (Datatables.isCellDeleteOk(keyCode)) {
          Datatables.doDeleteKey();
        }
      }
    }
  } catch (error) {}
  //console.log(' ace key evt specialHandled ',specialHandled);
  return specialHandled;
};
if (typeof (Datatables) == 'undefined') var Datatables = function () {
    // Get the text within an element
    // Doesn't do any normalising, returns a string
    // of text as found.
    function nodeText(n) {
      var text = [];
      var self = arguments.callee;
      var el, els = n.childNodes;
      var excluded = {
        'noscript': 'noscript',
        'script': 'script',
      };
      for (var i = 0, iLen = els.length; i < iLen; i++) {
        el = els[i];
        // May need to add other node types here
        if (el.nodeType == 1 && !(el.tagName.toLowerCase() in excluded)) {
          text.push(self(el));
          // If working with XML, add nodeType 4 to get text from CDATA nodes
        } else if (el.nodeType == 3) {
          // Deal with extra whitespace and returns in text here.
          text.push(el.data);
        }
      }
      return text.join('');
    }
    var dt = {
      defaults: {
        tblProps: {
          borderWidth: "1",
          cellAttrs: [],
          width: "100",
          rowAttrs: {},
          colAttrs: [],
          authors: {}
        }
      },
      config: {},
      /** Internal 'global' variables. */
      vars: {
        OVERHEAD_LEN_PRE: '{"payload":[["'.length,
        OVERHEAD_LEN_MID: '","'.length,
        OVERHEAD_LEN_ROW_START: '["'.length,
        OVERHEAD_LEN_ROW_END: '"],'.length,
        JS_KEY_CODE_BS: 8,
        JS_KEY_CODE_DEL: 46,
        TBL_OPTIONS: ['addTbl', 'addTblRowA', 'addTblRowB', 'addTblColL', 'addTblColR', 'delTbl', 'delTblRow', 'delTblCol']
      },
      /* passed parameters */
      context: null
    }; // end of dt
    dt.isFocused = function () {
      if (!this.context.rep.selStart || !this.context.rep.selEnd) return false;
      var line = this.context.rep.lines.atIndex(this.context.rep.selStart[0]);
      if (!line) return false;
      var currLineText = line.text || '';
      if (currLineText.indexOf("data-tables") == -1) {
        return false;
      }
      return true;
    };
    /* Helper function. not meant to be used as a standalone function

			   requires rowStartOffset

			 */
    dt._getRowEndOffset = function (rowStartOffset, tds) {
      var rowEndOffset = rowStartOffset + this.vars.OVERHEAD_LEN_ROW_START;
      for (var i = 0, len = tds.length; i < len; i++) {
        var overHeadLen = this.vars.OVERHEAD_LEN_MID;
        if (i == len - 1) {
          overHeadLen = this.vars.OVERHEAD_LEN_ROW_END;
        }
        rowEndOffset += tds[i].length + overHeadLen;
      }
      return rowEndOffset;
    }
    /**

			current row index,

			td index ,

			the length of leftover text of the current cell,

			current row start offset,

			current row end offset,

			current td start offset,

			current td end offset,

			and cellCaretPos

		*/
    dt.getFocusedTdInfo = function (payload, colStart) {
      var payloadOffset = colStart - this.vars.OVERHEAD_LEN_PRE;
      var rowStartOffset = 0;
      var payloadSum = 0;
      for (var rIndex = 0, rLen = payload.length; rIndex < rLen; rIndex++) {
        var tds = payload[rIndex];
        for (var tIndex = 0, tLen = tds.length; tIndex < tLen; tIndex++) {
          var overHeadLen = this.vars.OVERHEAD_LEN_MID;
          if (tIndex == tLen - 1) {
            overHeadLen = this.vars.OVERHEAD_LEN_ROW_END;
          }
          payloadSum += tds[tIndex].length + overHeadLen;
          if (payloadSum >= payloadOffset) {
            if (payloadSum == payloadOffset) {
              tIndex++;
            }
            var leftOverTdTxtLen = payloadSum - payloadOffset == 0 ? payload[rIndex][tIndex].length + this.vars.OVERHEAD_LEN_MID : payloadSum - payloadOffset;
            var cellCaretPos = tds[tIndex].length - (leftOverTdTxtLen - overHeadLen);
            var rowEndOffset = this._getRowEndOffset(rowStartOffset, tds);
            return {
              row: rIndex,
              td: tIndex,
              leftOverTdTxtLen: leftOverTdTxtLen,
              rowStartOffset: rowStartOffset,
              rowEndOffset: rowEndOffset,
              cellStartOffset: payloadSum - tds[tIndex].length - overHeadLen,
              cellEndOffset: payloadSum,
              cellCaretPos: cellCaretPos
            };
          }
        }
        rowStartOffset = payloadSum;
        payloadSum += this.vars.OVERHEAD_LEN_ROW_START;
      }
    };
    dt.printCaretPos = function (start, end) {
      top.console.log(JSON.stringify(start));
      top.console.log(JSON.stringify(end));
    };
    dt.doDatatableOptions = function (cmd, xByY) {
      Datatables.context = this; // the scope is still ep lite and not DataTables because of the binding we have to do in  exports.aceInitialized
      if ((typeof (cmd) == 'object' && cmd.tblPropertyChange)) {
        Datatables.updateTableProperties(cmd);
      } else {
        switch (cmd) {
        case Datatables.vars.TBL_OPTIONS[0]:
          Datatables.addTable(xByY);
          break;
        case Datatables.vars.TBL_OPTIONS[1]:
          Datatables.insertTblRow("addA");
          break;
        case Datatables.vars.TBL_OPTIONS[2]:
          Datatables.insertTblRow("addB");
          break;
        case Datatables.vars.TBL_OPTIONS[3]:
          Datatables.insertTblColumn("addL");
          break;
        case Datatables.vars.TBL_OPTIONS[4]:
          Datatables.insertTblColumn("addR");
          break;
        case Datatables.vars.TBL_OPTIONS[5]:
          Datatables.deleteTable();
          break;
        case Datatables.vars.TBL_OPTIONS[6]:
          Datatables.deleteTblRow();
          break;
        case Datatables.vars.TBL_OPTIONS[7]:
          Datatables.deleteTblColumn();
          break;
        }
      }
    };
    dt.addTable = function (tableObj) {
      var rep = this.context.rep;
      var start = rep.selStart;
      var end = rep.selEnd;
      var line = rep.lines.atIndex(rep.selStart[0]);
      var hasMoreRows = null;
      var isRowAddition = null;
      if (tableObj) {
        hasMoreRows = tableObj.hasMoreRows;
        isRowAddition = tableObj.isRowAddition;
      }
      if (isRowAddition) {
        var table = JSON.parse(tableObj.tblString);
        insertTblRowBelow(0, table);
        performDocApplyTblAttrToRow(rep.selStart, JSON.stringify(table.tblProperties));
        return;
      }
      //if the carret is within a table, add the new table at the bottom
      if (line) {
        var currLineText = line.text;
        if (currLineText.indexOf("data-tables") != -1) {
          do {
            rep.selStart[0] = rep.selStart[0] + 1
            currLineText = rep.lines.atIndex(rep.selStart[0]).text;
          } while (currLineText.indexOf("data-tables") != -1);
          rep.selEnd[1] = rep.selStart[1] = currLineText.length;
          this.context.editorInfo.ace_doReturnKey();
          this.context.editorInfo.ace_doReturnKey();
        } else {
          rep.selEnd[1] = rep.selStart[1] = currLineText.length;
          this.context.editorInfo.ace_doReturnKey();
          //				this.context.editorInfo.ace_inCallStackIfNecessary ('newline',this.context.editorInfo.ace_doReturnKey);
        }
      }
      //if no col/row specified, create a default 3X3  empty table
      if (tableObj == null) {
        var authors = {};
        this.insertTblRowBelow(3);
        this.performDocApplyTblAttrToRow(rep.selStart, this.createDefaultTblProperties(null, true));
        this.insertTblRowBelow(3);
        this.performDocApplyTblAttrToRow(rep.selStart, this.createDefaultTblProperties(authors));
        this.insertTblRowBelow(3);
        this.performDocApplyTblAttrToRow(rep.selStart, this.createDefaultTblProperties(authors));
        this.context.editorInfo.ace_doReturnKey();
        //this.context.editorInfo.ace_inCallStackIfNecessary ('newline',this.context.editorInfo.ace_doReturnKey);
        this.updateAuthorAndCaretPos(rep.selStart[0] - 3);
        return;
      }
      //xbyy cols and rows have been specified or an actual payload object is present, for the former, create x rows of magicdom lines that contain a row
      //per table.
      xByYSelect = typeof (tableObj) == "object" ? null : tableObj.split("X");
      if (xByYSelect != null && xByYSelect.length == 3) {
        var cols = parseInt(xByYSelect[1]);
        var rows = parseInt(xByYSelect[2]);
        var jsoStrTblProp = JSON.stringify(this.createDefaultTblProperties());
        var authors = {};
        for (var i = 0; i < rows; i++) {
          this.insertTblRowBelow(cols);
          if (i == 0) {
            this.performDocApplyTblAttrToRow(rep.selStart, this.createDefaultTblProperties(null, true));
          } else {
            this.performDocApplyTblAttrToRow(rep.selStart, this.createDefaultTblProperties(authors));
          }
        }
        this.context.editorInfo.ace_doReturnKey();
        this.updateAuthorAndCaretPos(rep.selStart[0] - rows + 1);
        return;
      }
      return newText;
    };
    //insert a row
    dt.insertTblRow = function (aboveOrBelow) {
      var func = 'insertTblRow()';
      var rep = this.context.rep;
      try {
        var newText = "";
        var currLineText = rep.lines.atIndex(rep.selStart[0]).text;
        var payload = JSON.parse(currLineText).payload;
        var currTdInfo = this.getFocusedTdInfo(payload, rep.selStart[1]);
        var currRow = currTdInfo.row;
        var lastRowOffSet = 0;
        var start = [],
          end = [];
        start[0] = rep.selStart[0], start[1] = rep.selStart[1];
        end[0] = rep.selStart[0], end[1] = rep.selStart[1];
        if (aboveOrBelow == 'addA') {
          // If we add a row above the first row, the new row must have the prop 'isFirstRow' and we must remove 'isFirstRow' from current row
          var isFirstRow = false;
          var jsoTblProp = this.getLineTableProperty(start[0]);
          if (isFirstRow = jsoTblProp.isFirstRow) {
            delete jsoTblProp['isFirstRow'];
            this.updateTblPropInAPool(-1, -1, jsoTblProp, start);
          }
          rep.selStart[0] = rep.selEnd[0] = rep.selStart[0] - 1;
          this.insertTblRowBelow(payload[0].length);
          this.performDocApplyTblAttrToRow(rep.selStart, this.createDefaultTblProperties(null, isFirstRow));
        } else { //below curr row ( aboveOrBelow = 'addB')
          this.insertTblRowBelow(payload[0].length);
          this.performDocApplyTblAttrToRow(rep.selStart, this.createDefaultTblProperties());
        }
        this.updateAuthorAndCaretPos(rep.selStart[0]);
        var updateEvenOddBgColor = true;
        this.sanitizeTblProperties(rep.selStart, updateEvenOddBgColor);
      } catch (error) {
        //domline.createErrorState(start,end,'insertTblRow',rep.lines.atIndex(rep.selStart[0]).text,rep.selStart,rep.selEnd,newText,error);
      }
    };
    //delete a table, also removes table overhead
    dt.deleteTable = function () {
      var rep = this.context.rep;
      var func = 'deleteTable()';
      var start = rep.seStart;
      var end = rep.seEnd;
      try {
        var line = rep.selStart[0] - 1;
        var numOfLinesAbove = 0;
        var numOfLinesBelow = 0;
        while (rep.lines.atIndex(line).text.indexOf('data-tables') != -1) { //count num of rows above current pos
          numOfLinesAbove++;
          line--;
        }
        line = rep.selEnd[0] + 1;
        while (rep.lines.atIndex(line).text.indexOf('data-tables') != -1) { //count num of rows below current pos
          numOfLinesBelow++;
          line++;
        }
        rep.selStart[1] = 0;
        rep.selStart[0] = rep.selStart[0] - numOfLinesAbove;
        rep.selEnd[0] = rep.selEnd[0] + numOfLinesBelow;
        rep.selEnd[1] = rep.lines.atIndex(rep.selEnd[0]).text.length;
        this.context.editorInfo.ace_performDocumentReplaceRange(rep.selStart, rep.selEnd, "");
      } catch (error) {
        //domline.createErrorState(start,end,func,rep.lines.atIndex(rep.selStart[0]).text,rep.selStart,rep.selEnd,"",error);
      }
    };
    //delete a row
    dt.deleteTblRow = function () {
      var func = 'deleteTblRow()';
      var rep = this.context.rep;
      try {
        // Check if the deleted row is the first row of the table
        var isFirstRow = false;
        var jsoTblProp = this.getLineTableProperty(rep.selStart[0]);
        if (jsoTblProp.isFirstRow) isFirstRow = true;

        var currLineText = rep.lines.atIndex(rep.selStart[0]).text;
        if (currLineText.indexOf('data-tables') == -1) return;
        rep.selEnd[0] = rep.selStart[0] + 1;
        rep.selStart[1] = 0;
        rep.selEnd[1] = 0;
        this.context.editorInfo.ace_performDocumentReplaceRange(rep.selStart, rep.selEnd, "");
        currLineText = rep.lines.atIndex(rep.selStart[0]).text;
        if (currLineText.indexOf('data-tables') == -1) return;
        this.updateAuthorAndCaretPos(rep.selStart[0], 0, 0);
        updateEvenOddBgColor = true;
        this.sanitizeTblProperties(rep.selStart, updateEvenOddBgColor);

        // If the deleted row was the first row, the new first row becomes the first row and must have the prop 'isFirstRow'
        if (isFirstRow) {
          var newJsoTblProp = this.getLineTableProperty(rep.selStart[0]);
          newJsoTblProp['isFirstRow'] = true;
          this.updateTblPropInAPool(-1, -1, newJsoTblProp, rep.selStart);
        }
      } catch (error) {
        //domline.createErrorState(start,end,'deleteTblRow',rep.lines.atIndex(rep.selStart[0]).text,rep.selStart,rep.selEnd,"",error);
      }
    };
    dt.updateTableProperties = function (props) {
      var rep = this.context.rep;
      var currTd = null;
      if (props.tblColWidth || props.tblSingleColBgColor || props.tblColVAlign) {
        var currLine = rep.lines.atIndex(rep.selStart[0]);
        var currLineText = currLine.text;
        var tblJSONObj = JSON.parse(currLineText);
        var payload = tblJSONObj.payload;
        var currTdInfo = this.getFocusedTdInfo(payload, rep.selStart[1]);
        currTd = currTdInfo.td;
      }
      if (props.tblWidth || props.tblHeight || props.tblBorderWidth || props.tblBorderColor || props.tblColWidth || props.tblSingleColBgColor || props.tblEvenRowBgColor || props.tblOddRowBgColor || props.tblColVAlign) {
        var start = [];
        start[0] = rep.selStart[0], start[1] = rep.selStart[1];
        var numOfLinesAbove = this.getTblAboveRowsFromCurFocus(start);
        var tempStart = [];
        tempStart[0] = start[0] - numOfLinesAbove;
        tempStart[1] = start[1];
        while (tempStart[0] < rep.lines.length() && rep.lines.atIndex(tempStart[0]).text.indexOf('data-tables') != -1) { //start from top of a table
          if (props.tblEvenRowBgColor && tempStart[0] % 2 != 0) {
            tempStart[0] = tempStart[0] + 1;
            continue;
          } else if (props.tblOddRowBgColor && tempStart[0] % 2 == 0) {
            tempStart[0] = tempStart[0] + 1;
            continue;
          }
          this.updateTablePropertiesHelper(props, tempStart, currTd);
          tempStart[0] = tempStart[0] + 1;
        }
      } else {
        var start = [];
        start[0] = rep.selStart[0];
        start[1] = rep.selStart[1];
        this.updateTablePropertiesHelper(props, start, currTd);
      }
    };
    dt.addCellAttr = function (start, tblJSONObj, tblProperties, attrName, attrValue) {
      var rep = this.context.rep;
      var payload = tblJSONObj.payload;
      var currTdInfo = this.getFocusedTdInfo(payload, start[1]);
      var currRow = currTdInfo.row;
      var currTd = currTdInfo.td;
      var cellAttrs = tblProperties.cellAttrs;
      var row = cellAttrs[currRow];
      if (row == null || typeof (row) == 'undefined') {
        row = [];
      }
      cell = row[currTd];
      if (cell == null || typeof (cell) == 'undefined') {
        cell = {};
      }
      //toggle these attributes
      if (attrName == 'fontWeight' || attrName == 'fontStyle' || attrName == 'textDecoration') {
        if (cell[attrName] == attrValue) {
          attrValue = '';
        }
      } else if (cell[attrName] == attrValue) return false; //other wise no need to update
      cell[attrName] = attrValue;
      row[currTd] = cell;
      cellAttrs[currRow] = row;
      tblProperties.cellAttrs = cellAttrs;
      return tblProperties;
    };
    //returns false if no chanage to tblProperties
    dt.addRowAttr = function (tblJSONObj, tblProperties, attrName, attrValue) {
      var rep = this.context.rep;
      var rowAttrs = tblProperties.rowAttrs;
      if (attrName == 'bgColor') { //specific single row property
        var payload = tblJSONObj.payload;
        var currTdInfo = this.getFocusedTdInfo(payload, rep.selStart[1]);
        var currRow = currTdInfo.row;
        var singleRowAttrs = rowAttrs.singleRowAttrs;
        if (singleRowAttrs == null || typeof (singleRowAttrs) == 'undefined') {
          singleRowAttrs = [];
        }
        if (singleRowAttrs[currRow] == null || typeof (singleRowAttrs[currRow]) == 'undefined') {
          singleRowAttrs[currRow] = {};
        } else if (singleRowAttrs[currRow][attrName] == attrValue) {
          return false;
        }
        singleRowAttrs[currRow][attrName] = attrValue;
        rowAttrs.singleRowAttrs = singleRowAttrs;
      } else { //even-odd rows properties,rowAlign
        if (rowAttrs[attrName] == attrValue) return false;
        rowAttrs[attrName] = attrValue;
      }
      tblProperties.rowAttrs = rowAttrs;
      return tblProperties;
    };
    //returns false if no chanage to tblProperties
    dt.addColumnAttr = function (start, tblJSONObj, tblProperties, attrName, attrValue, currTd) {
      var payload = tblJSONObj.payload;
      var currTdInfo = this.getFocusedTdInfo(payload, start[1]);
      var colAttrs = tblProperties.colAttrs;
      if (colAttrs == null || typeof (colAttrs) == 'undefined') {
        colAttrs = [];
      }
      if (colAttrs[currTd] == null || typeof (colAttrs[currTd]) == 'undefined') {
        colAttrs[currTd] = {};
      } else if (colAttrs[currTd][attrName] == attrValue) {
        return false;
      }
      colAttrs[currTd][attrName] = attrValue;
      tblProperties.colAttrs = colAttrs;
      return tblProperties;
    };
    dt.updateTablePropertiesHelper = function (props, start, currTd) {
      var rep = this.context.rep;
      lastTblPropertyUsed = 'updateTableProperties';
      start = start || rep.selStart;
      if (!(start)) return;
      var currLine = rep.lines.atIndex(start[0]);
      var currLineText = currLine.text;
      if (currLineText.indexOf('data-tables') == -1) return true;
      try {
        var tblJSONObj = JSON.parse(currLineText);
        var tblProperties = this.getLineTableProperty(start[0]);
        var update = false;
        //table width , height , border width and tbl  color
        if (props.tblWidth || props.tblHeight || props.tblBorderWidth || props.tblBorderColor) {
          var currAttrValue = tblProperties[props.attrName];
          if (props.attrValue != null && (typeof (currAttrValue) == 'undefined' || currAttrValue != props.attrValue)) {
            tblProperties[props.attrName] = props.attrValue;
            update = true;
          }
        }
        //cell background color, height, font, font size, font-weight, italic, text-decoration, v-align, h-align
        if (props.tblCellFont || props.tblCellFontSize || props.tblCellBgColor || props.tblCellHeight || props.tblcellVAlign || props.tblCellBold || props.tblCellItalic || props.tblCellDecoration || props.tblCellVAlign || props.tblCellHAlign) {
          var tblProps = this.addCellAttr(start, tblJSONObj, tblProperties, props.attrName, props.attrValue);
          if (tblProps) {
            tblProperties = tblProps;
            update = true;
          }
        }
        //even/odd row background color
        if (props.tblEvenRowBgColor || props.tblOddRowBgColor) {
          var tblProps = this.addRowAttr(tblJSONObj, tblProperties, props.attrName, props.attrValue);
          if (tblProps) {
            tblProperties = tblProps;
            update = true;
          }
        }
        //single row background color, rowVAlign
        if (props.tblSingleRowBgColor || props.tblRowVAlign) {
          var tblProps = this.addRowAttr(tblJSONObj, tblProperties, props.attrName, props.attrValue);
          if (tblProps) {
            tblProperties = tblProps;
            update = true;
          }
        }
        // col width, col bgColor, colVAlign
        if (props.tblColWidth || props.tblSingleColBgColor || props.tblColVAlign) {
          var tblProps = this.addColumnAttr(start, tblJSONObj, tblProperties, props.attrName, props.attrValue, currTd);
          if (tblProps) {
            tblProperties = tblProps;
            update = true;
          }
        }
        //only update if there is a change
        if (update) {
          this.updateTblPropInAPool(-1, -1, tblProperties, start);
        }
      } catch (error) {
        // domline.createErrorState(start,end,'updateTableProperties',rep.lines.atIndex(rep.selStart[0]).text,rep.selStart,rep.selEnd,"",error);
      }
    };
    dt.updateAuthorAndCaretPos = function (magicDomLineNum, tblRowNum, tblColNum) {
      var rep = this.context.rep;
      rep.selStart[1] = rep.selEnd[1] = this.vars.OVERHEAD_LEN_PRE;
      rep.selStart[0] = rep.selEnd[0] = magicDomLineNum;
      var row = typeof (tblRowNum) == 'undefined' || tblRowNum == null ? 0 : tblRowNum;
      var col = typeof (tblColNum) == 'undefined' || tblRowNum == null ? 0 : tblColNum;
      this.updateTblPropInAPool(row, col, null, rep.selStart);
      rep.selStart[1] = rep.selEnd[1] = this.vars.OVERHEAD_LEN_PRE;
      this.context.editorInfo.ace_performDocumentReplaceRange(rep.selStart, rep.selEnd, '');
    }
    dt.insertTblRowBelow = function (numOfRows, table) {
      var rep = this.rep;
      var currLineText = rep.lines.atIndex(rep.selStart[0]).text;
      var payload = [
        []
      ];
      if (!numOfRows && numOfRows != 0) {
        var tblPayload = JSON.parse(currLineText).payload;
        numOfRows = tblPayload[0].length;
      }
      var tblRows = new Array(numOfRows);
      if (numOfRows != 0) {
        for (var i = 0; i < tblRows.length; i++) {
          tblRows[i] = " ";
        }
      }
      payload = [tblRows];
      if (table) {
        payload = table.payload;
      }
      tableObj = {
        "payload": payload,
        "tblId": 1,
        "tblClass": "data-tables",
        "trClass": "alst",
        "tdClass": "hide-el"
      }
      rep.selEnd[1] = rep.selStart[1] = currLineText.length;
      this.context.editorInfo.ace_doReturnKey();
      this.context.editorInfo.ace_performDocumentReplaceRange(rep.selStart, rep.selEnd, JSON.stringify(tableObj));
    };
    dt.createDefaultTblProperties = function (authors, isFirstRow) {
      var rep = this.context.rep;
      var defTblProp = {
        borderWidth: "1",
        cellAttrs: [],
        width: "100",
        rowAttrs: {},
        colAttrs: [],
        authors: {}
      };
      if (authors) {
        defTblProp['authors'] = authors;
      }
      if (isFirstRow) {
        defTblProp['isFirstRow'] = isFirstRow;
      }
      //from existing Table tableborder,tbl_border_width,table_width and table_height
      var prevLine = rep.lines.atIndex(rep.selEnd[0] - 1);
      var jsoTblProp = null;
      if (prevLine) {
        var prevLineText = prevLine.text;
        if (prevLineText.indexOf("data-tables") != -1) {
          jsoTblProp = this.getLineTableProperty(rep.selStart[0] - 1);
        }
      }
      if (!jsoTblProp) {
        var nextLine = rep.lines.atIndex(rep.selEnd[0] +1);
        if (nextLine) {
          var nextLineText = nextLine.text;
          if (nextLineText.indexOf("data-tables") != -1) {
            jsoTblProp = this.getLineTableProperty(rep.selStart[0] + 1);
          }
        }
      }
      if (jsoTblProp) {
        defTblProp.borderWidth = jsoTblProp.borderWidth;
        defTblProp.borderColor = jsoTblProp.borderColor;
        defTblProp.width = jsoTblProp.width;
        defTblProp.height = jsoTblProp.height;
        defTblProp.colAttrs = jsoTblProp.colAttrs;
      }
      var jsoStrTblProp = JSON.stringify(defTblProp);
      return jsoStrTblProp;
    }
    dt.performDocApplyTblAttrToRow = function (start, jsoStrTblProp) {
      var tempStart = [],
        tempEnd = [];
      tempStart[0] = start[0], tempEnd[0] = start[0];
      tempStart[1] = 0, tempEnd[1] = this.context.rep.lines.atIndex(start[0]).text.length;
      this.context.editorInfo.ace_performDocumentApplyAttributesToRange(tempStart, tempEnd, [
        ["tblProp", jsoStrTblProp]
      ]);
    }
    /* handles tab key within a table */
    dt.performDocumentTableTabKey = function () {
      try {
        var context = this.context;
        var rep = context.rep;
        var currLine = rep.lines.atIndex(rep.selStart[0]);
        var currLineText = currLine.text;
        var tblJSONObj = JSON.parse(currLineText);
        var payload = tblJSONObj.payload;
        var currTdInfo = this.getFocusedTdInfo(payload, rep.selStart[1]);
        var leftOverTdTxtLen = currTdInfo.leftOverTdTxtLen;
        var currRow = currTdInfo.row;
        var currTd = currTdInfo.td;
        if (typeof (payload[currRow][currTd + 1]) == "undefined") { //next row
          currRow += 1;
          var nextLine = rep.lines.atIndex(rep.selStart[0] + 1);
          var nextLineText = nextLine.text;
          var updateEvenOddBgColor = false;
          if (nextLineText == null || nextLineText == '' || nextLineText.indexOf('data-tables') == -1) { //create new row and move caret to this new row
            this.insertTblRowBelow(null, null);
            this.performDocApplyTblAttrToRow(rep.selStart, this.createDefaultTblProperties());
            rep.selEnd[1] = rep.selStart[1] = this.vars.OVERHEAD_LEN_PRE;
            updateEvenOddBgColor = true;
          } else { //just move caret to existing next row
            currTd = -1;
            rep.selStart[0] = rep.selEnd[0] = rep.selStart[0] + 1;
            var tblJSONObj = JSON.parse(nextLineText);
            var payload = tblJSONObj.payload;
            leftOverTdTxtLen = payload[0][0].length;
            rep.selEnd[1] = rep.selStart[1] = this.vars.OVERHEAD_LEN_PRE + leftOverTdTxtLen;
          }
          context.editorInfo.ace_performDocumentReplaceRange(rep.selStart, rep.selEnd, "");
          var start = [];
          start[0] = rep.selStart[0];
          start[1] = rep.selStart[1];
          dt.updateTblCellAuthor(0, 0, null, start, updateEvenOddBgColor); //this requires removing potential user color in a differnt row(although it should only check the previous row)
        } else { //tab to the next col and update cell user color
          var nextTdTxtLen = typeof (payload[currRow]) == 'undefined' ? -leftOverTdTxtLen : payload[currRow][currTd + 1].length;
          payload = tblJSONObj.payload;
          rep.selStart[1] = rep.selEnd[1] = rep.selEnd[1] + nextTdTxtLen + leftOverTdTxtLen;
          context.editorInfo.ace_performDocumentReplaceRange(rep.selStart, rep.selEnd, "");
          // debugger;
          dt.updateTblPropInAPool(currRow, currTd + 1, null, rep.selStart); //this need not to update entire table of color setting
        }
      } catch (error) {}
    };
    dt.getTdInfo = function (payload, tdIndex) {
      var rep = this.context.rep;
      var startOffset = this.vars.OVERHEAD_LEN_PRE;
      var rowStartOffset = startOffset;
      var payloadSum = startOffset;
      var tds = payload[0];
      for (var tIndex = 0, tLen = tds.length; tIndex < tLen; tIndex++) {
        var overHeadLen = this.vars.OVERHEAD_LEN_MID;
        if (tIndex == tLen - 1) {
          overHeadLen = this.vars.OVERHEAD_LEN_ROW_END;
        }
        payloadSum += tds[tIndex].length + overHeadLen;
        if (tIndex >= tdIndex) {
          return {
            cellStartOffset: payloadSum - tds[tIndex].length - overHeadLen,
            cellEndOffset: payloadSum
          }
        }
      }
    };
    dt.getNextTdInfo = function (payload, currTdInfo) {
      var rep = this.context.rep;
      var startOffset = currTdInfo.rowEndOffset;
      var rowStartOffset = startOffset;
      var payloadSum = startOffset;
      var tds = payload[currTdInfo.row];
      for (var tIndex = 0, tLen = tds.length; tIndex < tLen; tIndex++) {
        var overHeadLen = this.vars.OVERHEAD_LEN_MID;
        if (tIndex == tLen - 1) {
          overHeadLen = this.vars.OVERHEAD_LEN_ROW_END;
        }
        payloadSum += tds[tIndex].length + overHeadLen;
        if (tIndex >= currTdInfo.td) {
          var leftOverTdTxtLen = payloadSum - startOffset == 0 ? payload[currTdInfo.row + 1][tIndex].length + this.vars.OVERHEAD_LEN_MID : payloadSum - startOffset;
          var rowEndOffset = this._getRowEndOffset(rowStartOffset, tds);
          var tdInfo = {
            row: currTdInfo.row + 1,
            td: tIndex,
            leftOverTdTxtLen: leftOverTdTxtLen,
            rowStartOffset: rowStartOffset,
            rowEndOffset: rowEndOffset,
            cellStartOffset: payloadSum - tds[tIndex].length - overHeadLen,
            cellEndOffset: payloadSum
          };
          return tdInfo;
        }
      }
    };
    //insert a column.
    dt.insertTblColumn = function (leftOrRight, start, end) {
      var rep = this.context.rep;
      var func = 'insertTblColumn()';
      try {
        var currLineText = rep.lines.atIndex(rep.selStart[0]).text;
        var tblJSONObj = JSON.parse(currLineText);
        var payload = tblJSONObj.payload;
        var currTdInfo = this.getFocusedTdInfo(payload, rep.selStart[1]);
        var currTd = currTdInfo.td;
        start = [], end = [];
        start[0] = rep.selStart[0];
        start[1] = rep.selStart[1];
        end[0] = rep.selEnd[0];
        end[1] = rep.selEnd[1];
        if (leftOrRight == "addL") {
          currTd -= 1;
        }
        var numOfLinesAbove = this.getTblAboveRowsFromCurFocus(start);
        rep.selEnd[0] = rep.selStart[0] = rep.selStart[0] - numOfLinesAbove;
        while (rep.selStart[0] < rep.lines.length() && rep.lines.atIndex(rep.selStart[0]).text.indexOf('data-tables') != -1) { //count num of rows above current pos
          var currLineText = rep.lines.atIndex(rep.selStart[0]).text;
          var tblJSONObj = JSON.parse(currLineText);
          var payload = tblJSONObj.payload;
          var cellPos = this.getTdInfo(payload, currTd).cellEndOffset;
          var newText = '" ",';
          if (currTd == payload[0].length - 1) { //add to the most right
            rep.selStart[1] = rep.selEnd[1] = cellPos - this.vars.OVERHEAD_LEN_ROW_END + 1;
            newText = '," "';
          } else if (currTd == -1) { //add to most left
            rep.selStart[1] = rep.selEnd[1] = this.vars.OVERHEAD_LEN_PRE - 1;
          } else {
            rep.selStart[1] = rep.selEnd[1] = cellPos - 1;
          }
          this.context.editorInfo.ace_performDocumentReplaceRange(rep.selStart, rep.selEnd, newText);
          rep.selEnd[0] = rep.selStart[0] = rep.selStart[0] + 1;
        }
        rep.selStart = start;
        rep.selEnd = end;
        if (leftOrRight == "addL") {
          rep.selStart[1] = rep.selEnd[1] = this.vars.OVERHEAD_LEN_PRE;
          rep.selStart[0] = rep.selEnd[0] = rep.selStart[0];
          this.updateTblPropInAPool(0, 0, null, rep.selStart);
          rep.selStart[1] = rep.selEnd[1] = this.vars.OVERHEAD_LEN_PRE;
        }
        currTd++;
        var updateEvenOddBgColor = false;
        var updateColAttrs = true;
        this.sanitizeTblProperties(start, updateEvenOddBgColor, updateColAttrs, currTd, "add")
        this.context.editorInfo.ace_performDocumentReplaceRange(rep.selStart, rep.selEnd, "");
      } catch (error) {
        //domline.createErrorState(start,end,'insertTblColumn',rep.lines.atIndex(rep.selStart[0]).text,rep.selStart,rep.selEnd,"",error);
      }
    };
    dt.deleteTblColumn = function () {
      var func = 'deleteTblColumn()';
      var rep = this.context.rep;
      try {
        var currLineText = rep.lines.atIndex(rep.selStart[0]).text;
        var tblJSONObj = JSON.parse(currLineText);
        var payload = tblJSONObj.payload;
        if (payload[0].length == 1) {
          deleteTable();
        }
        var currTdInfo = this.getFocusedTdInfo(payload, rep.selStart[1]);
        var currTd = currTdInfo.td;
        var start = [],
          end = [];
        start[0] = rep.selStart[0];
        start[1] = rep.selStart[1];
        end[0] = rep.selEnd[0];
        end[1] = rep.selEnd[1];
        var numOfLinesAbove = this.getTblAboveRowsFromCurFocus(start);
        rep.selEnd[0] = rep.selStart[0] = rep.selStart[0] - numOfLinesAbove;
        while (rep.selStart[0] < rep.lines.length() && rep.lines.atIndex(rep.selStart[0]).text.indexOf('data-tables') != -1) { //count num of rows above current pos
          var currLineText = rep.lines.atIndex(rep.selStart[0]).text;
          var tblJSONObj = JSON.parse(currLineText);
          var payload = tblJSONObj.payload;
          var cellTdInfo = this.getTdInfo(payload, currTd);
          var newText = '" ",';
          if (currTd == payload[0].length - 1) { //remove most right col
            rep.selStart[1] = cellTdInfo.cellStartOffset - 2;
            rep.selEnd[1] = cellTdInfo.cellEndOffset - 2;
          } else if (currTd == 0) { //remove most left col
            rep.selStart[1] = this.vars.OVERHEAD_LEN_PRE - 1;
            rep.selEnd[1] = cellTdInfo.cellEndOffset - 1;
          } else {
            rep.selStart[1] = cellTdInfo.cellStartOffset - 1
            rep.selEnd[1] = cellTdInfo.cellEndOffset - 1;
          }
          this.context.editorInfo.ace_performDocumentReplaceRange(rep.selStart, rep.selEnd, "");
          rep.selEnd[0] = rep.selStart[0] = rep.selStart[0] + 1;
        }
        rep.selStart = start;
        rep.selEnd = end;
        var updateEvenOddBgColor = false;
        var updateColAttrs = true;
        this.sanitizeTblProperties(start, updateEvenOddBgColor, updateColAttrs, currTd, "del")
        this.updateAuthorAndCaretPos(rep.selStart[0], 0, 0);
      } catch (error) {
        //domline.createErrorState(start,end,'deleteTblColumn',rep.lines.atIndex(rep.selStart[0]).text,rep.selStart,rep.selEnd,"",error);
      }
    }
    dt.insertTblRowBelow = function (numOfRows, table) {
      var context = this.context;
      var rep = context.rep;
      var currLineText = rep.lines.atIndex(rep.selStart[0]).text;
      var payload = [
        []
      ];
      if (!numOfRows && numOfRows != 0) {
        var tblPayload = JSON.parse(currLineText).payload;
        numOfRows = tblPayload[0].length;
      }
      var tblRows = new Array(numOfRows);
      if (numOfRows != 0) {
        for (var i = 0; i < tblRows.length; i++) {
          tblRows[i] = " ";
        }
      }
      payload = [tblRows];
      if (table) {
        payload = table.payload;
      }
      tableObj = {
        "payload": payload,
        "tblId": 1,
        "tblClass": "data-tables",
        "trClass": "alst",
        "tdClass": "hide-el"
      }
      rep.selEnd[1] = rep.selStart[1] = currLineText.length;
      this.context.editorInfo.ace_inCallStackIfNecessary('newline', this.context.editorInfo.ace_doReturnKey);
      context.editorInfo.ace_performDocumentReplaceRange(rep.selStart, rep.selEnd, JSON.stringify(tableObj));
    };
    dt.doReturnKey = function () {
      var context = this.context;
      var rep = context.rep;
      var start = rep.seStart;
      var end = rep.selEnd;
      lastTblPropertyUsed = 'doTableReturnKey';
      var currLine = rep.lines.atIndex(rep.selStart[0]);
      var currLineText = currLine.text;
      if (currLineText.indexOf('data-tables') == -1) return false;
      else {
        var func = 'doTableReturnKey()';
        try {
          var currCarretPos = rep.selStart[1];
          if (currLineText.substring(currCarretPos - 1, currCarretPos + 2) == '","') return true;
          else if (currLineText.substring(currCarretPos - 2, currCarretPos + 1) == '","') return true;
          else if (currCarretPos < this.vars.OVERHEAD_LEN_PRE) return true;
          else if (currCarretPos > currLineText.length) return true;
          var start = rep.selStart,
            end = rep.selEnd;
          newText = " /r/n ";
          start[1] = currCarretPos;
          end[1] = currCarretPos;
          try {
            var jsonObj = JSON.parse(currLineText.substring(0, start[1]) + newText + currLineText.substring(start[1]));
            payloadStr = JSON.stringify(jsonObj.payload);
            if (currCarretPos > payloadStr.length + this.vars.OVERHEAD_LEN_PRE - 2) {
              return true;
            }
          } catch (error) {
            return true;
          }
          context.editorInfo.ace_performDocumentReplaceRange(start, end, newText);
        } catch (error) {}
        return true;
      }
    };
    dt.isCellDeleteOk = function (keyCode) {
      var context = this.context;
      var rep = context.rep;
      var start = rep.selStart;
      var end = rep.selEnd;
      var currLine = rep.lines.atIndex(rep.selStart[0]);
      var currLineText = currLine.text;
      if (currLineText.indexOf('data-tables') == -1) return true;
      var isDeleteAccepted = false;
      try {
        var tblJSONObj = JSON.parse(currLineText);
        var table = tblJSONObj.payload;
        var currTdInfo = this.getFocusedTdInfo(table, rep.selStart[1]);
        cellEntryLen = table[currTdInfo.row][currTdInfo.td].length;
        var currCarretPos = rep.selStart[1];
        if (currLineText.substring(currCarretPos - 1, currCarretPos + 2) == '","') return false;
        else if (currLineText.substring(currCarretPos - 2, currCarretPos + 1) == '","') return false;
        switch (keyCode) {
        case this.vars.JS_KEY_CODE_BS:
          if (cellEntryLen != 0 && cellEntryLen > (currTdInfo.leftOverTdTxtLen - this.vars.OVERHEAD_LEN_MID)) {
            isDeleteAccepted = true;
          }
          break;
        case this.vars.JS_KEY_CODE_DEL:
          return false; //disabled for the moment
          if (cellEntryLen != 0 && currTdInfo.leftOverTdTxtLen - this.vars.OVERHEAD_LEN_MID > 0) {
            isDeleteAccepted = true;
          }
          break;
        default:
          // cntrl H
          if (cellEntryLen != 0 && cellEntryLen > (currTdInfo.leftOverTdTxtLen - this.vars.OVERHEAD_LEN_MID)) {
            isDeleteAccepted = true;
          }
          break;
        }
      } catch (error) {
        isDeleteAccepted = false;
      }
      return isDeleteAccepted;
    };
    dt.nodeTextPlain = function (n) {
      return n.innerText || n.textContent || n.nodeValue || '';
    }
    // Get the text within an element
    // Doesn't do any normalising, returns a string
    // of text as found.
    dt.toString = function () {
      return "ep_tables2";
    };
    dt.getLineAndCharForPoint = function () {
      var context = this.context;
      var point = context.point;
      var root = context.root;
      // Turn DOM node selection into [line,char] selection.
      // This method has to work when the DOM is not pristine,
      // assuming the point is not in a dirty node.
      if (point.node == root) {
        if (point.index == 0) {
          return [0, 0];
        } else {
          var N = this.context.rep.lines.length();
          var ln = this.context.rep.lines.atIndex(N - 1);
          return [N - 1, ln.text.length];
        }
      } else {
        var n = point.node;
        var col = 0;
        // if this part fails, it probably means the selection node
        // was dirty, and we didn't see it when collecting dirty nodes.
        if (nodeText(n) || point.index > 0) {
          col = point.index;
        }
        var parNode, prevSib;
        while ((parNode = n.parentNode) != root) {
          if ((prevSib = n.previousSibling)) {
            n = prevSib;
            var textLen = nodeText(n).length == 0 ? this.nodeTextPlain(n).length : nodeText(n).length;
            col += textLen;
          } else {
            n = parNode;
          }
        }
        if (n.id == "") console.debug("BAD");
        if (n.firstChild && context.editorInfo.ace_isBlockElement(n.firstChild)) {
          col += 1; // lineMarker
        }
        var lineEntry = this.context.rep.lines.atKey(n.id);
        var lineNum = this.context.rep.lines.indexOfEntry(lineEntry);
        return [lineNum, col];
      }
    };
    dt.doDeleteKey = function () {
      var context = this.context;
      var evt = context.evt || {};
      var handled = false;
      var rep = this.context.rep;
      var editorInfo = context.editorInfo;
      if (rep.selStart) {
        //end tbl-mod-by-wlos
        if (editorInfo.ace_isCaret()) {
          var lineNum = editorInfo.ace_caretLine();
          var col = editorInfo.ace_caretColumn();
          var lineEntry = rep.lines.atIndex(lineNum);
          var lineText = lineEntry.text;
          var lineMarker = lineEntry.lineMarker;
          if (/^ +$/.exec(lineText.substring(lineMarker, col))) {
            var col2 = col - lineMarker;
            var tabSize = ''.length; // zero for now, tabs are not supported within tables
            var toDelete = ((col2 - 1) % tabSize) + 1;
            editorInfo.ace_performDocumentReplaceRange([lineNum, col - toDelete], [lineNum, col], '');
            //scrollSelectionIntoView();
            handled = true;
          }
        }
        if (!handled) {
          if (editorInfo.ace_isCaret()) {
            var theLine = editorInfo.ace_caretLine();
            var lineEntry = rep.lines.atIndex(theLine);
            if (editorInfo.ace_caretColumn() <= lineEntry.lineMarker) {
              // delete at beginning of line
              var action = 'delete_newline';
              var prevLineListType = (theLine > 0 ? editorInfo.ace_getLineListType(theLine - 1) : '');
              var thisLineListType = editorInfo.ace_getLineListType(theLine);
              var prevLineEntry = (theLine > 0 && rep.lines.atIndex(theLine - 1));
              var prevLineBlank = (prevLineEntry && prevLineEntry.text.length == prevLineEntry.lineMarker);
              if (thisLineListType) {
                // this line is a list
                if (prevLineBlank && !prevLineListType) {
                  // previous line is blank, remove it
                  editorInfo.ace_performDocumentReplaceRange([theLine - 1, prevLineEntry.text.length], [theLine, 0], '');
                } else {
                  // delistify
                  editorInfo.ace_performDocumentReplaceRange([theLine, 0], [theLine, lineEntry.lineMarker], '');
                }
              } else if (theLine > 0) {
                // remove newline
                editorInfo.ace_performDocumentReplaceRange([theLine - 1, prevLineEntry.text.length], [theLine, 0], '');
              }
            } else {
              var docChar = editorInfo.ace_caretDocChar();
              if (docChar > 0) {
                if (evt.metaKey || evt.ctrlKey || evt.altKey) {
                  // delete as many unicode "letters or digits" in a row as possible;
                  // always delete one char, delete further even if that first char
                  // isn't actually a word char.
                  var deleteBackTo = docChar - 1;
                  while (deleteBackTo > lineEntry.lineMarker && editorInfo.ace_isWordChar(rep.alltext.charAt(deleteBackTo - 1))) {
                    deleteBackTo--;
                  }
                  editorInfo.ace_performDocumentReplaceCharRange(deleteBackTo, docChar, '');
                } else {
                  var returnKeyWitinTblOffset = 0;
                  if (lineText.substring(col - 5, col) == '/r/n ') {
                    returnKeyWitinTblOffset = 4;
                  }
                  // normal or table return key delete
                  editorInfo.ace_performDocumentReplaceCharRange(docChar - 1 - returnKeyWitinTblOffset, docChar, '');
                }
              }
            }
          } else {
            editorInfo.ace_performDocumentReplaceRange(rep.selStart, rep.selEnd, "");
          }
        }
      }
      //if the list has been removed, it is necessary to renumber
      //starting from the *next* line because the list may have been
      //separated. If it returns null, it means that the list was not cut, try
      //from the current one.
      var line = editorInfo.ace_caretLine();
      if (line != -1 && editorInfo.ace_renumberList(line + 1) === null) {
        editorInfo.ace_renumberList(line);
      }
    };
    dt.getLineTableProperty = function (lineNum) {
      var rep = this.context.rep;
      // get "tblProp" attribute of first char of line
      var aline = rep.alines[lineNum];
      if (aline) {
        var opIter = Changeset.opIterator(aline);
        if (opIter.hasNext()) {
          var tblJSString = Changeset.opAttributeValue(opIter.next(), 'tblProp', rep.apool);
          try {
            return JSON.parse(tblJSString);
          } catch (error) {
            return this.defaults.tblProps;
          }
        }
      }
      return this.defaults.tblProps;
    };
    dt.updateTblPropInAPool = function (row, td, jsoTblProp, start) {
      try {
        var rep = this.context.rep;
        var tblProps;
        var editorInfo = this.context.editorInfo;
        var thisAuthor = editorInfo.ace_getAuthor();
        var authorInfos = editorInfo.ace_getAuthorInfos();
        if (typeof (jsoTblProp) == 'undefined' || jsoTblProp == null) {
          jsoTblProp = this.getLineTableProperty(start[0]);
        }
        if (row != -1 && td != -1) {
          jsoTblProp['authors'][thisAuthor] = {
            row: row,
            cell: td,
            colorId: authorInfos[thisAuthor].bgcolor
          };
        }
        var jsoStrTblProp = JSON.stringify(jsoTblProp);
        var attrStart = [],
          attrEnd = [];
        attrStart[0] = start[0], attrStart[1] = 0;
        attrEnd[0] = start[0], attrEnd[1] = rep.lines.atIndex(start[0]).text.length;
        editorInfo.ace_performDocumentApplyAttributesToRange(attrStart, attrEnd, [
          ["tblProp", jsoStrTblProp]
        ]);
      } catch (error) {
        //createErrorState(start, start, 'updateTblPropInAPool', rep.lines.atIndex(start[0]).text, [row,td], [row,td], "", error);
      }
    };
    dt.getCurrTblOddEvenRowBgColor = function (startRowNum, currRowNum) {
      var rowBgColors = {
        oddBgColor: null,
        evenBgColor: null
      };
      if (startRowNum != currRowNum) {
        var jsoTblProp1 = this.getLineTableProperty(startRowNum);
        var jsoTblProp2 = this.getLineTableProperty(startRowNum + 1);
        rowBgColors.evenBgColor = jsoTblProp1['rowAttrs']['evenBgColor'] || jsoTblProp2['rowAttrs']['evenBgColor'];
        rowBgColors.oddBgColor = jsoTblProp1['rowAttrs']['oddBgColor'] || jsoTblProp2['rowAttrs']['oddBgColor'];
      }
      return rowBgColors;
    };
    dt.getTblAboveRowsFromCurFocus = function (start) {
      var rep = this.context.rep;
      var numOfLinesAbove = 0;
      var line = start[0] - 1;
      while (rep.lines.atIndex(line).text.indexOf('data-tables') != -1) { //count num of rows above current pos
        numOfLinesAbove++;
        line--;
      }
      return numOfLinesAbove;
    }
    dt.updateTableIndices = function (tblProperties, currTd, addOrDel) {
      cellAttrs = tblProperties.cellAttrs;
      for (var rIndex = 0, rLen = cellAttrs.length; rIndex < rLen; rIndex++) {
        var cellAttr = cellAttrs[rIndex];
        if (addOrDel == 'add') { //insert column
          if (cellAttr) {
            cellAttr.splice(currTd, 0, null);
          }
        } else { //remove column
          if (cellAttr) {
            cellAttr.splice(currTd, 1);
          }
        }
      }
      //col attrs
      colAttrs = tblProperties.colAttrs;
      if (addOrDel == 'add') { //insert column
        if (colAttrs) {
          colAttrs.splice(currTd, 0, null);
        }
      } else { //remove column
        if (colAttrs) {
          colAttrs.splice(currTd, 1);
        }
      }
      return tblProperties;
    };
    dt.sanitizeTblProperties = function (start, updateEvenOddBgColor, updateColAttrs, currTd, addOrDel) {
      var rep = this.context.rep;
      var editorInfo = this.context.editorInfo;
      var thisAuthor = editorInfo.ace_getAuthor();
      var numOfLinesAbove = this.getTblAboveRowsFromCurFocus(start);
      var tempStart = [];
      tempStart[0] = start[0] - numOfLinesAbove;
      var evenOddRowBgColors = {};
      if (updateEvenOddBgColor) {
        //evenOddRowBgColors=getCurrTblOddEvenRowBgColor(tempStart[0],start[0]);
      }
      while (tempStart[0] < rep.lines.length() && rep.lines.atIndex(tempStart[0]).text.indexOf('data-tables') != -1) { //start from top of a table
        var jsoTblProp = this.getLineTableProperty(tempStart[0]);
        var update = false;
        if (tempStart[0] != start[0] && jsoTblProp['authors'] && jsoTblProp['authors'][thisAuthor]) {
          delete jsoTblProp['authors'][thisAuthor];
          update = true;
        }
        if (updateColAttrs) {
          jsoTblProp = this.updateTableIndices(jsoTblProp, currTd, addOrDel);
          update = true;
        }
        if (tempStart[0] != start[0] && updateEvenOddBgColor) {
          delete jsoTblProp['rowAttrs']['oddBgColor'];
          delete jsoTblProp['rowAttrs']['evenBgColor'];
          update = true;
        }
        if (update) {
          this.updateTblPropInAPool(-1, -1, jsoTblProp, tempStart);
        }
        tempStart[0] = tempStart[0] + 1;
      }
    };
    dt.updateTblPropInAPool = function (row, td, jsoTblProp, start) {
      try {
        var rep = this.context.rep;
        var editorInfo = this.context.editorInfo;
        var thisAuthor = editorInfo.ace_getAuthor();
        var authorInfos = editorInfo.ace_getAuthorInfos();
        var tblProps;
        if (typeof (jsoTblProp) == 'undefined' || jsoTblProp == null) {
          jsoTblProp = this.getLineTableProperty(start[0]);
        }
        if (row != -1 && td != -1) {
          jsoTblProp['authors'][thisAuthor] = {
            row: row,
            cell: td,
            colorId: authorInfos[thisAuthor].bgcolor
          };
        }
        var jsoStrTblProp = JSON.stringify(jsoTblProp);
        var attrStart = [],
          attrEnd = [];
        attrStart[0] = start[0], attrStart[1] = 0;
        attrEnd[0] = start[0], attrEnd[1] = rep.lines.atIndex(start[0]).text.length;
        editorInfo.ace_performDocumentApplyAttributesToRange(attrStart, attrEnd, [
          ["tblProp", jsoStrTblProp]
        ]);
      } catch (error) {
        //createErrorState(start, start, 'updateTblPropInAPool', rep.lines.atIndex(start[0]).text, [row,td], [row,td], "", error);
      }
    };
    dt.updateTblCellAuthor = function (row, td, tblProperties, start, updateEvenOddBgColor) {
      try {
        this.updateTblPropInAPool(row, td, tblProperties, start);
        var tempStart = [];
        tempStart[0] = start[0];
        tempStart[1] = start[1];
        this.sanitizeTblProperties(tempStart, updateEvenOddBgColor);
      } catch (error) {
        //createErrorState(start, end, 'updateTblCellAuthor', rep.lines.atIndex(start).text, rep.selStart, rep.selEnd, "", error);
      }
    }
    return dt;
  }(); // end of anonymous function
typeof (exports) != 'undefined' ? exports.Datatables = Datatables : null;


text:
This project provides an example of Verilog compilation from an IEC61499 network described in TFB.

The system is an overcurrent detector breaker based on an IDMT curve.


text:
EdgeConf 2015 Frontend Data talk
=====

Nolan's 10-minute talk for [the frontend data panel](https://edgeconf.com/2015-london/schedule),
written in Reveal.js. Pull requests welcome!


text:
package psymbolic.runtime.values;

public abstract class PCollection extends PValue<PCollection>{
    public abstract int size();

    public abstract boolean contains(PValue<?> item);
}


text:
describe('containers', function() {
  require('./HomePage');
});


text:
package alluxio.grpc;

public interface SetAclPResponseOrBuilder extends
    // @@protoc_insertion_point(interface_extends:alluxio.grpc.file.SetAclPResponse)
    com.google.protobuf.MessageOrBuilder {
}


text:
/**
 * @since 2016-11-16 16:45
 * @author vivaxy
 */

import yargs from 'yargs';

export const command = 'config <command> ...';
export const describe = 'Show or edit configs';
export const builder = () => {
    return yargs.commandDir('./config-commands');
};
export const handler = () => {};


text:
IETF YANG Definitions
=====================

### IP Interface model

This directory contains IETF YANG definition for IP Interface model.  Original YANG files are in [YANG ietf RFC repository](https://github.com/YangModels/yang/tree/master/standard/ietf/RFC).

Here is a list of file name in here and original file in the repository

|File name           |Original repository file name                      |
|--------------------|-------------------------------|
|ietf-interfaces.yang|ietf-interfaces@2014-05-08.yang|
|ietf-inet-types.yang|ietf-inet-types@2013-07-15.yang|
|ietf-yang-types     |ietf-yang-types@2013-07-15.yang|
|ietf-ip.yang        |ietf-ip@2014-06-16.yang        |


text:
/*
 * File:   ControllPort.hpp
 * Author: harald
 *
 * Created on September 21, 2012, 1:09 PM
 */

#ifndef CONTROLLPORT_HPP
#define	CONTROLLPORT_HPP

#include <jni.h>
#ifndef JNI_VERSION_1_2
#error "Needs Java version 1.2 or higher.\n"
#endif

#include <string>
#include <sstream>
#include "port.hpp"
#include "messages.hpp"

using namespace std;

/**
 * Control ports are used internally in the port-chain. Control ports
 * are not seen externally and cannot be accessed through the java
 * interface. In a port-chain there are two control-ports; one at the
 * beginning, the "start-port" and one at the end of the chain, the
 * "end-port". The tasks of these ports are:
 *

 *
provide events for the MidiSystemListener
 * (onCycleStart, onCycleEnd, onClose, onOpen)

 *
Synchronize the Java process-thread with the native callback
 * on an empty port-chain. Thus preventing the Java tread from
 * endlessly spinning in an empty loop wasting process resources.

 */
class ControlPort : public Port {
private:
  const string name;
  jobject systemListener;
  jmethodID onOpenMid;
  jmethodID onCycleMid;
  jmethodID onCloseMid;

  /** the timecode of the next java buffer */
  jlong timeCodeStartDeprecated;
  jack_nframes_t timeCodeDurationDeprecated;

public:

  /**
   * Creates a new control port.
   * @param _isEndPort true if this port will be inserted at the end
   * of the port-chain, false if the port will be inserted at the beginning
   * of the port-chain. Note: the end-port is internally an output port,
   * the start-port is internally an input port.
   * @param _name an arbitrary name for this pseudo port.
   * @param internalId by convention the start-port will get the ID -1
   * and the end-port shall get the ID -2.
   */
  ControlPort(bool _isEndPort, const string& _name, long internalId) :
  Port(_isEndPort, internalId),
  name(_name),
  systemListener(NULL),
  onOpenMid(NULL),
  onCycleMid(NULL),
  onCloseMid(NULL) {
  }

  ControlPort(ControlPort && other) = default;

  ControlPort(const ControlPort & other) = delete;

  virtual ~ControlPort() {

  }

protected:

  /**
   * 1) Store the pointer to the listener (this will exclude it from garbage collection).
   * 2) cache the method-identifiers of the listeners methods.
   * 3) prepare a number of Java Arrays that we'll use to transfer data from Java to native
   * 4) execute the listeners onOpen method.
   * @param env the java environment pointer
   * @param name is ignored (the name is given in the constructor)
   * @param _javaPort a reference to the listener.
   * java class: public interface MidiIO4Java.MidiSystemListener
   */
  virtual void initialize_impl(JNIEnv * env, jstring /*name*/, jobject _systemListener)override {
    // pin the java-port
    systemListener = env->NewGlobalRef(_systemListener);
    if (systemListener == NULL) {
      THROW("Call to NewGlobalRef function failed.")
    }
    // --- cache the method IDs of the callback functions in the java port.
    jclass listenerClass = env->GetObjectClass(systemListener);

    if (listenerClass == NULL) {
      THROW("MidiSystemListener class not found.")
    }
    onOpenMid = env->GetMethodID(listenerClass, "onOpen", "()V");
    if (isInput()) {
      // Note: it might not be very clean to map two different java procedures
      // to one and the same identifier. But as the two procedures
      // must have the same signature, this works nicely and avoids
      // to have to make the distinction between input- and output- port in
      // the execJavaProcess_impl function.
      onCycleMid = env->GetMethodID(listenerClass, "onCycleStart", "(JJZ)V");
    } else {
      onCycleMid = env->GetMethodID(listenerClass, "onCycleEnd", "(JJZ)V");
    }
    onCloseMid = env->GetMethodID(listenerClass, "onClose", "()V");
    if ((onOpenMid == NULL) || (onCycleMid == NULL) || (onCloseMid == NULL)) {
      THROW("Method-identifier not found.")
    }

    // --- the startControl shall call MidiSystemListener.onOpen()
    if (isInput()) {
      env->CallVoidMethod(systemListener, onOpenMid);
    }
  }

  virtual void register_impl(void * client)override {
    if (client == nullptr) {
      THROW("Client was NULL.")
    }
    jack_client_t * jackClient = static_cast<jack_client_t *> (client);

  }

  virtual void start_impl()override {
  }

  virtual void execJavaProcess_impl(JNIEnv * env, unsigned long timeCodeStart, unsigned long timeCodeDuration, bool lastCycle)override {

    // perform call-backs
    env->CallVoidMethod(systemListener, onCycleMid,
            (jlong)timeCodeStart, // java signature: long timestamp,
            (jlong)timeCodeDuration, // java signature: long timeCodeDuration
            (jboolean)lastCycle); // java signature: boolean lastCycle

  }

  virtual void execNativeProcess_impl(unsigned long _timeCodeStart, unsigned long _timeCodeDuration, void * client)override {
  }

  virtual void stop_impl()override {
  }

  virtual void unregister_impl(void * client)override {
  }

  /**
   * 1) execute the listeners onClose method.
   * 2) Free the pointer to the listener (this will include it into garbage collection).
   * @param env
   */
  virtual void uninitialize_impl(JNIEnv * env) override {
    if ((systemListener == NULL) || (onCloseMid == NULL)) {
      THROW("Invalid null pointer.")
    }
    // --- the endControl shall call MidiSystemListener.onClose()
    if (isOutput()) {
      env->CallVoidMethod(systemListener, onCloseMid);
    }
    env->DeleteGlobalRef(systemListener);
    systemListener = NULL;
    onOpenMid = NULL;
    onCycleMid = NULL;
    onCloseMid = NULL;
  }
};

#endif	/* JACKOUTPUTPORT_HPP */


text:
import { Component } from '@angular/core';
import { ROUTER_DIRECTIVES } from '@angular/router';

import { HeroService } from './hero.service';

@Component({
  selector: 'my-app',
  // #docregion template
  template: `

{{title}}

      Dashboard
      Heroes

    <router-outlet></router-outlet>
  `,
  // #enddocregion template
  // #docregion style-urls
  styleUrls: ['app/app.component.css'],
  // #enddocregion style-urls
  directives: [ROUTER_DIRECTIVES],
  providers: [
    HeroService
  ]
})
export class AppComponent {
  title = 'Tour of Heroes';
}


text:
package abalufaske.where.is;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;

import org.json.JSONException;
import org.json.JSONObject;

import abalufaske.where.is.BaseDatos;
import abalufaske.where.is.commonconstants;

import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteConstraintException;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

import static abalufaske.where.is.commonconstants.*;

public class ParkingDB extends BaseDatos{

	   private final String[] listColumns;

	    /**
	     * Constructor
	     * @param con Contexto
	     */
	    public ParkingDB(final Context con) {
	        super(con);

	        	listColumns = new String[] {TABLE_PARKING_ID,
	        			TABLE_PARKING_COLOR,
	        			TABLE_PARKING_FLOOR,
	        			TABLE_PARKING_NUM,
	        			TABLE_PARKING_SECTION,
	        			TABLE_PARKING_NOTES
	    			  };

	    }

	    /**
	     * Editar un lugar en la base de datos
	     * @param place Lugar a editar
	     * @return True si se ha realizado con éxito. False en caso contrario.
	     * @throws JSONException
	     */

	    public Cursor fetch(long idPlace, Context con){

	        BaseDatos myDbHelper = new BaseDatos(con);

	    	try {

		 		myDbHelper.openDataBase();

		 	}catch(SQLException sqle){

		 		throw sqle;

		 	}

	    	Log.d("bit"," estoy aki");

	    	Cursor mCursor = myDbHelper.myDataBase.query(TABLE_PARKING, listColumns, TABLE_PARKING_ID + "=" + idPlace, null, null, null, null, null);
	  //  	Cursor mCursor = myDataBase.query(true, TABLE_FACULTY, listColumns, TABLE_FACULTY_FAV + "=" + 1, null, null, null, null, null);

	    	Log.d("bit"," datos "+mCursor.getCount());
	    	myDbHelper.close();
	    	if (mCursor != null) {
				mCursor.moveToFirst();
			}
			return mCursor;
	    }

	    /**
	     * Devuelve un objeto Place a partir de un id.
	     * @param idPlace id del objeto
	     * @return Un objeto Place
	     */
	    public Place get(long idPlace, Context con){
	    	Cursor crs = fetch(idPlace, con);
	        Place place = new Place(crs);
	        crs.close();
	        return place;
	    }

	    /**
	     * Devuelve un cursor con la lista de todos los lugares
	     * @param facultad
	     * @return Un cursor
	     */
	    public Cursor fetchAll(Context con, int facultad){
	    	Log.d("byte"," fetchAll ");

	        BaseDatos myDbHelper = new BaseDatos(con);

	  	    	try {

	  		 		myDbHelper.openDataBase();

	  		 	}catch(SQLException sqle){

	  		 		throw sqle;

	  		 	}
	  	    	Cursor 	mCursor =null;
	  	    	//= myDbHelper.myDataBase.query( TABLE_FACULTY, listColumns,null, null, null, null, null, null);

	  	    	if (facultad == 0)
	  	    	{

	  	    	}
  	    //	mCursor = myDbHelper.myDataBase.query( TABLE_ITEMS, listColumns,null, null, null, null, TABLE_ITEMS_LAST , null);

	   	    	mCursor = myDbHelper.myDataBase.query( TABLE_PARKING, listColumns,null, null, null, null, null, null);

	    	return mCursor;
	    }

	    /**
	     * Crea una lista de lugares a partir de lo que devuelve un cursor. Todos lo métodos get la usan pues
	     * todos ellos devuelve una lista de lugares a partir de un cursor.
	     * @param crs
	     * @return
	     */
	    private List<Parking> listPlaceFromCursor(Cursor crs){
	    	List<Parking> mListPlaces = new ArrayList<Parking>();
	    	crs.moveToFirst();
	    	while (!crs.isAfterLast()){
	    		Parking parking = new Parking(crs);
	    		mListPlaces.add(parking);
	    		crs.moveToNext();
	    	}
	    	crs.close();
	    	return mListPlaces;
	    }

		public List<Parking> getAll(Context applicationContext, int facultad) {
			Cursor crs = fetchAll(applicationContext, facultad);
	    	return listPlaceFromCursor(crs);
		}

		/*
		 * */

	    /**
	     * Cuenta el número de registros de la tabla places. Se utiliza para saber si la bbdd está vacía
	     * @return Un entero con el número de registros
	     */
	/*    public int getCount(){
	    	int count;
	    	Cursor crs = fetchAll();
	    	count = crs.getCount();
	    	crs.close();
	    	return count;
	    }*/

/**
 * Cambia el estado "favorito" de una evento.
 * @param idEvent Evento al que se le cambiará el estado
 * @param idPoi Id del poi en el que está el evento
 * @param status Entero que define el estado de favorito: 0=no favorito 1=favorito
 * @return True si se ha ejecutado la sentecia. False en caso contrario
 *
 */

		public boolean setName (final long idItem , final String Name)

		{
		  	  Log.d("byte"," entro en setName ? ");

		    SQLiteDatabase db = getWritableDatabase();
		    ContentValues cv = new ContentValues();
		    cv.put(TABLE_ITEMS_NAME,Name); //These Fields should be your String values of actual column names
		  	  Log.d("byte"," ajusto el content values ");

		    if(  db.update(TABLE_ITEMS, cv, TABLE_ITEMS_ID +" = "+idItem, null) >0)

		    {
		  	  db.close();
		  	  Log.d("byte"," asereje ja dejé ? ");
		  	  return true;
		    }

		    db.close();
		      return false;
		}

		public boolean setLat (final long idItem , final String Latitude)

		{
		  	  Log.d("byte"," entro en setName ? ");

		    SQLiteDatabase db = getWritableDatabase();
		    ContentValues cv = new ContentValues();
		    cv.put(TABLE_ITEMS_LATITUDE,Latitude); //These Fields should be your String values of actual column names
		  	  Log.d("byte"," ajusto el content values ");

		    if(  db.update(TABLE_ITEMS, cv, TABLE_ITEMS_ID +" = "+idItem, null) >0)

		    {
		  	  db.close();
		  	  Log.d("byte"," asereje ja dejé ? ");
		  	  return true;
		    }

		    db.close();
		      return false;
		}

		public boolean setParking (final int color , final int floor, final int number, final String Section , final String Notes)

		{
		long id = 1;
			/*
			 * 		TABLE_PARKING_COLOR+" integer, " +
		TABLE_PARKING_FLOOR+" integer, " +
		TABLE_PARKING_NUM+" integer, " +
		TABLE_PARKING_SECTION+" varchar(1), " +
		TABLE_PARKING_NOTES+" varchar(200));" ;
			 */
		String temp ="";
			if(Section.length()==0)
			{

			}
			else
			{
				 temp = Section.substring(0, 1);
			}
			Log.d("mes","entro al set parking? ");
		    SQLiteDatabase db = getWritableDatabase();
		    ContentValues cv = new ContentValues();
		    cv.put(TABLE_PARKING_COLOR,color);
		    cv.put(TABLE_PARKING_FLOOR,floor);
		    cv.put(TABLE_PARKING_NUM,number);
		    cv.put(TABLE_PARKING_SECTION,temp);
		    cv.put(TABLE_PARKING_NOTES,Notes);

		    //These Fields should be your String values of actual column names
		  	  Log.d("byte"," ajusto el content values ");

		    if(  db.update(TABLE_PARKING, cv, TABLE_PARKING_ID +" = "+id, null) >0)

		    {
		  	  db.close();
		  	  Log.d("byte"," Parking updated? ");
		  	  return true;
		    }

		    db.close();
		      return false;
		}

		public boolean setPark (final long idItem, final int Last)

		{

			 SQLiteDatabase db = getWritableDatabase();
			    ContentValues cv = new ContentValues();
			    cv.put(TABLE_ITEMS_LAST, 0); //These Fields should be your String values of actual column names
			  	  Log.d("byte"," ajusto el content values ");
				    if(  db.update(TABLE_ITEMS, cv, TABLE_ITEMS_LAST +" = "+Last, null) >0)
				    {
					  	  Log.d("byte"," quito el last al que lo tenga ");

				    }

				    ContentValues cv2 = new ContentValues();
				    cv2.put(TABLE_ITEMS_LAST, String.valueOf(Last));
			    if(  db.update(TABLE_ITEMS, cv2, TABLE_ITEMS_ID +" = "+idItem, null) >0)

			    {
				  	  Log.d("byte"," cambio el last al que modifiquŽ ");

			  	  db.close();
			  	  return true;

				    }

			    db.close();
			  return false;
		}

	}


text:
class CreatePeriodTimings < ActiveRecord::Migration
  def self.up
    create_table :period_timings do |t|
      t.string :name
      t.time :start_time
      t.time :end_time
      t.boolean :break
    end
    create_defaults
  end

  def self.down
    drop_table :period_timings
  end

  def self.create_defaults
    PeriodTiming.create(:name => "1", :break => false)
    PeriodTiming.create(:name => "2", :break => false)
    PeriodTiming.create(:name => "Interval", :break => true)
    PeriodTiming.create(:name => "3", :break => false)
    PeriodTiming.create(:name => "4", :break => false)
    PeriodTiming.create(:name => "Lunch", :break => true)
    PeriodTiming.create(:name => "5", :break => false)
    PeriodTiming.create(:name => "6", :break => false)
    PeriodTiming.create(:name => "7", :break => false)
  end
end


text:
package com.google.cloud.resourcemanager.v3.samples;

// [START resourcemanager_v3_generated_foldersclient_movefolder_lro_async]
import com.google.api.gax.longrunning.OperationFuture;
import com.google.cloud.resourcemanager.v3.Folder;
import com.google.cloud.resourcemanager.v3.FolderName;
import com.google.cloud.resourcemanager.v3.FoldersClient;
import com.google.cloud.resourcemanager.v3.MoveFolderMetadata;
import com.google.cloud.resourcemanager.v3.MoveFolderRequest;

public class AsyncMoveFolderLRO {

  public static void main(String[] args) throws Exception {
    asyncMoveFolderLRO();
  }

  public static void asyncMoveFolderLRO() throws Exception {
    // This snippet has been automatically generated and should be regarded as a code template only.
    // It will require modifications to work:
    // - It may require correct/in-range values for request initialization.
    // - It may require specifying regional endpoints when creating the service client as shown in
    // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
    try (FoldersClient foldersClient = FoldersClient.create()) {
      MoveFolderRequest request =
          MoveFolderRequest.newBuilder()
              .setName(FolderName.of("[FOLDER]").toString())
              .setDestinationParent(FolderName.of("[FOLDER]").toString())
              .build();
      OperationFuture<Folder, MoveFolderMetadata> future =
          foldersClient.moveFolderOperationCallable().futureCall(request);
      // Do something.
      Folder response = future.get();
    }
  }
}
// [END resourcemanager_v3_generated_foldersclient_movefolder_lro_async]


text:
#include <bomp_internal.h>

/*
 * These functions implement the OpenMP CRITICAL construct
 *
 * With a specified name, use omp set lock and omp unset lock with name being
 * transformed into a variable declared like
 *
 * omp_lock_t gomp_critical_user_<name> __attribute__((common))
 * Ideally the ABI would specify that all zero is a valid unlocked state, and
 * so we wouldn't need to initialize this at startup.
 */

void GOMP_critical_start(void)
{
    assert(g_bomp_state);
    bomp_mutex_lock(&g_bomp_state->critical_lock);
}

void GOMP_critical_end(void)
{
    assert(g_bomp_state);
    bomp_mutex_unlock(&g_bomp_state->critical_lock);
}

void GOMP_critical_name_start(void **pptr)
{
    assert(!"NYI");
}

void GOMP_critical_name_end(void **pptr)
{
    assert(!"NYI");
}