OSDN Git Service

%neon function.
authorvisor <visor@users.sourceforge.jp>
Sun, 27 Dec 2015 05:49:45 +0000 (14:49 +0900)
committervisor <visor@users.sourceforge.jp>
Sun, 27 Dec 2015 05:49:45 +0000 (14:49 +0900)
ext/ml-json.cc
lib/expr.cc
lib/ml.cc
lib/ml.h
lib/mlenv.cc
lib/motorvar.cc
lib/motorvar.h
lib/util_string.cc
modules/ml-neon.cc
modules/ml-neon.h
modules/ml-texp.cc

index a4ea94b..236e0ae 100644 (file)
@@ -256,6 +256,10 @@ static bool  jsonWrite (MotorOutput* out, MNode* json) {
                out->out_raw (CharConst ("}"));
            }
            break;
+       case MNode::MC_LIBOBJ:
+           out->out_raw (CharConst ("OBJECT"));
+           rc = false;
+           break;
 //     case MNode::MC_DELETED:
 //         break;
        default:
index 3d65170..0147b59 100644 (file)
@@ -100,6 +100,8 @@ MNode*  eval (MNode* cell, MlEnv* mlenv) {
        return vectorDup (cell);
     case MNode::MC_TABLE:
        return tableDup (cell);
+    case MNode::MC_LIBOBJ:
+       return cell;
     default:
        assert (0);
     }
index 931d893..df32c2a 100644 (file)
--- a/lib/ml.cc
+++ b/lib/ml.cc
@@ -133,10 +133,10 @@ inline bool  findNonSymbol (uiterator&b, uiterator e) { // '\'を含める
 }
 
 void  MNode::fdelete () {
-#ifdef DEBUG3
-    std::cerr << "fdelete:" << std::hex << this << std::dec << ":";
+#ifdef HEAPDEBUG_VERBOSE
+    std::cerr << "fdelete:" << std::hex << this << std::dec << ":" << type << ":<";
     this->dump (std::cerr);
-    std::cerr << "\n";
+    std::cerr << ">\n";
 #endif /* DEBUG */
     assert (type != MC_DELETED);
     switch (type) {
@@ -175,6 +175,9 @@ void  MNode::fdelete () {
        delete table;
        table = NULL;
        break;
+    case MC_LIBOBJ:
+       libobj = NULL;          // deleteは行わない
+       break;
     default:;
     }
     type = MC_DELETED;
@@ -263,9 +266,11 @@ void  MNode::vectorUnshift (MNode* e) {
 }
 
 MNode*  MNode::vectorShift () {
+    MNodePtr  ans;
     if (type != MC_VECTOR)
        throw (uErrorWrongType );
-    return vector->shift ();
+    ans = vector->shift ();
+    return ans.release ();
 }
 
 void  MNode::vectorPush (MNode* e) {
@@ -275,9 +280,11 @@ void  MNode::vectorPush (MNode* e) {
 }
 
 MNode*  MNode::vectorPop () {
+    MNodePtr  ans;
     if (type != MC_VECTOR)
        throw (uErrorWrongType );
-    return vector->pop ();
+    ans = vector->pop ();
+    return ans.release ();
 }
 
 void  MNode::vectorResize (size_t pos) {
@@ -287,9 +294,11 @@ void  MNode::vectorResize (size_t pos) {
 }
 
 MNode*  MNode::tableGet (const ustring& name) {
+    MNodePtr  ans;
     if (type != MC_TABLE)
        throw (uErrorWrongType );
-    return table->getVar (name);
+    ans = table->getVar (name);
+    return ans.release ();
 }
 
 void  MNode::tablePut (const ustring& name, MNode* e) {
@@ -299,11 +308,12 @@ void  MNode::tablePut (const ustring& name, MNode* e) {
 }
 
 MNode*  MNode::tableDel (const ustring& name) {
+    MNodePtr  ans;
     if (type != MC_TABLE)
        throw (uErrorWrongType );
-    MNode*  ans = table->getVar (name);
+    ans = table->getVar (name);
     table->eraseVar (name);
-    return ans;
+    return ans.release ();
 }
 
 double  MNode::to_double () {
@@ -320,6 +330,8 @@ double  MNode::to_double () {
        return boost::lexical_cast<double> (*sym);
     case MNode::MC_DOUBLE:
        return real;
+    case MNode::MC_LIBOBJ:
+       return 0.;
     default:
        assert (0);
     }
@@ -339,6 +351,8 @@ int  MNode::to_int () {
        return boost::lexical_cast<int> (*sym);
     case MNode::MC_DOUBLE:
        return real;
+    case MNode::MC_LIBOBJ:
+       return 0;
     default:
        assert (0);
     }
@@ -358,6 +372,8 @@ int64_t  MNode::to_int64 () {
        return boost::lexical_cast<int64_t> (*sym);
     case MNode::MC_DOUBLE:
        return real;
+    case MNode::MC_LIBOBJ:
+       return 0;
     default:
        assert (0);
     }
@@ -390,6 +406,8 @@ bool  MNode::to_bool () {
        } else {
            return true;
        }
+    case MNode::MC_LIBOBJ:
+       return true;
     default:
        assert (0);
     }
@@ -473,6 +491,8 @@ ustring  MNode::to_texp () {
        return vector_to_string ();
     case MNode::MC_TABLE:
        return table_to_string ();
+    case MNode::MC_LIBOBJ:
+       return ustring (CharConst ("OBJECT"));
     default:
        assert (0);
     }
@@ -494,6 +514,8 @@ ustring  MNode::to_string () {
        return vector_to_string ();
     case MNode::MC_TABLE:
        return table_to_string ();
+    case MNode::MC_LIBOBJ:
+       return to_texp ();
     default:
        assert (0);
     }
@@ -904,6 +926,11 @@ bool  eq (MNode* a, MNode* b) {
                } else {
                    return false;
                }
+           case MNode::MC_LIBOBJ:
+               if (a->libobj == b->libobj)
+                   return true;
+               else
+                   return false;
            default:
                assert (0);
            }
@@ -972,6 +999,11 @@ bool  equal (MNode* a, MNode* b) {
                } else {
                    return false;
                }
+           case MNode::MC_LIBOBJ:
+               if (a->libobj == b->libobj)
+                   return true;
+               else
+                   return false;
            default:
                assert (0);
            }
index 912d280..2bad9e4 100644 (file)
--- a/lib/ml.h
+++ b/lib/ml.h
@@ -10,6 +10,7 @@
 class  MlEnv;
 class  MotorVar;
 class  MotorVector;
+class  MLFunc;
 class  MNode {
  public:
     typedef enum {
@@ -21,6 +22,7 @@ class  MNode {
        MC_INT,                 // unused
        MC_VECTOR,
        MC_TABLE,
+       MC_LIBOBJ,
        MC_DELETED,
     }  ptr_type;
 
@@ -37,6 +39,7 @@ class  MNode {
        long long  num;         // unused
        MotorVector*  vector;
        MotorVar*  table;
+       MLFunc*  libobj;
     };
     MNode () {
        type = MC_NIL;
@@ -123,6 +126,11 @@ class  MNode {
            set_nil ();
     };
     // void  set (int v);
+    void  set_libobj (MLFunc* obj) {
+       assert (type == MC_NIL);
+       type = MC_LIBOBJ;
+       libobj = obj;
+    };
     inline bool  isNil () {
        return type == MC_NIL;
     };
@@ -144,6 +152,9 @@ class  MNode {
     inline bool  isTable () {
        return type == MC_TABLE;
     };
+    inline bool  isLibObj () {
+       return type == MC_LIBOBJ;
+    };
     inline MNode*  car () {
        if (type != MC_CONS)
            throw (uErrorWrongType);
@@ -347,6 +358,12 @@ MNode*  newMNode_vector ();
 MNode*  newMNode_table (MotorVar* tbl);
 MNode*  newMNode_table ();
 
+inline MNode*  newMNode_libobj (MLFunc* fn) {
+    MNode*  ans = new MNode;
+    ans->set_libobj (fn);
+    return ans;
+}
+
 class  MNodePtr {
  public:
     MNode*  p;
index 7e829f0..605689c 100644 (file)
@@ -47,11 +47,13 @@ bool  MlEnv::searchMTable (const ustring& name, FTableVal*& ans) {
 
     if (mlFTable->mtable && (it = mlFTable->mtable->find (name)) != mlFTable->mtable->end ()) {
        ans = it->second;
-       for (i = mlFTable->mstack.size () - 1; i >= 0; i --) {
-           if (mlFTable->mstack[i].mfunc->mlid == ans->mlid) {
-               // nested error.
-               throw (name + ": forbidden.");
-               return false;
+       if (name[0] == '$') {
+           for (i = mlFTable->mstack.size () - 1; i >= 0; i --) {
+               if (mlFTable->mstack[i].mfunc->mlid == ans->mlid) {
+                   // nested error.
+                   throw (name + ": forbidden.");
+                   return false;
+               }
            }
        }
        return true;
index 00b18e8..4e881ef 100644 (file)
@@ -35,6 +35,15 @@ MNode*  MotorVar::getVar (const ustring& name) {
     }
 }
 
+void  MotorVar::eraseVar (const ustring& name) {
+#ifdef HEAPDEBUG_VERBOSE
+    std::cerr << "MotorVar::eraseVar (" << name << ":(" << std::hex << getVar (name) << std::dec << ")";
+    getVar (name)->dump (std::cerr);   // XXX
+    std::cerr << ")\n";
+#endif /* DEBUG */
+    erase (name);
+}
+
 bool  MotorVar::defined (const ustring& name) {
     MotorVar::iterator  it = find (name);
     return (it != end ());
index dd603c0..c5d1935 100644 (file)
@@ -22,9 +22,7 @@ class  MotorVar: public boost::unordered_map<ustring, MNodePtr> {
     virtual  ~MotorVar () {};
     virtual void  setVar (const ustring& name, MNode* val);
     virtual MNode*  getVar (const ustring& name);
-    virtual void  eraseVar (const ustring& name) {
-       erase (name);
-    };
+    virtual void  eraseVar (const ustring& name);
     virtual bool  defined (const ustring& name);
 };
 
index a18993b..7c4cd0d 100644 (file)
@@ -704,7 +704,6 @@ ustring  passCrypt (const ustring& pass, passCryptFormat format) {
     default:
        assert (0);
     }
-    std::cerr << salt << ":" << salt.length () << "\n";
     return ustring (crypt (pass.c_str (), salt.c_str ()));
 }
 
index 0f444d5..9496955 100644 (file)
@@ -760,19 +760,22 @@ void  MLNeon::newSession (MlEnv* mlenv) {
 
 */
 /*DOC:
-===$neon==
- ($neon [#http | #https] Host Port
-       [:proxy '(HOSTNAME . PORT)] [:proxy-user '(ID . PASSWORD)]
-       [:on-error FUNCTION]
-       [#no-verify]
-       [SUBFUNCTION...]) -> LAST VALUE
+===$neon, %neon==
+ (%neon [#http | #https] Host Port
+       :module-store VAR
+       :proxy '(HOSTNAME . PORT) :proxy-user '(ID . PASSWORD)
+       :on-error FUNCTION
+       #no-verify
+       [SUBFUNCTION...]) -> LAST_VALUE
 
 */
 //#MFUNC       $neon   ml_neon cMLNeonID
+//#MFUNC       %neon   ml_neon cMLNeonID
 MNode*  ml_neon (MNode* cell, MlEnv* mlenv) {
     MNode*  arg = cell->cdr ();
     NeonInit.init ();
     MLNeon  obj (mlenv);
+    MNodePtr  objStore;
     MNodePtr  errfn;
     MNodePtr  ans;
     MNodePtr  t;
@@ -787,6 +790,7 @@ MNode*  ml_neon (MNode* cell, MlEnv* mlenv) {
        {CharConst ("proxy-user"), false},      // 3
        {CharConst ("on-error"), false},        // 4
        {CharConst ("no-verify"), true},        // 5
+       {CharConst ("module-store"), false},    // 6
        {NULL, 0, 0}
     };
 
@@ -815,6 +819,14 @@ MNode*  ml_neon (MNode* cell, MlEnv* mlenv) {
     }
     evkw (4, errfn);                   // 4:on-error
     evkw_bool (5, obj.fnoverify);      // 5:no-verify
+    if (evkw (6, t)) {                 // 6:module-store
+       if (isSym (t ())) {
+           objStore = newMNode_libobj (&obj);
+           mlenv->setVar (t ()->to_string (), objStore ());
+       } else {
+           throw (t ()->dump_string_short () + uErrorBadParam);
+       }
+    }
 
     if (! matchHostname (obj.host))
        throw (obj.host + ": bad hostname.");
@@ -839,6 +851,8 @@ MNode*  ml_neon (MNode* cell, MlEnv* mlenv) {
        }
     }
     mlenv->stopBreak (cell->car ());
+    if (objStore () && objStore ()->isLibObj ())
+       objStore ()->type = MNode::MC_NIL;              // 強制NIL化
 
     return ans.release ();
 }
@@ -907,18 +921,22 @@ static MNode*  checkConsList (MNode* e) {
 
 /*DOC:
 ====http-request====
- (http-request PATH [#get] [#post] [#put] [#delete] [#head] [#file]
-       [:basic-user '(ID . PASSWORD)]
-       [:query '((NAME . VALUE) ...)] [:get-query '((NAME . VALUE) ...)] [#no-encode]
-       [:post-file-serial '((NAME . FILE) ...)]
-       [:post-file-named '((NAME . FILE) ...)]
-       [:post-file-static '((NAME . FILE) ...)]
-       [:raw-query TEXT] [:raw-file-serial FILE] [:raw-file-named FILE] [:raw-file-static FILE]
-       [:query-type MIMETYPE]
-       [:cookie '((NAME . VALUE) ...)] [:header '((NAME . VALUE) ...)]
-       [#sjis] [#euc-jp] [:iconv NAME]
+ (http-request PATH [#get | #post | #put | #delete | #head | #file]
+       :basic-user '(ID . PASSWORD)
+       :query '((NAME . VALUE) ...)
+       :get-query '((NAME . VALUE) ...)
+       #no-encode
+       :post-file-serial '((NAME . FILE) ...)
+       :post-file-named '((NAME . FILE) ...)
+       :post-file-static '((NAME . FILE) ...)
+       :raw-query TEXT :raw-file-serial FILE :raw-file-named FILE :raw-file-static FILE
+       :query-type MIMETYPE
+       :cookie '((NAME . VALUE) ...) :header '((NAME . VALUE) ...)
+       [#sjis | #euc-jp | :iconv NAME]
+       :module MODULE
 */
-//#SFUNC       http-request    ml_neon_http_request
+//#SFUNC       http-request    ml_neon_http_request    $neon
+//#SFUNC       http-request    ml_neon_http_request    %neon
 MNode*  ml_neon_http_request (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     MNode*  arg = cell->cdr ();
     MLNeon*  obj = (MLNeon*)mobj;
@@ -952,11 +970,14 @@ MNode*  ml_neon_http_request (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
        {CharConst ("sjis"), true},                     // 19
        {CharConst ("euc-jp"), true},                   // 20
        {CharConst ("iconv"), false},                   // 21
+       {CharConst ("module"), false},                  // 22
        {NULL, 0, 0}
     };
 
-    obj->query.reset (new NeonQuery (obj->session->get (), mlenv));
     setParams (arg, 1, &params, kwlist, &keywords, NULL);
+    if (evkw (22, t))                  // 22:module
+       assignNLNeon (obj, t ());
+    obj->query.reset (new NeonQuery (obj->session->get (), mlenv));
     obj->query->path = eval_str (params[0], mlenv);
     if (evkw_bool (0, f))      // 0:get
        obj->query->method = NeonQuery::METHOD_GET;
@@ -1028,16 +1049,25 @@ MNode*  ml_neon_http_request (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
 
 /*DOC:
 ====http-status====
- (http-status) -> NUMBER
+ (http-status :module MODULE) -> NUMBER
 
 */
-//#SFUNC       http-status     ml_neon_http_status
+//#SFUNC       http-status     ml_neon_http_status     $neon
+//#SFUNC       http-status     ml_neon_http_status     %neon
 MNode*  ml_neon_http_status (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     MNode*  arg = cell->cdr ();
     MLNeon*  obj = (MLNeon*)mobj;
+    MNodePtr  t;
+    std::vector<MNode*>  keywords;
+    static paramList  kwlist[] = {
+       {CharConst ("module"), false},                  // 0
+       {NULL, 0, 0}
+    };
     
-    if (arg)
-       throw (uErrorWrongNumber);
+    setParams (arg, 0, NULL, kwlist, &keywords, NULL);
+    if (evkw (0, t))                   // 0:module
+       assignNLNeon (obj, t ());
+
     if (! obj->query)
        return NULL;
 
@@ -1046,17 +1076,26 @@ MNode*  ml_neon_http_status (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
 
 /*DOC:
 ====http-response====
- (http-response) -> STRING
+ (http-response :module MODULE) -> STRING
 
 */
-//#SFUNC       http-response   ml_neon_http_response
+//#SFUNC       http-response   ml_neon_http_response   $neon
+//#SFUNC       http-response   ml_neon_http_response   %neon
 MNode*  ml_neon_http_response (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     MNode*  arg = cell->cdr ();
     MLNeon*  obj = (MLNeon*)mobj;
     ustring  ans;
+    MNodePtr  t;
+    std::vector<MNode*>  keywords;
+    static paramList  kwlist[] = {
+       {CharConst ("module"), false},                  // 0
+       {NULL, 0, 0}
+    };
+
+    setParams (arg, 0, NULL, kwlist, &keywords, NULL);
+    if (evkw (0, t))                   // 0:module
+       assignNLNeon (obj, t ());
 
-    if (arg)
-       throw (uErrorWrongNumber);
     if (! obj->query)
        return NULL;
 
@@ -1068,22 +1107,29 @@ MNode*  ml_neon_http_response (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
 
 /*DOC:
 ====http-response-file====
- (http-response-file FILENAME) -> NIL
+ (http-response-file FILENAME :module MODULE) -> NIL
 
 */
-//#SFUNC       http-response-file      ml_neon_http_response_file
+//#SFUNC       http-response-file      ml_neon_http_response_file      $neon
+//#SFUNC       http-response-file      ml_neon_http_response_file      %neon
 MNode*  ml_neon_http_response_file (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     MNode*  arg = cell->cdr ();
     MLNeon*  obj = (MLNeon*)mobj;
     ustring  name;
     ustring  tgt, tmp;
+    MNodePtr  t;
+    std::vector<MNode*>  params;
+    std::vector<MNode*>  keywords;
+    static paramList  kwlist[] = {
+       {CharConst ("module"), false},                  // 0
+       {NULL, 0, 0}
+    };
+
+    setParams (arg, 1, &params, kwlist, &keywords, NULL);
+    name = eval_str (params[0], mlenv);
+    if (evkw (0, t))                                   // 0:module
+       assignNLNeon (obj, t ());
 
-    if (! arg)
-       throw (uErrorWrongNumber);
-    name = eval_str (arg->car (), mlenv);
-    nextNode (arg);
-    if (arg)
-       throw (uErrorWrongNumber);
     if (! obj->query)
        return NULL;
 
@@ -1103,23 +1149,28 @@ MNode*  ml_neon_http_response_file (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
 
 /*DOC:
 ====http-response-output====
- (http-response-output [#continue | :continue BOOL]) -> NIL
+ (http-response-output :module MODULE #continue) -> NIL
 
 */
-//#SFUNC       http-response-output    ml_neon_http_response_output
+//#SFUNC       http-response-output    ml_neon_http_response_output    $neon
+//#SFUNC       http-response-output    ml_neon_http_response_output    %neon
 MNode*  ml_neon_http_response_output (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     MNode*  arg = cell->cdr ();
     MLNeon*  obj = (MLNeon*)mobj;
     bool  cflag = false;
+    MNodePtr  t;
     std::vector<MNode*>  keywords;
     static paramList  kwlist[] = {
-       {CharConst ("continue"), true},
+       {CharConst ("continue"), true},                 // 0
+       {CharConst ("module"), false},                  // 1
        {NULL, 0, 0}
     };
 
     setParams (arg, 0, NULL, kwlist, &keywords, NULL);
-    if (keywords[0] && eval_bool (keywords[0], mlenv))
-       cflag = true;
+    evkw_bool (0, cflag);
+    if (evkw (1, t))                                   // 1:module
+       assignNLNeon (obj, t ());
+
     if (! obj->query)
        return NULL;
 
@@ -1135,21 +1186,28 @@ MNode*  ml_neon_http_response_output (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
 
 /*DOC:
 ====get-cookie====
- (get-cookie NAME) -> STRING
+ (get-cookie NAME :module MODULE) -> STRING
 
 */
-//#SFUNC       get-cookie      ml_neon_get_cookie
+//#SFUNC       get-cookie      ml_neon_get_cookie      $neon
+//#SFUNC       get-cookie      ml_neon_get_cookie      %neon
 MNode*  ml_neon_get_cookie (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     MNode*  arg = cell->cdr ();
     MLNeon*  obj = (MLNeon*)mobj;
     ustring  name;
+    MNodePtr  t;
+    std::vector<MNode*>  params;
+    std::vector<MNode*>  keywords;
+    static paramList  kwlist[] = {
+       {CharConst ("module"), false},                  // 0
+       {NULL, 0, 0}
+    };
+
+    setParams (arg, 1, &params, kwlist, &keywords, NULL);
+    name = eval_str (params[0], mlenv);
+    if (evkw (0, t))                   // 0:module
+       assignNLNeon (obj, t ());
 
-    if (! arg)
-       throw (uErrorWrongNumber);
-    name = eval_str (arg->car (), mlenv);
-    nextNode (arg);
-    if (arg)
-       throw (uErrorWrongNumber);
     if (! obj->query)
        return NULL;
 
@@ -1163,16 +1221,25 @@ MNode*  ml_neon_get_cookie (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
 
 /*DOC:
 ====get-cookie-all====
- (get-cookie-all) -> LIST of (NAME . VALUE)
+ (get-cookie-all :module MODULE) -> LIST of (NAME . VALUE)
 
 */
-//#SFUNC       get-cookie-all  ml_neon_get_cookie_all
+//#SFUNC       get-cookie-all  ml_neon_get_cookie_all  $neon
+//#SFUNC       get-cookie-all  ml_neon_get_cookie_all  %neon
 MNode*  ml_neon_get_cookie_all (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     MNode*  arg = cell->cdr ();
     MLNeon*  obj = (MLNeon*)mobj;
+    MNodePtr  t;
+    std::vector<MNode*>  keywords;
+    static paramList  kwlist[] = {
+       {CharConst ("module"), false},                  // 0
+       {NULL, 0, 0}
+    };
+
+    setParams (arg, 0, NULL, kwlist, &keywords, NULL);
+    if (evkw (0, t))                   // 0:module
+       assignNLNeon (obj, t ());
 
-    if (arg)
-       throw (uErrorWrongNumber);
     if (! obj->query)
        return NULL;
 
@@ -1181,13 +1248,24 @@ MNode*  ml_neon_get_cookie_all (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
 
 /*DOC:
 ====http-content-type====
- (http-content-type) -> STRING
+ (http-content-type :module MODULE) -> STRING
 
 */
-//#SFUNC       http-content-type       ml_neon_http_content_type
+//#SFUNC       http-content-type       ml_neon_http_content_type       $neon
+//#SFUNC       http-content-type       ml_neon_http_content_type       %neon
 MNode*  ml_neon_http_content_type (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     MNode*  arg = cell->cdr ();
     MLNeon*  obj = (MLNeon*)mobj;
+    MNodePtr  t;
+    std::vector<MNode*>  keywords;
+    static paramList  kwlist[] = {
+       {CharConst ("module"), false},                  // 0
+       {NULL, 0, 0}
+    };
+
+    setParams (arg, 0, NULL, kwlist, &keywords, NULL);
+    if (evkw (0, t))                                   // 0:module
+       assignNLNeon (obj, t ());
 
     if (! obj->query)
        return NULL;
@@ -1209,22 +1287,29 @@ MNode*  ml_neon_http_content_type (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
 
 /*DOC:
 ====http-get-header====
- (http-get-header NAME) -> STRING
+ (http-get-header NAME :module MODULE) -> STRING
 
 */
-//#SFUNC       http-get-header ml_neon_http_get_header
+//#SFUNC       http-get-header ml_neon_http_get_header $neon
+//#SFUNC       http-get-header ml_neon_http_get_header %neon
 MNode*  ml_neon_http_get_header (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     MNode*  arg = cell->cdr ();
     MLNeon*  obj = (MLNeon*)mobj;
     ustring  name;
     ustring  u;
+    MNodePtr  t;
+    std::vector<MNode*>  params;
+    std::vector<MNode*>  keywords;
+    static paramList  kwlist[] = {
+       {CharConst ("module"), false},                  // 0
+       {NULL, 0, 0}
+    };
+
+    setParams (arg, 1, &params, kwlist, &keywords, NULL);
+    name = eval_str (params[0], mlenv);
+    if (evkw (0, t))                                   // 0:module
+       assignNLNeon (obj, t ());
 
-    if (! arg)
-       throw (uErrorWrongNumber);
-    name = eval_str (arg->car (), mlenv);
-    nextNode (arg);
-    if (arg)
-       throw (uErrorWrongNumber);
     if (! obj->query)
        return NULL;
 
@@ -1238,16 +1323,25 @@ MNode*  ml_neon_http_get_header (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
 
 /*DOC:
 ====http-get-header-all====
- (http-get-header-all) -> LIST of (NAME . VALUE)
+ (http-get-header-all :module MODULE) -> LIST of (NAME . VALUE)
 
 */
-//#SFUNC       http-get-header-all     ml_neon_http_get_header_all
+//#SFUNC       http-get-header-all     ml_neon_http_get_header_all     $neon
+//#SFUNC       http-get-header-all     ml_neon_http_get_header_all     %neon
 MNode*  ml_neon_http_get_header_all (MNode* cell, MlEnv* mlenv, MLFunc* mobj) {
     MNode*  arg = cell->cdr ();
     MLNeon*  obj = (MLNeon*)mobj;
+    MNodePtr  t;
+    std::vector<MNode*>  keywords;
+    static paramList  kwlist[] = {
+       {CharConst ("module"), false},                  // 0
+       {NULL, 0, 0}
+    };
+
+    setParams (arg, 0, NULL, kwlist, &keywords, NULL);
+    if (evkw (0, t))                   // 0:module
+       assignNLNeon (obj, t ());
 
-    if (arg)
-       throw (uErrorWrongNumber);
     if (! obj->query)
        return NULL;
 
index ecfccba..97e4412 100644 (file)
@@ -187,6 +187,11 @@ class  MLNeon: public MLFunc {
     virtual void  newSession (MlEnv* mlenv);
 };
 
+inline void  assignNLNeon (MLNeon*& var, MNode* e) {
+    if (e && e->type == MNode::MC_LIBOBJ && e->libobj && e->libobj->id == cMLNeonID)
+       var = (MLNeon*)e->libobj;
+}
+
 MNode*  ml_neon (MNode* cell, MlEnv* mlenv);
 MNode*  ml_neon_http_request (MNode* cell, MlEnv* mlenv, MLFunc* mobj);
 MNode*  ml_neon_http_status (MNode* cell, MlEnv* mlenv, MLFunc* mobj);
index ca4a4b1..0574de2 100644 (file)
@@ -58,7 +58,7 @@ MNode*  ml_vector_get (MNode* cell, MlEnv* mlenv) {
     else if (! vec ()->isVector ())
        throw (uErrorWrongType);
     else
-       return vec ()->vectorGet (n);
+       return mlenv->retval = vec ()->vectorGet (n);
 }
 
 /*DOC:
@@ -84,7 +84,7 @@ MNode*  ml_vector_back (MNode* cell, MlEnv* mlenv) {
     else if (! isVector (vec ()))
        throw (uErrorWrongType);
     else
-       return vec ()->vectorGet (vec ()->vectorSize () - 1);
+       return mlenv->retval = vec ()->vectorGet (vec ()->vectorSize () - 1);
 }
 
 /*DOC:
@@ -173,9 +173,9 @@ MNode*  ml_vector_del (MNode* cell, MlEnv* mlenv) {
        throw (uErrorWrongType);
 
     if (isNil (toobj ())) {
-       return vec ()->vectorDel (to_int (fromobj ()));
+       return mlenv->retval = vec ()->vectorDel (to_int (fromobj ()));
     } else {
-       return vec ()->vectorDel (to_int (fromobj ()), to_int (toobj ()));
+       return mlenv->retval = vec ()->vectorDel (to_int (fromobj ()), to_int (toobj ()));
     }
 }
 
@@ -228,7 +228,7 @@ MNode*  ml_vector_shift (MNode* cell, MlEnv* mlenv) {
     if (! isVector (vec ()))
        throw (uErrorWrongType);
 
-    return vec ()->vectorShift ();
+    return mlenv->retval = vec ()->vectorShift ();
 }
 
 /*DOC:
@@ -280,7 +280,7 @@ MNode*  ml_vector_pop (MNode* cell, MlEnv* mlenv) {
     if (! isVector (vec ()))
        throw (uErrorWrongType);
 
-    return vec ()->vectorPop ();
+    return mlenv->retval = vec ()->vectorPop ();
 }
 
 /*DOC:
@@ -596,7 +596,7 @@ MNode*  ml_table_get (MNode* cell, MlEnv* mlenv) {
     if (! tbl ()->isTable ())
        throw (uErrorWrongType);
 
-    return tbl ()->tableGet (name);
+    return mlenv->retval = tbl ()->tableGet (name);
 }
 
 /*DOC:
@@ -653,7 +653,7 @@ MNode*  ml_table_del (MNode* cell, MlEnv* mlenv) {
 
     if (! isTable (tbl ()))
        throw (uErrorWrongType);
-    return tbl ()->tableDel (name);
+    return mlenv->retval = tbl ()->tableDel (name);
 }
 
 /*DOC: