From 909fa2daa49e5439c595e3d17a76f0e05d7934b0 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 12 Dec 2017 01:53:28 +0000 Subject: [js] Convert to using size instead of sentinels This CL changes the DefineMethod, DefineProps and DefineConsts methods to pass a size instead of depending on a sentinel value in the definition arrays. Change-Id: Ie054544124290c0833a8b21af175a203ca99591a Reviewed-on: https://pdfium-review.googlesource.com/20551 Commit-Queue: dsinclair Reviewed-by: Lei Zhang --- fxjs/cjs_object.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'fxjs/cjs_object.cpp') diff --git a/fxjs/cjs_object.cpp b/fxjs/cjs_object.cpp index ccddc7f8df..a1e5ce1c94 100644 --- a/fxjs/cjs_object.cpp +++ b/fxjs/cjs_object.cpp @@ -9,8 +9,9 @@ // static void CJS_Object::DefineConsts(CFXJS_Engine* pEngine, int objId, - const JSConstSpec consts[]) { - for (size_t i = 0; consts[i].pName != 0; ++i) { + const JSConstSpec consts[], + size_t count) { + for (size_t i = 0; i < count; ++i) { pEngine->DefineObjConst( objId, consts[i].pName, consts[i].eType == JSConstSpec::Number @@ -22,8 +23,9 @@ void CJS_Object::DefineConsts(CFXJS_Engine* pEngine, // static void CJS_Object::DefineProps(CFXJS_Engine* pEngine, int objId, - const JSPropertySpec props[]) { - for (size_t i = 0; props[i].pName != 0; ++i) { + const JSPropertySpec props[], + size_t count) { + for (size_t i = 0; i < count; ++i) { pEngine->DefineObjProperty(objId, props[i].pName, props[i].pPropGet, props[i].pPropPut); } @@ -32,8 +34,9 @@ void CJS_Object::DefineProps(CFXJS_Engine* pEngine, // static void CJS_Object::DefineMethods(CFXJS_Engine* pEngine, int objId, - const JSMethodSpec methods[]) { - for (size_t i = 0; methods[i].pName != 0; ++i) + const JSMethodSpec methods[], + size_t count) { + for (size_t i = 0; i < count; ++i) pEngine->DefineObjMethod(objId, methods[i].pName, methods[i].pMethodCall); } -- cgit v1.2.3