andy128k / cl-gobject-introspection

BSD 2-Clause "Simplified" License
49 stars 15 forks source link

Fix struct alloc #22

Closed hying-caritas closed 10 years ago

hying-caritas commented 10 years ago

And add test case for it.

Kalimehtar commented 10 years ago

Why :allocator? What if a struct has a method with name allocator() ? What wrong with my variant, where name is simply omitted? And why calculate size in all cases, not just when foreign-alloc is called?

andy128k commented 10 years ago

In this case size (fixnum) is captured, not info (foreign pointer). This seems reasonable.

andy128k commented 10 years ago

BTW, what about deallocation?

hying-caritas commented 10 years ago

On Fri, Apr 11, 2014 at 8:14 PM, Kalimehtar notifications@github.comwrote:

Why :allocator? What if a struct has a method with name allocator() ?

I think :allocate follows the same style as :this. If a struct has a constructor named allocate(), it can be called with (call "struct" 'allocate).

What wrong with my variant, where name is simply omitted?

That works. The "fix" in my patch subject is for foreign-alloc. I just think :allocate improve the readability and follow the same style of other code.

And why calculate size in all cases, not just when foreign-alloc is called?

In this way, we can calculate size during build struct class, not construct struct, we may use one built struct class to construct many structs. And we have chance to free info after bulding struct class.

hying-caritas commented 10 years ago

On Fri, Apr 11, 2014 at 8:19 PM, Andrey Kutejko notifications@github.comwrote:

BTW, what about deallocation?

Will use trivial-gc to do that.

Kalimehtar commented 10 years ago

I just think :allocate improve the readability and follow the same style of other code.

Then remove &optional from name in next commit.