]>
git.siccegge.de Git - frida/frida.git/blob - src/bindings/Guile.cxx
5 SCM
handler (void*, SCM tag
, SCM throw_args
) {
6 scm_handle_by_message_noexit ((void*)"foo", tag
, throw_args
);
11 GuileInterpreter::GuileInterpreter() {
14 scm_c_use_module("system repl server");
15 scm_call_0(scm_c_public_ref("system repl server", "spawn-server"));
16 scm_c_load_extension("libguile-frida-binding",
17 "scm_init_frida_module");
19 guile_output_port
= scm_open_output_string();
20 guile_error_port
= scm_open_output_string();
21 scm_set_current_output_port(guile_output_port
);
22 scm_set_current_error_port(guile_error_port
);
25 int GuileInterpreter::evaluate(const std::string
& command
,
28 std::string
& result
) {
30 SCM result_obj
= scm_internal_catch(SCM_BOOL_T
,
31 (SCM (*)(void *))scm_c_eval_string
,
32 (void*)command
.c_str(),
35 SCM result_str
= scm_object_to_string(result_obj
, SCM_UNDEFINED
);
37 SCM output
= scm_get_output_string(guile_output_port
);
38 stdout
<< scm_to_locale_string(output
);
40 output
= scm_get_output_string(guile_error_port
);
41 stderr
<< scm_to_locale_string(output
);
43 result
= scm_to_locale_string(result_str
);
45 scm_truncate_file(guile_output_port
, scm_from_uint16(0));
46 scm_truncate_file(guile_error_port
, scm_from_uint16(0));
51 int GuileInterpreter::loadFile(const std::string
& filename
,
54 std::string
& result
) {
55 scm_c_primitive_load(filename
.c_str());