[Pharo-project] NativeBoost types -> anonymous subclasses issue
Hi Igor, Besides some other small comits, in NativeBoost-Core-CiprianTeodorov.103 I have changed the way anonymous subclasses of NBExternalTypeValue and NBExternalArray are created. The reason is that using the old way we would create multiple instances of the same metaclass which is not allowed in the image. BTW, I was getting this problem when trying to modify (add or remove) class instance variables of the NBExternalArray. Doing NBExternalArray class allInstances, I was clearly getting more than one instance... Now the anonymous subclasses are build using ClassBuilder>>#newSubclassOf:type:instanceVariables:from: which seems to prevent this problem from happening. What do you think? Are there other ways to get around this problem? Cheers, -- Dr. Ciprian TEODOROV Ingénieur Développement CAO tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
On 16 December 2012 16:05, Ciprian Teodorov <ciprian.teodorov@gmail.com> wrote:
Hi Igor,
Besides some other small comits, in NativeBoost-Core-CiprianTeodorov.103 I have changed the way anonymous subclasses of NBExternalTypeValue and NBExternalArray are created.
The reason is that using the old way we would create multiple instances of the same metaclass which is not allowed in the image. BTW, I was getting this problem when trying to modify (add or remove) class instance variables of the NBExternalArray.
So, your problem is that you abusing it :) Anonymous subclasses is there for sole purpose to provide common minimal protocol for their instances. If you need something else, you can just make normal subclasses.
Doing NBExternalArray class allInstances, I was clearly getting more than one instance...
Now the anonymous subclasses are build using ClassBuilder>>#newSubclassOf:type:instanceVariables:from: which seems to prevent this problem from happening.
What do you think? Are there other ways to get around this problem?
Sure , you can use class builder, but again, you need it because you want to have more than just minimal interface. So, again, why don't just create own subclass?
Cheers, -- Dr. Ciprian TEODOROV Ingénieur Développement CAO
tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
-- Best regards, Igor Stasenko.
On Sun, Dec 16, 2012 at 6:27 PM, Igor Stasenko <siguctua@gmail.com> wrote:
On 16 December 2012 16:05, Ciprian Teodorov <ciprian.teodorov@gmail.com> wrote:
Hi Igor,
Besides some other small comits, in NativeBoost-Core-CiprianTeodorov.103 I have changed the way anonymous subclasses of NBExternalTypeValue and NBExternalArray are created.
The reason is that using the old way we would create multiple instances of the same metaclass which is not allowed in the image. BTW, I was getting this problem when trying to modify (add or remove) class instance variables of the NBExternalArray.
So, your problem is that you abusing it :)
Lool. Yes I abused it a little bit ... ;) but not this time.
Anonymous subclasses is there for sole purpose to provide common minimal protocol for their instances. If you need something else, you can just make normal subclasses.
In your image just do before := NBExternalArray class allInstances size. myFloatArray := NBExternalArray ofType: #NBFloat32 . after := NBExternalArray class allInstances size. {before. after} inspect. the number of metaclass instances should be one. If there are more you get errors when refactoring your class. Now just image that I have create a few of these external array types... before being able to touch the NBExternalArray ever again you have to somehow get rid of all wrong instances ... I did that yesterday and is not funny...
Doing NBExternalArray class allInstances, I was clearly getting more than one instance...
Now the anonymous subclasses are build using ClassBuilder>>#newSubclassOf:type:instanceVariables:from: which seems to prevent this problem from happening.
What do you think? Are there other ways to get around this problem?
Sure , you can use class builder, but again, you need it because you want to have more than just minimal interface. So, again, why don't just create own subclass?
I was playing a little bit with static arrays... passed by value on stack... you know I already told you that I want to use arrays in structures like struct {void *x[100]; }. I think that I can use the NBExternalStruct for that but ... seeing NBExternalArray tempted me
And since we are here ;) one more question: Why the NBExternalArray does not have a type ? It seems to me that they are not symmetric with all other native types.
Cheers, -- Dr. Ciprian TEODOROV Ingénieur Développement CAO
tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
-- Best regards, Igor Stasenko.
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
On 16 December 2012 19:02, Ciprian Teodorov <ciprian.teodorov@gmail.com> wrote:
On Sun, Dec 16, 2012 at 6:27 PM, Igor Stasenko <siguctua@gmail.com> wrote:
On 16 December 2012 16:05, Ciprian Teodorov <ciprian.teodorov@gmail.com> wrote:
Hi Igor,
Besides some other small comits, in NativeBoost-Core-CiprianTeodorov.103 I have changed the way anonymous subclasses of NBExternalTypeValue and NBExternalArray are created.
The reason is that using the old way we would create multiple instances of the same metaclass which is not allowed in the image. BTW, I was getting this problem when trying to modify (add or remove) class instance variables of the NBExternalArray.
So, your problem is that you abusing it :)
Lool. Yes I abused it a little bit ... ;) but not this time.
Anonymous subclasses is there for sole purpose to provide common minimal protocol for their instances. If you need something else, you can just make normal subclasses.
In your image just do
before := NBExternalArray class allInstances size. myFloatArray := NBExternalArray ofType: #NBFloat32 . after := NBExternalArray class allInstances size.
{before. after} inspect.
the number of metaclass instances should be one. If there are more you get errors when refactoring your class.
Now just image that I have create a few of these external array types... before being able to touch the NBExternalArray ever again you have to somehow get rid of all wrong instances ... I did that yesterday and is not funny...
yes, not funny. but why touching NBExternalArray in a first place? :)
Doing NBExternalArray class allInstances, I was clearly getting more than one instance...
Now the anonymous subclasses are build using ClassBuilder>>#newSubclassOf:type:instanceVariables:from: which seems to prevent this problem from happening.
What do you think? Are there other ways to get around this problem?
Sure , you can use class builder, but again, you need it because you want to have more than just minimal interface. So, again, why don't just create own subclass?
I was playing a little bit with static arrays... passed by value on stack... you know I already told you that I want to use arrays in structures like struct {void *x[100]; }. I think that I can use the NBExternalStruct for that but ... seeing NBExternalArray tempted me
And since we are here ;) one more question: Why the NBExternalArray does not have a type ? It seems to me that they are not symmetric with all other native types.
well, it adds another dimension to type system.. it needs to be implemented.. one day :) Right now, for passing a pointer to array to some function, you can use 'myArray address' it works both for external/internal arrays. -- Best regards, Igor Stasenko.
well... it turns out that my thing does not work either since the tools are expecting named classes everywhere... stay tuned for my 1 billion dolar question :)) On Sun, Dec 16, 2012 at 7:25 PM, Igor Stasenko <siguctua@gmail.com> wrote:
On 16 December 2012 19:02, Ciprian Teodorov <ciprian.teodorov@gmail.com> wrote:
On Sun, Dec 16, 2012 at 6:27 PM, Igor Stasenko <siguctua@gmail.com>
wrote:
On 16 December 2012 16:05, Ciprian Teodorov <ciprian.teodorov@gmail.com
wrote:
Hi Igor,
Besides some other small comits, in NativeBoost-Core-CiprianTeodorov.103 I have changed the way anonymous subclasses of NBExternalTypeValue and NBExternalArray are created.
The reason is that using the old way we would create multiple instances of the same metaclass which is not allowed in the image. BTW, I was getting this problem when trying to modify (add or remove) class instance variables of the NBExternalArray.
So, your problem is that you abusing it :)
Lool. Yes I abused it a little bit ... ;) but not this time.
Anonymous subclasses is there for sole purpose to provide common minimal protocol for their instances. If you need something else, you can just make normal subclasses.
In your image just do
before := NBExternalArray class allInstances size. myFloatArray := NBExternalArray ofType: #NBFloat32 . after := NBExternalArray class allInstances size.
{before. after} inspect.
the number of metaclass instances should be one. If there are more you get errors when refactoring your class.
Now just image that I have create a few of these external array types... before being able to touch the NBExternalArray ever again you have to somehow get rid of all wrong instances ... I did that yesterday and is not funny...
yes, not funny. but why touching NBExternalArray in a first place? :)
Doing NBExternalArray class allInstances, I was clearly getting more than one instance...
Now the anonymous subclasses are build using ClassBuilder>>#newSubclassOf:type:instanceVariables:from: which seems
to
prevent this problem from happening.
What do you think? Are there other ways to get around this problem?
Sure , you can use class builder, but again, you need it because you want to have more than just minimal interface. So, again, why don't just create own subclass?
I was playing a little bit with static arrays... passed by value on stack... you know I already told you that I want to use arrays in structures like struct {void *x[100]; }. I think that I can use the NBExternalStruct for that but ... seeing NBExternalArray tempted me
And since we are here ;) one more question: Why the NBExternalArray does not have a type ? It seems to me that they are not symmetric with all other native types.
well, it adds another dimension to type system.. it needs to be implemented.. one day :)
Right now, for passing a pointer to array to some function, you can use 'myArray address' it works both for external/internal arrays.
-- Best regards, Igor Stasenko.
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
On Sun, Dec 16, 2012 at 7:37 PM, Ciprian Teodorov < ciprian.teodorov@gmail.com> wrote:
well... it turns out that my thing does not work either since the tools are expecting named classes everywhere... stay tuned for my 1 billion dolar question :))
it seems to work in 2.0, and not in 1.4?
On Sun, Dec 16, 2012 at 7:25 PM, Igor Stasenko <siguctua@gmail.com> wrote:
On 16 December 2012 19:02, Ciprian Teodorov <ciprian.teodorov@gmail.com> wrote:
On Sun, Dec 16, 2012 at 6:27 PM, Igor Stasenko <siguctua@gmail.com>
wrote:
On 16 December 2012 16:05, Ciprian Teodorov <
ciprian.teodorov@gmail.com>
wrote:
Hi Igor,
Besides some other small comits, in NativeBoost-Core-CiprianTeodorov.103 I have changed the way anonymous subclasses of NBExternalTypeValue and NBExternalArray are created.
The reason is that using the old way we would create multiple instances of the same metaclass which is not allowed in the image. BTW, I was getting this problem when trying to modify (add or remove) class instance variables of the NBExternalArray.
So, your problem is that you abusing it :)
Lool. Yes I abused it a little bit ... ;) but not this time.
Anonymous subclasses is there for sole purpose to provide common minimal protocol for their instances. If you need something else, you can just make normal subclasses.
In your image just do
before := NBExternalArray class allInstances size. myFloatArray := NBExternalArray ofType: #NBFloat32 . after := NBExternalArray class allInstances size.
{before. after} inspect.
the number of metaclass instances should be one. If there are more you get errors when refactoring your class.
Now just image that I have create a few of these external array types... before being able to touch the NBExternalArray ever again you have to somehow get rid of all wrong instances ... I did that yesterday and is not funny...
yes, not funny. but why touching NBExternalArray in a first place? :)
Doing NBExternalArray class allInstances, I was clearly getting more than one instance...
Now the anonymous subclasses are build using ClassBuilder>>#newSubclassOf:type:instanceVariables:from: which
seems to
prevent this problem from happening.
What do you think? Are there other ways to get around this problem?
Sure , you can use class builder, but again, you need it because you want to have more than just minimal interface. So, again, why don't just create own subclass?
I was playing a little bit with static arrays... passed by value on stack... you know I already told you that I want to use arrays in structures like struct {void *x[100]; }. I think that I can use the NBExternalStruct for that but ... seeing NBExternalArray tempted me
And since we are here ;) one more question: Why the NBExternalArray does not have a type ? It seems to me that they are not symmetric with all other native types.
well, it adds another dimension to type system.. it needs to be implemented.. one day :)
Right now, for passing a pointer to array to some function, you can use 'myArray address' it works both for external/internal arrays.
-- Best regards, Igor Stasenko.
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO
tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
On Sun, Dec 16, 2012 at 7:25 PM, Igor Stasenko <siguctua@gmail.com> wrote:
On 16 December 2012 19:02, Ciprian Teodorov <ciprian.teodorov@gmail.com> wrote:
On Sun, Dec 16, 2012 at 6:27 PM, Igor Stasenko <siguctua@gmail.com>
wrote:
On 16 December 2012 16:05, Ciprian Teodorov <ciprian.teodorov@gmail.com
wrote:
Hi Igor,
Besides some other small comits, in NativeBoost-Core-CiprianTeodorov.103 I have changed the way anonymous subclasses of NBExternalTypeValue and NBExternalArray are created.
The reason is that using the old way we would create multiple instances of the same metaclass which is not allowed in the image. BTW, I was getting this problem when trying to modify (add or remove) class instance variables of the NBExternalArray.
So, your problem is that you abusing it :)
Lool. Yes I abused it a little bit ... ;) but not this time.
Anonymous subclasses is there for sole purpose to provide common minimal protocol for their instances. If you need something else, you can just make normal subclasses.
In your image just do
before := NBExternalArray class allInstances size. myFloatArray := NBExternalArray ofType: #NBFloat32 . after := NBExternalArray class allInstances size.
{before. after} inspect.
the number of metaclass instances should be one. If there are more you get errors when refactoring your class.
Now just image that I have create a few of these external array types... before being able to touch the NBExternalArray ever again you have to somehow get rid of all wrong instances ... I did that yesterday and is not funny...
yes, not funny. but why touching NBExternalArray in a first place? :)
I'm writing a FFI generator for Pharo that uses clang to parse header files and generates nativeboost mapping as output. The beast is almost working but there are still some small issues. So, that's why I've been poking at nativeboost ;) At the end I expect to have something that will generate correct ffi interface, and that will not bloat the image with thousand classes...
Doing NBExternalArray class allInstances, I was clearly getting more than one instance...
Now the anonymous subclasses are build using ClassBuilder>>#newSubclassOf:type:instanceVariables:from: which seems
to
prevent this problem from happening.
What do you think? Are there other ways to get around this problem?
Sure , you can use class builder, but again, you need it because you want to have more than just minimal interface. So, again, why don't just create own subclass?
I was playing a little bit with static arrays... passed by value on stack... you know I already told you that I want to use arrays in structures like struct {void *x[100]; }. I think that I can use the NBExternalStruct for that but ... seeing NBExternalArray tempted me
And since we are here ;) one more question: Why the NBExternalArray does not have a type ? It seems to me that they are not symmetric with all other native types.
well, it adds another dimension to type system.. it needs to be implemented.. one day :)
Right now, for passing a pointer to array to some function, you can use 'myArray address' it works both for external/internal arrays.
-- Best regards, Igor Stasenko.
-- Dr. Ciprian TEODOROV Ingénieur Développement CAO tél : 06 08 54 73 48 mail : ciprian.teodorov@gmail.com www.teodorov.ro
participants (2)
-
Ciprian Teodorov -
Igor Stasenko