mirror of https://github.com/KLayout/klayout.git
Trying to fix the ambiguity issue in Ruby < 3.0 with hash arguments vs. keyword arguments
This commit is contained in:
parent
11fbad0104
commit
6ceb77cf73
|
|
@ -91,7 +91,7 @@ module DRC
|
|||
macro = RBA::Macro::macro_by_path(script)
|
||||
macro || raise("Can't find DRC script #{script} - unable to re-run")
|
||||
|
||||
DRCExecutable::new(macro, @interpreter, self.generator("script" => script), params["rdb_index"])
|
||||
DRCExecutable::new(macro, @interpreter, self.generator({ "script" => script }, 0), params["rdb_index"])
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ module DRC
|
|||
|
||||
# Implements the execute method
|
||||
def executable(macro)
|
||||
DRCExecutable::new(macro, self, @recipe.generator("script" => macro.path))
|
||||
DRCExecutable::new(macro, self, @recipe.generator({"script" => macro.path}, 0))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -155,7 +155,7 @@ module DRC
|
|||
|
||||
# Implements the execute method
|
||||
def executable(macro)
|
||||
DRCExecutable::new(macro, self, @recipe.generator("script" => macro.path))
|
||||
DRCExecutable::new(macro, self, @recipe.generator({ "script" => macro.path }, 0))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -693,6 +693,16 @@ static Recipe_Impl *make_recipe (const std::string &name, const std::string &des
|
|||
return new Recipe_Impl (name, description);
|
||||
}
|
||||
|
||||
static tl::Variant make_impl (Recipe_Impl *recipe, const std::string &generator, const std::map<std::string, tl::Variant> &add_params, int /*dummy*/)
|
||||
{
|
||||
return recipe->make (generator, add_params);
|
||||
}
|
||||
|
||||
std::string generator_impl (Recipe_Impl *recipe, const std::map<std::string, tl::Variant> ¶ms, int /*dummy*/)
|
||||
{
|
||||
return recipe->generator (params);
|
||||
}
|
||||
|
||||
Class<Recipe_Impl> decl_Recipe_Impl ("tl", "Recipe",
|
||||
gsi::constructor ("new", &make_recipe, gsi::arg ("name"), gsi::arg ("description", std::string (), "\"\""),
|
||||
"@brief Creates a new recipe object with the given name and (optional) description"
|
||||
|
|
@ -703,15 +713,23 @@ Class<Recipe_Impl> decl_Recipe_Impl ("tl", "Recipe",
|
|||
gsi::method ("description", &Recipe_Impl::description,
|
||||
"@brief Gets the description of the recipe."
|
||||
) +
|
||||
gsi::method ("make", &Recipe_Impl::make, gsi::arg ("generator"), gsi::arg ("add_params", std::map<std::string, tl::Variant> (), "{}"),
|
||||
gsi::method_ext ("make", &make_impl, gsi::arg ("generator"), gsi::arg ("add_params", std::map<std::string, tl::Variant> (), "{}"), gsi::arg ("dummy", 0),
|
||||
"@brief Executes the recipe given by the generator string.\n"
|
||||
"The generator string is the one delivered with \\generator.\n"
|
||||
"Additional parameters can be passed in \"add_params\". They have lower priority than the parameters "
|
||||
"kept inside the generator string."
|
||||
"\n"
|
||||
"The dummy argument has been added in version 0.29 and disambiguates between keyword parameters "
|
||||
"and a single hash argument in Ruby. This is required for Ruby versions before 'real keywords'. Simply "
|
||||
"add this parameter with any value.\n"
|
||||
) +
|
||||
gsi::method ("generator", &Recipe_Impl::generator, gsi::arg ("params"),
|
||||
gsi::method_ext ("generator", &generator_impl, gsi::arg ("params"), gsi::arg ("dummy", 0),
|
||||
"@brief Delivers the generator string from the given parameters.\n"
|
||||
"The generator string can be used with \\make to re-run the recipe."
|
||||
"\n"
|
||||
"The dummy argument has been added in version 0.29 and disambiguates between keyword parameters "
|
||||
"and a single hash argument in Ruby. This is required for Ruby versions before 'real keywords'. Simply "
|
||||
"add this parameter with any value.\n"
|
||||
) +
|
||||
gsi::callback ("executable", &Recipe_Impl::executable, &Recipe_Impl::executable_cb, gsi::arg ("params"),
|
||||
"@brief Reimplement this method to provide an executable object for the actual implementation.\n"
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@ module LVS
|
|||
macro = RBA::Macro::macro_by_path(script)
|
||||
macro || raise("Can't find LVS script #{script} - unable to re-run")
|
||||
|
||||
LVSExecutable::new(macro, @interpreter, self.generator("script" => script), params["l2ndb_index"])
|
||||
LVSExecutable::new(macro, @interpreter, self.generator({ "script" => script }, 0), params["l2ndb_index"])
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ module LVS
|
|||
|
||||
# Implements the execute method
|
||||
def executable(macro)
|
||||
LVSExecutable::new(macro, self, @recipe.generator("script" => macro.path))
|
||||
LVSExecutable::new(macro, self, @recipe.generator({ "script" => macro.path }, 0))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -155,7 +155,7 @@ module LVS
|
|||
|
||||
# Implements the execute method
|
||||
def executable(macro)
|
||||
LVSExecutable::new(macro, self, @recipe.generator("script" => macro.path))
|
||||
LVSExecutable::new(macro, self, @recipe.generator({ "script" => macro.path }, 0))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ module D25
|
|||
macro = RBA::Macro::macro_by_path(script)
|
||||
macro || raise("Can't find D25 script #{script} - unable to re-run")
|
||||
|
||||
D25Executable::new(macro, @interpreter, self.generator("script" => script))
|
||||
D25Executable::new(macro, @interpreter, self.generator({ "script" => script }, 0))
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -129,7 +129,7 @@ module D25
|
|||
|
||||
# Implements the execute method
|
||||
def executable(macro)
|
||||
D25Executable::new(macro, self, @recipe.generator("script" => macro.path))
|
||||
D25Executable::new(macro, self, @recipe.generator({ "script" => macro.path }, 0))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -156,7 +156,7 @@ module D25
|
|||
|
||||
# Implements the execute method
|
||||
def executable(macro)
|
||||
D25Executable::new(macro, self, @recipe.generator("script" => macro.path))
|
||||
D25Executable::new(macro, self, @recipe.generator({ "script" => macro.path }, 0))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -301,10 +301,10 @@ class Tl_TestClass < TestBase
|
|||
assert_equal(my_recipe.name, "rba_test_recipe")
|
||||
assert_equal(my_recipe.description, "description")
|
||||
|
||||
g = my_recipe.generator({ "A" => 6, "B" => 7.0 })
|
||||
g = my_recipe.generator({ "A" => 6, "B" => 7.0 }, 0)
|
||||
assert_equal(g, "rba_test_recipe: A=#6,B=##7")
|
||||
assert_equal("%g" % RBA::Recipe::make(g), "42")
|
||||
assert_equal("%g" % RBA::Recipe::make(g, { "C" => 1.5 }).to_s, "63")
|
||||
assert_equal("%g" % RBA::Recipe::make(g, { "C" => 1.5 }, 0).to_s, "63")
|
||||
|
||||
my_recipe._destroy
|
||||
my_recipe = nil
|
||||
|
|
|
|||
Loading…
Reference in New Issue