 		name = "#{nameHint}#{i += 1}"
 	name
 
-register = (type, hint) ->
+register = (type, hint, pub = false) ->
 	name = type.typename? hint
 	if not type.name?
 		allTypes[type.name = name] = type
+	type.pub or= pub
 	type.name
 
-declare = (type) -> if not type.declared
+declare = (type) -> if not type.declared and type.pub
 	type.declared = true
 	if deps = type.dependencies?()
 		for n, t of deps
 			declare t
-	noDeps = type instanceof bw.Enum or type instanceof bw.Scaled
-	decl = type.declaration?() ? (type.spec and type.name != type.spec and "using #{type.name} = #{type.spec};" or "")
-	decls[if noDeps then 'forward' else 'other'].push decl
+	decl = type.declaration?() ? (type.spec and type.name != type.spec and "using #{type.name} = #{type.spec}" or "")
+	decls[if not deps then 'forward' else 'other'].push decl
+	if adapt = type.adapter?()
+		decls.adapters.push adapt
 
 capitalizeFirstLetter = (s) -> s[0].toUpperCase() + s.substring 1
 

bw.float32.name = 'float'
bw.string.name = 'std::string'

bw.List::typename = (hint) -> @spec = "std::vector<#{register @type, hint}>"
bw.Optional::typename = (hint) -> @spec = "std::optional<#{register @type, hint}>"
bw.Scaled::typename = (hint = 'Scaled') -> @spec = "bw::Scaled<#{@type.name}, #{hex floatAsUint32 @min} /*#{@min}*/, #{hex floatAsUint32 @max} /*#{@max}*/>"
bw.Enum::typename = (hint = 'Enum') -> newName hint

bw.Struct::typename = (hint = 'Struct') ->

bw = require '.'

publicTypes = require path.resolve process.argv[2]
namespace = process.argv[3]
allTypes = {}

decls =
	forward: []
	other: []
	adapters: []

newName = (nameHint) ->
	name = nameHint
