Hello, world.
Hello again.
import { } from "node"; // have to do this for some legacy Node reason I don't understand | |
Object.defineProperties(Array.prototype, { | |
takeWhile: { | |
configurable: true, | |
writable: true, | |
enumerable: false, | |
value: function() { /* ... */ } | |
}, | |
dropWhile: { |
declare_types! { | |
/// A simple native class for creating greeting strings. | |
pub class JsGreeter for Greeter { | |
init(greeting: String) { | |
Greeter { | |
greeting: greeting | |
} | |
} | |
call(self) -> f64 { |
#[doc(hidden)] | |
#[macro_export] | |
macro_rules! class_definition { | |
( $cls:ident ; $typ: ident ; $allocator:tt ; $mnames:tt ; $mdefs:tt ; init($call:ident) $body:block $($rest:tt)* ) => { | |
fn allocator_definition($call: $crate::vm::FunctionCall<$crate::js::JsUndefined>) -> $crate::vm::VmResult<$typ> { | |
$body | |
} | |
class_definition!($cls ; $typ ; allocator_definition ; $mnames ; $mdefs ; $($rest)*); | |
}; |
#[macro_use] | |
extern crate neon; | |
extern crate neon_sys; | |
use neon::mem::Handle; | |
use neon::vm; | |
use neon::js::{JsFunction, JsString, Value, Object}; | |
use neon::js::class::{JsClass, Class}; | |
struct Greeter { |
I'll use the term branded class to be a class hierarchy with:
Examples: Date
, Array
, Promise
, DOM classes
export default class A { ... } | |
import B from "B"; | |
A.B_INSTANCE = new B(); |
import * as fs from "fs"; | |
var Export = Reflect.Module.Export; | |
var y, TAU; | |
// reflective API takes Export objects to represent each export slot | |
var mod = new Reflect.Module({ | |
// initialized mutable (includes "uninitialized" var) | |
x: Export.var(), |
var addon = require('../native'); | |
console.log(addon.test({ foo: ["bar"] })); |
struct Greeter { | |
greeting: String | |
} | |
#[derive(Copy, Clone)] | |
struct JsGreeter(raw::Local); | |
impl Managed for JsGreeter { | |
fn to_raw(self) -> raw::Local { | |
let JsGreeter(raw) = self; |