###*
 * Stage definitions:
 * 
 * 0: Selection:			Got selector, awaiting object.
 * 1: Indication:			Got object, awaiting proxied property / function / Binding-object.
 * 2: Binding Complete:		Complete, awaiting additional (optional) bindings/mutations.
###
BindingInterface = (inheritedState, stage, subject, options, parentInterface, isSibling, saveOptions)->
	extendState(@, inheritedState) if inheritedState
	@stage = stage or 0
	@subs ?= []
	@saveOptions = saveOptions if saveOptions
	@isSibling = isSibling if isSibling
	@parentInterface = parentInterface if parentInterface
	
	if @stage is 0
		@optionsPassed = options ||= {}
		@options = {}
		for key of defaultOptions
			@options[key] = if options[key]? then options[key] else defaultOptions[key]
		

		if checkIf.isSimpleObject(subject)
			@stage = 1
			return @setObject(subject, true)

		else
			subject = subject.toString() if checkIf.isNumber(subject)
			@selector = @property = subject

			
			unless @options.simpleSelector
				if targetIncludes(subject, ':')
					split = subject.split(':')
					@descriptor = split[0] # An addl. string in the selector name defining the scope of the selection (i.e. SimplyBind('attr:class'))
					@property = split[1]
				
				
				if targetIncludes(subject, '.') # Placeholder extraction
					split = @property.split('.') # We use '@property' instead of 'subject' because it may have been modified by the previous ':' descriptor check
					@property = split[0]				
					@pholder = split.slice(1).join('.')



				if @descriptor is 'event'
					if targetIncludes(subject, '#')
						split = @property.split('#')
						@eventName = split[0]
						@property = split[1]
					else
						@eventName = @property
						@property = 0

					throwWarning('badEventArg',1) if isNaN parseInt(@property)

					@customEventMethod = {listen:@optionsPassed.listenMethod, emit:@optionsPassed.emitMethod}

				# @selector = @property
	
	return @



import prototype-private.coffee
import prototype-public.coffee