From 7a2a930a120b2efebfb693921056932b327c8842 Mon Sep 17 00:00:00 2001 From: Charles Yin Date: Thu, 23 Jun 2011 15:29:39 +1000 Subject: [PATCH] expose QSGContext2D::setPathString to v8 Javascript API Change-Id: I97a26c6c5273ba8800b13ca5f1f994eff04a24b8 --- src/declarative/items/qsgcontext2d.cpp | 14 ++++++++++++++ 1 files changed, 14 insertions(+), 0 deletions(-) diff --git a/src/declarative/items/qsgcontext2d.cpp b/src/declarative/items/qsgcontext2d.cpp index ff7b5c3..c694cf3 100644 --- a/src/declarative/items/qsgcontext2d.cpp +++ b/src/declarative/items/qsgcontext2d.cpp @@ -1078,6 +1078,19 @@ static v8::Handle ctx2d_isPointInPath(const v8::Arguments &args) return v8::Boolean::New(pointInPath); } +static v8::Handle ctx2d_setPathString(const v8::Arguments &args) +{ + QV8Context2DResource *r = v8_resource_cast(args.This()); + if (!r || !r->context) + V8THROW_ERROR("Not a Context2D object"); + + QV8Engine *engine = V8ENGINE(); + if (args.Length() == 1) { + r->context->setPathString(engine->toString(args[0])); + } + return v8::Undefined(); +} + // text v8::Handle ctx2d_font(v8::Local, const v8::AccessorInfo &info) { @@ -3148,6 +3161,7 @@ QSGContext2DEngineData::QSGContext2DEngineData(QV8Engine *engine) ft->PrototypeTemplate()->Set(v8::String::New("rect"), V8FUNCTION(ctx2d_rect, engine)); ft->PrototypeTemplate()->Set(v8::String::New("stroke"), V8FUNCTION(ctx2d_stroke, engine)); ft->PrototypeTemplate()->Set(v8::String::New("isPointInPath"), V8FUNCTION(ctx2d_isPointInPath, engine)); + ft->PrototypeTemplate()->Set(v8::String::New("setPathString"), V8FUNCTION(ctx2d_setPathString, engine)); ft->InstanceTemplate()->SetAccessor(v8::String::New("font"), ctx2d_font, ctx2d_font_set, v8::External::Wrap(engine)); ft->InstanceTemplate()->SetAccessor(v8::String::New("textAlign"), ctx2d_textAlign, ctx2d_textAlign_set, v8::External::Wrap(engine)); ft->InstanceTemplate()->SetAccessor(v8::String::New("textBaseline"), ctx2d_textBaseline, ctx2d_textBaseline_set, v8::External::Wrap(engine)); -- 1.7.2.5