Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

Generic code generator from WebIDL interfaces.

Project description

PyWIdl
======

Generic code generator from WebIDL interfaces.

pywidl parses WebIDL code using PLY, builds the interface object model and emits
whatever code using user's mako templates or even user's native python module.


WebIDL object model
-------------------
Defined in pywidl/model.py

Common usage in tests/idl.py



Example usage
-------------

$ cat fragment.idl

exception GraphicsException {
DOMString reason;
};

interface Paint { };

interface SolidColor : Paint {
attribute float red;
attribute float green;
attribute float blue;
};

interface Pattern : Paint {
attribute DOMString imageURL;
};

[Constructor]
interface GraphicalWindow {
readonly attribute unsigned long width;
readonly attribute unsigned long height;

attribute Paint currentPaint;

void drawRectangle(float x, float y, float width, float height);

void drawText(float x, float y, DOMString text);
};

$ cat mako.tpl

// ${foo}
% for definition in definitions:
${definition.name}
% endfor

$ pywidl -m -o fragment.txt -t mako.tpl fragment.idl -- --foo=bar

$ cat fragment.txt

// bar
GraphicsException
Paint
SolidColor
Pattern
GraphicalWindow

$ cat native.py

def render(definitions=[], source=None, output=None,
template=None, template_type=None, foo=None, **kwargs):

with open(output, 'w') as out:
print >>out, "// %s" % foo
for definition in definitions:
print >>out, definition.name

$ PYTHONPATH=".:$PYTHONPATH"
pywidl -n -o fragment.txt -t native fragment.idl-- --foo=bar

$ cat fragment.txt

// bar
GraphicsException
Paint
SolidColor
Pattern
GraphicalWindow

Project details


Release history Release notifications

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pywidl, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size pywidl-0.1-py2.7.egg (53.6 kB) File type Egg Python version 2.7 Upload date Hashes View hashes
Filename, size pywidl-0.1.tar.gz (18.9 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page