Wrote some stuff for Kari's core (ie kari.dll) that marshalls CLI types to Kari types and vice versa.
It's got some pretty cool stuff in it that marshalls delegates over to curried Kari functions through a mess of spaghetti code involving reflection, lambdas, dynamic invocation and recursion.
To put it bluntly, it means I can do shit like this:
[cpp]
class Program
{
static string Test(decimal a, decimal b)
{
return (a + b).ToString();
}
static void Main(string[] args)
{
var runtime = new Runtime();
runtime.GlobalContext.Variables.Add("test", new MarshalledDelegate((Func<decimal, decimal, string>)Test).GetFunction());
}
}
[/cpp]
When test is called from Kari, it goes to a method in the MarshalledDelegate object that keeps returning itself until it's built up enough arguments to call the actual method. It then marshalls all the Kari values over to CLI objects, invokes the delegate, marshalls the return object back to a Kari value and returns back into Kari.
Here's that snippet above in action:
[img]http://ahb.me/wBn[/img]
This is a pretty important feature - it means I can make the Standard Library for Kari [b]significantly[/b] more DRY, and it also means those OpenGL binding aren't far away :v:
I want to write a parser for a brainfuck-like language, but brainfuck itself is too restrictive IMO.
Besides, I'm having problems figuring out how to parse loops. Maybe I should convert it to bytecode or something :P
[QUOTE=esalaka;25061780]Besides, I'm having problems figuring out how to parse loops.[/QUOTE]
Use a stack.
[QUOTE=esalaka;25061780]I want to write a parser for a brainfuck-like language, but brainfuck itself is too restrictive IMO.
Besides, I'm having problems figuring out how to parse loops. Maybe I should convert it to bytecode or something :P[/QUOTE]
Too restrictive?
And how would bytecode help?
[QUOTE=turb_;25061810]Use a stack.[/QUOTE]
Or simple recursion. Which would also use a stack (the callstack), but you don't have to manage that.
[cpp]//returns false if returning from a loop, true if eof
bool parseBrainfuck(chariter iter)
{
while(iter.valid())
{
switch(iter.get())
{
case BF_LOOPBEGIN:
++iter;
while(data[currentIndex] != 0)
if(parseBrainfuck(iter))
error();
break;
case BF_LOOPEND:
return false;
//...
}
++iter;
}
return true;
}[/cpp]
Summin' like that.
[QUOTE=ZeekyHBomb;25062226]Too restrictive?
And how would bytecode help?[/QUOTE]
Yes, brainfuck restricts me to simple I/O. Of course every calculation can be done in BF, as it's Turing-complete.
Probably not at all, the only effect would probably be that I could just parse loops into conditional jumps.
...Although I'd still have to parse them into those jumps, which involves figuring out which two []-symbols correspond, anyway.
[editline]02:45PM[/editline]
Also turb write a BF interpreter in Kari :v:
[QUOTE=esalaka;25062296]Yes, brainfuck restricts me to simple I/O. Of course every calculation can be done in BF, as it's Turing-complete.
Probably not at all, the only effect would probably be that I could just parse loops into conditional jumps.
...Although I'd still have to parse them into those jumps, which involves figuring out which two []-symbols correspond, anyway.
[editline]02:45PM[/editline]
Also turb write a BF interpreter in Kari :v:[/QUOTE]
I always keep a count of how many braces I'm inside; when I'm skipping a loop, I add one to the loop count and keep incrementing the instruction pointer - incrementing loop count for a [ and decrementing it for a ] - until the loop count is at its original value. When you enter a loop, you increment the loop count and push the position of the instruction pointer onto your stack, and then pop it again when you return to the start. When you exit the loop you just decrement the loop count and pop off the top value, so that the top value is the position of the [ belonging to the current loop.
Add another brainfuck symbol to plot pixels on a window with
Then you can do lots of fun stuff
I thought I'd try my hand at making a notepad, too (but only as a point of interest - not a serious project - of course). I'm having some significant difficulty getting the tabbing working right, though.
[cpp]
System.Drawing.Graphics g = this.CreateGraphics();
float w = g.MeasureString("a", this.Font).Width;
g.Dispose();
// Calculate the tab offsets.
int[] stops = new int[32];
for(int i = 0; i < 32; i++)
{
stops[i] = (int)(w * chars * i);
}
this.SelectionTabs = stops;
[/cpp]
Despite using a monospaced font, this doesn't produce the correct results. Supplying a 'chars' value of 4, I get output consistent with a tab width of 6.5; supplying 3 gives 4.89. Clearly for 4 I want 4 and for 3 I want 3, so why the discrepancy, and how do I fix it?
[editline]02:14AM[/editline]
Using some magic maths, it seems I need to multiply by about 2.46 to get a width of 4 characters, like I desire.
So, each character is actually 1.625 characters. I [i]love[/i] logic.
[editline]02:15AM[/editline]
I suppose it could be due to an ambiguity of font sizing? this.Font is using Pixel as it's measurement size, but I'm not sure what units the SelectionTabs array is supposed to be in. Time for bed, these mysteries can be solved at a more reasonable time!
Currently working on re-writing or better said re-creating the C++ math library focusing on trigonometric functions and such.
Does anyone think its worth it?
Writing a language sounds fun, but I absolutely hate parsing.
[QUOTE=Richy19;25066505]Currently working on re-writing or better said re-creating the C++ math library focusing on trigonometric functions and such.
Does anyone think its worth it?[/QUOTE]
Will there be any advantage of doing that? Apart from it being a learning experience
[QUOTE=Chris220;25067041]Will there be any advantage of doing that? Apart from it being a learning experience[/QUOTE]
Well im not sure how advanced the standard math library is but i hope i will be able to go more in depth with it.
As well as it would be exactly made to my needs (not that i have any at this moment)
I think we're spoilt a bit with .NET and all its in-built functions.
Back at the height of my VB6 days (3-4 years ago) I used to have a library I had to make myself with loads of useful functions in it.
[QUOTE=turb_;25053971]If we're text editor band-wagoning:
[img_thumb]http://ahb.me/wmJ[/img_thumb][/QUOTE]
How did you do your line numbering?
How about making an advanced math library that adds loads of cool, more advanced shit, instead of remaking an entire library that already exists
[editline]06:24PM[/editline]
[QUOTE=CarlBooth;25067524]I think we're spoilt a bit with .NET and all its in-built functions.
Back at the height of my VB6 days (3-4 years ago) I used to have a library I had to make myself with loads of useful functions in it.[/QUOTE]
This is why I don't like using C# as much as I like C++. C# gives you everything you need 90% of the time, it takes a lot of the fun out of it for me
Gah! My computer is completely messed up, getting CMOS errors and no video output, refusing to boot.
I can't get my console text editor now, and I don't know when I'll get access to it again :(
I guess I can still work on features in my old version, and then just stitch it together later. Still, I was really looking forward to working on it today, instead I've spent 5 hours googling for a solution to no avail.
try a linux live cd to get the editor backup
Anyone know if printing with line numbers is broken in Visual C~ 2010 Express Edition. I've tried with various settings and it just won't print any line numbers.
I've got the IDE itself showing line numbers, I've ticked the box in the print dialogue but it still isn't printing them.
Edit: Fixed, was out of colour ink and the lines where trying to print in blue :doh:
[QUOTE=Richy19;25067857]try a linux live cd to get the editor backup[/QUOTE]
That's a good idea, but it doesn't even get that far. At no point during the startup is there anything on my monitor. I believe the graphics card is fried, and I have no replacement, nor does my motherboard have a video port.
[QUOTE=Wickedgenius;25067874]Anyone know if printing with line numbers is broken in Visual C~ 2010 Express Edition. I've tried with various settings and it just won't print any line numbers.
I've got the IDE itself showing line numbers, I've ticked the box in the print dialogue but it still isn't printing them.[/QUOTE]
Printing line number into debug output or actually physically printing the code listing onto paper?
Personally I don't trust .net and will probably never use it.
[QUOTE=eXeC64;25070082]Personally I don't trust .net and will probably never use it.[/QUOTE]
Eh? Really? Why?
[QUOTE=BlkDucky;25070324]Eh? Really? Why?[/QUOTE]
I don't want my code to be dependant on a standard set by microsoft. I'm not an extremist like stallman who rejects it on principle. I just don't trust microsoft enough to use the .net library as a crutch.
[QUOTE=eXeC64;25070510]I don't want my code to be dependant on a standard set by microsoft. I'm not an extremist like stallman who rejects it on principle. I just don't trust microsoft enough to use the .net library as a crutch.[/QUOTE]
You can say that about pretty much every library, the fact a big company is backing this one is what makes it more likely to be there for a while, tried making a game engine, the GUI system and rendering both depended on a project that pretty much went dead.
[QUOTE=nekosune;25070861]You can say that about pretty much every library, the fact a big company is backing this one is what makes it more likely to be there for a while, tried making a game engine, the GUI system and rendering both depended on a project that pretty much went dead.[/QUOTE]
This. Though I don't like depending on anyone, you are forced to in someway if you want to get anything done in a reasonable manor. .NET is backed by Microsoft and Microsoft isn't a company that drops a lot of project. Even though some developers don't like it .NET is were all the "new developers" are going and therefore the inevitable future will be paved with .NET. Thats just my prophecy though.
Managed to add some of the functionality of my newest version to my old one, atleast enough so that I could add syntax highlighting
It's a little buggy though.
[IMG]http://cubeupload.com/files/7ffbe6unavngivet.png[/IMG]
[QUOTE=eXeC64;25070510]I don't want my code to be dependant on a standard set by microsoft. I'm not an extremist like stallman who rejects it on principle. I just don't trust microsoft enough to use the .net library as a crutch.[/QUOTE]
How do you depend on Microsoft when using it?
It's not like they can fuck it up or reverse it being an ECMA and ISO/IEC standard.
You'd only depend on them if something forces you to use the newest version and I think it's doubtful that MS would fuck something up that you didn't wanna upgrade.
[QUOTE=eXeC64;25070510]I don't want my code to be dependant on a standard set by microsoft. I'm not an extremist like stallman who rejects it on principle. I just don't trust microsoft enough to use the .net library as a crutch.[/QUOTE]
What's with everyone thinking you must use .NET for languages like C#? MONO
[QUOTE=ZeekyHBomb;25071623]— — I think it's doubtful that MS would fuck something up that you didn't wanna upgrade.[/QUOTE]
:raise:
[img]http://www.fortfn.co.uk/images/ue2/ue2_6.png[/img]
[img]http://www.fortfn.co.uk/images/ue2/ue2_8.png[/img]
My C++ game engine client and C# server now talk to each other! Client uses a non-blocking TCP socket (I chose TCP over UDP for a reason), server uses overlapped I/O socket (completion ports). The client pings the server and checks for slow responses, signs that the connection might have timed out. Authentication works, it checks the client's version and then a username & password before letting it send chat messages. (At the moment, I have a hard-coded guest auth but it would be simple enough to add a MySQL database to the server (which I will be doing in the future)).
Both clientside and serverside have Lua bindings, and in both cases the C++/C# program does the "dirty work" whilst Lua processes the packets and suchlike. Clientside, Lua will be responsible for loading the user interface (creating the buttons, textboxes etc) and handling user interface events (button click) but the actual rendering and input handling is handled by C++ (very much like gmod and vgui).
Now I need to tidy up some boilerplate code, comment out all the annoying debug print statements, and write some more "abuse" protection code on the server (to stop anyone from connecting and sending random data to crash the server, or no data at all to "hog" a connection slot). Then I will move the clientside connection stuff out of developer console and into a proper GUI, complete with chatbox and all.
My overall goal is to produce a basic prototype, more like a tech demo actually, where players can join and walk around a small terrain in top-down 3rd person view and chat and stuff, MMO styled. And the hard part is done.
Sorry, you need to Log In to post a reply to this thread.