Now we make use of the client data to track the indent level. The recursive call to clang_visitChildren() seems a bit of an anti-pattern to use with a visitor – presumably a new visitor is created each call. However that’s how it was done in a few tutorials I found and it does provide local storage for each nextLevel variable for the purpose of this demonstration. Continue reading
Okay, so we’ve got most of the parts ready. In the last part we managed to load the AST. Now lets do something useful with it. Traversing the tree is done uses a visitor pattern that supplies cursors to a callback function that define locations in the tree. To the original C code from part 3 we add: the callback function, which I’ve called acceptCursorCallback(); and the callout function clang_visitChildren(), which traverses the tree and invokes the callback function for each node it visits. Continue reading
In the last part we learnt how to get the version string of the library. That was good to prove it basically works, and also to develop our first C type “CXString“. Now we want to Pharo to process some C code. Baby steps with `libclang`: Walking an abstract syntax tree provided a good introductory tutorial to using libclang but was a bit C++ oriented, which is not so suitable for Pharo’s FFI. A pure C interface is easier, so I adapted that tutorial with help from sabottenda’s libclang-sample ASTVisitor. Continue reading
This is my first exposure to using Pharo’s FFI, so before diving in to process some AST, lets try something simpler to gain familiarity with the library. Something real simple…
no parameters and just returning a string. The function clang_getClangVersion() seems to fit the bill. First lets see how it works in pure-C. Continue reading
Table of contents
I wanted to better understand the opensmalltalk-vm that Pharo runs on. I started to manually chart and compare the C code between platforms, which was insightful but tedious and error prone. What I needed was to automatically process these files. Clang is a C language front-end for the LLVM compiler, designed to be integrated into external projects. Libclang provides an interface suitable for the Pharo FFI, but I’d never used FFI before. From a distance FFI had seemed somewhat daunting and complex, but it turns out reasonably straight forward. I’m documenting my experience in the form of this tutorial that I can refer back to, and perhaps shines a newbie light on things that may encourage other FFI neophytes to give it a go. Continue reading
When I was learning Pharo Smalltalk, I found the Pharo By Example book a great help. It was well written and available at a good price ;). However as Pharo advances at great speed and the original authors are busy documenting and implementing new and advanced features – this learning resource has become out of date with some of its examples. So I thought I’d contribute back to help update it to the latest release. Here is how…
Having just got ConfigurationOfODBC working from Pharo Smalltalk, I had some trouble determining exactly how to get at the individual data items. So I thought I’d check out DBXTalk for comparison. DBXTalk is a lot more comprehensive solution leaveraging OpenDBX which includes its own ODBC interface along with several other backends. However all the ODBC connection examples I saw were for database servers with connection strings that were not of the “DSN” form that I think is required for Microsoft Access – so I ended up returning to ConfigurationOfODBC and resolving the issue above.
Yet I was most of the way through getting DBXTalk working, so I record my experience here for posterity. It is the “hack” version since to resolve library dependencies I simply copied everything next to virtual machine executable. I’ll look into resolving these more correctly later. So I… Continue reading
Wow. Eight months since my last post. It is now apparent the impact over that time of my 60-70 hour work week onsite at a mine expansion.
This post summarises the result of discussion on the pharo-project mailling list where I sought assistance getting ODBC working on Pharo 1.3. Credit goes to Mariano Peck and Eliot Mirranda for assistance troubleshooting, providing a slightly older configuration that worked, and then the latest VM build. I am happy to report that ODBC appears to be working with the Pharo 1.3 image on MS Windows 7 using CogVM version 2522.
The purpose of this is that I have a UML design an application has stored in a Microsoft Access database. I want to use Pharo to implement that design directly into Smalltalk classes since I could not find a common export/import format. ConfigurationOfODBC looked promising so I followed instructions at http://www.pharocasts.com/2010/12/access-database-through-odbc.html, except that rather than using SQLLite I started with a blank Microsoft Access database. This worked well on Pharo 1.2.1 but not out of the box Pharo 1.3.
Here is the method to get ODBC working and tested with Pharo 1.3. Continue reading
My mouse is a Logitech Wireless Nano Mouse M305. The default function of the mousewheel (button 3) is Zoom. To be most useful for Smalltalk, the mousewheel function needed to be configured as Middle Button. For Windows 7 this was done via
[Start > Control Panel > Mouse > SetPoint Settings] as pictured below. Continue reading
For anyone anyone so inclined to replicate the results, or update the results for subsequent releases of the Smalltalk systems, the linked spreadsheet Squeak Graphics Framework Performance Testing.ODF was used to generate the graphs in these articles:
You are able to attach graphs to your comments in those articles.