Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix EOLs and Repo Settings #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
root = true


## Nim
#######
[*.{nim,nim.cfg,nimble,nimf,nims}]
indent_size = unset
indent_style = space
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true


## C++ Source Files
###################
[*.{cpp,h,hpp,mm}]
indent_style = space
indent_size = 2
end_of_line = unset
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

; C-style doc comments:
block_comment_start = /*
block_comment = *
block_comment_end = */


## Repository Configurations
############################
[.{git*,editorconfig}]
indent_style = space
indent_size = unset
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true


## Make Files
#############
[{*[Mm]akefile*,*.mak,*.mk,depend}]
indent_size = 2
indent_style = tab
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true


## Shell Scripts
################
[*.sh]
end_of_line = lf
indent_style = tab
indent_size = unset
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true


## Batch Scripts
################
[*.bat]
indent_style = tab
indent_size = unset
end_of_line = crlf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
40 changes: 40 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
* text=auto

## Nim files
############
*.nim text eol=lf
*.nim.cfg text eol=lf
*.nimble text eol=lf
*.nimf text eol=lf linguist-language=Nim
*.nims text eol=lf

## C++ includes
###############
*.cpp text
*.h text
*.hpp text
*.mm text

## Shell/CMD scripts
####################
*.bat text eol=crlf
*.sh text eol=lf

## Documentation
################
*.md text
*.rst text
LICENSE text

## Miscellanea
##############
*.html text
Makefile text eol=lf

## Repository settings
######################
.editorconfig text eol=lf
.gitattributes text eol=lf
.gitconfig text eol=lf
.gitignore text eol=lf
.gitmodules text eol=lf
60 changes: 58 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,64 @@
/nimcache/
*.log
*.so
sciter
sciter.html
test
sciter*.dll

## ============
## Binary files
## ============

## Object files
###############
*.elf
*.ko
*.o
*.obj

## Static libraries
###################
*.a
*.la
*.lib
*.lo

## Shared objects
#################
*.dll
*.dylib
*.so
*.so.*

## Executables
##############
*.app
*.exe
*.out

############################
## COMMON IGNORE PATTERNS ##
############################

## Linux
########
*~
.directory
.fuse_hidden*
.nfs*
.Trash-*

## macOS
########
*.DS_Store
._*
.AppleDouble
.LSOverride
Icon

## Windows
##########
Thumbs.db
ehthumbs.db
ehthumbs_vista.db
Desktop.ini
.BIN/
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
NSRC = test.nim sciter.nim xapi.nim xdef.nim xbehavior.nim loader.nim \
xdom.nim xgraphics.nim xrequest.nim xvalue.nim xtiscript.nim \
event.nim valueprocs.nim
NSRC = test.nim sciter.nim xapi.nim xdef.nim xbehavior.nim loader.nim \
xdom.nim xgraphics.nim xrequest.nim xvalue.nim xtiscript.nim \
event.nim valueprocs.nim

test:${NSRC}
nim c test
Expand All @@ -17,21 +17,21 @@ xapi.nim:include/sciter-x-api.h
sed -i 's/ptr LPCSTR_RECEIVER/LPCSTR_RECEIVER/g' $@
sed -i 's/ptr LPCWSTR_RECEIVER/LPCWSTR_RECEIVER/g' $@
sed -i 's/ptr LPCBYTE_RECEIVER/LPCBYTE_RECEIVER/g' $@

xdef.nim:include/sciter-x-def.h
c2nim -o:$@ $^

xbehavior.nim:include/sciter-x-behavior.h
c2nim -o:$@ $^
sed -i 's/EVENT_GROUPS\* \= enum/EVENT_GROUPS\* {\.size: sizeof(cint)\.} \= enum/g' $@

xdom.nim:include/sciter-x-dom.h
c2nim -o:$@ $^
sed -i '/HELEMENT\* \=/c\ HELEMENT* = distinct pointer' $@

xgraphics.nim:include/sciter-x-graphics.h
c2nim -o:$@ $^

xrequest.nim:include/sciter-x-request.h
c2nim -o:$@ $^

Expand All @@ -42,5 +42,5 @@ xtiscript.nim:include/tiscript.h
c2nim -o:$@ $^

clean:
rm -rf sciter nimcache xapi.nim xdef.nim xdom.nim xgraphics.nim xrequest.nim xtiscript.nim xvalue.nim xbehavior.nim \
test
rm -rf sciter nimcache xapi.nim xdef.nim xdom.nim xgraphics.nim xrequest.nim xtiscript.nim xvalue.nim xbehavior.nim \
test
88 changes: 44 additions & 44 deletions event.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type
handle_data_arrived*: proc(he:HELEMENT, params: ptr DATA_ARRIVED_PARAMS ):bool
handle_scripting_call*: proc(he:HELEMENT, params: ptr SCRIPTING_METHOD_PARAMS):bool

detached*: proc(he:HELEMENT)
detached*: proc(he:HELEMENT)
attached*: proc(he:HELEMENT)

EventHandler* = ptr EventHandlerObj
Expand All @@ -35,19 +35,19 @@ var fn_handle_data_arrived = proc(he:HELEMENT, params: ptr DATA_ARRIVED_PARAMS )
var fn_handle_scripting_call = proc(he:HELEMENT, params: ptr SCRIPTING_METHOD_PARAMS):bool = return false
var fn_ttach = proc(he:HELEMENT) = discard

proc newEventHandler*(): EventHandler =
proc newEventHandler*(): EventHandler =
var eh:EventHandler = cast[EventHandler](alloc(sizeof(EventHandlerObj)))
eh.handle_mouse = fn_handle_mouse
eh.handle_key = fn_handle_key
eh.handle_focus = fn_handle_focus
eh.handle_timer = fn_handle_timer
eh.handle_mouse = fn_handle_mouse
eh.handle_key = fn_handle_key
eh.handle_focus = fn_handle_focus
eh.handle_timer = fn_handle_timer
eh.handle_size = fn_handle_size
eh.handle_scroll = fn_handle_scroll
eh.handle_gesture = fn_handle_gesture
eh.handle_draw = fn_handle_draw
eh.handle_method_call = fn_handle_method_call
eh.handle_tiscript_call = fn_handle_tiscript_call
eh.handle_event = fn_handle_event
eh.handle_method_call = fn_handle_method_call
eh.handle_tiscript_call = fn_handle_tiscript_call
eh.handle_event = fn_handle_event
eh.handle_data_arrived = fn_handle_data_arrived
eh.handle_scripting_call = fn_handle_scripting_call
eh.detached = fn_ttach
Expand All @@ -66,59 +66,59 @@ proc element_proc(tag: pointer; he: HELEMENT; evtg: uint32; prms: pointer): bool
# var p: ptr UINT = cast[ptr UINT](prms)
# return pThis.subscription(he, p)
of uint32(HANDLE_INITIALIZATION):
var p: ptr INITIALIZATION_PARAMS = cast[ptr INITIALIZATION_PARAMS](prms)
if p.cmd == BEHAVIOR_DETACH:
var p: ptr INITIALIZATION_PARAMS = cast[ptr INITIALIZATION_PARAMS](prms)
if p.cmd == BEHAVIOR_DETACH:
pThis.detached(he)
evct.inc(pThis, -1)
if evct.contains(pThis):
dealloc(pThis)
elif p.cmd == BEHAVIOR_ATTACH:
dealloc(pThis)
elif p.cmd == BEHAVIOR_ATTACH:
pThis.attached(he)
evct.inc(pThis)
return true
return true
of uint32(HANDLE_MOUSE):
var p: ptr MOUSE_PARAMS = cast[ptr MOUSE_PARAMS](prms)
return pThis.handle_mouse(he, p)
var p: ptr MOUSE_PARAMS = cast[ptr MOUSE_PARAMS](prms)
return pThis.handle_mouse(he, p)
of uint32(HANDLE_KEY):
var p: ptr KEY_PARAMS = cast[ptr KEY_PARAMS](prms)
return pThis.handle_key(he, p)
var p: ptr KEY_PARAMS = cast[ptr KEY_PARAMS](prms)
return pThis.handle_key(he, p)
of uint32(HANDLE_FOCUS):
var p: ptr FOCUS_PARAMS = cast[ptr FOCUS_PARAMS](prms)
return pThis.handle_focus(he, p)
var p: ptr FOCUS_PARAMS = cast[ptr FOCUS_PARAMS](prms)
return pThis.handle_focus(he, p)
of uint32(HANDLE_DRAW):
var p: ptr DRAW_PARAMS = cast[ptr DRAW_PARAMS](prms)
return pThis.handle_draw(he, p)
var p: ptr DRAW_PARAMS = cast[ptr DRAW_PARAMS](prms)
return pThis.handle_draw(he, p)
of uint32(HANDLE_TIMER):
var p: ptr TIMER_PARAMS = cast[ptr TIMER_PARAMS](prms)
return pThis.handle_timer(he, p)
var p: ptr TIMER_PARAMS = cast[ptr TIMER_PARAMS](prms)
return pThis.handle_timer(he, p)
of uint32(HANDLE_BEHAVIOR_EVENT):
var p: ptr BEHAVIOR_EVENT_PARAMS = cast[ptr BEHAVIOR_EVENT_PARAMS](prms)
return pThis.handle_event(he, p)
var p: ptr BEHAVIOR_EVENT_PARAMS = cast[ptr BEHAVIOR_EVENT_PARAMS](prms)
return pThis.handle_event(he, p)
of uint32(HANDLE_METHOD_CALL):
var p: ptr METHOD_PARAMS = cast[ptr METHOD_PARAMS](prms)
return pThis.handle_method_call(he, p)
var p: ptr METHOD_PARAMS = cast[ptr METHOD_PARAMS](prms)
return pThis.handle_method_call(he, p)
of uint32(HANDLE_DATA_ARRIVED):
var p: ptr DATA_ARRIVED_PARAMS = cast[ptr DATA_ARRIVED_PARAMS](prms)
return pThis.handle_data_arrived(he, p)
var p: ptr DATA_ARRIVED_PARAMS = cast[ptr DATA_ARRIVED_PARAMS](prms)
return pThis.handle_data_arrived(he, p)
of uint32(HANDLE_SCROLL):
var p: ptr SCROLL_PARAMS = cast[ptr SCROLL_PARAMS](prms)
return pThis.handle_scroll(he, p)
var p: ptr SCROLL_PARAMS = cast[ptr SCROLL_PARAMS](prms)
return pThis.handle_scroll(he, p)
of uint32(HANDLE_SIZE):
discard pThis.handle_size(he)
return false
## # call using sciter::value's (from CSSS!)
discard pThis.handle_size(he)
return false
## # call using sciter::value's (from CSSS!)
of uint32(HANDLE_SCRIPTING_METHOD_CALL):
var p: ptr SCRIPTING_METHOD_PARAMS = cast[ptr SCRIPTING_METHOD_PARAMS](prms)
return pThis.handle_scripting_call(he, p)
## # call using tiscript::value's (from the script)
var p: ptr SCRIPTING_METHOD_PARAMS = cast[ptr SCRIPTING_METHOD_PARAMS](prms)
return pThis.handle_scripting_call(he, p)
## # call using tiscript::value's (from the script)
of uint32(HANDLE_TISCRIPT_METHOD_CALL):
var p: ptr TISCRIPT_METHOD_PARAMS = cast[ptr TISCRIPT_METHOD_PARAMS](prms)
return pThis.handle_tiscript_call(he, p)
var p: ptr TISCRIPT_METHOD_PARAMS = cast[ptr TISCRIPT_METHOD_PARAMS](prms)
return pThis.handle_tiscript_call(he, p)
of uint32(HANDLE_GESTURE):
var p: ptr GESTURE_PARAMS = cast[ptr GESTURE_PARAMS](prms)
return pThis.handle_gesture(he, p)
var p: ptr GESTURE_PARAMS = cast[ptr GESTURE_PARAMS](prms)
return pThis.handle_gesture(he, p)
else:
return false
return false
return false

proc Attach*(target:EventTarget, eh:EventHandler, mask:uint32 = HANDLE_ALL): int32 {.discardable.} =
Expand Down Expand Up @@ -154,7 +154,7 @@ proc defineScriptingFunction*(target:EventTarget, name:string, fn:NativeFunctor)
var step = cast[uint](sizeof(Value))
if params.argc > 0.uint32:
for idx in 0..params.argc-1:
var p = cast[ptr Value](base + step*uint(idx))
var p = cast[ptr Value](base + step*uint(idx))
args[int(idx)] = p[]
params.result = fn(args)
return true
Expand Down
Loading