Merge pull request #712 from aaronfranke/black

[master] Run black format on SConstruct files and bindings generator
pull/715/head
Rémi Verschelde 2022-02-26 23:44:54 +01:00 committed by GitHub
commit 1cbf121b08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 6 deletions

View File

@ -9,7 +9,6 @@ if sys.version_info < (3,):
def decode_utf8(x):
return x
else:
import codecs
@ -265,7 +264,7 @@ elif env["platform"] == "ios":
env.Append(CCFLAGS=["-arch", env["ios_arch"]])
env.Append(CCFLAGS=["-isysroot", sdk_path])
env.Append(LINKFLAGS=["-isysroot", sdk_path, "-F" + sdk_path,])
env.Append(LINKFLAGS=["-isysroot", sdk_path, "-F" + sdk_path])
if env["target"] == "debug":
env.Append(CCFLAGS=["-Og", "-g"])

View File

@ -623,7 +623,9 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
# Move constructor.
result.append(f"{class_name}::{class_name}({class_name} &&other) {{")
if needs_copy_instead_of_move(class_name) and copy_constructor_index >= 0:
result.append(f"\tinternal::_call_builtin_constructor(_method_bindings.constructor_{copy_constructor_index}, &opaque, &other);")
result.append(
f"\tinternal::_call_builtin_constructor(_method_bindings.constructor_{copy_constructor_index}, &opaque, &other);"
)
else:
result.append("\tstd::swap(opaque, other.opaque);")
result.append("}")
@ -741,7 +743,9 @@ def generate_builtin_class_source(builtin_api, size, used_classes, fully_used_cl
# Move assignment.
result.append(f"{class_name} &{class_name}::operator=({class_name} &&other) {{")
if needs_copy_instead_of_move(class_name) and copy_constructor_index >= 0:
result.append(f"\tinternal::_call_builtin_constructor(_method_bindings.constructor_{copy_constructor_index}, &opaque, &other);")
result.append(
f"\tinternal::_call_builtin_constructor(_method_bindings.constructor_{copy_constructor_index}, &opaque, &other);"
)
else:
result.append("\tstd::swap(opaque, other.opaque);")
result.append("\treturn *this;")
@ -1626,6 +1630,7 @@ def is_packed_array(type_name):
"PackedVector3Array",
]
def needs_copy_instead_of_move(type_name):
"""
Those are types which need initialised data or we'll get warning spam so need a copy instead of move.
@ -1634,6 +1639,7 @@ def needs_copy_instead_of_move(type_name):
"Dictionary",
]
def is_enum(type_name):
return type_name.startswith("enum::")

View File

@ -17,8 +17,18 @@ env.Append(CPPPATH=["src/"])
sources = Glob("src/*.cpp")
if env["platform"] == "osx":
library = env.SharedLibrary("demo/bin/libgdexample.{}.{}.framework/libgdexample.{}.{}".format(env["platform"], env["target"], env["platform"], env["target"]), source=sources)
library = env.SharedLibrary(
"demo/bin/libgdexample.{}.{}.framework/libgdexample.{}.{}".format(
env["platform"], env["target"], env["platform"], env["target"]
),
source=sources,
)
else:
library = env.SharedLibrary("demo/bin/libgdexample.{}.{}.{}{}".format(env["platform"], env["target"], env["arch_suffix"], env["SHLIBSUFFIX"]), source=sources)
library = env.SharedLibrary(
"demo/bin/libgdexample.{}.{}.{}{}".format(
env["platform"], env["target"], env["arch_suffix"], env["SHLIBSUFFIX"]
),
source=sources,
)
Default(library)