visualworks

Which Smalltalk object should be passed to a C function expecting const char*

倖福魔咒の 提交于 2021-01-27 14:36:02
问题 I want to call the following C function: int ssh_userauth_password (ssh_session session, const char * username, const char * password) But regular Smalltalk strings are not working: library ssh_login: session userAuth: nil password: 'myPwd'. session is a pointer that i already have and works ok. But const char * are not mapped to normal string. Is there any class to map this ? Also i tried with CPointer and asByteArray but both fail. 回答1: You need to pass a CPointer object. Easiest way to do

How to convert a number to a string in Smalltalk (visual works)

自作多情 提交于 2019-12-13 16:26:27
问题 I am having difficulty finding information on how to get a string representation of a number in Cincom Smalltalk. How is this performed in this language? Specifically I'm composing a string representation of an object, similar to the toString function in Java. 回答1: The printString method is meant to return a string to allow a programmer to interpret the number. If you used 3.14d in your example (a Double), you would see the 'd' character in the printString. This is fine for developers but if

Keyword messages in smalltalk (Beginner)(Pharo)

五迷三道 提交于 2019-12-11 13:38:36
问题 I am trying to create a keyword message style method, but I can't figure out how to access the Receiver from inside the method. I am sure this is simple, however I can't find the answer anywhere. What I am trying to implement is redundant, but I would still like to know how it works. subst: i1 by: i2 ^ self copyReplaceAll: i1 with: i2. It would be called in the workspace as follows: string1 := 'Lemon'. string2 := 'm'. string3 := 'ss'. string1 subst: string2 by: string3. Error msg:

How to create a window in smalltalk

落爺英雄遲暮 提交于 2019-12-11 03:26:10
问题 I am trying to make a window show up, but i keep getting a message not understood error. The snippet: Window new label: 'Hello'; open 回答1: Ok, for a game like that you want to use a custom control. You start by creating a subclass of View for your game and override the displayOn: method to display the view. You can add the view to the UIPainter canvas using a ViewHolder. Set the View: property to be the name of a method that returns your custom view. To intercept mouse clicks, you'll need to

Why can't I pass an UninterpretedBytes to a void* thru DLL/C-Connect?

孤者浪人 提交于 2019-12-11 01:09:09
问题 I'd like to pass an UninterpretedBytes to an external library, say something like this MyLibrary>>foo: buf len: len <C: int foo(void *buf,unsigned int len)> MyApplication>>test buffer := UninterpretedBytes new: 4. ^MyLibrary new foo: buffer len: buffer size. But this fails in CPointerType>>coerceForArgument:anObject . I know that I could use buffer gcCopyToHeap but I don't want to. I want to handle an object in Smalltalk memory with Smalltalk 1-based address and no extra copy nor any other

How to manage 2d array in Smalltalk?

两盒软妹~` 提交于 2019-12-10 16:11:28
问题 I have a list of point and have to do erosion/dilation operations. I need a kind of 2d-array but can't find how to do in VisualWorks (I know there is a Array2d class in Squeak, but I must use VW). 回答1: Use simply a generic way: array of arrays: (Array new: xSize) at: 1 put: ((Array new: ySize) at: 1 put: aValue; at: 2 put: aValue; ...); at: 2 put: ((Array new: ySize) at: 1 put: aValue; at: 2 put: aValue; ...); ... 回答2: Many Smalltalk implementation will have some kind of Matrix class,

Indices of a substring in Smalltalk

我与影子孤独终老i 提交于 2019-12-10 14:43:21
问题 It seems Smalltalk implementations misses an algorithm which return all the indices of a substring in a String. The most similar ones returns only one index of an element, for example : firstIndexesOf:in: , findSubstring:, findAnySubstring: variants. There are implementations in Ruby but the first one relies on a Ruby hack, the second one does not work ignoring overlapping Strings and the last one uses an Enumerator class which I don't know how to translate to Smalltalk. I wonder if this

What is the correct way to test Unicode support in a Smalltalk implementation?

江枫思渺然 提交于 2019-12-08 20:38:25
问题 Given any Smalltalk flavor, how should I proceed to check if Unicode is supported? In case of not having support, how can I detect at which level is missing (VM, font, Converter, etc)? 回答1: At the VM level you can try Character codePoint: 256 or Character codePoint: 65536 (some Smalltalks may use value: instead of codePoint: still). Converter APIs differ between dialects too, but chances are that if the VM supports Unicode so will the converters. As far as I know, no Smalltalk fully supports

Packages for developing static web sites in Smalltalk?

陌路散爱 提交于 2019-12-07 19:14:19
问题 What would be good (cross Smalltalk, mantained, documented) web frameworks or packages (in terms of fewer things to learn/adapt) to use for implementing a static web site with really few forms? .i.e. : a search box and a contact form. I have no "model" or application behind, so I'm not searching for CMS or web application capabilities. There is any example or simple script of a static web site developed in any web frameworks? please I'm NOT interested in counter or 'Hello World' examples. The

Packages for developing static web sites in Smalltalk?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-06 11:27:46
What would be good (cross Smalltalk, mantained, documented) web frameworks or packages (in terms of fewer things to learn/adapt) to use for implementing a static web site with really few forms? .i.e. : a search box and a contact form. I have no "model" or application behind, so I'm not searching for CMS or web application capabilities. There is any example or simple script of a static web site developed in any web frameworks? please I'm NOT interested in counter or 'Hello World' examples. The examples I've seen from Seaside looks too complicated, too many nested blocks with the "programmatic