Skip to content

Instantly share code, notes, and snippets.

View vadz's full-sized avatar

VZ vadz

View GitHub Profile
@vadz
vadz / wx-stats.sh
Created April 18, 2020 23:04
Get CSV stats for wx release downloads
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: $0 <x.y.z>" >&2
exit 1
fi
ver=$1
stats_file=download_stats-`date +%Y%m%d`.csv
@vadz
vadz / python_optional.i
Created March 4, 2019 13:46
Python typemaps for OptionalValue
%define DEFINE_OPTIONAL_SIMPLE(OptT, T)
// Use reference, not pointer, typemaps for member variables of this type.
%naturalvar OptionalValue< T >;
// Even though this type is not mentioned anywhere, we must still do this to
// tell SWIG to actually export this type.
%template(OptT) OptionalValue< T >;
// This typemap is used for function arguments and for setting member fields of
@vadz
vadz / java_optional.i
Created March 4, 2019 13:45
Java typemaps for OptionalValue
%define DEFINE_OPTIONAL_SIMPLE(OptT, T)
// Use reference, not pointer, typemaps for member variables of this type.
%naturalvar OptionalValue< T >;
%template(OptT) OptionalValue< T >;
// Note the use of "jboxtype" instead of just "jstype": for primitive types,
// such as "double", they're different and we must use the former as
// Optional<> can only be used with reference types in Java.
@vadz
vadz / csharp_optional.i
Last active March 4, 2019 13:47
C# typemaps for OptionalValue
// The macro arguments for all these macros are the name of the exported class
// and the C++ type T of OptionalValue<T> to generate the typemaps for.
// Common part of the macros below, shouldn't be used directly.
%define DEFINE_OPTIONAL_HELPER(OptT, T)
// The OptionalValue<> specializations themselves are only going to be used
// inside our own code, the user will deal with either T? or T, depending on
// whether T is a value or a reference type, so make them private to our own
// assembly.
@vadz
vadz / optional.i
Created March 4, 2019 13:39
Main optional.i file
%{
#include "optionalvalue.h"
%}
// Provide simplified declarations of various template classes we use for SWIG.
template <typename T>
class OptionalValue
{
public:
OptionalValue();
@vadz
vadz / gtkdpi.cpp
Created October 29, 2018 17:51
Show display sizes and DPI using various GTK+ functions
// Compile using the following command
//
// g++ -Wall -Wno-deprecated-declarations gtkdpi.cpp `pkg-config --cflags --libs gtk+-3.0`
//
// And then run ./a.out
#include <gtk/gtk.h>
static void
print_sizes_and_dpi(int w, int h, int wmm, int hmm)
{
Cloning into '.'...
10.80s user 2.47s system 1% cpu 13:00.52 total
ATTENTION: no --prefix supplied, building and installing to /tmp/tmp.o2BIF8otPY/install
No pre-existing installed file found at /tmp/tmp.o2BIF8otPY/install/bin/nqp-m
Cloning into 'nqp'...
Note: checking out '2017.09-119-g4494e7049'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
@vadz
vadz / lmi_style.md
Created March 6, 2017 14:57
Draft of lmi style guide

Coding Style Guidelines for lmi

Files

This section covers organization of the source code in files.

Don't use subdirectories

#include <wx/secretstore.h>
void DoSomethingRequiringAPassword(const wxString& username)
{
wxSecretStore store = wxSecretStore::GetDefault();
if ( !store.IsOk() ) {
// Complain about not being able to store the password securely
...
return;
}

Random Notes About SWIG Objects Attributes

Random Notes About SWIG Objects Attributes

Overview

SWIG parses all declarations in its input in an object tree. Each node of this tree is a DOHHash and developer documentation