00:42:44  <indutny>creationix: evening, yt?
00:43:09  <creationix>yep
00:43:27  <indutny>creationix: so the problem with cdata is that it's a string internally
00:43:35  <indutny>that means that your data resides in the heap too
00:43:41  <indutny>and your data may be moved
00:43:53  <creationix>moving is fine as long as the bits move with it
00:44:08  <creationix>I don't think the struct cares where it's base address is
00:44:10  <indutny>I don't think that moving is fine for candor.io
00:44:32  <indutny>suppose you've a cdata at some addr
00:44:33  * piscisaureus_quit (Ping timeout: 248 seconds)
00:44:44  * hij1nxjoined
00:44:44  <indutny>and an async action that will read that struct after some time
00:45:00  <indutny>you'll store pointer to that structure into libuv's queue
00:45:18  <indutny>and once libuv will finish it's job - it'll load that pointer, cast object and run callback
00:45:22  <creationix>true
00:45:44  <creationix>well than we shouldn't be moving the cdata
00:45:45  <indutny>that's what I hadn't considered before
00:45:50  <creationix>allocate it outside th heap maybe
00:45:55  <indutny>hm...
00:46:12  <creationix>if cdata can't be used for anything than pointers, what good is it
00:46:24  <creationix>(meaning the alloc properties of it)
00:46:25  <indutny>it can be used for structures
00:46:33  <indutny>but that depends on your usage
00:46:54  <creationix>in lua I do the same thing and haven't hit any issues
00:47:04  <creationix>I'll bet they don't move the cdata
00:47:06  <indutny>having the actual bytes in external storage will require adding weak callback for each created cdata
00:47:41  <creationix>true, but if I store a pointer to the struct I'll have to register a weak callback myself
00:47:54  <indutny>yes
00:48:02  <indutny>true too
00:53:54  <indutny>ok, gtg
00:54:01  <indutny>I'll think about it today
01:04:56  <indutny>ttyl
01:12:15  <indutny>creationix: fixed most of your issues
01:12:19  * indutnychanged nick to indutny_away
01:13:16  <creationix>indutny_away, thanks
01:22:10  * alejandromgjoined
01:47:31  * karterkjoined
01:48:34  <creationix>indutny_away, one issue is still there
01:48:44  <creationix>I should have filed it as it's own issue, not as part of the : issue
01:48:50  <creationix>I'll file a new one
03:10:58  * karterkquit (Remote host closed the connection)
03:34:31  * karterkjoined
05:57:25  * alejandromgquit (Quit: leaving)
06:20:54  * alejandr1mgjoined
06:38:39  * alejandr1mgquit (Quit: leaving)
09:54:47  * indutny_awayquit (Ping timeout: 250 seconds)
10:01:05  * indutnyjoined
12:15:31  * karterkquit (Remote host closed the connection)
12:27:50  <indutny>creationix: fixed!
12:27:51  <indutny>:)
12:47:10  * karterkjoined
12:52:32  <creationix>indutny, mornin
12:52:42  <indutny>creationix: mornin
12:53:48  <creationix>testing fix now
12:53:54  <indutny>cool
12:54:00  * indutnypart
12:54:01  * indutnyjoined
12:54:42  <indutny>brb
12:54:45  * indutnyquit (Quit: Leaving.)
12:55:37  * indutnyjoined
12:55:41  <indutny>back
13:01:17  <indutny>creationix: candor.io works fine locally (net.can example)
13:01:33  <indutny>logging output is seems to be correct
13:01:34  <indutny>oh, btw
13:01:41  <indutny>let me open a PR for you
13:01:45  <indutny>I've removed Arguments class
13:01:48  <creationix>I see
13:01:53  <creationix>I was trying to fix that
13:03:16  <indutny>creationix: done, https://github.com/creationix/candor.io/pull/2/files
13:03:51  <creationix>much prettier, I like the new API
13:04:11  <indutny>heh
13:05:09  <creationix>I don't know why, but Value*[] makes more sense to me than Arguments
13:05:25  <indutny>to me too
13:05:32  <indutny>it wasn't possible before
13:05:41  <indutny>i did some hack to implement that
13:05:53  <indutny>pushing variables to stack in natural order now
13:21:31  <indutny>creationix: how is it going?
13:22:00  * piscisaureus_joined
13:24:07  <creationix>good, but need to go eat breakfast with family
13:25:34  <creationix>saved my changes
13:25:40  <indutny>:)
13:25:41  <indutny>cool
13:54:04  <creationix>alright, net.can is working
13:54:21  <creationix>with a very node-like API
13:54:31  <creationix>now I need to find a way to have script modules built-in
14:08:01  <creationix>indutny, so what should I do about the moving structs?
14:18:58  * karterkquit (Remote host closed the connection)
14:21:56  * karterkjoined
14:29:16  * karterkquit (Remote host closed the connection)
15:45:49  * karterkjoined
15:58:18  * mmalecki[zzz]changed nick to mmalecki
16:34:43  * indutnyquit (Ping timeout: 252 seconds)
16:50:57  * mmaleckichanged nick to mmalecki[brb]
17:31:07  * indutnyjoined
17:31:09  * indutnypart
17:31:14  * indutnyjoined
17:43:44  <indutny>creationix: you should allocate data in user-managable heap
17:43:47  <indutny>i.e with malloc/new
17:44:29  * mmalecki[brb]changed nick to mmalecki
17:44:49  <creationix>indutny, right
17:46:13  <indutny>so use CWrapper
17:46:31  <indutny>create class
17:46:54  <indutny>let me think
17:55:38  * hij1nxquit (Quit: hij1nx)
18:02:39  * alejandromgjoined
18:18:06  * piscisaureus_quit (Ping timeout: 246 seconds)
18:26:55  <indutny>creationix: yt?
18:27:13  <creationix>sorry, I was fixing c9 stuff
18:27:16  <creationix>yeah, I have a class
18:27:17  <indutny>np
18:27:20  <creationix>inherits from CWrapper
18:27:33  <indutny>so, I tried subclassing from class that inherits from CWrapper
18:27:38  <indutny>https://github.com/indutny/candor/commit/c08e05092b5707881faad79e49a5abe833844ea7
18:27:41  <indutny>and it works fine
18:27:58  <indutny>are you sure you're doing class A : public B {} instead of class A : B {}
18:28:33  <creationix>indutny, https://gist.github.com/673906bbce33c8a1c67e
18:29:11  <indutny>what if you'll make properties public
18:29:34  <indutny>?
18:29:42  <creationix>I didn't like what I was doing before because it was too much code
18:29:50  <creationix>I needed C wrappers for all the C++ methods
18:30:08  <creationix>since Function::New() and all the libuv callbacks need normal static functions
18:30:36  <indutny>just use static functions
18:30:39  <indutny>as you use in node
18:30:49  <indutny>class A : public CWrapper {
18:30:57  <creationix>right, my new approach is to use this new class in place of vanilla CData
18:31:01  <indutny>static Value* New();
18:31:19  <indutny>kk
18:31:46  <creationix>well static C++ function or flat C functions, it's all the same, just in a different plce
18:32:46  <creationix>so I'm having trouble compiling this code
18:32:57  <creationix>and also there is a design flaw where objects never get GCed
18:33:04  <indutny>huh?
18:33:17  <creationix>so in https://gist.github.com/673906bbce33c8a1c67e
18:33:41  <creationix>from candor I need an object that's a clone of the prototype object and also contains a cdata property
18:33:52  <creationix>where cdata is the Wrap() version of this class
18:34:18  <creationix>but I want a way to ensure the object is referenced sometimes
18:34:26  <creationix>like when there is a pending callback that needs it
18:34:38  <indutny>ah
18:34:43  <creationix>so I thought I would put a handle in my class
18:34:46  <indutny>you need some sort of weak reference then
18:34:47  <creationix>Handle<Object>
18:35:03  <creationix>I need a weak reference and refcounting on it
18:35:13  <creationix>so I can make it strong or weak depending on the count
18:36:44  <indutny>ok
18:36:48  <indutny>I'll implement that
18:36:57  <creationix>refcount for handles?
18:38:05  <indutny>I think, yes
18:40:26  <creationix>that would be awesome
18:41:08  <creationix>add ref, remove ref, and get number of refs, when it's 0, the handle is weak
18:41:19  <creationix>maybe default to 1 to keep current behavior
18:42:19  <indutny>yes
18:42:24  <indutny>default should be 1
18:47:49  <creationix>there is another way
18:47:56  <creationix>instead of implementing a refcount system inside handle
18:48:03  * karterkquit (Remote host closed the connection)
18:48:14  <creationix>just put a hook on the weakcallback where I can return true and it won't be collected
18:48:30  <creationix>then I can implement the refcount or other logic inside my class
18:48:52  <creationix>maybe I just have a list of pending callbacks and I check is the list is non-empty
18:49:12  <creationix>indutny, ^^
18:49:43  <indutny>that'll add complexity to GC
18:49:59  <creationix>yeah, I wasn't sure how flexible the logic in there was
18:50:10  <indutny>and waste CPU time on calling your callbacks
18:50:32  <creationix>right
18:50:54  <creationix>so at a minimum I need a way to set a handle weak or strong
18:51:02  <creationix>bonus points if there is a refcount system too
18:51:13  <creationix>but if not, I can just set it weak and strong manually and do my own refcount
18:51:27  <indutny>ok
18:51:57  * hij1nxjoined
18:54:32  * hij1nxquit (Remote host closed the connection)
18:59:36  * hij1nxjoined
19:01:35  <indutny>creationix: done
19:01:45  <indutny>https://github.com/indutny/candor/commit/06c7d124bfb7e615b16ec78e2ba24ef30f01cb22
19:04:55  <creationix>indutny, ok, so by default there is a count of 1 and I have to call Unref to make it weak?
19:05:03  <indutny>yes
19:11:44  <indutny>creationix: how does it looks? is API fine?
19:12:30  <creationix>I think so
19:12:35  <creationix>my code is completely busted right now
19:12:47  <creationix>I hadn't finished integrating my new class in
19:12:56  <creationix>and now I'm getting strange errors after updating
19:13:24  <creationix>canio: src/api.cc:208: bool candor::Value::Is() [with T = candor::String]: Assertion `!HValue::Cast(addr())->IsSoftGCMarked() && !HValue::Cast(addr())->IsGCMarked()' failed.
19:17:47  <creationix>hmm, so "this" in my class isn't a stable pointer
19:17:52  <creationix>since that's what the cdata points to
19:18:13  <creationix>but my Handle<Object> member is
19:18:24  <creationix>?
19:19:43  <creationix>and Unwrap will let go of the object no matter how many refs there are right?
19:26:11  * indutnyquit (Read error: Connection timed out)
19:29:27  * indutnyjoined
19:29:32  <indutny>sorry
19:29:36  <indutny>reconnected
19:49:07  <creationix>I'm trying to use templates
19:49:10  <creationix>but it's not linking
19:49:28  <indutny>templates in your code?
19:49:42  <indutny>you'll need to put declarations in .cc file
19:49:53  <indutny>https://github.com/indutny/candor/blob/master/src/api.cc#L29-43
19:49:59  <indutny>creationix: like that ^
19:51:10  <creationix>so I have this template function https://github.com/creationix/candor.io/blob/master/src/luv.h
19:51:29  <creationix>and I use it like https://github.com/creationix/candor.io/blob/master/src/luv_timer.cc#L32
19:51:44  <creationix>so I just need to declare it up top in luc_timer.cc so the code gets generated?
19:51:57  <indutny>better in luv.cc
19:52:35  <creationix>for all the types I'll use
19:52:37  <indutny>yes
19:52:39  <creationix>good idea
19:52:52  <indutny>and luv.o will contain compiled functions which linker is requesting
19:52:59  <indutny>that's just how it works
19:53:01  <indutny>:)
19:53:24  <creationix>kuje template uv_handle_t* UVData::ObjectTo<uv_handle_t>();
19:53:33  <creationix>s/kuje/like/
19:54:58  <creationix>well, with the proper argument signature
19:54:59  <creationix>seems to work
19:55:39  <creationix>alright, it's compiling, but segfaulting like crazy
19:56:58  <creationix>heh, my uv_timer_t* is 0x10
19:57:09  <creationix>that's an awfully small pointer value
19:59:53  <creationix>C++ template variables can't be put in a printf somehow can they?
19:59:53  <kohai>C has 14 beers
19:59:54  <indutny>heh
20:00:06  <creationix>like #foo in C macros
20:00:07  <indutny>what's a template variable?
20:00:10  <creationix><T>
20:00:11  <creationix>the T
20:00:25  <indutny>what is T?
20:00:26  <creationix>which is later uv_timer_t
20:00:45  <indutny>I think no, but I don't really know
20:01:49  <indutny>0x10
20:01:51  <indutny>nice :)
20:02:41  <creationix>yeah, the real value is something like 0xc59460
20:02:50  <creationix>I messed up somewhere in all the pointers to pointers
20:03:25  <indutny>:)
20:04:35  * piscisaureus_joined
20:06:51  <indutny>btw, why malloc and not new?
20:06:59  <creationix>how do I use new?
20:07:12  <creationix>the size is a variable
20:07:16  <creationix>passed in
20:07:37  <indutny>new char[var]
20:07:42  <indutny>and convert it
20:07:44  <creationix>ok
20:07:55  <creationix>is char always 8 bit?
20:08:02  <creationix>or is int8_t safer
20:08:16  <indutny>you can safely do char[var]
20:08:20  <indutny>it's always 8bit
20:08:22  <creationix>ok
20:08:26  <indutny>AFAIK
20:08:34  <indutny>so, basically
20:08:40  <indutny>I'm debugging your code atm
20:09:13  <creationix>:)
20:09:18  <creationix>yay, no more stdlib.h
20:09:31  <indutny>and it's receiving UVData object that wasn't created
20:10:32  <indutny>oh, that's odd
20:10:35  <creationix>I think my ObjectTo<T> is wrong
20:11:10  <creationix>I should use CWrapper::Unwrap
20:11:24  <indutny>yes
20:12:39  <indutny>creationix: what should VoidToObject do?
20:12:45  <indutny>and why're you using a handle here?
20:12:49  <creationix>it's for async callbacks
20:13:05  <creationix>the ->data pointer in libuv structs and requests is a Handle<Object>*
20:13:22  <creationix>It should take the void* and give back the Object*
20:13:29  <indutny>yes
20:13:33  <indutny>but why is a Handle here?
20:13:44  <creationix>because objects move
20:14:08  <indutny>err
20:14:15  <indutny>you should store Handle inside class then
20:14:58  <creationix>what should libuv point to
20:15:26  <creationix>I can't point to the class instance
20:15:41  <creationix>it will move just like my uv_handle_t structs were moving before
20:16:14  <indutny>class won't move
20:16:25  <indutny>it's allocated with new
20:16:26  <creationix>the instance will
20:16:28  <indutny>no
20:16:41  <indutny>cdata contains pointer to the class
20:17:01  <creationix>ahh, CWrapper handles this for me
20:17:08  <creationix>that's why my handmade unwrapper was wrong
20:17:33  <creationix>ok, then I should give uv a pointer to the class
20:17:44  <creationix>and do straight typecast from void* to UVData*
20:18:12  <indutny>yes
20:21:06  <creationix>ok, pushed fixes
20:21:10  <creationix>it's working mostly now
20:21:11  <creationix>but I'
20:21:23  <creationix>I'l still crashing on the same libuv assert as before when my structs were moving
20:21:50  <indutny>hm...
20:22:26  <creationix>or maybe the moving wasn't the cause of the trouble
20:22:38  <creationix>let me refactor tcp and stream to use this new class too
20:22:40  <indutny>that's what I was afraid of :)
20:22:45  <creationix>and see if the tcp echo server gets fixed
20:22:52  <indutny>Assertion failed: (!(handle->flags & UV_CLOSED)), function uv__finish_close, file src/unix/core.c, line 237.
20:22:54  <creationix>that one I'm pretty sure is caused by moving structs
20:23:18  <creationix>yep, I've had that issue in test-timer for a long time
20:23:21  <creationix>no clue what's causing it
20:23:29  <creationix>only calling close on the first timer object does it
20:23:36  <creationix>the second one is fine
20:23:50  <indutny>interesting
20:24:18  <creationix>another unrelated weirdness, simple calling require in an empty candor script makes the libuv event loop block
20:24:26  <creationix>even if it's a non uv module like string
20:24:59  <creationix>try it, create a script with just 'global.prettyPrint(require"string"))'
20:25:23  <creationix>but just 'global.prettyPrint(require)' is fine
20:25:23  <indutny>one sec
20:26:38  <indutny>odd
20:26:42  <indutny>how is that related to uv?
20:26:53  <creationix>no clue
20:26:59  <creationix>but the process does hang
20:27:12  * alejandromgquit (Ping timeout: 260 seconds)
20:27:22  <creationix>I don't even execute the modules till the first time they are required
20:27:30  <creationix>it's just dormant code in the executable before that
20:27:42  <creationix>and the prototypes are generated on the first time they are requested
20:27:55  <indutny>k
20:27:59  <indutny>I'll consider that tomorrow
20:28:00  <creationix>so all of luv_* should be executed at all
20:28:05  <indutny>going to sleep now
20:28:07  <indutny>ttyl
20:28:09  <creationix>*shouldn't
20:28:09  * indutnychanged nick to indutny_sleeping
20:28:12  <creationix>ok, get some rest
20:35:49  <creationix>yep, that fixed the tcp echo server
20:52:34  * indutny_sleepingquit (Read error: Connection timed out)
20:59:27  * indutnyjoined
21:07:41  * piscisaureus_quit (Ping timeout: 246 seconds)
21:11:09  * alejandromgjoined
21:25:27  * alejandromgquit (Read error: Connection reset by peer)
21:26:50  * alejandromgjoined
22:33:59  <creationix>who needs python anyway :P
22:33:59  <creationix>https://github.com/creationix/candor.io/commit/074b0223e3cf344427c9e5e518e57f06616ee05f
22:54:34  * alejandromgquit (Quit: #freenode)
23:41:57  * tilgovijoined
23:59:23  * tilgoviquit (Remote host closed the connection)