Skip to content

Commit

Permalink
Implementing inheritance: done.
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Reale committed Nov 8, 2016
1 parent e988a99 commit da7e7a8
Showing 1 changed file with 33 additions and 9 deletions.
42 changes: 33 additions & 9 deletions lib/library/loader
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function bashlets_library_loader_search_methods()
bashlet_path=${BASH_REMATCH[1]}
method_name=${BASH_REMATCH[2]}

echo $bashlet_path $bashlet_name $method_name
echo "$bashlet_path:$bashlet_name:$method_name"
fi
done
}
Expand All @@ -134,7 +134,8 @@ function bashlets_library_loader_import()
local bashlet="$1"
local bashlet_name bashlet_path file_name
local bashlets_library_loader_list_methods
local container_name container_def method_prefix
local container_name container_def container_def_0 method_prefix
local method method_full

bashlet_name="$(__bashlets_library_loader_bashlet_to_name "$bashlet")"
bashlet_path="$(__bashlets_library_loader_bashlet_to_path "$bashlet")"
Expand All @@ -155,20 +156,35 @@ function bashlets_library_loader_import()
method_prefix="bashlets_${bashlet_path}_${bashlet_name}"
}

# container header

container_def="function ${container_name}()
{
local method=\"\$1\" ; shift
case \"\$method\" in
"

# for method in $(
# bashlets_library_loader_search_methods "$bashlet" | \
# sed "s/${method_prefix}_//"
# )
# do
# echo $method
# done
# inherited methods (to be added afterwards)

for method_full in $(
bashlets_library_loader_search_methods "$bashlet_name"
)
do
local v bashlet_name_0 bashlet_path_0 method_prefix_0

IFS=: read -r bashlet_path_0 bashlet_name_0 method <<<"$method_full"

method_prefix_0="bashlets_${bashlet_path_0}_${bashlet_name_0}"

container_def_0="$container_def_0
$method)
${method_prefix_0}_\$method \"\$@\"
;;
"
done

# new methods

if [[ $BASHLETS_LIB_LIBRARY_LOADER_STYLE == new ]]; then
bashlets_library_loader_list_methods=bashlets_library_loader_list_methods_new
Expand All @@ -190,6 +206,14 @@ function bashlets_library_loader_import()
"
done

# add inherited methods

container_def="$container_def
$container_def_0
"

# container footer

container_def="$container_def
*)
echo \"Method not found!\"
Expand Down

0 comments on commit da7e7a8

Please sign in to comment.