[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-smalltalk] DLD Usage
From: |
Jean-Marc Farinas |
Subject: |
[Help-smalltalk] DLD Usage |
Date: |
Thu, 31 Jan 2008 22:51:55 -0500 |
Hi,
There is a utility named gtk-server (http://www.gtk-server.org) wich
offers a stream-oriented interface to the GTK library. The stream
interface is easily implemented in GNU smalltalk, but there is also a
shared library version which provide a simple function
('char* gtk(char*)').
I've tried to implement this kind of interface with DLD and
CFunctionDescriptor classes.
When I'm calling the gtk function, it access the library but cannot
recover the returned char*.
Here is the script:
"
======================================================================
This is a template of gtk-server usage as a library
======================================================================
"
Object subclass: GtkServer [
| type |
<comment: 'I implement access to gtk server library'>
<category: 'GUI'>
<shape: #inherit>
"Class Variables"
gtkFuncP := nil.
"Class Methods"
GtkServer class >> new [
<category: 'instance creation'>
|r|
r := super new.
DLD addLibrary: 'libgtk-server.so'.
"
In this library there is a function '' char* gtk(char*) '' wich gives
access to whatever function as specified in the configuration file.
"
DLD defineExternFunc: 'gtk'.
gtkFuncP := CFunctionDescriptor for: 'gtk'
returning: #string
withArgs: #(#string).
gtkFuncP printNl.
^r init
]
init [
type = 'lib'.
^self.
]
type [
^ type
]
type: aType [
type := aType
]
call: aString [
| result |
">>>> This is where the returned value is always 'nil' and it "
^gtkFuncP callInto: result.
">>>> should be a string"
]
]
"Now try to make a new gtk-server instance (taken from perl example in
gtk server source tree)"
Eval [
| win |
WS := GtkServer new.
WS call: 'gtk_init NULL NULL'.
win := WS call: 'gtk_window_new 0'.
"win variable is not instanciated to window descriptor"
win printNl.
WS call: 'gtk_window_set_title ' , win , 'GST window'.
WS call: 'gtk_window_set_default_size ', win, '400 200'.
WS call: 'gtk_window_set_position ' ,win, '1'.
WS call: 'gtk_widget_show_all ', win.
WS call: 'gtk_server_callback wait'.
]
Do i miss something when the C function descriptor is build ?
Jean-Marc
- [Help-smalltalk] DLD Usage,
Jean-Marc Farinas <=