[Pkg-javascript-commits] [node-expat] 143/371: Exposing XML_ParserReset.
Jonas Smedegaard
dr at jones.dk
Sun Feb 28 09:59:56 UTC 2016
This is an automated email from the git hooks/post-receive script.
js pushed a commit to branch master
in repository node-expat.
commit f638c4689d5b1a87c48b6141adc2604ba15e575c
Author: Satyam Shekhar <satyamshekhar at gmail.com>
Date: Mon Apr 9 00:24:14 2012 +0530
Exposing XML_ParserReset.
---
lib/node-expat.js | 3 +++
node-expat.cc | 41 ++++++++++++++++++++++++++++++++++-------
2 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/lib/node-expat.js b/lib/node-expat.js
index 765515e..76962b2 100644
--- a/lib/node-expat.js
+++ b/lib/node-expat.js
@@ -40,6 +40,9 @@ exports.Parser.prototype.pause = function() {
exports.Parser.prototype.resume = function() {
return this.parser.resume();
};
+exports.Parser.prototype.reset = function() {
+ return this.parser.reset();
+};
exports.Parser.prototype.getCurrentLineNumber = function() {
return this.parser.getCurrentLineNumber();
};
diff --git a/node-expat.cc b/node-expat.cc
index c35b3b2..2904918 100644
--- a/node-expat.cc
+++ b/node-expat.cc
@@ -29,6 +29,7 @@ public:
NODE_SET_PROTOTYPE_METHOD(t, "getError", GetError);
NODE_SET_PROTOTYPE_METHOD(t, "stop", Stop);
NODE_SET_PROTOTYPE_METHOD(t, "resume", Resume);
+ NODE_SET_PROTOTYPE_METHOD(t, "reset", Reset);
NODE_SET_PROTOTYPE_METHOD(t, "getCurrentLineNumber", GetCurrentLineNumber);
NODE_SET_PROTOTYPE_METHOD(t, "getCurrentColumnNumber", GetCurrentColumnNumber);
NODE_SET_PROTOTYPE_METHOD(t, "getCurrentByteIndex", GetCurrentByteIndex);
@@ -73,6 +74,16 @@ protected:
parser = XML_ParserCreate(encoding);
assert(parser != NULL);
+ attachHandlers();
+ }
+
+ ~Parser()
+ {
+ XML_ParserFree(parser);
+ }
+
+ void attachHandlers()
+ {
XML_SetUserData(parser, this);
XML_SetElementHandler(parser, StartElement, EndElement);
XML_SetCharacterDataHandler(parser, Text);
@@ -82,12 +93,7 @@ protected:
XML_SetXmlDeclHandler(parser, XmlDecl);
XML_SetEntityDeclHandler(parser, EntityDecl);
}
-
- ~Parser()
- {
- XML_ParserFree(parser);
- }
-
+
/*** parse() ***/
static Handle<Value> Parse(const Arguments& args)
@@ -235,6 +241,27 @@ protected:
return XML_ResumeParser(parser) != 0;
}
+ static Handle<Value> Reset(const Arguments& args)
+ {
+ Parser *parser = ObjectWrap::Unwrap<Parser>(args.This());
+ HandleScope scope;
+ XML_Char *encoding = NULL;
+ if (args.Length() == 1 && args[0]->IsString())
+ {
+ encoding = new XML_Char[32];
+ args[0]->ToString()->WriteAscii(encoding, 0, 32);
+ }
+
+ int status = parser->reset(encoding);
+ if (status)
+ parser->attachHandlers();
+ return scope.Close(status ? True() : False());
+ }
+
+ int reset(XML_Char *encoding)
+ {
+ return XML_ParserReset(parser, encoding) != 0;
+ }
const XML_LChar *getError()
{
enum XML_Error code;
@@ -287,7 +314,7 @@ private:
/* no default ctor */
Parser();
-
+
/*** SAX callbacks ***/
/* Should a local HandleScope be used in those callbacks? */
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-expat.git
More information about the Pkg-javascript-commits
mailing list