This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros | |
import strutils | |
import typetraits | |
import tables | |
import strutils | |
import sequtils | |
import compileTimeHeap | |
{.experimental.} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Compile Time Fields | |
# This module is provided under | |
# | |
# The MIT License (MIT) | |
# | |
# Copyright (c) 2016 Michael Jendrusch | |
# | |
# Permission is hereby granted, free of charge, to any | |
# person obtaining a copy of this software and associated |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A fully dynamic type for ad hoc interfacing with JavaScript | |
import macros | |
import tables | |
import typeinfo | |
import typetraits | |
{. experimental .} | |
# Hack for type inference: | |
# Build a Table of (JsObject instance to (field to type)), | |
# which updates at each evaluation of `.=`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros | |
# Macro to build a lambda using JavaScript's `this` | |
# from a proc, `this` being the first argument. | |
macro bindMethod*(procedure: typed): auto = | |
var | |
rawProc = getImpl(procedure.symbol) | |
args = rawProc[3] | |
thisType = args[1][1] | |
params = newNimNode(nnkFormalParams).add(args[0]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import macros | |
# Takes a pragma identifier, together with a typesection | |
macro pragmaTypeSection*(prag, x : untyped): untyped = | |
result = newNimNode(nnkTypeSection) | |
for child in x[0].children: | |
var | |
name = child[0] | |
rawBody = child[2] | |
body = rawBody |