Example #1
0
float * val_array_float(hx::Object * arg1)
{
   Array_obj<float> *a = dynamic_cast< Array_obj<float> * >(arg1);
   if (a==0)
      return 0;
   return (float *)a->GetBase();
}
Example #2
0
// Array access - fast if possible - may return null
// Resizing the array may invalidate the pointer
bool * val_array_bool(hx::Object * arg1)
{
   Array_obj<bool> *a = dynamic_cast< Array_obj<bool> * >(arg1);
   if (a==0)
      return 0;
   return (bool *)a->GetBase();
}
Example #3
0
double * val_array_double(hx::Object * arg1)
{
   Array_obj<double> *a = dynamic_cast< Array_obj<double> * >(arg1);
   if (a==0)
      return 0;
   return (double *)a->GetBase();
}
Example #4
0
/**
	file_contents : f:string -> string
	<doc>Read the content of the file [f] and return it.</doc>
**/
static value file_contents( value name ) {
	using namespace Kore;
	buffer s=0;
	int len;
	val_check(name,string);
	fio f(val_filename(name));
	const char* fname = val_string(name);
	gc_enter_blocking();
	{
		FileReader file;
		if (file.open(fname)) {
			len = static_cast<int>(file.size());
			#ifdef SYS_WIIU
			void* data = file.readAll();
			Array_obj<unsigned char>* b = new Array_obj<unsigned char>(len, len);
			memcpy(b->GetBase(), data, len);
			s = (buffer)b;
			#else
			s = alloc_buffer_len(len);
			file.read(buffer_data(s), static_cast<uint>(len));
			#endif
		}
		else {
			file_error("file_contents", &f);
		}
	}
	gc_exit_blocking();
	return buffer_val(s);
}