Removed Node, NodeType and Document definitions from jssys.
This commit is contained in:
parent
eaed36092c
commit
0abfbf8f0d
2 changed files with 22 additions and 74 deletions
|
|
@ -33,6 +33,9 @@ type
|
||||||
lineNumber {.importc.}: int
|
lineNumber {.importc.}: int
|
||||||
message {.importc.}: cstring
|
message {.importc.}: cstring
|
||||||
stack {.importc.}: cstring
|
stack {.importc.}: cstring
|
||||||
|
|
||||||
|
JSRef = ref RootObj # Fake type.
|
||||||
|
|
||||||
{.deprecated: [TSafePoint: SafePoint, TCallFrame: CallFrame].}
|
{.deprecated: [TSafePoint: SafePoint, TCallFrame: CallFrame].}
|
||||||
|
|
||||||
var
|
var
|
||||||
|
|
@ -282,61 +285,6 @@ proc eqStrings(a, b: string): bool {.asmNoStackFrame, compilerProc.} =
|
||||||
return true;
|
return true;
|
||||||
"""
|
"""
|
||||||
|
|
||||||
type
|
|
||||||
Document {.importc.} = object of RootObj
|
|
||||||
write: proc (text: cstring) {.nimcall.}
|
|
||||||
writeln: proc (text: cstring) {.nimcall.}
|
|
||||||
createAttribute: proc (identifier: cstring): ref Node {.nimcall.}
|
|
||||||
createElement: proc (identifier: cstring): ref Node {.nimcall.}
|
|
||||||
createTextNode: proc (identifier: cstring): ref Node {.nimcall.}
|
|
||||||
getElementById: proc (id: cstring): ref Node {.nimcall.}
|
|
||||||
getElementsByName: proc (name: cstring): seq[ref Node] {.nimcall.}
|
|
||||||
getElementsByTagName: proc (name: cstring): seq[ref Node] {.nimcall.}
|
|
||||||
|
|
||||||
NodeType* = enum
|
|
||||||
ElementNode = 1,
|
|
||||||
AttributeNode,
|
|
||||||
TextNode,
|
|
||||||
CDATANode,
|
|
||||||
EntityRefNode,
|
|
||||||
EntityNode,
|
|
||||||
ProcessingInstructionNode,
|
|
||||||
CommentNode,
|
|
||||||
DocumentNode,
|
|
||||||
DocumentTypeNode,
|
|
||||||
DocumentFragmentNode,
|
|
||||||
NotationNode
|
|
||||||
Node* {.importc.} = object of RootObj
|
|
||||||
attributes*: seq[ref Node]
|
|
||||||
childNodes*: seq[ref Node]
|
|
||||||
data*: cstring
|
|
||||||
firstChild*: ref Node
|
|
||||||
lastChild*: ref Node
|
|
||||||
nextSibling*: ref Node
|
|
||||||
nodeName*: cstring
|
|
||||||
nodeType*: NodeType
|
|
||||||
nodeValue*: cstring
|
|
||||||
parentNode*: ref Node
|
|
||||||
previousSibling*: ref Node
|
|
||||||
appendChild*: proc (child: ref Node) {.nimcall.}
|
|
||||||
appendData*: proc (data: cstring) {.nimcall.}
|
|
||||||
cloneNode*: proc (copyContent: bool) {.nimcall.}
|
|
||||||
deleteData*: proc (start, len: int) {.nimcall.}
|
|
||||||
getAttribute*: proc (attr: cstring): cstring {.nimcall.}
|
|
||||||
getAttributeNode*: proc (attr: cstring): ref Node {.nimcall.}
|
|
||||||
getElementsByTagName*: proc (): seq[ref Node] {.nimcall.}
|
|
||||||
hasChildNodes*: proc (): bool {.nimcall.}
|
|
||||||
insertBefore*: proc (newNode, before: ref Node) {.nimcall.}
|
|
||||||
insertData*: proc (position: int, data: cstring) {.nimcall.}
|
|
||||||
removeAttribute*: proc (attr: cstring) {.nimcall.}
|
|
||||||
removeAttributeNode*: proc (attr: ref Node) {.nimcall.}
|
|
||||||
removeChild*: proc (child: ref Node) {.nimcall.}
|
|
||||||
replaceChild*: proc (newNode, oldNode: ref Node) {.nimcall.}
|
|
||||||
replaceData*: proc (start, len: int, text: cstring) {.nimcall.}
|
|
||||||
setAttribute*: proc (name, value: cstring) {.nimcall.}
|
|
||||||
setAttributeNode*: proc (attr: ref Node) {.nimcall.}
|
|
||||||
{.deprecated: [TNode: Node, TNodeType: NodeType, TDocument: Document].}
|
|
||||||
|
|
||||||
when defined(kwin):
|
when defined(kwin):
|
||||||
proc rawEcho {.compilerproc, asmNoStackFrame.} =
|
proc rawEcho {.compilerproc, asmNoStackFrame.} =
|
||||||
asm """
|
asm """
|
||||||
|
|
@ -360,28 +308,28 @@ elif defined(nodejs):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
else:
|
else:
|
||||||
var
|
|
||||||
document {.importc, nodecl.}: ref Document
|
|
||||||
|
|
||||||
proc ewriteln(x: cstring) =
|
proc ewriteln(x: cstring) =
|
||||||
var node = document.getElementsByTagName("body")[0]
|
var node : JSRef
|
||||||
if node != nil:
|
{.emit: "`node` = document.getElementsByTagName('body')[0];".}
|
||||||
node.appendChild(document.createTextNode(x))
|
if node.isNil:
|
||||||
node.appendChild(document.createElement("br"))
|
|
||||||
else:
|
|
||||||
raise newException(ValueError, "<body> element does not exist yet!")
|
raise newException(ValueError, "<body> element does not exist yet!")
|
||||||
|
{.emit: """
|
||||||
|
`node`.appendChild(document.createTextNode(`x`));
|
||||||
|
`node`.appendChild(document.createElement("br"));
|
||||||
|
""".}
|
||||||
|
|
||||||
proc rawEcho {.compilerproc.} =
|
proc rawEcho {.compilerproc.} =
|
||||||
var node = document.getElementsByTagName("body")[0]
|
var node : JSRef
|
||||||
if node == nil:
|
{.emit: "`node` = document.getElementsByTagName('body')[0];".}
|
||||||
|
if node.isNil:
|
||||||
raise newException(IOError, "<body> element does not exist yet!")
|
raise newException(IOError, "<body> element does not exist yet!")
|
||||||
asm """
|
{.emit: """
|
||||||
for (var i = 0; i < arguments.length; ++i) {
|
for (var i = 0; i < arguments.length; ++i) {
|
||||||
var x = `toJSStr`(arguments[i]);
|
var x = `toJSStr`(arguments[i]);
|
||||||
`node`.appendChild(document.createTextNode(x))
|
`node`.appendChild(document.createTextNode(x));
|
||||||
}
|
}
|
||||||
"""
|
`node`.appendChild(document.createElement("br"));
|
||||||
node.appendChild(document.createElement("br"))
|
""".}
|
||||||
|
|
||||||
# Arithmetic:
|
# Arithmetic:
|
||||||
proc addInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
|
proc addInt(a, b: int): int {.asmNoStackFrame, compilerproc.} =
|
||||||
|
|
@ -532,8 +480,6 @@ proc nimMax(a, b: int): int {.compilerproc.} = return if a >= b: a else: b
|
||||||
type NimString = string # hack for hti.nim
|
type NimString = string # hack for hti.nim
|
||||||
include "system/hti"
|
include "system/hti"
|
||||||
|
|
||||||
type JSRef = ref RootObj # Fake type.
|
|
||||||
|
|
||||||
proc isFatPointer(ti: PNimType): bool =
|
proc isFatPointer(ti: PNimType): bool =
|
||||||
# This has to be consistent with the code generator!
|
# This has to be consistent with the code generator!
|
||||||
return ti.base.kind notin {tyObject,
|
return ti.base.kind notin {tyObject,
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ News
|
||||||
|
|
||||||
- ``macros.newLit`` for ``bool`` now produces false/true symbols which
|
- ``macros.newLit`` for ``bool`` now produces false/true symbols which
|
||||||
actually work with the bool datatype.
|
actually work with the bool datatype.
|
||||||
|
- when compiling to JS, ``Node``, ``NodeType`` and ``Document`` are no longer
|
||||||
|
defined. Use the types defined in ``dom.nim`` instead.
|
||||||
|
|
||||||
|
|
||||||
2015-10-27 Version 0.12.0 released
|
2015-10-27 Version 0.12.0 released
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue