Second version using SLEN() instead of strlen().
This patch to Document/bnd makes the Javascript writeln() function
work as well as write().
diff --git a/javascript/duktape/Document.bnd b/javascript/duktape/Document.bnd
index 6d11ea9..0e07f24 100644
--- a/javascript/duktape/Document.bnd
+++ b/javascript/duktape/Document.bnd
@@ -13,6 +13,7 @@ class Document {
#include "utils/corestrings.h"
#include "render/html_internal.h"
#include "utils/libdom.h"
+#include "utils/utils.h"
%};
}
@@ -37,6 +38,27 @@ method Document::write()
return 0;
%}
+method Document::writeln()
+%{
+ const char br[] = "<br>";
+ struct html_content *htmlc;
+ duk_size_t text_len;
+ for (int i = 0; i < duk_get_top(ctx); ++i)
+ duk_safe_to_string(ctx, i);
+ duk_concat(ctx, duk_get_top(ctx));
+ const char *text = duk_safe_to_lstring(ctx, 0, &text_len);
+ LOG("Writeln %*s", (int)text_len, text);
+ dom_exception err;
+ err = dom_node_get_user_data(priv->parent.node,
+ corestring_dom___ns_key_html_content_data,
+ &htmlc);
+ if (err == DOM_NO_ERR && htmlc->parser != NULL) {
+ dom_hubbub_parser_insert_chunk(htmlc->parser, (uint8_t *)text, text_len);
+ dom_hubbub_parser_insert_chunk(htmlc->parser, (uint8_t *)br, SLEN(br));
+ }
+ return 0;
+%}
+
method Document::createTextNode()
%{
dom_node *newnode;
Hope this helps.
Dave
____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!
No comments:
Post a Comment