// When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns. // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)), // since that's the earliest that a buffer overrun could occur. This way, checks are // as rare as required, but as often as necessary to ensure never crossing this bound. // Furthermore, buffers are only tested at most once per write(), so passing a very // large string into write() might have undesirable effects, but this is manageable by // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme // edge case, result in creating at most one complete copy of the string passed in. // Set to Infinity to have unlimited buffers. class Tag { var name : string; var attributes : Map.; var isSelfClosing : boolean; function constructor (name : string) { this.name = name; this.attributes = {} : Map.; this.isSelfClosing = false; } } class _Common { static const buffers = [ "comment", "sgmlDecl", "textNode", "tagName", "doctype", "procInstName", "procInstBody", "entity", "attribName", "attribValue", "cdata", "script" ]; static const EVENTS = // for discoverability. [ "text", "processinginstruction", "sgmldeclaration", "doctype", "comment", "attribute", "opentag", "closetag", "opencdata", "cdata", "clo_State.CDATA", "error", "end", "ready", "script", "opennamespace", "closenamespace" ]; static const MAX_BUFFER_LENGTH = 64 * 1024; } class _State { static const BEGIN = 1; static const TEXT = 2; // general stuff static const TEXT_ENTITY = 3; // & and such. static const OPEN_WAKA = 4; // < static const SGML_DECL = 5; // static const SCRIPT = 33; //