Skip to content

Instantly share code, notes, and snippets.

@michaelwu
michaelwu / bindings.js
Last active December 3, 2015 00:39
Self hosted TS
/// <reference path="selfhosted.d.ts"/>
// Integer conversions
function WebidlEnforceRange(val, min, max) {
var num = ToNumber(val);
if (!Number_isFinite(num))
ThrowTypeError("Value isn't finite!");
if (val < 0)
num = -std_Math_floor(std_Math_abs(num));
else
num = std_Math_floor(std_Math_abs(num));
@michaelwu
michaelwu / jsapi.rs
Last active September 18, 2015 22:13
jsapi.rs (09/18/2015)
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(raw_pointer_derive)]
#![feature(const_fn)]
#![feature(libc)]
extern crate libc;
use libc::{size_t, intptr_t, uintptr_t, ptrdiff_t, FILE};
use std::marker::PhantomData;
@michaelwu
michaelwu / jsapi.rs
Created September 14, 2015 19:11
jsapi.rs (link_name)
/* automatically generated by rust-bindgen */
/**
* Helper class used as a base for various type traits, exposed publicly
* because <type_traits> exposes it as well.
*/#[repr(C)]
#[derive(Copy)]
pub struct IntegralConstant<T>;
pub type TrueType = IntegralConstant;
pub type FalseType = IntegralConstant;
@michaelwu
michaelwu / magic.rs
Created August 31, 2015 19:49
Magic plugin output
// Before
#![feature(plugin)]
#![feature(associated_consts)]
#![feature(custom_attribute)]
#![feature(trace_macros)]
#![plugin(plugins)]
trace_macros!(true);
@michaelwu
michaelwu / jsapi.rs
Created July 23, 2015 21:35
jsapi.rs (char fixed)
This file has been truncated, but you can view the full file.
/* automatically generated by rust-bindgen */
pub type MallocSizeOf =
::std::option::Option<unsafe extern "C" fn(p: *const ::libc::c_void)
-> size_t>;
pub type MozMallocSizeOf =
::std::option::Option<unsafe extern "C" fn(p: *const ::libc::c_void)
-> size_t>;
/**
/* automatically generated by rust-bindgen */
pub enum nsISupports { }
#[repr(C)]
#[derive(Copy)]
pub struct TabSizes {
pub objects: size_t,
pub strings: size_t,
pub private_: size_t,
pub other: size_t,
// Generated by rust-peg. Do not edit.
#![allow(non_snake_case, unused)]
use self::RuleResult::{Matched, Failed};
fn escape_default(s: &str) -> String {
s.chars().flat_map(|c| c.escape_default()).collect()
}
fn char_range_at(s: &str, pos: usize) -> (char, usize) {
let c = &s[pos..].chars().next().unwrap();
let next_pos = pos + c.len_utf8();
(*c, next_pos)
// http://heycam.github.io/webidl/#idl-grammar
integer
= "-"? [1-9] [0-9]*
/ "-"? "0" [Xx] [0-9A-Fa-f]+
/ "-"? "0" [0-7]*
float
= "-"? significand exponent?
/ "-"? [0-9]+ exponent
@michaelwu
michaelwu / TestBindingBinding.rs
Created May 29, 2015 17:10
TestBindingBinding.rs
/* THIS FILE IS AUTOGENERATED - DO NOT EDIT */
#![allow(unreachable_code,non_camel_case_types,non_upper_case_globals,unused_parens,unused_imports,unused_variables,unused_unsafe,unused_mut,unused_assignments,dead_code)]
use dom::bindings;
use dom::bindings::callback::wrap_call_this_object;
use dom::bindings::callback::{CallSetup,ExceptionHandling};
use dom::bindings::callback::{CallbackContainer,CallbackInterface,CallbackFunction};
use dom::bindings::codegen::Bindings::*;
use dom::bindings::codegen::{PrototypeList, RegisterBindings, UnionTypes};
use dom::bindings::conversions::DOM_OBJECT_SLOT;