mirror of
https://github.com/nim-lang/Nim.git
synced 2026-08-31 02:43:41 +00:00
Compare commits
9 Commits
797b05eda6
...
pr_nodecl_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a659dbff1b | ||
|
|
276840610b | ||
|
|
449511995f | ||
|
|
33263ef806 | ||
|
|
ce20f1b31a | ||
|
|
c1f99aa362 | ||
|
|
67d80c4971 | ||
|
|
237669a1b2 | ||
|
|
d39c76b8bd |
@@ -19,6 +19,8 @@ errors.
|
||||
|
||||
- With `-d:nimPreviewAsmSemSymbol`, backticked symbols are type checked in the `asm/emit` statements.
|
||||
|
||||
- `importc` no longer implies `nodecl` for imported types. Use `header` or `nodecl` pragmas so that it doesn't generate a declaration for the type symbol.
|
||||
|
||||
- The bare `except:` now panics on `Defect`. Use `except Exception:` or `except Defect:` to catch `Defect`. `--legacy:noPanicOnExcept` is provided for a transition period.
|
||||
|
||||
- With `-d:nimPreviewCStringComparisons`, comparsions (`<`, `>`, `<=`, `>=`) between cstrings switch from reference semantics to value semantics like `==` and `!=`.
|
||||
@@ -27,6 +29,7 @@ errors.
|
||||
|
||||
- With `-d:nimPreviewDuplicateModuleError`, importing two modules that share the same name becomes a compile-time error. This includes importing the same module more than once. Use `import foo as foo1` (or other aliases) to avoid collisions.
|
||||
|
||||
|
||||
## Standard library additions and changes
|
||||
|
||||
[//]: # "Additions:"
|
||||
|
||||
@@ -238,6 +238,9 @@ proc mapReturnType(conf: ConfigRef; typ: PType): TCTypeKind =
|
||||
proc isImportedType(t: PType): bool =
|
||||
result = t.sym != nil and sfImportc in t.sym.flags
|
||||
|
||||
proc isNoDeclType(t: PType): bool =
|
||||
result = t.sym != nil and {lfNoDecl, lfHeader} * t.sym.loc.flags != {}
|
||||
|
||||
proc isImportedCppType(t: PType): bool =
|
||||
let x = t.skipTypes(irrelevantForBackend)
|
||||
result = (t.sym != nil and sfInfixCall in t.sym.flags) or
|
||||
@@ -390,7 +393,7 @@ proc getTypeForward(m: BModule; typ: PType; sig: SigHash): Rope =
|
||||
of tySequence, tyTuple, tyObject:
|
||||
result = getTypeName(m, typ, sig)
|
||||
m.forwTypeCache[sig] = result
|
||||
if not isImportedType(concrete):
|
||||
if not isNoDeclType(concrete):
|
||||
addForwardStructFormat(m, structOrUnion(typ), result)
|
||||
else:
|
||||
pushType(m, concrete)
|
||||
@@ -1045,14 +1048,14 @@ proc getTypeDescAux(m: BModule; origTyp: PType, check: var IntSet; kind: TypeDes
|
||||
if result == "":
|
||||
result = getTypeName(m, origTyp, sig)
|
||||
m.forwTypeCache[sig] = result
|
||||
if not isImportedType(t):
|
||||
if not isNoDeclType(t):
|
||||
addForwardStructFormat(m, structOrUnion(t), result)
|
||||
assert m.forwTypeCache[sig] == result
|
||||
m.typeCache[sig] = result # always call for sideeffects:
|
||||
if not incompleteType(t):
|
||||
let recdesc = if t.kind != tyTuple: getRecordDesc(m, t, result, check)
|
||||
else: getTupleDesc(m, t, result, check)
|
||||
if not isImportedType(t):
|
||||
if not isImportedType(t) and not isNoDeclType(t):
|
||||
m.s[cfsTypes].add(recdesc)
|
||||
elif tfIncompleteStruct notin t.flags:
|
||||
discard # addAbiCheck(m, t, result) # already handled elsewhere
|
||||
|
||||
@@ -238,7 +238,7 @@ elif defined(ios) or defined(macosx):
|
||||
const errSecSuccess = 0 ## No error.
|
||||
|
||||
type
|
||||
SecRandom {.importc: "struct __SecRandom".} = object
|
||||
SecRandom {.importc: "struct __SecRandom", header: "<Security/SecRandom.h>".} = object
|
||||
|
||||
SecRandomRef = ptr SecRandom
|
||||
## An abstract Core Foundation-type object containing information about a random number generator.
|
||||
|
||||
@@ -113,13 +113,13 @@ elif defined(windows) or defined(dos):
|
||||
#
|
||||
when defined(cpp):
|
||||
type
|
||||
THINSTANCE {.importc: "HINSTANCE".} = object
|
||||
THINSTANCE {.importc: "HINSTANCE", nodecl.} = object
|
||||
x: pointer
|
||||
proc getProcAddress(lib: THINSTANCE, name: cstring): ProcAddr {.
|
||||
importcpp: "(void*)GetProcAddress(@)", header: "<windows.h>", stdcall.}
|
||||
else:
|
||||
type
|
||||
THINSTANCE {.importc: "HINSTANCE".} = pointer
|
||||
THINSTANCE {.importc: "HINSTANCE", nodecl.} = pointer
|
||||
proc getProcAddress(lib: THINSTANCE, name: cstring): ProcAddr {.
|
||||
importc: "GetProcAddress", header: "<windows.h>", stdcall.}
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@ var s = bork()
|
||||
import tables
|
||||
|
||||
type
|
||||
cdbl {.importc: "double".} = object
|
||||
cdbl {.importc: "double", nodecl.} = object
|
||||
|
||||
MyObject = ref object of RootObj
|
||||
y: Table[string, cdbl]
|
||||
|
||||
|
||||
|
||||
proc test =
|
||||
var x = new(MyObject)
|
||||
|
||||
@@ -140,7 +140,7 @@ block: # bug #9940
|
||||
typedef struct { int base; } S;
|
||||
""".}
|
||||
|
||||
type S {.importc: "S", completeStruct.} = object
|
||||
type S {.importc: "S", nodecl, completeStruct.} = object
|
||||
base: cint
|
||||
proc init(x:ptr S) =
|
||||
x.base = 1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
discard """
|
||||
targets: "c cpp"
|
||||
matrix: "--gc:refc; --gc:arc"
|
||||
matrix: "--mm:refc; --mm:arc"
|
||||
"""
|
||||
|
||||
# bug #7308
|
||||
@@ -41,3 +41,8 @@ block: # bug #11797
|
||||
proc foo3(): int32 = 2
|
||||
foo(proc(): cint = foo1())
|
||||
foo(proc(): int32 = foo3())
|
||||
|
||||
|
||||
block: # bug #24604
|
||||
type MyType {.importc, incompleteStruct.} = object
|
||||
var v {.exportc.}: ptr MyType
|
||||
|
||||
@@ -15,7 +15,7 @@ struct SystemManager {
|
||||
|
||||
""".}
|
||||
|
||||
type Input {.importcpp: "System::Input".} = object
|
||||
type Input {.importcpp: "System::Input", nodecl.} = object
|
||||
proc getSubsystem*[T](): ptr T {.
|
||||
importcpp: "SystemManager::getSubsystem<'*0>()", nodecl.}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ template ensureCgen(T: typedesc) =
|
||||
var a {.volatile.}: T
|
||||
|
||||
block:
|
||||
type Foo1Alias{.importc: "struct Foo1", size: sizeof(cint).} = object
|
||||
type Foo1Alias{.importc: "struct Foo1", nodecl, size: sizeof(cint).} = object
|
||||
a: cint
|
||||
ensureCgen Foo1Alias
|
||||
|
||||
|
||||
@@ -488,7 +488,7 @@ typedef struct{
|
||||
""".}
|
||||
|
||||
type
|
||||
Foo {.importc.} = object
|
||||
Foo {.importc, nodecl.} = object
|
||||
|
||||
Bar = object
|
||||
b: byte
|
||||
@@ -549,7 +549,7 @@ doAssert alignof(MyCustomAlignObject) == 32
|
||||
##########################################
|
||||
|
||||
type
|
||||
imported_double {.importc: "double".} = object
|
||||
imported_double {.importc: "double", nodecl.} = object
|
||||
|
||||
Pod = object
|
||||
v* : imported_double
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
{.passL: "-lsfml-graphics -lsfml-system -lsfml-window".}
|
||||
|
||||
type
|
||||
VideoMode* {.importcpp: "sf::VideoMode".} = object
|
||||
RenderWindowObj {.importcpp: "sf::RenderWindow".} = object
|
||||
VideoMode* {.importcpp: "sf::VideoMode", nodecl.} = object
|
||||
RenderWindowObj {.importcpp: "sf::RenderWindow", nodecl.} = object
|
||||
RenderWindow* = ptr RenderWindowObj
|
||||
Color* {.importcpp: "sf::Color".} = object
|
||||
Event* {.importcpp: "sf::Event".} = object
|
||||
Color* {.importcpp: "sf::Color", nodecl.} = object
|
||||
Event* {.importcpp: "sf::Event", nodecl.} = object
|
||||
|
||||
{.push cdecl, header: "<SFML/Graphics.hpp>".}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ cimported set1_imported(double x) {
|
||||
|
||||
"""}
|
||||
|
||||
type vfloat{.importc: "cimported".} = object
|
||||
type vfloat{.importc: "cimported", nodecl.} = object
|
||||
|
||||
proc set1(a: float): vfloat {.importc: "set1_imported".}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user