i found definition in "wtypes.h"
vt_ptr = 26, vt_safearray = 27, vt_carray = 28, vt_userdefined = 29, vt_lpstr = 30, vt_lpwstr = 31, * vt_ptr [t] pointer type * vt_safearray [t] (use vt_array in variant) * vt_carray [t] c style array * vt_userdefined [t] user defined type * vt_lpstr [t][p] null terminated string * vt_lpwstr [t][p] wide null terminated string
in opinion,this definition show variant can c array,ptr or c point. can't type of arg when use follow code pass c array javascript
stdmethodimp cfilesystemobject::invoke( dispid dispidmember, refiid riid, lcid lcid, word wflags, dispparams *pdispparams, variant *pvarresult, excepinfo *pexcepinfo, uint *puargerr ){ pvarresult->vt = vt_carray|vt_i4; pvarresult->pintval = new int[4]; }
how pass c array javascript c++?
there several ways can achieve close goal.
a) have method return safearray
(see safearraycreate
, safearrayaccessdata
et al). can pack variant of type vt_array | vt_i4
. javascript cannot consume safearrays directly, can of vbarray
object. on javascript side, call this:
var retarr = new vbarray(yourobject.yourmethod()).toarray()
note that, if want method callable vbscript in addition javascript, vbscript understands safearrays of variants (vt_array | vt_variant
), not of other type. need create safearray of variants, , have each of variants wrap int. javascript work such arrangement, too.
b) implement separate com collection object wrapping array. object expose, say, length
, item()
properties access individual elements; , optionally _newenum
property play vbscript's for each
syntax, if that's concern. method create , return instance of object.
i think, though not 100% sure, default property (one dispid
of dispid_value
) accessible in javascript via objectname[i]
syntax, in addition regular objectname.item(i)
syntax. if works, make collection object native javascript array.
c) create, populate , return native javascript array object:
http://www.codeproject.com/articles/88753/creating-javascript-arrays-and-other-objects-from
i wouldn't recommend this, ties component intimately particular host. mention completeness.
Comments
Post a Comment