Example #1
0
def go(target, targettable,modifyEntries = False):
	
	out = iface_get(target, fSort=False)
	#make dictionary of iface
	dictiface = {}
	for o in out:
		o.found = False
		dictiface[o.name] = o
	
	misleadingNames = []
	i=0
	listSciFns = getIfacetablecxx(targettable, 'static IFaceFunction ifaceFunctions[] =')
	for ln in listSciFns:
		i+=1
		spl = ln.split(',')
		name = spl[0].strip()
		if name.startswith('Get') or name.startswith('Set'):
			misleadingNames.append(name)
		entry = dictiface[name]
		if entry.type!='fun':
			#correct it
			print 'INCORRECT (should be fn), ',entry.name,entry.type
			if modifyEntries: entry.type = 'fun'
		
		ifaceargs = parseArgs(entry)
		if spl[2].strip()=='iface_length': spl[2]='iface_int'
		if spl[3].strip()=='iface_length': spl[3]='iface_int'
		if spl[4].strip()=='iface_length': spl[4]='iface_int'
		expectEqual(ifaceargs[0], spl[2].strip(),spl)
		expectEqual(ifaceargs[1], spl[3].strip(),spl)
		expectEqual(ifaceargs[2], spl[4].strip(),spl)
		
		entry.found = True
		
		
	
	print 'dictIsScintillaFnNotProperty = {'
	for nm in misleadingNames: print '"%s":True,'%nm,
	print '}'
	print '-'
	hackPrefix = ('Annotation', 'AutoC', 'Indic', 'Margin', 'CallTip','Style') #should try Annotation before trying Style
	listSciProps = getIfacetablecxx(targettable, 'static IFaceProperty ifaceProperties[] =')
	for ln in listSciProps:
		spl = ln.split(',')
		pname = spl[0].strip()
		hasGet = spl[1].strip() != '0'
		hasSet = spl[2].strip() != '0'
		if hasGet:
			i+=1
			name = 'Get'+pname
			entry = None
			if name not in dictiface:
				if pname in ('LinesOnScreen','SelectionIsRectangle') :
					entry = dictiface[pname]
				else:
					for k in hackPrefix:
						if k in name:
							tname = k+name.replace(k,'')
							if tname not in dictiface:
								print k, ln
							entry = dictiface[tname]
							break
				if not entry:
					print ln; 
					raise 'not found'
			else:
				entry = dictiface[name]
			if entry.type!='get':
				print 'incorrect (is get), ',entry.name,entry.type
				raise 'incorrect'
			if name!=entry.name:
				print 'INCORRECT: name %s should be %s'%(entry.name, name)
				if modifyEntries: entry.name = name
			#verify args
			ifaceargs = parseArgs(entry)
			
			expectEqual( ifaceargs[2], 'iface_void') #other param null
			expectEqual(ifaceargs[0], spl[3].strip(),spl) #value is value
			expectEqual(ifaceargs[1], spl[4].strip(),spl)
			
			entry.found = True
			
		if hasSet:
			i+=1
			name = 'Set'+pname
			entry = None
			if name not in dictiface:
				if pname in ('CallTipUseStyle') :
					entry = dictiface[pname]
					
				else:
					for k in hackPrefix:
						if k in name:
							tname = k+name.replace(k,'')
							if tname not in dictiface:
								print k, ln
							entry = dictiface[tname]
							break
				if not entry:
					print ln
					raise 'not found'
			else:
				entry = dictiface[name]
			
			if entry.type!='set':
				print 'incorrect (is set), ',entry.name,entry.type
				raise 'incorrect (is set)'
			if name!=entry.name:
				print 'INCORRECT: name %s should be %s'%(entry.name, name)
				if modifyEntries: entry.name = name
			
			#verify args
			ifaceargs = parseArgs(entry)
			expectEqual(ifaceargs[0], 'iface_void',spl) #setters should return void
			if ifaceargs[2]=='iface_void':
				expectEqual(ifaceargs[1], spl[3].strip(),spl)
			else:
				expectEqual(ifaceargs[1], spl[4].strip(),spl)
				expectEqual(ifaceargs[2], spl[3].strip(),spl)

			entry.found = True
		
		
	#were all the entries found?
	for o in out:
		if o.found != True:
			print 'undocumented', o
	
	assert i== len(out)
	print 'done', len(out)
	
	return out #returns the modified entries. has corrections.
Example #2
0
def go(starget, starget2):
	print '''
# Constants, from IFaceTable.cxx
ScApp.SCFIND_WHOLEWORD
ScApp.SCFIND_MATCHCASE 
ScApp.SCFIND_WORDSTART 
ScApp.SCFIND_REGEXP
ScApp.SCFIND_POSIX
...many others...

# ScApp methods
ScApp.Trace(s)
ScApp.MsgBox(s)
ScApp.OpenFile(s)
ScApp.GetProperty(s)
ScApp.SetProperty(s, v)
ScApp.UnsetProperty(s)
ScApp.UpdateStatusBar(bUpdateSlowData)

# Menu commands'''
	f=open(starget2,'r')
	isStart=False
	out = []
	for line in f:
		if not isStart:
			if 'rgFriendlyNamedIDMConstants[] =' in line:
				isStart = True
		else:
			if '};' in line:
				break
			else:
				out.append(line.split('",')[0].replace('{"',''))
	assert isStart
	for part in out:
		#~ print 'void\tScApp.fn'+part+'()'
		print 'ScApp.fn'+part+'()'
	f.close()
	
	print '''
# Pane methods (all apply to ScOutput as well)
ScEditor.Append(txt)
ScEditor.Insert(npos, txt)
ScEditor.Remove(npos1, npos2)
ScEditor.Textrange(npos1, npos2)
ScEditor.FindText(s,n1=0,n2=-1,wholeWord=False,matchCase=False,regExp=False, nFlags=0)

	'''
	
	out = iface_get(target)
	
	
	okPrefix = {'Annotation':1, 'AutoC':1, 'Indic':1, 'Margin':1, 'Style':1, 'CallTip':1}
	for o in out:
		if o.name=='AddRefDocument': continue
		sname = 'fn'+o.name if o.type=='fun' else o.name
		
		# I see what they mean by putting Annotation, AutoC together... though..
		
		if o.type == 'get':
			if not o.name.startswith('Get'):
				if o.name.split('Get')[0] in okPrefix:
					sname = 'Get' + o.name.replace('Get', '')
				elif o.name=='LinesOnScreen': sname = 'Get' + o.name
				elif o.name=='SelectionIsRectangle': sname = 'Get' + o.name
				else:
					print 'fail: '+o.name
					return
		if o.type == 'set':
			if not o.name.startswith('Set'):
				if o.name.split('Set')[0] in okPrefix:
					sname = 'Set' + o.name.replace('Set', '')
				elif o.name=='CallTipUseStyle': sname = 'Set' + o.name
				else:
					print 'fail: '+o.name
					return
		
		if 'stringresult' not in o.args:
			rettype=o.returntype.replace('position','pos')
			print rettype + '\tScEditor.'+sname + o.args.replace(',)',')')
		else:
			assert o.returntype=='int'
			sargs = o.args.split(',')[0] + ')'
			
			print 'string' + '\tScEditor.'+sname + sargs
		
		if o.docs: print o.docs.replace('#','')