Aida tutorial error? - smalltalk

Newbee question - I am trying to learn Aida from the 6.0 version for Dolphin Smalltalk using the tutorial for Pharao (I think). I know Smalltalk quite well but I am new to Web.
From AIDA tutorial:
**3. Registering a root domain object
After our ADemoAddressBook is prepared, we register its URL in Aida, so that it is accessible from web. In our workspace we evaluate:
AIDASite default register: book onUrl: '/addressbook'
But I get : register:onUrl: not understood, and I cannot find the method in the AIDASite class or in the image??
Really strange - what is the correct method to use ?
OBS OBS
Wow - I found it. Inspired by the french tutorial on the Wiki http://community.ofset.org/index.php/Aida_Tutorial.
The following works:
AIDASite default urlResolver defaultURL: '/addressbook' forObject: book

I don't know on Dolphin but on Pharo3.0, the code:
AIDASite default register: book onUrl: '/addressbook'
works fine.
Anyway this question is still marked as non answered whereas the author edit it with a solution and Janko said it's an issue of Aida's versions. So this answer is just to "close" this question.

Related

Ironpython - Issues attaching to an instance of an already running program

Ok folks this is a long one, so please bear with me. I'll preface this by stating that I am -for all intents and purposes- a noob.
I'm trying to link to a running instance of a program (ETABS) using IronPython. The program has an API and decent documentation on how one can go about hooking into the running instance (EXAMPLE). However, their examples are for Python, C#, VB.net but not IronPython.
No biggie I thought, the Marshal module can be used to hook into it. So I tried this:
from System.Runtime.InteropServices import Marshal
csiApp = Marshal.GetActiveObject("CSI.ETABS.API.ETABSObject")
SapModel=csiApp.SapModel
Unfortunately I get errors on that last line - "ETABSObject has no attribute SapModel".
And yes, I've tried running it with csiApp.SapModel() as well with the same results.
So I delved deeper into it and apparently the object needs to be cast into another type - at least that's the way its been done for the C# example (LINK). Since - to my knowledge - we can't really cast objects around in Python (and yes, I've already tried clr.Convert) I came to the conclusion that the object being returned to Ironpython is a few abstractions removed from the object that I really need. Apparently comtypes can handle this automatically in the background (seeing as the python example works flawlessly). The code block below shows the object types returned to Ironpython and to pure python respectively:
Ipy : <System.MarshalByRefObject object at 0x000000000000002B [CSI.ETABS.API.ETABSObject]>
Python with comtypes : <POINTER(cOAPI) ptr=0x2e68d17f7c8 at 2e690b36a48>
I'm working on Ironpython 2.7.3 and can't really update it (for several reasons not relevant to this post). Would love to have advice on how to fix this or on how to install comtypes on Ipy.
So I think I've found the reason why this is happening - Ironpython cannot directly use MarshalByRefObjects (source) since Reflection doesn't work on these. It seems I'll need to create a C# class which can cast this object into the one I want, compile it into a dll and load that into my Ipy code.
I'll leave this here in case someone with more knowledge has a better answer.

PackT book - Advanced Express Web App Dev

I am running into a MOCHA problem in reference to the book, Chapter 1, during the first run of MOCHA test. it saying that my /heartbeat is undefined and not a function. I have copied the book, and I have even backed dependencies back down to what the book used (not what is most current) and still having a failure. I have my development upto the point of the failure in the book on github here (https://github.com/EnergeticPixels/expressWebAppDev_packt.git). Can anyone help point me out my mistake??? It has to be something simple.
totally my fault. I missed a darn comma following the function name in the express/index.js file. Told ya it was a simple mistake.

Error while porting a VisualAge Smalltalk 4.5 application to VA Smalltalk 8.6

I am porting an old (circa year 2000) IBM VAST 4.5 application to VA Smalltalk.
I managed to import the app from the VAST repository to my new VA Smalltalk repository with no error messages. But when I try to load the application this error occurs:
Error: 365 Cannot complete the load because CwItem can only be
defined by one of ('CwControls V 4.5a' 'CwWindowsControls V 8.6.0
[269]').
I understand that CwControls changed to CwWindowsControls but my Smalltalk knowledge is very rusty: I have no idea how to solve this.
Someone in the VA Smalltalk group mentioned a similar situation but his answer is a bit cryptic to me:
"CwControls app name is changed in new version as CwWindowsControls. When I create a empty app named CwControls, I can load apps uses controls in this app."
I know that I can create an empty app called CwControls but then my application will not compile as the methods normally provided by the original CwControls will not be present.
How can I solve this problem?
Thank you very much!!
It looks to me like CwWindowsControls already defines CwItem. When you load CwItem from the other project it is defined by CwControls though. I'm not familiar with VA but you might be able to resolve the issue by first deleting CwItem where it's defined by CwWindowsControls, then loading the other project and finally (possibly) refactor CwItem to be defined by CwWindowsControls.
I found a way to solve my problem.
My application needed another application called CwControls. But CwControls had changed its name to CwWindowsControls.
So, inspired by the answer by #MikeLeske, I just created an empty app called CwControls. That way VA Smalltalk let me continue the load.
Another error appeared then:
"Error: 365 Cannot complete the load because AbtCwPanel can only be defined by one of ('AbtRunWinCwControlsApp V 4.5' 'AbtWinRunViewsSubApp V 8.6.0 [269]')."
But the answer was similar: I just created an empty app called AbtRunWinCwControlsApp.
Now I have my 13 year old application loaded into my image. Time to work!!!
Thanks.
I had a similar problem, but with SstHttpSupport which became SstHttpCommunications and such.
I fixed this by "Managing" the application and removing the requirement for SstHttpSupport.
I then successfully ported the application into VAST 8.6.
Knowing that I no longer had SstHttpSupport, I add SstHttpCommunications as the new requirement in 8.6.
Hope this helps

Debugging interpreter in VM when changing vm primitives

Context
As a university project we want to change the the pharo vm to use an object-table and see what happens.
We use a pharo-vm clone from github and VMMaker. Building the VM works fine.
To get started we added a primitive that returns an incremented Integer:
InterpreterPrimitives>>primitiveIntegerIncrement
"increments an integer"
self pushInteger: self popInteger + 1 .
and modified StackInterpreter class>>initializePrimitiveTable accordingly
MaxPrimitiveIndex := 576.
"... and so on ..."
(575 primitiveFail)
(576 primitiveIntegerIncrement))
And it works.
Problem
When we make changes to the VM we want to test-run already in the SmalltalkImage so we do not need to compile and see it did not work.
Something like:
StackInterpreter test: '1 inc'
And then I can debug if the primitive is wrong or an error occurs. Of course there needs to be done much more but how can I achieve this?
What we tried
category VMMaker-InterpreterSimulation class StackInterpreterSimulator. Trying the code in the comments
DoIt
^ (StackInterpreterSimulator new openOn: Smalltalk imageName) test
errors:
displayForm := 'Display has not yet been installed' asDisplayText form.
the ByteString does not understand asDisplayText
(CogVMSimulator new openOn: Smalltalk imageName) test
(InterpreterSimulator new openOn: Smalltalk imageName) test
error:
PrimitiveFailed: primitive #basicNew: in Array class failed
I also found this screen cast but it only debugs the VM from outside using gbd: http://vimeo.com/22485382#
Our project is hosted here: http://smalltalkhub.com/#!/~kirstin/PharoObjectTable
Current Status
We started implementing an object table. The lookup of attributes can go throught the object table. Full object table support and no usage of direct pointes is very tricky since pointers are expected everywhere. So we use pointers into the object table to identify when a lookup should go through the OT. We also found all object creation primitives and add new objects to the table.
How long is your project and how many people are you ? To me what you try to do is quite some work. Do you have good knowledge about low level behavior ?
To answer your question, the main problem here is that the cog simulator is not maintained in the pharo vm fork. This is because no one in the pharo crew use the simulator. We only use external debugging from gdb. In fact the pharo folks work mostly on VM plugins, the core of the VM is mainly maintained and developed by Eliot Miranda which works on Squeak. Therefore we report to him when there's a bug in the VM core.
For your project you would have to split it in at least 2 steps:
step 1: make the object table work with the stack VM
step 2: make the JIT work with your object table
Note that for step 2 I would recommend not to change the way an object access its header, therefore having a VW-like object table where you have the fixed size header on the one in the the object table, and the fields of the objects (and maybe header extensions) in the heap.
So use the StackVMSimulator and build the StackVM first. When everything will work (including context), you can think about hacking the JIT. Recently Guillermo Polito ported the Stack VM to the build process (see PharoSVMBuilder instead of PharoVMBuilder), a guy reported problems with this builder but you could hack it a bit to make it work.
Now to make the simulator work on Pharo 2.0 (which is the Pharo version of the generator image you have), you have to open the monticello browser and merge from Eliot's branch the Cog package (repo MCHttpRepository location: 'http: //source. squeak. org/VMMaker'), but not the latest Cog, the one at around the same date as the current VMMaker package of pharo-vm because the latest Cog and VMMaker of Eliot's branch are not stable.
The alternative being to start from Eliot's build image and merge things from the pharo branch. Here are infos about how to build the squeak development image (http://www.mirandabanda.org/cogblog/build-image/).
Then Eliot gave me this script once:
| cos |
cos := CogVMSimulator newWithOptions: #(Cogit SistaStackToRegisterMappingCogit).
cos desiredNumStackPages: 8.
cos openOn: 'my/favourite.image'.
cos openAsMorph; toggleTranscript; halt; run
You don't need the SistaStackToRegisterMappingCogit option. I guess some similar script with the StackVMSimulator should work.
Lastly there are some documentation about the simulator but it is only for the CogSimulator (these documentations expects you already knows how the StackSimulator works, and just give you hints about how to use it with the JIT):
http://www.mirandabanda.org/cogblog/2008/12/12/simulate-out-of-the-bochs/
and in one of the video named "Cog VM (part x)", x being from 1 to 6, Eliot shows how he uses the simulator to disassemble x86, print the stack and inspect the heap.
Another tip, ask your questions on the pharo mailing list (pharo users or pharo dev), because here no one may notice your question (fortunately someone pointed me out your question this time).
And tell on the pharo mailing list if you managed to run the simulator in Pharo 2.0, some people (as me) are very interested in it. I was planning to do it at some point.
Good luck ! Nice project anyway.
The last time I tried to use the simulator is roughly a year ago, and I did not make it work.
However, there are a few patches, which I assume never got integrated that might be of help:
https://code.google.com/p/cog/issues/detail?id=106
https://code.google.com/p/cog/issues/detail?id=107
https://code.google.com/p/cog/issues/detail?id=108
Issue 107 includes a patch for your asDisplayText issue.

Getting Cocoa method completions in Sublime Text 2

I've been playing with Sublime Text 2 the last few days and was wondering if anyone out there has had any success getting Cocoa method completions working yet? Is there a plugin (or in-progress project to create one) out there?
Any general comments on using Objective-C in Chocolat or Sublime Text 2 would also be welcome.
There is an in-progress Sublime Text package that connects to clang to get autocomplete data called SublimeClang I've not managed to successfully get it to work totally with Cocoa/UIKit Dev, but here's a screenshot
and my options, that are a start
In MacVim I use a plugin called Cocoa.vim which haves useful python scripts that generates a classes and methods files for autocompletion. I didn't try so much with ST2, but may be is posible to create a sublime-package or sublime-completions file with all this data.
For the moment, I only create a sublime-completions file with some snippets. If I find a way to make this work, I will tell you.
I let my SublimeClang configuration options if helps anybody. I've already some of the autocompletions working:
"options":[
"-Wall",
"-isystem", "/Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/include/",
"-isystem", "/Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/include/c++/4.2.1/",
"-I/usr/lib/clang/3.1/include/**",
"-I", "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/llvm-gcc-4.2/lib/gcc/i686-apple-darwin11/4.2.1/include/",
"-arch","armv7",
"-isysroot", "/Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk",
"-D__IPHONE_OS_VERSION_MIN_REQUIRED=50000",
"-ferror-limit=0"
]
Answering my own question here. A quick visit to the Sublime forums didn't turn up any leads nor did Google. It looks as though method completions for Objective-C aren't currently part of the default install nor available via 3rd-party quite yet.
This user http://b.rthr.me/wp/?p=368 claims to have gotten SublimeClang working. I may report back myself once I try it...