Skip to content

Instantly share code, notes, and snippets.

@Sgeo
Sgeo / SDL_keycode.h
Last active October 1, 2018 03:54
vice32.js .. modifications off VICE 3.2 branch.
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997-2012 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
@Sgeo
Sgeo / library_sdl.js
Last active September 16, 2018 21:32
Custom library_sdl.js to fix SDL1 keycodes. Possible issues.
//"use strict";
// See browser tests for examples (tests/runner.py, search for sdl_). Run with
// python tests/runner.py browser
// Notes:
// SDL_VIDEORESIZE: This is sent when the canvas is resized. Note that the user
// cannot manually do so, so this is only sent when the
// program manually resizes it (emscripten_set_canvas_size
// or otherwise).
Index: configure.proto
===================================================================
--- configure.proto (revision 35456)
+++ configure.proto (working copy)
@@ -2847,89 +2847,6 @@
fi
dnl check for opengl libs.
- AC_MSG_CHECKING(whether we can use the GL library)
-
use std::marker::PhantomData;
use std::cell::Cell;
struct Scope<'s> {
num: Cell<usize>,
phantom: PhantomData<Cell<&'s mut ()>>,
//ms: Vec<&'s mut i32>, <-- useful trick for understanding lifetimes
}
impl<'s> Scope<'s> {
ALU
Sequence: name=ALUSeq
SetInteger: name=SI00
Sequence: name=Seq.1
SetInteger: name=SI01
Sequence: name=Seq1.
SetInteger: name=SI10
Sequence: name=Seq.1-2
SetInteger: name=SI11
Sequence: name=Decoder
use std::any::TypeId;
use std::any::Any;
fn wrap<F: Fn()+Any>(closure: F) -> extern "C" fn() {
extern "C" fn wrapped<F: Any>() -> () {
println!("Haven't written this yet! TypeId: {:?}", TypeId::of::<F>());
}
println!("Storing closure {:?}", TypeId::of::<F>());
wrapped::<F>
}
@Sgeo
Sgeo / unique_types.rs
Created August 17, 2016 22:43
With help of talchas
#![feature(type_macros)]
struct Zero;
struct Succ<T>(T);
macro_rules! newtype {
($name_:ident) => {
get_and_inc!($name_, Zero);
}
@Sgeo
Sgeo / anymap_spec.rs
Created August 14, 2016 08:23
Specialization-based approach to an AnyMap-like structure
#![feature(specialization)]
#![allow(dead_code)]
struct Nil;
struct Cons<H, T>(H, T);
trait MayContain<T> {
fn get(&self) -> Option<&T>;
fn get_mut(&mut self) -> Option<&mut T>;
}
#![feature(specialization)]
#![allow(dead_code)]
struct Nil;
struct Cons<H, T>(H, T);
struct Zero;
struct Succ<T>(T);
trait At<L> {
#![feature(specialization)]
#![allow(dead_code)]
struct Here;
struct There<T>(T);
struct Nil;
struct Cons<Head, Index, Tail>(Head, Index, Tail);
trait ContainsAt<T, I> {