Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Re: Receiving JavaScript arrays in npruntime plugin



Even if "length" returns 0, you could try to access property 0, 1, 2,
etc. When you got to the end of the array, you would get "undefined"
back.

Thanks, this seems to work.

For reference, here's how I'm accessing the "length" property:

	NPObject* dispatch = NPVARIANT_TO_OBJECT(val); // the array object
	NPVariant outvar;
	NPString str;
	str.utf8characters = "length";
	MakeNPString( "length", str ); // sets utf8characters and utf8length

	VOID_TO_NPVARIANT(outvar);
	if( NPN_Evaluate( npp, dispatch, &str, &outvar ) ) // query length
	{
		int length = -1;
		if( NPVARIANT_IS_DOUBLE(outvar) )
		{
			// in Safari all numbers seem to be doubles...
			length = static_cast<int>( NPVARIANT_TO_DOUBLE(outvar) );
			// always get zero!
		}
		else if( NPVARIANT_IS_INT32(outvar) )
		{
			// this happens in Firefox, length being correct
			length = NPVARIANT_TO_INT32(outvar);
		}
		NPN_ReleaseVariantValue(&outvar);
		// ...


-- Aras Pranckevicius Graphics programmer at unity3d.com _______________________________________________ Do not post admin requests to the list. They will be ignored. Webkitsdk-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webkitsdk-dev/email@hidden

This email sent to email@hidden
References: 
 >Receiving JavaScript arrays in npruntime plugin (From: "Aras Pranckevicius" <email@hidden>)
 >Re: Receiving JavaScript arrays in npruntime plugin (From: Geoffrey Garen <email@hidden>)
 >Re: Receiving JavaScript arrays in npruntime plugin (From: "Aras Pranckevicius" <email@hidden>)
 >Re: Receiving JavaScript arrays in npruntime plugin (From: Geoffrey Garen <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.