Skip to content

File context.h

File List > jac > machine > context.h

Go to the documentation of this file

#pragma once

#include <quickjs.h>

#include "internal/declarations.h"


namespace jac {


class ContextRef {
    JSContext* _ctx;

public:
    ContextRef(JSContext* ctx) : _ctx(ctx) {}

    JSContext* get() { return _ctx; }

    Exception getException();

    Object getGlobalObject();

    operator JSContext*() { return _ctx; }
    operator JSContext*() const { return _ctx; }
    operator bool() { return _ctx != nullptr; }
    ContextRef& operator=(JSContext* ctx) { _ctx = ctx; return *this; }
};


}  // namespace jac