0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00

Added support for Python 3. (Roland Puntaier)

This commit is contained in:
Bram Moolenaar 2010-07-17 21:19:38 +02:00
parent 02c707a87d
commit bd5e15fd5c
28 changed files with 4229 additions and 58 deletions

View File

@ -216,6 +216,7 @@ SRC_DOS_UNIX = \
src/if_perl.xs \
src/if_perlsfio.c \
src/if_python.c \
src/if_python3.c \
src/if_ruby.c \
src/if_sniff.h \
src/if_tcl.c \
@ -225,6 +226,7 @@ SRC_DOS_UNIX = \
src/proto/if_perl.pro \
src/proto/if_perlsfio.pro \
src/proto/if_python.pro \
src/proto/if_python3.pro \
src/proto/if_ruby.pro \
src/proto/if_tcl.pro \
src/typemap \

View File

@ -80,8 +80,9 @@ DOSBIN_S = dosbin_s
# runtime/doc/*.txt and nsis/gvim.nsi. Other things in README_os2.txt. For a
# minor/major version: src/GvimExt/GvimExt.reg, src/vim.def, src/vim16.def.
# - Correct included_patches[] in src/version.c.
# - Compile Vim with GTK, Perl, Python, TCL, Ruby, MZscheme, Lua (if you can
# make it work), Cscope and "huge" features. Exclude workshop and SNiFF.
# - Compile Vim with GTK, Perl, Python, Python3, TCL, Ruby, MZscheme, Lua (if
# you can make it work), Cscope and "huge" features. Exclude workshop and
# SNiFF.
# - With these features: "make proto" (requires cproto and Motif installed;
# ignore warnings for missing include files, fix problems for syntax errors).
# - With these features: "make depend" (works best with gcc).

View File

@ -0,0 +1,606 @@
"python3complete.vim - Omni Completion for python
" Maintainer: Aaron Griffin <aaronmgriffin@gmail.com>
" Version: 0.9
" Last Updated: 18 Jun 2009
"
" Roland Puntaier: this file contains adaptations for python3 and is parallel to pythoncomplete.vim
"
" Changes
" TODO:
" 'info' item output can use some formatting work
" Add an "unsafe eval" mode, to allow for return type evaluation
" Complete basic syntax along with import statements
" i.e. "import url<c-x,c-o>"
" Continue parsing on invalid line??
"
" v 0.9
" * Fixed docstring parsing for classes and functions
" * Fixed parsing of *args and **kwargs type arguments
" * Better function param parsing to handle things like tuples and
" lambda defaults args
"
" v 0.8
" * Fixed an issue where the FIRST assignment was always used instead of
" using a subsequent assignment for a variable
" * Fixed a scoping issue when working inside a parameterless function
"
"
" v 0.7
" * Fixed function list sorting (_ and __ at the bottom)
" * Removed newline removal from docs. It appears vim handles these better in
" recent patches
"
" v 0.6:
" * Fixed argument completion
" * Removed the 'kind' completions, as they are better indicated
" with real syntax
" * Added tuple assignment parsing (whoops, that was forgotten)
" * Fixed import handling when flattening scope
"
" v 0.5:
" Yeah, I skipped a version number - 0.4 was never public.
" It was a bugfix version on top of 0.3. This is a complete
" rewrite.
"
if !has('python3')
echo "Error: Required vim compiled with +python3"
finish
endif
function! python3complete#Complete(findstart, base)
"findstart = 1 when we need to get the text length
if a:findstart == 1
let line = getline('.')
let idx = col('.')
while idx > 0
let idx -= 1
let c = line[idx]
if c =~ '\w'
continue
elseif ! c =~ '\.'
let idx = -1
break
else
break
endif
endwhile
return idx
"findstart = 0 when we need to return the list of completions
else
"vim no longer moves the cursor upon completion... fix that
let line = getline('.')
let idx = col('.')
let cword = ''
while idx > 0
let idx -= 1
let c = line[idx]
if c =~ '\w' || c =~ '\.'
let cword = c . cword
continue
elseif strlen(cword) > 0 || idx == 0
break
endif
endwhile
execute "py3 vimpy3complete('" . cword . "', '" . a:base . "')"
return g:python3complete_completions
endif
endfunction
function! s:DefPython()
py3 << PYTHONEOF
import sys, tokenize, io, types
from token import NAME, DEDENT, NEWLINE, STRING
debugstmts=[]
def dbg(s): debugstmts.append(s)
def showdbg():
for d in debugstmts: print("DBG: %s " % d)
def vimpy3complete(context,match):
global debugstmts
debugstmts = []
try:
import vim
cmpl = Completer()
cmpl.evalsource('\n'.join(vim.current.buffer),vim.eval("line('.')"))
all = cmpl.get_completions(context,match)
all.sort(key=lambda x:x['abbr'].replace('_','z'))
dictstr = '['
# have to do this for double quoting
for cmpl in all:
dictstr += '{'
for x in cmpl: dictstr += '"%s":"%s",' % (x,cmpl[x])
dictstr += '"icase":0},'
if dictstr[-1] == ',': dictstr = dictstr[:-1]
dictstr += ']'
#dbg("dict: %s" % dictstr)
vim.command("silent let g:python3complete_completions = %s" % dictstr)
#dbg("Completion dict:\n%s" % all)
except vim.error:
dbg("VIM Error: %s" % vim.error)
class Completer(object):
def __init__(self):
self.compldict = {}
self.parser = PyParser()
def evalsource(self,text,line=0):
sc = self.parser.parse(text,line)
src = sc.get_code()
dbg("source: %s" % src)
try: exec(src,self.compldict)
except: dbg("parser: %s, %s" % (sys.exc_info()[0],sys.exc_info()[1]))
for l in sc.locals:
try: exec(l,self.compldict)
except: dbg("locals: %s, %s [%s]" % (sys.exc_info()[0],sys.exc_info()[1],l))
def _cleanstr(self,doc):
return doc.replace('"',' ').replace("'",' ')
def get_arguments(self,func_obj):
def _ctor(class_ob):
try: return class_ob.__init__
except AttributeError:
for base in class_ob.__bases__:
rc = _ctor(base)
if rc is not None: return rc
return None
arg_offset = 1
if type(func_obj) == type: func_obj = _ctor(func_obj)
elif type(func_obj) == types.MethodType: arg_offset = 1
else: arg_offset = 0
arg_text=''
if type(func_obj) in [types.FunctionType, types.LambdaType,types.MethodType]:
try:
cd = func_obj.__code__
real_args = cd.co_varnames[arg_offset:cd.co_argcount]
defaults = func_obj.__defaults__ or []
defaults = ["=%s" % name for name in defaults]
defaults = [""] * (len(real_args)-len(defaults)) + defaults
items = [a+d for a,d in zip(real_args,defaults)]
if func_obj.__code__.co_flags & 0x4:
items.append("...")
if func_obj.__code__.co_flags & 0x8:
items.append("***")
arg_text = (','.join(items)) + ')'
except:
dbg("arg completion: %s: %s" % (sys.exc_info()[0],sys.exc_info()[1]))
pass
if len(arg_text) == 0:
# The doc string sometimes contains the function signature
# this works for alot of C modules that are part of the
# standard library
doc = func_obj.__doc__
if doc:
doc = doc.lstrip()
pos = doc.find('\n')
if pos > 0:
sigline = doc[:pos]
lidx = sigline.find('(')
ridx = sigline.find(')')
if lidx > 0 and ridx > 0:
arg_text = sigline[lidx+1:ridx] + ')'
if len(arg_text) == 0: arg_text = ')'
return arg_text
def get_completions(self,context,match):
#dbg("get_completions('%s','%s')" % (context,match))
stmt = ''
if context: stmt += str(context)
if match: stmt += str(match)
try:
result = None
all = {}
ridx = stmt.rfind('.')
if len(stmt) > 0 and stmt[-1] == '(':
result = eval(_sanitize(stmt[:-1]), self.compldict)
doc = result.__doc__
if doc is None: doc = ''
args = self.get_arguments(result)
return [{'word':self._cleanstr(args),'info':self._cleanstr(doc)}]
elif ridx == -1:
match = stmt
all = self.compldict
else:
match = stmt[ridx+1:]
stmt = _sanitize(stmt[:ridx])
result = eval(stmt, self.compldict)
all = dir(result)
dbg("completing: stmt:%s" % stmt)
completions = []
try: maindoc = result.__doc__
except: maindoc = ' '
if maindoc is None: maindoc = ' '
for m in all:
if m == "_PyCmplNoType": continue #this is internal
try:
dbg('possible completion: %s' % m)
if m.find(match) == 0:
if result is None: inst = all[m]
else: inst = getattr(result,m)
try: doc = inst.__doc__
except: doc = maindoc
typestr = str(inst)
if doc is None or doc == '': doc = maindoc
wrd = m[len(match):]
c = {'word':wrd, 'abbr':m, 'info':self._cleanstr(doc)}
if "function" in typestr:
c['word'] += '('
c['abbr'] += '(' + self._cleanstr(self.get_arguments(inst))
elif "method" in typestr:
c['word'] += '('
c['abbr'] += '(' + self._cleanstr(self.get_arguments(inst))
elif "module" in typestr:
c['word'] += '.'
elif "type" in typestr:
c['word'] += '('
c['abbr'] += '('
completions.append(c)
except:
i = sys.exc_info()
dbg("inner completion: %s,%s [stmt='%s']" % (i[0],i[1],stmt))
return completions
except:
i = sys.exc_info()
dbg("completion: %s,%s [stmt='%s']" % (i[0],i[1],stmt))
return []
class Scope(object):
def __init__(self,name,indent,docstr=''):
self.subscopes = []
self.docstr = docstr
self.locals = []
self.parent = None
self.name = name
self.indent = indent
def add(self,sub):
#print('push scope: [%s@%s]' % (sub.name,sub.indent))
sub.parent = self
self.subscopes.append(sub)
return sub
def doc(self,str):
""" Clean up a docstring """
d = str.replace('\n',' ')
d = d.replace('\t',' ')
while d.find(' ') > -1: d = d.replace(' ',' ')
while d[0] in '"\'\t ': d = d[1:]
while d[-1] in '"\'\t ': d = d[:-1]
dbg("Scope(%s)::docstr = %s" % (self,d))
self.docstr = d
def local(self,loc):
self._checkexisting(loc)
self.locals.append(loc)
def copy_decl(self,indent=0):
""" Copy a scope's declaration only, at the specified indent level - not local variables """
return Scope(self.name,indent,self.docstr)
def _checkexisting(self,test):
"Convienance function... keep out duplicates"
if test.find('=') > -1:
var = test.split('=')[0].strip()
for l in self.locals:
if l.find('=') > -1 and var == l.split('=')[0].strip():
self.locals.remove(l)
def get_code(self):
str = ""
if len(self.docstr) > 0: str += '"""'+self.docstr+'"""\n'
for l in self.locals:
if l.startswith('import'): str += l+'\n'
str += 'class _PyCmplNoType:\n def __getattr__(self,name):\n return None\n'
for sub in self.subscopes:
str += sub.get_code()
for l in self.locals:
if not l.startswith('import'): str += l+'\n'
return str
def pop(self,indent):
#print('pop scope: [%s] to [%s]' % (self.indent,indent))
outer = self
while outer.parent != None and outer.indent >= indent:
outer = outer.parent
return outer
def currentindent(self):
#print('parse current indent: %s' % self.indent)
return ' '*self.indent
def childindent(self):
#print('parse child indent: [%s]' % (self.indent+1))
return ' '*(self.indent+1)
class Class(Scope):
def __init__(self, name, supers, indent, docstr=''):
Scope.__init__(self,name,indent, docstr)
self.supers = supers
def copy_decl(self,indent=0):
c = Class(self.name,self.supers,indent, self.docstr)
for s in self.subscopes:
c.add(s.copy_decl(indent+1))
return c
def get_code(self):
str = '%sclass %s' % (self.currentindent(),self.name)
if len(self.supers) > 0: str += '(%s)' % ','.join(self.supers)
str += ':\n'
if len(self.docstr) > 0: str += self.childindent()+'"""'+self.docstr+'"""\n'
if len(self.subscopes) > 0:
for s in self.subscopes: str += s.get_code()
else:
str += '%spass\n' % self.childindent()
return str
class Function(Scope):
def __init__(self, name, params, indent, docstr=''):
Scope.__init__(self,name,indent, docstr)
self.params = params
def copy_decl(self,indent=0):
return Function(self.name,self.params,indent, self.docstr)
def get_code(self):
str = "%sdef %s(%s):\n" % \
(self.currentindent(),self.name,','.join(self.params))
if len(self.docstr) > 0: str += self.childindent()+'"""'+self.docstr+'"""\n'
str += "%spass\n" % self.childindent()
return str
class PyParser:
def __init__(self):
self.top = Scope('global',0)
self.scope = self.top
def _parsedotname(self,pre=None):
#returns (dottedname, nexttoken)
name = []
if pre is None:
tokentype, token, indent = self.donext()
if tokentype != NAME and token != '*':
return ('', token)
else: token = pre
name.append(token)
while True:
tokentype, token, indent = self.donext()
if token != '.': break
tokentype, token, indent = self.donext()
if tokentype != NAME: break
name.append(token)
return (".".join(name), token)
def _parseimportlist(self):
imports = []
while True:
name, token = self._parsedotname()
if not name: break
name2 = ''
if token == 'as': name2, token = self._parsedotname()
imports.append((name, name2))
while token != "," and "\n" not in token:
tokentype, token, indent = self.donext()
if token != ",": break
return imports
def _parenparse(self):
name = ''
names = []
level = 1
while True:
tokentype, token, indent = self.donext()
if token in (')', ',') and level == 1:
if '=' not in name: name = name.replace(' ', '')
names.append(name.strip())
name = ''
if token == '(':
level += 1
name += "("
elif token == ')':
level -= 1
if level == 0: break
else: name += ")"
elif token == ',' and level == 1:
pass
else:
name += "%s " % str(token)
return names
def _parsefunction(self,indent):
self.scope=self.scope.pop(indent)
tokentype, fname, ind = self.donext()
if tokentype != NAME: return None
tokentype, open, ind = self.donext()
if open != '(': return None
params=self._parenparse()
tokentype, colon, ind = self.donext()
if colon != ':': return None
return Function(fname,params,indent)
def _parseclass(self,indent):
self.scope=self.scope.pop(indent)
tokentype, cname, ind = self.donext()
if tokentype != NAME: return None
super = []
tokentype, thenext, ind = self.donext()
if thenext == '(':
super=self._parenparse()
elif thenext != ':': return None
return Class(cname,super,indent)
def _parseassignment(self):
assign=''
tokentype, token, indent = self.donext()
if tokentype == tokenize.STRING or token == 'str':
return '""'
elif token == '(' or token == 'tuple':
return '()'
elif token == '[' or token == 'list':
return '[]'
elif token == '{' or token == 'dict':
return '{}'
elif tokentype == tokenize.NUMBER:
return '0'
elif token == 'open' or token == 'file':
return 'file'
elif token == 'None':
return '_PyCmplNoType()'
elif token == 'type':
return 'type(_PyCmplNoType)' #only for method resolution
else:
assign += token
level = 0
while True:
tokentype, token, indent = self.donext()
if token in ('(','{','['):
level += 1
elif token in (']','}',')'):
level -= 1
if level == 0: break
elif level == 0:
if token in (';','\n'): break
assign += token
return "%s" % assign
def donext(self):
type, token, (lineno, indent), end, self.parserline = next(self.gen)
if lineno == self.curline:
#print('line found [%s] scope=%s' % (line.replace('\n',''),self.scope.name))
self.currentscope = self.scope
return (type, token, indent)
def _adjustvisibility(self):
newscope = Scope('result',0)
scp = self.currentscope
while scp != None:
if type(scp) == Function:
slice = 0
#Handle 'self' params
if scp.parent != None and type(scp.parent) == Class:
slice = 1
newscope.local('%s = %s' % (scp.params[0],scp.parent.name))
for p in scp.params[slice:]:
i = p.find('=')
if len(p) == 0: continue
pvar = ''
ptype = ''
if i == -1:
pvar = p
ptype = '_PyCmplNoType()'
else:
pvar = p[:i]
ptype = _sanitize(p[i+1:])
if pvar.startswith('**'):
pvar = pvar[2:]
ptype = '{}'
elif pvar.startswith('*'):
pvar = pvar[1:]
ptype = '[]'
newscope.local('%s = %s' % (pvar,ptype))
for s in scp.subscopes:
ns = s.copy_decl(0)
newscope.add(ns)
for l in scp.locals: newscope.local(l)
scp = scp.parent
self.currentscope = newscope
return self.currentscope
#p.parse(vim.current.buffer[:],vim.eval("line('.')"))
def parse(self,text,curline=0):
self.curline = int(curline)
buf = io.StringIO(''.join(text) + '\n')
self.gen = tokenize.generate_tokens(buf.readline)
self.currentscope = self.scope
try:
freshscope=True
while True:
tokentype, token, indent = self.donext()
#dbg( 'main: token=[%s] indent=[%s]' % (token,indent))
if tokentype == DEDENT or token == "pass":
self.scope = self.scope.pop(indent)
elif token == 'def':
func = self._parsefunction(indent)
if func is None:
print("function: syntax error...")
continue
dbg("new scope: function")
freshscope = True
self.scope = self.scope.add(func)
elif token == 'class':
cls = self._parseclass(indent)
if cls is None:
print("class: syntax error...")
continue
freshscope = True
dbg("new scope: class")
self.scope = self.scope.add(cls)
elif token == 'import':
imports = self._parseimportlist()
for mod, alias in imports:
loc = "import %s" % mod
if len(alias) > 0: loc += " as %s" % alias
self.scope.local(loc)
freshscope = False
elif token == 'from':
mod, token = self._parsedotname()
if not mod or token != "import":
print("from: syntax error...")
continue
names = self._parseimportlist()
for name, alias in names:
loc = "from %s import %s" % (mod,name)
if len(alias) > 0: loc += " as %s" % alias
self.scope.local(loc)
freshscope = False
elif tokentype == STRING:
if freshscope: self.scope.doc(token)
elif tokentype == NAME:
name,token = self._parsedotname(token)
if token == '=':
stmt = self._parseassignment()
dbg("parseassignment: %s = %s" % (name, stmt))
if stmt != None:
self.scope.local("%s = %s" % (name,stmt))
freshscope = False
except StopIteration: #thrown on EOF
pass
except:
dbg("parse error: %s, %s @ %s" %
(sys.exc_info()[0], sys.exc_info()[1], self.parserline))
return self._adjustvisibility()
def _sanitize(str):
val = ''
level = 0
for c in str:
if c in ('(','{','['):
level += 1
elif c in (']','}',')'):
level -= 1
elif level == 0:
val += c
return val
sys.path.extend(['.','..'])
PYTHONEOF
endfunction
call s:DefPython()

View File

@ -1089,17 +1089,12 @@ Before (beta) release 7.3:
- Add fixes for 7.2 to version7.txt
- Add hg history to version7.txt
- Remove UF_VERSION_CRYPT_PREV and UF_VERSION_PREV.
- Build the MS-Windows version with Python 2.6.5 and 3.1.2?
Before release 7.3:
- Rename vim73 branch to default (hints: Xavier de Gaye, 2010 May 23)
Vim 7.3:
Patches to possibly include:
- Patch for Python 3 support. (Roland Puntaier, 2009 Sep 22)
Includes changes for omnicompletion.
Needs some more testing.
Update 2010 Apr 20, patch by Andy Kittner, May 16
Build the MS-Windows version with Python 2.6.5 and 3.1.2?
Needs some work:
- Have a look at patch to enable screen access from Python. (Marko Mahnic,
2010 Apr 12)

View File

@ -16,7 +16,7 @@ syn keyword vimTodo contained COMBAK FIXME TODO XXX
syn cluster vimCommentGroup contains=vimTodo,@Spell
" regular vim commands {{{2
syn keyword vimCommand contained abc[lear] argdo argu[ment] bel[owright] bN[ext] breakd[el] b[uffer] caddb[uffer] cb[uffer] cex[pr] cg[etfile] checkt[ime] cnew[er] col[der] con[tinue] cq[uit] delc[ommand] diffoff diffu[pdate] dr[op] echoe[rr] el[se] endfo[r] endw[hile] f[ile] fin[d] fo[ld] foldo[pen] gr[ep] his[tory] il[ist] iuna[bbrev] keepalt lad[dexpr] later lcl[ose] lf[ile] lg[etfile] ll lmapc[lear] lnf[ile] lockv[ar] lp[revious] lv[imgrep] ma[rk] mk[exrc] mkv[imrc] mz[scheme] new noh[lsearch] on[ly] ped[it] popu prev[ious] prof[ile] pta[g] ptn[ext] pts[elect] py[thon] r[ead] redr[aw] ret[ab] rightb[elow] rundo san[dbox] sbf[irst] sbN[ext] scripte[ncoding] setg[lobal] sh[ell] sla[st] sme sni[ff] sor[t] spelli[nfo] sp[lit] startg[replace] st[op] sunme syncbind tabd[o] tabl[ast] tabN[ext] tabs tcld[o] th[row] tm[enu] tp[revious] tu undoj[oin] uns[ilent] vert[ical] vi[sual] wa[ll] winp[os] wp[revious] ws[verb] xa[ll] xmenu xnoremenu
syn keyword vimCommand contained abc[lear] argdo argu[ment] bel[owright] bN[ext] breakd[el] b[uffer] caddb[uffer] cb[uffer] cex[pr] cg[etfile] checkt[ime] cnew[er] col[der] con[tinue] cq[uit] delc[ommand] diffoff diffu[pdate] dr[op] echoe[rr] el[se] endfo[r] endw[hile] f[ile] fin[d] fo[ld] foldo[pen] gr[ep] his[tory] il[ist] iuna[bbrev] keepalt lad[dexpr] later lcl[ose] lf[ile] lg[etfile] ll lmapc[lear] lnf[ile] lockv[ar] lp[revious] lv[imgrep] ma[rk] mk[exrc] mkv[imrc] mz[scheme] new noh[lsearch] on[ly] ped[it] popu prev[ious] prof[ile] pta[g] ptn[ext] pts[elect] py[thon] py3 r[ead] redr[aw] ret[ab] rightb[elow] rundo san[dbox] sbf[irst] sbN[ext] scripte[ncoding] setg[lobal] sh[ell] sla[st] sme sni[ff] sor[t] spelli[nfo] sp[lit] startg[replace] st[op] sunme syncbind tabd[o] tabl[ast] tabN[ext] tabs tcld[o] th[row] tm[enu] tp[revious] tu undoj[oin] uns[ilent] vert[ical] vi[sual] wa[ll] winp[os] wp[revious] ws[verb] xa[ll] xmenu xnoremenu
syn keyword vimCommand contained abo[veleft] arge[dit] as[cii] bf[irst] bo[tright] breakl[ist] buffers cad[dexpr] cc cf[ile] c[hange] cla[st] cn[ext] colo[rscheme] cope[n] cr[ewind] d[elete] diffpatch dig[raphs] ds[earch] echom[sg] elsei[f] endf[unction] ene[w] files fini[sh] foldc[lose] for grepa[dd] iabc[lear] imapc[lear] j[oin] keepj[umps] laddf[ile] lb[uffer] le[ft] lfir[st] lgr[ep] lla[st] lnew[er] lNf[ile] lol[der] lr[ewind] lvimgrepa[dd] marks mks[ession] mod[e] nbc[lose] n[ext] nu[mber] o[pen] pe[rl] popu[p] p[rint] promptf[ind] ptf[irst] ptN[ext] pu[t] qa[ll] rec[over] redraws[tatus] retu[rn] rub[y] ru[ntime] sa[rgument] sbl[ast] sbp[revious] scrip[tnames] setl[ocal] sign sl[eep] smenu sno[magic] so[urce] spellr[epall] spr[evious] star[tinsert] stopi[nsert] sunmenu t tabe[dit] tabm[ove] tabo[nly] ta[g] tclf[ile] tj[ump] tn[ext] tr[ewind] tu[nmenu] undol[ist] up[date] vie[w] vmapc[lear] wh[ile] win[size] wq wundo x[it] XMLent xunme
syn keyword vimCommand contained al[l] argg[lobal] bad[d] bl[ast] bp[revious] br[ewind] bun[load] caddf[ile] ccl[ose] cfir[st] changes cl[ist] cN[ext] comc[lear] co[py] cuna[bbrev] delf[unction] diffpu[t] di[splay] dsp[lit] echon em[enu] en[dif] ex filetype fir[st] folddoc[losed] fu[nction] ha[rdcopy] if is[earch] ju[mps] kee[pmarks] lan[guage] lc[d] lefta[bove] lgetb[uffer] lgrepa[dd] lli[st] lne[xt] lo[adview] lop[en] ls lw[indow] mat[ch] mksp[ell] m[ove] nb[key] N[ext] ol[dfiles] opt[ions] perld[o] pp[op] P[rint] promptr[epl] ptj[ump] ptp[revious] pw[d] q[uit] redi[r] reg[isters] rew[ind] rubyd[o] rv[iminfo] sav[eas] sbm[odified] sbr[ewind] se[t] sf[ind] sil[ent] sm[agic] sn[ext] snoreme spelld[ump] spellu[ndo] sre[wind] startr[eplace] sts[elect] sus[pend] tab tabf[ind] tabnew tabp[revious] tags te[aroff] tl[ast] tN[ext] try una[bbreviate] unh[ide] verb[ose] vim[grep] vne[w] winc[md] wn[ext] wqa[ll] wv[iminfo] xmapc[lear] XMLns xunmenu
syn keyword vimCommand contained arga[dd] argl[ocal] ba[ll] bm[odified] brea[k] bro[wse] bw[ipeout] cal[l] cd cgetb[uffer] chd[ir] clo[se] cnf[ile] comp[iler] cpf[ile] cw[indow] delm[arks] diffsplit dj[ump] earlier e[dit] emenu* endt[ry] exi[t] fina[lly] fix[del] foldd[oopen] go[to] hid[e] ij[ump] isp[lit] k laddb[uffer] la[st] lch[dir] lex[pr] lgete[xpr] l[ist] lmak[e] lN[ext] loc[kmarks] lpf[ile] lt[ag] mak[e] menut[ranslate] mkvie[w] mzf[ile] nbs[tart] nmapc[lear] omapc[lear] pc[lose] po[p] pre[serve] profd[el] ps[earch] ptl[ast] ptr[ewind] pyf[ile] quita[ll] red[o] res[ize] ri[ght] rubyf[ile] sal[l] sba[ll] sbn[ext] sb[uffer] setf[iletype] sfir[st] sim[alt] sm[ap] sN[ext] snoremenu spe[llgood] spellw[rong] sta[g] stj[ump] sun[hide] sv[iew] tabc[lose] tabfir[st] tabn[ext] tabr[ewind] tc[l] tf[irst] tm to[pleft] ts[elect] u[ndo] unlo[ckvar] ve[rsion] vimgrepa[dd] vs[plit] windo wN[ext] w[rite] X xme xnoreme y[ank]
@ -594,16 +594,16 @@ if (g:vimsyn_embed =~ 'P' && has("python")) && filereadable(s:pythonpath)
unlet! b:current_syntax
exe "syn include @vimPythonScript ".s:pythonpath
if exists("g:vimsyn_folding") && g:vimsyn_folding =~ 'P'
syn region vimPythonRegion fold matchgroup=vimScriptDelim start=+py\%[thon]\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimPythonScript
syn region vimPythonRegion fold matchgroup=vimScriptDelim start=+py\%[thon]\s*<<\s*$+ end=+\.$+ contains=@vimPythonScript
syn region vimPythonRegion fold matchgroup=vimScriptDelim start=+py[3]\%[thon]\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimPythonScript
syn region vimPythonRegion fold matchgroup=vimScriptDelim start=+py[3]\%[thon]\s*<<\s*$+ end=+\.$+ contains=@vimPythonScript
else
syn region vimPythonRegion matchgroup=vimScriptDelim start=+py\%[thon]\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimPythonScript
syn region vimPythonRegion matchgroup=vimScriptDelim start=+py\%[thon]\s*<<\s*$+ end=+\.$+ contains=@vimPythonScript
syn region vimPythonRegion matchgroup=vimScriptDelim start=+py[3]\%[thon]\s*<<\s*\z(.*\)$+ end=+^\z1$+ contains=@vimPythonScript
syn region vimPythonRegion matchgroup=vimScriptDelim start=+py[3]\%[thon]\s*<<\s*$+ end=+\.$+ contains=@vimPythonScript
endif
syn cluster vimFuncBodyList add=vimPythonRegion
else
syn region vimEmbedError start=+py\%[thon]\s*<<\s*\z(.*\)$+ end=+^\z1$+
syn region vimEmbedError start=+py\%[thon]\s*<<\s*$+ end=+\.$+
syn region vimEmbedError start=+py[3]\%[thon]\s*<<\s*\z(.*\)$+ end=+^\z1$+
syn region vimEmbedError start=+py[3]\%[thon]\s*<<\s*$+ end=+\.$+
endif
unlet s:pythonpath

View File

@ -44,6 +44,9 @@
# PYTHON define to path to Python dir to get PYTHON support (not defined)
# PYTHON_VER define to version of Python being used (22)
# DYNAMIC_PYTHON no or yes: use yes to load the Python DLL dynamically (no)
# PYTHON3 define to path to Python3 dir to get PYTHON3 support (not defined)
# PYTHON3_VER define to version of Python3 being used (31)
# DYNAMIC_PYTHON3 no or yes: use yes to load the Python3 DLL dynamically (no)
# TCL define to path to TCL dir to get TCL support (not defined)
# TCL_VER define to version of TCL being used (83)
# DYNAMIC_TCL no or yes: use yes to load the TCL DLL dynamically (no)
@ -141,6 +144,9 @@ NETBEANS = yes
### PYTHON: uncomment this line if you want python support in vim
# PYTHON=c:\python22
### PYTHON3: uncomment this line if you want python3 support in vim
# PYTHON3=c:\python31
### RUBY: uncomment this line if you want ruby support in vim
# RUBY=c:\ruby
@ -207,6 +213,7 @@ ALIGN = 4
!if ("$(FASTCALL)"=="") && \
("$(LUA)"=="") && \
("$(PYTHON)"=="") && \
("$(PYTHON3)"=="") && \
("$(PERL)"=="") && \
("$(TCL)"=="") && \
("$(RUBY)"=="") && \
@ -327,9 +334,15 @@ PERL_LIB_FLAG = /nodefaultlib:
! endif
!endif
!ifdef PYTHON
!ifdef PYTHON3
DYNAMIC_PYTHON=yes
DYNAMIC_PYTHON3=yes
!endif
!endif
!ifdef PYTHON
INTERP_DEFINES = $(INTERP_DEFINES) -DFEAT_PYTHON
INCLUDE = $(PYTHON)\include;$(INCLUDE)
!ifndef PYTHON_VER
PYTHON_VER = 22
!endif
@ -339,6 +352,18 @@ PYTHON_LIB_FLAG = /nodefaultlib:
!endif
!endif
!ifdef PYTHON3
INTERP_DEFINES = $(INTERP_DEFINES) -DFEAT_PYTHON3
!ifndef PYTHON3_VER
PYTHON3_VER = 31
!endif
!if "$(DYNAMIC_PYTHON3)" == "yes"
INTERP_DEFINES = $(INTERP_DEFINES) -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python$(PYTHON3_VER).dll\"
PYTHON3_LIB_FLAG = /nodefaultlib:
!endif
!endif
!ifdef RUBY
!ifndef RUBY_VER
RUBY_VER = 16
@ -618,6 +643,11 @@ vimobj = $(vimobj) \
$(OBJDIR)\if_python.obj
!endif
!ifdef PYTHON3
vimobj = $(vimobj) \
$(OBJDIR)\if_python3.obj
!endif
!ifdef RUBY
vimobj = $(vimobj) \
$(OBJDIR)\if_ruby.obj
@ -734,6 +764,12 @@ MSG = $(MSG) PYTHON
MSG = $(MSG)(dynamic)
! endif
!endif
!ifdef PYTHON3
MSG = $(MSG) PYTHON3
! if "$(DYNAMIC_PYTHON3)" == "yes"
MSG = $(MSG)(dynamic)
! endif
!endif
!ifdef RUBY
MSG = $(MSG) RUBY
! if "$(DYNAMIC_RUBY)" == "yes"
@ -827,6 +863,9 @@ clean:
!ifdef PYTHON
-@del python.lib
!endif
!ifdef PYTHON3
-@del python3.lib
!endif
!ifdef RUBY
-@del ruby.lib
!endif
@ -867,6 +906,9 @@ $(DLLTARGET): $(OBJDIR) $(vimdllobj)
!ifdef PYTHON
$(PYTHON_LIB_FLAG)python.lib+
!endif
!ifdef PYTHON3
$(PYTHON3_LIB_FLAG)python3.lib+
!endif
!ifdef RUBY
$(RUBY_LIB_FLAG)ruby.lib+
!endif
@ -919,6 +961,9 @@ $(TARGET): $(OBJDIR) $(vimobj) $(OBJDIR)\$(RESFILE)
!ifdef PYTHON
$(PYTHON_LIB_FLAG)python.lib+
!endif
!ifdef PYTHON3
$(PYTHON3_LIB_FLAG)python3.lib+
!endif
!ifdef RUBY
$(RUBY_LIB_FLAG)ruby.lib+
!endif
@ -962,7 +1007,10 @@ if_perl.c: if_perl.xs typemap
$(PERL)\lib\ExtUtils\typemap if_perl.xs > $@
$(OBJDIR)\if_python.obj: if_python.c python.lib
$(CC) $(CCARG) $(CC1) $(CC2)$@ -pc if_python.c
$(CC) -I$(PYTHON)\include $(CCARG) $(CC1) $(CC2)$@ -pc if_python.c
$(OBJDIR)\if_python3.obj: if_python3.c python3.lib
$(CC) -I$(PYTHON3)\include $(CCARG) $(CC1) $(CC2)$@ -pc if_python3.c
$(OBJDIR)\if_ruby.obj: if_ruby.c ruby.lib
$(CC) $(CCARG) $(CC1) $(CC2)$@ -pc if_ruby.c
@ -1017,6 +1065,9 @@ perl.lib: $(PERL)\lib\CORE\perl$(PERL_VER).lib
python.lib: $(PYTHON)\libs\python$(PYTHON_VER).lib
coff2omf $(PYTHON)\libs\python$(PYTHON_VER).lib $@
python3.lib: $(PYTHON3)\libs\python$(PYTHON3_VER).lib
coff2omf $(PYTHON3)\libs\python$(PYTHON3_VER).lib $@
ruby.lib: $(RUBY)\lib\$(RUBY_INSTALL_NAME).lib
coff2omf $(RUBY)\lib\$(RUBY_INSTALL_NAME).lib $@
@ -1065,3 +1116,4 @@ $(OBJDIR)\bcc.cfg: Make_bc5.mak $(OBJDIR)
| $@
# vi:set sts=4 sw=4:

View File

@ -14,6 +14,9 @@
# PYTHON define to path to Python dir to get PYTHON support (not defined)
# PYTHON_VER define to version of Python being used (22)
# DYNAMIC_PYTHON no or yes: use yes to load the Python DLL dynamically (yes)
# PYTHON3 define to path to Python3 dir to get PYTHON3 support (not defined)
# PYTHON3_VER define to version of Python3 being used (22)
# DYNAMIC_PYTHON3 no or yes: use yes to load the Python3 DLL dynamically (yes)
# TCL define to path to TCL dir to get TCL support (not defined)
# TCL_VER define to version of TCL being used (83)
# DYNAMIC_TCL no or yes: use yes to load the TCL DLL dynamically (yes)
@ -139,7 +142,6 @@ endif
##############################
ifdef PYTHON
DEFINES += -DFEAT_PYTHON
INCLUDES += -I$(PYTHON)/include
EXTRA_OBJS += $(OUTDIR)/if_python.o
ifndef DYNAMIC_PYTHON
@ -157,6 +159,29 @@ EXTRA_LIBS += $(PYTHON)/libs/python$(PYTHON_VER).lib
endif
endif
##############################
# DYNAMIC_PYTHON3=yes works.
# DYNAMIC_PYTHON3=no does not (unresolved externals on link).
##############################
ifdef PYTHON3
DEFINES += -DFEAT_PYTHON3
EXTRA_OBJS += $(OUTDIR)/if_python3.o
ifndef DYNAMIC_PYTHON3
DYNAMIC_PYTHON3 = yes
endif
ifndef PYTHON3_VER
PYTHON3_VER = 31
endif
ifeq (yes, $(DYNAMIC_PYTHON3))
DEFINES += -DDYNAMIC_PYTHON3 -DDYNAMIC_PYTHON3_DLL=\"python$(PYTHON3_VER).dll\"
else
EXTRA_LIBS += $(PYTHON3)/libs/python$(PYTHON3_VER).lib
endif
endif
##############################
# DYNAMIC_RUBY=yes works.
# DYNAMIC_RUBY=no does not (process exits).
@ -563,6 +588,12 @@ $(OUTDIR)/if_cscope.o: if_cscope.c $(INCL) if_cscope.h
$(OUTDIR)/if_ole.o: if_ole.cpp $(INCL)
$(CC) -c $(CFLAGS) if_ole.cpp -o $(OUTDIR)/if_ole.o
$(OUTDIR)/if_python.o : if_python.c $(INCL)
$(CC) -c $(CFLAGS) -I$(PYTHON)/include $< -o $@
$(OUTDIR)/if_python3.o : if_python3.c $(INCL)
$(CC) -c $(CFLAGS) -I$(PYTHON3)/include $< -o $@
if_perl.c: if_perl.xs typemap
$(PERL)/bin/perl `cygpath -d $(PERL)/lib/ExtUtils/xsubpp` \
-prototypes -typemap \
@ -612,3 +643,4 @@ else
@echo char_u *compiled_user = (char_u *)"$(USERNAME)"; >> pathdef.c
@echo char_u *compiled_sys = (char_u *)"$(USERDOMAIN)"; >> pathdef.c
endif

View File

@ -194,6 +194,28 @@ PYTHONINC=-I $(PYTHON)/win32inc
endif
endif
#PYTHON3: See comment for Python 2 above
ifdef PYTHON3
ifndef DYNAMIC_PYTHON3
DYNAMIC_PYTHON3=yes
endif
ifndef PYTHON3_VER
PYTHON3_VER=31
endif
ifeq (no,$(DYNAMIC_PYTHON3))
PYTHON3LIB=-L$(PYTHON3)/libs -lPYTHON$(PYTHON3_VER)
endif
ifeq ($(CROSS),no)
PYTHON3INC=-I $(PYTHON3)/include
else
PYTHON3INC=-I $(PYTHON3)/win32inc
endif
endif
# TCL interface:
# TCL=[Path to TCL directory]
# DYNAMIC_TCL=yes (to load the TCL DLL dynamically)
@ -334,9 +356,16 @@ endif
endif
ifdef PYTHON
CFLAGS += -DFEAT_PYTHON $(PYTHONINC)
CFLAGS += -DFEAT_PYTHON
ifeq (yes, $(DYNAMIC_PYTHON))
CFLAGS += -DDYNAMIC_PYTHON -DDYNAMIC_PYTHON_DLL=\"python$(PYTHON_VER).dll\"
CFLAGS += -DDYNAMIC_PYTHON
endif
endif
ifdef PYTHON3
CFLAGS += -DFEAT_PYTHON3
ifeq (yes, $(DYNAMIC_PYTHON3))
CFLAGS += -DDYNAMIC_PYTHON3
endif
endif
@ -468,6 +497,9 @@ endif
ifdef PYTHON
OBJ += $(OUTDIR)/if_python.o
endif
ifdef PYTHON3
OBJ += $(OUTDIR)/if_python3.o
endif
ifdef RUBY
OBJ += $(OUTDIR)/if_ruby.o
endif
@ -576,7 +608,7 @@ uninstal.exe: uninstal.c
$(CC) $(CFLAGS) -o uninstal.exe uninstal.c $(LIB)
$(TARGET): $(OUTDIR) $(OBJ)
$(CC) $(CFLAGS) $(LFLAGS) -o $@ $(OBJ) $(LIB) -lole32 -luuid $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(RUBYLIB)
$(CC) $(CFLAGS) $(LFLAGS) -o $@ $(OBJ) $(LIB) -lole32 -luuid $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(PYTHON3LIB) $(RUBYLIB)
upx: exes
upx gvim.exe
@ -608,6 +640,12 @@ INCL = vim.h feature.h os_win32.h os_dos.h ascii.h keymap.h term.h macros.h \
structs.h regexp.h option.h ex_cmds.h proto.h globals.h farsi.h \
gui.h
$(OUTDIR)/if_python.o : if_python.c $(INCL)
$(CC) -c $(CFLAGS) $(PYTHONINC) -DDYNAMIC_PYTHON_DLL=\"python$(PYTHON_VER).dll\" $< -o $@
$(OUTDIR)/if_python3.o : if_python3.c $(INCL)
$(CC) -c $(CFLAGS) $(PYTHON3INC) -DDYNAMIC_PYTHON3_DLL=\"PYTHON$(PYTHON3_VER).dll\" $< -o $@
$(OUTDIR)/%.o : %.c $(INCL)
$(CC) -c $(CFLAGS) $< -o $@
@ -659,7 +697,7 @@ ifneq (sh.exe, $(SHELL))
@echo 'char_u *default_vim_dir = (char_u *)"$(VIMRCLOC)";' >> pathdef.c
@echo 'char_u *default_vimruntime_dir = (char_u *)"$(VIMRUNTIMEDIR)";' >> pathdef.c
@echo 'char_u *all_cflags = (char_u *)"$(CC) $(CFLAGS)";' >> pathdef.c
@echo 'char_u *all_lflags = (char_u *)"$(CC) $(CFLAGS) $(LFLAGS) -o $(TARGET) $(LIB) -lole32 -luuid $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(RUBYLIB)";' >> pathdef.c
@echo 'char_u *all_lflags = (char_u *)"$(CC) $(CFLAGS) $(LFLAGS) -o $(TARGET) $(LIB) -lole32 -luuid $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(PYTHON3LIB) $(RUBYLIB)";' >> pathdef.c
@echo 'char_u *compiled_user = (char_u *)"$(USERNAME)";' >> pathdef.c
@echo 'char_u *compiled_sys = (char_u *)"$(USERDOMAIN)";' >> pathdef.c
else
@ -669,7 +707,7 @@ else
@echo char_u *default_vim_dir = (char_u *)"$(VIMRCLOC)"; >> pathdef.c
@echo char_u *default_vimruntime_dir = (char_u *)"$(VIMRUNTIMEDIR)"; >> pathdef.c
@echo char_u *all_cflags = (char_u *)"$(CC) $(CFLAGS)"; >> pathdef.c
@echo char_u *all_lflags = (char_u *)"$(CC) $(CFLAGS) $(LFLAGS) -o $(TARGET) $(LIB) -lole32 -luuid $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(RUBYLIB)"; >> pathdef.c
@echo char_u *all_lflags = (char_u *)"$(CC) $(CFLAGS) $(LFLAGS) -o $(TARGET) $(LIB) -lole32 -luuid $(LUA_LIB) $(MZSCHEME_LIBDIR) $(MZSCHEME_LIB) $(PYTHONLIB) $(PYTHON3LIB) $(RUBYLIB)"; >> pathdef.c
@echo char_u *compiled_user = (char_u *)"$(USERNAME)"; >> pathdef.c
@echo char_u *compiled_sys = (char_u *)"$(USERDOMAIN)"; >> pathdef.c
endif

View File

@ -52,6 +52,11 @@
# DYNAMIC_PYTHON=yes (to load the Python DLL dynamically)
# PYTHON_VER=[Python version, eg 15, 20] (default is 22)
#
# Python3 interface:
# PYTHON3=[Path to Python3 directory]
# DYNAMIC_PYTHON3=yes (to load the Python3 DLL dynamically)
# PYTHON3_VER=[Python3 version, eg 30, 31] (default is 31)
#
# Ruby interface:
# RUBY=[Path to Ruby directory]
# DYNAMIC_RUBY=yes (to load the Ruby DLL dynamically)
@ -166,6 +171,9 @@ OBJDIR = $(OBJDIR)L
!ifdef PYTHON
OBJDIR = $(OBJDIR)Y
!endif
!ifdef PYTHON3
OBJDIR = $(OBJDIR)H
!endif
!ifdef TCL
OBJDIR = $(OBJDIR)T
!endif
@ -641,6 +649,13 @@ LUA_LIB = "$(LUA)\lib\lua$(LUA_VER).lib"
!endif
!endif
!ifdef PYTHON
!ifdef PYTHON3
DYNAMIC_PYTHON=yes
DYNAMIC_PYTHON3=yes
!endif
!endif
# PYTHON interface
!ifdef PYTHON
!ifndef PYTHON_VER
@ -662,6 +677,27 @@ PYTHON_LIB = $(PYTHON)\libs\python$(PYTHON_VER).lib
!endif
!endif
# PYTHON3 interface
!ifdef PYTHON3
!ifndef PYTHON3_VER
PYTHON3_VER = 31
!endif
!message Python3 requested (version $(PYTHON3_VER)) - root dir is "$(PYTHON3)"
!if "$(DYNAMIC_PYTHON3)" == "yes"
!message Python3 DLL will be loaded dynamically
!endif
CFLAGS = $(CFLAGS) -DFEAT_PYTHON3
PYTHON3_OBJ = $(OUTDIR)\if_python3.obj
PYTHON3_INC = /I "$(PYTHON3)\Include" /I "$(PYTHON3)\PC"
!if "$(DYNAMIC_PYTHON3)" == "yes"
CFLAGS = $(CFLAGS) -DDYNAMIC_PYTHON3 \
-DDYNAMIC_PYTHON3_DLL=\"python$(PYTHON3_VER).dll\"
PYTHON3_LIB = /nodefaultlib:python$(PYTHON3_VER).lib
!else
PYTHON3_LIB = $(PYTHON3)\libs\python$(PYTHON3_VER).lib
!endif
!endif
# MzScheme interface
!ifdef MZSCHEME
!message MzScheme requested - root dir is "$(MZSCHEME)"
@ -835,7 +871,7 @@ conflags = $(conflags) /map /mapinfo:lines
LINKARGS1 = $(linkdebug) $(conflags)
LINKARGS2 = $(CON_LIB) $(GUI_LIB) $(LIBC) $(OLE_LIB) user32.lib $(SNIFF_LIB) \
$(LUA_LIB) $(MZSCHEME_LIB) $(PERL_LIB) $(PYTHON_LIB) $(RUBY_LIB) \
$(LUA_LIB) $(MZSCHEME_LIB) $(PERL_LIB) $(PYTHON_LIB) $(PYTHON3_LIB) $(RUBY_LIB) \
$(TCL_LIB) $(NETBEANS_LIB) $(XPM_LIB) $(LINK_PDB)
# Report link time code generation progress if used.
@ -851,12 +887,12 @@ all: $(VIM).exe vimrun.exe install.exe uninstal.exe xxd/xxd.exe \
GvimExt/gvimext.dll
$(VIM).exe: $(OUTDIR) $(OBJ) $(GUI_OBJ) $(OLE_OBJ) $(OLE_IDL) $(MZSCHEME_OBJ) \
$(LUA_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(RUBY_OBJ) $(TCL_OBJ) \
$(LUA_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(PYTHON3_OBJ) $(RUBY_OBJ) $(TCL_OBJ) \
$(SNIFF_OBJ) $(CSCOPE_OBJ) $(NETBEANS_OBJ) $(XPM_OBJ) \
version.c version.h
$(CC) $(CFLAGS) version.c
$(link) $(LINKARGS1) -out:$(VIM).exe $(OBJ) $(GUI_OBJ) $(OLE_OBJ) \
$(LUA_OBJ) $(MZSCHEME_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(RUBY_OBJ) \
$(LUA_OBJ) $(MZSCHEME_OBJ) $(PERL_OBJ) $(PYTHON_OBJ) $(PYTHON3_OBJ) $(RUBY_OBJ) \
$(TCL_OBJ) $(SNIFF_OBJ) $(CSCOPE_OBJ) $(NETBEANS_OBJ) \
$(XPM_OBJ) $(OUTDIR)\version.obj $(LINKARGS2)
@ -1016,6 +1052,9 @@ mzscheme_base.c:
$(OUTDIR)/if_python.obj: $(OUTDIR) if_python.c $(INCL)
$(CC) $(CFLAGS) $(PYTHON_INC) if_python.c
$(OUTDIR)/if_python3.obj: $(OUTDIR) if_python3.c $(INCL)
$(CC) $(CFLAGS) $(PYTHON3_INC) if_python3.c
$(OUTDIR)/if_ole.obj: $(OUTDIR) if_ole.cpp $(INCL) if_ole.h
$(OUTDIR)/if_ruby.obj: $(OUTDIR) if_ruby.c $(INCL)

View File

@ -41,6 +41,7 @@
# --enable-luainterp for Lua interpreter
# --enable-perlinterp for Perl interpreter
# --enable-pythoninterp for Python interpreter
# --enable-python3interp for Python3 interpreter
# --enable-rubyinterp for Ruby interpreter
# --enable-tclinterp for Tcl interpreter
# --enable-cscope for Cscope interface
@ -383,7 +384,12 @@ CClink = $(CC)
# NOTE: This may cause threading to be enabled, which has side effects (such
# as using different libraries and debugging becomes more difficult).
# NOTE: Using this together with Perl may cause a crash in initialization.
# For Python3 support make a symbolic link in /usr/local/bin:
# ln -s python3 python3.1
# If both python2.x and python3.x are enabled then the linking will be via
# dlopen(), dlsym(), dlclose(), i.e. pythonX.Y.so must be available
#CONF_OPT_PYTHON = --enable-pythoninterp
#CONF_OPT_PYTHON3 = --enable-python3interp
# TCL
# Uncomment this when you want to include the Tcl interface.
@ -1304,7 +1310,7 @@ SHELL = /bin/sh
.SUFFIXES: .c .o .pro
PRE_DEFS = -Iproto $(DEFS) $(GUI_DEFS) $(GUI_IPATH) $(CPPFLAGS) $(EXTRA_IPATHS)
POST_DEFS = $(X_CFLAGS) $(LUA_CFLAGS) $(MZSCHEME_CFLAGS) $(PERL_CFLAGS) $(ECL_CFLAGS) $(PYTHON_CFLAGS) $(TCL_CFLAGS) $(RUBY_CFLAGS) $(EXTRA_DEFS)
POST_DEFS = $(X_CFLAGS) $(LUA_CFLAGS) $(MZSCHEME_CFLAGS) $(PERL_CFLAGS) $(ECL_CFLAGS) $(TCL_CFLAGS) $(RUBY_CFLAGS) $(EXTRA_DEFS)
ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(POST_DEFS)
@ -1319,7 +1325,23 @@ LINT_EXTRA = -DUSE_SNIFF -DHANGUL_INPUT -D"__attribute__(x)="
DEPEND_CFLAGS = -DPROTO -DDEPEND -DFEAT_GUI $(LINT_CFLAGS)
ALL_LIB_DIRS = $(GUI_LIBS_DIR) $(X_LIBS_DIR)
ALL_LIBS = $(GUI_LIBS1) $(GUI_X_LIBS) $(GUI_LIBS2) $(X_PRE_LIBS) $(X_LIBS) $(X_EXTRA_LIBS) $(LIBS) $(EXTRA_LIBS) $(LUA_LIBS) $(MZSCHEME_LIBS) $(PERL_LIBS) $(PYTHON_LIBS) $(TCL_LIBS) $(RUBY_LIBS) $(PROFILE_LIBS)
ALL_LIBS = \
$(GUI_LIBS1) \
$(GUI_X_LIBS) \
$(GUI_LIBS2) \
$(X_PRE_LIBS) \
$(X_LIBS) \
$(X_EXTRA_LIBS) \
$(LIBS) \
$(EXTRA_LIBS) \
$(LUA_LIBS) \
$(MZSCHEME_LIBS) \
$(PERL_LIBS) \
$(PYTHON_LIBS) \
$(PYTHON3_LIBS) \
$(TCL_LIBS) \
$(RUBY_LIBS) \
$(PROFILE_LIBS)
# abbreviations
DEST_BIN = $(DESTDIR)$(BINDIR)
@ -1422,15 +1444,24 @@ BASIC_SRC = \
window.c \
$(OS_EXTRA_SRC)
SRC = $(BASIC_SRC) $(GUI_SRC) $(HANGULIN_SRC) $(LUA_SRC) $(MZSCHEME_SRC) \
$(PERL_SRC) $(PYTHON_SRC) $(TCL_SRC) $(RUBY_SRC) \
$(SNIFF_SRC) $(WORKSHOP_SRC) $(WSDEBUG_SRC)
SRC = $(BASIC_SRC) \
$(GUI_SRC) \
$(HANGULIN_SRC) \
$(LUA_SRC) \
$(MZSCHEME_SRC) \
$(PERL_SRC) \
$(PYTHON_SRC) $(PYTHON3_SRC) \
$(TCL_SRC) \
$(RUBY_SRC) \
$(SNIFF_SRC) \
$(WORKSHOP_SRC) \
$(WSDEBUG_SRC)
TAGS_SRC = *.c *.cpp if_perl.xs
EXTRA_SRC = hangulin.c if_lua.c if_mzsch.c auto/if_perl.c if_perlsfio.c \
if_python.c if_tcl.c if_ruby.c if_sniff.c gui_beval.c \
workshop.c wsdebug.c integration.c netbeans.c
if_python.c if_python3.c if_tcl.c if_ruby.c if_sniff.c \
gui_beval.c workshop.c wsdebug.c integration.c netbeans.c
# All sources, also the ones that are not configured
ALL_SRC = $(BASIC_SRC) $(ALL_GUI_SRC) $(EXTRA_SRC)
@ -1438,7 +1469,7 @@ ALL_SRC = $(BASIC_SRC) $(ALL_GUI_SRC) $(EXTRA_SRC)
# Which files to check with lint. Select one of these three lines. ALL_SRC
# checks more, but may not work well for checking a GUI that wasn't configured.
# The perl sources also don't work well with lint.
LINT_SRC = $(BASIC_SRC) $(GUI_SRC) $(HANGULIN_SRC) $(PYTHON_SRC) $(TCL_SRC) \
LINT_SRC = $(BASIC_SRC) $(GUI_SRC) $(HANGULIN_SRC) $(PYTHON_SRC) $(PYTHON3_SRC) $(TCL_SRC) \
$(SNIFF_SRC) $(WORKSHOP_SRC) $(WSDEBUG_SRC) $(NETBEANS_SRC)
#LINT_SRC = $(SRC)
#LINT_SRC = $(ALL_SRC)
@ -1499,6 +1530,7 @@ OBJ = \
$(MZSCHEME_OBJ) \
$(PERL_OBJ) \
$(PYTHON_OBJ) \
$(PYTHON3_OBJ) \
$(TCL_OBJ) \
$(RUBY_OBJ) \
$(OS_EXTRA_OBJ) \
@ -1528,6 +1560,7 @@ PRO_AUTO = \
if_cscope.pro \
if_xcmdsrv.pro \
if_python.pro \
if_python3.pro \
if_ruby.pro \
main.pro \
mark.pro \
@ -1589,7 +1622,7 @@ config auto/config.mk: auto/configure config.mk.in config.h.in
CC="$(CC)" CPPFLAGS="$(CPPFLAGS)" CFLAGS="$(CFLAGS)" \
LDFLAGS="$(LDFLAGS)" $(CONF_SHELL) srcdir="$(srcdir)" \
./configure $(CONF_OPT_GUI) $(CONF_OPT_X) $(CONF_OPT_XSMP) \
$(CONF_OPT_DARWIN) $(CONF_OPT_PERL) $(CONF_OPT_PYTHON) \
$(CONF_OPT_DARWIN) $(CONF_OPT_PERL) $(CONF_OPT_PYTHON) $(CONF_OPT_PYTHON3) \
$(CONF_OPT_TCL) $(CONF_OPT_RUBY) $(CONF_OPT_NLS) \
$(CONF_OPT_CSCOPE) $(CONF_OPT_MULTIBYTE) $(CONF_OPT_INPUT) \
$(CONF_OPT_OUTPUT) $(CONF_OPT_GPM) $(CONF_OPT_WORKSHOP) \
@ -2464,8 +2497,24 @@ objects/if_perl.o: auto/if_perl.c
objects/if_perlsfio.o: if_perlsfio.c
$(CCC) -o $@ if_perlsfio.c
objects/if_python.o: if_python.c
$(CCC) -o $@ $(PYTHON_CFLAGS_EXTRA) if_python.c
objects/py_config.o: $(PYTHON_CONFDIR)/config.c
$(CCC) $(PYTHON_CFLAGS) -o $@ $(PYTHON_CONFDIR)/config.c \
-I$(PYTHON_CONFDIR) -DHAVE_CONFIG_H -DNO_MAIN
objects/py_getpath.o: $(PYTHON_CONFDIR)/getpath.c
$(CCC) $(PYTHON_CFLAGS) -o $@ $(PYTHON_CONFDIR)/getpath.c \
-I$(PYTHON_CONFDIR) -DHAVE_CONFIG_H -DNO_MAIN \
$(PYTHON_GETPATH_CFLAGS)
objects/py3_config.o: $(PYTHON3_CONFDIR)/config.c
$(CCC) $(PYTHON3_CFLAGS) -o $@ $(PYTHON3_CONFDIR)/config.c \
-I$(PYTHON3_CONFDIR) -DHAVE_CONFIG_H -DNO_MAIN
objects/if_python.o: if_python.c
$(CCC) $(PYTHON_CFLAGS) $(PYTHON_CFLAGS_EXTRA) -o $@ if_python.c
objects/if_python3.o: if_python3.c
$(CCC) $(PYTHON3_CFLAGS) $(PYTHON3_CFLAGS_EXTRA) -o $@ if_python3.c
objects/if_ruby.o: if_ruby.c
$(CCC) -o $@ if_ruby.c
@ -2536,15 +2585,6 @@ objects/os_unix.o: os_unix.c
objects/pathdef.o: auto/pathdef.c
$(CCC) -o $@ auto/pathdef.c
objects/py_config.o: $(PYTHON_CONFDIR)/config.c
$(CCC) -o $@ $(PYTHON_CONFDIR)/config.c \
-I$(PYTHON_CONFDIR) -DHAVE_CONFIG_H -DNO_MAIN
objects/py_getpath.o: $(PYTHON_CONFDIR)/getpath.c
$(CCC) -o $@ $(PYTHON_CONFDIR)/getpath.c \
-I$(PYTHON_CONFDIR) -DHAVE_CONFIG_H -DNO_MAIN \
$(PYTHON_GETPATH_CFLAGS)
objects/pty.o: pty.c
$(CCC) -o $@ pty.c
@ -2978,6 +3018,10 @@ objects/if_python.o: if_python.c vim.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
globals.h farsi.h arabic.h
objects/if_python3.o: if_python3.c vim.h auto/config.h feature.h os_unix.h \
auto/osdef.h ascii.h keymap.h term.h macros.h option.h structs.h \
regexp.h gui.h gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h \
globals.h farsi.h arabic.h
objects/if_tcl.o: if_tcl.c vim.h auto/config.h feature.h os_unix.h auto/osdef.h \
ascii.h keymap.h term.h macros.h option.h structs.h regexp.h gui.h \
gui_beval.h proto/gui_beval.pro ex_cmds.h proto.h globals.h farsi.h \

290
src/auto/configure vendored
View File

@ -639,6 +639,12 @@ TCL_PRO
TCL_OBJ
TCL_SRC
vi_cv_path_tcl
PYTHON3_OBJ
PYTHON3_SRC
PYTHON3_CFLAGS
PYTHON3_LIBS
PYTHON3_CONFDIR
vi_cv_path_python3
PYTHON_OBJ
PYTHON_SRC
PYTHON_CFLAGS
@ -755,6 +761,8 @@ with_plthome
enable_perlinterp
enable_pythoninterp
with_python_config_dir
enable_python3interp
with_python3_config_dir
enable_tclinterp
with_tclsh
enable_rubyinterp
@ -1417,6 +1425,7 @@ Optional Features:
--enable-mzschemeinterp Include MzScheme interpreter.
--enable-perlinterp Include Perl interpreter.
--enable-pythoninterp Include Python interpreter.
--enable-python3interp Include Python3 interpreter.
--enable-tclinterp Include Tcl interpreter.
--enable-rubyinterp Include Ruby interpreter.
--enable-cscope Include cscope interface.
@ -1458,6 +1467,7 @@ Optional Packages:
--with-lua-prefix=PFX Prefix where Lua is installed.
--with-plthome=PLTHOME Use PLTHOME.
--with-python-config-dir=PATH Python's config directory
--with-python3-config-dir=PATH Python's config directory
--with-tclsh=PATH which tclsh to use (default: tclsh8.0)
--with-ruby-command=RUBY name of the Ruby command (default: ruby)
--with-x use the X Window System
@ -5362,6 +5372,286 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-python3interp argument" >&5
$as_echo_n "checking --enable-python3interp argument... " >&6; }
# Check whether --enable-python3interp was given.
if test "${enable_python3interp+set}" = set; then :
enableval=$enable_python3interp;
else
enable_python3interp="no"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_python3interp" >&5
$as_echo "$enable_python3interp" >&6; }
if test "$enable_python3interp" = "yes"; then
# Extract the first word of "python3", so it can be a program name with args.
set dummy python3; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if test "${ac_cv_path_vi_cv_path_python3+set}" = set; then :
$as_echo_n "(cached) " >&6
else
case $vi_cv_path_python3 in
[\\/]* | ?:[\\/]*)
ac_cv_path_vi_cv_path_python3="$vi_cv_path_python3" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
ac_cv_path_vi_cv_path_python3="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
;;
esac
fi
vi_cv_path_python3=$ac_cv_path_vi_cv_path_python3
if test -n "$vi_cv_path_python3"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_path_python3" >&5
$as_echo "$vi_cv_path_python3" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test "X$vi_cv_path_python3" != "X"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Python version" >&5
$as_echo_n "checking Python version... " >&6; }
if test "${vi_cv_var_python3_version+set}" = set; then :
$as_echo_n "(cached) " >&6
else
vi_cv_var_python3_version=`
${vi_cv_path_python3} -c 'import sys; print(sys.version[1:3])'`
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_var_python3_version" >&5
$as_echo "$vi_cv_var_python3_version" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Python's install prefix" >&5
$as_echo_n "checking Python's install prefix... " >&6; }
if test "${vi_cv_path_python3_pfx+set}" = set; then :
$as_echo_n "(cached) " >&6
else
vi_cv_path_python3_pfx=`
${vi_cv_path_python3} -c \
"import sys; print(sys.prefix)"`
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_path_python3_pfx" >&5
$as_echo "$vi_cv_path_python3_pfx" >&6; }
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Python's execution prefix" >&5
$as_echo_n "checking Python's execution prefix... " >&6; }
if test "${vi_cv_path_python3_epfx+set}" = set; then :
$as_echo_n "(cached) " >&6
else
vi_cv_path_python3_epfx=`
${vi_cv_path_python3} -c \
"import sys; print(sys.exec_prefix)"`
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_path_python3_epfx" >&5
$as_echo "$vi_cv_path_python3_epfx" >&6; }
if test "${vi_cv_path_python3path+set}" = set; then :
$as_echo_n "(cached) " >&6
else
vi_cv_path_python3path=`
unset PYTHONPATH;
${vi_cv_path_python3} -c \
"import sys, string; print(':'.join(sys.path))"`
fi
# Check whether --with-python3-config-dir was given.
if test "${with_python3_config_dir+set}" = set; then :
withval=$with_python3_config_dir; vi_cv_path_python3_conf="${withval}"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Python's configuration directory" >&5
$as_echo_n "checking Python's configuration directory... " >&6; }
if test "${vi_cv_path_python3_conf+set}" = set; then :
$as_echo_n "(cached) " >&6
else
vi_cv_path_python3_conf=
for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
for subdir in lib share; do
d="${path}/${subdir}/python3${vi_cv_var_python3_version}/config"
if test -d "$d" && test -f "$d/config.c"; then
vi_cv_path_python3_conf="$d"
fi
done
done
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $vi_cv_path_python3_conf" >&5
$as_echo "$vi_cv_path_python3_conf" >&6; }
PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
if test "X$PYTHON3_CONFDIR" = "X"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: can't find it!" >&5
$as_echo "can't find it!" >&6; }
else
if test "${vi_cv_path_python3_plibs+set}" = set; then :
$as_echo_n "(cached) " >&6
else
pwd=`pwd`
tmp_mkf="$pwd/config-PyMake$$"
cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
__:
@echo "python3_MODLIBS='$(MODLIBS)'"
@echo "python3_LIBS='$(LIBS)'"
@echo "python3_SYSLIBS='$(SYSLIBS)'"
@echo "python3_LINKFORSHARED='$(LINKFORSHARED)'"
eof
eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
rm -f -- "${tmp_mkf}"
vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython3${vi_cv_var_python3_version}"
vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_MODLIBS} ${python3_LIBS} ${python3_SYSLIBS} ${python3_LINKFORSHARED}"
vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
fi
PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python3${vi_cv_var_python3_version}"
else
PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python3${vi_cv_var_python3_version} -I${vi_cv_path_python3_epfx}/include/python3${vi_cv_var_python3_version}"
fi
PYTHON3_SRC="if_python3.c"
if test "x$MACOSX" = "xyes"; then
PYTHON3_OBJ="objects/if_python3.o"
else
PYTHON3_OBJ="objects/if_python3.o objects/py3_config.o"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if -pthread should be used" >&5
$as_echo_n "checking if -pthread should be used... " >&6; }
threadsafe_flag=
thread_lib=
if test "`(uname) 2>/dev/null`" != Darwin; then
test "$GCC" = yes && threadsafe_flag="-pthread"
if test "`(uname) 2>/dev/null`" = FreeBSD; then
threadsafe_flag="-D_THREAD_SAFE"
thread_lib="-pthread"
fi
fi
libs_save_old=$LIBS
if test -n "$threadsafe_flag"; then
cflags_save=$CFLAGS
CFLAGS="$CFLAGS $threadsafe_flag"
LIBS="$LIBS $thread_lib"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }; PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }; LIBS=$libs_save_old
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$cflags_save
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compile and link flags for Python are sane" >&5
$as_echo_n "checking if compile and link flags for Python are sane... " >&6; }
cflags_save=$CFLAGS
libs_save=$LIBS
CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
LIBS="$LIBS $PYTHON3_LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main ()
{
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }; python3_ok=yes
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no: PYTHON3 DISABLED" >&5
$as_echo "no: PYTHON3 DISABLED" >&6; }; python3_ok=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
CFLAGS=$cflags_save
LIBS=$libs_save
if test "$python3_ok" = yes; then
$as_echo "#define FEAT_PYTHON3 1" >>confdefs.h
else
LIBS=$libs_save_old
PYTHON3_SRC=
PYTHON3_OBJ=
PYTHON3_LIBS=
PYTHON3_CFLAGS=
fi
fi
fi
fi
if test "$python_ok" = yes && test "$python3_ok" = yes; then
$as_echo "#define DYNAMIC_PYTHON 1" >>confdefs.h
$as_echo "#define DYNAMIC_PYTHON3 1" >>confdefs.h
PYTHON_SRC="if_python.c"
PYTHON_OBJ="objects/if_python.o"
PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"libpython${vi_cv_var_python_version}.so\\\""
PYTHON_LIBS=
PYTHON3_SRC="if_python3.c"
PYTHON3_OBJ="objects/if_python3.o"
PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"libpython3${vi_cv_var_python3_version}.so\\\""
PYTHON3_LIBS=
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-tclinterp argument" >&5
$as_echo_n "checking --enable-tclinterp argument... " >&6; }
# Check whether --enable-tclinterp was given.

View File

@ -607,6 +607,9 @@ free_buffer(buf)
#ifdef FEAT_PYTHON
python_buffer_free(buf);
#endif
#ifdef FEAT_PYTHON3
python3_buffer_free(buf);
#endif
#ifdef FEAT_RUBY
ruby_buffer_free(buf);
#endif

View File

@ -328,6 +328,15 @@
/* Define if you want to include the Python interpreter. */
#undef FEAT_PYTHON
/* Define if you want to include the Python3 interpreter. */
#undef FEAT_PYTHON3
/* Define for linking via dlopen() or LoadLibrary() */
#undef DYNAMIC_PYTHON
/* Define for linking via dlopen() or LoadLibrary() */
#undef DYNAMIC_PYTHON3
/* Define if you want to include the Ruby interpreter. */
#undef FEAT_RUBY

View File

@ -66,6 +66,12 @@ PYTHON_LIBS = @PYTHON_LIBS@
PYTHON_CONFDIR = @PYTHON_CONFDIR@
PYTHON_GETPATH_CFLAGS = @PYTHON_GETPATH_CFLAGS@
PYTHON3_SRC = @PYTHON3_SRC@
PYTHON3_OBJ = @PYTHON3_OBJ@
PYTHON3_CFLAGS = @PYTHON3_CFLAGS@
PYTHON3_LIBS = @PYTHON3_LIBS@
PYTHON3_CONFDIR = @PYTHON3_CONFDIR@
TCL = @vi_cv_path_tcl@
TCL_SRC = @TCL_SRC@
TCL_OBJ = @TCL_OBJ@

View File

@ -878,7 +878,7 @@ eof
AC_MSG_RESULT(no)
fi
dnl check that compiling a simple program still works with the flags
dnl Check that compiling a simple program still works with the flags
dnl added for Python.
AC_MSG_CHECKING([if compile and link flags for Python are sane])
cflags_save=$CFLAGS
@ -906,6 +906,7 @@ eof
fi
fi
fi
AC_SUBST(PYTHON_CONFDIR)
AC_SUBST(PYTHON_LIBS)
AC_SUBST(PYTHON_GETPATH_CFLAGS)
@ -913,6 +914,183 @@ AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_SRC)
AC_SUBST(PYTHON_OBJ)
AC_MSG_CHECKING(--enable-python3interp argument)
AC_ARG_ENABLE(python3interp,
[ --enable-python3interp Include Python3 interpreter.], ,
[enable_python3interp="no"])
AC_MSG_RESULT($enable_python3interp)
if test "$enable_python3interp" = "yes"; then
dnl -- find the python3 executable
AC_PATH_PROG(vi_cv_path_python3, python3)
if test "X$vi_cv_path_python3" != "X"; then
dnl -- get its version number
AC_CACHE_CHECK(Python version,vi_cv_var_python3_version,
[[vi_cv_var_python3_version=`
${vi_cv_path_python3} -c 'import sys; print(sys.version[1:3])'`
]])
dnl -- find where python3 thinks it was installed
AC_CACHE_CHECK(Python's install prefix,vi_cv_path_python3_pfx,
[ vi_cv_path_python3_pfx=`
${vi_cv_path_python3} -c \
"import sys; print(sys.prefix)"` ])
dnl -- and where it thinks it runs
AC_CACHE_CHECK(Python's execution prefix,vi_cv_path_python3_epfx,
[ vi_cv_path_python3_epfx=`
${vi_cv_path_python3} -c \
"import sys; print(sys.exec_prefix)"` ])
dnl -- python3's internal library path
AC_CACHE_VAL(vi_cv_path_python3path,
[ vi_cv_path_python3path=`
unset PYTHONPATH;
${vi_cv_path_python3} -c \
"import sys, string; print(':'.join(sys.path))"` ])
dnl -- where the Python implementation library archives are
AC_ARG_WITH(python3-config-dir,
[ --with-python3-config-dir=PATH Python's config directory],
[ vi_cv_path_python3_conf="${withval}" ] )
AC_CACHE_CHECK(Python's configuration directory,vi_cv_path_python3_conf,
[
vi_cv_path_python3_conf=
for path in "${vi_cv_path_python3_pfx}" "${vi_cv_path_python3_epfx}"; do
for subdir in lib share; do
d="${path}/${subdir}/python3${vi_cv_var_python3_version}/config"
if test -d "$d" && test -f "$d/config.c"; then
vi_cv_path_python3_conf="$d"
fi
done
done
])
PYTHON3_CONFDIR="${vi_cv_path_python3_conf}"
if test "X$PYTHON3_CONFDIR" = "X"; then
AC_MSG_RESULT([can't find it!])
else
dnl -- we need to examine Python's config/Makefile too
dnl see what the interpreter is built from
AC_CACHE_VAL(vi_cv_path_python3_plibs,
[
pwd=`pwd`
tmp_mkf="$pwd/config-PyMake$$"
cat -- "${PYTHON3_CONFDIR}/Makefile" - <<'eof' >"${tmp_mkf}"
__:
@echo "python3_MODLIBS='$(MODLIBS)'"
@echo "python3_LIBS='$(LIBS)'"
@echo "python3_SYSLIBS='$(SYSLIBS)'"
@echo "python3_LINKFORSHARED='$(LINKFORSHARED)'"
eof
dnl -- delete the lines from make about Entering/Leaving directory
eval "`cd ${PYTHON3_CONFDIR} && make -f "${tmp_mkf}" __ | sed '/ directory /d'`"
rm -f -- "${tmp_mkf}"
vi_cv_path_python3_plibs="-L${PYTHON3_CONFDIR} -lpython3${vi_cv_var_python3_version}"
vi_cv_path_python3_plibs="${vi_cv_path_python3_plibs} ${python3_MODLIBS} ${python3_LIBS} ${python3_SYSLIBS} ${python3_LINKFORSHARED}"
dnl remove -ltermcap, it can conflict with an earlier -lncurses
vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-ltermcap//`
vi_cv_path_python3_plibs=`echo $vi_cv_path_python3_plibs | sed s/-lffi//`
])
PYTHON3_LIBS="${vi_cv_path_python3_plibs}"
if test "${vi_cv_path_python3_pfx}" = "${vi_cv_path_python3_epfx}"; then
PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python3${vi_cv_var_python3_version}"
else
PYTHON3_CFLAGS="-I${vi_cv_path_python3_pfx}/include/python3${vi_cv_var_python3_version} -I${vi_cv_path_python3_epfx}/include/python3${vi_cv_var_python3_version}"
fi
PYTHON3_SRC="if_python3.c"
dnl For Mac OSX 10.2 config.o is included in the Python library.
if test "x$MACOSX" = "xyes"; then
PYTHON3_OBJ="objects/if_python3.o"
else
PYTHON3_OBJ="objects/if_python3.o objects/py3_config.o"
fi
dnl On FreeBSD linking with "-pthread" is required to use threads.
dnl _THREAD_SAFE must be used for compiling then.
dnl The "-pthread" is added to $LIBS, so that the following check for
dnl sigaltstack() will look in libc_r (it's there in libc!).
dnl Otherwise, when using GCC, try adding -pthread to $CFLAGS. GCC
dnl will then define target-specific defines, e.g., -D_REENTRANT.
dnl Don't do this for Mac OSX, -pthread will generate a warning.
AC_MSG_CHECKING([if -pthread should be used])
threadsafe_flag=
thread_lib=
dnl if test "x$MACOSX" != "xyes"; then
if test "`(uname) 2>/dev/null`" != Darwin; then
test "$GCC" = yes && threadsafe_flag="-pthread"
if test "`(uname) 2>/dev/null`" = FreeBSD; then
threadsafe_flag="-D_THREAD_SAFE"
thread_lib="-pthread"
fi
fi
libs_save_old=$LIBS
if test -n "$threadsafe_flag"; then
cflags_save=$CFLAGS
CFLAGS="$CFLAGS $threadsafe_flag"
LIBS="$LIBS $thread_lib"
AC_TRY_LINK(,[ ],
AC_MSG_RESULT(yes); PYTHON3_CFLAGS="$PYTHON3_CFLAGS $threadsafe_flag",
AC_MSG_RESULT(no); LIBS=$libs_save_old
)
CFLAGS=$cflags_save
else
AC_MSG_RESULT(no)
fi
dnl check that compiling a simple program still works with the flags
dnl added for Python.
AC_MSG_CHECKING([if compile and link flags for Python are sane])
cflags_save=$CFLAGS
libs_save=$LIBS
CFLAGS="$CFLAGS $PYTHON3_CFLAGS"
LIBS="$LIBS $PYTHON3_LIBS"
AC_TRY_LINK(,[ ],
AC_MSG_RESULT(yes); python3_ok=yes,
AC_MSG_RESULT(no: PYTHON3 DISABLED); python3_ok=no)
CFLAGS=$cflags_save
LIBS=$libs_save
if test "$python3_ok" = yes; then
AC_DEFINE(FEAT_PYTHON3)
else
LIBS=$libs_save_old
PYTHON3_SRC=
PYTHON3_OBJ=
PYTHON3_LIBS=
PYTHON3_CFLAGS=
fi
fi
fi
fi
AC_SUBST(PYTHON3_CONFDIR)
AC_SUBST(PYTHON3_LIBS)
AC_SUBST(PYTHON3_CFLAGS)
AC_SUBST(PYTHON3_SRC)
AC_SUBST(PYTHON3_OBJ)
dnl if python2.x and python3.x are enabled one can only link in code
dnl with dlopen(), dlsym(), dlclose()
if test "$python_ok" = yes && test "$python3_ok" = yes; then
AC_DEFINE(DYNAMIC_PYTHON)
AC_DEFINE(DYNAMIC_PYTHON3)
PYTHON_SRC="if_python.c"
PYTHON_OBJ="objects/if_python.o"
PYTHON_CFLAGS="$PYTHON_CFLAGS -DDYNAMIC_PYTHON_DLL=\\\"libpython${vi_cv_var_python_version}.so\\\""
PYTHON_LIBS=
PYTHON3_SRC="if_python3.c"
PYTHON3_OBJ="objects/if_python3.o"
PYTHON3_CFLAGS="$PYTHON3_CFLAGS -DDYNAMIC_PYTHON3_DLL=\\\"libpython3${vi_cv_var_python3_version}.so\\\""
PYTHON3_LIBS=
fi
AC_MSG_CHECKING(--enable-tclinterp argument)
AC_ARG_ENABLE(tclinterp,
[ --enable-tclinterp Include Tcl interpreter.], ,

View File

@ -5911,8 +5911,8 @@ list_equal(l1, l2, ic)
return item1 == NULL && item2 == NULL;
}
#if defined(FEAT_RUBY) || defined(FEAT_PYTHON) || defined(FEAT_MZSCHEME) \
|| defined(FEAT_LUA) || defined(PROTO)
#if defined(FEAT_RUBY) || defined(FEAT_PYTHON) || defined(FEAT_PYTHON3) \
|| defined(FEAT_MZSCHEME) || defined(FEAT_LUA) || defined(PROTO)
/*
* Return the dictitem that an entry in a hashtable points to.
*/
@ -11991,6 +11991,11 @@ f_has(argvars, rettv)
"python",
#endif
#endif
#ifdef FEAT_PYTHON3
#ifndef DYNAMIC_PYTHON3
"python3",
#endif
#endif
#ifdef FEAT_POSTSCRIPT
"postscript",
#endif
@ -12184,10 +12189,18 @@ f_has(argvars, rettv)
else if (STRICMP(name, "ruby") == 0)
n = ruby_enabled(FALSE);
#endif
#ifdef FEAT_PYTHON
#ifdef DYNAMIC_PYTHON
else if (STRICMP(name, "python") == 0)
n = python_enabled(FALSE);
#endif
#endif
#ifdef FEAT_PYTHON3
#ifdef DYNAMIC_PYTHON3
else if (STRICMP(name, "python3") == 0)
n = python3_enabled(FALSE);
#endif
#endif
#ifdef DYNAMIC_PERL
else if (STRICMP(name, "perl") == 0)
n = perl_enabled(FALSE);

View File

@ -741,6 +741,10 @@ EX(CMD_python, "python", ex_python,
RANGE|EXTRA|NEEDARG|CMDWIN),
EX(CMD_pyfile, "pyfile", ex_pyfile,
RANGE|FILE1|NEEDARG|CMDWIN),
EX(CMD_python3, "py3", ex_python3,
RANGE|EXTRA|NEEDARG|CMDWIN),
EX(CMD_py3file, "py3file", ex_py3file,
RANGE|FILE1|NEEDARG|CMDWIN),
EX(CMD_quit, "quit", ex_quit,
BANG|TRLBAR|CMDWIN),
EX(CMD_quitall, "quitall", ex_quit_all,

View File

@ -129,8 +129,8 @@ static int getargopt __ARGS((exarg_T *eap));
static int check_more __ARGS((int, int));
static linenr_T get_address __ARGS((char_u **, int skip, int to_other_file));
static void get_flags __ARGS((exarg_T *eap));
#if !defined(FEAT_PERL) || !defined(FEAT_PYTHON) || !defined(FEAT_TCL) \
|| !defined(FEAT_RUBY) || !defined(FEAT_MZSCHEME)
#if !defined(FEAT_PERL) || !defined(FEAT_PYTHON) || !defined(FEAT_PYTHON3) \
|| !defined(FEAT_TCL) || !defined(FEAT_RUBY) || !defined(FEAT_MZSCHEME)
# define HAVE_EX_SCRIPT_NI
static void ex_script_ni __ARGS((exarg_T *eap));
#endif
@ -265,6 +265,10 @@ static void ex_popup __ARGS((exarg_T *eap));
# define ex_python ex_script_ni
# define ex_pyfile ex_ni
#endif
#ifndef FEAT_PYTHON3
# define ex_python3 ex_script_ni
# define ex_py3file ex_ni
#endif
#ifndef FEAT_TCL
# define ex_tcl ex_script_ni
# define ex_tcldo ex_ni
@ -2554,6 +2558,7 @@ do_one_cmd(cmdlinep, sourcing,
case CMD_perl:
case CMD_psearch:
case CMD_python:
case CMD_python3:
case CMD_return:
case CMD_rightbelow:
case CMD_ruby:
@ -2816,6 +2821,10 @@ find_command(eap, full)
{
while (ASCII_ISALPHA(*p))
++p;
/* for python 3.x support (:py3, :python3) */
if (eap->cmd[0] == 'p' && eap->cmd[1] == 'y')
p = skipdigits(p);
/* check for non-alpha command */
if (p == eap->cmd && vim_strchr((char_u *)"@*!=><&~#", *p) != NULL)
++p;

View File

@ -1415,9 +1415,13 @@ EXTERN char_u e_isadir2[] INIT(= N_("E17: \"%s\" is a directory"));
#ifdef FEAT_LIBCALL
EXTERN char_u e_libcall[] INIT(= N_("E364: Library call failed for \"%s()\""));
#endif
#if defined(DYNAMIC_PERL) || defined(DYNAMIC_PYTHON) || defined(DYNAMIC_RUBY) \
|| defined(DYNAMIC_TCL) || defined(DYNAMIC_ICONV) \
|| defined(DYNAMIC_GETTEXT) || defined(DYNAMIC_MZSCHEME) \
#if defined(DYNAMIC_PERL) \
|| defined(DYNAMIC_PYTHON) || defined(DYNAMIC_PYTHON3) \
|| defined(DYNAMIC_RUBY) \
|| defined(DYNAMIC_TCL) \
|| defined(DYNAMIC_ICONV) \
|| defined(DYNAMIC_GETTEXT) \
|| defined(DYNAMIC_MZSCHEME) \
|| defined(DYNAMIC_LUA)
EXTERN char_u e_loadlib[] INIT(= N_("E370: Could not load library %s"));
EXTERN char_u e_loadfunc[] INIT(= N_("E448: Could not load library function %s"));

View File

@ -96,6 +96,19 @@ struct PyMethodDef { Py_ssize_t a; };
# define HINSTANCE long_u /* for generating prototypes */
# endif
#ifndef _WIN32
# include <dlfcn.h>
# define FARPROC void*
# define HINSTANCE void*
# define load_dll(n) dlopen((n),RTLD_LAZY)
# define close_dll dlclose
# define symbol_from_dll dlsym
#else
# define load_dll LoadLibrary
# define close_dll FreeLibrary
# define symbol_from_dll GetProcAddress
#endif
/* This makes if_python.c compile without warnings against Python 2.5
* on Win32 and Win64. */
#undef PyRun_SimpleString
@ -315,7 +328,7 @@ end_dynamic_python(void)
{
if (hinstPython)
{
FreeLibrary(hinstPython);
close_dll(hinstPython);
hinstPython = 0;
}
}
@ -332,7 +345,7 @@ python_runtime_link_init(char *libname, int verbose)
if (hinstPython)
return OK;
hinstPython = LoadLibrary(libname);
hinstPython = load_dll(libname);
if (!hinstPython)
{
if (verbose)
@ -342,10 +355,10 @@ python_runtime_link_init(char *libname, int verbose)
for (i = 0; python_funcname_table[i].ptr; ++i)
{
if ((*python_funcname_table[i].ptr = GetProcAddress(hinstPython,
if ((*python_funcname_table[i].ptr = symbol_from_dll(hinstPython,
python_funcname_table[i].name)) == NULL)
{
FreeLibrary(hinstPython);
close_dll(hinstPython);
hinstPython = 0;
if (verbose)
EMSG2(_(e_loadfunc), python_funcname_table[i].name);

2796
src/if_python3.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1405,6 +1405,9 @@ getout(exitval)
#ifdef FEAT_PYTHON
python_end();
#endif
#ifdef FEAT_PYTHON3
python3_end();
#endif
#ifdef FEAT_PERL
perl_end();
#endif

View File

@ -186,6 +186,10 @@ void qsort __ARGS((void *base, size_t elm_count, size_t elm_size, int (*cmp)(con
# include "if_python.pro"
# endif
# ifdef FEAT_PYTHON3
# include "if_python3.pro"
# endif
# ifdef FEAT_TCL
# include "if_tcl.pro"
# endif

8
src/proto/if_python3.pro Normal file
View File

@ -0,0 +1,8 @@
/* if_python.c */
int python3_enabled __ARGS((int verbose));
void python3_end __ARGS((void));
void ex_python3 __ARGS((exarg_T *eap));
void ex_py3file __ARGS((exarg_T *eap));
void python3_buffer_free __ARGS((buf_T *buf));
void python3_window_free __ARGS((win_T *win));
/* vim: set ft=c : */

View File

@ -1612,6 +1612,10 @@ struct file_buffer
void *b_python_ref; /* The Python reference to this buffer */
#endif
#ifdef FEAT_PYTHON3
void *b_python3_ref; /* The Python3 reference to this buffer */
#endif
#ifdef FEAT_TCL
void *b_tcl_ref;
#endif
@ -2106,6 +2110,10 @@ struct window_S
void *w_python_ref; /* The Python value for this window */
#endif
#ifdef FEAT_PYTHON3
void *w_python3_ref; /* The Python value for this window */
#endif
#ifdef FEAT_TCL
void *w_tcl_ref;
#endif

View File

@ -474,6 +474,15 @@ static char *(features[]) =
#else
"-python",
#endif
#ifdef FEAT_PYTHON3
# ifdef DYNAMIC_PYTHON3
"+python3/dyn",
# else
"+python3",
# endif
#else
"-python3",
#endif
#ifdef FEAT_QUICKFIX
"+quickfix",
#else

View File

@ -13,6 +13,7 @@
#if defined(__BORLANDC__) && defined(WIN32) && !defined(DEBUG)
#if defined(FEAT_PERL) || \
defined(FEAT_PYTHON) || \
defined(FEAT_PYTHON3) || \
defined(FEAT_RUBY) || \
defined(FEAT_TCL) || \
defined(FEAT_MZSCHEME) || \

View File

@ -4386,6 +4386,10 @@ win_free(wp, tp)
python_window_free(wp);
#endif
#ifdef FEAT_PYTHON3
python3_window_free(wp);
#endif
#ifdef FEAT_TCL
tcl_window_free(wp);
#endif