Forum Replies Created
-
AuthorPosts
-
September 19, 2016 at 9:03 am in reply to: you can't have a field in an extend of 'external extends void' #4020
Just passing canvas as a plain parameter would be the safest/cleanest if this is possible.
It’s kind of hard to suggest the best approach without knowing more about your code – if you’ve got something that works probably best to just stick with it for now until you have more to show/share.
September 19, 2016 at 3:59 am in reply to: you can't have a field in an extend of 'external extends void' #4014My aim is to pass the canvas passed to OnRender to my box2D debugdraw.
The safest way would be to pass it as a parameter if possible.
Failing that, a canvas ptr will work as long as you stick the canvas somewhere the gc can see it, eg: in a monkey2 global. Then, c++ code can safely use the pointer as long as you don’t modify the global, as the gc will be keeping the global alive. If that’s what you’re doing, it’s not a bad solution.
The OnRender canvas will indeed probably ‘survive’ at least one pass through OnRender without you having to do anything tricky (right now it’ll probably survive for as long as the window) but I can’t guarantee that’ll be true forever.
September 18, 2016 at 11:59 pm in reply to: how to get an extern class that extends bbObject and not void? #4012The c++ class must actually extend bbObject, eg:
Monkey12345678910111213141516171819#ifndef EXTERNAL_H#define EXTERNAL_H#include <bbmonkey.h>class Foo : public bbObject{private:int prv;public:Foo(){prv=0;}//virtual ~Foo() {} // Ensures to invoke actual object destructorvoid Set(int i) {prv=i;}int Get() { return prv; }int MyM(int i) {return prv*i;}};Have you got a small test program for the Linq stuff?
September 18, 2016 at 8:31 pm in reply to: you can't have a field in an extend of 'external extends void' #4008I’ll fix the compiler error, but the main problem here is you shouldn’t really store GCable objects (like MiniFoo) in non-GCable objects (like Foo or any subclass) as Foo’s fields will not be garbage collected (since Foo isn’t) and MiniFoo will eventually be GCd unless you have somehow made sure it’s kept alive elsewhere. I think this should be prohibited altogether.
Using a Ptr – or even a Ptr to a struct that contains a MiniFoo – wont help because MiniFoo still wont be found by the GC.
If you really need to do this, the safest way is probably via an int handle, and an IntMap<MiniFoo> somewhere that assocates handles with objects.
The module builds but I’m getting pretty much empty .cpp source files in my windows_debug folder and if I try to use any of the extension methods I get “undefined reference” errors.
Are you using the latest mx2cc? Extensions are undergoing ongoing maintenance…
If you are, can you reproduce with a simple example?
I’ve made a pretty good start on tinyxml2, but the more the merrier! Wish people would staring using that module manager thingy though…
Anyway, I’m more of a JSON guy myself, but is this pretty much what you need from an xml module?
Monkey123456789101112131415161718192021222324252627282930313233343536Function Dump( node:XMLNode,indent:String )Print indent+node.Value()Local child:=node.FirstChild()While childDump( child,indent+" " )child=child.NextSibling()WendEndFunction Main()Local xml:=LoadString( "asset::dream.xml" )Local doc:=New XMLDocumentIf doc.Parse( xml )<>XMLError.XML_SUCCESSPrint "Failed to parse"ReturnEndifPrint "Parsed!"Dump( doc,"" )doc.Destroy()Print "Bye!"End…which produces…
Monkey12345678910111213141516171819202122232425xml version="1.0"DOCTYPE PLAY SYSTEM "play.dtd"PLAYTITLEA Midsummer Night's DreamFMPText placed in the public domain by Moby Lexical Tools, 1992.PSGML markup by Jon Bosak, 1992-1994.PXML version by Jon Bosak, 1996-1998.PThis work may be freely copied and distributed worldwide.PERSONAETITLEDramatis PersonaePERSONATHESEUS, Duke of Athens.PERSONAEGEUS, father to Hermia.PGROUPPERSONA...etc...tinyxml2 looks very tidy…
http://www.grinninglizard.com/tinyxml2/
The mx2 API would probably look something like:
Monkey12345678910111213141516171819202122232425262728293031323334353637Class XMLNodeMethod GetDocument:XMLDocument()Method NoChildren:Bool()Method Parent:XMLNode()Method FirstChild:XMLNode()Method NextSibling:XMLNode()Method Value:String()EndClass XMLDocument Extends XMLNodeEndClass XMLComment Extends XMLNodeEndClass XMLElement Extends XMLNodeEndClass XMLDeclaration Extends XMLNodeEndClass XMLText Extends XMLNodeEndClass XMLUnknown Extends XMLNodeEndFunction LoadXMLDocument:XMLDocument( path:String )EndThere’s more methods, but that’s the jist of it, just yer basic tree. Is that the sort of thing you’re after?
Just commited the ‘official’ std.socket.Socket and std.socket.SockerServer classes.
Very similar to Si’s work except:
- Only Read( ptr,count) and Write( ptr,count ) IO supported for now. Socket extends Stream so the intent is to add ReadString/WriteString etc to Stream.
- If called from a fiber, socket ops including connect, listen, accept, close, read and write are performed on a thread while the fiber suspends itself, ie: they wont lockup the gui. Lots of room for improvement in the implementation here (and there are vsync issues), but it makes client/server stuff about 10000 easier to write than in mx1 (see new echoserver banana).
- Only ‘stream’ sockets for now. Connection oriented datagrams should be very easy to add, connection-less will require more work, but are these even used any more? I think something WebSocket-ish (ie: a message/reply based protocol) should be next up!
- Should be completely ipv6 friendly.
Basically, it’s a WIP first attempt. The ‘new’ ipv6 friendly way to do sockets is much nicer to work with though.
ipv6 socket support for mx1 has just reared it’s ugly head again, so I think I’ll get stuck into this right now!
It’s working here as long as I ‘./updatemx2cc.sh’ and ‘./rebuildall.sh’ after that.
Perhaps best to wait until the next binaries update – I’ll do one today.
…also running OS X El Capitan 10.11.6
Just did a clean install from github-master.zip and it works fine as long as I do ‘./updatemx2cc.sh’.
However, the error message I get when it does crap out is slightly different, so perhaps it’s a compiler version problem. Here’s my g++ –version info:
Monkey123456Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1Apple LLVM version 7.3.0 (clang-703.0.31)Target: x86_64-apple-darwin15.6.0Thread model: posixInstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/binPlease post yours.
The error I get is:
Monkey1/Users/marksibly/Desktop/MissionPatrol/MissionPatrol.buildv1.0.5/macos_debug/src/MissionPatrol_game_2levels.cpp:95:44: error: use of undeclared identifier 't_default_EntityState'> so it could probably be with my computer only.
It’s incredibly unlikely to be that.
What’s probably happened is that the version I committed wasn’t working 100%, while the version here on my machine is. Unfortunately, I wont be commiting the latest just yet as there are lots of changes that need testing first.
So don’t panic, we’ll get it sorted soon!
Fixed! Needs more testing but I think it’s doable – take that c#!
-
AuthorPosts