On Wed, 26 Oct 2011 23:40:52 +1000 David Seikel <[email protected]> wrote:
> On Wed, 26 Oct 2011 15:33:14 +0200 Cedric BAIL <[email protected]> > wrote: > > > Hey, > > > > On Wed, Oct 26, 2011 at 2:56 PM, David Seikel <[email protected]> > > wrote: > > > I'm having an odd problem when trying to add an array of simple > > > types in an eet file. The attached file is the simple cut down > > > version. The real code is more complex, and needs the fuller > > > versions of these structures to be the way they are. > > > > > > I have a macro that is patterned after the other eet macros - > > > EET_DATA_DESCRIPTOR_ADD_BASIC_ARRAY. It's used twice in this > > > example, once for the Meter.prizes array, the second one for the > > > Barrel.cards array. If the Meter.prizes version is commented out, > > > everything works fine. Otherwise I get the attached valgrind > > > report (with no eet file existing when it starts). > > > > > > Likely there is something wrong with my macro. I think there > > > should be such a macro already, but apparently the received wisdom > > > from raster is that for something so simple, just use the > > > eet_data_descriptor_element_add() function directly. Even though > > > that functions docs say - > > > > > > "It is complex to use by hand and should be left to be used by the > > > macros, and thus is not documented." > > > > > > Um, yeah. Well, I tried. lol > > > > Well we are adding this macro as people need and use it. First be > > aware I have no way to compile nor test your code nor what I will > > say. I think you need to divide the size of your structure by the > > size of the element so that the count do match. So you should have > > something like : sizeof(___ett.member) / sizeof(___ett.member[0]). > > Ah, that did the trick, and makes sense. It's the count of elements, > not the count of bytes. > > Thanks. > > I'll send a patch with this macro after some more testing. Unless > someone beats me to it. Here's the patch, as promised. -- A big old stinking pile of genius that no one wants coz there are too many silver coated monkeys in the world.
Index: src/lib/Eet.h
===================================================================
--- src/lib/Eet.h (revision 64479)
+++ src/lib/Eet.h (working copy)
@@ -3104,6 +3104,35 @@
} while (0)
/**
+ * Add an array of basic data elements to a data descriptor.
+ * @param edd The data descriptor to add the type to.
+ * @param struct_type The type of the struct.
+ * @param name The string name to use to encode/decode this member
+ * (must be a constant global and never change).
+ * @param member The struct member itself to be encoded.
+ * @param type The type of the member to encode.
+ *
+ * This macro lets you easily add a fixed size array of basic data
+ * types. All the parameters are the same as for
+ * EET_DATA_DESCRIPTOR_ADD_BASIC().
+ * The array must be defined with a fixed size in the declaration of the
+ * struct containing it.
+ *
+ * @since 1.5.0
+ * @ingroup Eet_Data_Group
+ */
+#define EET_DATA_DESCRIPTOR_ADD_BASIC_ARRAY(edd, struct_type, name, member, type) \
+ do { \
+ struct_type ___ett; \
+ eet_data_descriptor_element_add(edd, name, type, EET_G_ARRAY, \
+ (char *)(& (___ett.member)) - \
+ (char *)(& (___ett)), \
+ sizeof(___ett.member) / \
+ sizeof(___ett.member[0]), \
+ NULL, NULL); \
+ } while(0)
+
+/**
* Add a fixed size array type to a data descriptor
* @param edd The data descriptor to add the type to.
* @param struct_type The type of the struct.
signature.asc
Description: PGP signature
------------------------------------------------------------------------------ The demand for IT networking professionals continues to grow, and the demand for specialized networking skills is growing even more rapidly. Take a complimentary Learning@Cisco Self-Assessment and learn about Cisco certifications, training, and career opportunities. http://p.sf.net/sfu/cisco-dev2dev
_______________________________________________ enlightenment-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
