Giter VIP home page Giter VIP logo

godot-d-verify's Introduction

Godot D Verify

Verify Godot 3 projects that use the D Programming Language

⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️

!!! WARNING !!!

This project is obsolete. It has been replaced by https://github.com/ImmersiveRPG/super-dlang-godot3-turbo-hyper-fighting-champion-edition

⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️ ⚠️

Run unit tests

dub test

Build

dub build

Run verify

godot-d-verify --project game/project/ --source game/src/

Generating GodotNativeLibrary automatically

Normally we would have to call GodotNativeLibrary and manually enter all scene classes

// entrypoint.d
import godot;
import std.stdio : writefln;

mixin GodotNativeLibrary!(
	"game",
	Door,   // Manually added
	Enemy,  // Manually added
	Fish,   // Manually added
	Global, // Manually added
	Player, // Manually added
	(GodotInitOptions o) {
		writefln("Library initialized");
	},
	(GodotTerminateOptions o) {
		writefln("Library terminated");
	}
);

Instead, we can use godot-d-verify to generate a list of scene classes

godot-d-verify --project game/project/ --source game/src/ --generate_script_list
// entrypoint.d
import godot;
import std.stdio : writefln;

import helpers : generateGodotNativeLibrary;
import generated_script_list : script_list;

mixin generateGodotNativeLibrary!(
	"game",
	script_list, // Get all the scene classes from generated_script_list.d
	(GodotInitOptions o) {
		writefln("Library initialized");
	},
	(GodotTerminateOptions o) {
		writefln("Library terminated");
	}
);
// generated_script_list.d
// This file was generated by godot-d-verify
enum string[string] script_list = [
	"door" : "Door",
	"enemy" : "Enemy",
	"fish" : "Fish",
	"global" : "Global",
	"player" : "Player",
];
// helpers.d
import godot : GodotInitOptions, GodotTerminateOptions;

// A helper function to generate the GodotNativeLibrary with the script list
template generateGodotNativeLibrary(
	string symbol_prefix,
	string[string] godot_scripts,
	void function(GodotInitOptions o) func_init = null,
	void function(GodotTerminateOptions o) func_terminate = null) {

	import std.string : format;
	import std.array : join;

	// Import all the classes
	static foreach (mod, klass ; godot_scripts) {
		mixin (`import %s : %s;`.format(mod, klass));
	}

	// Get all the classes
	enum class_list = godot_scripts.values.join(",\n");

	// Generate the GodotNativeLibrary mixin with the prefix, classes, and funcs
	enum string code =
`mixin GodotNativeLibrary!(
"%s",
%s,
(GodotInitOptions o) {
	if (func_init) func_init(o);
},
(GodotTerminateOptions o) {
	if (func_terminate) func_terminate(o);
});`.format(symbol_prefix, class_list);
	//pragma(msg, code);
	mixin (code);
}

godot-d-verify's People

Contributors

workhorsy avatar

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.