Clean up C code

This commit is contained in:
Twarit
2019-06-25 22:56:22 +05:30
parent 6c2cd289bf
commit 08a74bfb61
13 changed files with 0 additions and 271 deletions

13
.gitignore vendored
View File

@@ -1,13 +0,0 @@
*.o
*.os
*.so
*.dylib
.import
*.import
*.dblite
*.dll
*.exp
*.lib
*.obj
logs
.vscode/

3
.gitmodules vendored
View File

@@ -1,3 +0,0 @@
[submodule "godot_headers"]
path = godot_headers
url = https://github.com/GodotNativeTools/godot_headers

View File

@@ -1,79 +0,0 @@
#!python
import os, subprocess
opts = Variables([], ARGUMENTS)
# Gets the standard flags CC, CCX, etc.
env = DefaultEnvironment()
# Define our options
opts.Add(EnumVariable('target', "Compilation target", 'debug', ['d', 'debug', 'r', 'release']))
opts.Add(EnumVariable('platform', "Compilation platform", '', ['', 'windows', 'x11', 'linux', 'osx']))
opts.Add(EnumVariable('p', "Compilation target, alias for 'platform'", '', ['', 'windows', 'x11', 'linux', 'osx']))
opts.Add(BoolVariable('use_llvm', "Use the LLVM / Clang compiler", 'no'))
opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'demo/bin/'))
opts.Add(PathVariable('target_name', 'The library name.', 'libsimple', PathVariable.PathAccept))
# Local dependency paths, adapt them to your setup
godot_headers_path = "godot_headers/"
# only support 64 at this time..
bits = 64
# Updates the environment with the option variables.
opts.Update(env)
# Process some arguments
if env['use_llvm']:
env['CC'] = 'clang'
env['CXX'] = 'clang++'
if env['p'] != '':
env['platform'] = env['p']
if env['platform'] == '':
print("No valid target platform selected.")
quit();
# Check our platform specifics
if env['platform'] == "osx":
env['target_path'] += 'osx/'
if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS = ['-g','-O2', '-arch', 'x86_64'])
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
else:
env.Append(CCFLAGS = ['-g','-O3', '-arch', 'x86_64'])
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
elif env['platform'] in ('x11', 'linux'):
env['target_path'] += 'x11/'
if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS = ['-fPIC', '-g3','-Og', '-std=c++17'])
else:
env.Append(CCFLAGS = ['-fPIC', '-g','-O3', '-std=c++17'])
elif env['platform'] == "windows":
env['target_path'] += 'win64/'
# This makes sure to keep the session environment variables on windows,
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
env.Append(ENV = os.environ)
env.Append(CCFLAGS = ['-DWIN32', '-D_WIN32', '-D_WINDOWS', '-W3', '-GR', '-D_CRT_SECURE_NO_WARNINGS'])
if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '-MDd'])
else:
env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '-MD'])
# make sure our binding library is properly includes
env.Append(CPPPATH=['.', godot_headers_path])
# tweak this if you want to use different folders, or more folders, to store your source code in.
env.Append(CPPPATH=['src/'])
sources = Glob('src/*.c')
library = env.SharedLibrary(target=env['target_path'] + env['target_name'] , source=sources)
Default(library)
# Generates help for the -h scons option.
Help(opts.GenerateHelpText(env))

View File

@@ -1,18 +0,0 @@
[general]
singleton=false
load_once=true
symbol_prefix="godot_"
reloadable=true
[entry]
X11.64="res://bin/x11/libsimple.so"
Windows.64="res://bin/win64/libsimple.dll"
OSX.64="res://bin/osx/libsimple.dylib"
[dependencies]
X11.64=[ ]
Windows=[ ]
OSX.64=[ ]

View File

@@ -1,10 +0,0 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://bin/test.gdnlib" type="GDNativeLibrary" id=1]
[resource]
resource_name = "SIMPLE"
class_name = "SIMPLE"
library = ExtResource( 1 )
_sections_unfolded = [ "Resource" ]

View File

@@ -1,7 +0,0 @@
[gd_resource type="Environment" load_steps=2 format=2]
[sub_resource type="ProceduralSky" id=1]
[resource]
background_mode = 2
background_sky = SubResource( 1 )

View File

@@ -1,9 +0,0 @@
extends Control
# load the SIMPLE library
const SIMPLE = preload("res://bin/test.gdns")
onready var data = SIMPLE.new()
func _on_Button_pressed():
$Label.text = "Data = " + data.get_data()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -1,13 +0,0 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass

View File

@@ -1,24 +0,0 @@
; Engine configuration file.
; It's best edited using the editor UI and not directly,
; since the parameters that go here are not all obvious.
;
; Format:
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
_global_script_classes=[ ]
_global_script_class_icons={
}
[application]
config/name="demo"
run/main_scene="res://test.tscn"
config/icon="res://icon.png"
[rendering]
environment/default_environment="res://default_env.tres"

View File

@@ -1,3 +0,0 @@
[gd_scene format=2]
[node name="Spatial" type="Spatial"]

Submodule godot_headers deleted from 4fa11f8c2a

View File

@@ -1,91 +0,0 @@
#include <gdnative_api_struct.gen.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct user_data_struct
{
char data[256];
} user_data_struct;
const godot_gdnative_core_api_struct *api = NULL;
const godot_gdnative_ext_nativescript_api_struct *nativescript_api = NULL;
GDCALLINGCONV void *simple_constructor(godot_object *p_instance, void *p_method_data);
GDCALLINGCONV void simple_destructor(godot_object *p_instance, void *p_method_data, void *p_user_data);
godot_variant simple_get_data(godot_object *p_instance, void *p_method_data, void *p_user_data, int p_num_args, godot_variant **p_args);
void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *p_options)
{
api = p_options->api_struct;
// now find our extensions
for (int i = 0; i < api->num_extensions; i++)
{
switch (api->extensions[i]->type)
{
case GDNATIVE_EXT_NATIVESCRIPT:
{
nativescript_api = (godot_gdnative_ext_nativescript_api_struct *)api->extensions[i];
};
break;
default:
break;
};
};
}
void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *p_options)
{
api = NULL;
nativescript_api = NULL;
}
void GDN_EXPORT godot_nativescript_init(void *p_handle)
{
godot_instance_create_func create = {NULL, NULL, NULL};
create.create_func = &simple_constructor;
godot_instance_destroy_func destroy = {NULL, NULL, NULL};
destroy.destroy_func = &simple_destructor;
nativescript_api->godot_nativescript_register_class(p_handle, "SIMPLE", "Reference", create, destroy);
godot_instance_method get_data = {NULL, NULL, NULL};
get_data.method = &simple_get_data;
godot_method_attributes attributes = {GODOT_METHOD_RPC_MODE_DISABLED};
nativescript_api->godot_nativescript_register_method(p_handle, "SIMPLE", "get_data", attributes, get_data);
}
GDCALLINGCONV void *simple_constructor(godot_object *p_instance, void *p_method_data)
{
printf("SIMPLE._init()\n");
user_data_struct *user_data = api->godot_alloc(sizeof(user_data_struct));
strcpy(user_data->data, "World from GDNative!");
return user_data;
}
GDCALLINGCONV void simple_destructor(godot_object *p_instance, void *p_method_data, void *p_user_data)
{
printf("SIMPLE._byebye()\n");
api->godot_free(p_user_data);
}
godot_variant simple_get_data(godot_object *p_instance, void *p_method_data, void *p_user_data, int p_num_args, godot_variant **p_args)
{
godot_string data;
godot_variant ret;
user_data_struct *user_data = (user_data_struct *)p_user_data;
api->godot_string_new(&data);
api->godot_string_parse_utf8(&data, user_data->data);
api->godot_variant_new_string(&ret, &data);
api->godot_string_destroy(&data);
return ret;
}