Exemplo n.º 1
0
// Create and return a grace object which contains the above functions
Object module_math_init() {

    if (math_module != NULL)
        return math_module;

    srand(time(NULL));

    ClassData c = alloc_class("Module<math>", 13);
    
    add_Method(c, "asString", &math_asString);
    add_Method(c, "asDebugString", &math_asDebugString);
    add_Method(c, "sin", &math_sin);
    add_Method(c, "cos", &math_cos);
    add_Method(c, "tan", &math_tan);
    add_Method(c, "asin", &math_asin);
    add_Method(c, "acos", &math_acos);
    add_Method(c, "atan", &math_atan);
    add_Method(c, "random", &math_random);
    add_Method(c, "pi", &math_pi);
    add_Method(c, "π", &math_pi);
    add_Method(c, "sqrt", &math_sqrt);
    add_Method(c, "abs", &math_abs);

    Object o = alloc_newobj(0, c);
    math_module = o;
    gc_root(math_module);

    return o;
}
Exemplo n.º 2
0
Object module_cuda_init() {
    if (cuda_module != NULL)
        return cuda_module;
    CudaError = alloc_Exception("CudaError", ErrorObject);
    gc_root(CudaError);
    ClassData c = alloc_class("Module<cuda>", 13);
    add_Method(c, "over()map", &cuda_over_map);
    add_Method(c, "floatArray", &cuda_floatArray);
    add_Method(c, "deviceName", &cuda_deviceName);
    add_Method(c, "computeCapability", &cuda_computeCapability);
    add_Method(c, "cores", &cuda_cores);
    add_Method(c, "using()do()blockWidth()blockHeight()gridWidth()gridHeight",
        &cuda_using_do_blockWidth_blockHeight_gridWidth_gridHeight);
    add_Method(c, "using()do", &cuda_using_do);
    add_Method(c, "using()times()do", &cuda_using_times_do);
    add_Method(c, "do", &cuda_do_infer);
    add_Method(c, "do()blockWidth()blockHeight()gridWidth()gridHeight",
            &cuda_do_dimensions_infer);
    add_Method(c, "bindir", &cuda_bindir);
    add_Method(c, "includedir", &cuda_includedir);
    Object o = alloc_newobj(0, c);
    cuda_module = o;
    gc_root(o);
    return o;
}
Exemplo n.º 3
0
Object module_repl_init() {
    if (repl_module != NULL)
        return repl_module;
    ClassData c = alloc_class("Module<repl>", 12);
    add_Method(c, "asString", &Object_asString);
    add_Method(c, "registerVisitor", &repl_registerVisitor);
    add_Method(c, "createobject", &repl_createobject);
    add_Method(c, "addmethod", &repl_addmethod);
    Object o = alloc_newobj(0, c);
    repl_module = o;
    gc_root(repl_module);
    if (module_ast == NULL)
        module_ast = module_ast_init();
    if (module_interactive == NULL)
        module_interactive = module_interactive_init();
    return o;
}