Exemplo n.º 1
0
def _set_timezone(interp, this, w_value):
    pass


def _set_timezone_type(interp, this, w_value):
    pass


space = getspace()

k_DateTime = def_class('DateTime', [
    construct, format, modify, get_timestamp, set_timestamp, get_timezone,
    set_date, set_iso_date, set_time, set_timezone, create_from_format,
    get_last_errors, sub, add, diff, get_offset
], [
    GetterSetterWrapper(_get_date, _set_date, "date", consts.ACC_PUBLIC),
    GetterSetterWrapper(_get_timezone_type, _set_timezone_type,
                        "timezone_type", consts.ACC_PUBLIC),
    GetterSetterWrapper(_get_timezone, _set_timezone, "timezone",
                        consts.ACC_PUBLIC)
], [('ATOM', space.wrap("Y-m-d\TH:i:sP")),
    ('COOKIE', space.wrap("l, d-M-y H:i:s T")),
    ('ISO8601', space.wrap("Y-m-d\TH:i:sO")),
    ('RFC822', space.wrap("D, d M y H:i:s O")),
    ('RFC850', space.wrap("l, d-M-y H:i:s T")),
    ('RFC1036', space.wrap("D, d M y H:i:s O")),
    ('RFC1123', space.wrap("D, d M Y H:i:s O")),
    ('RFC2822', space.wrap("D, d M Y H:i:s O")),
    ('RFC3339', space.wrap("Y-m-d\TH:i:sP")),
    ('RSS', space.wrap("D, d M Y H:i:s O")),
    ('W3C', space.wrap("Y-m-d\TH:i:sP"))],
Exemplo n.º 2
0
@wrap_method(['interp', ThisUnwrapper(W_ReflectionFunctionAbstract)],
             name='ReflectionFunctionAbstract::getName')
def get_name(interp, this):
    return _get_name(interp, this)


def _get_class(interp, this):
    return interp.space.wrap(this.ref_klass.name)


def _set_class(interp, this, w_value):
    pass


def _get_name(interp, this):
    return interp.space.wrap(this.ref_method.get_name())


def _set_name(interp, this, w_value):
    pass


ReflectionFunctionAbstract = def_class(
    'ReflectionFunctionAbstract', [get_name], [
        GetterSetterWrapper(_get_class, _set_class, "class",
                            consts.ACC_PUBLIC),
        GetterSetterWrapper(_get_name, _set_name, "name", consts.ACC_PUBLIC)
    ], [],
    flags=consts.ACC_ABSTRACT,
    instance_class=W_ReflectionFunctionAbstract)
Exemplo n.º 3
0
    if not w_dir.is_valid():
        interp.warn(
            "Directory::rewind(): %d is not a valid Directory resource" %
            w_dir.res_id)
        return interp.space.w_False

    else:
        w_dir.rewind()
        return interp.space.w_Null


@wrap_method([
    'interp',
    ThisUnwrapper(W_Directory),
    Optional(Resource(W_DirResource, True))
],
             name='Directory::close')
def dir_close(interp, this, w_dir=None):
    if not w_dir:
        w_dir = this.handle
    assert isinstance(w_dir, W_DirResource)
    w_dir.close()
    return interp.space.w_Null


k_Directory = def_class('Directory', [dir_read, dir_rewind, dir_close], [
    GetterSetterWrapper(_get_path, _set_path, "path", consts.ACC_PUBLIC),
    GetterSetterWrapper(_get_handle, _set_handle, "handle", consts.ACC_PUBLIC)
],
                        instance_class=W_Directory)
Exemplo n.º 4
0

def _get_name(interp, this):
    return interp.space.newstr(this.name)


def _set_name(interp, this, w_value):
    pass


k_ReflectionProperty = def_class('ReflectionProperty', [
    'export', '__construct', 'getName', 'getValue', 'setValue',
    'getDeclaringClass', "isPublic", "isPrivate", "isProtected", "isStatic",
    "isDefault", "getModifiers", "__toString"
], [
    GetterSetterWrapper(_get_name, _set_name, 'name', consts.ACC_PUBLIC),
    GetterSetterWrapper(_get_class, _set_class, 'class', consts.ACC_PUBLIC)
], [('IS_STATIC', W_IntObject(IS_STATIC)),
    ('IS_PUBLIC', W_IntObject(IS_PUBLIC)),
    ('IS_PROTECTED', W_IntObject(IS_PROTECTED)),
    ('IS_PRIVATE', W_IntObject(IS_PRIVATE))],
                                 instance_class=W_ReflectionProperty)


@k_ReflectionProperty.def_method(
    ['interp', W_Root, str, Optional(bool)], flags=consts.ACC_STATIC)
def export(interp, w_klass, name, return_string=False):
    refl = k_ReflectionProperty.call_args(
        interp, [w_klass, interp.space.wrap(name)])
    result = refl.get_str()
    if return_string:
Exemplo n.º 5
0
    return this.ref_fun.get_name()


@wrap_method(['interp', ThisUnwrapper(W_ReflectionFunction)],
             name='ReflectionFunction::getParameters')
def get_parameters(interp, this):
    return this.ref_fun.get_parameters()


@wrap_method(['interp', ThisUnwrapper(W_ReflectionFunction)],
             name='ReflectionFunction::getDocComment')
def get_doc_comment(interp, this):
    return interp.space.wrap("")


def _get_name(interp, this):
    return this.ref_fun.get_name()


def _set_name(interp, this, w_value):
    pass


def_class(
    'ReflectionFunction',
    [construct, get_name, get_doc_comment, get_parameters],
    [GetterSetterWrapper(_get_name, _set_name, "name", consts.ACC_PUBLIC)],
    [('IS_DEPRECATED', W_IntObject(IS_DEPRECATED))],
    instance_class=W_ReflectionFunction,
    extends=ReflectionFunctionAbstract)
Exemplo n.º 6
0
             get_perms,
             get_size,
             get_type,
             is_dir,
             is_link,
             is_executable,
             is_file,
             is_readable,
             is_writable,
             getatime,
             getctime,
             getmtime,
             get_realpath,
             get_linktarget,
             openfile],
    properties=[GetterSetterWrapper(_get_pathname, _set_pathname,
                                    "pathName", consts.ACC_PRIVATE),
                GetterSetterWrapper(_get_filename, _set_filename,
                                    "fileName", consts.ACC_PRIVATE), ],
        instance_class=W_SplFileInfo
        )


SFO_DROP_NEW_LINE = 1
SFO_READ_AHEAD = 2
SFO_SKIP_EMPTY = 4
SFO_READ_CSV = 8


def _sfo_readline(interp, sfo):
    if sfo.open_mode not in ('w', 'a', 'x', 'c'):
        return sfo.w_res.readline(sfo.flags & SFO_DROP_NEW_LINE)
Exemplo n.º 7
0
class W_ArrayIterator(W_SplArray):
    _iter = None

def _get_storage(interp, this):
    return this.w_arr

def _set_storage(interp, this, w_arr):
    raise NotImplementedError


k_ArrayObject = def_class(
    'ArrayObject',
    ['__construct', 'offsetExists', 'offsetGet', 'offsetSet', 'offsetUnset',
     'append', 'count',
     'getIterator'],
    [GetterSetterWrapper(_get_storage, _set_storage, 'storage', consts.ACC_PRIVATE)],
    instance_class=W_SplArray,
    implements=[k_IteratorAggregate, k_ArrayAccess])


k_ArrayIterator = def_class(
    'ArrayIterator',
    ['__construct', 'offsetExists', 'offsetGet', 'offsetSet', 'offsetUnset',
     'append', 'count',
     'current', 'next', 'key', 'rewind', 'valid'],
    [GetterSetterWrapper(_get_storage, _set_storage, 'storage', consts.ACC_PRIVATE)],
    instance_class=W_ArrayIterator,
    implements=[k_ArrayAccess, k_Iterator])


@k_ArrayObject.def_method(['interp', 'this', Optional(W_Root), Optional(int),
Exemplo n.º 8
0
def get_have_special_relative(interp, this):
    return interp.space.wrap(intmask(this.time_diff.c_have_special_relative))

def set_have_special_relative(interp, this, value):
    raise NotImplementedError("bogus cast!")
    this.time_diff.c_have_special_relative = rffi.cast(rffi.UINT, value)


k_DateInterval = def_class(
    'DateInterval',

    [construct,
     create_from_date_string,
     format],

    [GetterSetterWrapper(get_y, set_y,
                         "y", consts.ACC_PUBLIC),
     GetterSetterWrapper(get_m, set_m,
                         "m", consts.ACC_PUBLIC),
     GetterSetterWrapper(get_d, set_d,
                         "d", consts.ACC_PUBLIC),
     GetterSetterWrapper(get_h, set_h,
                         "h", consts.ACC_PUBLIC),
     GetterSetterWrapper(get_i, set_i,
                         "i", consts.ACC_PUBLIC),
     GetterSetterWrapper(get_s, set_s,
                         "s", consts.ACC_PUBLIC),
     GetterSetterWrapper(get_weekday, set_weekday,
                         "weekday", consts.ACC_PUBLIC),
     GetterSetterWrapper(get_weekday_behavior, set_weekday_behavior,
                         "weekday_behavior", consts.ACC_PUBLIC),
     GetterSetterWrapper(get_first_last_day_of, set_first_last_day_of,