Skip to content

Instantly share code, notes, and snippets.

@aranega
aranega / catsoo.md
Last active April 6, 2017 07:55
CatsooLang documentation

CatsooLang Documentation (under construction...)

What is CatsooLang?

CatsooLang is a little Domain Specific Langage (DSL) that allows you to handle models in a textual programming way into http://www.genmymodel.com. You can handle very low level feature of your model. CatsooLang interpreter is evaluated on the client side only, there is no intensive communication with server (there is some, we will come back on this later). Here is some details about the language:

  • dynamic typed,
  • adhoc polymorphic (function overloading) and type constraints/bounds,
#import 'https://gist.githubusercontent.com/aranega/03ca7cf65c879e3bf4f3/raw/refact.catsoo'
def _logwrap(o : Object, s : String)
{
log(s);
}
def metrics()
{
var elems := model objects();
@aranega
aranega / PHP-part1
Created March 19, 2015 14:18
PHP Generator samples for "Build your own PHP" articles (http://blog.genmymodel.com)
[module PHP('http://www.eclipse.org/uml2/4.0.0/UML')/]
[template public generate(c : Class)]
[comment @main/]
[file (c.name + '.php', false, 'UTF-8')]
<?php
[if (c.generalization->notEmpty())]require_once("[c.generalization.general.name/].php");[/if]
[for (s : String | c.interfaceRealization.contract.name)]
require_once("[s/].php");
[/for]
@aranega
aranega / uml2python.mtl
Last active October 31, 2022 10:13
UML to Python Generator written in Acceleo
[**
*
* -=( Python Code Generator )=-
*
* This script will generate one file per packages.
* It also support following things:
* - classes/interfaces (as classes)/enumerations
* - inheritance/interface realization (as inheritance)
* - attributes/associations
* + cardinility {x...*} -> generated as list
@aranega
aranega / geppetto_pyecore_demo.py
Last active January 14, 2017 14:00
Demo of loading the Geppetto metamodel and models, modication and XMI serialization using PyEcore
# Ecore core and PyEcore runtime core
import pyecore.ecore as Ecore
# global_registry for metamodels registration
from pyecore.resources import global_registry
# Resource for load/save data, URI for file location model/metamodel
# ResourceSet to create a resource container and isolate the loaded metamodel
from pyecore.resources import ResourceSet, Resource, URI
@aranega
aranega / rds2doc.mtl
Created October 21, 2017 15:10
Sample RDS to Documentation Acceleo Generator
[module rds2doc('http://com.genmymodel.rds.core/1.0')/]
[template public generate(d : Database)]
[comment @main/]
[file (d.name + '.txt', false, 'UTF-8')]
= [d.name/] Database Documentation
[d.getDoc()/]
[d.elements.generate()/]
@aranega
aranega / gmf-notation-pyecore.md
Last active May 3, 2024 02:05
This little guide show how to generate the Python/PyEcore code for the GMF Notation metamodel using pyecoregen

GMF Notation Model for Python

This little tutorial shows "in depth" how to generate Python/PyEcore code for the GMF-Notation metamodel using pyecoregen.

Generating the Metamodel Code

First, due to some dependencies expressed in the GMF Notation .ecore (relative paths towards other .ecore), it is required to have the full GMF Notation

from pyecore.resources import ResourceSet
import pyecore.ecore as ecore
import multigen
from pyecoregen.ecore import EcoreTask
class RenameTask(EcoreTask):
template_name = 'update_name.py.tpl'
element_type = ecore.EPackage
@aranega
aranega / validator.py
Created May 19, 2019 16:20
A WIP about model validation for PyEcore
from pyecore.ecore import *
from pyecore.resources import ResourceSet
from pyecore.utils import dispatch
from enum import unique, Enum
from functools import wraps
import pyecore.ecore as ecore
from collections import namedtuple
@aranega
aranega / tsuite.h
Created August 22, 2019 07:19
Simple macros to reduce boilerplate code for the "check" framework
#include <check.h>
#include <stdarg.h>
void add2tsuite(TCase *, int, ...);
#define ADD2TSUITE(s, ...) add2tsuite(s, sizeof((TFun []) {__VA_ARGS__}) / sizeof(TFun), __VA_ARGS__)
void add2tsuite(TCase * core, int n, ...) {
int i;
va_list va;
va_start(va, n);