Skip to content

Instantly share code, notes, and snippets.

View rubber-duck's full-sized avatar

Rafael Munitić rubber-duck

  • atena.tech
  • Zagreb, Croatia
  • 07:01 (UTC +02:00)
View GitHub Profile
module toybox.math.vector;
private
{
import std.stdio, std.string, std.metastrings, std.typecons, std.traits;
static import std.math, std.algorithm;
import toybox.math.matrix;
}
template IsComponentType(T) { static if(is(T == float) || is(T == double) || is(T == int) || is(T == uint) || is(T == bool)) { enum IsComponentType = true; } else { enum IsComponentType = false; } }
template IsFloat(T) { static if(is(T == float) || is(T == double)) { enum IsFloat = true; } else { enum IsFloat = false; } }
static node_size : uint = 32;
struct HashArrayMappedTrie<T> {
root : ~Node<T>,
length : uint
}
enum Node<T> {
Values([T]),
Children([@Node<T>, ..node_size]),
use std::uint; use std::vec;
static node_size : uint = 32;
struct HashArrayMappedTrie<T> {
root : Node<T>,
length : uint
}
#[deriving(Clone)]
src/functions.rs:1557:109: 1557:113 error: unresolved import. maybe a missing `extern mod libc`?
src/functions.rs:1557 fn glDrawElementsInstancedBaseInstance(mode: ::GLenum, count: ::GLsizei, gltype: ::GLenum, indices: *::libc::c_void, instancecount: ::GLsizei, baseinstance: ::GLuint);
^~~~
src/functions.rs:1557:109: 1557:123 error: use of undeclared module `::libc`
src/functions.rs:1557 fn glDrawElementsInstancedBaseInstance(mode: ::GLenum, count: ::GLsizei, gltype: ::GLenum, indices: *::libc::c_void, instancecount: ::GLsizei, baseinstance: ::GLuint);
^~~~~~~~~~~~~~
src/functions.rs:1557:109: 1557:123 error: use of undeclared type name `libc::c_void`
src/functions.rs:1557 fn glDrawElementsInstancedBaseInstance(mode: ::GLenum, c
#[deriving(ToStr)]
struct Vec3f {
x: f32,
y: f32,
z: f32
}
macro_rules! impl_vec_op(
($tr: ident, $op: ident, $vt: ident, $($members: ident)+) => (
impl $tr<$vt, $vt> for $vt {
macro_rules! define_vec (
($vect: ident, $vecmod: ident, $compt: ty, $($components: ident)+) => (
mod $vecmod {
#[deriving(ToStr)]
pub struct $vect { $($components : $compt),+ }
impl $vect
{
#[inline(always)]
pub fn new($($components: $compt),+) -> $vect {
pub use self::_vec2::vec2;
pub use self::_vec3::vec3;
pub use self::_vec4::vec4;
macro_rules! impl_vec_dot(
($x: ident, $y: ident, $z: ident, $w: ident) => ( x.$x * y.$x + x.$y * y.$y + x.$z * y.$z + x.$w * y.$w );
($x: ident, $y: ident, $z: ident) => ( x.$x * y.$x + x.$y * y.$y + x.$z * y.$z );
($x: ident, $y: ident) => ( x.$x * y.$x + x.$y * y.$y );
)
struct Foo {
bar: ~[int]
}
fn main() {
let mut foo = Foo { bar: ~[0i] };
foo.bar = append_one(foo.bar, 1);
}
#[deriving(Clone)]
struct Foo<'self>
{
foo: &'self str
}
fn main() {
}
struct Foo<'self>
{
foo: &'self fn()
}
impl<'self> Foo<'self> {
fn foo(&self) {
println("Method foo");
}
}