Skip to content

Instantly share code, notes, and snippets.

View burg's full-sized avatar

Blaze Jayne burg

View GitHub Profile
@burg
burg / display_list.rs
Created September 11, 2012 22:50
DisplayList WIP
use azure::azure_hl::DrawTarget;
use gfx::render_task::{draw_solid_color, draw_image, draw_text};
use gfx::geometry::*;
use geom::rect::Rect;
use image::base::Image;
use servo_text::text_run::TextRun;
use std::arc::ARC;
use dvec::DVec;
fn build_element_kind(tag_name: &str) -> ~ElementKind {
match tag_name {
~"div" => ~HTMLDivElement,
// what the heck?
~"img" => ~HTMLImageElement({ mut size: Size2D(au::from_px(100), au::from_px(100)) }),
~"script" => ~HTMLScriptElement,
~"head" => ~HTMLHeadElement,
_ => ~UnknownElement
}
@burg
burg / gist:3758844
Created September 20, 2012 22:58
boom crash
(gdb) run /Users/burg/repos/servo/src/rust-core-foundation/core_foundation.rc -o librustcorefoundation.dummy
Starting program: /usr/local/bin/rustc /Users/burg/repos/servo/src/rust-core-foundation/core_foundation.rc -o librustcorefoundation.dummy
Reading symbols for shared libraries .....+................................................................. done
Assertion failed: (S->getType()->isPointerTy() && "Invalid cast"), function CreatePointerCast, file /Users/burg/repos/rust/src/llvm/lib/VMCore/Instructions.cpp, line 2383.
Program received signal SIGABRT, Aborted.
[Switching to process 80740 thread 0x1d03]
0x00007fff8e233ce2 in __pthread_kill ()
(gdb) bt
#0 0x00007fff8e233ce2 in __pthread_kill ()
@burg
burg / gist:3791204
Created September 26, 2012 23:08
test case for mozilla/rust issue #3601
struct HTMLImageData {
mut image: Option<~str>
}
struct ElementData {
kind: ~ElementKind
}
enum ElementKind {
HTMLImageElement(HTMLImageData)
/Users/burg/repos/servo/src/servo/layout/box.rs:101:14: 101:18 error: illegal borrow: borrowed value does not live long enough
/Users/burg/repos/servo/src/servo/layout/box.rs:101 match self {
^~~~
/Users/burg/repos/servo/src/servo/layout/box.rs:100:36: 106:5 note: borrowed pointer must be valid for the lifetime &a as defined on the block at 100:36...
/Users/burg/repos/servo/src/servo/layout/box.rs:100 pure fn d() -> &a/RenderBoxData {
/Users/burg/repos/servo/src/servo/layout/box.rs:101 match self {
/Users/burg/repos/servo/src/servo/layout/box.rs:102 GenericBox(ref d) => d,
/Users/burg/repos/servo/src/servo/layout/box.rs:103 ImageBox(ref d, _) => d,
/Users/burg/repos/servo/src/servo/layout/box.rs:104 TextBox(ref d, _) => d
/Users/burg/repos/servo/src/servo/layout/box.rs:105 }
trait BinarySearchMethods<T: Ord Eq> {
pure fn binary_search(&self, &T) -> Option<&self/T>;
pure fn binary_search_index(&self, &T) -> Option<uint>;
}
impl<T: Ord Eq> &[T]: BinarySearchMethods<T> {
pure fn binary_search(&self, key: &T) -> Option<&self/T> {
match self.binary_search_index(key) {
None => None,
Some(i) => Some(&self[i])
@burg
burg / gist:3854903
Created October 8, 2012 20:53
reservation, please?
use core::dvec::DVec;
fn main() {
let v : DVec<int> = DVec();
v.reserve(1);
v.set_elt(0, 12345);
debug!("v=%?", v);
}
// inside of scanner.scan_for_runs(...).
// box count will be 35.
debug!("swapping out boxes.");
// swap out old and new box list of flow
self.flow.inline().boxes.set(dvec::unwrap(temp_boxes));
debug!("new inline flow boxes:");
do self.flow.inline().boxes.each |box| {
debug!("%s", box.debug_str()); true
}
@burg
burg / gist:3886401
Created October 13, 2012 22:22
tree fail
use core::vec;
// A generic tree datatype.
mod tree {
pub type Tree<T> = {
mut parent: Option<T>,
mut first_child: Option<T>,
mut last_child: Option<T>,
@burg
burg / example implementations
Created October 31, 2013 03:02
Plans for supporting WebCore-free Inspector
// BackendDispatcher and SupplementalDispatcher
class InspectorSupplementalBackendDispatcher;
// Map of dispatchers, dispatch to the appropriate one.
class InspectorBackendDispatcher {
public:
InspectorBackendDispatcher() { }
void registerDispatcherForDomain(String domain, InspectorSupplementalBackendDispatcher* dispatcher);