Win a copy of Fixing your Scrum this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Rob Spoor
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Holloway
  • Piet Souris
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Himai Minh

Converting Java Parcelable Object Array To Native Parcelable Array

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying to convert Java class object implemented as Parcelable to native c++ Parcelable Array. I have below example that does the native Parcelable to java Parcelable I wanted to do vice versa.

template<class T, class BASE>
void JNIParcel::writeParcelableArray(shared_ptr<vector<shared_ptr<BASE>>> ptr) {
   vector<shared_ptr<BASE>> *array = ptr.get();
   int arrSize = array->size();
   jobjectArray jArray = mEnv->NewObjectArray(arrSize, clazz_Parcelable, jstring());
   typename vector<shared_ptr<BASE>>::iterator it = array->begin();
   int i = 0;
   while(it != array->end()){
       T* t = static_cast<T*>(&*it->get());
       mEnv->SetObjectArrayElement(jArray, i, t->toJParcelable(mEnv));
       i++;
       ++it;
   }
   mEnv->CallVoidMethod(obj, Parcel_writeTypedArray, jArray, 0);
   mEnv->DeleteLocalRef(jArray);
}
 
Marshal
Posts: 73738
332
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please post a link describing Parcelable.
 
Campbell Ritchie
Marshal
Posts: 73738
332
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaah!

Moving you to our Android forum.

[edit]I don't know any Android.
 
Pay attention! Tiny ad!
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic