[Pkg-javascript-commits] [node-expat] 12/371: move SAX callbacks to private static methods of class Parser

Jonas Smedegaard dr at jones.dk
Sun Feb 28 09:59:40 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 e6ac47b17e7720d5b6e8c5c14802e46f419f8082
Author: Astro <astro at spaceboyz.net>
Date:   Sun May 23 15:53:17 2010 +0200

    move SAX callbacks to private static methods of class Parser
---
 expat.cc | 58 ++++++++++++++++++++++++++++------------------------------
 1 file changed, 28 insertions(+), 30 deletions(-)

diff --git a/expat.cc b/expat.cc
index e932318..efb7df6 100644
--- a/expat.cc
+++ b/expat.cc
@@ -7,10 +7,6 @@ extern "C" {
 using namespace v8;
 using namespace node;
 
-static void StartElement(void *userData, const XML_Char *name, const XML_Char **atts);
-static void EndElement(void *userData, const XML_Char *name);
-static void Text(void *userData, const XML_Char *s, int len);
-
 static Persistent<String> sym_startElement, sym_endElement, sym_text;
 
 class Parser : public EventEmitter {
@@ -99,40 +95,42 @@ protected:
 
 private:
   XML_Parser parser;
-};
 
+  /*** SAX callbacks ***/
 
-static void StartElement(void *userData, const XML_Char *name, const XML_Char **atts)
-{
-  Parser *parser = reinterpret_cast<Parser *>(userData);
+  static void StartElement(void *userData, const XML_Char *name, const XML_Char **atts)
+    {
+      Parser *parser = reinterpret_cast<Parser *>(userData);
 
-  /* Collect atts into JS object */
-  Local<Object> attr = Object::New();
-  for(const XML_Char **atts1 = atts; *atts1; atts1 += 2)
-    attr->Set(String::New(atts1[0]), String::New(atts1[1]));
+      /* Collect atts into JS object */
+      Local<Object> attr = Object::New();
+      for(const XML_Char **atts1 = atts; *atts1; atts1 += 2)
+        attr->Set(String::New(atts1[0]), String::New(atts1[1]));
 
-  /* Trigger event */
-  Handle<Value> argv[2] = { String::New(name), attr };
-  parser->Emit(sym_startElement, 2, argv);
-}
+      /* Trigger event */
+      Handle<Value> argv[2] = { String::New(name), attr };
+      parser->Emit(sym_startElement, 2, argv);
+    }
 
-static void EndElement(void *userData, const XML_Char *name)
-{
-  Parser *parser = reinterpret_cast<Parser *>(userData);
+  static void EndElement(void *userData, const XML_Char *name)
+    {
+      Parser *parser = reinterpret_cast<Parser *>(userData);
 
-  /* Trigger event */
-  Handle<Value> argv[1] = { String::New(name) };
-  parser->Emit(sym_endElement, 1, argv);
-}
+      /* Trigger event */
+      Handle<Value> argv[1] = { String::New(name) };
+      parser->Emit(sym_endElement, 1, argv);
+    }
 
-static void Text(void *userData, const XML_Char *s, int len)
-{
-  Parser *parser = reinterpret_cast<Parser *>(userData);
+  static void Text(void *userData, const XML_Char *s, int len)
+    {
+      Parser *parser = reinterpret_cast<Parser *>(userData);
+
+      /* Trigger event */
+      Handle<Value> argv[1] = { String::New(s, len) };
+      parser->Emit(sym_text, 1, argv);
+    }
+};
 
-  /* Trigger event */
-  Handle<Value> argv[1] = { String::New(s, len) };
-  parser->Emit(sym_text, 1, argv);
-}
 
 
 extern "C" void init(Handle<Object> target)

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