Example #1
0
int user_open_source (char **argv, int argc, double area,
		      double cosx, double cosy, double cosz)
{
   char *file;
   int status;

   if (-1 == init_slang ())
     return -1;
   
   file = argv[0];
   if ((argc == 0) || (NULL == (file = argv[0])))
     {
	fprintf (stderr, "No filename specified for the slang source\n");
	return -1;
     }

   if (0 != SLang_load_file (file))
     {
	fprintf (stderr, "Encountered a problem loading %s\n", file);
	return -1;
     }

   if (NULL == (Open_Source = SLang_get_function ("user_open_source")))
     {
	fprintf (stderr, "%s failed to define user_open_source\n", file);
	return -1;
     }

   if (NULL == (Create_Ray = SLang_get_function ("user_create_ray")))
     {
	fprintf (stderr, "%s failed to define user_create_ray\n", file);
	return -1;
     }

   if ((-1 == SLang_start_arg_list ())
       || (-1 == push_c_string_array (argv, argc))
       || (-1 == SLang_push_double (area))
       || (-1 == SLang_push_double (cosx))
       || (-1 == SLang_push_double (cosy))
       || (-1 == SLang_push_double (cosz))
       || (-1 == SLang_end_arg_list ())
       || (-1 == SLexecute_function (Open_Source))
       || (-1 == SLang_pop_integer (&status)))
     {
	SLang_verror (0, "Error occured processing user_open_source in %s", file);
	return -1;
     }

   return status;
}
Example #2
0
int main (int argc, char **argv)
{
   char *file;

   if (argc == 2)
     {
	/* fprintf (stderr, "Usage: %s <filename>\n", argv[0]); */
	file = argv[1];
	/* return 1; */
     }
   else file = NULL;

   if (-1 == SLang_init_slang ())
     return 1;

   _pSLcompile_ptr = dump_token;
   _pSLang_Compile_BOSEOS = 3;
   _pSLang_Compile_BOFEOF = 1;
   SLang_load_file (file);

   return _pSLang_Error;
}
Example #3
0
File: sltest.c Project: parke/slang
int main (int argc, char **argv)
{
   int i;
   int utf8 = 0;

   for (i = 1; i < argc; i++)
     {
	char *arg = argv[i];
	if (*arg != '-')
	  break;

	if (0 == strcmp (arg, "-utf8"))
	  {
	     utf8 = 1;
	     continue;
	  }
	i = argc;
     }

   if (i >= argc)
     {
	fprintf (stderr, "Usage: %s [-utf8] FILE...\n", argv[0]);
	return 1;
     }
   (void) SLutf8_enable (utf8);

   if ((-1 == SLang_init_all ())
       || (-1 == SLang_init_array_extra ())
       || (-1 == SLadd_intrin_fun_table (Intrinsics, NULL))
       || (-1 == add_test_classes ()))
     return 1;

   SLang_Traceback = 1;

   if (-1 == SLang_set_argc_argv (argc, argv))
     return 1;

#ifdef HAVE_FPSETMASK
# ifndef FP_X_OFL
#  define FP_X_OFL 0
# endif
# ifndef FP_X_INV
#  define FP_X_INV 0
# endif
# ifndef FP_X_DZ
#  define FP_X_DZ 0
# endif
# ifndef FP_X_DNML
#  define FP_X_DNML 0
# endif
# ifndef FP_X_UFL
#  define FP_X_UFL 0
# endif
# ifndef FP_X_IMP
#  define FP_X_IMP 0
# endif
   fpsetmask (~(FP_X_OFL|FP_X_INV|FP_X_DZ|FP_X_DNML|FP_X_UFL|FP_X_IMP));
#endif

   if (i + 1 < argc)
     Ignore_Exit = 1;

   while (i < argc)
     {
	char *file = argv[i];
	if (0 == strncmp (SLpath_extname (file), ".slc", 4))
	  {
	     char *file_sl = SLmake_string (file);
	     file_sl[strlen(file_sl)-1] = 0;
	     if (-1 == SLang_byte_compile_file (file_sl, 0))
	       {
		  SLfree (file_sl);
		  return 1;
	       }
	     SLfree (file_sl);
	  }
	if (-1 == SLang_load_file (file))
	  return 1;
	i++;
     }

   return SLang_get_error ();
}