Skip to content

Instantly share code, notes, and snippets.

Michael Wu michaelwu

Block or report user

Report or block michaelwu

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@michaelwu
michaelwu / bindings.js
Last active Dec 3, 2015
Self hosted TS
View bindings.js
/// <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 Sep 18, 2015
jsapi.rs (09/18/2015)
View jsapi.rs
#![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 Sep 14, 2015
jsapi.rs (link_name)
View jsapi.rs
/* 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 Aug 31, 2015
Magic plugin output
View magic.rs
// Before
#![feature(plugin)]
#![feature(associated_consts)]
#![feature(custom_attribute)]
#![feature(trace_macros)]
#![plugin(plugins)]
trace_macros!(true);
@michaelwu
michaelwu / jsapi.rs
Created Jul 23, 2015
jsapi.rs (char fixed)
View jsapi.rs
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>;
/**
View gist:9f10f60dc8b2c8e881cd
/* 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,
View gist:a889fae11dc67b8c5165
// 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)
View gist:eefab99e7bd879470f4c
// 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
View 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;
You can’t perform that action at this time.