Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

custom copy methods #49

Closed
catfact opened this issue Aug 13, 2013 · 5 comments
Closed

custom copy methods #49

catfact opened this issue Aug 13, 2013 · 5 comments
Assignees

Comments

@catfact
Copy link
Collaborator

catfact commented Aug 13, 2013

get your OOP act together and write custom copy methods for preset_t, scene_t, ctlnet_t, and whatever other big data classes are being blindly memcpy'd with impunity all over the dang place.

@catfact
Copy link
Collaborator Author

catfact commented Aug 21, 2013

the memory stuff is weird because we have an SRAM that is not allocated from the heap. instead, the chip has a hard-coded address. there is a super-primitive system to allocate pointers to SRAM in avr32/src/memory.c , and no mechanism to free them. we could theoretically fix this by mapping the SRAM to heap in the memory map, but my abortive attempts at this were highly frustrating and wasted a lot of time.

anyways, my approach is to basically think of all of these data structures as statically allocated. memcpy should be fine and appropriate, except evidently some pointers to heap-allocated structures are sneaking in somewhere. probably a fucking string or maybe a function pointer. probably specific to the single extant momome grid operator.

@catfact
Copy link
Collaborator Author

catfact commented Aug 21, 2013

still, might be safer to implement custom copy methods in the proper fashion.

@catfact
Copy link
Collaborator Author

catfact commented Aug 24, 2013

belatedly realizing that of course certain things in this system will break between builds if operator layouts, etc change drastically.

obviously this is happening a lot right now. we could assume layouts will not change between major releases or something. i'm not really sure of the right way to handle version numbers but ship should be 0.x "beta" . can deal with compatibility when we want to break it ?

@catfact
Copy link
Collaborator Author

catfact commented Aug 27, 2013

iss 49:

need deep-copy on ctlnet ?

case: scene is written with older version of bees
struct layouts for ops and everything are different.
loading the scene gives garbage.

so, scene file needs to store bees version number.
then we can knowingly break compatibility as long as we maintain inter-version translation routines.

obvs, would be safest to have deep-copy methods for everything,
even though this runs to a lot of code and is boring.
of course, have to do it sooner or later in order to have x-platform file parsing.

q: can struct layout ever change between builds because of optimization level or other non-coding reason? it would be nice to enforce packed everywhere, but having trouble with this when nesting structs with gcc.

@catfact
Copy link
Collaborator Author

catfact commented Oct 26, 2013

using class-defined serialization methods, closing this and making #64

@catfact catfact closed this as completed Oct 26, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant