Interesting.
I saw a cpp file under Emerald Browser, which contains Python-looking
brace-less indented code (must be C += 2):
// Copyright 2021 Gregory Coreutils
// Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
// 1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
// 3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define MULTIPANE false
#define TRANSPARENT false
#include <QApplication>
#include <QSplitter>
#include <QMainWindow>
#include <QWebEngineView>
#include <QWebEngineSettings>
#include <QNetworkProxyFactory>
#include <QUrl>
#include "qtermwidget.h"
#include <QStyleFactory>
#include <QScreen>
#include <QVBoxLayout>
#include <unistd.h>
#define findC(a) get_window()->findChildren<a*>()
#define findQTermWidgets findC(QTermWidget)
#define findQWebEngineViews findC(QWebEngineView)
#define FOO QList<int>()
auto get_window()
static QSplitter* s = nullptr
if s == nullptr
s = new QSplitter(nullptr)
return s
//#include <unistd.h>
auto get_acwin(QWidget* w)
(void)w
static QMainWindow* s = nullptr
if s == nullptr
s = new QMainWindow
// return
// e
return s
// if a == nullptr
// return
void bg()
puts("BG")
a decl std::string("")
unlink("/tmp/emerald-browser-fifo")
result decl system("mkfifo /tmp/emerald-browser-fifo 2>/dev/null")
b decl std::string("/tmp/emerald-browser-fifo")
// emfifo")
//c decl a
while true
a < b
std::cout << std::quoted(a) << std::endl
old_str decl QString(a.c_str())
old_list decl old_str.split("\n")
// for auto i : get_window()->children()
// static_cast<QWidget*>(i)->resize(QGuiApplication::primaryScreen()->size().width(),
50)
//i.resize(i->ge, 0)
//std::cout << i << std::endl;
for auto i : old_list
// empty decl i.isEmpty()
empty decl i.isEmpty()
if empty
continue;
// continue;
if i == "close"
delete get_window()
exit(0)
qDebug() << i << i.right(i.length() - 5) << "!!!"
if QMetaObject::invokeMethod(get_window(), "objectNameChanged",
Qt::QueuedConnection, Q_ARG(const QString&, i.right(i.length()-5)))
== false
puts("Error")
void add_window(const QString& website)
viewptr decl new QWebEngineView
view decl& (*viewptr)
view.resize(QGuiApplication::primaryScreen()->size().width(), 800)
for auto i : findQWebEngineViews
if !MULTIPANE
delete i
// i->destroy()
// a = findQWebEngineViews
views decl findQWebEngineViews
new_list decl FOO
views_size decl views.size()
for (int i = 0; i < views_size; ++i)
new_list append 0
//get_window()->setSizes(views )
get_window()->setSizes(new_list)
get_window()->addWidget(viewptr)
// qDebug() << website;
// qDebug() << website;
view.load(QUrl(website))
//a = a
// se
a decl view.settings()
a->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, true)
//::D , true)
a->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, false)
//a.setAttribute(QWebEngineSettings::PlaybackRequiresUserGestur, false)
a->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled, true)
a->setAttribute(QWebEngineSettings::FullScreenSupportEnabled , true)
a->setAttribute(QWebEngineSettings::ScrollAnimatorEnabled , true)
f decl get_window()->font()
f setPointSize 20
view setFont f
// viewptr->setHeight(450)
viewptr->show()
//get_window()->showFullScreen()
//get_window()
//get_window()->get_full
void signal_(const QString& a)
for (int i = 0; i < 2; ++i)
qDebug() << a << '\n'
add_window(a)
main
QApplication a(argc, argv)
//QNetworkProxyFactory::setUseSystemConfiguration(false);
QApplication::setStyle("gtk2");// num_terms decl
//window_ decl new QMainWindow
layoutptr decl get_window()
layout decl& (*layoutptr)
QObject::connect( layoutptr, &QObject::objectNameChanged,
signal_ );
//window_ setContentsMargins 0, 0, 0, 0)
//get_window()->setObjectName(QString("foo"))
layout setOrientation(Qt::Vertical)
n decl (argc==1 ? 1 : atoi(argv[1]))
for (int i = 0; i <n; ++i)
consoleptr decl new QTermWidget
console decl& (*consoleptr)
qDebug() << " availableColorSchemes:" << console.availableColorSchemes()
console.setColorScheme("GreenOnWhite");
// console.setTerminalOpacity(0.7)
//setTerminalOpacity(0.8)
//console.setTOpacity(80)
//font decl QApplication::font()
//console setColor "black"
//font setFamily "Monospace"
//font setPointSize 8
//console setTerminalFont font
layout addWidget consoleptr
if i == 0
get_acwin(nullptr)->setCentralWidget(layoutptr)
if TRANSPARENT
get_acwin(nullptr)->setAttribute(Qt::WA_TranslucentBackground);
//
//get_window()->setCentralWidget
size decl QGuiApplication::primaryScreen()->size()
// rec decl QApplication::desktop()->screenGeometry()
height decl size.height()
width decl size.width()
//acwin decl new QVBoxLayout(get_acwin(nullptr))
// layout.setLayout(acwin)
// get_acwin(nullptr)->setSpacing(0)
// get_acwin(nullptr)->setMargin(0)
//get_acwin->addWidget(layoutptr)
//get_acwin(acwin)
get_acwin(nullptr)->resize(width, height)
//get_acwin(nullptr)->setCentralWidget(get_window())
get_acwin(nullptr)->showFullScreen()
//layout.s
styles decl QStyleFactory::keys()
styles
qDebug() << i
// bg()
bg &
return a.exec()
I looked through g+ next. It is indeed written in Ruby and processes
that C += 2 into something else.
I'm not a C++ dude, so C += 2 is lost on me, but it's cool to learn
such a thing exists.
Andy
···
On Thu, Oct 21, 2021 at 10:04 AM Gregory Cohen <gregorycohen2@gmail.com> wrote:
OK
So, it's not that big.
The transpiler is just 600 lines.
But it uses regular expressions a lot.
Look in "g+" for regular expression conversions.
And look at the source for emerald browser
It reads a fifo just using the languages syntax for reading files (like bash)
One feature it lacks, is that it doesn't support classes, namespaces or structs
However #defines and #includes work, so you can include any C or C++ code you want.
I ran rubocop for g+ recently.
The syntax of g+, is just like g++, but you "save time", lol, when you omit a "+"
g+ -Wall -Wextra -O3 -s foo.cpp -o foo
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
--
Andy Maleh
LinkedIn: Andy Maleh - Lexop | LinkedIn
Blog: http://andymaleh.blogspot.com
GitHub: http://www.github.com/AndyObtiva