base.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:FMoviesPlus.bundle 作者: coder-alpha 项目源码 文件源码
def __init__(self, func, prototype=None, extensible=True, source=None):
        cand = fix_js_args(func)
        has_scope = cand is func
        func = cand
        self.argcount = six.get_function_code(func).co_argcount - 2 - has_scope
        self.code = func
        self.source = source if source else '{ [python code] }'
        self.func_name = func.__name__ if not func.__name__.startswith('PyJs_anonymous') else ''
        self.extensible = extensible
        self.prototype = prototype
        self.own = {}
        #set own property length to the number of arguments
        self.define_own_property('length', {'value': Js(self.argcount), 'writable': False,
                                            'enumerable': False, 'configurable': False})

        if self.func_name:
            self.define_own_property('name', {'value': Js(self.func_name), 'writable': False,
                                            'enumerable': False, 'configurable': True})

        # set own prototype
        proto = Js({})
        # constructor points to this function
        proto.define_own_property('constructor',{'value': self, 'writable': True,
                                                 'enumerable': False, 'configurable': True})
        self.define_own_property('prototype', {'value': proto, 'writable': True,
                                                 'enumerable': False, 'configurable': False})
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号