コード例 #1
0
ファイル: NekoAPI.cpp プロジェクト: FoxInFreefall/ghostbutter
value haxe_alloc_string(const char *inString)
{
   value neko_string = alloc_string(inString);
   if (gNeko2HaxeString)
      return val_call1(*gNeko2HaxeString,neko_string);
   return neko_string;
}
コード例 #2
0
ファイル: TouchEvent.cpp プロジェクト: GumbertGumbert/lime
	void TouchEvent::Dispatch (TouchEvent* event) {
		
		if (TouchEvent::callback) {
			
			if (!init) {
				
				id_id = val_id ("id");
				id_type = val_id ("type");
				id_x = val_id ("x");
				id_y = val_id ("y");
				init = true;
				
			}
			
			value object = (TouchEvent::eventObject ? TouchEvent::eventObject->get () : alloc_empty_object ());
			
			alloc_field (object, id_id, alloc_int (event->id));
			alloc_field (object, id_type, alloc_int (event->type));
			alloc_field (object, id_x, alloc_float (event->x));
			alloc_field (object, id_y, alloc_float (event->y));
			
			val_call1 (TouchEvent::callback->get (), object);
			
		}
		
	}
コード例 #3
0
ファイル: builtins.c プロジェクト: ConstNW/neko
static value varargs_callback( value *args, int nargs ) {
	value f = NEKO_VM()->env;
	value a = alloc_array(nargs);
	int i;
	for(i=0;i<nargs;i++)
		val_array_ptr(a)[i] = args[i];
	return val_call1(f,a);
}
コード例 #4
0
ファイル: ExternalInterface.cpp プロジェクト: gameduell/input
JAVA_EXPORT void JNICALL Java_org_haxe_duell_input_DuellInputNativeInterface_startTouchInfoBatch(JNIEnv * env, jobject obj, jint count)
{
	AutoHaxe haxe("startTouchInfoBatch");

	__touchCount = count;

	val_call1(*__onTouchBatchStartCallback, __touchCountValue);
}
コード例 #5
0
ファイル: ByteArray.cpp プロジェクト: caivega/lime
	ByteArray::ByteArray (const QuickVec<uint8> &inData) {
		
		mValue = val_call1 (gByteArrayCreate->get (), alloc_int (inData.size ()));
		uint8 *bytes = Bytes ();
		if (bytes)
			memcpy (bytes, &inData[0], inData.size ());
		
	}
コード例 #6
0
ファイル: ByteArray.cpp プロジェクト: caivega/lime
	void ByteArray::Resize (int inSize) {
		
		if (mValue == 0)
			mValue = val_call1 (gByteArrayCreate->get (), alloc_int (inSize));
		else
			val_call2 (gByteArrayResize->get (), mValue, alloc_int (inSize));
		
	}
コード例 #7
0
ファイル: Scene.cpp プロジェクト: Amadren/hx-gameplay
 bool visitWrapper(Node *node)
 {
     bool result =
             val_get_bool(val_call1(
                     clbkVisitMethod.get(),
                     ReferenceToValue(node, true)
                 ));
     return result;
 }
コード例 #8
0
ファイル: mod_neko.c プロジェクト: HaxeFoundation/neko
static value init_module() {
	neko_vm *vm = neko_vm_current();
	mcontext *ctx = CONTEXT();
	value env = vm->env;
	ctx->main = NULL;
	val_call1(val_array_ptr(env)[0],val_array_ptr(env)[1]);
	cache_module(ctx->r->filename,FTIME(ctx->r),ctx->main);
	return val_null;
}
コード例 #9
0
ファイル: ssl.c プロジェクト: jonasmalacofilho/neko
static int sni_callback( void *arg, mbedtls_ssl_context *ctx, const unsigned char *name, size_t len ){
	if( name && arg ){
	 	value ret = val_call1((value)arg, alloc_string((const char*)name)) ;
		if( !val_is_null(ret) ){
			// TODO authmode and ca
			return mbedtls_ssl_set_hs_own_cert( ctx, val_cert(val_field(ret, val_id("cert"))), val_pkey(val_field(ret, val_id("key"))) );
		}
	}
	return -1;
}
コード例 #10
0
ファイル: ExternalInterface.cpp プロジェクト: gameduell/input
JAVA_EXPORT void JNICALL Java_org_haxe_duell_input_DuellInputNativeInterface_touchInfo(JNIEnv * env, jobject obj, jint identifier, jfloat x, jfloat y, jint state)
{
	AutoHaxe haxe("onTouchInfo");

	__touch.id = identifier;
	__touch.state = state;
	__touch.x = x;
	__touch.y = y;

	val_call1(*__onTouchCallback, __touchValue);
}
コード例 #11
0
ファイル: ExternalInterface.cpp プロジェクト: fserb/RTMidi
void _rtmidi_in_callback(double deltatime,
                         std::vector<unsigned char> *message,
                         void *userData) {
  int top = 0;
  gc_set_top_of_stack(&top, true);

  value ret = alloc_array(message->size());
  for (int i = 0; i < message->size(); ++i) {
    val_array_set_i(ret, i, alloc_int((*message)[i]));
  }
  val_call1(callback_root->get(), ret);
  gc_set_top_of_stack(0,true);
}
コード例 #12
0
ファイル: ValuePointer.cpp プロジェクト: haxiomic/lime
	void* ValuePointer::Call (void* arg0) {

		if (!hlValue) {

			return val_call1 ((value)Get (), (value)arg0);

		} else {

			vdynamic* arg = (vdynamic*) arg0;
			return hl_dyn_call ((vclosure*)hlValue, &arg, 1);

		}

	}
コード例 #13
0
ファイル: ByteArray.cpp プロジェクト: caivega/lime
	const unsigned char *ByteArray::Bytes () const {
		
		value bytes = val_call1 (gByteArrayBytes->get (), mValue);
		
		if (val_is_string (bytes))
			return (unsigned char *)val_string (bytes);
		
		buffer buf = val_to_buffer (bytes);
		
		if (buf == 0) {
			
			val_throw (alloc_string ("Bad ByteArray"));
		}
		
		return (unsigned char *)buffer_data (buf);
		
	}
コード例 #14
0
ファイル: hxfcgi.cpp プロジェクト: RudolfVonKrugstein/hxfcgi
value hxfcgi_cache_module(value func) {
	val_check_function(func,1);
	hxfcgi::Request *req;
	while (true) {
		try {
			if(FCGX_IsCGI()) break;
			req = new hxfcgi::Request();
			val_call1(func,alloc_abstract(hxRequest,req));
			delete req;
		}
		catch (string error) {
			hx_failure(error.c_str());
			break;
		}
	}
	return val_null;
	
}
コード例 #15
0
/**
	regexp_replace_fun : 'regexp -> from:string -> f:('regexp -> any) -> string
	<doc>Perform a replacement of all matched substrings by calling [f] for every match</doc>
**/
static value regexp_replace_fun( value o, value s, value f ) {
	val_check_kind(o,k_regexp);
	val_check(s,string);
	val_check_function(f,1);
	{
		pcredata *d = PCRE(o);
		buffer b = alloc_buffer(NULL);
		int pos = 0;
		int len = val_strlen(s);
		const char *str = val_string(s);
		d->str = s;
		while( pcre_exec(d->r,NULL,str,len,pos,0,d->matchs,d->nmatchs * 3) >= 0 ) {
			buffer_append_sub(b,str+pos,d->matchs[0] - pos);
			val_buffer(b,val_call1(f,o));
			pos = d->matchs[1];
		}
		d->str = alloc_null();
		buffer_append_sub(b,str+pos,len-pos);
		return buffer_to_string(b);
	}
}
コード例 #16
0
ファイル: ByteArray.cpp プロジェクト: caivega/lime
	ByteArray::ByteArray (const OSChar *inFilename) {
		
		FILE_HANDLE *file = lime::fopen (inFilename, "rb");
		
		if (!file) {
			
			//#ifdef ANDROID
			//return AndroidGetAssetBytes(inFilename);
			//#endif
			return;
			
		}
		
		lime::fseek (file, 0, SEEK_END);
		int len = lime::ftell (file);
		lime::fseek (file, 0, SEEK_SET);
		
		mValue = val_call1 (gByteArrayCreate->get (), alloc_int (len));
		
		int status = lime::fread (Bytes (), len, 1, file);
		lime::fclose (file);
		
	}
コード例 #17
0
ファイル: NekoAPI.cpp プロジェクト: FoxInFreefall/ghostbutter
value  api_alloc_array(int arg1)
{
   if (!gNekoNewArray)
	   return alloc_array(arg1);
	return val_call1(*gNekoNewArray,alloc_int(arg1));
}
コード例 #18
0
ファイル: ByteArray.cpp プロジェクト: caivega/lime
	ByteArray::ByteArray (int inSize) {
		
		mValue = val_call1 (gByteArrayCreate->get (), alloc_int (inSize));
		
	}
コード例 #19
0
ファイル: NekoAPI.cpp プロジェクト: FoxInFreefall/ghostbutter
value  api_val_call1(value  arg1,value  arg2)
{
	return val_call1(arg1,arg2);
}
コード例 #20
0
ファイル: mysql.c プロジェクト: bsmr-haxe/neko
/**
	result_next : 'result -> object?
	<doc>
	Return the next row if available. A row is represented
	as an object, which fields have been converted to the
	corresponding Neko value (int, float or string). For
	Date and DateTime you can specify your own conversion
	function using [result_set_conv_date]. By default they're
	returned as plain strings. Additionally, the TINYINT(1) will
	be converted to either true or false if equal to 0.
	</doc>
**/
static value result_next( value o ) {
	result *r;
	unsigned long *lengths = NULL;
	MYSQL_ROW row;
	val_check_kind(o,k_result);
	r = RESULT(o);
	row = mysql_fetch_row(r->r);
	if( row == NULL )
		return val_null;
	{
		int i;
		value cur = alloc_object(NULL);
		r->current = row;
		for(i=0;i<r->nfields;i++)
			if( row[i] != NULL ) {
				value v;
				switch( r->fields_convs[i] ) {
				case CONV_INT:
					v = alloc_best_int(atoi(row[i]));
					break;
				case CONV_STRING:
					v = alloc_string(row[i]);
					if( r->conv_string != NULL )
						v = val_call1(r->conv_string,v);
					break;
				case CONV_BOOL:
					v = alloc_bool( *row[i] != '0' );
					break;
				case CONV_FLOAT:
					v = alloc_float(atof(row[i]));
					break;
				case CONV_BINARY:
					if( lengths == NULL ) {
						lengths = mysql_fetch_lengths(r->r);
						if( lengths == NULL )
							val_throw(alloc_string("mysql_fetch_lengths"));
					}
					v = copy_string(row[i],lengths[i]);
					if( r->conv_bytes != NULL )
						v = val_call1(r->conv_bytes,v);
					break;
				case CONV_DATE:
					if( r->conv_date == NULL )
						v = alloc_string(row[i]);
					else {
						struct tm t;
						sscanf(row[i],"%4d-%2d-%2d",&t.tm_year,&t.tm_mon,&t.tm_mday);
						t.tm_hour = 0;
						t.tm_min = 0;
						t.tm_sec = 0;
						t.tm_isdst = -1;
						t.tm_year -= 1900;
						t.tm_mon--;
						v = val_call1(r->conv_date,alloc_int32((int)mktime(&t)));
					}
					break;
				case CONV_DATETIME:
					if( r->conv_date == NULL )
						v = alloc_string(row[i]);
					else {
						struct tm t;
						sscanf(row[i],"%4d-%2d-%2d %2d:%2d:%2d",&t.tm_year,&t.tm_mon,&t.tm_mday,&t.tm_hour,&t.tm_min,&t.tm_sec);
						t.tm_isdst = -1;
						t.tm_year -= 1900;
						t.tm_mon--;
						v = val_call1(r->conv_date,alloc_int32((int)mktime(&t)));
					}
					break;
				default:
					v = val_null;
					break;
				}
				alloc_field(cur,r->fields_ids[i],v);
			}
		return cur;
	}
}
コード例 #21
0
ファイル: misc.c プロジェクト: MattTuttle/neko
static void print_callback( const char *s, int size, void *f ) {	
	val_call1(f,copy_string(s,size));
}
コード例 #22
0
ファイル: hx_Game.cpp プロジェクト: josephzizys/hx-gameplay
 void render(float elapsedTime)
 {
     val_call1(clbkRender.get(), alloc_float(elapsedTime));
 }
コード例 #23
0
ファイル: NekoAPI.cpp プロジェクト: FoxInFreefall/ghostbutter
value api_alloc_string_len(const char *inStr,int inLen)
{
	if (gNeko2HaxeString)
		return val_call1(*gNeko2HaxeString,copy_string(inStr,inLen));
   return copy_string(inStr,inLen);
}
コード例 #24
0
ファイル: ByteArray.cpp プロジェクト: caivega/lime
	int ByteArray::Size () const {
		
		return val_int (val_call1 (gByteArrayLen->get (), mValue));
		
	}
コード例 #25
0
ファイル: serialize.c プロジェクト: MattTuttle/neko
static value unserialize_rec( sbuffer *b, value loader ) {
	switch( read_char(b) ) {
	case 'N':
		return val_null;
	case 'T':
		return val_true;
	case 'F':
		return val_false;
	case 'i':
		return alloc_int(read_int(b));
	case 'I':
		return alloc_int32(read_int(b));
	case 'f':
		{
			tfloat d;
			read_str(b,sizeof(tfloat),&d);
			return alloc_float(d);
		}
	case 's':
		{
			int l = read_int(b);
			value v;
			if( l < 0 || l > max_string_size )
				ERROR();
			v = alloc_empty_string(l);
			add_ref(b,v);
			read_str(b,l,(char*)val_string(v));
			return v;
		}
	case 'o':
		{
			int f;
			value o = alloc_object(NULL);
			add_ref(b,o);
			while( (f = read_int(b)) != 0 ) {
				value fval = unserialize_rec(b,loader);
				alloc_field(o,(field)f,fval);
			}
			switch( read_char(b) ) {
			case 'p':
				{
					value v = unserialize_rec(b,loader);
					if( !val_is_object(v) )
						ERROR();
					((vobject*)o)->proto = (vobject*)v;
				}
				break;
			case 'z':
				break;
			default:
				ERROR();
			}
			return o;
		}
	case 'r':
		{
			int n = read_int(b);
			if( n < 0 || n >= b->nrefs )
				ERROR();
			return b->trefs[b->nrefs - n - 1];
		}
	case 'a':
		{
			int i;
			int n = read_int(b);
			value o;
			value *t;
			if( n < 0 || n > max_array_size )
				ERROR();
			o = alloc_array(n);
			t = val_array_ptr(o);
			add_ref(b,o);
			for(i=0;i<n;i++)
				t[i] = unserialize_rec(b,loader);
			return o;

		}
	case 'p':
		{
			int nargs = read_int(b);
			vfunction *f = (vfunction*)alloc_function((void*)1,nargs,NULL);
			vfunction *f2;
			value name;
			add_ref(b,(value)f);
			name = unserialize_rec(b,loader);
			f2 = (vfunction*)val_ocall2(loader,id_loadprim,name,alloc_int(nargs));
			if( !val_is_function(f2) || val_fun_nargs(f2) != nargs )
				failure("Loader returned not-a-function");
			f->t = f2->t;
			f->addr = f2->addr;
			f->module = f2->module;
			return (value)f;
		}
	case 'L':
		{
			vfunction *f = (vfunction*)alloc_function((void*)1,0,NULL);
			value mname;
			int pos;
			int nargs;
			value env;
			add_ref(b,(value)f);
			mname = unserialize_rec(b,loader);
			pos = read_int(b);
			nargs = read_int(b);
			env = unserialize_rec(b,loader);
			if( !val_is_array(env) )
				ERROR();
			{
				value exp = val_ocall2(loader,id_loadmodule,mname,loader);
				value mval;
				unsigned int i;
				int_val *mpos;
				neko_module *m;
				if( !val_is_object(exp) ) {
					buffer b = alloc_buffer("module ");
					val_buffer(b,mname);
					buffer_append(b," is not an object");
					bfailure(b);
				}
				mval = val_field(exp,id_module);
				if( !val_is_kind(mval,neko_kind_module) ) {
					buffer b = alloc_buffer("module ");
					val_buffer(b,mname);
					buffer_append(b," has invalid type");
					bfailure(b);
				}
				m = (neko_module*)val_data(mval);
				mpos = m->code + pos;
				for(i=0;i<m->nglobals;i++) {
					vfunction *g = (vfunction*)m->globals[i];
					if( val_is_function(g) && g->addr == mpos && g->module == m && g->nargs == nargs ) {
						f->t = VAL_FUNCTION;
						f->env = env;
						f->addr = mpos;
						f->nargs = nargs;
						f->module = m;
						return (value)f;
					}
				}
				{
					buffer b = alloc_buffer("module ");
					val_buffer(b,mname);
					buffer_append(b," has been modified");
					bfailure(b);
				}
			}
			return val_null;
		}
	case 'x':
		{
			value mname = unserialize_rec(b,loader);
			value data = unserialize_rec(b,loader);
			value exports = val_ocall2(loader,id_loadmodule,mname,loader);
			value s;
			if( !val_is_object(exports) ) {
				buffer b = alloc_buffer("module ");
				val_buffer(b,mname);
				buffer_append(b," is not an object");
				bfailure(b);
			}
			s = val_field(exports,id_unserialize);
			if( !val_is_function(s) || (val_fun_nargs(s) != 1 && val_fun_nargs(s) != VAR_ARGS) ) {
				buffer b = alloc_buffer("module ");
				val_buffer(b,mname);
				buffer_append(b," has invalid __unserialize function");
			}
			s = val_call1(s,data);
			add_ref(b,s);
			return s;
		}
	case 'h':
		{
			int i;
			vhash *h = (vhash*)alloc(sizeof(vhash));
			h->ncells = read_int(b);
			h->nitems = read_int(b);
			h->cells = (hcell**)alloc(sizeof(hcell*)*h->ncells);
			for(i=0;i<h->ncells;i++)
				h->cells[i] = NULL;
			for(i=0;i<h->nitems;i++) {
				hcell **p;
				hcell *c = (hcell*)alloc(sizeof(hcell));
				c->hkey = read_int(b);
				c->key = unserialize_rec(b,loader);
				c->val = unserialize_rec(b,loader);
				c->next = NULL;
				p = &h->cells[c->hkey % h->ncells];
				while( *p != NULL )
					p = &(*p)->next;
				*p = c;
			}
			return alloc_abstract(k_hash,h);
		}
	default:
		ERROR();
		return val_null;
	}
}
コード例 #26
0
void HaxeScreenDisplayer::delegateCall(void *param)
{
    val_call1(*clbkMethod, HandleToValueOrNull(param, NULL));
}
コード例 #27
0
ファイル: hx_Game.cpp プロジェクト: josephzizys/hx-gameplay
 void update(float elapsedTime)
 {
     val_call1(clbkUpdate.get(), alloc_float(elapsedTime));
 }