Commits

Jason Perkins  committed 7690444

Add api.unregister() to allow replacing field definitions

  • Participants
  • Parent commits ee2f3f2

Comments (0)

Files changed (2)

File src/base/api.lua

 
 
 ---
+-- 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.
 --
 --
 
 	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

File src/base/field.lua

 
 
 ---
+-- 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.
 --
 -- @param tag
 --    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