Skip to content

Commit

Permalink
JuliaInterface: remove more dead code (oscar-system#91)
Browse files Browse the repository at this point in the history
* JuliaInterface: remove more dead code

All of the removed functions are potentially useful. However, I believe that
we will be better off reimplementing them in Julia, and then exporting these
Julia functions to GAP.

* Readded JuliaSetVal

* Add simple test for JuliaSetVal + JuliaGetGlobalVariable
  • Loading branch information
fingolfin authored and sebasguts committed Oct 21, 2018
1 parent 78fadc9 commit 9bf20f2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 32 deletions.
33 changes: 1 addition & 32 deletions JuliaInterface/src/JuliaInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ static Obj FuncJuliaModule(Obj self, Obj name)

// Sets the value of the julia identifier <name> to the julia value the julia
// object GAP object <julia_val> points to.
// This function is for debugging purposes
static Obj FuncJuliaSetVal(Obj self, Obj name, Obj julia_val)
{
jl_value_t * julia_obj = GET_JULIA_OBJ(julia_val);
Expand Down Expand Up @@ -900,35 +901,6 @@ static Obj Func_JuliaSetGAPFuncAsJuliaObjFunc(Obj self,
return NULL;
}

static Obj FuncJuliaSetAsJuliaPointer(Obj self, Obj obj)
{
jl_value_t * module_value = jl_eval_string("GAP");
JULIAINTERFACE_EXCEPTION_HANDLER
if (!jl_is_module(module_value))
ErrorMayQuit("GAP module not yet defined", 0, 0);
jl_module_t * module_t = (jl_module_t *)module_value;
jl_function_t * set_gap_obj = jl_get_function(module_t, "GapObj");
JULIAINTERFACE_EXCEPTION_HANDLER
jl_value_t * gap_obj_ptr = jl_call1(set_gap_obj, jl_box_voidpointer(obj));
JULIAINTERFACE_EXCEPTION_HANDLER
return NewJuliaObj(gap_obj_ptr);
}

static Obj FuncJuliaGetFromJuliaPointer(Obj self, Obj obj)
{
jl_value_t * julia_ptr = GET_JULIA_OBJ(obj);
jl_value_t * gap_ptr = jl_get_field(julia_ptr, "ptr");
JULIAINTERFACE_EXCEPTION_HANDLER
return (Obj)(jl_unbox_voidpointer(gap_ptr));
}

static Obj Func_JuliaIsNothing(Obj self, Obj obj)
{
if (jl_is_nothing(GET_JULIA_OBJ(obj))) {
return True;
}
return False;
}

// Table of functions to export
static StructGVarFunc GVarFuncs[] = {
Expand All @@ -947,9 +919,6 @@ static StructGVarFunc GVarFuncs[] = {
GVAR_FUNC(JuliaSymbol, 1, "name"),
GVAR_FUNC(JuliaModule, 1, "name"),
GVAR_FUNC(_ConvertedFromJulia_record_dict, 1, "dict"),
GVAR_FUNC(JuliaSetAsJuliaPointer, 1, "obj"),
GVAR_FUNC(JuliaGetFromJuliaPointer, 1, "obj"),
GVAR_FUNC(_JuliaIsNothing, 1, "obj"),
GVAR_FUNC(_NewJuliaCFunc, 2, "ptr,arg_names"),
{ 0 } /* Finish with an empty entry */

Expand Down
5 changes: 5 additions & 0 deletions JuliaInterface/tst/utils.tst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ rec( ok := false,
value := "DomainError(-1.0, \"sqrt will only return a complex result if call\
ed with a complex argument. Try sqrt(Complex(x)).\")" )

#
gap> JuliaSetVal("foo", JuliaEvalString("1"));
gap> JuliaGetGlobalVariable("foo");
<Julia: 1>

##
gap> STOP_TEST( "utils.tst", 1 );

0 comments on commit 9bf20f2

Please sign in to comment.