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

Jonas Smedegaard dr at jones.dk
Sun Feb 28 09:59:45 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 4c7daa649a29c5cf0baa7d408474633590a861c5
Author: Peter Körner <peter at peter-lappi.(none)>
Date:   Fri Apr 8 21:18:43 2011 +0200

    expose stop and resume to the nodejs side
---
 README.markdown |  3 +++
 node-expat.cc   | 36 ++++++++++++++++++++++++++++++++++++
 package.json    |  2 +-
 3 files changed, 40 insertions(+), 1 deletion(-)

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 32cc35f..0d6bc93 100644
--- a/package.json
+++ b/package.json
@@ -13,7 +13,7 @@
 		  ,"email": "astro at spaceboyz.net"
 		  ,"web": "http://spaceboyz.net/~astro/"
 		 }]
-,"contributors": ["Stephan Maka", "Derek Hammer", "Iein Valdez"]
+,"contributors": ["Stephan Maka", "Derek Hammer", "Iein Valdez", "Peter Körner"]
 ,"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