2018-06-09 18:32:04 -04:00
|
|
|
// Copyright 2018 Ryan Dahl <ry@tinyclouds.org>
|
|
|
|
// All rights reserved. MIT License.
|
2018-06-09 22:55:31 -04:00
|
|
|
#ifndef INCLUDE_DENO_H_
|
|
|
|
#define INCLUDE_DENO_H_
|
2018-06-10 08:18:15 -04:00
|
|
|
// Neither Rust nor Go support calling directly into C++ functions, therefore
|
|
|
|
// the public interface to libdeno is done in C.
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2018-06-09 20:24:34 -04:00
|
|
|
|
2018-06-09 18:32:04 -04:00
|
|
|
// Data that gets transmitted.
|
2018-06-10 08:18:15 -04:00
|
|
|
typedef struct {
|
2018-06-09 18:32:04 -04:00
|
|
|
void* data;
|
|
|
|
size_t len;
|
2018-06-10 08:18:15 -04:00
|
|
|
} deno_buf;
|
2018-06-09 21:44:56 -04:00
|
|
|
|
2018-06-09 18:32:04 -04:00
|
|
|
struct deno_s;
|
|
|
|
typedef struct deno_s Deno;
|
2018-06-09 21:44:56 -04:00
|
|
|
|
2018-06-09 18:32:04 -04:00
|
|
|
// The callback from V8 when data is sent.
|
2018-06-10 08:18:15 -04:00
|
|
|
typedef deno_buf (*RecvCallback)(Deno* d, deno_buf buf);
|
2018-06-09 18:32:04 -04:00
|
|
|
|
2018-06-10 08:18:15 -04:00
|
|
|
void deno_init();
|
2018-06-09 18:32:04 -04:00
|
|
|
const char* v8_version();
|
|
|
|
void v8_set_flags(int* argc, char** argv);
|
|
|
|
|
2018-06-10 08:18:15 -04:00
|
|
|
// Constructor
|
|
|
|
Deno* deno_new(void* data, RecvCallback cb);
|
2018-06-09 18:32:04 -04:00
|
|
|
|
|
|
|
void* deno_get_data();
|
|
|
|
|
|
|
|
// Returns nonzero on error.
|
|
|
|
// Get error text with deno_last_exception().
|
|
|
|
int deno_load(Deno* d, const char* name_s, const char* source_s);
|
|
|
|
|
|
|
|
// Returns nonzero on error.
|
2018-06-10 08:18:15 -04:00
|
|
|
int deno_send(Deno* d, deno_buf buf);
|
2018-06-09 18:32:04 -04:00
|
|
|
|
|
|
|
const char* deno_last_exception(Deno* d);
|
|
|
|
|
|
|
|
void deno_dispose(Deno* d);
|
|
|
|
void deno_terminate_execution(Deno* d);
|
|
|
|
|
2018-06-10 08:18:15 -04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
} // extern "C"
|
|
|
|
#endif
|
2018-06-09 22:55:31 -04:00
|
|
|
#endif // INCLUDE_DENO_H_
|