示例#1
0
文件: stdlib.py 项目: fetus-hina/pyhp
def str_repeat(args):
    string = args[0]
    repeat = args[1]
    assert(isstr(string))
    assert(isint(repeat))
    repeated = string.str() * repeat.get_int()
    return W_StringObject(repeated)
示例#2
0
文件: stdlib.py 项目: yaoshaojun/pyhp
def str_repeat(interpreter, space, args):
    string = args[0].get_value()
    repeat = args[1].get_value()
    assert(isstr(string))
    assert(isint(repeat))
    repeated = string.str() * repeat.get_int()
    return space.wrap(repeated)
示例#3
0
文件: stdlib.py 项目: yaoshaojun/pyhp
def printf(interpreter, space, args):
    template = args[0]
    assert(isstr(template))
    items = [arg.get_value() for arg in args[1:]]
    formatter = StringFormatter(template.str(), items)
    interpreter.output(formatter.format())
    return space.w_Null
示例#4
0
文件: stdlib.py 项目: codewizz/pyhp
def printf(space, args):
    template = args[0]
    assert(isstr(template))
    items = [arg.get_value() for arg in args[1:]]
    formatter = StringFormatter(template.str(), items)
    printf_(formatter.format())
    return w_Null
示例#5
0
文件: stdlib.py 项目: codewizz/pyhp
def str_repeat(space, args):
    string = args[0].get_value()
    repeat = args[1].get_value()
    assert(isstr(string))
    assert(isint(repeat))
    repeated = string.str() * repeat.get_int()
    return newstring(repeated)
示例#6
0
文件: stdlib.py 项目: yaoshaojun/pyhp
def define(interpreter, space, args):
    name = args[0].get_value()
    assert(isstr(name))
    value = args[1].get_value()

    if space.get_constant(name.str()):
        return space.w_False

    space.declare_constant(name.str(), value)
    return space.w_True
示例#7
0
文件: stdlib.py 项目: fetus-hina/pyhp
def strlen(args):
    string = args[0]
    assert(isstr(string))
    return W_IntObject(string.len())
示例#8
0
文件: stdlib.py 项目: yaoshaojun/pyhp
def strlen(interpreter, space, args):
    string = args[0].get_value()
    assert(isstr(string))
    return space.wrap(string.len())
示例#9
0
文件: stdlib.py 项目: codewizz/pyhp
def strlen(space, args):
    string = args[0].get_value()
    assert(isstr(string))
    return newint(string.len())
示例#10
0
文件: stdlib.py 项目: codewizz/pyhp
def define(space, args):
    name = args[0].get_value()
    assert(isstr(name))
    value = args[1].get_value()
    return newbool(space.declare_constant(name.str(), value))