Skip to content

Commit

Permalink
4-strprim/makestr.scm works for python
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriano committed Jun 7, 2012
1 parent 443f324 commit 7ff58d9
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
36 changes: 35 additions & 1 deletion gsc/_t-univ.scm
Expand Up @@ -853,6 +853,7 @@ EOF
#<<EOF #<<EOF
#! /usr/bin/python #! /usr/bin/python


from array import array
import ctypes import ctypes


glo = {} glo = {}
Expand All @@ -863,6 +864,32 @@ nargs = 0
temp1 = False temp1 = False
temp2 = False temp2 = False


#
# String
#
class String:
def __init__ ( self, *args ):
self.chars = array('u', list(args))

def stringset ( self, n, c ):
self.chars[n] = c

def stringref ( self, n ):
return self.chars[n]

def __len__ ( self ):
return len(self.chars)

def __str__ ( self ):
return "".join(self.chars)

def makestring ( n, c ):
args = [unicode(c)]*n
return String(*args)

def stringp ( s ):
return isinstance(s, String)



def lbl1_println(): # println def lbl1_println(): # println
global glo, reg, stack, sp, nargs, temp1, temp2 global glo, reg, stack, sp, nargs, temp1, temp2
Expand Down Expand Up @@ -1586,7 +1613,14 @@ EOF
(translate-gvm-opnd ctx (list-ref opnds 1)) (translate-gvm-opnd ctx (list-ref opnds 1))
")")) ")"))


((python ruby php) ;TODO: complete ((python)
(gen "makestring("
(translate-gvm-opnd ctx (list-ref opnds 0))
", unicode(chr("
(translate-gvm-opnd ctx (list-ref opnds 1))
")))"))

((ruby php) ;TODO: complete
(gen "")) (gen ""))


(else (else
Expand Down
4 changes: 2 additions & 2 deletions include/stamp.h
Expand Up @@ -2,5 +2,5 @@
* Time stamp of last source code repository commit. * Time stamp of last source code repository commit.
*/ */


#define ___STAMP_YMD 20120606 #define ___STAMP_YMD 20120607
#define ___STAMP_HMS 221116 #define ___STAMP_HMS 3514

0 comments on commit 7ff58d9

Please sign in to comment.