def __init__(self, func, klass, storage_w, w_this=None, static=False): assert isinstance(func, Function) self._func = func self.closure_args = [None] * len(func.closuredecls) W_InstanceObject.__init__(self, klass, storage_w) self.w_this = w_this self.static = static
def parse_single(space, i, lines): line = lines[i].strip() #ignore byref markers in arrays/objects if line.startswith('&'): line = line[1:] if line.startswith('int'): return space.wrap(int(line[len('int('):-1])), i + 1 elif line.startswith('bool'): return space.wrap(line[len('bool('):-1] == 'true'), i + 1 if line.startswith('float'): return space.wrap(float(line[len('float('):-1])), i + 1 elif line == 'NULL': return space.w_Null, i + 1 elif line.startswith('array'): lgt = int(line[len('array') + 1:line.find(')')]) pairs, i = parse_array(space, i + 1, lines, lgt) return space.new_array_from_pairs(pairs), i elif line.startswith('string'): lgt = int(line[len('string') + 1:line.find(')')]) return space.newstr(line[line.find('"') + 1:-1]), i + 1 elif line.startswith('object('): lgt = int(line[line.rfind('(') + 1:line.rfind(')')]) clsname = line[len('object('):line.index(')')] pairs, i = parse_array(space, i + 1, lines, lgt) obj = W_InstanceObject(FakeClass(clsname), []) for w_name, w_value in pairs: obj._create_attr(space.str_w(w_name), w_value) return obj, i else: raise Exception("unsupported line %s" % line)
def create_instance(self, interp, storage_w): if self.custom_instance_class is not None: w_res = self.custom_instance_class(self, storage_w) w_res.setup(interp) else: w_res = W_InstanceObject(self, storage_w) return w_res
def parse_single(space, i, lines): line = lines[i].strip() #ignore byref markers in arrays/objects if line.startswith('&'): line = line[1:] if line.startswith('int'): return space.wrap(int(line[len('int('):-1])), i + 1 elif line.startswith('bool'): return space.wrap(line[len('bool('):-1] == 'true'), i + 1 if line.startswith('float'): return space.wrap(float(line[len('float('):-1])), i + 1 elif line == 'NULL': return space.w_Null, i + 1 elif line.startswith('array'): lgt = int(line[len('array') + 1:line.find(')')]) return parse_array(space, i + 1, lines, lgt) elif line.startswith('string'): lgt = int(line[len('string') + 1:line.find(')')]) return space.newstr(line[line.find('"') + 1:-1]), i + 1 elif line.startswith('object('): lgt = int(line[line.rfind('(') + 1:line.rfind(')')]) clsname = line[len('object('):line.index(')')] array, i = parse_array(space, i + 1, lines, lgt) obj = W_InstanceObject(FakeClass(clsname), array.as_rdict()) return obj, i else: raise Exception("unsupported line %s" % line)
def clone(self, interp, contextclass): w_res = W_InstanceObject.clone(self, interp, contextclass) w_res.file_name = self.file_name w_res.path_name = self.path_name w_res.delimiter = self.delimiter w_res.enclosure = self.enclosure w_res.open_mode = self.open_mode return w_res
def clone(self, interp, contextclass): w_res = W_InstanceObject.clone(self, interp, contextclass) assert isinstance(w_res, W_RecursiveDirectoryIterator) w_res.path_name = self.path_name w_res.w_dir_res = self.w_dir_res w_res.flags = self.flags w_res.path = self.path return w_res
def clone(self, interp, contextclass): w_res = W_InstanceObject.clone(self, interp, contextclass) assert isinstance(w_res, W_SplFileObject) w_res.file_name = self.file_name w_res.path_name = self.path_name w_res.delimiter = self.delimiter w_res.enclosure = self.enclosure w_res.open_mode = self.open_mode return w_res
def clone(self, interp, contextclass): from hippy.module.date.common import TimeZoneWrapper w_res = W_InstanceObject.clone(self, interp, contextclass) w_datetimezone = W_InstanceObject.clone(self.w_datetimezone, interp, contextclass) assert isinstance(w_res, W_DateTime) assert isinstance(w_datetimezone, W_DateTimeZone) w_datetimezone.timelib_timezone = timelib.timelib_tzinfo_clone( self.w_datetimezone.timezone_info.timelib_timezone ) w_datetimezone.timezone_info = TimeZoneWrapper(w_datetimezone.timelib_timezone, 3) w_res.w_datetimezone = w_datetimezone w_res.timelib_time = timelib.timelib_time_clone(self.timelib_time) return w_res
def clone(self, interp, contextclass): from hippy.module.date.common import TimeZoneWrapper w_res = W_InstanceObject.clone(self, interp, contextclass) w_datetimezone = W_InstanceObject.clone(self.w_datetimezone, interp, contextclass) assert isinstance(w_res, W_DateTime) assert isinstance(w_datetimezone, W_DateTimeZone) w_datetimezone.timelib_timezone = timelib.timelib_tzinfo_clone( self.w_datetimezone.timezone_info.timelib_timezone) w_datetimezone.timezone_info = TimeZoneWrapper( w_datetimezone.timelib_timezone, 3) w_res.w_datetimezone = w_datetimezone w_res.timelib_time = timelib.timelib_time_clone(self.timelib_time) return w_res
def __init__(self, klass, dct_w): W_InstanceObject.__init__(self, klass, dct_w)
def clone(self, interp, contextclass): w_res = W_InstanceObject.clone(self, interp, contextclass) w_res.file_name = self.file_name w_res.path_name = self.path_name return w_res
def __init__(self, func, klass, dct_w): assert isinstance(func, Function) self._func = func self.closure_args = [None] * (len(func.names) - len(func.types)) W_InstanceObject.__init__(self, klass, dct_w)
def clone(self, interp, contextclass): w_res = W_InstanceObject.clone(self, interp, contextclass) w_res.timelib_time = timelib.timelib_time_clone(self.timelib_time) return w_res
def clone(self, interp, contextclass): w_res = W_InstanceObject.clone(self, interp, contextclass) assert isinstance(w_res, W_SplFileInfo) w_res.file_name = self.file_name w_res.path_name = self.path_name return w_res
def getmeth(self, space, name, contextclass=None): if name.lower() == "__invoke": return self.get_callable() return W_InstanceObject.getmeth(self, space, name, contextclass)