Changeset 14185


Ignore:
Timestamp:
06/18/12 21:54:20 (12 years ago)
Author:
tbretz
Message:
Some small updated to the database enine,mainly ReadOnlys
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/InterpreterV8.cc

    r14177 r14185  
    341341
    342342        Handle<Array> ret = Array::New();
    343         ret->Set(String::New("table"), String::New(res.table()));
     343        ret->Set(String::New("table"), String::New(res.table()), ReadOnly);
     344
     345        Handle<Array> cols = Array::New();
    344346
    345347        int irow=0;
     
    353355            {
    354356                const Handle<Value> name = String::New((*list)[i].c_str());
     357                if (irow==0)
     358                    cols->Set(Integer::NewFromUnsigned(i), name, ReadOnly);
    355359
    356360                if ((*it)[i].is_null())
    357361                {
    358                     row->Set(name, Undefined());
     362                    row->Set(name, Undefined(), ReadOnly);
    359363                    continue;
    360364                }
     
    370374                        const uint64_t val = (uint64_t)(*it)[i];
    371375                        if (val>UINT32_MAX)
    372                             row->Set(name, Number::New(val));
     376                            row->Set(name, Number::New(val), ReadOnly);
    373377                        else
    374                             row->Set(name, Integer::NewFromUnsigned(val));
     378                            row->Set(name, Integer::NewFromUnsigned(val), ReadOnly);
    375379                    }
    376380                    else
     
    378382                        const int64_t val = (int64_t)(*it)[i];
    379383                        if (val<INT32_MIN || val>INT32_MAX)
    380                             row->Set(name, Number::New(val));
     384                            row->Set(name, Number::New(val), ReadOnly);
    381385                        else
    382                             row->Set(name, Integer::NewFromUnsigned(val));
     386                            row->Set(name, Integer::NewFromUnsigned(val), ReadOnly);
    383387                    }
    384388                    continue;
     
    389393                {
    390394                    if (uns)
    391                         row->Set(name, Integer::NewFromUnsigned((uint32_t)(*it)[i]));
     395                        row->Set(name, Integer::NewFromUnsigned((uint32_t)(*it)[i]), ReadOnly);
    392396                    else
    393                         row->Set(name, Integer::New((int32_t)(*it)[i]));
     397                        row->Set(name, Integer::New((int32_t)(*it)[i]), ReadOnly);
    394398                }
    395399
    396400                if (sql_type.find("BOOL")!=string::npos )
    397401                {
    398                     row->Set(name, Boolean::New((bool)(*it)[i]));
     402                    row->Set(name, Boolean::New((bool)(*it)[i]), ReadOnly);
    399403                    continue;
    400404                }
     
    404408                    ostringstream val;
    405409                    val << setprecision(7) << (float)(*it)[i];
    406                     row->Set(name, Number::New(stod(val.str())));
     410                    row->Set(name, Number::New(stod(val.str())), ReadOnly);
    407411                    continue;
    408412
     
    410414                if (sql_type.find("DOUBLE")!=string::npos)
    411415                {
    412                     row->Set(name, Number::New((double)(*it)[i]));
     416                    row->Set(name, Number::New((double)(*it)[i]), ReadOnly);
    413417                    continue;
    414418                }
     
    417421                    sql_type.find("TEXT")!=string::npos)
    418422                {
    419                     row->Set(name, String::New((const char*)(*it)[i]));
     423                    row->Set(name, String::New((const char*)(*it)[i]), ReadOnly);
    420424                    continue;
    421425                }
     
    423427                if (sql_type.find("TIMESTAMP")!=string::npos)
    424428                {
    425                     row->Set(name, Date::New(time_t(mysqlpp::Time((*it)[i]))*1000));
     429                    row->Set(name, Date::New(time_t(mysqlpp::Time((*it)[i]))*1000), ReadOnly);
    426430                    continue;
    427431                }
     
    429433                if (sql_type.find("DATETIME")!=string::npos)
    430434                {
    431                     row->Set(name, Date::New(time_t(mysqlpp::DateTime((*it)[i]))*1000));
     435                    row->Set(name, Date::New(time_t(mysqlpp::DateTime((*it)[i]))*1000), ReadOnly);
    432436                    continue;
    433437                }
     
    435439                if (sql_type.find(" DATE ")!=string::npos)
    436440                {
    437                     row->Set(name, Date::New(time_t((mysqlpp::Date)(*it)[i])*1000));
     441                    row->Set(name, Date::New(time_t((mysqlpp::Date)(*it)[i])*1000), ReadOnly);
    438442                    continue;
    439443                }
     
    441445            }
    442446
    443             ret->Set(Integer::New(irow++), row);
     447            ret->Set(Integer::NewFromUnsigned(irow++), row, ReadOnly);
    444448        }
     449
     450        if (irow>0)
     451            ret->Set(String::New("cols"), cols, ReadOnly);
    445452
    446453        return handle_scope.Close(ret);
     
    711718    v8::Locker::StartPreemption(10);
    712719    const bool rc = ExecuteFile(filename);
     720
     721    // -----
     722    // This is how an exit handler could look like, but there is no way to interrupt it
     723    // -----
     724    // Handle<Object> obj = Handle<Object>::Cast(context->Global()->Get(String::New("dim")));
     725    // if (!obj.IsEmpty())
     726    // {
     727    //     Handle<Value> onexit = obj->Get(String::New("onexit"));
     728    //     if (!onexit->IsUndefined())
     729    //         Handle<Function>::Cast(onexit)->NewInstance(0, NULL); // argc, argv
     730    //     // Handle<Object> result = Handle<Function>::Cast(onexit)->NewInstance(0, NULL); // argc, argv
     731    // }
     732
    713733    v8::Locker::StopPreemption();
    714734    //context->Exit();
     
    730750void InterpreterV8::JsStop()
    731751{
    732     v8::Locker locker;
     752    Locker locker;
    733753    //cout << "Terminate " << fThreadId << endl;
    734754    if (This->fThreadId>=0)
    735         v8::V8::TerminateExecution(This->fThreadId);
     755        V8::TerminateExecution(This->fThreadId);
    736756    //cout << "Terminate " << fThreadId << endl;
    737     v8::Unlocker unlocker;
     757    Unlocker unlocker;
    738758}
    739759
Note: See TracChangeset for help on using the changeset viewer.