Ecere SDK/eC Forums • View topic - SIGSEGV on serializing Map object




Ecere SDK/eC Forums

Ecere Developers Community

SIGSEGV on serializing Map object

General help with the eC language.

SIGSEGV on serializing Map object

Postby nicktick » Tue Mar 26, 2013 2:39 am

Please see the line where commented with "SIGSEGV" in following code.
Code: Select all
class TestClass 
{
   public int x;
   public String str;
   public void Print()
   {
      PrintLn(x);
      PrintLn(str);
   }
}
void test_serialize_map()
{
   File f;
   Map<String, TestClass> data { };
   data["BobsScore"]   = TestClass {1,"1-1"};   
 
   f = FileOpen("savedstuff", write);
   f.Put(data);
   delete f;
   delete data;
 
   f = FileOpen("savedstuff", read);
   f.Get(data);   
   delete f;
   { 
      TestClass t = data["BobsScore"];    //SIGSEGV happened here
       //how to resolve the SIGSEGV problem ?
      t.Print();
      delete t;
   }
}   
 
class TestApp : Application
{
   void Main()
   {
      test_serialize_map();
  }
}
nicktick
 
Posts: 17
Joined: Tue Nov 13, 2012 8:34 pm

Re: SIGSEGV on serializing Map object

Postby jerome » Tue Mar 26, 2013 12:05 pm

Hi nicktick!

Confirmed. Map Serialization/Unserialization does not work yet.

I will try to implement it for you tonight :)

Regards,

Jerome
jerome
Site Admin
 
Posts: 621
Joined: Sat Jan 16, 2010 11:16 pm

Re: SIGSEGV on serializing Map object

Postby jerome » Thu Mar 28, 2013 12:16 am

Hi nicktick!

I just committed a fix for the Map Serialization/Unserialization:

https://github.com/ecere/sdk/commit/224 ... 79c4da1f79
It will be included in today's 0.44.06 release.

Maps didn't work with the generic container serialization, because they must additionally serialize the keys as well as the data.

Your code should now work as expected :D

Regards,

Jerome
jerome
Site Admin
 
Posts: 621
Joined: Sat Jan 16, 2010 11:16 pm

Re: SIGSEGV on serializing Map object

Postby nicktick » Thu Mar 28, 2013 2:23 am

thanks !
nicktick
 
Posts: 17
Joined: Tue Nov 13, 2012 8:34 pm

Re: SIGSEGV on serializing Map object

Postby nicktick » Thu Mar 28, 2013 3:16 am

One more question:
Is eC's serialized object platform independent? or binary compatible on different OS?
nicktick
 
Posts: 17
Joined: Tue Nov 13, 2012 8:34 pm

Re: SIGSEGV on serializing Map object

Postby jerome » Thu Mar 28, 2013 9:32 am

Hi nicktick!

It is meant to be platform-independent (and thus binary compatible on different OSes and architectures). In particular, it produces the same output regardless of the machine endianness.

The serialization of base types (e.g. uint, uint64, float etc.) takes care of flipping these to big endian. And complex types normally serialize by serializing the simpler types. Thus serialization is in effect serialized to big endian (or 'network' byte order, as it is called). This is all done in ecere/src/com/dataTypes.ec, if you're curious, with the PUT/GET X * macros.

Please let me know if you find an incompatibility :) But I you probably don't have a little-endian platform to test on (e.g. PowerPC).

Regards,

Jerome
jerome
Site Admin
 
Posts: 621
Joined: Sat Jan 16, 2010 11:16 pm


Return to eC Language

Who is online

Users browsing this forum: No registered users and 2 guests

cron