コード例 #1
0
ファイル: context.py プロジェクト: heston/v8-cffi
    def __enter__(self):
        """
        Instantiate string_ptr and len_ptr
        """
        assert self.string_ptr is None
        assert self.len_ptr is None

        self.string_ptr = ffi.new('char **')
        self.string_ptr[0] = ffi.NULL
        self.len_ptr = ffi.new('size_t *', 0)

        return self
コード例 #2
0
    def __enter__(self):
        """
        Instantiate string_ptr and len_ptr
        """
        assert self.string_ptr is None
        assert self.len_ptr is None

        self.string_ptr = ffi.new('char **')
        self.string_ptr[0] = ffi.NULL
        self.len_ptr = ffi.new('size_t *', 0)

        return self
コード例 #3
0
ファイル: context.py プロジェクト: heston/v8-cffi
    def __enter__(self):
        """
        See :py:func:`set_up` method for docs
        """
        assert self._c_context is None
        assert self._vm.is_alive()

        self._c_context = ffi.new('v8cffi_context_t **')
        self._c_context[0] = ffi.NULL
        code = lib.v8cffi_context_new(self._c_context, self._vm.get_c_vm()[0])

        if code != lib.E_V8_OK:
            raise exceptions.get_exception(code)

        return self
コード例 #4
0
ファイル: vm.py プロジェクト: yaaminu/v8-cffi
    def __enter__(self):
        """
        See :py:func:`set_up` method for docs
        """
        assert not self.is_alive()
        assert self._platform.is_alive()

        self._c_vm = ffi.new('v8cffi_vm_t **')
        self._c_vm[0] = ffi.NULL
        code = lib.v8cffi_vm_new(self._c_vm)

        if code != lib.E_V8_OK:
            raise exceptions.get_exception(code)

        return self
コード例 #5
0
    def __enter__(self):
        """
        See :py:func:`set_up` method for docs
        """
        assert self._c_context is None
        assert self._vm.is_alive()

        self._c_context = ffi.new('v8cffi_context_t **')
        self._c_context[0] = ffi.NULL
        code = lib.v8cffi_context_new(self._c_context, self._vm.get_c_vm()[0])

        if code != lib.E_V8_OK:
            raise exceptions.get_exception(code)

        return self
コード例 #6
0
ファイル: vm.py プロジェクト: heston/v8-cffi
    def __enter__(self):
        """
        See :py:func:`set_up` method for docs
        """
        assert not self.is_alive()
        assert self._platform.is_alive()

        self._c_vm = ffi.new('v8cffi_vm_t **')
        self._c_vm[0] = ffi.NULL
        code = lib.v8cffi_vm_new(self._c_vm)

        if code != lib.E_V8_OK:
            raise exceptions.get_exception(code)

        return self
コード例 #7
0
    def __enter__(self):
        """
        See :py:func:`set_up` method for docs
        """
        assert not self.is_alive()
        assert not self._is_dead

        self._c_platform = ffi.new(
            'v8cffi_platform_t **')  # initialized to NULL ?
        self._c_platform[0] = ffi.NULL
        natives_blob = _read_file(self.natives_path)
        snapshot_blob = _read_file(self.snapshot_path)
        code = lib.v8cffi_platform_new(self._c_platform, natives_blob,
                                       len(natives_blob), snapshot_blob,
                                       len(snapshot_blob))

        if code != lib.E_V8_OK:
            raise exceptions.get_exception(code)

        return self
コード例 #8
0
ファイル: platform.py プロジェクト: theatlantic/v8-cffi
    def __enter__(self):
        """
        See :py:func:`set_up` method for docs
        """
        assert not self.is_alive()
        assert not self._is_dead

        self._c_platform = ffi.new('v8cffi_platform_t **')  # initialized to NULL ?
        self._c_platform[0] = ffi.NULL
        natives_blob = _read_file(self.natives_path)
        snapshot_blob = _read_file(self.snapshot_path)
        code = lib.v8cffi_platform_new(
            self._c_platform,
            natives_blob,
            len(natives_blob),
            snapshot_blob,
            len(snapshot_blob))

        if code != lib.E_V8_OK:
            raise exceptions.get_exception(code)

        return self