Skip to main content

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 | RSS feed

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.

Source Distribution

pywidl-0.1.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

pywidl-0.1-py2.7.egg (53.6 kB view details)

Uploaded Egg

File details

Details for the file pywidl-0.1.tar.gz.

File metadata

  • Download URL: pywidl-0.1.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pywidl-0.1.tar.gz
Algorithm Hash digest
SHA256 d77a6170117e8725ea0d7e5f65e223dd53af7151cee19d0eb80fd714643d9286
MD5 2a62704d8f1e9abdf6fa55cb355c22b6
BLAKE2b-256 d9c338a07b0e37bc74c1559ea0c0a04ba9e9ec0f8878dea0b4794dd2bedc6c54

See more details on using hashes here.

File details

Details for the file pywidl-0.1-py2.7.egg.

File metadata

  • Download URL: pywidl-0.1-py2.7.egg
  • Upload date:
  • Size: 53.6 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pywidl-0.1-py2.7.egg
Algorithm Hash digest
SHA256 7afba99c9e70a4e1ed4a30b8110359d3b0772149f5dbd07ec84e5d9fdd5ea289
MD5 dea754c69172a8ad2e1ebe7945d6248e
BLAKE2b-256 eaee0294d4ce11885ef9af549fd96294ed7776e22c3a6717c59d0a94896851cd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page