Git Product home page Git Product logo

atdjs's Introduction

atdjs is a tool for generating serializers and unserializers from atd type definition. Like atdgen, atdjs generates OCaml source code. However, unlike atdgen, the generated code is intended for compilation by the js_of_ocaml compiler, an OCaml compiler with a Javascript backend.

atdjs simplifies the construction of browser-based client apps (written in OCaml and compiled with js_of_ocaml which send/receive typed messages via Javascript's XHR.

Plain OCaml and atd are required for building atdjs. js_of_ocaml and jsonoj are required for building the code which atdjs generates.

atdjs's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

atdjs's Issues

.ml produced has a type error

Hi, here my (huge) .atd file

type notification =
{
add : info list;
del : info list;
update : info list;
}

type position = (int*int)

type info = {
events : eventJeu list;
inventaire : objetJeu list;
detection : itemJeu list;
chat : chatLigne list;
fichePerso : fichePersoItem list;
actionJoueur : actionJoueurType ;
}

type nainInfo = {
idnainInfo: string;
nomen: string;
guilde: string;
niveau: string;
tag : string;
xp : string;
(Etc...)
}

              (*TODO TODO : voir si la date ne doit pas être en float pour prendre en compte les ms sur les arbitrages*)

type itemJeu = [Nain of nainLight | Objet of objetJeu ]
type eventJeu = (nainLight * nainLight * objetJeu * objetJeu * typeEvenement * int (int pour la date)) (* C'est à qu'il faut le remplacer par une liste d'Events possibles )
type nainLight = { idnain : string; }
type chatLigne = (nainLight * heureDate * string)
type heureDate = int
type fichePersoItem = string (Inconnu total, à déterminer)
type objetJeu = { idobj : string }(TODO plus le reste qui viendra plus tard)
type actionJoueurType = [
| DeplacementGauche of nainLight(
=>)
| DeplacementDroite of nainLight(
=>)
| DeplacementHaut of nainLight(
=>)
| DeplacementBas of nainLight(
=>)
| DeplacementBasGauche of nainLight(
=>)
| DeplacementBasDroite of nainLight(
=>)
| DeplacementHautGauche of nainLight(
=>)
| DeplacementHautDroite of nainLight(
=>)
| AttaqueEvt of ( nainLight * nainLight * objetJeu * position )(
=>)
| JeSuisAttaqueEvt of ( nainLight * nainLight * objetJeu * position )(
=>)
| RamasseObjetEvt of ( nainLight * objetJeu )(
=>)
| PoserObjetEvt of ( nainLight * objetJeu )(
=>)
| UtiliserObjetEvt of ( nainLight * objetJeu )(
=>)
| PrendDrapeauEvt of nainLight(
=>)
| PoseDrapeauEvt of nainLight(
=>*)
| VideEvt
]

type typeEvenement = [
| AttaqueEvent of ( nainLight * nainLight * objetJeu * position ) (TODO plus le reste qui viendra plus tard)
| PriseObjetEvent of ( nainLight * objetJeu )
| PoseObjetEvent of ( nainLight * objetJeu )
]

type dialogueClientServeur = [ EvenementFromClient of (demandeClient * idClient) | RefreshFromServeurToClient of (notification * idClient)]

type demandeClient = [ ActionJoueur of actionJoueurType | DemandeInfo of typeInfo]

type typeInfo = [ ClassementGuilde of int(Guilde)) | Evenements of heureDate (TODO gérer comme ds Nainwak le filtrage --> on le mettra sur le client)
| MondeCourant of infoMonde ]

type infoMonde = {
nomMonde : string;
liste_Objets : (int * int * objetJeu ) list;
liste_Champion : (int * int * nainLight) list;
liste_Events : eventJeu list; (Du plus récent au plus ancien)
}

type idClient = int

type success = { success : bool ; msgs : string list}
(=>)

type etatSpaceChampion = [
| HiberneDepuis of int (* Les dates = nombre de seconde depuis 2000*)
| Vivant
| CompteSupprimeLe of int
]

type typeObjet = [
| Arme
| Rune
| Special
| Bouffe
] (TODO : on pourrait mettre les caractéristiques ici)

type objetBackup = {
au_sol : bool ;
possede_par : string;
nom : string;
description : string;
coutUtilisation : int;
typeObjet : typeObjet; (* A voir : est-ce que c'est là qu'on stokera diverses infos spécifiques ? _)
utilisable_le : int; (_date en seconde à partir de laquelle l'objet devient utilisable*)
position : position;
force : int;
portee : int;
utilisee_le : int;
temp_blocage : int
}

type hashIDObjet = (string * objetBackup) list

type spaceChampionBackup = {
etatChampion : etatSpaceChampion;
pa : int;
pv : int;
xp : int;
attaque : int;
regeneration : int;
celerite : int; (Nombre de pa par déplacement ?)
coutDeplacement : int;
position : position;
direction : int; ([1;4]U[6;9])
inventaire : hashIDObjet; (_let prem : Hashtbl.create 127 in Hashtbl.add prem "IDObj0" (None : objetSpaceChampion option); prem(_Liste d'objets*) *)
mondeCourant : monde;
myShoulder : spaceChampionBackup;
myObject1 : objetBackup;
myObject2 : objetBackup
}

type monde = {
damier : (spaceChampionBackup list * objetBackup list) list;
listeChampion : spaceChampionBackup;
listeObjets : spaceChampionBackup;
}

The file produced give me the following error :

ocamlc.opt -verbose -c -I /opt/local/lib/ocaml/site-lib/lwt -I /opt/local/lib/ocaml/site-lib/js_of_ocaml -I /opt/local/lib/ocaml/site-lib/jsonoj spacechampion.ml
File "spacechampion.ml", line 753, characters 27-31:
Error: This expression has type info but an expression was expected of type
spaceChampionBackup

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.