Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: ANE

No certain about the C logic (FRENewObjectFromUTF8 looks fine), but on the AS3 side, you just need to do:

return this._ctx.call( "encrypt", s ) as String;

Dont need to allocate a String (with new) since String is a base object like int and Number.
Developer
Developer
Posts: 227
Registered: ‎01-17-2012
My Device: PB
My Carrier: ATT

Re: ANE

I thought so too, but when it didn't work, I reverted to the example...

 

then, on reading the Adobe doc it says that the returned result (from native) is only valid until the AS3 function returns, so seems that new String IS required.

 

Regards,

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: ANE

You can then do:

var str : String = this._ctx.call( 'encrypt', s ) as String;
return str;
Developer
Developer
Posts: 227
Registered: ‎01-17-2012
My Device: PB
My Carrier: ATT

Re: ANE

actually, I'm back to agreeing that new String is NOT needed.  The note on result scope is for: FREGetObjectAsUTF8.

 

Regards,

Developer
Developer
Posts: 227
Registered: ‎01-17-2012
My Device: PB
My Carrier: ATT

Re: ANE

so: guessing that I need to extract the String arg:

 

FREObject encrypt(FREContext ctx, void* functionData, uint32_t argc,
		FREObject argv[]) {

	uint32_t length = strlen(argv[0]) + 1;
	uint8_t s[length];
	FREGetObjectAsUTF8( argv[0], length, &s );

 but even gcc doesn't like it... says:

passing argument 3 of 'FREGetObjectAsUTF8' from incompatible pointer type [enabled by default]

 

What am I missing? Docs says it want uint8_t **

Developer
Developer
Posts: 227
Registered: ‎01-17-2012
My Device: PB
My Carrier: ATT

Re: ANE

progress:

	uint32_t	 length;
	const uint8_t 	*pString;

	if ( FREGetObjectAsUTF8( argv[0], &length, &pString ) != FRE_OK )
	{
		return NULL;
	}

 const **uint8_t;

 

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: ANE

Little rusty on my C/C++:

Try:

uint8_t *s = malloc( sizeof( uint8_t ) * length );

Developer
Developer
Posts: 227
Registered: ‎01-17-2012
My Device: PB
My Carrier: ATT

Re: ANE

yes, that was my original interpretation.  However, it sets the length (parm 2) so can't be expecting us to pre-allocate since we can't know the length to allocate.

 

I'm not sure that anything is actually wrong in the native code - I've tried returning a result string immediately, no change - simply crashes on entry (or thereabouts) to "encrypt".

 

Finally figured out that I need to export from Momentics after any change to NativeAS3 lib...  I do know that my NativeAS3 lib code is now being called because trace (in AS3 side) is working.

 

Also: whenever I look at FB4.6 properties->Build, it adds qnx-screen and I need to manually remove it, sometimes twice.  This also happened in 4.5.1 but I expected it to go away in 4.6. 

Do you notice the same?

 

Regards,

Developer
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: ANE

In 4.6, you can just check the box to include the BB libraries. You should never have to manually deal with them (I never had to).
Developer
Developer
Posts: 227
Registered: ‎01-17-2012
My Device: PB
My Carrier: ATT

Re: ANE

if I go to project->Properties->Action Script Build Packaging->Playbook Tablet OS e.g. to check which ANE,

FB appends qnx-screen to the list of libraries and I get the following error in FB:

 

Description	Resource	Path	Location	Type
unable to open 'C:\Program Files\Research In Motion\blackberry-tablet-sdk-2.0.0\frameworks\libs\qnx-screen'	MyTonido		Unknown	Flex Problem

 and need to go back to Build Packaging and remove to offending lib... sometimes twice.