Add api.unregister() to allow replacing field definitions
This commit is contained in:
parent
5e0eb1ab6d
commit
25482510ac
@ -130,6 +130,19 @@
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- Unregister a field definition, removing its functions and field
|
||||
-- list entries.
|
||||
---
|
||||
|
||||
function api.unregister(field)
|
||||
premake.field.unregister(field)
|
||||
_G[field.name] = nil
|
||||
_G["remove" .. field.name] = nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- Create an alias to one of the canonical API functions. This creates
|
||||
-- new setter and remover names pointing to the same functions.
|
||||
@ -158,7 +171,7 @@
|
||||
--
|
||||
|
||||
function api.addAllowed(fieldName, value)
|
||||
local field = premake.fields[fieldName]
|
||||
local field = premake.field.get(fieldName)
|
||||
if not field then
|
||||
error("No such field: " .. fieldName, 2)
|
||||
end
|
||||
|
@ -92,6 +92,16 @@
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- Remove a previously created field definition.
|
||||
---
|
||||
|
||||
function field.unregister(f)
|
||||
field._list[f.name] = nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
---
|
||||
-- Register a new kind of data for field storage.
|
||||
--
|
||||
@ -130,7 +140,7 @@
|
||||
-- The field for which an accessor should be returned.
|
||||
-- @param method
|
||||
-- The type of accessor function required; currently this should be one of
|
||||
-- "set", "remove", or "merge" though it is possible for add-on modules to
|
||||
-- "store", "remove", or "merge" though it is possible for add-on modules to
|
||||
-- extend the available methods by implementing appropriate processing
|
||||
-- functions.
|
||||
-- @return
|
||||
|
Reference in New Issue
Block a user