Git Product home page Git Product logo

adl's People

Contributors

bacek avatar dependabot[bot] avatar gmhta avatar james-helix avatar latos avatar millergarym avatar paul-thompson-helix avatar spl avatar timbod7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adl's Issues

Build process to construct a standalone distribution

Proposed structure

bin/adlc

lib/adl/std                        -- std library
lib/adl/std/adlast.adl
lib/adl/std/types.adl
lib/adl/std/types.adl-java                  -- custom type overrides
lib/adl/std/types.adl-hs
lib/adl/std/types.adl-cpp

lib/adl/sys/                       -- implementation details
lib/adl/sys/config/java.adl
lib/adl/sys/config/haskell.adl
lib/adl/sys/config/cpp.adl

Added a new primitive type `Primitive`

ADL can then have examples like:

/// A Map with String keys and values of type T/
///
/// Serialised as a JSON object with string keys, ie
///  JSERIALIZE{ StringMap<T> } -> JsonObject<JSERIALIZE{<Serialise<T>}> 

newtype StringMap<T> = Primitive;

and backends will fail if they need to use such a type without a custom mapping.

Over time we can consider reducing the set of hard coded builtin primitives, and replacing them with newtypes like the above.

Clean up adl output

It would be useful to some intelligent truncation to the adl output or add colorisation so the messages are easier to sift through.

Enum serialisation and deserialisation is not complementary

I'm not sure if complementary is the word here (invertible maybe?)

If I declare a union such as this:

union GraphType {
  Void area;
  Void line;
  Void zones;
  Void onoff;
};
struct Foo {
   GraphType graphType;
};

It reads it in from json as for example "graphType": "area"

but when it serialises back to json it becomes

"graphType": {
   "disc": "AREA"
}

It seems like serialisation and deserialisation should be the reverse of each other?

`Void` type annotations without specifying `null` serialized value

Currently, annotations of the Void type needs to specify null as the serialized value, e.g.

newtype Localizable = Void;

struct MyStruct {
    @Localizable null
    String name;
}

Since there can only be one value for a Void type, it would be good to make this implicit and allow annotations like so:

@Localizable
String name;

More meaningful exceptions in java deserialisation

As an example, currently if you define an enum with a wrong value the deserialiser just throws an "IllegalStateException". It would be useful to have some more verbose error message here (i.e. which enum resulted in the error and what the value was).

Implement a javascript backend

Unlike other language backends it is envisaged that a javascript backend won't generate type definitions - rather it will generate records of auxiliary functions to assist with each ADL type. For example, given this ADL:

module mymodel
{
  struct User
  {
     String name;
     String address;
     Int32 age;
  };
};

We might generate code like:

//----------------------------------------------------------------------
// adl/primitives.js   (hand written library code)

var String = {
  validate : function(v) {return typeof(v) == "string";},
  default : function() {return "";},
  copy : function(v) {return v;},
  equal : function(v1, v2) {return v1 == v2;}
};

var Int32 = {
  validate : function(v) {return typeof(v) == "number";},
  default : function() {return 0;},
  copy : function(v) {return return v;},
  equal : function(v1, v2) {return v1 == v2;}
};

//----------------------------------------------------------------------
// mymodel.js (machine generated)


var primitives = require('adl/primitives.js');

var User = {
  validate : function(v) {
    return primitives.String.validate(v.name)
      && primitives.String.validate(v.address)
      && primitives.Int32.validate(v.age);
  },
  default : function() {
    return {
      name : primitives.String.default(),
      address : primitives.String.default(),
      age : primitives.Int32.default()
    };
  },
  copy : function(v) {
    return {
      name : primitives.String.copy(v.name),
      address : primitives.String.copy(v.address),
      age : primitives.Int32.copy(v.age)
    };
  },
  equals : function(v1, v2) {
    return primitives.String.equals(v1.name, v2.name)
      && primitives.String.equals(v1.address, v2.name)
      && primitives.Int32.equals(v1.age, v2.age);
  }
}

Of course, there are lots of complexities to be dealt with:

  • explicit defaults in the ADL
  • generic types
  • custom type definitions.

etc

Improved mechanism for finding custom type definitions

Currently a command line argument is required for each file of custom type definitions. Instead, it would be better if custom type files were given specfic suffixes, and were loaded automatically if found on the search path, ie with files

sys/types.adl
sys/types.cpp.adlmap
sys/types.hs.adlmap
sys/types.java.adlmap

importing sys.types in the java backend would automatically load the custom types from sys/types.java.adlmap

Fix literals for polymorphic types

currently commented out in test4:

// FIXME: Should work, but gives error:
//        Invalid override of field v8a of S: literals not allows for parameterised fields
//
//    Map<String,Int32> v8a = [
//      { "v1" : "X", "v2" : 1 },
//      { "v1" : "Y", "v2" : 2 }
//      ];
};

hashcode method on java unions is broken

Not sure if you're aware of this - but PaymentMethod.hashCode() currently NPE's because the value instance variable is null. Since all members are Void, then maybe we don't need a value variable? Or we can do a null check in hashCode().

Replace remaining IllegalStateExceptions in java json parsing with helpful errors

Deserialisation exceptions for non-default fields

It would be good to have fields that we can define as "not-null" and "not-default" which must be specified by the users (i.e. they don't have a default value). These should throw an exception if they are not specified during deserialisation.

Fix java backend implementation to support recursive types

The folllowing tests currently result in a stack overflow:

public class TestArrayRecursion {

   @Test
   public void testFactory(){
    Factory<Tree<String>> factory = Tree.factory(Factories.STRING);
   }

   @Test
   public void testJsonSerializer(){
     JsonBinding<Tree<String>> jbinding = Tree.jsonBinding(JsonBindings.STRING);
   }

};

(as would similar tests where the recursion is through a union).

Merge mechanism for annotations

Now that we have custom annotations, we need a file format in which we can specify annotations that get merged into the main ADL files. This will keep the ADL files clear as annotations are more widely used.

Exact format of file, and how those files get automatically discovered is yet to be determined.

C++ backend cleanup

  • Use a FieldDetails structure akin to the java backend
  • Delete the ADL/Compiler/Backends/Utils/Literals.hs using code in Processing.hs
  • Consider using the IndentedCode.hs module

Fix license

Change from GPL to a more permissive license (BSD).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.