Add .clang-format

This commit is contained in:
Fabien Freling 2019-07-16 13:31:07 +02:00
parent 90526946e6
commit 20041deef5
6 changed files with 158 additions and 143 deletions

6
src/qt/.clang-format Normal file
View file

@ -0,0 +1,6 @@
---
BasedOnStyle: Mozilla
IndentWidth: 4
TabWidth: 4
ColumnLimit: 100
UseTab: ForIndentation

View file

@ -8,7 +8,8 @@
#include <caml/callback.h> #include <caml/callback.h>
int main(int argc, char *argv[]) int
main(int argc, char* argv[])
{ {
QCoreApplication::setApplicationName("OBoy"); QCoreApplication::setApplicationName("OBoy");
QCoreApplication::setOrganizationName("ffreling"); QCoreApplication::setOrganizationName("ffreling");

View file

@ -4,15 +4,16 @@
#include <QUrl> #include <QUrl>
#include <QtGlobal> #include <QtGlobal>
#include <caml/mlvalues.h>
#include <caml/callback.h>
#include <caml/alloc.h> #include <caml/alloc.h>
#include <caml/bigarray.h> #include <caml/bigarray.h>
#include <caml/callback.h>
#include <caml/memory.h> #include <caml/memory.h>
#include <caml/misc.h> #include <caml/misc.h>
#include <caml/mlvalues.h>
#include <caml/osdeps.h> #include <caml/osdeps.h>
OBoy::OBoy(QObject *parent) : QObject(parent) OBoy::OBoy(QObject* parent)
: QObject(parent)
{ {
const QStringList args = QCoreApplication::arguments(); const QStringList args = QCoreApplication::arguments();
if (args.size() > 1) { if (args.size() > 1) {
@ -21,7 +22,9 @@ OBoy::OBoy(QObject *parent) : QObject(parent)
} }
} }
value *fetch_caml_callback(const char *name) { value*
fetch_caml_callback(const char* name)
{
value* closure_f = caml_named_value(name); value* closure_f = caml_named_value(name);
if (closure_f == nullptr) { if (closure_f == nullptr) {
qFatal("Cannot find OCaml function: %s", name); qFatal("Cannot find OCaml function: %s", name);
@ -32,7 +35,8 @@ value *fetch_caml_callback(const char *name) {
// https://caml.inria.fr/pub/docs/manual-ocaml/intfc.html // https://caml.inria.fr/pub/docs/manual-ocaml/intfc.html
// http://www.mega-nerd.com/erikd/Blog/CodeHacking/Ocaml/calling_ocaml.html // http://www.mega-nerd.com/erikd/Blog/CodeHacking/Ocaml/calling_ocaml.html
QString OBoy::name() const QString
OBoy::name() const
{ {
CAMLparam0(); CAMLparam0();
@ -47,7 +51,8 @@ QString OBoy::name() const
return QString(str); return QString(str);
} }
QString OBoy::version() const QString
OBoy::version() const
{ {
CAMLparam0(); CAMLparam0();
@ -62,7 +67,9 @@ QString OBoy::version() const
return QString(str); return QString(str);
} }
bool OBoy::load(const QUrl &path) { bool
OBoy::load(const QUrl& path)
{
CAMLparam0(); CAMLparam0();
CAMLlocal1(ocaml_path); CAMLlocal1(ocaml_path);
@ -83,12 +90,14 @@ bool OBoy::load(const QUrl &path) {
return _loaded; return _loaded;
} }
bool OBoy::loaded() const bool
OBoy::loaded() const
{ {
return _loaded; return _loaded;
} }
QImage OBoy::backgroundMap(int index) const QImage
OBoy::backgroundMap(int index) const
{ {
CAMLparam0(); CAMLparam0();
CAMLlocal1(ocaml_index); CAMLlocal1(ocaml_index);

View file

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <QObject>
#include <QImage> #include <QImage>
#include <QObject>
#include <QString> #include <QString>
class OBoy : public QObject class OBoy : public QObject

View file

@ -4,11 +4,10 @@
OImageProvider::OImageProvider(QQmlApplicationEngine& engine) OImageProvider::OImageProvider(QQmlApplicationEngine& engine)
: QQuickImageProvider(QQuickImageProvider::Image) : QQuickImageProvider(QQuickImageProvider::Image)
, _engine(engine) , _engine(engine)
{ {}
} QImage
OImageProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize)
QImage OImageProvider::requestImage(const QString &id, QSize *size, const QSize &requestedSize)
{ {
QList<QObject*> roots = _engine.rootObjects(); QList<QObject*> roots = _engine.rootObjects();
OBoy* oboy = roots[0]->findChild<OBoy*>("qml_oboy"); OBoy* oboy = roots[0]->findChild<OBoy*>("qml_oboy");