Creating a Class in a Temporary Environment

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Creating a Class in a Temporary Environment

Sean P. DeNigris
Administrator
I used to have

        creatingAClassInATemporaryNamespace

        | testingEnvironment morph |
        testingEnvironment := SystemDictionary new.

        ClassBuilder new
                name: #AClassForTesting
                inEnvironment: testingEnvironment
                subclassOf: Object
                type: Object typeOfClass
                instanceVariableNames: ''
                classVariableNames: ''
                poolDictionaries: ''
                category: 'TemporaryTesting'.

How do I do this with Slots?

I tried:

        creatingAClassInATemporaryNamespace

        | testingEnvironment morph |
        testingEnvironment := SystemDictionary new.

        PharoClassInstaller make: [ :builder |
                builder
                        superclass: Object;
                        name: #AClassForTesting;
                        environment: testingEnvironment;
                        category: 'TemporaryTesting' ].

but got "key #SystemOrganization not found in SystemDictionary".
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Creating a Class in a Temporary Environment

Mariano Martinez Peck
Sean, 

Maybe it is not exactly what you asked but when it is about creating classes/traits for testing I always used ClassFactoryForTestCase (see it is used by Fuel). You can even check how that class currently creates the stuff.

Cheers,

On Tue, May 12, 2015 at 7:45 AM, Sean P. DeNigris <[hidden email]> wrote:
I used to have

        creatingAClassInATemporaryNamespace

        | testingEnvironment morph |
        testingEnvironment := SystemDictionary new.

        ClassBuilder new
                name: #AClassForTesting
                inEnvironment: testingEnvironment
                subclassOf: Object
                type: Object typeOfClass
                instanceVariableNames: ''
                classVariableNames: ''
                poolDictionaries: ''
                category: 'TemporaryTesting'.

How do I do this with Slots?

I tried:

        creatingAClassInATemporaryNamespace

        | testingEnvironment morph |
        testingEnvironment := SystemDictionary new.

        PharoClassInstaller make: [ :builder |
                builder
                        superclass: Object;
                        name: #AClassForTesting;
                        environment: testingEnvironment;
                        category: 'TemporaryTesting' ].

but got "key #SystemOrganization not found in SystemDictionary".



-----
Cheers,
Sean
--
View this message in context: http://forum.world.st/Creating-a-Class-in-a-Temporary-Environment-tp4825963.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.




--
Reply | Threaded
Open this post in threaded view
|

Re: Creating a Class in a Temporary Environment

camille teruel
In reply to this post by Sean P. DeNigris
Hi Sean,

You can use AnonymousClassInstaller instead of PharoClassInstaller.
We should improve it because it has limitations: the environment is not used and you won’t be able to change the slots or the superclass after creation.

AnonymousClassInstaller make: [ :builder |
        builder
                superclass: Object;
                name: #AClassForTesting ].

Camille


> On 12 May 2015, at 12:45, Sean P. DeNigris <[hidden email]> wrote:
>
> I used to have
>
> creatingAClassInATemporaryNamespace
>
> | testingEnvironment morph |
> testingEnvironment := SystemDictionary new.
>
> ClassBuilder new
> name: #AClassForTesting
> inEnvironment: testingEnvironment
> subclassOf: Object
> type: Object typeOfClass
> instanceVariableNames: ''
> classVariableNames: ''
> poolDictionaries: ''
> category: 'TemporaryTesting'.
>
> How do I do this with Slots?
>
> I tried:
>
> creatingAClassInATemporaryNamespace
>
> | testingEnvironment morph |
> testingEnvironment := SystemDictionary new.
>
> PharoClassInstaller make: [ :builder |
> builder
> superclass: Object;
> name: #AClassForTesting;
> environment: testingEnvironment;
> category: 'TemporaryTesting' ].
>
> but got "key #SystemOrganization not found in SystemDictionary”.
>
> -----
> Cheers,
> Sean
> --
> View this message in context: http://forum.world.st/Creating-a-Class-in-a-Temporary-Environment-tp4825963.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: Creating a Class in a Temporary Environment

Marcus Denker-4

> On 12 May 2015, at 14:57, Camille <[hidden email]> wrote:
>
> Hi Sean,
>
> You can use AnonymousClassInstaller instead of PharoClassInstaller.

Hmmm… I don’t like that. It is for anonymous classes.

We should fix the class builder itself… and check that Opal can use environments, too.

It is already on my TODO...

> We should improve it because it has limitations: the environment is not used and you won’t be able to change the slots or the superclass after creation.
>
> AnonymousClassInstaller make: [ :builder |
> builder
> superclass: Object;
> name: #AClassForTesting ].
>
> Camille
>
>
>> On 12 May 2015, at 12:45, Sean P. DeNigris <[hidden email]> wrote:
>>
>> I used to have
>>
>> creatingAClassInATemporaryNamespace
>>
>> | testingEnvironment morph |
>> testingEnvironment := SystemDictionary new.
>>
>> ClassBuilder new
>> name: #AClassForTesting
>> inEnvironment: testingEnvironment
>> subclassOf: Object
>> type: Object typeOfClass
>> instanceVariableNames: ''
>> classVariableNames: ''
>> poolDictionaries: ''
>> category: 'TemporaryTesting'.
>>
>> How do I do this with Slots?
>>
>> I tried:
>>
>> creatingAClassInATemporaryNamespace
>>
>> | testingEnvironment morph |
>> testingEnvironment := SystemDictionary new.
>>
>> PharoClassInstaller make: [ :builder |
>> builder
>> superclass: Object;
>> name: #AClassForTesting;
>> environment: testingEnvironment;
>> category: 'TemporaryTesting' ].
>>
>> but got "key #SystemOrganization not found in SystemDictionary”.
>>
>> -----
>> Cheers,
>> Sean
>> --
>> View this message in context: http://forum.world.st/Creating-a-Class-in-a-Temporary-Environment-tp4825963.html
>> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Creating a Class in a Temporary Environment

Marcus Denker-4
In reply to this post by Sean P. DeNigris

On Tue, May 12, 2015 at 12:45 PM, Sean P. DeNigris <[hidden email]> wrote:
I used to have

        creatingAClassInATemporaryNamespace

        | testingEnvironment morph |
        testingEnvironment := SystemDictionary new.

        ClassBuilder new
                name: #AClassForTesting
                inEnvironment: testingEnvironment
                subclassOf: Object
                type: Object typeOfClass
                instanceVariableNames: ''
                classVariableNames: ''
                poolDictionaries: ''
                category: 'TemporaryTesting'.

How do I do this with Slots?

I tried:

        creatingAClassInATemporaryNamespace

        | testingEnvironment morph |
        testingEnvironment := SystemDictionary new.

        PharoClassInstaller make: [ :builder |
                builder
                        superclass: Object;
                        name: #AClassForTesting;
                        environment: testingEnvironment;
                        category: 'TemporaryTesting' ].

but got "key #SystemOrganization not found in SystemDictionary".



-----
Cheers,
Sean
--
View this message in context: http://forum.world.st/Creating-a-Class-in-a-Temporary-Environment-tp4825963.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.




--
Reply | Threaded
Open this post in threaded view
|

Re: Creating a Class in a Temporary Environment

Sean P. DeNigris
Administrator
Marcus Denker-4 wrote
I fixed it:
Cool! Thanks :)
Cheers,
Sean