[Bugs] #1034 HIGH: Journal Integration

SugarLabs Bugs bugtracker-noreply at sugarlabs.org
Wed Jul 15 10:22:36 EDT 2009


#1034: Journal Integration
----------------------------+-----------------------------------------------
    Reporter:  asaf         |          Owner:  asaf                       
        Type:  enhancement  |         Status:  reopened                   
    Priority:  High         |      Milestone:  Unspecified by Release Team
   Component:  Physics      |        Version:  Unspecified                
    Severity:  Unspecified  |     Resolution:                             
    Keywords:               |   Distribution:  Unspecified                
Status_field:  Assigned     |  
----------------------------+-----------------------------------------------

Comment(by kne):

 SWIG objects are not serializable because they exist both on the Python
 (the shadow classes) and C++-side (the actual structure itself). As such,
 the somewhat complicated procedure found in
 [http://code.google.com/p/pybox2d/source/browse/trunk/Box2D/Box2D_pickling.i
 here] was created. It eventually boils everything down to dictionaries
 when saving and then recreates them upon loading.

 Should you take the JSON route of starting from scratch, you will have to
 take into account things like joints and controllers. When saving, you
 want to first save the world's shape list. Then enumerate each joint in
 the world, writing the index of the shape instead of another copy of the
 shape definition (as you don't want the shape to be created again). Any
 references to shapes in your code also have to be fixed like this (which
 is why the pickle_fix method was introduced).

 I did my best to introduce the same-named properties in the shapes as the
 definitions (as of course they weren't present in the original C++ code).
 I think there was perhaps one property that didn't get changed though, so
 take a look at the pickling code as a reference.

 You might be able to get by with a somewhat hackish method of using the
 __getstate__/__setstate__s that I painstakingly (*cough*) wrote for the
 pickling functionality. Use them to get the necessary data and then use
 the JSON serializer as you please.

-- 
Ticket URL: <http://dev.sugarlabs.org/ticket/1034#comment:9>
Sugar Labs <http://sugarlabs.org/>
Sugar Labs bug tracking system


More information about the Bugs mailing list