COMMUNITY

HaxeShare (A simple, but powerful web framework)

Okay, I’ve thought about the approach to use quite a lot for this project and have ultimately decided upon using more of a direct Haxe approach as you suggested, but not exactly in the way you describe.

I’ve called this new library HaxeShare which I would suggest is far easier to use than previously.

Example:

package;
#if macro

import hxshare.Builder;

class Generator
{

    public static function build()
    {
        Builder.init();

        Builder.beginStructure("PM_Department");
        Builder.addField("id", "ID");
        Builder.addField("shorttext", "URL");
        Builder.addField("shorttext", "Title", true);
        Builder.addField("longtext", "Description");

        Builder.build();
    }

}

#end

Of course, all the build and setup instructions are on the main page on GitHub.

Original Post

I am curious why did you go with a custom format and then generate types from it with a macro, when you could just use a normal Haxe class or structure syntax and macro-generate the necessary support code directly from the type definition.

1 Like

Hmm… Well, I suppose I could, for example, implement typedef which Haxe at macro context could then generate the respective server class, but then there is also a number of metadata tags you might want to add to these variables to customise and define output.

However, there are customisation options I would like to add for language-specific targets.

Say, for example, you want to generate type references for WPF or WinForms on the C# target, or Swing on the Java target, or any other UI element for any other framework. The options are endless but having metadata stacked up on each other for these options is potentially messy. At least to me it looks messy.

With a custom format, it’s potentially easier to read to be able to define or even add extra Field Types for their relevant target-specific frameworks.

However, I suppose as this project grows we would have to wait and see if this is true in practice and how much of a benefit it might be to use metadata over a custom format.

EDIT: The custom format approach is for readability which I think is important for a project of this scale.

I have now added the following features to HaxeShare:

  1. A server-based router generated into a RESTful API.
  2. Added a hash-based client-side router class.

Please see updated project and documented README on GitHub for full details.

1 Like

I have added a lot more beneficial features to this project since the last time it was updated. Here are the patch notes:

  • Removed searchable from Builder.addField. Searching now requires an object from the client.
  • Added ability to create custom REST components.
  • The id parameter of the generated modify function of database objects is now of type Dynamic for greater flexibility.
  • Added isPrimary parameter to Builder.addField to specify what field should be the primary key in the generated database object.
  • Added Router.remainder function to retrieve the remaining route components as a string from the currently matched index.
  • The Request.get function should call cb with false even if a status code of 200 is not given. This allows for greater flexibility on finding issues on the server-side.

In addition to these changes being found on GitHub, you can also find this project on Haxelib now.