47 views
in System Integration by
Hi,

I wish to create an instance of a class defined inside EW, but I want to create in C code (I'm unpacked a large data structure and want to use a pre-existing internal class to store the data and pass it into the application.

(For good reasons, I don't want to create an API call that takes multiple parameters - there are a lof ot them, and they may change - just a single API call that takes an instance of a data object.)

Looking at the source, I can see:

EwNewObjectIndirect(aClass, aArg)

This object is only expected to have a lifespan of the C call.

Are there any issues with doing the following:

1. Unpack the message coming in (It's on a serial line)

2. Use EwNewObjectIndirect to create an instance of my 'DataParameters' object.

3. Use the Set methods to update the object.

4. Pass the object reference into an AutoObject method (MyHandlerClass__HandleDataParameters(objectRef, myShinyNewObject)

5. The object will then use the data internally.

6. Gargabe collection removed the object next time.

1 Answer

+1 vote
by

Hello,

the described application case should work. 

This object is only expected to have a lifespan of the C call.

This restriction means that pointers to the objects shouldn't be stored in C variables for 'later use' since the object will be released eventually if it is not used by the EW application. Passing the object via parameter to the EW application is o.k. If the application retains the object, the object will even survive the garbage collection.

I hope it helps you further.

Best regards

Paul Banach

by
Thankyou - the object is only going to exist for the duration of the call and won't be stored anywhere in C code.

Regards

Martin

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...