Anteru's blog
  • Consulting
  • Research
    • Assisted environment probe placement
    • Assisted texture assignment
    • Edge-Friend: Fast and Deterministic Catmull-Clark Subdivision Surfaces
    • Error Metrics for Smart Image Refinement
    • High-Quality Shadows for Streaming Terrain Rendering
    • Hybrid Sample-based Surface Rendering
    • Interactive rendering of Giga-Particle Fluid Simulations
    • Quantitative Analysis of Voxel Raytracing Acceleration Structures
    • Real-time Hybrid Hair Rendering
    • Real-Time Procedural Generation with GPU Work Graphs
    • Scalable rendering for very large meshes
    • Spatiotemporal Variance-Guided Filtering for Motion Blur
    • Subpixel Reconstruction Antialiasing
    • Tiled light trees
    • Towards Practical Meshlet Compression
  • About
  • Archive

Thoughts on scripting

January 31, 2006
  • Programming
approximately 2 minutes to read

I mentioned script-driven classes, without going into detail what I mean with this. Read on for some thoughts on scripting. Note that nothing of this has been implemented, and it is mostly just ideas that I carry around without having time to implement them properly.

The script side

The scripts would run in some kind of ScriptVM, probably a stack-based machine. Calling script code from C++ would invoke populating the stack with the appropriate parameters, and invoking a script method. The script method names and their parameters would be stored in some global array inside the ScriptVM. When a script is called, the ScriptVM processes each of the compiled opcodes and operates on the script stack only. If another scipt function is invoked from a script, the operation would be the same as if it was called from C++.

Host->Script

The simpler side. Calling scripts would mean: The user knows what variables the script expects and what function. With a script function void func (int, int):

ScriptVM->stack->push<int> (param1);
ScriptVM->stack->push<int> (param2);
ScriptVM->invoke("MyPackage.MyClass","func");

Script->Host

This way is more difficult. A possible solution is that when a C++ class is made scriptable, a new wrapper class is generated. For example, assume we have a C++ call void func(int,int);. The wrapper would look like this this:

extern "C" void scr_func (Stack& stack) 
{
    int p1 = stack->pop();
    int p2 = stack->pop();
    func (p1, p2);
}

So much for now, maybe I get some prototype working, then you’ll get more ideas.

Previous post
Next post

Recent posts

  • Data formats: Why CSV and JSON aren't the best
    Posted on 2024-12-29
  • Replacing cron with systemd-timers
    Posted on 2024-04-21
  • Open Source Maintenance
    Posted on 2024-04-02
  • Angular, Caddy, Gunicorn and Django
    Posted on 2023-10-21
  • Effective meetings
    Posted on 2022-09-12
  • Older posts

Find me on the web

  • GitHub
  • GPU database
  • Projects

Follow me

Anteru NIV_Anteru
Contents © 2005-2025
Anteru
Imprint/Impressum
Privacy policy/Datenschutz
Made with Liara
Last updated February 20, 2019