예제 #1
0
	JS1_API bool STDCALL execute_command_handler(void *script_handle, void* event_handler_handle, const uint16_t *data_json, 
		const uint16_t *data_other[], int32_t other_length, uint16_t **result_json, void **memory_handle)
	{

		js1::QueryScript *query_script;
		//TODO: add v8::try_catch here (and move scope/context to this level) and make errors reportable to theC# level
		
		query_script = reinterpret_cast<js1::QueryScript *>(script_handle);
		js1::PreludeScope prelude_scope(query_script);

		v8::HandleScope handle_scope(v8::Isolate::GetCurrent());

		v8::Handle<v8::String> result;
		js1::Status success = query_script->execute_handler(event_handler_handle, data_json, data_other, other_length, result);
		if (success != js1::S_OK) {
			*result_json = NULL;
			*memory_handle = NULL;
			return false;
		}
		//NOTE: incorrect return types are handled in execute_handler
		if (!result.IsEmpty()) 
		{
			v8::String::Value * result_buffer = new v8::String::Value(result);
			*result_json = **result_buffer;
			*memory_handle = result_buffer;
		}
		else 
		{
			*result_json = NULL;
			*memory_handle = NULL;
		}
		return true;
	};
예제 #2
0
	JS1_API void * STDCALL compile_query(
		void *prelude, 
		const uint16_t *script,
		const uint16_t *file_name,
		REGISTER_COMMAND_HANDLER_CALLBACK register_command_handler_callback,
		REVERSE_COMMAND_CALLBACK reverse_command_callback
		)
	{

		js1::PreludeScript *prelude_script = reinterpret_cast<js1::PreludeScript *>(prelude);
		js1::QueryScript *query_script;
		js1::PreludeScope prelude_scope(prelude_script);

		v8::HandleScope scope(v8::Isolate::GetCurrent());


		query_script = new js1::QueryScript(prelude_script, register_command_handler_callback, reverse_command_callback);

		js1::Status status;
		if ((status = query_script->compile_script(script, file_name)) == js1::S_OK)
			status = query_script->try_run();

		if (status != js1::S_TERMINATED)
			return query_script;

		delete query_script;
		return NULL;

	};
예제 #3
0
	JS1_API void STDCALL dispose_script(void *script_handle)
	{
		js1::CompiledScript *compiled_script;
		compiled_script = reinterpret_cast<js1::CompiledScript *>(script_handle);
		js1::PreludeScope prelude_scope(compiled_script);
		delete compiled_script;
	};
예제 #4
0
	//TODO: revise error reporting completely (we are loosing error messages from the load_module this way)
	JS1_API void report_errors(void *script_handle, REPORT_ERROR_CALLBACK report_error_callback) 
	{
		js1::QueryScript *query_script;
		query_script = reinterpret_cast<js1::QueryScript *>(script_handle);
		js1::PreludeScope prelude_scope(query_script);

		query_script->report_errors(report_error_callback);
	}
예제 #5
0
파일: js1.cpp 프로젝트: trbngr/EventStore
	JS1_API void STDCALL dispose_script(void *script_handle)
	{
		js1::CompiledScript *compiled_script;
		compiled_script = reinterpret_cast<js1::CompiledScript *>(script_handle);
		bool owns_isolate = compiled_script->owns_isolate();
		js1::PreludeScope prelude_scope(compiled_script, owns_isolate);
		delete compiled_script;
	};
예제 #6
0
파일: js1.cpp 프로젝트: trbngr/EventStore
	JS1_API void * STDCALL compile_prelude(const uint16_t *prelude, const uint16_t *file_name, LOAD_MODULE_CALLBACK load_module_callback, LOG_CALLBACK log_callback)
	{

		js1::PreludeScript *prelude_script;
		prelude_script = new js1::PreludeScript(load_module_callback, log_callback);
		js1::PreludeScope prelude_scope(prelude_script);

		v8::HandleScope scope;

		if (prelude_script->compile_script(prelude, file_name))
			prelude_script->run();

		return prelude_script;
	};
예제 #7
0
파일: js1.cpp 프로젝트: trbngr/EventStore
	//TODO: revise error reporting - it is no the best way to create faulted objects and then immediately dispose them
	JS1_API void * STDCALL compile_module(void *prelude, const uint16_t *script, const uint16_t *file_name)
	{
		js1::PreludeScript *prelude_script = reinterpret_cast<js1::PreludeScript *>(prelude);
		js1::ModuleScript *module_script;

		js1::PreludeScope prelude_scope(prelude_script);
		v8::HandleScope scope;


		module_script = new js1::ModuleScript(prelude_script);

		if (module_script->compile_script(script, file_name))
			module_script->run();
		return module_script;
	};
예제 #8
0
	JS1_API void * STDCALL compile_prelude(const uint16_t *prelude, const uint16_t *file_name, LOAD_MODULE_CALLBACK load_module_callback, 
		ENTER_CANCELLABLE_REGION enter_calcellable_region_callback, EXIT_CANCELLABLE_REGION exit_cancellable_region_callback, LOG_CALLBACK log_callback)
	{
		js1::PreludeScript *prelude_script;
		prelude_script = new js1::PreludeScript(load_module_callback, enter_calcellable_region_callback, exit_cancellable_region_callback, log_callback);
		js1::PreludeScope prelude_scope(prelude_script);

		v8::HandleScope scope(v8::Isolate::GetCurrent());

		js1::Status status;
		if ((status = prelude_script->compile_script(prelude, file_name)) == js1::S_OK)
			status = prelude_script->try_run();

		if (status != js1::S_TERMINATED)
			return prelude_script;

		delete prelude_script;
		return NULL;
	};
예제 #9
0
	//TODO: revise error reporting - it is no the best way to create faulted objects and then immediately dispose them
	JS1_API void * STDCALL compile_module(void *prelude, const uint16_t *script, const uint16_t *file_name)
	{
		js1::PreludeScript *prelude_script = reinterpret_cast<js1::PreludeScript *>(prelude);
		js1::ModuleScript *module_script;

		js1::PreludeScope prelude_scope(prelude_script);
		v8::HandleScope scope(v8::Isolate::GetCurrent());


		module_script = new js1::ModuleScript(prelude_script);

		js1::Status status;
		if ((status = module_script->compile_script(script, file_name)) == js1::S_OK)
			status = module_script->try_run();

		if (status != js1::S_TERMINATED)
			return module_script;

		delete module_script;
		return NULL;
	};
예제 #10
0
파일: js1.cpp 프로젝트: trbngr/EventStore
	JS1_API void * STDCALL execute_command_handler(void *script_handle, void* event_handler_handle, const uint16_t *data_json, const uint16_t *data_other[], int32_t other_length, uint16_t **result_json)
	{

		js1::QueryScript *query_script;
		//TODO: add v8::try_catch here (and move scope/context to this level) and make errors reportable to theC# level
		
		query_script = reinterpret_cast<js1::QueryScript *>(script_handle);
		js1::PreludeScope prelude_scope(query_script);

		v8::Persistent<v8::String> result = query_script->execute_handler(event_handler_handle, data_json, data_other, other_length);
		if (result.IsEmpty()) {
			*result_json = NULL;
			return NULL;
		}
		//NOTE: incorrect return types are handled in execute_handler
		v8::String::Value * result_buffer = new v8::String::Value(result);
		result.Dispose();
		*result_json = **result_buffer;

		return result_buffer;
	};
예제 #11
0
파일: js1.cpp 프로젝트: trbngr/EventStore
	JS1_API void * STDCALL compile_query(
		void *prelude, 
		const uint16_t *script,
		const uint16_t *file_name,
		REGISTER_COMMAND_HANDLER_CALLBACK register_command_handler_callback,
		REVERSE_COMMAND_CALLBACK reverse_command_callback
		)
	{

		js1::PreludeScript *prelude_script = reinterpret_cast<js1::PreludeScript *>(prelude);
		js1::QueryScript *query_script;
		js1::PreludeScope prelude_scope(prelude_script);

		v8::HandleScope scope;


		query_script = new js1::QueryScript(prelude_script, register_command_handler_callback, reverse_command_callback);

		if (query_script->compile_script(script, file_name))
			query_script->run();
		return query_script;
	};