Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > looking for some kind of IDL for Perl types only

Reply
Thread Tools

looking for some kind of IDL for Perl types only

 
 
Ted Zlatanov
Guest
Posts: n/a
 
      04-11-2012
I'm trying to describe a function's data interface through a simple JSON
language (a sort of DSL). Yes, this is a lot like an IDL. For instance
this interface takes a boolean "activated" parameter and a "users" hash
with mandatory and optional keys as shown.

{
"activated": { "type": "boolean" },

"users":
{
# "stringmap" has only string keys
"type": "stringmap",
"keys":
{
"gecos" : "string",
"uid" : "integer",
"home" : "string",
"shell" : "string"
},
"optional_keys":
{
"passwdhash" : "string",
"groupname" : "string",
"_allow_dup_gid" : "boolean",
"_enforce" : "boolean",
"_nocreate_home" : "boolean",
"_noseed" : "boolean"
}
}
}

I am not attached to the JSON-based DSL, it's just my first prototype.

Parsing and validating the DSL strikes me as boring and surely something
that has been done before, but I'm not crazy about using existing IDLs
like Protocol Buffers, Thrift IDL, WSDL, or the Avro IDL
(http://avro.apache.org/docs/current/idl.html) because they are all too
complex. SWIG is too C-oriented, and so on.

I'd rather have something very simple and easy to parse, which only
supports the basic pure data types in Perl (strings, integers, floating
point, booleans) and lists and hashes that use those data types. I
don't want custom data types. Does such a beast exist in CPAN or
Perl-land? Ideally I should be able to pass it an interface definition
and the actual data, and it should tell me if there's a problem and
where.

Thanks
Ted
 
Reply With Quote
 
 
 
 
Bjoern Hoehrmann
Guest
Posts: n/a
 
      04-11-2012
* Ted Zlatanov wrote in comp.lang.perl.misc:
>I'm trying to describe a function's data interface through a simple JSON
>language (a sort of DSL). Yes, this is a lot like an IDL. For instance
>this interface takes a boolean "activated" parameter and a "users" hash
>with mandatory and optional keys as shown.


You might be looking for <http://en.wikipedia.org/wiki/JSON#Schema>.

>I'd rather have something very simple and easy to parse, which only
>supports the basic pure data types in Perl (strings, integers, floating
>point, booleans) and lists and hashes that use those data types. I
>don't want custom data types. Does such a beast exist in CPAN or
>Perl-land? Ideally I should be able to pass it an interface definition
>and the actual data, and it should tell me if there's a problem and
>where.


(I do not know how mature the JSON Schema implementations in Perl are.)
--
Björn Höhrmann · (E-Mail Removed) · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
 
Reply With Quote
 
 
 
 
Ted Zlatanov
Guest
Posts: n/a
 
      04-11-2012
On Wed, 11 Apr 2012 22:51:40 +0200 Bjoern Hoehrmann <(E-Mail Removed)> wrote:

BH> * Ted Zlatanov wrote in comp.lang.perl.misc:
>> I'm trying to describe a function's data interface through a simple JSON
>> language (a sort of DSL). Yes, this is a lot like an IDL. For instance
>> this interface takes a boolean "activated" parameter and a "users" hash
>> with mandatory and optional keys as shown.


BH> You might be looking for <http://en.wikipedia.org/wiki/JSON#Schema>.

Ah, very nice. A little bit overkill for my needs, but it's not verbose
and does not need special compilers.
http://davidwalsh.name/json-validation has a nice summary.

BH> (I do not know how mature the JSON Schema implementations in Perl are.)

JSON::Schema on CPAN is fairly new but it's a start.

Thank you very much!
Ted
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using IDL from a perl script James Everton Perl Misc 4 10-22-2007 08:05 PM
Looking for IDL generator. Mike Pennington C++ 1 10-14-2004 09:24 AM
Java and Rsi IDL Pushya Java 1 06-15-2004 12:49 PM
Interactive tutorial of some kind for teaching people basic Windows/some internet browsing? fitwell Computer Support 10 09-19-2003 06:07 AM
ADA/C++/IDL to XML? Ken XML 0 09-05-2003 12:08 PM



Advertisments