text:
#include "erl_nif.h"

#include "libsecp256k1-config.h"
#include "secp256k1.c"
#include "include/secp256k1.h"
#include "testrand_impl.h"
#include "include/secp256k1_recovery.h"

// Key export
#include "contrib/lax_der_parsing.c"
#include "contrib/lax_der_privatekey_parsing.c"

// Prototypes

static ERL_NIF_TERM atom_from_result(ErlNifEnv* env, int res);
static ERL_NIF_TERM error_result(ErlNifEnv* env, char* error_msg);
static ERL_NIF_TERM ok_result(ErlNifEnv* env, ERL_NIF_TERM *r);
int get_compressed_flag(ErlNifEnv* env, ERL_NIF_TERM arg, int* compressed, size_t* pubkeylen);
int check_compressed(size_t Size);
int get_nonce_function(ErlNifEnv* env, ERL_NIF_TERM nonce_term, ERL_NIF_TERM nonce_data_term, secp256k1_nonce_function* noncefp, ErlNifBinary* noncedata);
int get_recid(ErlNifEnv* env, ERL_NIF_TERM argv, int* recid);
// Global context
static secp256k1_context *ctx = NULL;

static int
load(ErlNifEnv* env, void** priv, ERL_NIF_TERM load_info)
{
    ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
    return 0;
}

static int
upgrade(ErlNifEnv* env, void** priv, void** old_priv, ERL_NIF_TERM load_info)
{
    return 0;
}

static void
unload(ErlNifEnv* env, void* priv)
{
	secp256k1_context_destroy(ctx);
    return;
}

// Double Sha256 Hash
static ERL_NIF_TERM
dsha256(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	unsigned char* output;
	ErlNifBinary p;
	ERL_NIF_TERM r;

	if (!enif_inspect_binary(env, argv[0], &p)) {
       return enif_make_badarg(env);
    }

	// Create a NIF binary object with a 32 byte return
	output = enif_make_new_binary(env, 32, &r);

    secp256k1_sha256_t hasher;
    secp256k1_sha256_initialize(&hasher);
    secp256k1_sha256_write(&hasher, (const unsigned char*)(p.data), p.size);
    secp256k1_sha256_finalize(&hasher, output);

    secp256k1_sha256_t hasher2;
    secp256k1_sha256_initialize(&hasher2);
    secp256k1_sha256_write(&hasher2, (const unsigned char*)(output), 32);
    secp256k1_sha256_finalize(&hasher2, output);

    return r;
}

static ERL_NIF_TERM
sha256(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	unsigned char* output;
	ErlNifBinary p;
	ERL_NIF_TERM r;

	if (!enif_inspect_binary(env, argv[0], &p)) {
       return enif_make_badarg(env);
    }

	// Create a NIF binary object with a 32 byte return
	output = enif_make_new_binary(env, 32, &r);
    secp256k1_sha256_t hasher;
    secp256k1_sha256_initialize(&hasher);
    secp256k1_sha256_write(&hasher, (const unsigned char*)(p.data), p.size);
    secp256k1_sha256_finalize(&hasher, output);

    return r;
}

static ERL_NIF_TERM
hmac_sha256(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	unsigned char* output;
	ErlNifBinary key, input;
	ERL_NIF_TERM r;

	if (!enif_inspect_binary(env, argv[0], &key)) {
       return enif_make_badarg(env);
    }

	if (!enif_inspect_binary(env, argv[1], &input)) {
       return enif_make_badarg(env);
    }

	// Create a NIF binary object with a 32 byte return
	output = enif_make_new_binary(env, 32, &r);
    secp256k1_hmac_sha256_t hasher;
    secp256k1_hmac_sha256_initialize(&hasher, (const unsigned char*)(key.data), key.size);
    secp256k1_hmac_sha256_write(&hasher, (const unsigned char*)(input.data), input.size);
    secp256k1_hmac_sha256_finalize(&hasher, output);

    return r;
}

// Random Test Functions
//

static ERL_NIF_TERM
rand32(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	ERL_NIF_TERM r;
	unsigned char* output = enif_make_new_binary(env, 4, &r);
	uint32_t v = secp256k1_rand32();
    memcpy(&v, output, 4);
	return r;
}

static ERL_NIF_TERM
rand256(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	ERL_NIF_TERM r;
	unsigned char* output = enif_make_new_binary(env, 32, &r);
	secp256k1_rand256(output);
	return r;
}

// Number operations

// Scalar operations

// ECDSA key operations

static ERL_NIF_TERM
ec_seckey_verify(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	ErlNifBinary privkey;
	secp256k1_scalar key;
	unsigned char b32[32];
    int overflow = 0;
	int result;

	if (!enif_inspect_binary(env, argv[0], &privkey)) {
       return enif_make_badarg(env);
    }

    if (privkey.size != 32) {
    	return enif_make_badarg(env);
	}

	secp256k1_scalar_set_b32(&key, b32, &overflow);
	if (overflow || secp256k1_scalar_is_zero(&key)) {
		return enif_make_int(env, 0);
	}

	secp256k1_scalar_get_b32(privkey.data, &key);

    result = secp256k1_ec_seckey_verify(ctx, privkey.data);
    return atom_from_result(env, result);
}

static ERL_NIF_TERM
ec_pubkey_create(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	int result;
	ErlNifBinary privkey;
	ERL_NIF_TERM r;
	unsigned char* pubkey_buf;
	size_t pubkeylen;
	int compressed;
    secp256k1_pubkey pubkey;

	if (!enif_inspect_binary(env, argv[0], &privkey)) {
       return enif_make_badarg(env);
    }

	if (!get_compressed_flag(env, argv[1], &compressed, &pubkeylen)) {
		return error_result(env, "Compression flag invalid");
	}

	if (privkey.size != 32) {
		return error_result(env, "Private key size not 32 bytes");
	}

	pubkey_buf = enif_make_new_binary(env, pubkeylen, &r);
	result = secp256k1_ec_pubkey_create(ctx, &pubkey, privkey.data);
	if (result == 1 &&
			(secp256k1_ec_pubkey_serialize(ctx, pubkey_buf, &pubkeylen, &pubkey, compressed) == 1)) {
			return ok_result(env, &r);
	} else {
		return error_result(env, "Public key generation error");
	}

}

static ERL_NIF_TERM
ec_pubkey_decompress(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{

	ErlNifBinary pubkey;
	ERL_NIF_TERM r;
	unsigned char* decompressedkey;
	size_t decompressedkeylen = 65;
    secp256k1_pubkey pubkeyt;

	if (!enif_inspect_binary(env, argv[0], &pubkey)) {
       return enif_make_badarg(env);
    }

	if ((pubkey.size != 33) && (pubkey.size != 65)) {
		return error_result(env, "Public key size != 33 or 65 bytes");
	}

	decompressedkey = enif_make_new_binary(env, decompressedkeylen, &r);

	if (secp256k1_ec_pubkey_parse(ctx, &pubkeyt, pubkey.data, pubkey.size) != 1) {
		return error_result(env, "Public key parse error");
	}

	if (secp256k1_ec_pubkey_serialize(ctx, decompressedkey, &decompressedkeylen,
	            &pubkeyt, SECP256K1_EC_UNCOMPRESSED) != 1) {
		return error_result(env, "Public key decompression error");
	}

	return ok_result(env, &r);

}

static ERL_NIF_TERM
ec_pubkey_verify(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	int result;
	ErlNifBinary pubkey;
    secp256k1_pubkey pubkeyt;

	if (!enif_inspect_binary(env, argv[0], &pubkey)) {
       return enif_make_badarg(env);
    }

    if ((pubkey.size != 33) && (pubkey.size != 65)) {
		return error_result(env, "Public key size != 33 or 65 bytes");
	}

	result = secp256k1_ec_pubkey_parse(ctx, &pubkeyt, pubkey.data, pubkey.size);
	return atom_from_result(env, result);
}

static ERL_NIF_TERM
ec_privkey_export(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	ERL_NIF_TERM r;
	ErlNifBinary privkey;
	unsigned char exported_seckey[300];
	unsigned char* seckey_buf;
	size_t seckey_len = 300;
	int compressed, result;
	size_t pubkeylen;

	if (!enif_inspect_binary(env, argv[0], &privkey)) {
       return enif_make_badarg(env);
    }

    if (privkey.size != 32) {
    	return enif_make_badarg(env);
	}

	if (!get_compressed_flag(env, argv[1], &compressed, &pubkeylen)) {
		return error_result(env, "Compression flag invalid");
	}

	result = ec_privkey_export_der(ctx,
	        exported_seckey, &seckey_len,
			privkey.data, compressed);
	if (result == 0) {
		return error_result(env, "privkey export returned 0");
	}

	seckey_buf = enif_make_new_binary(env, seckey_len, &r);
	memcpy(seckey_buf, exported_seckey, seckey_len);
	return ok_result(env, &r);
}

static ERL_NIF_TERM
ec_privkey_import(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	ERL_NIF_TERM r;
	ErlNifBinary exportedkey;
	unsigned char* privkey_buf;
	int result;

	if (!enif_inspect_binary(env, argv[0], &exportedkey)) {
       return enif_make_badarg(env);
    }

	privkey_buf = enif_make_new_binary(env, 32, &r);
    result = ec_privkey_import_der(ctx, privkey_buf, exportedkey.data, exportedkey.size);
    if (result == 0) {
		return error_result(env, "privkey import returned 0");
	}

	return ok_result(env, &r);

}

static ERL_NIF_TERM
ec_privkey_tweak_add(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	ERL_NIF_TERM r;
	ErlNifBinary privkey, tweak;
	unsigned char* privkey_buf;
	int result;

	if (!enif_inspect_binary(env, argv[0], &privkey)) {
       return enif_make_badarg(env);
    }

	if (!enif_inspect_binary(env, argv[1], &tweak)) {
       return enif_make_badarg(env);
    }

    privkey_buf = enif_make_new_binary(env, 32, &r);
	memcpy(privkey_buf, privkey.data, privkey.size);

	result = secp256k1_ec_privkey_tweak_add(ctx, privkey_buf, tweak.data);

	if (result == 0) {
		return error_result(env, "ec_privkey_tweak_add returned 0");
	}

	return ok_result(env, &r);
}

static ERL_NIF_TERM
ec_pubkey_tweak_add(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	ERL_NIF_TERM r;
	ErlNifBinary pubkey, tweak;
	unsigned char* pubkey_buf;
    secp256k1_pubkey pubkeyt;

	if (!enif_inspect_binary(env, argv[0], &pubkey)) {
       return enif_make_badarg(env);
    }

	if (!enif_inspect_binary(env, argv[1], &tweak)) {
       return enif_make_badarg(env);
    }

    pubkey_buf = enif_make_new_binary(env, pubkey.size, &r);

	if (secp256k1_ec_pubkey_parse(ctx, &pubkeyt, pubkey.data, pubkey.size) != 1) {
		return enif_make_badarg(env);
	};

	if (secp256k1_ec_pubkey_tweak_add(ctx, &pubkeyt, tweak.data) != 1) {
		return error_result(env, "ec_pubkey_tweak_add returned 0");
	}

	if (secp256k1_ec_pubkey_serialize(ctx, pubkey_buf, (size_t *)&pubkey.size, &pubkeyt,
				check_compressed(pubkey.size)) != 1) {
		return error_result(env, "Public key serialize error");
	}

	return ok_result(env, &r);
}

int check_compressed(size_t Size) {
	if (Size == 33) {
		return SECP256K1_EC_COMPRESSED;
	}
		return SECP256K1_EC_UNCOMPRESSED;
}

static ERL_NIF_TERM
ec_privkey_tweak_mul(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	ERL_NIF_TERM r;
	ErlNifBinary privkey, tweak;
	unsigned char* privkey_buf;
	int result;

	if (!enif_inspect_binary(env, argv[0], &privkey)) {
       return enif_make_badarg(env);
    }

	if (!enif_inspect_binary(env, argv[1], &tweak)) {
       return enif_make_badarg(env);
    }

    privkey_buf = enif_make_new_binary(env, 32, &r);
	memcpy(privkey_buf, privkey.data, privkey.size);

	result = secp256k1_ec_privkey_tweak_mul(ctx, privkey_buf, tweak.data);

	if (result == 0) {
		return error_result(env, "ec_privkey_tweak_mul returned 0");
	}

	return ok_result(env, &r);

}

static ERL_NIF_TERM
ec_pubkey_tweak_mul(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	ERL_NIF_TERM r;
	ErlNifBinary pubkey, tweak;
	unsigned char* pubkey_buf;
    secp256k1_pubkey pubkeyt;

	if (!enif_inspect_binary(env, argv[0], &pubkey)) {
       return enif_make_badarg(env);
    }

	if (!enif_inspect_binary(env, argv[1], &tweak)) {
       return enif_make_badarg(env);
    }

    pubkey_buf = enif_make_new_binary(env, pubkey.size, &r);

	if (secp256k1_ec_pubkey_parse(ctx, &pubkeyt, pubkey.data, pubkey.size) != 1) {
		return enif_make_badarg(env);
	};

	if (secp256k1_ec_pubkey_tweak_mul(ctx, &pubkeyt, tweak.data) != 1) {
		return error_result(env, "ec_pubkey_tweak_mul returned 0");
	}

	if (secp256k1_ec_pubkey_serialize(ctx, pubkey_buf, (size_t *)&pubkey.size, &pubkeyt,
				check_compressed(pubkey.size)) != 1) {
		return error_result(env, "Public key serialize error");
	}

	return ok_result(env, &r);

}

//// Ecdsa Signing
//
static ERL_NIF_TERM
ecdsa_sign(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	ERL_NIF_TERM r;
	ErlNifBinary message, privkey, noncedata;
	int result;
    secp256k1_ecdsa_signature signature;
	unsigned char* finishedsig;
	unsigned char intermediatesig[74];
	size_t siglen = 74;

	secp256k1_nonce_function noncefp;

	if (!enif_inspect_binary(env, argv[0], &message)) {
       return enif_make_badarg(env);
    }

	if (!enif_inspect_binary(env, argv[1], &privkey)) {
       return enif_make_badarg(env);
    }

    if (!get_nonce_function(env, argv[2], argv[3], &noncefp, &noncedata)) {
		return error_result(env, "Invalid nonce function name");
	}

	result = secp256k1_ecdsa_sign(ctx, &signature, message.data,
			privkey.data, noncefp, noncedata.data);
	if (!result) {
		return error_result(env, "ecdsa_sign returned 0");
	}

    // DER serialization may return a signature under buffer size
    // need to delay nif binary allocation
	if (secp256k1_ecdsa_signature_serialize_der(ctx, &intermediatesig, &siglen, &signature) != 1) {
		return error_result(env, "ecdsa_signature_serialize returned 0");
	}
    CHECK(secp256k1_ecdsa_signature_parse_der(ctx, &signature, &intermediatesig, siglen) == 1);
    finishedsig = enif_make_new_binary(env, siglen, &r);
    memcpy(finishedsig, intermediatesig, siglen);
	return ok_result(env, &r);

}

static ERL_NIF_TERM
ecdsa_verify(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	ErlNifBinary message, rawsignature, rawpubkey;
    secp256k1_ecdsa_signature signature;
    secp256k1_pubkey pubkey;
	int result;

	if (!enif_inspect_binary(env, argv[0], &message)) {
       return enif_make_badarg(env);
    }

	if (!enif_inspect_binary(env, argv[1], &rawsignature)) {
       return enif_make_badarg(env);
    }

	if (!enif_inspect_binary(env, argv[2], &rawpubkey)) {
       return enif_make_badarg(env);
    }

	// Parse serialized signature
	if (secp256k1_ecdsa_signature_parse_der(ctx, &signature, rawsignature.data, rawsignature.size) != 1) {
		return error_result(env, "ecdsa signature der parse error");
	}
	// Parse serialized public key

	if (secp256k1_ec_pubkey_parse(ctx, &pubkey, rawpubkey.data, rawpubkey.size) != 1) {
		return error_result(env, "Public key invalid");
	};

	result = secp256k1_ecdsa_verify(ctx, &signature, message.data, &pubkey);

	return atom_from_result(env, result);
}

static ERL_NIF_TERM
ecdsa_sign_compact(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	ERL_NIF_TERM r;
	ErlNifBinary message, privkey, noncedata;
	int result;
    secp256k1_ecdsa_recoverable_signature signature;
	unsigned char* finishedsig;
	int siglen = 64;
	int recid = 0;

	secp256k1_nonce_function noncefp;

	if (!enif_inspect_binary(env, argv[0], &message)) {
       return enif_make_badarg(env);
    }

	if (!enif_inspect_binary(env, argv[1], &privkey)) {
       return enif_make_badarg(env);
    }

    if (!get_nonce_function(env, argv[2], argv[3], &noncefp, &noncedata)) {
		return error_result(env, "Invalid nonce function name");
	}

	result = secp256k1_ecdsa_sign_recoverable(ctx, &signature, message.data,
			privkey.data, noncefp, noncedata.data);
	if (!result) {
		return error_result(env, "ecdsa_sign returned 0");
	}

    finishedsig = enif_make_new_binary(env, siglen, &r);
	if (secp256k1_ecdsa_recoverable_signature_serialize_compact(ctx,
				finishedsig, &recid, &signature) != 1) {
		return error_result(env, "ecdsa_signature_serialize returned 0");
	}

	if (recid == -1) {
		return error_result(env, "invalid recovery id");
	}

    return enif_make_tuple3(env, enif_make_atom(env, "ok"), r, enif_make_int(env, recid));

}

static ERL_NIF_TERM
ecdsa_recover_compact(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[])
{
	ERL_NIF_TERM r;
	ErlNifBinary message, csignature;
	int result, compressed;
	size_t pubkeylen;
	int recid = 0;
    unsigned char* finished_recpubkey_buf;
    secp256k1_ecdsa_recoverable_signature signature;
    secp256k1_pubkey recpubkey;

	if (!enif_inspect_binary(env, argv[0], &message)) {
       return enif_make_badarg(env);
    }

	if (!enif_inspect_binary(env, argv[1], &csignature)) {
       return enif_make_badarg(env);
    }

	if (!get_compressed_flag(env, argv[2], &compressed, &pubkeylen)) {
		return error_result(env, "Compression flag invalid");
	}

	if (compressed == SECP256K1_EC_COMPRESSED) {
		pubkeylen = 33;
	} else {
		pubkeylen = 65;
	}

	if (!get_recid(env, argv[3], &recid)) {
		return error_result(env, "Recovery id invalid 0-3");
	}
	result = secp256k1_ecdsa_recoverable_signature_parse_compact(ctx, &signature, csignature.data, recid);

	if (!result) {
		return error_result(env, "ecdsa_signature_parse_compact returned 0");
	}

	// Now do ECDSA recovery
	result = secp256k1_ecdsa_recover(ctx, &recpubkey, &signature, message.data);

	if (!result) {
	    return error_result(env, "ecdsa recovery problem");
	}

	// Now serialize recpubkey based on the compression flag
	finished_recpubkey_buf = enif_make_new_binary(env, pubkeylen, &r);

	result = secp256k1_ec_pubkey_serialize(ctx, finished_recpubkey_buf,
			&pubkeylen, &recpubkey, compressed);

	if (!result) {
		return error_result(env, "ecdsa pubkey serialize error");
	}

    return ok_result(env, &r);

}

// Utility functions

// Grab the compressed atom
int get_compressed_flag(ErlNifEnv* env, ERL_NIF_TERM arg, int* compressed, size_t* pubkeylen) {

	char compressed_atom[16];

	if (!enif_get_atom(env, arg, compressed_atom, 16, ERL_NIF_LATIN1)) {
		return 0;
    }

	if (strcmp(compressed_atom, "compressed")  == 0) {
		*pubkeylen = 33;
		*compressed = SECP256K1_EC_COMPRESSED;
		return 1;
	} else if (strcmp(compressed_atom, "uncompressed") == 0) {
		*pubkeylen = 65;
		*compressed = SECP256K1_EC_UNCOMPRESSED;
		return 1;
	}

	return 0;

}

// Grab recovery id
int get_recid(ErlNifEnv* env, ERL_NIF_TERM argv, int* recid) {

	if (!enif_get_int(env, argv, recid)) {
		return 0;
	}

	if (*recid >= 0 && *recid <= 3) {
		return 1;
	}

	return 0;

}

// Get and validate nonce function and associated nonce
int get_nonce_function(ErlNifEnv* env, ERL_NIF_TERM nonce_term, ERL_NIF_TERM nonce_data_term, secp256k1_nonce_function* noncefp, ErlNifBinary* noncedata) {
	char nonce_atom[32];

    if (!enif_get_atom(env, nonce_term, nonce_atom, 32, ERL_NIF_LATIN1)) {
    	return 0;
    }

	if (strcmp(nonce_atom, "default") == 0) {
		*noncefp = NULL;
		noncedata->data = NULL;
		noncedata->size = 0;
		return 1;
	} else if (strcmp(nonce_atom, "nonce_function_rfc6979") == 0) {
		*noncefp = nonce_function_rfc6979;

		if (!enif_inspect_binary(env, nonce_data_term, noncedata)) {
			return 0;
		}
		return 1;
	}

	return 0;
}

static ERL_NIF_TERM error_result(ErlNifEnv* env, char* error_msg)
{
    return enif_make_tuple2(env, enif_make_atom(env, "error"), enif_make_string(env, error_msg, ERL_NIF_LATIN1));
}

static ERL_NIF_TERM ok_result(ErlNifEnv* env, ERL_NIF_TERM *r)
{
    return enif_make_tuple2(env, enif_make_atom(env, "ok"), *r);
}

static ERL_NIF_TERM
atom_from_result(ErlNifEnv* env, int res)
{
	char* ret_string;
	if (res == 1) {
		ret_string = "ok";
	} else {
		ret_string = "error";
	}

	return enif_make_atom(env, ret_string);
}

static ErlNifFunc nif_funcs[] = {
	{"dsha256", 1, dsha256},
    {"sha256", 1, sha256},
	{"hmac_sha256", 2, hmac_sha256},
	{"rand32", 0, rand32},
	{"rand256", 0, rand256},
	{"ec_seckey_verify", 1, ec_seckey_verify},
	{"ec_pubkey_create", 2, ec_pubkey_create},
	{"ec_pubkey_decompress", 1, ec_pubkey_decompress},
	{"ec_pubkey_verify", 1, ec_pubkey_verify},
	{"ec_privkey_export", 2, ec_privkey_export},
	{"ec_privkey_import", 1, ec_privkey_import},
	{"ec_privkey_tweak_add", 2, ec_privkey_tweak_add},
	{"ec_pubkey_tweak_add", 2, ec_pubkey_tweak_add},
	{"ec_privkey_tweak_mul", 2, ec_privkey_tweak_mul},
	{"ec_pubkey_tweak_mul", 2, ec_pubkey_tweak_mul},
	{"ecdsa_sign", 4, ecdsa_sign},
	{"ecdsa_verify", 3, ecdsa_verify},
	{"ecdsa_sign_compact", 4, ecdsa_sign_compact},
	{"ecdsa_recover_compact", 4, ecdsa_recover_compact}
};

ERL_NIF_INIT(libsecp256k1, nif_funcs, &load, NULL, &upgrade, &unload);


text:
<?php
// This class was automatically generated by a giiant build task
// You should not change it manually as it will be overwritten on next build

namespace common\models\base;

use Yii;

/**
 * This is the base-model class for table "gender".
 *
 * @property integer $id
 * @property string $name
 * @property string $eng_name
 *
 * @property \common\models\Person[] $people
 * @property string $aliasModel
 */
abstract class Gender extends \yii\db\ActiveRecord
{

    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'gender';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name', 'eng_name'], 'required'],
            [['name', 'eng_name'], 'string', 'max' => 100]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'name' => Yii::t('app', 'Name'),
            'eng_name' => Yii::t('app', 'Eng Name'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getPeople()
    {
        return $this->hasMany(\common\models\Person::className(), ['gender_id' => 'id']);
    }

    /**
     * @inheritdoc
     * @return GenderQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new \common\models\GenderQuery(get_called_class());
    }

}

redpajama_set_name: RedPajamaGithub


text:
angular.module('loginuser')
    .config(['$stateProvider', function ($stateProvider) {
        $stateProvider
            .state('login.user', {
                userNotAuthenticated: true,
                userAuthenticated: false,
                url: '',
                templateUrl: 'login/templates/login-view.html',
                controller: 'LoginController'
            })
        ;
    }])

    .controller('LoginController', ['$scope', '$rootScope', 'AUTH_EVENTS', 'AuthService', '$state', '$http', 'CustomerPassword', 'growl', '$location',
        function ($scope, $rootScope, AUTH_EVENTS, AuthService, $state, $http, CustomerPassword, growl, $location) {
            $rootScope.loginFailed = null;
            $rootScope.sendResetPasswordFailed = null;
            $rootScope.sendResetPasswordSuccess = null;
            $scope.restPassword = false;
            $scope.resetPasswordFormSubmitted = false;
            $scope.credentials = {
                username: '',
                password: ''
            };

            $scope._url = location.hostname.split('.');
            $scope.tenantID = $scope._url.shift();

            $scope.changeForm = function () {

                $rootScope.loginFailed = null;
                $scope.restPassword = !$scope.restPassword;

            };
            $scope.resetPasswordRequest = function (email) {
                $rootScope.isLoading = true;
                $scope.resetPasswordFormSubmitted = true;

                $http({method: 'GET', url: CustomerPassword.one().getRestangularUrl()
                    + "?" + "&email=" + email + "&tenantId=" + $scope.tenantID,

                    headers: {'Content-Type': 'application/x-www-form-urlencoded'}

                })
                    .success(function (res, status, headers, config) {

                        $rootScope.sendResetPasswordFailed = null;
                        growl.addSuccessMessage('Check your email, you will receive an email with a link to reset your password.', {ttl: 10000});
//                        $rootScope.sendResetPasswordSuccess = "Check your email, you will receive an email with a link to reset your password. ";
                        $scope.restPassword = false;
                        $rootScope.isLoading = false;

                    })
                    .error(function (data, status, headers, config) {
                        $rootScope.sendResetPasswordSuccess = null;
//                        $rootScope.sendResetPasswordFailed = data.message;
                        growl.addErrorMessage(data.message, {ttl: 10000});

                        $rootScope.isLoading = false;

                    });

            }

        }]);


text:
package com._4dconcept.springframework.data.marklogic.core.query;

import javax.xml.namespace.QName;

/**
 * Definition of a Criteria. Give access to underlying value (criteria object) and full qualified name if any
 *
 * @author stoussaint
 * @since 2017-08-03
 */
public interface CriteriaDefinition {

    /**
     * Get {@link Object} representation.
     *
     * @return the underlying value
     */
    Object getCriteriaObject();

    /**
     * Get the element {@literal QName}.
     *
     * @return the current full qualified name if any
     */
    QName getQname();

}


text:
<!DOCTYPE html>
<html>
<head>
  <title>Share Button Test: Pinterest</title>
  <link rel="stylesheet" type="text/css" href="../../dist/share-button.min.css">
  <style>
    html {
      width: 100%;
      height: 100%;
      overflow: hidden;
    }
    share-button {
      position: relative;
      top: 0;
      left: 50%;
      bottom: 0;
      right: 0;
      z-index: 100;
    }
  </style>
</head>

<body>
  <share-button></share-button>
  <script src='../../dist/share-button.min.js'></script>
  <script>
    var shareButton = new ShareButton({
      networks: {
        twitter: { enabled: false },
        facebook: { enabled: false },
        whatsapp: { enabled: false },
        googlePlus: { enabled: false },
        reddit: { enabled: false },
        linkedin: { enabled: false },
        email: { enabled: false },
        pinterest: {
          url: "http://www.example.com",
          image: "http://carrot.is/img/fb-share.jpg",
          description: "pinterest discription"
        }
      },
      ui: {
        flyout: 'center bottom'
      }
    });
  </script>
</body>

</html>


text:
//---------------------------------------------------------------------------
//	Greenplum Database
//	Copyright (C) 2012 EMC Corp.
//
//	@filename:
//		CPhysicalSequence.cpp
//
//	@doc:
//		Implementation of physical sequence operator
//---------------------------------------------------------------------------

#include "gpos/base.h"

#include "gpopt/base/COptCtxt.h"
#include "gpopt/base/CUtils.h"
#include "gpopt/base/CDistributionSpecAny.h"
#include "gpopt/base/CDistributionSpecNonSingleton.h"
#include "gpopt/base/CDistributionSpecSingleton.h"
#include "gpopt/base/CCTEReq.h"

#include "gpopt/operators/ops.h"
#include "gpopt/operators/CCNFConverter.h"

using namespace gpopt;

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::CPhysicalSequence
//
//	@doc:
//		Ctor
//
//---------------------------------------------------------------------------
CPhysicalSequence::CPhysicalSequence
	(
	IMemoryPool *pmp
	)
	:
	CPhysical(pmp),
	m_pcrsEmpty(NULL)
{
	// Sequence generates two distribution requests for its children:
	// (1) If incoming distribution from above is Singleton, pass it through
	//		to all children, otherwise request Non-Singleton on all children
	//
	// (2)	Optimize first child with Any distribution requirement, and compute
	//		distribution request on other children based on derived distribution
	//		of first child:
	//			* If distribution of first child is a Singleton, request Singleton
	//				on all children
	//			* If distribution of first child is a Non-Singleton, request
	//				Non-Singleton on all children

	SetDistrRequests(2);

	m_pcrsEmpty = GPOS_NEW(pmp) CColRefSet(pmp);
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::~CPhysicalSequence
//
//	@doc:
//		Dtor
//
//---------------------------------------------------------------------------
CPhysicalSequence::~CPhysicalSequence()
{
	m_pcrsEmpty->Release();
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::FMatch
//
//	@doc:
//		Match operators
//
//---------------------------------------------------------------------------
BOOL
CPhysicalSequence::FMatch
	(
	COperator *pop
	)
	const
{
	return Eopid() == pop->Eopid();
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::PcrsRequired
//
//	@doc:
//		Compute required output columns of n-th child
//
//---------------------------------------------------------------------------
CColRefSet *
CPhysicalSequence::PcrsRequired
	(
	IMemoryPool *pmp,
	CExpressionHandle &exprhdl,
	CColRefSet *pcrsRequired,
	ULONG ulChildIndex,
	DrgPdp *, // pdrgpdpCtxt
	ULONG // ulOptReq
	)
{
	const ULONG ulArity = exprhdl.UlArity();
	if (ulChildIndex == ulArity - 1)
	{
		// request required columns from the last child of the sequence
		return PcrsChildReqd(pmp, exprhdl, pcrsRequired, ulChildIndex, ULONG_MAX);
	}

	m_pcrsEmpty->AddRef();
	GPOS_ASSERT(0 == m_pcrsEmpty->CElements());

	return m_pcrsEmpty;
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::PppsRequired
//
//	@doc:
//		Compute required partition propagation of the n-th child
//
//---------------------------------------------------------------------------
CPartitionPropagationSpec *
CPhysicalSequence::PppsRequired
	(
	IMemoryPool *pmp,
	CExpressionHandle &exprhdl,
	CPartitionPropagationSpec *pppsRequired,
	ULONG ulChildIndex,
	DrgPdp *, //pdrgpdpCtxt,
	ULONG //ulOptReq
	)
{
	GPOS_ASSERT(NULL != pppsRequired);

	return CPhysical::PppsRequiredPushThruNAry(pmp, exprhdl, pppsRequired, ulChildIndex);
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::PcteRequired
//
//	@doc:
//		Compute required CTE map of the n-th child
//
//---------------------------------------------------------------------------
CCTEReq *
CPhysicalSequence::PcteRequired
	(
	IMemoryPool *pmp,
	CExpressionHandle &exprhdl,
	CCTEReq *pcter,
	ULONG ulChildIndex,
	DrgPdp *pdrgpdpCtxt,
	ULONG //ulOptReq
	)
	const
{
	GPOS_ASSERT(NULL != pcter);
	if (ulChildIndex < exprhdl.UlArity() - 1)
	{
		return pcter->PcterAllOptional(pmp);
	}

	// derived CTE maps from previous children
	CCTEMap *pcmCombined = PcmCombine(pmp, pdrgpdpCtxt);

	// pass the remaining requirements that have not been resolved
	CCTEReq *pcterUnresolved = pcter->PcterUnresolvedSequence(pmp, pcmCombined, pdrgpdpCtxt);
	pcmCombined->Release();

	return pcterUnresolved;
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::FProvidesReqdCols
//
//	@doc:
//		Helper for checking if required columns are included in output columns
//
//---------------------------------------------------------------------------
BOOL
CPhysicalSequence::FProvidesReqdCols
	(
	CExpressionHandle &exprhdl,
	CColRefSet *pcrsRequired,
	ULONG // ulOptReq
	)
	const
{
	GPOS_ASSERT(NULL != pcrsRequired);

	// last child must provide required columns
	ULONG ulArity = exprhdl.UlArity();
	GPOS_ASSERT(0 < ulArity);

	CColRefSet *pcrsChild = exprhdl.Pdprel(ulArity - 1)->PcrsOutput();

	return pcrsChild->FSubset(pcrsRequired);
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::PdsRequired
//
//	@doc:
//		Compute required distribution of the n-th child
//
//---------------------------------------------------------------------------
CDistributionSpec *
CPhysicalSequence::PdsRequired
	(
	IMemoryPool *pmp,
	CExpressionHandle &
#ifdef GPOS_DEBUG
	exprhdl
#endif // GPOS_DEBUG
	,
	CDistributionSpec *pdsRequired,
	ULONG  ulChildIndex,
	DrgPdp *pdrgpdpCtxt,
	ULONG  ulOptReq
	)
	const
{
	GPOS_ASSERT(2 == exprhdl.UlArity());
	GPOS_ASSERT(ulChildIndex < exprhdl.UlArity());
	GPOS_ASSERT(ulOptReq < UlDistrRequests());

	if (0 == ulOptReq)
	{
		if (CDistributionSpec::EdtSingleton == pdsRequired->Edt() ||
			CDistributionSpec::EdtStrictSingleton == pdsRequired->Edt())
		{
			// incoming request is a singleton, request singleton on all children
			CDistributionSpecSingleton *pdss = CDistributionSpecSingleton::PdssConvert(pdsRequired);
			return GPOS_NEW(pmp) CDistributionSpecSingleton(pdss->Est());
		}

		// incoming request is a non-singleton, request non-singleton on all children
		return GPOS_NEW(pmp) CDistributionSpecNonSingleton();
	}
	GPOS_ASSERT(1 == ulOptReq);

	if (0 == ulChildIndex)
	{
		// no distribution requirement on first child
		return GPOS_NEW(pmp) CDistributionSpecAny(this->Eopid());
	}

	// get derived plan properties of first child
	CDrvdPropPlan *pdpplan = CDrvdPropPlan::Pdpplan((*pdrgpdpCtxt)[0]);
	CDistributionSpec *pds = pdpplan->Pds();

	if (pds->FSingletonOrStrictSingleton())
	{
		// first child is singleton, request singleton distribution on second child
		CDistributionSpecSingleton *pdss = CDistributionSpecSingleton::PdssConvert(pds);
		return GPOS_NEW(pmp) CDistributionSpecSingleton(pdss->Est());
	}

	if (CDistributionSpec::EdtUniversal == pds->Edt())
	{
		// first child is universal, impose no requirements on second child
		return GPOS_NEW(pmp) CDistributionSpecAny(this->Eopid());
	}

	// first child is non-singleton, request a non-singleton distribution on second child
	return GPOS_NEW(pmp) CDistributionSpecNonSingleton();
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::PosRequired
//
//	@doc:
//		Compute required sort order of the n-th child
//
//---------------------------------------------------------------------------
COrderSpec *
CPhysicalSequence::PosRequired
	(
	IMemoryPool *pmp,
	CExpressionHandle &, // exprhdl,
	COrderSpec * ,// posRequired,
	ULONG , // ulChildIndex,
	DrgPdp *, // pdrgpdpCtxt
	ULONG // ulOptReq
	)
	const
{
	// no order requirement on the children
	return GPOS_NEW(pmp) COrderSpec(pmp);
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::PrsRequired
//
//	@doc:
//		Compute required rewindability order of the n-th child
//
//---------------------------------------------------------------------------
CRewindabilitySpec *
CPhysicalSequence::PrsRequired
	(
	IMemoryPool *, // pmp,
	CExpressionHandle &, // exprhdl,
	CRewindabilitySpec *, // prsRequired,
	ULONG , // ulChildIndex,
	DrgPdp *, // pdrgpdpCtxt
	ULONG // ulOptReq
	)
	const
{
	// no rewindability required on the children
	return GPOS_NEW(m_pmp) CRewindabilitySpec(CRewindabilitySpec::ErtNone);
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::PosDerive
//
//	@doc:
//		Derive sort order
//
//---------------------------------------------------------------------------
COrderSpec *
CPhysicalSequence::PosDerive
	(
	IMemoryPool *, // pmp,
	CExpressionHandle &exprhdl
	)
	const
{
	// pass through sort order from last child
	const ULONG ulArity = exprhdl.UlArity();

	GPOS_ASSERT(1 <= ulArity);

	COrderSpec *pos = exprhdl.Pdpplan(ulArity - 1 /*ulChildIndex*/)->Pos();
	pos->AddRef();

	return pos;
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::PdsDerive
//
//	@doc:
//		Derive distribution
//
//---------------------------------------------------------------------------
CDistributionSpec *
CPhysicalSequence::PdsDerive
	(
	IMemoryPool *, // pmp,
	CExpressionHandle &exprhdl
	)
	const
{
	// pass through distribution from last child
	const ULONG ulArity = exprhdl.UlArity();

	GPOS_ASSERT(1 <= ulArity);

	CDistributionSpec *pds = exprhdl.Pdpplan(ulArity - 1 /*ulChildIndex*/)->Pds();
	pds->AddRef();

	return pds;
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::PrsDerive
//
//	@doc:
//		Derive rewindability
//
//---------------------------------------------------------------------------
CRewindabilitySpec *
CPhysicalSequence::PrsDerive
	(
	IMemoryPool *, // pmp,
	CExpressionHandle & // exprhdl
	)
	const
{
	// no rewindability by sequence
	return GPOS_NEW(m_pmp) CRewindabilitySpec(CRewindabilitySpec::ErtNone /*ert*/);
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::EpetDistribution
//
//	@doc:
//		Return the enforcing type for distribution property based on this operator
//
//---------------------------------------------------------------------------
CEnfdProp::EPropEnforcingType
CPhysicalSequence::EpetDistribution
	(
	CExpressionHandle &exprhdl,
	const CEnfdDistribution *ped
	)
	const
{
	GPOS_ASSERT(NULL != ped);

	// get distribution delivered by the sequence node
	CDistributionSpec *pds = CDrvdPropPlan::Pdpplan(exprhdl.Pdp())->Pds();

	if (ped->FCompatible(pds))
	{
		// required distribution will be established by the sequence operator
		return CEnfdProp::EpetUnnecessary;
	}

	// required distribution will be enforced on sequence's output
	return CEnfdProp::EpetRequired;
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::EpetOrder
//
//	@doc:
//		Return the enforcing type for the order property based on this operator
//
//---------------------------------------------------------------------------
CEnfdProp::EPropEnforcingType
CPhysicalSequence::EpetOrder
	(
	CExpressionHandle &exprhdl,
	const CEnfdOrder *peo
	)
	const
{
	GPOS_ASSERT(NULL != peo);

	// get order delivered by the sequence node
	COrderSpec *pos = CDrvdPropPlan::Pdpplan(exprhdl.Pdp())->Pos();

	if (peo->FCompatible(pos))
	{
		// required order will be established by the sequence operator
		return CEnfdProp::EpetUnnecessary;
	}

	// required distribution will be enforced on sequence's output
	return CEnfdProp::EpetRequired;
}

//---------------------------------------------------------------------------
//	@function:
//		CPhysicalSequence::EpetRewindability
//
//	@doc:
//		Return the enforcing type for rewindability property based on this operator
//
//---------------------------------------------------------------------------
CEnfdProp::EPropEnforcingType
CPhysicalSequence::EpetRewindability
	(
	CExpressionHandle &, // exprhdl
	const CEnfdRewindability * // per
	)
	const
{
	// rewindability must be enforced on operator's output
	return CEnfdProp::EpetRequired;
}

// EOF


text:
namespace NLog.UnitTests.Targets
{
    using NLog.Targets;
    using Xunit;
    using Xunit.Extensions;
    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.Collections;
    using System.Text.RegularExpressions;
    public class DefaultJsonSerializerTests : NLogTestBase
    {
        private DefaultJsonSerializer _serializer;

        public DefaultJsonSerializerTests()
        {
            _serializer = DefaultJsonSerializer.Instance;
        }

        [Fact]
        public void SingleLineString_Test()
        {
            var text = "This is, sort of, surprising the 1. time you see that test-result.";
            var expected = "\"This is, sort of, surprising the 1. time you see that test-result.\"";

            var actual = _serializer.SerializeObject(text);
            Assert.Equal(expected, actual);
        }

        [Fact]
        public void MultiLineString_Test()
        {
            var text = "First line followed by Windows line break\r\nNow this is second with UNIX\nand third at last";
            var expected = "\"First line followed by Windows line break\\r\\nNow this is second with UNIX\\nand third at last\"";

            var actual = _serializer.SerializeObject(text);
            Assert.Equal(expected, actual);
        }

        [Fact]
        public void StringWithTabBackSpaceFormfeed_Test()
        {
            var text = "A tab\tis followed by a feed\fand finally cancel last character\b";
            var expected = "\"A tab\\tis followed by a feed\\fand finally cancel last character\\b\"";

            var actual = _serializer.SerializeObject(text);
            Assert.Equal(expected, actual);
        }

        [Fact]
        public void StringWithSlashAndQuotes_Test()
        {
            var text = "This sentence/text is \"normal\", we think.";
            var expected = "\"This sentence\\/text is \\\"normal\\\", we think.\"";

            var actual = _serializer.SerializeObject(text);
            Assert.Equal(expected, actual);
        }

        [Fact]
        public void ReferenceLoopInDictionary_Test()
        {
            var d = new Dictionary<string, object>();
            d.Add("First", 17);
            d.Add("Loop", d);
            var target = new Dictionary<string, object>
            {
                {"Name", "TestObject" },
                {"Assets" , d }
            };

            var expected = "{\"Name\":\"TestObject\",\"Assets\":{\"First\":17}}";
            var actual = _serializer.SerializeObject(target);

            Assert.Equal(expected, actual);
        }

        [Fact]
        public void ReferenceLoopInList_Test()
        {
            var d = new List<object>();
            d.Add(17);
            d.Add(d);
            d.Add(3.14);
            var target = new List<object>
            {
                {"TestObject" },
                {d }
            };

            var expected = "[\"TestObject\",[17,3.14]]";
            var actual = _serializer.SerializeObject(target);

            Assert.Equal(expected, actual);
        }

        [Fact]
        public void InfiniteLoop_Test()
        {
            var d = new TestList();
            var actual = _serializer.SerializeObject(d);

            var cnt = Regex.Matches(actual, "\\[\"alpha\",\"bravo\"\\]").Count;
            Assert.Equal(9, cnt);       // maximum level is 10 => 10 recursion is skipped => count is 10 - 1
        }

        [Fact]
        public void StringWithMixedControlCharacters_Test()
        {
            var text = "First\\Second\tand" +(char)3+ "for" + (char)0x1f + "with" + (char)0x10 + "but" + (char)0x0d + "and no" + (char)0x20;
            var expected = "\"First\\\\Second\\tand\\u0003for\\u001fwith\\u0010but\\rand no \"";

            var actual = _serializer.SerializeObject(text);
            Assert.Equal(expected, actual);
        }

        [Theory]
        [InlineData((int)177, "177")]
        [InlineData((long)32711520331, "32711520331")]
        [InlineData(3.14159265, "3.14159265")]
        [InlineData(2776145.7743, "2776145.7743")]
        public void SerializeNumber_Test(object o, string expected)
        {
            var actual = _serializer.SerializeObject(o);
            Assert.Equal(expected, actual);
        }

        [Fact]
        public void SerializeBool_Test()
        {
            var actual = _serializer.SerializeObject(true);
            Assert.Equal("true", actual, StringComparer.OrdinalIgnoreCase);
            actual = _serializer.SerializeObject(false);
            Assert.Equal("false", actual, StringComparer.OrdinalIgnoreCase);
        }

        private class TestList : IEnumerable<IEnumerable>
        {
            static List<int> _list1 = new List<int> { 17, 3 };
            static List<string> _list2 = new List<string> { "alpha", "bravo" };

            public IEnumerator<IEnumerable> GetEnumerator()
            {
                yield return _list1;
                yield return _list2;
                yield return new TestList();
            }

            IEnumerator IEnumerable.GetEnumerator()
            {
                return this.GetEnumerator();
            }
        }
    }
}


text:
@echo off
REM ImportFlex2Word.bat - 2-Aug-2013 Greg Trihus
set myProg=\SIL\msWordExport\msWordExport.exe
set progDir=C:\Program Files
if exist "%progDir%%myProg%" goto foundIt
set progDir=%ProgramFiles(x86)%
if exist "%progDir%%myProg%" goto foundIt
set progDir=%ProgramFiles%
if exist "%progDir%%myProg%" goto fountIt
echo msWordExport.exe not found
goto done

:foundIt
@echo on
"%progDir%%myProg%" -v -o=main.doc -t="My Title" "%1"
@echo off
:done
pause


text:
module ConflictExport (D6.fringe, myFringe) where

{-Rename 'myFringe' to 'fringe' will fail because of
  conflicting exports. -}
import D6

myFringe:: Tree a -> [a]
myFringe (Leaf x ) = [x]
myFringe (Branch left right) = myFringe right


text:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>kernel.core.macro — IPython v0.10 documentation</title>
    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />

    <link rel="top" title="IPython v0.10 documentation" href="../../index.html" />
    <link rel="up" title="The IPython API" href="../index.html" />
    <link rel="next" title="kernel.core.magic" href="IPython.kernel.core.magic.html" />
    <link rel="prev" title="kernel.core.interpreter" href="IPython.kernel.core.interpreter.html" />

Navigation

          index

          modules |

          next |

          previous |

IPython v0.10 documentation »

The IPython API »

kernel.core.macro¶

Module: <tt class="xref docutils literal">kernel.core.macro</tt>¶

Inheritance diagram for <tt class="docutils literal">IPython.kernel.core.macro</tt>:

<map id="inheritance6bda148fde" name="inheritance6bda148fde">
<area shape="rect" href="#IPython.kernel.core.macro.Macro" title="core.macro.Macro" alt="" coords="7,5,143,32"/>
</map>

Support for interactive macros in IPython

<tt class="xref docutils literal">Macro</tt>¶

class <tt class="descclassname">IPython.kernel.core.macro.</tt><tt class="descname">Macro</tt><big>(</big>data<big>)</big>¶

Simple class to store the value of macros as strings.

This allows us to later exec them by checking when something is an
instance of this class.

<tt class="descname">__init__</tt><big>(</big>data<big>)</big>¶

Table Of Contents

kernel.core.macro

Module: <tt class="docutils literal">kernel.core.macro</tt>

<tt class="docutils literal">Macro</tt>

Previous topic

kernel.core.interpreter

Next topic

kernel.core.magic

This Page

Show Source

Quick search

            <form class="search" action="../../search.html" method="get">
              <input type="text" name="q" size="18" /> <input type="submit" value="Go" />
              <input type="hidden" name="check_keywords" value="yes" />
              <input type="hidden" name="area" value="default" />
            </form>

Navigation

          index

          modules |

          next |

          previous |

IPython v0.10 documentation »

The IPython API »

      © Copyright 2008, The IPython Development Team.
      Last updated on Aug 04, 2009.
      Created using Sphinx 0.5.2.


text:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<type interface="true" language="gradle" name="org.gradle.api.plugins.ExtensionContainer" version="3.0">
    <description> Allows adding 'namespaced' DSL extensions to a target object.

</description>
    <method name="add" returnType="void">
        <description> Adding an extension of name 'foo' will:

 add 'foo' dynamic property

 add 'foo' dynamic method that accepts a closure that is a configuration script block

param:name Will be used as a sort of namespace of properties/methods.

param:extension Any object whose methods and properties will extend the target object
 @throws IllegalArgumentException When an extension with the given name already exists.

</description>
        <parameter type="java.lang.String" name="name"/>
        <parameter type="java.lang.Object" name="extension"/>
    </method>
    <method name="configure" returnType="void">
        <description> Looks for the extension of the specified type and configures it with the supplied action.

param:type extension type

param:action the configure action
 @throws UnknownDomainObjectException if no extension is found.

</description>
        <parameter type="java.lang.Class" name="type"/>
        <parameter type="org.gradle.api.Action" name="action"/>
    </method>
    <method name="create" returnType="T">
        <description> Adds a new extension to this container, that itself is dynamically made ExtensionAware.

 A new instance of the given type will be created using the given constructionArguments. The new
 instance will have been dynamically which means that you can cast the object to ExtensionAware.

 (see Object))

param:name The name for the extension

param:type The type of the extension

param:constructionArguments The arguments to be used to construct the extension instance

returns:The created instance
 @throws IllegalArgumentException When an extension with the given name already exists.

</description>
        <parameter type="java.lang.String" name="name"/>
        <parameter type="java.lang.Class" name="type"/>
        <parameter type="java.lang.Object" name="constructionArguments"/>
    </method>
    <method name="findByName" returnType="java.lang.Object">
        <description> Looks for the extension of a given name. If none found null is returned.

param:name extension name

returns:extension or null

</description>
        <parameter type="java.lang.String" name="name"/>
    </method>
    <method name="findByType" returnType="T">
        <description> Looks for the extension of a given type (useful to avoid casting). If none found null is returned.

param:type extension type

returns:extension or null

</description>
        <parameter type="java.lang.Class" name="type"/>
    </method>
    <method name="getByName" returnType="java.lang.Object">
        <description> Looks for the extension of a given name. If none found it will throw an exception.

param:name extension name

returns:extension, never null
 @throws UnknownDomainObjectException When the given extension is not found.

</description>
        <parameter type="java.lang.String" name="name"/>
    </method>
    <method name="getByType" returnType="T">
        <description> Looks for the extension of a given type (useful to avoid casting). If none found it will throw an exception.

param:type extension type

returns:extension, never null
 @throws UnknownDomainObjectException When the given extension is not found.

</description>
        <parameter type="java.lang.Class" name="type"/>
    </method>
    <method name="getExtraProperties" returnType="org.gradle.api.plugins.ExtraPropertiesExtension">
        <description> The extra properties extension in this extension container.

 This extension is always present in the container, with the name "ext".

returns:The extra properties extension in this extension container.

</description>
    </method>
    <property name="byName" type="java.lang.Object">
        <description> Looks for the extension of a given name. If none found it will throw an exception.

param:name extension name

returns:extension, never null
 @throws UnknownDomainObjectException When the given extension is not found.

</description>
    </property>
    <property name="byType" type="T">
        <description> Looks for the extension of a given type (useful to avoid casting). If none found it will throw an exception.

param:type extension type

returns:extension, never null
 @throws UnknownDomainObjectException When the given extension is not found.

</description>
    </property>
    <property name="extraProperties" type="org.gradle.api.plugins.ExtraPropertiesExtension">
        <description> The extra properties extension in this extension container.

 This extension is always present in the container, with the name "ext".

returns:The extra properties extension in this extension container.

</description>
    </property>
</type>