From fbd184fe421591851e1224518a3c9430dd37dce8 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 4 Oct 2012 19:48:32 +0100 Subject: allow teh binding to specify contents for operations --- test/data/bindings/htmldocument.bnd | 59 +++++++++++++++---------------------- 1 file changed, 24 insertions(+), 35 deletions(-) (limited to 'test/data/bindings') diff --git a/test/data/bindings/htmldocument.bnd b/test/data/bindings/htmldocument.bnd index 6c470e4..8d35df9 100644 --- a/test/data/bindings/htmldocument.bnd +++ b/test/data/bindings/htmldocument.bnd @@ -12,55 +12,44 @@ hdrcomment "multi" hdrcomment "IDL http://www.whatwg.org/specs/web-apps/current-work/#the-document-object"; -preamble [[[ +preamble %{ #include - + #include "utils/config.h" #include "utils/log.h" #include "javascript/jsapi.h" -static JSBool JSAPI_NATIVE(write, JSContext *cx, uintN argc, jsval *vp) -{ - JSString* u16_txt; - char *txt; - unsigned long length; - struct jsclass_document_priv *document; - - document = JS_GetInstancePrivate(cx, JS_THIS_OBJECT(cx,vp), &JSCLASS_OBJECT, NULL); - if (document == NULL) { - return JS_FALSE; - } - if (!JS_ConvertArguments(cx, argc, JSAPI_ARGV(cx, vp), "S", &u16_txt)) { - return JS_FALSE; - } + %} - JSString_to_char(u16_txt, txt, length); +operation write %{ - LOG(("content %p parser %p writing %s", - document->htmlc, document->htmlc->parser, txt)); - if (document->htmlc->parser != NULL) { - dom_hubbub_parser_insert_chunk(document->htmlc->parser, (uint8_t *)txt, length); - } - JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); + if (!JS_ConvertArguments(cx, argc, JSAPI_ARGV(cx, vp), "S", &u16_txt)) { + return JS_FALSE; + } - foo[23] = bar[n +[x]]; + JSString_to_char(u16_txt, txt, length); - return JS_TRUE; -} + LOG(("content %p parser %p writing %s", + document->htmlc, document->htmlc->parser, txt)); + if (document->htmlc->parser != NULL) { + dom_hubbub_parser_insert_chunk(document->htmlc->parser, (uint8_t *)txt, length); + } + JSAPI_SET_RVAL(cx, vp, JSVAL_VOID); -]]]; + return JS_TRUE; + %} binding document { - type js_libdom; /* the binding type */ + type js_libdom; /* the binding type */ - /* parameters to constructor value stored in private - * context structure. - */ - private "dom_document *node"; - private "struct html_content *htmlc"; + /* parameters to constructor value stored in private + * context structure. + */ + private "dom_document *node"; + private "struct html_content *htmlc"; - interface Document; /* Web IDL interface to generate */ -}; + interface Document; /* Web IDL interface to generate */ +} -- cgit v1.2.3