Skip to content

Commit 26d7ac0

Browse files
authored
Merge pull request #2 from nextjournal/dev
Prefix module names to avoid name conflicts
2 parents eb61adf + 2706fa1 commit 26d7ac0

File tree

7 files changed

+18
-17
lines changed

7 files changed

+18
-17
lines changed

src/effi.app.src

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{description, "Erlang Foreign Function Interface"},
44
{vsn, "0.1.1-snapshot"},
55
{modules, [
6-
effi, effi_interact, effi_script, bash, python, r
6+
effi, effi_interact, effi_script, effi_bash, effi_python, effi_r, effi_perl, lib_refactor
77
]},
88
{registered, []},
99
{applications, [

src/effi.erl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ runscript( Dir, Refactor, [RequestFile, SumFile] ) ->
235235
{Lam, Fa, R, LibMap} = case erl_parse:parse_term( Tokens ) of
236236
{error, Reason} -> error( Reason );
237237
{ok, Y} -> Y
238-
end,
238+
end,
239239

240240
% run script
241241
Summary = case check_run( Lam, Fa, R, Dir, LibMap ) of
@@ -403,35 +403,36 @@ when is_tuple( Lam ),
403403
{lam, _Line, _LamName, Sign, Body} = Lam,
404404
{forbody, Lang, Script} = Body,
405405
{sign, Lo, Li} = Sign,
406+
Mod = list_to_existing_atom("effi_" ++ atom_to_list(Lang)),
406407

407408
% get Foreign Function Interface type
408-
FfiType = apply( Lang, ffi_type, [] ),
409+
FfiType = apply( Mod, ffi_type, [] ),
409410

410411
% include lib paths
411-
LibPath = [[apply( Lang, libpath, [P] ), $\n] || P <- maps:get( Lang, LibMap, [] )],
412+
LibPath = [[apply( Mod, libpath, [P] ), $\n] || P <- maps:get( Lang, LibMap, [] )],
412413

413414
% collect assignments
414415
Assign = lists:map(
415416
fun( {param, {name, N, _Pf}, Pl} ) ->
416417
X = maps:get( N, Fa ),
417418
X1 = [S ||{str, S} <- X],
418-
[apply( Lang, assignment, [N, Pl, X1] ), $\n]
419+
[apply( Mod, assignment, [N, Pl, X1] ), $\n]
419420
end,
420421
Li ),
421422

422423
% collect dismissals
423424
Suffix = lists:map(
424425
fun( {param, {name, N, _Pf}, Pl} ) ->
425-
[apply( Lang, dismissal, [N, Pl] ), $\n]
426+
[apply( Mod, dismissal, [N, Pl] ), $\n]
426427
end,
427428
Lo ),
428429

429-
Script1 = apply( Lang, preprocess, [Script] ),
430+
Script1 = apply( Mod, preprocess, [Script] ),
430431

431432
Script2 = io_lib:format( "~s~n~s~n~s~n~s~n", [LibPath, Assign, Script1, Suffix] ),
432433

433434
% run script
434-
{_Port, _ActScript} = apply( FfiType, create_port, [Lang, Script2, Dir] ).
435+
{_Port, _ActScript} = apply( FfiType, create_port, [Mod, Script2, Dir] ).
435436

436437

437438

src/bash.erl renamed to src/effi_bash.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
%% @author Jörgen Brandt <brandjoe@hu-berlin.de>
2020

2121

22-
-module( bash ).
22+
-module( effi_bash ).
2323
-author( "Jorgen Brandt <brandjoe@hu-berlin.de>" ).
2424
-vsn( "0.1.1-snapshot" ).
2525

src/effi_interact.erl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,20 @@
5858

5959
%% create_port/3
6060
%
61-
create_port( Lang, Script, Dir )
61+
create_port( Mod, Script, Dir )
6262

63-
when is_atom( Lang ),
63+
when is_atom( Mod ),
6464
is_list( Script ),
6565
is_list( Dir ) ->
6666

6767
% get interpreter
68-
Interpreter = apply( Lang, interpreter, [] ),
68+
Interpreter = apply( Mod, interpreter, [] ),
6969

7070
% get prefix
71-
Prefix = apply( Lang, prefix, [] ),
71+
Prefix = apply( Mod, prefix, [] ),
7272

7373
% get suffix
74-
Suffix = apply( Lang, suffix, [] ),
74+
Suffix = apply( Mod, suffix, [] ),
7575

7676
% complement script
7777
ActScript = string:join( [Prefix, Script, Suffix, ""], "\n" ),

src/perl.erl renamed to src/effi_perl.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
%% @author Jörgen Brandt <brandjoe@hu-berlin.de>
2020

2121

22-
-module( perl ).
22+
-module( effi_perl ).
2323
-author( "Jorgen Brandt <brandjoe@hu-berlin.de>" ).
2424
-vsn( "0.1.1-snapshot" ).
2525

src/python.erl renamed to src/effi_python.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
%% @author Jörgen Brandt <brandjoe@hu-berlin.de>
2020

2121

22-
-module( python ).
22+
-module( effi_python ).
2323
-author( "Jorgen Brandt <brandjoe@hu-berlin.de>" ).
2424
-vsn( "0.1.1-snapshot" ).
2525

src/r.erl renamed to src/effi_r.erl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
%% @author Jörgen Brandt <brandjoe@hu-berlin.de>
2020

2121

22-
-module( r ).
22+
-module( effi_r ).
2323
-author( "Jorgen Brandt <brandjoe@hu-berlin.de>" ).
2424
-vsn( "0.1.1-snapshot" ).
2525

0 commit comments

Comments
 (0)