Coder Social home page Coder Social logo

riicchhaarrd / cgsc Goto Github PK

View Code? Open in Web Editor NEW
40.0 8.0 7.0 1022 KB

embeddable (game) scripting language in C

Home Page: https://r1chard.nl/gsc

License: MIT License

Shell 0.67% C 98.45% C++ 0.88%
c scripting-language embeddable library yield coroutines mit-license

cgsc's Introduction

hi

cgsc's People

Contributors

kungfooman avatar riicchhaarrd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cgsc's Issues

ffi malloc small size issue

probably due to handling sizes smaller than 0xff differently in asm

#pragma comment(lib, "msvcrt.dll")
main()
{
	for(i=0;i<2000;i++)
	{
		p=malloc(i);
		if(p==0)
		{
			printf("p=0 at %\n",i);
		}
		free(p);
	}
}

self waittill / memory access out of bounds

task()
{
    self waittill("begin counting");
    printf("self = %\n", self);
}

main()
{
    o = spawnstruct();
    o thread task();
    wait 1;
    o notify("begin counting");
    printf("notifying\n");
}

This script fails with:

image

Save/Load Bytecode?

Possible?

I want to be able to compile some sources, bind the byte code to a runner and that runner will check on startup if there a "payload" attached (as a win32 resource), load back in and then execute it.

I looked over the src and example scripts, am I right in assuming

#include <file>

is the only way to include modules of code in script?

[script]
#include <module1>
#include <module2>
#include <module3>

game_startup() {
}

game_shutdown() {
}

game_update(deltaTime) {
}

game_render() {
}

game_show() {
}

main {
  ...
}

my gamelib will load the main script file, it needs to then load in all the different parts that make up the game script code, I can then compile and save out the bytecode to the runner is what I'm going for. On execution, the lib will then call into the game_xxx functions as needed.

The ability to

#pragma comment(lib, "gamelib.dll") 

is so sweet and the thread support, ahh marvelous. How does gsc compare to LuaJit in terms of performance. My current gamelib is using LuaJit and I'm looking to switch to gsc.

Thanks

Jarrod

Examples don't work

There are (currently) three examples:

  • hello_world.osc
    • This works fine.
  • write_file_stuff.osc
    • This fails because it tries to call the built-in function fclose which isn't setup in src_defaultlib.c.
    • Commenting out the calls to fclose() allows it to run.
  • color_circles.osc
    • This tries to call the function rand() which isn't defined in src_defaultlib.c.

    • Changing the calls to rand() to read randomint() allos it to get further.

    • But even with that we see failures:

      deagol ~/cidscropt $ ./bin/cidscropt examples/color_circles.osc
      variable 'vid_width' does not exist!
      BLOCK=1,curpos=832,at=895

Shuffling the variables around so each is defined in the functions eventually allows it to run, but nothing useful happens:

  deagol ~/cidscropt $ ./bin/cidscropt examples/color_circles.osc
  built-in function 'set_pixel' does not exist! (0)
  Segmentation fault

It looks like variables defined inside functions aren't accessible outside that function, which is is what you'd expect from a C-like function. This is demonstrated by this example:

 function bar()
 {
    global = 3
    print("Global set to " + global + "\n" );
 }

 main() {
    bar()
     //   print("Global is now dead: " + global + "\n")
 }

Uncomment the second print and you see a failure - and this is exactly how the code in the color_circles example is setup - specifically you'll see the function rand_col() defined variables, and the vid_size, etc, variables in main aren't available in clear_screen().

In short it would be nice if the examples all worked :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.