Created
August 11, 2010 23:46
-
-
Save rofl0r/520029 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
XString: class { | |
data : Char* | |
size : SizeT | |
init: func (src: Char*, =size) { | |
data = gc_malloc(size) | |
memcpy (data, src, size) | |
} | |
equals?: func -> Bool { false } | |
} | |
operator implicit as (s: XString) -> Char* { | |
s data | |
} | |
operator implicit as (c: Char*) -> XString { | |
XString new (c, strlen(c)) | |
} | |
operator [] (string: XString, index: SizeT) -> Char { | |
( string data + index )@ | |
} | |
operator []= (string: XString, index: SizeT, value: Char) { | |
(string data + index)@ = value | |
} | |
main: func { | |
x := XString new ( "xxxx" as Char*, 4) | |
x[1] = 'y' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment