diff options
author | Philipp Hagemeister <[email protected]> | 2014-07-20 14:49:10 +0200 |
---|---|---|
committer | Philipp Hagemeister <[email protected]> | 2014-07-20 14:49:10 +0200 |
commit | 0d989011fffd768116d0ca81f6c067c7e0876f36 (patch) | |
tree | 00f000b4f7b0c789b95102db0de0576e4015a683 /youtube_dl | |
parent | 01b4b745749bb92b4a56b4201d699740cbf450ab (diff) | |
download | youtube-dl-0d989011fffd768116d0ca81f6c067c7e0876f36.tar.gz youtube-dl-0d989011fffd768116d0ca81f6c067c7e0876f36.zip |
[swfinterp] Add support for calling methods on objects
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/swfinterp.py | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/youtube_dl/swfinterp.py b/youtube_dl/swfinterp.py index 8ccb64c9d..d043c2f99 100644 --- a/youtube_dl/swfinterp.py +++ b/youtube_dl/swfinterp.py @@ -50,6 +50,17 @@ class _AVMClass_Object(object): return '%s#%x' % (self.avm_class.name, id(self)) +class _ScopeDict(dict): + def __init__(self, avm_class): + super(_ScopeDict, self).__init__() + self.avm_class = avm_class + + def __repr__(self): + return '%s__Scope(%s)' % ( + self.avm_class.name, + super(_ScopeDict, self).__repr__()) + + class _AVMClass(object): def __init__(self, name_idx, name): self.name_idx = name_idx @@ -59,17 +70,7 @@ class _AVMClass(object): self.methods = {} self.method_pyfunctions = {} - class ScopeDict(dict): - def __init__(self, avm_class): - super(ScopeDict, self).__init__() - self.avm_class = avm_class - - def __repr__(self): - return '%s__Scope(%s)' % ( - self.avm_class.name, - super(ScopeDict, self).__repr__()) - - self.variables = ScopeDict(self) + self.variables = _ScopeDict(self) def make_object(self): return _AVMClass_Object(self) @@ -411,6 +412,14 @@ class SWFInterpreter(object): res = func(args) stack.append(res) continue + elif isinstance(obj, _ScopeDict): + if mname in obj.avm_class.method_names: + func = self.extract_function(obj.avm_class, mname) + res = func(args) + else: + res = obj[mname] + stack.append(res) + continue elif isinstance(obj, compat_str): if mname == 'split': assert len(args) == 1 |