summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2015-01-18 16:04:02 +0100
committerAraq <rumpf_a@web.de>2015-01-18 16:04:02 +0100
commitbb3dae3a9196abbe663ffbdf6f065eba86d6c548 (patch)
tree44203fd8ed8a71b45eac35eff000b2e0f3ad9724 /lib
parentbe1441a810a94617be53c3a4f0d45529d0fd2ffc (diff)
downloadNim-bb3dae3a9196abbe663ffbdf6f065eba86d6c548.tar.gz
osinfo_win compiles again
Diffstat (limited to 'lib')
-rw-r--r--lib/impure/osinfo_win.nim7
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/impure/osinfo_win.nim b/lib/impure/osinfo_win.nim
index becec928e..94a27eb03 100644
--- a/lib/impure/osinfo_win.nim
+++ b/lib/impure/osinfo_win.nim
@@ -195,9 +195,8 @@ proc getVersionInfo*(): TVersionInfo =
 proc getProductInfo*(majorVersion, minorVersion, SPMajorVersion, 
                      SPMinorVersion: int): int =
   ## Retrieves Windows' ProductInfo, this function only works in Vista and 7
-
   var pGPI = cast[proc (dwOSMajorVersion, dwOSMinorVersion, 
-              dwSpMajorVersion, dwSpMinorVersion: int32, outValue: Pint32)](getProcAddress(
+              dwSpMajorVersion, dwSpMinorVersion: int32, outValue: Pint32){.stdcall.}](getProcAddress(
                 getModuleHandleA("kernel32.dll"), "GetProductInfo"))
                 
   if pGPI != nil:
@@ -214,7 +213,7 @@ proc getSystemInfo*(): TSYSTEM_INFO =
   ## Returns the SystemInfo
 
   # Use GetNativeSystemInfo if it's available
-  var pGNSI = cast[proc (lpSystemInfo: LPSYSTEM_INFO)](getProcAddress(
+  var pGNSI = cast[proc (lpSystemInfo: LPSYSTEM_INFO){.stdcall.}](getProcAddress(
                 getModuleHandleA("kernel32.dll"), "GetNativeSystemInfo"))
                 
   var systemi: TSYSTEM_INFO              
@@ -407,6 +406,6 @@ when isMainModule:
   
   echo($osvi)
 
-  echo(getFileSize(r"osinfo_win.nim") div 1024 div 1024)
+  echo(getFileSize(r"lib\impure\osinfo_win.nim") div 1024, " KB")
   
   echo(rdFileTime(getPartitionInfo(r"C:\")[0]))
eight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
discard """
  output: '''
A
A
25.0
210.0
apr
'''
"""


block t4435:
  type
    A[T] = distinct T
    B[T] = distinct T

  proc foo[T](x:A[T]) = echo "A"
  proc foo[T](x:B[T]) = echo "B"
  proc bar(x:A) = echo "A"
  proc bar(x:B) = echo "B"

  var
    a:A[int]

  foo(a) # fine
  bar(a) # testdistinct.nim(14, 4) Error: ambiguous call; both testdistinct.bar(x: A) and testdistinct.bar(x: B) match for: (A[system.int])



block t7010:
  type MyInt = distinct int

  proc `+`(x: MyInt, y: MyInt): MyInt {.borrow.}
  proc `+=`(x: var MyInt, y: MyInt) {.borrow.}
  proc `=`(x: var MyInt, y: MyInt) {.borrow.}

  var next: MyInt

  proc getNext() : MyInt =
      result = next
      next += 1.MyInt
      next = next + 1.MyInt



block t9079:
  type
    Dollars = distinct float

  proc `$`(d: Dollars): string {.borrow.}
  proc `*`(a, b: Dollars): Dollars {.borrow.}
  proc `+`(a, b: Dollars): Dollars {.borrow.}

  var a = Dollars(20)
  a = Dollars(25.0)
  echo a
  a = 10.Dollars * (20.Dollars + 1.Dollars)
  echo a



block t9322:
  type Fix = distinct string
  proc `$`(f: Fix): string {.borrow.}
  proc mystr(s: string) =
    echo s
  mystr($Fix("apr"))


block: # bug #13517
  type MyUint64 = distinct uint64

  proc `==`(a: MyUint64, b: uint64): bool = uint64(a) == b

  block:
    doAssert MyUint64.high is MyUint64
    doAssert MyUint64.high == 18446744073709551615'u64

  static:
    doAssert MyUint64.high is MyUint64
    doAssert MyUint64.high == 18446744073709551615'u64