Remove unneeded parameter from CFCParcel_new_from_file

Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/5db69da7
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/5db69da7
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/5db69da7

Branch: refs/heads/master
Commit: 5db69da71f96812135443d390a041b863fbb9e91
Parents: 3e225d4
Author: Nick Wellnhofer <[email protected]>
Authored: Fri Jul 15 20:15:08 2016 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Sat Jul 16 15:27:02 2016 +0200

----------------------------------------------------------------------
 compiler/perl/lib/Clownfish/CFC.pm |  3 +--
 compiler/perl/lib/Clownfish/CFC.xs |  5 ++---
 compiler/perl/t/403-parcel.t       |  8 ++++++--
 compiler/src/CFCHierarchy.c        |  2 +-
 compiler/src/CFCParcel.c           | 10 ++++++----
 compiler/src/CFCParcel.h           |  2 +-
 compiler/src/CFCTestParcel.c       |  8 +++++---
 7 files changed, 22 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5db69da7/compiler/perl/lib/Clownfish/CFC.pm
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC.pm 
b/compiler/perl/lib/Clownfish/CFC.pm
index eec76bd..88b687d 100644
--- a/compiler/perl/lib/Clownfish/CFC.pm
+++ b/compiler/perl/lib/Clownfish/CFC.pm
@@ -355,7 +355,6 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.5.0' ) }
     }
 
     our %new_from_file_PARAMS = (
-        path      => undef,
         file_spec => undef,
     );
 
@@ -363,7 +362,7 @@ BEGIN { XSLoader::load( 'Clownfish::CFC', '0.5.0' ) }
         my ( $either, %args ) = @_;
         verify_args( \%new_from_file_PARAMS, %args ) or confess $@;
         confess "no subclassing allowed" unless $either eq __PACKAGE__;
-        return _new_from_file( @args{qw( path file_spec )} );
+        return _new_from_file( @args{qw( file_spec )} );
     }
 
 #    $parcel = 
Clownfish::CFC::Model::Parcel->acquire($parcel_name_or_parcel_object);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5db69da7/compiler/perl/lib/Clownfish/CFC.xs
----------------------------------------------------------------------
diff --git a/compiler/perl/lib/Clownfish/CFC.xs 
b/compiler/perl/lib/Clownfish/CFC.xs
index c79ee34..26b997a 100644
--- a/compiler/perl/lib/Clownfish/CFC.xs
+++ b/compiler/perl/lib/Clownfish/CFC.xs
@@ -1079,11 +1079,10 @@ CODE:
 OUTPUT: RETVAL
 
 SV*
-_new_from_file(path, file_spec)
-    const char *path;
+_new_from_file(file_spec)
     CFCFileSpec *file_spec;
 CODE:
-    CFCParcel *self = CFCParcel_new_from_file(path, file_spec);
+    CFCParcel *self = CFCParcel_new_from_file(file_spec);
     RETVAL = S_cfcbase_to_perlref(self);
     CFCBase_decref((CFCBase*)self);
 OUTPUT: RETVAL

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5db69da7/compiler/perl/t/403-parcel.t
----------------------------------------------------------------------
diff --git a/compiler/perl/t/403-parcel.t b/compiler/perl/t/403-parcel.t
index b1812ec..ada6c31 100644
--- a/compiler/perl/t/403-parcel.t
+++ b/compiler/perl/t/403-parcel.t
@@ -18,7 +18,7 @@ use warnings;
 
 use Clownfish::CFC::Test::TestUtils qw( test_files_dir );
 use Test::More tests => 35;
-use File::Spec::Functions qw( catfile );
+use File::Spec::Functions qw( catdir );
 
 BEGIN { use_ok('Clownfish::CFC::Model::Prereq') }
 
@@ -89,7 +89,11 @@ isa_ok(
 
 isa_ok(
     Clownfish::CFC::Model::Parcel->new_from_file(
-        path => catfile( test_files_dir(), qw( cfbase Animal.cfp ) ),
+        file_spec => Clownfish::CFC::Model::FileSpec->new(
+            source_dir => catdir( test_files_dir(), 'cfbase' ),
+            path_part  => 'Animal',
+            ext        => '.cfp',
+        ),
     ),
     "Clownfish::CFC::Model::Parcel",
     "new_from_file"

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5db69da7/compiler/src/CFCHierarchy.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCHierarchy.c b/compiler/src/CFCHierarchy.c
index 68a5d88..87e596c 100644
--- a/compiler/src/CFCHierarchy.c
+++ b/compiler/src/CFCHierarchy.c
@@ -249,7 +249,7 @@ S_parse_parcel_files(const char *source_dir, int 
is_included) {
         char *path_part = S_extract_path_part(path, source_dir, ".cfp");
         CFCFileSpec *file_spec
             = CFCFileSpec_new(source_dir, path_part, ".cfp", is_included);
-        CFCParcel *parcel = CFCParcel_new_from_file(path, file_spec);
+        CFCParcel *parcel = CFCParcel_new_from_file(file_spec);
         const char *name = CFCParcel_get_name(parcel);
         CFCParcel *existing = CFCParcel_fetch(name);
         if (existing) {

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5db69da7/compiler/src/CFCParcel.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCParcel.c b/compiler/src/CFCParcel.c
index 23bd7fd..525a510 100644
--- a/compiler/src/CFCParcel.c
+++ b/compiler/src/CFCParcel.c
@@ -213,7 +213,8 @@ CFCParcel_init(CFCParcel *self, const char *name, const 
char *nickname,
 }
 
 static CFCParcel*
-S_new_from_json(const char *json, const char *path, CFCFileSpec *file_spec) {
+S_new_from_json(const char *json, CFCFileSpec *file_spec) {
+    const char *path = file_spec ? CFCFileSpec_get_path(file_spec) : "[NULL]";
     CFCJson *parsed = CFCJson_parse(json);
     if (!parsed) {
         CFCUtil_die("Invalid JSON parcel definition in '%s'", path);
@@ -321,14 +322,15 @@ S_set_prereqs(CFCParcel *self, CFCJson *node, const char 
*path) {
 
 CFCParcel*
 CFCParcel_new_from_json(const char *json, CFCFileSpec *file_spec) {
-    return S_new_from_json(json, "[NULL]", file_spec);
+    return S_new_from_json(json, file_spec);
 }
 
 CFCParcel*
-CFCParcel_new_from_file(const char *path, CFCFileSpec *file_spec) {
+CFCParcel_new_from_file(CFCFileSpec *file_spec) {
+    const char *path = CFCFileSpec_get_path(file_spec);
     size_t len;
     char *json = CFCUtil_slurp_text(path, &len);
-    CFCParcel *self = S_new_from_json(json, path, file_spec);
+    CFCParcel *self = S_new_from_json(json, file_spec);
     FREEMEM(json);
     return self;
 }

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5db69da7/compiler/src/CFCParcel.h
----------------------------------------------------------------------
diff --git a/compiler/src/CFCParcel.h b/compiler/src/CFCParcel.h
index e70b73d..2a15666 100644
--- a/compiler/src/CFCParcel.h
+++ b/compiler/src/CFCParcel.h
@@ -67,7 +67,7 @@ CFCParcel_new(const char *name, const char *nickname,
               struct CFCVersion *version, struct CFCFileSpec *file_spec);
 
 CFCParcel*
-CFCParcel_new_from_file(const char *path, struct CFCFileSpec *file_spec);
+CFCParcel_new_from_file(struct CFCFileSpec *file_spec);
 
 CFCParcel*
 CFCParcel_new_from_json(const char *json, struct CFCFileSpec *file_spec);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5db69da7/compiler/src/CFCTestParcel.c
----------------------------------------------------------------------
diff --git a/compiler/src/CFCTestParcel.c b/compiler/src/CFCTestParcel.c
index 7a33a6b..c71f14b 100644
--- a/compiler/src/CFCTestParcel.c
+++ b/compiler/src/CFCTestParcel.c
@@ -169,11 +169,13 @@ S_run_extended_tests(CFCTest *test) {
     }
 
     {
-        char *path = CFCTest_path("cfbase" CHY_DIR_SEP "Animal.cfp");
-        CFCParcel *parcel = CFCParcel_new_from_file(path, NULL);
+        char *dir = CFCTest_path("cfbase");
+        CFCFileSpec *file_spec = CFCFileSpec_new(dir, "Animal", ".cfp", false);
+        CFCParcel *parcel = CFCParcel_new_from_file(file_spec);
         OK(test, parcel != NULL, "new_from_file");
         CFCBase_decref((CFCBase*)parcel);
-        FREEMEM(path);
+        CFCBase_decref((CFCBase*)file_spec);
+        FREEMEM(dir);
     }
 
     {

Reply via email to