Skip to content

Commit

Permalink
Remove JuliaModule C command
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasguts authored and fingolfin committed Nov 14, 2018
1 parent 0eb4aca commit f266bd0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
8 changes: 8 additions & 0 deletions JuliaInterface/gap/JuliaInterface.gd
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,11 @@ DeclareGlobalFunction( "JuliaTypeInfo" );
#! If an error occured then <C>ok</C> has the value <K>false</K>,
#! and <C>value</C> is the error message as a &GAP; string.
DeclareGlobalFunction( "CallJuliaFunctionWithCatch" );

#! @Arguments name
#! @Returns a julia object
#! @Description
#! Returns the Julia objects that points to the module
#! with <A>name</A>. Note that the module needs to be
#! imported before being present.
DeclareGlobalFunction( "JuliaModule" );
14 changes: 14 additions & 0 deletions JuliaInterface/gap/JuliaInterface.gi
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,17 @@ InstallGlobalFunction( StructuralConvertedFromJulia,
return unboxed_obj;
end );

InstallGlobalFunction( JuliaModule,
function( name )
if not IsString( name ) then
Error( "JuliaModule: <name> must be a string" );
fi;
if not IsBound( Julia.(name) ) then
Error( "JuliaModule: Module <name> does not exists, did you import it?" );
fi;
if not IsJuliaModule( Julia.(name) ) then
Error( "JuliaModule: <name> is not a module" );
fi;
return Julia.(name)!.julia_pointer;
end );

13 changes: 0 additions & 13 deletions JuliaInterface/src/JuliaInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,18 +511,6 @@ static Obj FuncJuliaSymbol(Obj self, Obj name)
return NewJuliaObj((jl_value_t *)julia_symbol);
}

// Returns a julia object GAP object that holds the pointer to the julia
// module <name>.
static Obj FuncJuliaModule(Obj self, Obj name)
{
if (!IsStringConv(name)) {
ErrorMayQuit("JuliaModule: <name> must be a string", 0, 0);
}

jl_module_t * julia_module = get_module_from_string(CSTR_STRING(name));
return NewJuliaObj((jl_value_t *)julia_module);
}

// Sets the value of the julia identifier <name> to the <val>.
// This function is for debugging purposes.
static Obj FuncJuliaSetVal(Obj self, Obj name, Obj val)
Expand Down Expand Up @@ -624,7 +612,6 @@ static StructGVarFunc GVarFuncs[] = {
GVAR_FUNC(_JuliaGetGlobalVariableByModule, 2, "name,module"),
GVAR_FUNC(JuliaGetFieldOfObject, 2, "obj,name"),
GVAR_FUNC(JuliaSymbol, 1, "name"),
GVAR_FUNC(JuliaModule, 1, "name"),
GVAR_FUNC(_ConvertedFromJulia_record_dict, 1, "dict"),
GVAR_FUNC(_NewJuliaCFunc, 2, "ptr,arg_names"),
GVAR_FUNC(_JULIAINTERFACE_INTERNAL_INIT, 0, ""),
Expand Down
4 changes: 3 additions & 1 deletion JuliaInterface/tst/utils.tst
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,11 @@ Error, JuliaSymbol: <name> must be a string
gap> JuliaModule("Base");
<Julia: Base>
gap> JuliaModule("This_Module_Does_Not_Exist");
Error, UndefVarError: This_Module_Does_Not_Exist not defined
Error, JuliaModule: Module <name> does not exists, did you import it?
gap> JuliaModule(1);
Error, JuliaModule: <name> must be a string
gap> JuliaModule( "sqrt" );
Error, JuliaModule: <name> is not a module

##
gap> _JuliaGetGlobalVariable(0);
Expand Down

0 comments on commit f266bd0

Please sign in to comment.