void Multiplayers_onEvent( const char *sType , const char *sArg , int statusCode ){
		#ifdef ANDROID
		//ALOG("Multiplayers_onEvent" );
		#endif
		val_call3(
					eval_onEvent_multi->get( ) ,
					alloc_string( sType ) ,
					alloc_string( sArg ),
					alloc_int( statusCode )
				);
	}
	void HypPlayServices_onEvent( const char *sType , const char *sArg , int statusCode ){
		#ifdef ANDROID
		//ALOG("hypps_onEvent" );
		#endif
		val_call3(
					eval_onEvent->get( ) ,
					alloc_string( sType ) ,
					alloc_string( sArg ),
					alloc_int( statusCode )
				);
	}
Пример #3
0
static int read_proxy( readp p, void *buf, int size ) {
	value fread = val_array_ptr(p)[0];
	value vbuf = val_array_ptr(p)[1];
	value ret;
	int len;
	if( size < 0 )
		return -1;
	if( size > READ_BUFSIZE )
		vbuf = alloc_empty_string(size);
	ret = val_call3(fread,vbuf,alloc_int(0),alloc_int(size));
	if( !val_is_int(ret) )
		return -1;
	len = val_int(ret);
	if( len < 0 || len > size )
		return -1;
	memcpy(buf,val_string(vbuf),len);
	return len;
}
Пример #4
0
	void* ValuePointer::Call (void* arg0, void* arg1, void* arg2) {

		if (!hlValue) {

			return val_call3 ((value)Get (), (value)arg0, (value)arg1, (value)arg2);

		} else {

			vdynamic* args[] = {
				(vdynamic*)arg0,
				(vdynamic*)arg1,
				(vdynamic*)arg2,
			};

			return hl_dyn_call ((vclosure*)hlValue, (vdynamic**)&args, 3);

		}

	}
Пример #5
0
value ftIterateKerningPairs( value font, value callback ) {
    if( !val_is_object(font) ) {
        ft_failure_v("not a freetype font face: ", font );
    }
    value __f = val_field( font, val_id("__f") );
    if( __f == NULL || !val_is_abstract( __f ) || !val_is_kind( __f, k_ft_face ) ) {
        ft_failure_v("not a freetype font face: ", font );
    }
    FT_Face *face = val_data( __f );

	if( !FT_HAS_KERNING((*face)) ) {
		return val_null;
	}
	

	FT_UInt left_index, right_index;
	FT_ULong left, right;
	FT_Vector vec;

    left = FT_Get_First_Char( *face, &left_index );
    while( left != 0 ) {

		right = FT_Get_First_Char( *face, &right_index );
		while( right != 0 ) {

			if( !FT_Get_Kerning( *face, left_index, right_index, FT_KERNING_UNFITTED, &vec ) && vec.x ) {
//				printf("KERNING %c_%c: %f\n", left, right, vec.x );
		        val_call3( callback, alloc_int( (int)left ), alloc_int( (int)right ), alloc_float( vec.x ) );
		    }
	        
	        right = FT_Get_Next_Char( *face, right, &right_index );
	    }
            
        left = FT_Get_Next_Char( *face, left, &left_index );
    }
		
    return val_true;
}
Пример #6
0
/**
	parse_multipart_data : onpart:function:2 -> ondata:function:3 -> void
	<doc>
	Incrementally parse the multipart data. call [onpart(name,filename)] for each part
	found and [ondata(buf,pos,len)] when some data is available
	</doc>
**/
static value parse_multipart_data( value onpart, value ondata ) {
	value buf;
	int len = 0;
	mcontext *c = CONTEXT();
	const char *ctype = ap_table_get(c->r->headers_in,"Content-Type");
	value boundstr;
	val_check_function(onpart,2);
	val_check_function(ondata,3);
	buf = alloc_empty_string(BUFSIZE);
	if( !ctype || strstr(ctype,"multipart/form-data") == NULL )
		return val_null;
	// extract boundary value
	{
		const char *boundary, *bend;
		if( (boundary = strstr(ctype,"boundary=")) == NULL )
			neko_error();
		boundary += 9;
		PARSE_HEADER(boundary,bend);
		len = (int)(bend - boundary);
		boundstr = alloc_empty_string(len+2);
		if( val_strlen(boundstr) > BUFSIZE / 2 )
			neko_error();
		val_string(boundstr)[0] = '-';
		val_string(boundstr)[1] = '-';
		memcpy(val_string(boundstr)+2,boundary,len);
	}
	len = 0;
    if( !ap_should_client_block(c->r) )
		neko_error();
	while( true ) {
		char *name, *end_name, *filename, *end_file_name, *data;
		int pos;
		// refill buffer
		// we assume here that the the whole multipart header can fit in the buffer
		fill_buffer(c,buf,&len);
		// is boundary at the beginning of buffer ?
		if( len < val_strlen(boundstr) || memcmp(val_string(buf),val_string(boundstr),val_strlen(boundstr)) != 0 )
			return discard_body(c);
		name = memfind(val_string(buf),len,"Content-Disposition:");
		if( name == NULL )
			break;
		name = memfind(name,len - (int)(name - val_string(buf)),"name=");
		if( name == NULL )
			return discard_body(c);
		name += 5;
		PARSE_HEADER(name,end_name);
		data = memfind(end_name,len - (int)(end_name - val_string(buf)),"\r\n\r\n");
		if( data == NULL )
			return discard_body(c);
		filename = memfind(name,(int)(data - name),"filename=");
		if( filename != NULL ) {
			filename += 9;
			PARSE_HEADER(filename,end_file_name);
		}
		data += 4;
		pos = (int)(data - val_string(buf));
		// send part name
		val_call2(onpart,copy_string(name,(int)(end_name - name)),filename?copy_string(filename,(int)(end_file_name - filename)):val_null);
		// read data
		while( true ) {
			const char *boundary;
			// recall buffer
			memmove(val_string(buf),val_string(buf)+pos,len - pos);
			len -= pos;
			pos = 0;
			fill_buffer(c,buf,&len);
			// lookup bounds
			boundary = memfind(val_string(buf),len,val_string(boundstr));
			if( boundary == NULL ) {
				if( len == 0 )
					return discard_body(c);
				// send as much buffer as possible to client
				if( len < BUFSIZE )
					pos = len;
				else
					pos = len - val_strlen(boundstr) + 1;
				val_call3(ondata,buf,alloc_int(0),alloc_int(pos));
			} else {
				// send remaining data
				pos = (int)(boundary - val_string(buf));
				val_call3(ondata,buf,alloc_int(0),alloc_int(pos-2));
				// recall
				memmove(val_string(buf),val_string(buf)+pos,len - pos);
				len -= pos;
				break;
			}
		}
	}
	return val_null;
}
Пример #7
0
 void gestureSwipeEvent(int x, int y, int direction)
 {
     val_call3(clbkGestureSwipeEvent.get(), alloc_int(x), alloc_int(y), alloc_int(direction));
 }
Пример #8
0
 void gesturePinchEvent(int x, int y, float scale)
 {
      val_call3(clbkGesturePinchEvent.get(), alloc_int(x), alloc_int(y), alloc_float(scale));
 }
Пример #9
0
value hxfcgi_parse_multipart_neko(value hreq, value onpart, value ondata ) {
	val_check_kind(hreq,hxRequest);
	val_check_function(onpart,2);
	val_check_function(ondata,3);
	hxfcgi::Request *req = get_request(hreq);
	char *buf;
	int len = 0;
	char *boundstr;
	hxfcgi::BasicData b;
	string ctype = b.getHeader("CONTENT_TYPE");
	if(ctype.find("multipart/form-data") != 0)
		return val_null;
	// extract boundary value
	{
		const char *boundary, *bend;
		if( (boundary = strstr(ctype.c_str(),"boundary=")) == NULL )
			neko_error();
		boundary += 9;
		PARSE_HEADER(boundary,bend);
		len = (int)(bend - boundary);
		boundstr = (char *) malloc(sizeof(char) * (len+3));
		if( strlen(boundstr) > BUFSIZE / 2 )
			neko_error();
		
		boundstr[0] = '-';
		boundstr[1] = '-';
		memcpy(boundstr+2,boundary,len);
		boundstr[len+2] = 0;
	}
	
	len = 0;
	buf = (char *) malloc(sizeof(char) * (BUFSIZE));
	while( true ) {
		char *name, *end_name, *filename, *end_file_name, *data;
		int pos;
		// refill buffer
		// we assume here that the the whole multipart header can fit in the buffer
		req->bufferFill(buf,&len);
		// is boundary at the beginning of buffer ?
		if( len < (int) strlen(boundstr) || memcmp(buf,boundstr,strlen(boundstr)) != 0 ) {
			free(boundstr);
			free(buf);
			return val_null;
		}		
		name = memfind(buf,len,"Content-Disposition:");
		if( name == NULL )
			break;
		name = memfind(name,len - (int)(name - buf),"name=");
		if( name == NULL ) {
			free(boundstr);
			free(buf);
			return val_null;
		}
		name += 5;
		PARSE_HEADER(name,end_name);
		data = memfind(end_name,len - (int)(end_name - buf),"\r\n\r\n");
		if( data == NULL ) {
			free(boundstr);
			free(buf);
			return val_null;
		}
		filename = memfind(name,(int)(data - name),"filename=");
		if( filename != NULL ) {
			filename += 9;
			PARSE_HEADER(filename,end_file_name);
		}
		data += 4;
		pos = (int)(data - buf);
		// send part name
		val_call2(onpart,copy_string(name,(int)(end_name - name)),filename?copy_string(filename,(int)(end_file_name - filename)):val_null);
		
		
		// read data
		while( true ) {
			const char *boundary;
			// recall buffer
			memcpy(buf,buf+pos,len - pos);
			len -= pos;
			pos = 0;
			req->bufferFill(buf,&len);
			// lookup bounds
			boundary = memfind(buf,len,boundstr);
			if( boundary == NULL ) {
				if( len == 0 ) {
					free(boundstr);
					free(buf);
					return val_null;
				}
				// send as much buffer as possible to client
				if( len < BUFSIZE )
					pos = len;
				else
					pos = len - strlen(boundstr) + 1;
				val_call3(ondata,copy_string(buf,pos),alloc_int(0),alloc_int(pos));
			} else {
				// send remaining data
				pos = (int)(boundary - buf);
				val_call3(ondata,copy_string(buf,pos-2),alloc_int(0),alloc_int(pos-2));
				// recall
				memcpy(buf,buf+pos,len - pos);
				len -= pos;
				break;
			}
		}
	}	
	free(boundstr);
	free(buf);
	return val_null;
}
Пример #10
0
value  api_val_call3(value  arg1,value  arg2,value  arg3,value  arg4)
{
	return val_call3(arg1,arg2,arg3,arg4);
}