Skip to content

Instantly share code, notes, and snippets.

View deltaluca's full-sized avatar

Luca Deltodesco deltaluca

View GitHub Profile
namespace v8interop { namespace noise
{
// General node/v8 wrapper of a noise function.
template <typename In, typename Out>
class Noise : public node::ObjectWrap
{
public:
::noise::Noise<In, Out> noise;
Noise() = delete;
#ifndef WORLEYNOISE_H
#define WORLEYNOISE_H
#include <dynarray>
#include <vector>
#include <noise/noise.h>
#include <util/spatialcache.h>
#include <util/fastmath.h>
@deltaluca
deltaluca / haxe.vim
Last active December 21, 2015 15:59
Improved haxe syntax file for vim http://i.imgur.com/ViMwoeh.png
" Vim syntax file
" Language: Haxe
" Maintainer: Luca Deltodesco <[email protected]>
" Last Change: 2013 August 26
if exists("b:current_syntax")
finish
endif
command! -nargs=+ HaxeHiLink hi def link <args>
import haxe.macro.Expr;
import haxe.macro.ExprTools;
import haxe.macro.Context;
@:autoBuild(ShortLambdas.run()) interface Lambdas {}
class ShortLambdas {
public static function run() {
var fields = Context.getBuildFields();
// perform AST transforms.
// trace fields for now to check it's running
package;
@:build(goodies.BitFields.run(ABC)) abstract ABC(Int) {
static var A = 1;
static var B = 2;
static var C = 4;
}
class Main {
static function main() {
@deltaluca
deltaluca / gist:5844993
Created June 23, 2013 13:08
patch for hxcpp CFFILoader for buffer_data and val_array_set_size on neko.
Index: include/hx/CFFILoader.h
===================================================================
--- include/hx/CFFILoader.h (revision 744)
+++ include/hx/CFFILoader.h (working copy)
@@ -101,7 +101,7 @@
if (!sNekoDllHandle)
sNekoDllHandle = dlopen("libneko." NEKO_EXT ".0", RTLD_NOW);
#endif
-
+
@deltaluca
deltaluca / ImColour.hx
Created May 20, 2013 23:43
Funky mixin method.
package imgui;
#if macro
import haxe.macro.Context;
class ImColourBuild {
public static function run() {
var fields = Context.getBuildFields();
fields.push({
pos: Context.currentPos(),
name: "_colour",
test/Test.hx:
-------------
package test;
class Test {
public static function test() {
throw "Test";
}
}
@deltaluca
deltaluca / gist:5413225
Created April 18, 2013 14:37
16.16 Fixed point numbers in Haxe 3
abstract Fixed16(Int) {
inline function new(x:Int) this = x;
inline function raw() return this;
inline static function RAW(x:Int) return new Fixed16(x);
public static var MAX_VALUE:Fixed16 = RAW(0x7fffffff);
public static var MIN_VALUE:Fixed16 = RAW(1);
@:from public static inline function fromf(x:Float) {
#if debug
@deltaluca
deltaluca / Macros.hx
Created April 16, 2013 19:50
convert long param functions into params object functions.
package;
#if macro
import haxe.macro.Expr;
import haxe.macro.Context;
#end
@:autoBuild(LongParamsImpl.run()) interface LongParams {}
class LongParamsImpl {