Skip to content

Instantly share code, notes, and snippets.

View deltaluca's full-sized avatar

Luca Deltodesco deltaluca

View GitHub Profile
test/Test.hx:
-------------
package test;
class Test {
public static function test() {
throw "Test";
}
}
@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",
@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
-
+
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() {
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
@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>
#ifndef WORLEYNOISE_H
#define WORLEYNOISE_H
#include <dynarray>
#include <vector>
#include <noise/noise.h>
#include <util/spatialcache.h>
#include <util/fastmath.h>
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;
...
const std::array<float32_t, 2> bounds;
private:
static std::array<float32_t, 2> compute_bounds(const std::vector<Component>& components)
{
std::array<float32_t, 2> bounds = {0, 0};
for (const auto& component: components)
{
bounds[0] -= component.multiplier;
...
const std::vector<Component> components;
template <typename C>
Product(
typename std::enable_if<
std::is_same<std::decay<C>::type, std::vector<Component>>::value,
C
>::type&& components):