primitiveMaker and proxies

Chris Double chris.double at double.co.nz
Sun Sep 22 15:00:31 UTC 2013


I'm attempting to add some types and functions to xlibTemplates.self. It
took me a while to understand how some things work and am hopeful that
someone can help me see if I'm on the right path.

I'm adding a type, 'XftFont' and some functions that operate on it. In
xlib_glue.cpp I added the 'template(XftFont). In xlibTemplates.self I
added a test accessor:

  traits: traits xlib xftFont
   visibility: publicSlot
    XftFont ascent = int getMember ascent

For this to work I needed to add a 'traits xlib xftFont' object in my
world. Running the template script successfully added the 'ascent'
method to the trait so I think I understand that area ok.

Next step was to add a method to the template that created an XftFont
object:

 Display xftFontOpenOnScreen: int \
                        Name: string \
         = XftFont {xlib xftFont deadCopy} \
            call XftFontOpenName canAWS

I see some template definitions use something like:

         = proxy XftFont* XftFont_seal \
             {xlib xftFont deadCopy} \
             call XftFontOpenName canAWS

Are 'proxy XftFont* XftFont_seal' and 'XftFont' funtionally equivalent?
When would you use one over the other?

I'm using 'string' in the definition. Other templates use 'string_null'
and 'string_len_null'. What's the difference?

For this definition to work I needed to have an 'xlib xftFont' object in
the world. I struggled to find out how to create one of these that
worked but eventually I found that I needed to:

1) Create an object that is a 'copy down' parent of 'proxy' using
'deadCopy' as the selector and ommitting 'parent'. This can be done by
changing the attributes of an object or using 'Subclass Me' from the
middle click menu of 'proxy'.

2) Change the 'parent' slot of the object to be 'traits xftFont' I
created earlier.

If I didn't do (1) above and instead just 'copy' the 'proxy' object and
change the parent slot then the foreign function calls would fail with a
type error.

Once I did these steps and rebuilt the VM plus world then calling the
function gave me an XftFont object I could inspect, success!

I notice that most of the slots in 'xlib' have 'dead 'or 'alive' in the
name. My 'xlib xftFont' object didn't have this until I set 'Complete'
to 'Yes' in the attributes. What does 'Complete' mean?

Does the above sound right for integrating a new foreign object and
functions into the VM? 

-- 
http://www.bluishcoder.co.nz



More information about the Self-interest mailing list