native boost is the best thing since COGVM

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

native boost is the best thing since COGVM

Fernando olivero-2
I was able to create the binding to Pango using NB.

The ultimate goal is to provide a cleaner implementation of "text" widgets.

Thanks Igor !

Fernando

Screen Shot 2011-12-11 at 3.03.53 AM.png (246K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: native boost is the best thing since COGVM

Levente Uzonyi-2
Why wasn't that possible with FFI?


Levente

On Sun, 11 Dec 2011, Fernando Olivero wrote:

> I was able to create the binding to Pango using NB.
>
> The ultimate goal is to provide a cleaner implementation of "text" widgets.
>
> Thanks Igor !
>
> Fernando
>

Reply | Threaded
Open this post in threaded view
|

Re: native boost is the best thing since COGVM

Stéphane Ducasse
In reply to this post by Fernando olivero-2
neat.
Keep pushing.
I should sit with igor on the native boost chapter.

Stef
On Dec 11, 2011, at 3:09 AM, Fernando Olivero wrote:

> I was able to create the binding to Pango using NB.
>
> The ultimate goal is to provide a cleaner implementation of "text" widgets.
>
> Thanks Igor !
>
> Fernando
> <Screen Shot 2011-12-11 at 3.03.53 AM.png>


Reply | Threaded
Open this post in threaded view
|

Re: native boost is the best thing since COGVM

melkyades
In reply to this post by Fernando olivero-2
Cooool!!!

On 12/11/11, Fernando Olivero <[hidden email]> wrote:
> I was able to create the binding to Pango using NB.
>
> The ultimate goal is to provide a cleaner implementation of "text" widgets.
>
> Thanks Igor !
>
> Fernando
>


--
Lic. Javier Pimás
Ciudad de Buenos Aires

Reply | Threaded
Open this post in threaded view
|

Re: native boost is the best thing since COGVM

Fernando olivero-2
In reply to this post by Fernando olivero-2
A taste of what will be available: rendering the same GLabel (the
gaucho equivalent to StringMorph), scaling the CairoCanvas.

Pesudo Code:

"create a label"
label := GLabel on : 'hello Pango-Cairo'.

"draw it on the canvas"
label drawOn: canvas.

"scale the canvas"
canvas translateBy: aDelta ; scaleBy: aScale.

"draw it on the canvas"
label drawOn: canvas.

"repeat"




On Sun, Dec 11, 2011 at 7:43 PM, Javier Pimás
<[hidden email]> wrote:

> Cooool!!!
>
> On 12/11/11, Fernando Olivero <[hidden email]> wrote:
>> I was able to create the binding to Pango using NB.
>>
>> The ultimate goal is to provide a cleaner implementation of "text" widgets.
>>
>> Thanks Igor !
>>
>> Fernando
>>
>
>
> --
> Lic. Javier Pimás
> Ciudad de Buenos Aires

panoCairo.png (275K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: native boost is the best thing since COGVM

Tudor Girba-2
I am almost drooling :)

Doru


On Mon, Dec 12, 2011 at 4:02 PM, Fernando Olivero
<[hidden email]> wrote:

> A taste of what will be available: rendering the same GLabel (the
> gaucho equivalent to StringMorph), scaling the CairoCanvas.
>
> Pesudo Code:
>
> "create a label"
> label := GLabel on : 'hello Pango-Cairo'.
>
> "draw it on the canvas"
> label drawOn: canvas.
>
> "scale the canvas"
> canvas translateBy: aDelta ; scaleBy: aScale.
>
> "draw it on the canvas"
> label drawOn: canvas.
>
> "repeat"
>
>
>
>
> On Sun, Dec 11, 2011 at 7:43 PM, Javier Pimás
> <[hidden email]> wrote:
>> Cooool!!!
>>
>> On 12/11/11, Fernando Olivero <[hidden email]> wrote:
>>> I was able to create the binding to Pango using NB.
>>>
>>> The ultimate goal is to provide a cleaner implementation of "text" widgets.
>>>
>>> Thanks Igor !
>>>
>>> Fernando
>>>
>>
>>
>> --
>> Lic. Javier Pimás
>> Ciudad de Buenos Aires



--
www.tudorgirba.com

"Every thing has its own flow"

Reply | Threaded
Open this post in threaded view
|

Re: native boost is the best thing since COGVM

Igor Stasenko
CairoSamplePrograms>>rectangleAndText
does not works, because it uses a following method:

NBCairo>>selectFont: aFamily slant: slant weight: aWeight on: aNBCairoContext
        <primitive: #primitiveNativeCall module: #NativeBoostPlugin>
        ^self call: #(void cairo_select_font_face (NBCairoContext aNBCairoContext,
                                                         String aFamily,

cairo_font_slant_t slant,

cairo_font_weight_t aWeight) )


and during code generation it barks that it unable to resolve
'cairo_font_slant_t'  type.
Because NBCairo class does not includes a corresponding shared pool
(NBCairoTypes).

Also, Fernando, i don't like that you put everything into a single
class (NBCairo).
This is wrong, not object-oriented. The original organization made by
Javier was much more closer to my tastes.

This approach to wrapping a library is too mechanical. It is much
better to place calls at proper place(s) in proper classes,
rather than putting everything into a single one. Which means that in
this way you are at least 1 message send farther from
real function call.
But in your case its not even that..

NBCairoPattern>>status
        ^ self cairo patternStatusOf: self

cairo
        ^ NBCairo default

so , it is 2 extra message sends, instead of direct call to foreign function!


--
Best regards,
Igor Stasenko.

Reply | Threaded
Open this post in threaded view
|

Re: native boost is the best thing since COGVM

Fernando olivero-2
In reply to this post by Tudor Girba-2
ok, i see your point. I will refactor back to Javier's approach.
My rationale was to reify the Cairo library as it is, luckily all the
other examples work.

If i add the shared pool NBCairoTypes to the NBCairo then NativeBoost
automatically associates the type? Because i've been putting directly
"int". Would be nice to have a couple of examples of NB (whenever the
time is enough for you guys, i know you are busy)

thanks for the feedback,
Fernando



On Mon, Dec 12, 2011 at 5:05 PM, Igor Stasenko <[hidden email]> wrote:

> CairoSamplePrograms>>rectangleAndText
> does not works, because it uses a following method:
>
> NBCairo>>selectFont: aFamily slant: slant weight: aWeight on: aNBCairoContext
>        <primitive: #primitiveNativeCall module: #NativeBoostPlugin>
>        ^self call: #(void cairo_select_font_face (NBCairoContext aNBCairoContext,
>                                                         String aFamily,
>
> cairo_font_slant_t slant,
>
> cairo_font_weight_t aWeight) )
>
>
> and during code generation it barks that it unable to resolve
> 'cairo_font_slant_t'  type.
> Because NBCairo class does not includes a corresponding shared pool
> (NBCairoTypes).
>
> Also, Fernando, i don't like that you put everything into a single
> class (NBCairo).
> This is wrong, not object-oriented. The original organization made by
> Javier was much more closer to my tastes.
>
> This approach to wrapping a library is too mechanical. It is much
> better to place calls at proper place(s) in proper classes,
> rather than putting everything into a single one. Which means that in
> this way you are at least 1 message send farther from
> real function call.
> But in your case its not even that..
>
> NBCairoPattern>>status
>        ^ self cairo patternStatusOf: self
>
> cairo
>        ^ NBCairo default
>
> so , it is 2 extra message sends, instead of direct call to foreign function!
>
>
> --
> Best regards,
> Igor Stasenko.
>

Reply | Threaded
Open this post in threaded view
|

Re: native boost is the best thing since COGVM

Igor Stasenko
On 12 December 2011 17:16, Fernando Olivero <[hidden email]> wrote:
> ok, i see your point. I will refactor back to Javier's approach.
> My rationale was to reify the Cairo library as it is, luckily all the
> other examples work.

Well, it makes sense to do things like that, when you want a fast and
dirty working stuff.
But a good wrapping makes a lot of difference: there is no need to
indicate that you using a library
through 'self cairo' everywhere. It is just an indirection without any benefit.

Wrapper classes and their instances should provide a required
functionality through well defined protocols, and then from user's
standpoint it is really
makes no difference who implements them.
That's why we need Athens.

>
> If i add the shared pool NBCairoTypes to the NBCairo then NativeBoost
> automatically associates the type? Because i've been putting directly
> "int". Would be nice to have a couple of examples of NB (whenever the
> time is enough for you guys, i know you are busy)
>

Yes, but these examples were written specifically to show how to wrap
a library in object-oriented way  :)
Look at pharo by example book [1], there you can find an explanation
how to use shared pools.
Of course it is far from complete, but my opinion that your
refactoring gives a bad example to future developers.
They should think in terms of objects and place callouts in
corresponding classes with nicely formed protocol(s).

I am looking forward for you to come, so i can explain things more
directly and easier :)

[1] https://gforge.inria.fr/scm/viewvc.php/*checkout*/PharoByExampleTwo-Eng/Alien/alien.pdf?root=pharobooks

> thanks for the feedback,
> Fernando
>
>
>
> On Mon, Dec 12, 2011 at 5:05 PM, Igor Stasenko <[hidden email]> wrote:
>> CairoSamplePrograms>>rectangleAndText
>> does not works, because it uses a following method:
>>
>> NBCairo>>selectFont: aFamily slant: slant weight: aWeight on: aNBCairoContext
>>        <primitive: #primitiveNativeCall module: #NativeBoostPlugin>
>>        ^self call: #(void cairo_select_font_face (NBCairoContext aNBCairoContext,
>>                                                         String aFamily,
>>
>> cairo_font_slant_t slant,
>>
>> cairo_font_weight_t aWeight) )
>>
>>
>> and during code generation it barks that it unable to resolve
>> 'cairo_font_slant_t'  type.
>> Because NBCairo class does not includes a corresponding shared pool
>> (NBCairoTypes).
>>
>> Also, Fernando, i don't like that you put everything into a single
>> class (NBCairo).
>> This is wrong, not object-oriented. The original organization made by
>> Javier was much more closer to my tastes.
>>
>> This approach to wrapping a library is too mechanical. It is much
>> better to place calls at proper place(s) in proper classes,
>> rather than putting everything into a single one. Which means that in
>> this way you are at least 1 message send farther from
>> real function call.
>> But in your case its not even that..
>>
>> NBCairoPattern>>status
>>        ^ self cairo patternStatusOf: self
>>
>> cairo
>>        ^ NBCairo default
>>
>> so , it is 2 extra message sends, instead of direct call to foreign function!
>>
>>
>> --
>> Best regards,
>> Igor Stasenko.
>>
>



--
Best regards,
Igor Stasenko.

Reply | Threaded
Open this post in threaded view
|

Re: native boost is the best thing since COGVM

Stéphane Ducasse
In reply to this post by Fernando olivero-2
Igor

what is the link between pango cairo and the work you did on the text model in athens?
Because I have the impression that you work on text modeling is important.

Stef


> A taste of what will be available: rendering the same GLabel (the
> gaucho equivalent to StringMorph), scaling the CairoCanvas.
>
> Pesudo Code:
>
> "create a label"
> label := GLabel on : 'hello Pango-Cairo'.
>
> "draw it on the canvas"
> label drawOn: canvas.
>
> "scale the canvas"
> canvas translateBy: aDelta ; scaleBy: aScale.
>
> "draw it on the canvas"
> label drawOn: canvas.
>
> "repeat"

Reply | Threaded
Open this post in threaded view
|

Re: native boost is the best thing since COGVM

Stéphane Ducasse
In reply to this post by Igor Stasenko

On Dec 12, 2011, at 5:35 PM, Igor Stasenko wrote:

> On 12 December 2011 17:16, Fernando Olivero <[hidden email]> wrote:
>> ok, i see your point. I will refactor back to Javier's approach.
>> My rationale was to reify the Cairo library as it is, luckily all the
>> other examples work.
>
> Well, it makes sense to do things like that, when you want a fast and
> dirty working stuff.
> But a good wrapping makes a lot of difference: there is no need to
> indicate that you using a library
> through 'self cairo' everywhere. It is just an indirection without any benefit.
>
> Wrapper classes and their instances should provide a required
> functionality through well defined protocols, and then from user's
> standpoint it is really
> makes no difference who implements them.
> That's why we need Athens.

Indeed we do want to have cairo dependencies inside our system
just encapsulated in their respective canvases.


>> If i add the shared pool NBCairoTypes to the NBCairo then NativeBoost
>> automatically associates the type? Because i've been putting directly
>> "int". Would be nice to have a couple of examples of NB (whenever the
>> time is enough for you guys, i know you are busy)
>>
>
> Yes, but these examples were written specifically to show how to wrap
> a library in object-oriented way  :)
> Look at pharo by example book [1], there you can find an explanation
> how to use shared pools.
> Of course it is far from complete, but my opinion that your
> refactoring gives a bad example to future developers.
> They should think in terms of objects and place callouts in
> corresponding classes with nicely formed protocol(s).
>
> I am looking forward for you to come, so i can explain things more
> directly and easier :)
>
> [1] https://gforge.inria.fr/scm/viewvc.php/*checkout*/PharoByExampleTwo-Eng/Alien/alien.pdf?root=pharobooks
>
>> thanks for the feedback,
>> Fernando
>>
>>
>>
>> On Mon, Dec 12, 2011 at 5:05 PM, Igor Stasenko <[hidden email]> wrote:
>>> CairoSamplePrograms>>rectangleAndText
>>> does not works, because it uses a following method:
>>>
>>> NBCairo>>selectFont: aFamily slant: slant weight: aWeight on: aNBCairoContext
>>>        <primitive: #primitiveNativeCall module: #NativeBoostPlugin>
>>>        ^self call: #(void cairo_select_font_face (NBCairoContext aNBCairoContext,
>>>                                                         String aFamily,
>>>
>>> cairo_font_slant_t slant,
>>>
>>> cairo_font_weight_t aWeight) )
>>>
>>>
>>> and during code generation it barks that it unable to resolve
>>> 'cairo_font_slant_t'  type.
>>> Because NBCairo class does not includes a corresponding shared pool
>>> (NBCairoTypes).
>>>
>>> Also, Fernando, i don't like that you put everything into a single
>>> class (NBCairo).
>>> This is wrong, not object-oriented. The original organization made by
>>> Javier was much more closer to my tastes.
>>>
>>> This approach to wrapping a library is too mechanical. It is much
>>> better to place calls at proper place(s) in proper classes,
>>> rather than putting everything into a single one. Which means that in
>>> this way you are at least 1 message send farther from
>>> real function call.
>>> But in your case its not even that..
>>>
>>> NBCairoPattern>>status
>>>        ^ self cairo patternStatusOf: self
>>>
>>> cairo
>>>        ^ NBCairo default
>>>
>>> so , it is 2 extra message sends, instead of direct call to foreign function!
>>>
>>>
>>> --
>>> Best regards,
>>> Igor Stasenko.
>>>
>>
>
>
>
> --
> Best regards,
> Igor Stasenko.
>


Reply | Threaded
Open this post in threaded view
|

Re: native boost is the best thing since COGVM

Fernando olivero-2
In reply to this post by Igor Stasenko
Done, indeed it's a better design now!

I've removed the NBCairo class, reified almost all Cairo objects as a
subclass of NBCairoObject.

I've also added CairoText, for easier drawing of text using Cairo Toy Text API.
(and CairoLineCap, CairoLineJoin )

All the examples work again, also the new ones. As soon as
squeaksource is up again i'll commit.

Fernando
pd: I will apply the same refactoring to NBPango also. I still have to
answer your questions regarding the use of Pango.


On Mon, Dec 12, 2011 at 6:44 PM, Stéphane Ducasse
<[hidden email]> wrote:

>
> On Dec 12, 2011, at 5:35 PM, Igor Stasenko wrote:
>
>> On 12 December 2011 17:16, Fernando Olivero <[hidden email]> wrote:
>>> ok, i see your point. I will refactor back to Javier's approach.
>>> My rationale was to reify the Cairo library as it is, luckily all the
>>> other examples work.
>>
>> Well, it makes sense to do things like that, when you want a fast and
>> dirty working stuff.
>> But a good wrapping makes a lot of difference: there is no need to
>> indicate that you using a library
>> through 'self cairo' everywhere. It is just an indirection without any benefit.
>>
>> Wrapper classes and their instances should provide a required
>> functionality through well defined protocols, and then from user's
>> standpoint it is really
>> makes no difference who implements them.
>> That's why we need Athens.
>
> Indeed we do want to have cairo dependencies inside our system
> just encapsulated in their respective canvases.
>
>
>>> If i add the shared pool NBCairoTypes to the NBCairo then NativeBoost
>>> automatically associates the type? Because i've been putting directly
>>> "int". Would be nice to have a couple of examples of NB (whenever the
>>> time is enough for you guys, i know you are busy)
>>>
>>
>> Yes, but these examples were written specifically to show how to wrap
>> a library in object-oriented way  :)
>> Look at pharo by example book [1], there you can find an explanation
>> how to use shared pools.
>> Of course it is far from complete, but my opinion that your
>> refactoring gives a bad example to future developers.
>> They should think in terms of objects and place callouts in
>> corresponding classes with nicely formed protocol(s).
>>
>> I am looking forward for you to come, so i can explain things more
>> directly and easier :)
>>
>> [1] https://gforge.inria.fr/scm/viewvc.php/*checkout*/PharoByExampleTwo-Eng/Alien/alien.pdf?root=pharobooks
>>
>>> thanks for the feedback,
>>> Fernando
>>>
>>>
>>>
>>> On Mon, Dec 12, 2011 at 5:05 PM, Igor Stasenko <[hidden email]> wrote:
>>>> CairoSamplePrograms>>rectangleAndText
>>>> does not works, because it uses a following method:
>>>>
>>>> NBCairo>>selectFont: aFamily slant: slant weight: aWeight on: aNBCairoContext
>>>>        <primitive: #primitiveNativeCall module: #NativeBoostPlugin>
>>>>        ^self call: #(void cairo_select_font_face (NBCairoContext aNBCairoContext,
>>>>                                                         String aFamily,
>>>>
>>>> cairo_font_slant_t slant,
>>>>
>>>> cairo_font_weight_t aWeight) )
>>>>
>>>>
>>>> and during code generation it barks that it unable to resolve
>>>> 'cairo_font_slant_t'  type.
>>>> Because NBCairo class does not includes a corresponding shared pool
>>>> (NBCairoTypes).
>>>>
>>>> Also, Fernando, i don't like that you put everything into a single
>>>> class (NBCairo).
>>>> This is wrong, not object-oriented. The original organization made by
>>>> Javier was much more closer to my tastes.
>>>>
>>>> This approach to wrapping a library is too mechanical. It is much
>>>> better to place calls at proper place(s) in proper classes,
>>>> rather than putting everything into a single one. Which means that in
>>>> this way you are at least 1 message send farther from
>>>> real function call.
>>>> But in your case its not even that..
>>>>
>>>> NBCairoPattern>>status
>>>>        ^ self cairo patternStatusOf: self
>>>>
>>>> cairo
>>>>        ^ NBCairo default
>>>>
>>>> so , it is 2 extra message sends, instead of direct call to foreign function!
>>>>
>>>>
>>>> --
>>>> Best regards,
>>>> Igor Stasenko.
>>>>
>>>
>>
>>
>>
>> --
>> Best regards,
>> Igor Stasenko.
>>
>

Reply | Threaded
Open this post in threaded view
|

Re: native boost is the best thing since COGVM

Igor Stasenko
In reply to this post by Stéphane Ducasse
On 12 December 2011 18:42, Stéphane Ducasse <[hidden email]> wrote:
> Igor
>
> what is the link between pango cairo and the work you did on the text model in athens?
> Because I have the impression that you work on text modeling is important.
>

i dont know much about pango to say anything, except that it is
library for text layout.

my impression, that if we will want to use pango for text layout, then
we need to use different model for text.
Or maybe Text could stay, but morphic related stuff will require
serious changes.

This is because when i did text layout for Athens, i had to make own
paragraph/morph pair, because of hardcoded
stuff in existing classes.

> Stef
>
>
>> A taste of what will be available: rendering the same GLabel (the
>> gaucho equivalent to StringMorph), scaling the CairoCanvas.
>>
>> Pesudo Code:
>>
>> "create a label"
>> label := GLabel on : 'hello Pango-Cairo'.
>>
>> "draw it on the canvas"
>> label drawOn: canvas.
>>
>> "scale the canvas"
>> canvas translateBy: aDelta ; scaleBy: aScale.
>>
>> "draw it on the canvas"
>> label drawOn: canvas.
>>
>> "repeat"
>



--
Best regards,
Igor Stasenko.