| |
| /pliant/language/type/text/cchar.pli |
| |
| 1 |
# Copyright (C) 2000 John Eikenberry | |
| 2 |
# | |
| 3 |
# This program is free software; you can redistribute it and/or | |
| 4 |
# modify it under the terms of the GNU General Public License version 2 | |
| 5 |
# as published by the Free Software Foundation. | |
| 6 |
# | |
| 7 |
# This program is distributed in the hope that it will be useful, | |
| 8 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 10 |
# GNU General Public License for more details. | |
| 11 |
# | |
| 12 |
# You should have received a copy of the GNU General Public License | |
| 13 |
# version 2 along with this program; if not, write to the Free Software | |
| 14 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 15 |
| |
| 16 |
scope "/pliant/language/" "/pliant/install/" | |
| 17 |
module "/pliant/install/ring2.pli" | |
| 18 |
| |
| 19 |
type CChar | |
| 20 |
field Int number | |
| 21 |
| |
| 22 |
function 'cast CChar' c -> cc | |
| 23 |
arg Char c ; arg CChar cc | |
| 24 |
implicit | |
| 25 |
cc number := c number | |
| 26 |
| |
| 27 |
function 'cast Char' cc -> c | |
| 28 |
arg CChar cc ; arg Char c | |
| 29 |
implicit | |
| 30 |
c := character cc:number | |
| 31 |
| |
| 32 |
method data 'to string' options -> s | |
| 33 |
arg CChar data ; arg Str options ; arg Str s | |
| 34 |
s set (memory_allocate 1 addressof:s) 1 true | |
| 35 |
s 0 := character data:number | |
| 36 |
| |
| 37 |
# Now change 'number' field to read only | |
| 38 |
gvar Pointer:Int a :> ((the_function '. number' CChar -> Int) arg 1) access | |
| 39 |
a := a .and. .not. access_result_write+access_result_consistent | |
| 40 |
a := a .or. access_result_read | |
| 41 |
| |
| 42 |
export 'CChar' '. number' 'cast CChar' 'cast Char' | |
| |