Forum Replies Created
-
AuthorPosts
-
Sorry about that, docs are kind of ‘mid-overhaul’.
The links in the tree should work, but the links in the actual pages don’t. Fixing now…
Incidentally, what do you think of the font size – too small? Looks good here but I have a 27″ monitor so I’m not sure…
I have never had any problems with menu->Quit in Ted2 so I have no idea what’s up there.
To be absolutely clear: You are selecting Quit from the Ted2 file menu and nothing happens?
I mainly added Cmd-Q so that users can quit their own apps in fullscreen (it can be tricky otherwise on Mac) but the latest change shouldn’t really affect Ted2 behaviour, which here at least has never been broken.
You could try adding a DebugStop() to fileactions->OnQuit to see if it gets that far or if something else is eating the Cmd-Q key.
Anyone else having problems with File->Quit on the Mac?
What version MacOS are you on?
pressing Tab on multiline selection, doesn’t indent the last line in the selection.
Will fix this in TextView. Just checked and notepad++ does it and that’s what I’m using as a guide for ‘normal’ editor behaviour these days.
My bad, try latest master!
Oops, forgot to add these. Try latest master.
The module doesn’t actually use chipmunk_extern.monkey2 any more, it’s really just there for reference.
I’ve manually copied bits from this into body.monkey2, shape.monkey2 etc, so it’s possible I’ve missed more.
Thanks, can reproduce and there’s a fix on the way.
Ok, major overhaul of chipmunk now up.
cpSpace, cpBody etc. are now ‘extends void’ objects so you don’t need use ‘Ptr’ with them anymore. You still need to use cp ‘new’ functions to create them though, eg: cpSpaceNew().
Callbacks for debug draw and collision handlers are now ‘proper’ mx2 function pointers, ie: you can use functions, methods or lambdas with them. Note that other callbacks are still plain ‘C’ function pointers so they need to be used with global functions or you’ll get a ‘null function’ error when they’re invoked. These may or may not be converted over too depending on demand and whether it’s even possible (the function type really needs a ‘userdata’ pointer for mx2 to hook into). There is also some overhead involved in using mx2 function pointers in terms of GC, so that needs to be taken into consideration too.
I also added a bunch of ‘extension properties’ to most types too, so you can now go…
space.Gravity=cv( 0,100 )
…instead of…
cpSpaceSetGravity( space,cv( 0,100 ) )
…but either way will work.
I’m very happy with this as it’s pretty much zero overhead (except for function pointer glue code) so should be nice and fast, yet it still looks mx2-ish.
I dealt with the ‘const*’ issue inside the function pointer glue code, and I think in general glue code is probably the sanest way to deal with type system problems like this. A bit tedious, but glue code offers full flexibility.
Maybe c2mx2 will be able to help with writing glue code one day, but in this case at least (where the function pointer was actually a struct field) it was a little more complex than I could imagine doing via c2mx2 so doing it by hand was really the only option. But it wasn’t a big deal, and I expect all modules produced by c2mx2 will require some amount of tweaking.
Not for a while yet.
> I’ll give the above samples a try.
The above code for iterating through a container is a bit wrong – here’a another example that also removes items as it goes:
Monkey123456Local it:= My_List.All()While Not it.AtEndLocal item:=it.CurrentIf item.dead it.Erase() Else it.Bump()WendNote that you can replace List with Stack or Deque and it will look/work the same way.
I don’t see that as much of a stunt as its all part of List’s public functionality.
But it does depend on undocumented behaviour, eg: it assumes a node can still safely be used after it’s been removed from a list, and also that the ‘head’ node has a null value so you know when you’ve reached the end of list. This is what I mean by ‘stunt’ programming – relying on undocumented implementation details. There is a correct (ie: documented) way to do what you want (see above) so IMO it makes sense to use it.
In fact, your code *does* break here on the latest version, as I cleaned up node remove so that the node could still be inserted elsewhere safely, but I think I’ll give up on try to make a ‘clean’ list class and just concentrate on trying to duplicate bmx’s/monkey1’s quirks instead!
Think it’s also time to add RemoveIf() too!
Does that even work? Isn’t link.Succ null after the Remove()?
Weirdly, I have grown to really dislike ‘stunt’ list processing!
And of course, List.Clear() is fastest…
Will these come for Monkey 1 as well.
Nope.
So no chance to use the Java libraries anymore for Android?
The plan is to write a little ‘interpreter’ on the java side using reflection so you can execute java code from c++ simply by going JavaExec( “blah” ) or something, but this is some time off yet.
>Your code on the first post works fine as is
The code as posted doesn’t compile, and ‘fixing’ it still leaves you with an empty list! I had to add an item to break it.
It should also be mentioned that peterigz’s solution is faster – List.Remove() needs to find the item’s node using a linear search, while it.Remove() can just remove the node directly.
People have requested support for this every now and then, and it since it’s a ‘one file wonder’ it seemed like a good candidate for c2mx2 experiments!
I wont be changing this – there’s just no easy way to guarantee you’re not completely messing up a list by removing stuff will you’re iterating through it, and I’m sure there’s a fair few ‘sneaky’ bugs out there due to this.
It showed up fine in the debugger for me, I just had to click on the first non-module function in the debug view.
Here’s a super-duper fast way to remove stuff while iterating through a stack:
Monkey1234567Local put:=0For local item:=Eachin stackIf item.ShouldBeRemoved continuestack[put]=itemput+=1Nextstack.Resize( put )Mark. in the latest build you have completely removed ReadCString and WriteCString
Oops, meant to restore these sorry. Will do so soon.
-
AuthorPosts