Skip to content

Instantly share code, notes, and snippets.

View aranega's full-sized avatar
🥑

Vincent Aranega aranega

🥑
View GitHub Profile
@aranega
aranega / plantumlgen.py
Last active August 12, 2023 06:07
Quick ecore to plantuml generator in Python using PyEcore
from pyecore.resources import ResourceSet
from pyecore.utils import dispatch
import pyecore.ecore as ecore
class PlantUMLSwitch(object):
def __init__(self):
self.visited = set()
@dispatch
@aranega
aranega / microreflexivekernel.py
Last active April 30, 2021 09:24
Micro reflexive MDE-like kernel in Python
class MList(object):
def __init__(self, owner, feature):
self.innerlist = []
self.owner = owner
self.feature = feature
def size(self):
return len(self.innerlist)
def append(self, value, update_opposite=True):
@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);
@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
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 / gmf-notation-pyecore.md
Last active February 9, 2018 15:14
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

@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 / 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 / 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 / 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]