summaryrefslogtreecommitdiff
path: root/scripting/v8_utils.h
blob: bcbf54f6f2bc538ad8ab9f5adcc7a6151c15b57e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// v8_utils.h

#pragma once

#include <v8.h>

#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <assert.h>
#include <iostream>

namespace mongo {

    // Executes a string within the current v8 context.
    bool ExecuteString(v8::Handle<v8::String> source,
                       v8::Handle<v8::Value> name,
                       bool print_result,
                       bool report_exceptions);
    
    v8::Handle<v8::Value> Print(const v8::Arguments& args);
    void ReportException(v8::TryCatch* handler);
    
    
    void installShellUtils( v8::Handle<v8::ObjectTemplate>& global );
    
#define jsassert(x,msg) assert(x)
    
    std::ostream& operator<<( std::ostream &s, const v8::Handle<v8::Value> & o );
    std::ostream& operator<<( std::ostream &s, const v8::Handle<v8::TryCatch> * try_catch );
    std::string toSTLString( const v8::Handle<v8::Value> & o );

}