[Pkg-javascript-commits] [node-expat] 55/371: expose stop and resume to the nodejs side

Jonas Smedegaard dr at jones.dk
Sun Feb 28 09:59:44 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 45a818ac6df94e57478fbf4af5bbb037f23700d9
Author: Peter Körner <peter at peter-lappi.(none)>
Date:   Thu Apr 7 23:58:14 2011 +0200

    expose stop and resume to the nodejs side
---
 README.markdown |  3 +++
 node-expat.cc   | 36 ++++++++++++++++++++++++++++++++++++
 package.json    | 10 ++++++----
 3 files changed, 45 insertions(+), 4 deletions(-)

diff --git a/README.markdown b/README.markdown
index 573daaa..82dc256 100644
--- a/README.markdown
+++ b/README.markdown
@@ -33,6 +33,9 @@ Important events emitted by a parser:
 
 There are more. Use `test.js` for reference.
 
+It's possible to stop and resume the parser from within element handlers using the parsers 
+stop() and resume() methods.
+
 ## Error handling ##
 
 We don't emit an error event because libexpat doesn't use a callback
diff --git a/node-expat.cc b/node-expat.cc
index 3f16237..9917043 100644
--- a/node-expat.cc
+++ b/node-expat.cc
@@ -27,6 +27,8 @@ public:
     NODE_SET_PROTOTYPE_METHOD(t, "parse", Parse);
     NODE_SET_PROTOTYPE_METHOD(t, "setEncoding", SetEncoding);
     NODE_SET_PROTOTYPE_METHOD(t, "getError", GetError);
+    NODE_SET_PROTOTYPE_METHOD(t, "stop", Stop);
+    NODE_SET_PROTOTYPE_METHOD(t, "resume", Resume);
 
     target->Set(String::NewSymbol("Parser"), t->GetFunction());
 
@@ -189,7 +191,41 @@ protected:
     else
       return scope.Close(Null());
   }
+  
+  /*** stop() ***/
+
+  static Handle<Value> Stop(const Arguments& args)
+  {
+    Parser *parser = ObjectWrap::Unwrap<Parser>(args.This());
+    HandleScope scope;
+
+    int status = parser->stop();
+    
+    return scope.Close(status ? True() : False());
+  }
+
+  int stop()
+  {
+    return XML_StopParser(parser, XML_TRUE) != 0;
+  }
+  
+  /*** resume() ***/
+
+  static Handle<Value> Resume(const Arguments& args)
+  {
+    Parser *parser = ObjectWrap::Unwrap<Parser>(args.This());
+    HandleScope scope;
 
+    int status = parser->resume();
+    
+    return scope.Close(status ? True() : False());
+  }
+
+  int resume()
+  {
+    return XML_ResumeParser(parser) != 0;
+  }
+  
   const XML_LChar *getError()
   {
     enum XML_Error code;
diff --git a/package.json b/package.json
index a47a9c8..a07acf5 100644
--- a/package.json
+++ b/package.json
@@ -1,17 +1,19 @@
 { "name": "node-expat"
-,"version": "1.2.0"
+,"version": "1.3.0"
 ,"main": "./build/default/node-expat"
 ,"description": "NodeJS binding for fast XML parsing."
 ,"scripts" : { "install" : "./install.sh" }
 ,"dependencies": []
 ,"repositories": [{ "type": "git"
-		   ,"path": "git://github.com/astro/node-expat.git"
+		   ,"path": "git://github.com/MaZderMind/node-expat.git"
 		  }]
-,"homepage": "http://github.com/astro/node-expat"
-,"bugs": "http://github.com/astro/node-expat/issues"
+,"homepage": "http://github.com/MaZderMind/node-expat"
+,"bugs": "http://github.com/MaZderMind/node-expat/issues"
 ,"maintainers": [{ "name": "Astro"
 		  ,"email": "astro at spaceboyz.net"
 		  ,"web": "http://spaceboyz.net/~astro/"
+		 }, { "name": "MaZderMind"
+		  ,"email": "peter at mazdermind.de"
 		 }]
 ,"licenses": [{ "type": "MIT" }]
 ,"engine": "node"

-- 
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