Skip to content
This repository
Browse code

4-strprim/makestr.scm works for python

  • Loading branch information...
commit 7ff58d91ea2b9e7e4d13aa92461a0d728295be84 1 parent 443f324
Gabriano Gabriano authored

Showing 2 changed files with 37 additions and 3 deletions. Show diff stats Hide diff stats

  1. +35 1 gsc/_t-univ.scm
  2. +2 2 include/stamp.h
36 gsc/_t-univ.scm
@@ -853,6 +853,7 @@ EOF
853 853 #<<EOF
854 854 #! /usr/bin/python
855 855
  856 +from array import array
856 857 import ctypes
857 858
858 859 glo = {}
@@ -863,6 +864,32 @@ nargs = 0
863 864 temp1 = False
864 865 temp2 = False
865 866
  867 +#
  868 +# String
  869 +#
  870 +class String:
  871 + def __init__ ( self, *args ):
  872 + self.chars = array('u', list(args))
  873 +
  874 + def stringset ( self, n, c ):
  875 + self.chars[n] = c
  876 +
  877 + def stringref ( self, n ):
  878 + return self.chars[n]
  879 +
  880 + def __len__ ( self ):
  881 + return len(self.chars)
  882 +
  883 + def __str__ ( self ):
  884 + return "".join(self.chars)
  885 +
  886 +def makestring ( n, c ):
  887 + args = [unicode(c)]*n
  888 + return String(*args)
  889 +
  890 +def stringp ( s ):
  891 + return isinstance(s, String)
  892 +
866 893
867 894 def lbl1_println(): # println
868 895 global glo, reg, stack, sp, nargs, temp1, temp2
@@ -1586,7 +1613,14 @@ EOF
1586 1613 (translate-gvm-opnd ctx (list-ref opnds 1))
1587 1614 ")"))
1588 1615
1589   - ((python ruby php) ;TODO: complete
  1616 + ((python)
  1617 + (gen "makestring("
  1618 + (translate-gvm-opnd ctx (list-ref opnds 0))
  1619 + ", unicode(chr("
  1620 + (translate-gvm-opnd ctx (list-ref opnds 1))
  1621 + ")))"))
  1622 +
  1623 + ((ruby php) ;TODO: complete
1590 1624 (gen ""))
1591 1625
1592 1626 (else
4 include/stamp.h
@@ -2,5 +2,5 @@
2 2 * Time stamp of last source code repository commit.
3 3 */
4 4
5   -#define ___STAMP_YMD 20120606
6   -#define ___STAMP_HMS 221116
  5 +#define ___STAMP_YMD 20120607
  6 +#define ___STAMP_HMS 3514

0 comments on commit 7ff58d9

Please sign in to comment.
Something went wrong with that request. Please try again.