Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Korostelev nadako

View GitHub Profile
@nadako
nadako / Main.hx
Created Mar 18, 2020
declaration-site unification check
View Main.hx
class Point implements UnifyCheck<{x:Int}> {
public var x:Int;
}
class Main {
static function main() {
}
}
View server-connect.md

--server-connect

Haxe 4.0 introduces a new way of communicating IDE and the compiler.

Here's what an IDE needs to do:

  • start a TCP server on some port (can pass 0 to bind to any available one)
  • start haxe --server-connect <port> where <port> is replaced with the port number the started TCP server was bound to.
  • haxe will connect to that server and await requests, ensure that happens
  • send messages of the following structure:
@nadako
nadako / 1 Main.hx
Last active Oct 16, 2021
ocaml-like `with` for Haxe
View 1 Main.hx
using WithMacro;
typedef Player = {
final name:String;
final level:Int;
}
class Main {
static function main() {
var player = {name: "Dan", level: 15};
@nadako
nadako / tasks.json
Created Aug 29, 2016
tasks.json from Haxe with OCaml problem matcher
View tasks.json
{
"version": "0.1.0",
"command": "make",
"isShellCommand": true,
"args": ["ADD_REVISION=1", "-f", "Makefile.win", "haxe"],
"showOutput": "always",
"problemMatcher": {
"fileLocation": "relative",
"owner": "ocaml",
"pattern": [
View building-haxe-ng-plus.md

NOTE: This gist was added to the official building manual and will be updated there from now on: https://haxe.org/documentation/introduction/building-haxe.html

Preparation

  • Uninstall OCaml, MinGW, Cygwin
  • Remove leftover environment vars, cleanup PATH

Installation

View Component.hx
// register a build-macro that will be called
// for building fields for subclasses of this class
@:autoBuild(ComponentMacro.build())
class Component {
// this function will be overriden in subclasses
public function registerCallbacks(updates:Array<Void->Void>) {}
}
View FunctionArgMacro.hx
import haxe.macro.Context;
import haxe.macro.Expr;
class FunctionArgMacro {
macro static function build():Array<Field> {
var fields = Context.getBuildFields();
for (field in fields) {
switch (field.kind) {
case FFun(fun):
var checks = [];
@nadako
nadako / tasks.json
Created Apr 19, 2016
haxe problem matcher for vs code
View tasks.json
{
"version": "0.1.0",
"command": "haxe",
"args": ["build.hxml"],
"problemMatcher": {
"owner": "haxe",
"pattern": {
"regexp": "^(.+):(\\d+): (?:lines \\d+-(\\d+)|character(?:s (\\d+)-| )(\\d+)) : (?:(Warning) : )?(.*)$",
"file": 1,
"line": 2,
@nadako
nadako / 0_reuse_code.js
Created Apr 12, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console