about summary refs log blame commit diff stats
path: root/012transform.cc
blob: 209eb5d987724b3f07f3a84ea027b9a88bc29fce (plain) (tree)
1
2
3
4
5
6
7
8
                                                                              



                                                                     
                             
                          
                                    








                                            
                                          
                                                  
                                                                                           


                                               
                                                    


                              




                                                                       
                                                                                         

                                  
                                                              
                                            
                     
//: Phase 2: Filter loaded recipes through an extensible list of 'transforms'.
//:
//: The hope is that this framework of transform tools will provide a
//: deconstructed alternative to conventional compilers.

:(before "End recipe Fields")
index_t transformed_until;
  recipe() :transformed_until(-1) {}

:(before "End Types")
typedef void (*transform_fn)(recipe_number);

:(before "End Globals")
vector<transform_fn> Transform;

:(code)
void transform_all() {
//?   cout << "AAA transform_all\n"; //? 1
  for (index_t t = 0; t < Transform.size(); ++t) {
    for (map<recipe_number, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) {
      recipe& r = p->second;
      if (r.steps.empty()) continue;
      if (r.transformed_until != t-1) continue;
      (*Transform.at(t))(/*recipe_number*/p->first);
      r.transformed_until = t;
    }
  }
  parse_int_reagents();  // do this after all other transforms have run
}

void parse_int_reagents() {
//?   cout << "parse_int_reagents\n"; //? 1
  for (map<recipe_number, recipe>::iterator p = Recipe.begin(); p != Recipe.end(); ++p) {
    recipe& r = p->second;
    if (r.steps.empty()) continue;
    for (index_t index = 0; index < r.steps.size(); ++index) {
      instruction& inst = r.steps.at(index);
      for (index_t i = 0; i < inst.ingredients.size(); ++i) {
        populate_value(inst.ingredients.at(i));
      }
      for (index_t i = 0; i < inst.products.size(); ++i) {
        populate_value(inst.products.at(i));
      }
    }
  }
}

void populate_value(reagent& r) {
  if (r.initialized) return;
  char* end = NULL;
  int result = strtol(r.name.c_str(), &end, /*any base*/0);
  if (*end != '\0') return;
//?   cout << "setting value\n"; //? 1
  r.set_value(result);
}
*resource, GDateTime *last_activity, char *pgpkey); void sv_ev_leave_room(const char *const room); void sv_ev_room_destroy(const char *const room); void sv_ev_room_occupant_offline(const char *const room, const char *const nick, const char *const show, const char *const status); void sv_ev_room_destroyed(const char *const room, const char *const new_jid, const char *const password, const char *const reason); void sv_ev_room_kicked(const char *const room, const char *const actor, const char *const reason); void sv_ev_room_occupent_kicked(const char *const room, const char *const nick, const char *const actor, const char *const reason); void sv_ev_room_banned(const char *const room, const char *const actor, const char *const reason); void sv_ev_room_occupent_banned(const char *const room, const char *const nick, const char *const actor, const char *const reason); void sv_ev_outgoing_carbon(char *barejid, char *message); void sv_ev_incoming_carbon(char *barejid, char *resource, char *message); void sv_ev_xmpp_stanza(const char *const msg); void sv_ev_muc_self_online(const char *const room, const char *const nick, gboolean config_required, const char *const role, const char *const affiliation, const char *const actor, const char *const reason, const char *const jid, const char *const show, const char *const status); void sv_ev_muc_occupant_online(const char *const room, const char *const nick, const char *const jid, const char *const role, const char *const affiliation, const char *const actor, const char *const reason, const char *const show_str, const char *const status_str); void sv_ev_roster_update(const char *const barejid, const char *const name, GSList *groups, const char *const subscription, gboolean pending_out); void sv_ev_roster_received(void); int sv_ev_certfail(const char *const errormsg, const char *const certname, const char *const certfp, const char *const notbefore, const char *const notafter); void sv_ev_lastactivity_response(const char *const from, const int seconds, const char *const msg); #endif