Implement var proc
This commit is contained in:
parent
48955b3aa1
commit
8dc327d02b
3 changed files with 28 additions and 10 deletions
|
|
@ -47,14 +47,16 @@ proc saveNodeData(node: TSNode, nimState: NimState): bool =
|
||||||
|
|
||||||
nimState.data.add((name, val))
|
nimState.data.add((name, val))
|
||||||
|
|
||||||
if name == "field_identifier" and
|
if pname == "pointer_declarator" and
|
||||||
pname == "pointer_declarator" and
|
|
||||||
ppname == "function_declarator":
|
ppname == "function_declarator":
|
||||||
if pppname == "pointer_declarator":
|
if name == "field_identifier":
|
||||||
nimState.data.insert(("pointer_declarator", ""), nimState.data.len-1)
|
if pppname == "pointer_declarator":
|
||||||
if ppppname == "pointer_declarator":
|
|
||||||
nimState.data.insert(("pointer_declarator", ""), nimState.data.len-1)
|
nimState.data.insert(("pointer_declarator", ""), nimState.data.len-1)
|
||||||
nimState.data.add(("function_declarator", ""))
|
if ppppname == "pointer_declarator":
|
||||||
|
nimState.data.insert(("pointer_declarator", ""), nimState.data.len-1)
|
||||||
|
nimState.data.add(("function_declarator", ""))
|
||||||
|
elif name == "identifier":
|
||||||
|
nimState.data.add(("pointer_declarator", ""))
|
||||||
|
|
||||||
elif name in gExpressions and name != "escape_sequence":
|
elif name in gExpressions and name != "escape_sequence":
|
||||||
if $node.tsNodeParent.tsNodeType() notin gExpressions:
|
if $node.tsNodeParent.tsNodeType() notin gExpressions:
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ proc initGrammar(): Grammar =
|
||||||
(pointer_declarator!
|
(pointer_declarator!
|
||||||
(type_identifier)
|
(type_identifier)
|
||||||
)
|
)
|
||||||
(type_identifier)
|
(type_identifier|identifier)
|
||||||
)
|
)
|
||||||
{paramListGrammar}
|
{paramListGrammar}
|
||||||
(noexcept|throw_specifier?)
|
(noexcept|throw_specifier?)
|
||||||
|
|
@ -588,8 +588,13 @@ proc initGrammar(): Grammar =
|
||||||
pout, pname, ptyp, pptr = ""
|
pout, pname, ptyp, pptr = ""
|
||||||
count = 1
|
count = 1
|
||||||
flen = ""
|
flen = ""
|
||||||
|
fVar = false
|
||||||
|
|
||||||
i += 1
|
i += 1
|
||||||
|
if i < nimState.data.len and nimState.data[i].name == "pointer_declarator":
|
||||||
|
fVar = true
|
||||||
|
i += 1
|
||||||
|
|
||||||
while i < nimState.data.len:
|
while i < nimState.data.len:
|
||||||
if nimState.data[i].name == "function_declarator":
|
if nimState.data[i].name == "function_declarator":
|
||||||
break
|
break
|
||||||
|
|
@ -605,9 +610,15 @@ proc initGrammar(): Grammar =
|
||||||
pragma = nimState.getPragma(nimState.getImportC(fname, fnname), "cdecl")
|
pragma = nimState.getPragma(nimState.getImportC(fname, fnname), "cdecl")
|
||||||
|
|
||||||
if fptr.len != 0 or ftyp != "object":
|
if fptr.len != 0 or ftyp != "object":
|
||||||
nimState.procStr &= &"{nimState.getComments(true)}\nproc {fnname}*({pout}): {getPtrType(fptr&ftyp)}{pragma}"
|
if fVar:
|
||||||
|
nimState.procStr &= &"{nimState.getComments(true)}\nvar {fnname}*: proc ({pout}): {getPtrType(fptr&ftyp)}{{.cdecl.}}"
|
||||||
|
else:
|
||||||
|
nimState.procStr &= &"{nimState.getComments(true)}\nproc {fnname}*({pout}): {getPtrType(fptr&ftyp)}{pragma}"
|
||||||
else:
|
else:
|
||||||
nimState.procStr &= &"{nimState.getComments(true)}\nproc {fnname}*({pout}){pragma}"
|
if fVar:
|
||||||
|
nimState.procStr &= &"{nimState.getComments(true)}\nvar {fnname}*: proc ({pout}){{.cdecl.}}"
|
||||||
|
else:
|
||||||
|
nimState.procStr &= &"{nimState.getComments(true)}\nproc {fnname}*({pout}){pragma}"
|
||||||
))
|
))
|
||||||
|
|
||||||
# // comment
|
# // comment
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
import nimterop/[cimport, build, paths]
|
import nimterop/[cimport, build]
|
||||||
|
|
||||||
const
|
const
|
||||||
baseDir = getProjectCacheDir("nimterop" / "tests" / "pcre")
|
baseDir = getProjectCacheDir("nimterop" / "tests" / "pcre")
|
||||||
|
|
@ -33,3 +33,8 @@ cPlugin:
|
||||||
cImport(pcreH, dynlib="dynpcre")
|
cImport(pcreH, dynlib="dynpcre")
|
||||||
|
|
||||||
echo version()
|
echo version()
|
||||||
|
|
||||||
|
proc my_malloc(a1: cuint) {.cdecl.} =
|
||||||
|
discard
|
||||||
|
|
||||||
|
malloc = my_malloc
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue