コード例 #1
0
tp_obj initClasspyDFMenu(tp_vm *vm)
{
  tp_obj myClass = tp_class(vm);
  tp_set(vm,myClass, tp_string("__init__"), tp_fnc(vm,myCtorpyDFMenu));
  tp_set(vm,myClass, tp_string("__set__"), tp_fnc(vm,zzpy__pyDFMenu_set));
  tp_set(vm,myClass, tp_string("__get__"), tp_fnc(vm,zzpy__pyDFMenu_get));
  tp_set(vm,myClass, tp_string("help"), tp_fnc(vm,zzpy__pyDFMenu_help));
  return myClass;
}
コード例 #2
0
ファイル: kolibri_net.c プロジェクト: ashmew2/kolibriosSVN
tp_obj kolibri_socket_module(TP)
{
    tp_obj socket_mod = tp_dict(tp);

    tp_set(tp, socket_mod, tp_string("AF_INET"), tp_number(AF_INET));
    tp_set(tp, socket_mod, tp_string("SOCK_STREAM"), tp_number(SOCK_STREAM));
    tp_set(tp, socket_mod, tp_string("SOCK_DGRAM"), tp_number(SOCK_DGRAM));
    tp_set(tp, socket_mod, tp_string("inet_pton"), tp_fnc(tp, kolibri_inet_pton));
    tp_set(tp, socket_mod, tp_string("socket"), tp_fnc(tp, kolibri_socket));
    return socket_mod;
}
コード例 #3
0
ファイル: init.c プロジェクト: Saruta/pyr0
void cpuinfo_init(TP)
{
	/* module */
	tp_obj cpuinfo_mod = tp_dict(tp);

	/* methods */
	tp_set(tp, cpuinfo_mod, tp_string("processor"),
	       tp_fnc(tp, cpuinfo_processor));
	tp_set(tp, cpuinfo_mod, tp_string("vendor_id"),
	       tp_fnc(tp, cpuinfo_vendor_id));
	tp_set(tp, cpuinfo_mod, tp_string("cpu_family"),
	       tp_fnc(tp, cpuinfo_cpu_family));
	tp_set(tp, cpuinfo_mod, tp_string("model"),
	       tp_fnc(tp, cpuinfo_model));
	tp_set(tp, cpuinfo_mod, tp_string("model_name"),
	       tp_fnc(tp, cpuinfo_model_name));
	tp_set(tp, cpuinfo_mod, tp_string("stepping"),
	       tp_fnc(tp, cpuinfo_stepping));
	tp_set(tp, cpuinfo_mod, tp_string("flags"),
	       tp_fnc(tp, cpuinfo_flags));
	tp_set(tp, cpuinfo_mod, tp_string("cpuinfo"),
	       tp_fnc(tp, cpuinfo_cpuinfo));

	/* special attributes */
	tp_set(tp, cpuinfo_mod, tp_string("__doc__"),
	       tp_string(help));
	tp_set(tp, cpuinfo_mod, tp_string("__name__"), tp_string("cpuinfo"));
	tp_set(tp, cpuinfo_mod, tp_string("__file__"), tp_string(__FILE__));

	/* bind */
	tp_set(tp, tp->modules, tp_string("cpuinfo"), cpuinfo_mod);
}
コード例 #4
0
ファイル: init.c プロジェクト: ashmew2/kolibriosSVN
/*
 * init math module, namely, set its dictionary
 */
void math_init(TP)
{
    /*
     * new a module dict for math
     */
    tp_obj math_mod = tp_dict(tp);

    /*
     * initialize pi and e
     */
    math_pi = tp_number(M_PI);
    math_e  = tp_number(M_E);

    /*
     * bind math functions to math module
     */
    tp_set(tp, math_mod, tp_string("pi"), math_pi);
    tp_set(tp, math_mod, tp_string("e"), math_e);
    tp_set(tp, math_mod, tp_string("acos"), tp_fnc(tp, math_acos));
    tp_set(tp, math_mod, tp_string("asin"), tp_fnc(tp, math_asin));
    tp_set(tp, math_mod, tp_string("atan"), tp_fnc(tp, math_atan));
    tp_set(tp, math_mod, tp_string("atan2"), tp_fnc(tp, math_atan2));
    tp_set(tp, math_mod, tp_string("ceil"), tp_fnc(tp, math_ceil));
    tp_set(tp, math_mod, tp_string("cos"), tp_fnc(tp, math_cos));
    tp_set(tp, math_mod, tp_string("cosh"), tp_fnc(tp, math_cosh));
    tp_set(tp, math_mod, tp_string("degrees"), tp_fnc(tp, math_degrees));
    tp_set(tp, math_mod, tp_string("exp"), tp_fnc(tp, math_exp));
    tp_set(tp, math_mod, tp_string("fabs"), tp_fnc(tp, math_fabs));
    tp_set(tp, math_mod, tp_string("floor"), tp_fnc(tp, math_floor));
    tp_set(tp, math_mod, tp_string("fmod"), tp_fnc(tp, math_fmod));
    tp_set(tp, math_mod, tp_string("frexp"), tp_fnc(tp, math_frexp));
    tp_set(tp, math_mod, tp_string("hypot"), tp_fnc(tp, math_hypot));
    tp_set(tp, math_mod, tp_string("ldexp"), tp_fnc(tp, math_ldexp));
    tp_set(tp, math_mod, tp_string("log"), tp_fnc(tp, math_log));
    tp_set(tp, math_mod, tp_string("log10"), tp_fnc(tp, math_log10));
    tp_set(tp, math_mod, tp_string("modf"), tp_fnc(tp, math_modf));
    tp_set(tp, math_mod, tp_string("pow"), tp_fnc(tp, math_pow));
    tp_set(tp, math_mod, tp_string("radians"), tp_fnc(tp, math_radians));
    tp_set(tp, math_mod, tp_string("sin"), tp_fnc(tp, math_sin));
    tp_set(tp, math_mod, tp_string("sinh"), tp_fnc(tp, math_sinh));
    tp_set(tp, math_mod, tp_string("sqrt"), tp_fnc(tp, math_sqrt));
    tp_set(tp, math_mod, tp_string("tan"), tp_fnc(tp, math_tan));
    tp_set(tp, math_mod, tp_string("tanh"), tp_fnc(tp, math_tanh));

    /*
     * bind special attributes to math module
     */
    tp_set(tp, math_mod, tp_string("__doc__"), 
            tp_string(
                "This module is always available.  It provides access to the\n"
                "mathematical functions defined by the C standard."));
    tp_set(tp, math_mod, tp_string("__name__"), tp_string("math"));
    tp_set(tp, math_mod, tp_string("__file__"), tp_string(__FILE__));

    /*
     * bind to tiny modules[]
     */
    tp_set(tp, tp->modules, tp_string("math"), math_mod);
}