Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[js-ctypes] Type long returns an object instead of a number

1 view
Skip to first unread message

Daniel Kirsch

unread,
Aug 30, 2010, 9:00:22 AM8/30/10
to
I have a DLL returning me the size of any image I pass. I use the new
js-ctypes way

getPictureSize : function(imgPath) {
var width = new ctypes.long();
var height = new ctypes.long();
var service = this.ctypesService;
service.getDimensions(imgPath, width.address(), height.address());
return {
width:width.value,
height:height.value
};
}

However instead of a number, width.value will return an object.
Can someone explain why width.value is of type "object" instead of a
number? IMHO it should be the same (or a similar type) as defined by its
prototype - here "ctypes.long". I expect it to be a number object which
I can calculate with. (Yes, I now typecast the value before returning it.)

Thanks for an explanation.
Daniel

Benjamin Smedberg

unread,
Aug 30, 2010, 9:56:11 AM8/30/10
to
On 8/30/10 9:00 AM, Daniel Kirsch wrote:
> I have a DLL returning me the size of any image I pass. I use the new
> js-ctypes way

Please use mdt.js-engine for ctypes questions.

>
> getPictureSize : function(imgPath) {
> var width = new ctypes.long();
> var height = new ctypes.long();
> var service = this.ctypesService;
> service.getDimensions(imgPath, width.address(), height.address());
> return {
> width:width.value,
> height:height.value
> };
> }
>
> However instead of a number, width.value will return an object.
> Can someone explain why width.value is of type "object" instead of a number?
> IMHO it should be the same (or a similar type) as defined by its prototype -
> here "ctypes.long". I expect it to be a number object which I can calculate
> with. (Yes, I now typecast the value before returning it.)

https://developer.mozilla.org/en/js-ctypes/js-ctypes_reference/ctypes#Types_that_act_like_specific_C_types

See the note about "long" automatically being a 64-bit type, for
cross-plaform compatibility. The .value you get back is an Int64 object:

https://developer.mozilla.org/en/js-ctypes/js-ctypes_reference/Int64

--BDS

0 new messages