Beispiel #1
0
int main(int argc, char **argv) {
    // Debug flags
    debug_gc = getEnvFlag("MINILISP_DEBUG_GC");
    always_gc = getEnvFlag("MINILISP_ALWAYS_GC");

    // Memory allocation
    memory = alloc_semispace();

    // Constants and primitives
    Symbols = Nil;
    void *root = NULL;
    DEFINE2(env, expr);
    *env = make_env(root, &Nil, &Nil);
    define_constants(root, env);
    define_primitives(root, env);

    // The main loop
    printf("%s", ">");
    for (;;) {
        *expr = read_expr(root);
        if (!*expr)
            return 0;
        if (*expr == Cparen)
            error("Stray close parenthesis");
        if (*expr == Dot)
            error("Stray dot");
        print(eval(root, env, expr));
        printf("\n%s", ">");
    }
}
Beispiel #2
0
void Init_alf(VALUE module)
{
  VALUE mALF;
  mALF = rb_define_module_under(module, "ALF");
  cWspace = rb_define_class_under(mALF, "Workspace", cGSL_Object);
  rb_define_singleton_method(cWspace, "alloc", rb_alf_alloc, 1);
  rb_define_singleton_method(mALF, "alloc", rb_alf_alloc, 1);
  rb_define_module_function(module, "alf_alloc", rb_alf_alloc, 1);

  rb_define_method(cWspace, "params", rb_alf_params, 3);

  rb_define_method(cWspace, "Plm_array", rb_alf_Plm_array, -1);
  rb_define_method(cWspace, "Plm_deriv_array", rb_alf_Plm_deriv_array, -1);

  rb_define_module_function(mALF, "array_size", rb_alf_array_size, 1);
  rb_define_module_function(mALF, "array_index", rb_alf_array_index, 2);

  define_constants(mALF);
}
Beispiel #3
0
int main() {
    // Debug flags
    debug_gc = getEnvFlag("MINILISP_DEBUG_GC");
    always_gc = getEnvFlag("MINILISP_ALWAYS_GC");

    // Memory allocation
    memory = (void *)memory1;

    // Init constants
    Obj trueObj, nilObj, dotObj, cparenObj;
    True = &trueObj;
    Nil = &nilObj;
    Dot = &dotObj;
    Cparen = &cparenObj;
    True->type = TTRUE;
    Nil->type = TNIL;
    Dot->type = TDOT;
    Cparen->type = TCPAREN;

    // Constants and primitives
    Symbols = Nil;
    void *root = NULL;
    DEFINE2(env, expr);
    *env = make_env(root, &Nil, &Nil);
    define_constants(root, env);
    define_primitives(root, env);

    // The main loop
    for (;;) {
        setjmp(&jmpbuf);
        *expr = read_expr(root);
        if (!*expr)
            return 0;
        if (*expr == Cparen)
            error("Stray close parenthesis");
        if (*expr == Dot)
            error("Stray dot");
        print(eval(root, env, expr));
        printf("\n");
    }
}
PyMODINIT_FUNC initUART(void)
#endif
{
    PyObject *module = NULL;

#if PY_MAJOR_VERSION > 2
    if ((module = PyModule_Create(&bbuartmodule)) == NULL)
       return NULL;
#else
    if ((module = Py_InitModule3("UART", uart_methods, moduledocstring)) == NULL)
       return;
#endif

   define_constants(module);


#if PY_MAJOR_VERSION > 2
    return module;
#else
    return;
#endif
}
Beispiel #5
0
PyMODINIT_FUNC initSOFTPWM(void)
#endif
{
    PyObject *module = NULL;

#if PY_MAJOR_VERSION > 2
    if ((module = PyModule_Create(&chipspwmmodule)) == NULL)
       return NULL;
#else
    if ((module = Py_InitModule3("SOFTPWM", pwm_methods, moduledocstring)) == NULL)
       return;
#endif

   define_constants(module);


#if PY_MAJOR_VERSION > 2
    return module;
#else
    return;
#endif
}
PyMODINIT_FUNC initGPIO(void)
#endif
{
   int i;
   PyObject *module = NULL;

#if PY_MAJOR_VERSION > 2
   if ((module = PyModule_Create(&rpigpiomodule)) == NULL)
      return NULL;
#else
   if ((module = Py_InitModule3("RPi.GPIO", rpi_gpio_methods, moduledocstring)) == NULL)
      return;
#endif

   define_constants(module);

   for (i=0; i<54; i++)
      gpio_direction[i] = -1;

   // detect board revision and set up accordingly
   revision = get_rpi_revision();
   if (revision == -1)
   {
      PyErr_SetString(PyExc_RuntimeError, "This module can only be run on a Raspberry Pi!");
      setup_error = 1;
#if PY_MAJOR_VERSION > 2
      return NULL;
#else
      return;
#endif
   } else if (revision == 1) {
      pin_to_gpio = &pin_to_gpio_rev1;
   } else if (revision == 2) {
      pin_to_gpio = &pin_to_gpio_rev2;
   } else { // assume model B+
      pin_to_gpio = &pin_to_gpio_rev3;
   }

   rpi_revision = Py_BuildValue("i", revision);
   PyModule_AddObject(module, "RPI_REVISION", rpi_revision);

   // Add PWM class
   if (PWM_init_PWMType() == NULL)
#if PY_MAJOR_VERSION > 2
      return NULL;
#else
      return;
#endif
   Py_INCREF(&PWMType);
   PyModule_AddObject(module, "PWM", (PyObject*)&PWMType);

   if (!PyEval_ThreadsInitialized())
      PyEval_InitThreads();

   // register exit functions - last declared is called first
   if (Py_AtExit(cleanup) != 0)
   {
      setup_error = 1;
      cleanup();
#if PY_MAJOR_VERSION > 2
      return NULL;
#else
      return;
#endif
   }

   if (Py_AtExit(event_cleanup_all) != 0)
   {
      setup_error = 1;
      cleanup();
#if PY_MAJOR_VERSION > 2
      return NULL;
#else
      return;
#endif
   }

#if PY_MAJOR_VERSION > 2
   return module;
#else
   return;
#endif
}
Beispiel #7
0
LUALIB_API int luaopen_lua_glu(lua_State* L) {
    luaL_register(L, "glu", funcs);
    define_constants(L);
    return 1;
}
Beispiel #8
0
PyMODINIT_FUNC initGPIO(void)
#endif
{
   int i;
   PyObject *module = NULL;
   char cpuRev[1024] = {'\0'};
   
#if PY_MAJOR_VERSION > 2
   if ((module = PyModule_Create(&lmkgpiomodule)) == NULL)
      return NULL;
#else
   if ((module = Py_InitModule3("LMK.GPIO", lmk_gpio_methods, moduledocstring)) == NULL)
      return;
#endif

   if (get_cpuinfo_revision(cpuRev) == NULL)
#if PY_MAJOR_VERSION > 2
	return NULL;
#else
	return;
#endif
   
    revision = get_lmk_revision();
    debug("BOARD: revision(%d)\n",revision);
	
   define_constants(module);

   for (i=0; i<256; i++)
      gpio_direction[i] = -1;

   if (revision == -1)
   {
      PyErr_SetString(PyExc_RuntimeError, "This module can only be run on a Raspberry Pi!");
      setup_error = 1;
#if PY_MAJOR_VERSION > 2
      return NULL;
#else
      return;
#endif
   } 
   
   lmk_revision = Py_BuildValue("i", revision);
   PyModule_AddObject(module, "LMK_REVISION", lmk_revision);


   // Add PWM class
   if (PWM_init_PWMType() == NULL){
#if PY_MAJOR_VERSION > 2
      return NULL;
#else
      return;
#endif
    }

   Py_INCREF(&PWMType);
   PyModule_AddObject(module, "PWM", (PyObject*)&PWMType);

   if (!PyEval_ThreadsInitialized()){
      PyEval_InitThreads();

   }
   
   //Initialized only once
    if (mmap_gpio_mem())
#if PY_MAJOR_VERSION > 2
      return NULL;
#else
      return;
#endif
	
   // register exit functions - last declared is called first
   if (Py_AtExit(cleanup) != 0)
   {
      setup_error = 1;
      cleanup();


#if PY_MAJOR_VERSION > 2
      return NULL;
#else
      return;
#endif
   }

   if (Py_AtExit(event_cleanup_all) != 0)
   {
      setup_error = 1;
      cleanup();


#if PY_MAJOR_VERSION > 2
      return NULL;
#else
      return;
#endif
   }

#if PY_MAJOR_VERSION > 2

   return module;
#else

   return;
#endif
}
Beispiel #9
0
void Init_Console_ext(void)
{
   rb_mWin32 = rb_define_module("Win32");
   rb_define_const(rb_mKernel, "Win32", rb_mWin32);

   rb_mConsole = rb_define_class_under(rb_mWin32, "Console", rb_cObject);

   // Handle Constants
   rb_mConstants = rb_define_module_under(rb_mConsole,"Constants");
   define_constants();

   // Handle API
   rb_mAPI = rb_define_class_under(rb_mConsole, "API", rb_cObject);
   
   RB_DEF_API_METHOD(constant, 1); //OK

   RB_DEF_API_METHOD(AllocConsole, 0);
   
   RB_DEF_API_METHOD(CreateConsoleScreenBuffer, 3); //OK
   
   RB_DEF_API_METHOD(FillConsoleOutputAttribute, 5); //OK
   RB_DEF_API_METHOD(FillConsoleOutputCharacter, 5); //OK
//     RB_DEF_API_METHOD(FillConsoleInputBuffer, 1); // Does not exist anymore
   
   RB_DEF_API_METHOD(FreeConsole, 0);
   
   RB_DEF_API_METHOD(GenerateConsoleCtrlEvent, 2);
   
   RB_DEF_API_METHOD(GetConsoleCP, 0); //OK
   RB_DEF_API_METHOD(GetConsoleCursorInfo, 1); //OK
   RB_DEF_API_METHOD(GetConsoleMode, 1);
   RB_DEF_API_METHOD(GetConsoleOutputCP, 0);
   RB_DEF_API_METHOD(GetConsoleScreenBufferInfo, 1); //OK
   RB_DEF_API_METHOD(GetConsoleTitle, 0);
   RB_DEF_API_METHOD(GetConsoleWindow, 0);
   RB_DEF_API_METHOD(GetLargestConsoleWindowSize, 1);
   RB_DEF_API_METHOD(GetNumberOfConsoleInputEvents, 1);
   RB_DEF_API_METHOD(GetNumberOfConsoleMouseButtons, 0);
   
   RB_DEF_API_METHOD(GetStdHandle, 1); //OK
   
   RB_DEF_API_METHOD(PeekConsoleInput, 1); //OK
   RB_DEF_API_METHOD(ReadConsole, 3); //OK
   RB_DEF_API_METHOD(ReadConsoleInput, 1); //OK
   
   RB_DEF_API_METHOD(ReadConsoleOutput, 10);  // OK
   RB_DEF_API_METHOD(ReadConsoleOutputAttribute, 4);  // OK
   RB_DEF_API_METHOD(ReadConsoleOutputCharacter, 5);  // OK

   
   RB_DEF_API_METHOD(ScrollConsoleScreenBuffer, 13); //OK
   
   RB_DEF_API_METHOD(SetConsoleActiveScreenBuffer, 1);
   RB_DEF_API_METHOD(SetConsoleCP, 1);
   RB_DEF_API_METHOD(SetConsoleCursorPosition, 3);
   RB_DEF_API_METHOD(SetConsoleCursorInfo, 3);
   RB_DEF_API_METHOD(SetConsoleMode, 2); //OK
   RB_DEF_API_METHOD(SetConsoleOutputCP, 1);
   RB_DEF_API_METHOD(SetConsoleScreenBufferSize, 3);
   RB_DEF_API_METHOD(SetConsoleTextAttribute, 2);
   RB_DEF_API_METHOD(SetConsoleTitle, 1); //OK
   RB_DEF_API_METHOD(SetConsoleWindowInfo, 6);
   
   RB_DEF_API_METHOD(SetStdHandle, 2);
   
   RB_DEF_API_METHOD(WriteConsole, 2);
   RB_DEF_API_METHOD(WriteFile, 2);
   
   RB_DEF_API_METHOD(WriteConsoleInput, -1);
   RB_DEF_API_METHOD(WriteConsoleOutput, 10);
   RB_DEF_API_METHOD(WriteConsoleOutputAttribute, 4);
   RB_DEF_API_METHOD(WriteConsoleOutputCharacter, 4);
 
}
Beispiel #10
0
int main(int argc, char* argv[]) {
    define_constants();
    return do_tests(2);
}