Sha256: 4d2b68c23bcd1ec019c22d6bd9df4fd734aa8f01b744616a686c439dfef557e7

Contents?: true

Size: 1.52 KB

Versions: 16

Compression:

Stored size: 1.52 KB

Contents

#include "ruby.h"
#include "logging/RhoLog.h"
#include "syscall.h"

#undef DEFAULT_LOGCATEGORY
#define DEFAULT_LOGCATEGORY "RhoSysCall"

extern void _rho_ext_syscall(PARAMS_WRAPPER* params);

VALUE rho_sys_makephonecall(const char* callname, int nparams, char** param_names, char** param_values) {
	PARAMS_WRAPPER params = {nparams,param_names,param_values,callname,0};
	PARAMS_WRAPPER* ret;
	VALUE ret_value = Qnil;
	int i;
	
	//Check if we need to do syscall on UI thread
	for (i=0;i<nparams;i++) {
		if (strcmp("thread",param_names[i]) == 0) {
			if (strcmp("ui",param_values[i]) == 0) {
				RAWLOG_INFO("SysCall on UI theread...\n");
				params._call_on_ui_thread = 1;
			}
			break;
		}
	}	

	if (params._call_on_ui_thread) {
		// Switching to UI thread
		// There is no return parameters because syscall on UI thread will be done asynchronously
		_rho_ext_syscall(&params);
	} else {
		// Doing syscall on "ruby" thread; this call is done syncronously
		ret = do_syscall(&params);
		if (ret!=NULL) {
			VALUE hash = rb_hash_new();
			RAWLOG_INFO("Add to return hash:\n");
			for (i=0;i<ret->_nparams;i++) {
				RAWLOG_INFO2("%s => %s\n",ret->_names[i],ret->_values[i]);
				if (ret->_names[i] && ret->_values[i])
					rb_hash_aset(hash, rb_str_new2(ret->_names[i]), rb_str_new2(ret->_values[i]));
				if (ret->_names[i]) free(ret->_names[i]);
				if (ret->_values[i]) free(ret->_values[i]);
			}	
			if (ret->_names) free(ret->_names);
			if (ret->_values) free(ret->_values);
			free(ret);			
			ret_value = hash;
		}
	}
	
	return ret_value;
}

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rhodes-2.0.0.beta11 platform/iphone/rhoextlib/syscall.c
rhodes-2.0.0.beta10 platform/iphone/rhoextlib/syscall.c
rhodes-2.0.0.beta9 platform/iphone/rhoextlib/syscall.c
rhodes-2.0.0.beta8 platform/iphone/rhoextlib/syscall.c
rhodes-2.0.0.beta7 platform/iphone/rhoextlib/syscall.c
rhodes-2.0.0.beta6 platform/iphone/rhoextlib/syscall.c
rhodes-2.0.0.beta4 platform/iphone/rhoextlib/syscall.c
rhodes-2.0.0.beta3 platform/iphone/rhoextlib/syscall.c
rhodes-1.5.5 platform/iphone/rhoextlib/syscall.c
rhodes-2.0.0.beta2 platform/iphone/rhoextlib/syscall.c
rhodes-2.0.0.beta1 platform/iphone/rhoextlib/syscall.c
rhodes-1.5.4 platform/iphone/rhoextlib/syscall.c
rhodes-1.5.3 platform/iphone/rhoextlib/syscall.c
rhodes-1.5.2 platform/iphone/rhoextlib/syscall.c
rhodes-1.5.1 platform/iphone/rhoextlib/syscall.c
rhodes-1.5.0 platform/iphone/rhoextlib/syscall.c