Exemplo n.º 1
0
/* arg0: Record constructed over the appropriate column list
   arg1: Array of field names
   arg2: Array of typeConverters 

   Returns: a constructor function that can be used to create native-backed 
   objects
*/
Handle<Value> getValueObjectConstructor(const Arguments &args) {
  DEBUG_MARKER(UDEB_DEBUG);
  HandleScope scope;
  Local<FunctionTemplate> ft = FunctionTemplate::New();
  Local<ObjectTemplate> inst = ft->InstanceTemplate();
  inst->SetInternalFieldCount(2);

  /* Initialize the mapData */
  Local<Object> mapData = Object::New();
  
  /* Store the record in the mapData at 0 */
  mapData->Set(0, args[0]);

  /* Build the ColumnHandlers and store them in the mapData at 1 */
  const Record * record = unwrapPointer<const Record *>(args[0]->ToObject());
  const uint32_t ncol = record->getNoOfColumns();
  ColumnHandlerSet *columnHandlers = new ColumnHandlerSet(ncol);
  for(unsigned int i = 0 ; i < ncol ; i++) {
    const NdbDictionary::Column * col = record->getColumn(i);
    size_t offset = record->getColumnOffset(i);
    ColumnHandler * handler = columnHandlers->getHandler(i);
    handler->init(col, offset, args[2]->ToObject()->Get(i));
  }
  Local<Object> jsHandlerSet = columnHandlerSetEnvelope.newWrapper();
  wrapPointerInObject<ColumnHandlerSet *>(columnHandlers, 
                                          columnHandlerSetEnvelope,
                                          jsHandlerSet);
  mapData->Set(1, jsHandlerSet);

  /* Create accessors for the mapped fields in the instance template.
     AccessorInfo.Data() for the accessor will hold the field number.
  */
  Local<Object> jsFields = args[1]->ToObject();
  for(unsigned int i = 0 ; i < ncol; i++) {
    Handle<String> fieldName = jsFields->Get(i)->ToString();
    inst->SetAccessor(fieldName, nroGetter, nroSetter, Number::New(i),
                      DEFAULT, DontDelete);
  }

  /* The generic constructor is the CallHandler */
  ft->SetCallHandler(nroConstructor, Persistent<Object>::New(mapData));

  return scope.Close(ft->GetFunction());
}
Exemplo n.º 2
0
void DBOperationHelper_initOnLoad(Handle<Object> target) {
  DEBUG_MARKER(UDEB_DETAIL);
  DEFINE_JS_FUNCTION(target, "DBOperationHelper", DBOperationHelper);

  Persistent<Object> OpHelper = Persistent<Object>(Object::New());
  target->Set(Persistent<String>(String::NewSymbol("OpHelper")), OpHelper);
  DEFINE_JS_INT(OpHelper, "row_buffer",  HELPER_ROW_BUFFER);
  DEFINE_JS_INT(OpHelper, "key_buffer",  HELPER_KEY_BUFFER);
  DEFINE_JS_INT(OpHelper, "row_record",  HELPER_ROW_RECORD);
  DEFINE_JS_INT(OpHelper, "key_record",  HELPER_KEY_RECORD);
  DEFINE_JS_INT(OpHelper, "lock_mode",   HELPER_LOCK_MODE);
  DEFINE_JS_INT(OpHelper, "column_mask", HELPER_COLUMN_MASK);
  DEFINE_JS_INT(OpHelper, "value_obj",   HELPER_VALUE_OBJECT);

  Persistent<Object> LockModes = Persistent<Object>(Object::New());
  target->Set(Persistent<String>(String::NewSymbol("LockModes")), LockModes);
  DEFINE_JS_INT(LockModes, "EXCLUSIVE", NdbOperation::LM_Exclusive);
  DEFINE_JS_INT(LockModes, "SHARED", NdbOperation::LM_Read);
  DEFINE_JS_INT(LockModes, "COMMITTED", NdbOperation::LM_CommittedRead);
}
Exemplo n.º 3
0
void DBOperationHelper_initOnLoad(Handle<Object> target) {
  DEBUG_MARKER(UDEB_DETAIL);
  DEFINE_JS_FUNCTION(target, "DBOperationHelper", DBOperationHelper);
  Local<Object> OpHelper = Object::New(Isolate::GetCurrent());
  Local<Object> LockModes = Object::New(Isolate::GetCurrent());

  target->Set(NEW_SYMBOL("OpHelper"), OpHelper);
  DEFINE_JS_INT(OpHelper, "row_buffer",   HELPER_ROW_BUFFER);
  DEFINE_JS_INT(OpHelper, "key_buffer",   HELPER_KEY_BUFFER);
  DEFINE_JS_INT(OpHelper, "row_record",   HELPER_ROW_RECORD);
  DEFINE_JS_INT(OpHelper, "key_record",   HELPER_KEY_RECORD);
  DEFINE_JS_INT(OpHelper, "lock_mode",    HELPER_LOCK_MODE);
  DEFINE_JS_INT(OpHelper, "column_mask",  HELPER_COLUMN_MASK);
  DEFINE_JS_INT(OpHelper, "value_obj",    HELPER_VALUE_OBJECT);
  DEFINE_JS_INT(OpHelper, "opcode",       HELPER_OPCODE);
  DEFINE_JS_INT(OpHelper, "is_value_obj", HELPER_IS_VO);
  DEFINE_JS_INT(OpHelper, "blobs",        HELPER_BLOBS);
  DEFINE_JS_INT(OpHelper, "is_valid",     HELPER_IS_VALID);

  target->Set(NEW_SYMBOL("LockModes"), LockModes);
  DEFINE_JS_INT(LockModes, "EXCLUSIVE", NdbOperation::LM_Exclusive);
  DEFINE_JS_INT(LockModes, "SHARED", NdbOperation::LM_Read);
  DEFINE_JS_INT(LockModes, "COMMITTED", NdbOperation::LM_CommittedRead);
}
Exemplo n.º 4
0
Error
_dxfAsyncRender (dxObject r, Camera c, char *obsolete, char *displayString)
{
    Private 	    cacheObject = NULL;
    tdmChildGlobalP   globals = NULL;
    char*		    cacheId = NULL;
    tdmParsedFormatT *pFormat = NULL;
    dxObject	   attr;


    ENABLE_DEBUG();
    DEBUG_MARKER("_dxfAsyncRender ENTRY");
    ENTRY(("_dxfAsyncRender (0x%x, 0x%x, \"%s\", \"%s\")",
           r, c, obsolete, displayString));

# if defined(DEBUG)

    if(DXGetAttribute(r, "force env var")) {
        char *Buff;

        if(DXExtractString(DXGetAttribute(r, "force env var"), &Buff)) {
            PRINT(("Putting Variable %s\n", Buff));
            putenv(Buff);
        }
    }
#  endif


    if (!c && !DXGetImageBounds(r,NULL,NULL,NULL,NULL))
        goto error;


    /* get host and window name from display string, fill in the cache id */
    if (!(pFormat = _tdmParseDisplayString (displayString, &cacheId)))
        goto error;

    /* validate the display string */
    if (!(_validateDisplayString(pFormat, 1)))
        goto error ;

    /* Get a pointer to the global data, out of the cache or create a new one. */
    if((cacheObject = (Private) DXGetCacheEntry(cacheId, 0, 0)) != NULL) {
        globals = (tdmChildGlobalP) DXGetPrivateData(cacheObject) ;
#if defined(DX_NATIVE_WINDOWS)
        /*
         * Now lock globals so that rendering doesn't occur in another
         * thread until the setup is done.  If we create a globals structure 
         * here, the lock is created in CreateRenderModule, and its created 
         * owned.
         */
        {
            DEFGLOBALDATA(globals);
            if (DXWaitForSignal(1, &LOCK) == WAIT_TIMEOUT)
                goto error;
        }
#endif

    } else {
        if(!(globals = (tdmChildGlobalP)_dxfCreateRenderModule(pFormat)))
            return ERROR;

        /* save globals in cache; call _dxfEndRenderModule when cache deleted */
        if(!(cacheObject = (Private)
                           DXNewPrivate((Pointer) globals,
                                        (Error (*)(Pointer))_dxfEndRenderModule))) {
            /* Can't cache tdm globals */
            DXErrorGoto (ERROR_INTERNAL, "#13290");
        }

        /* Create a reference so this doesn't get deleted while I'm using it */
        DXReference ((Pointer)cacheObject);

        /* associate cacheId with cacheObject, set to permanent status */
        if(! DXSetCacheEntry((Pointer)cacheObject, CACHE_PERMANENT,
                             cacheId, 0, 0)) {
            /* Can't set cache entry for tdm globals */
            DXErrorGoto (ERROR_INTERNAL, "#13300") ;
        }

        /* save the cacheId to allow cache deletion upon DestroyNotify event */
        if(! (globals->cacheId = tdmAllocate(strlen(cacheId)+1))) {
            DXErrorGoto (ERROR_NO_MEMORY, "") ;
        }

        /* save cacheId */
        strcpy(globals->cacheId,cacheId) ;
    }

    /* Now that we have a global store, use it */
    {
        int needInit = 0;
        DEFGLOBALDATA(globals);

        if (!OBJECT || (OBJECT && OBJECT_TAG != DXGetObjectTag(r)))
        {
            if (OBJECT)
                DXDelete(OBJECT);

            OBJECT = DXReference(r);
            OBJECT_TAG = DXGetObjectTag(r);
            needInit = 1;
        }

        if (!CAMERA || (CAMERA && CAMERA_TAG != DXGetObjectTag((dxObject)c)))
        {
            if (CAMERA)
                DXDelete(CAMERA);

            CAMERA = DXReference((dxObject)c);
            CAMERA_TAG = DXGetObjectTag((dxObject)c);
            needInit = 1;
        }

        _dxfInitializeStereoSystemMode(globals, DXGetAttribute(r, "stereo system mode"));
        _dxfInitializeStereoCameraMode(globals, DXGetAttribute(r, "stereo camera mode"));

        if(CAMERA && needInit)
        {
            if(!_dxfInitRenderObject(LWIN)) {
                /* unable to set up for rendering */
                DXErrorGoto(ERROR_NO_HARDWARE_RENDERING, "#13350");
            }
        }

        /* Handle X events and redraw the image */
#if !defined(DX_NATIVE_WINDOWS)
        if(! _dxfProcessEvents (-1, globals, 1))
            goto error;
#endif

    }

    if ((attr = DXGetAttribute((dxObject)c, "camera interaction mode")) == NULL)
        if ((attr = DXGetAttribute(r, "object interaction mode")) == NULL)
            attr = DXGetAttribute(r, "interaction mode");

    if (attr) {
        Array amode;
        int mode;

        if (DXGetObjectClass(attr) == CLASS_GROUP) {
            if (NULL == (amode = (Array)DXGetMember((Group)attr, "mode")))
                DXErrorGoto(ERROR_DATA_INVALID,
                            "interaction mode args group must contain a member named \"mode\"");
        } else if (DXGetObjectClass(attr) != CLASS_ARRAY) {
            DXErrorGoto(ERROR_DATA_INVALID,
                        "interaction mode args must be a group or array");
        } else
            amode = (Array)attr;

        if (DXExtractInteger((dxObject)amode, &mode))
            _dxfSetInteractionMode(globals, mode, attr);
        else
            DXErrorGoto(ERROR_DATA_INVALID,
                        "interaction mode attribute must be an integer");
    } else
        _dxfSetInteractionMode(globals, 11, NULL);

    if(cacheObject) {
        /* delete the working reference  */
        DXDelete((Pointer)cacheObject) ;
        cacheObject = NULL;
    }

    if (cacheId)
        tdmFree(cacheId);
    if (pFormat)
        _dxfDeleteParsedDisplayString(pFormat);

    EXIT(("OK"));
    DEBUG_MARKER("_dxfAsyncRender EXIT");
    return OK ;

error:

    if(cacheObject) {
        /* delete the working reference  */
        DXDelete((Pointer)cacheObject) ;
        cacheObject = NULL;
    }

    if (cacheId)
        tdmFree(cacheId);
    if (pFormat)
        _dxfDeleteParsedDisplayString(pFormat);

    EXIT(("ERROR"));
    DEBUG_MARKER("_dxfAsyncRender EXIT");
    return ERROR ;
}
Exemplo n.º 5
0
Error
_dxfRedrawInActiveContext (dxObject r, Camera c, char *displayString)
{
    Private 	    cacheObject = NULL;
    char*		    cacheId = NULL;

	/* Need to build up the globals then call _dxfDraw() */
	tdmChildGlobalP globals = NULL;
    tdmParsedFormatT *pFormat = NULL;

	    if (!c && !DXGetImageBounds(r,NULL,NULL,NULL,NULL))
        goto error;


    /* get host and window name from display string, fill in the cache id */
    if (!(pFormat = _tdmParseDisplayString (displayString, &cacheId)))
        goto error;

    /* validate the display string */
    if (!(_validateDisplayString(pFormat, 1)))
        goto error ;

    /* Get a pointer to the global data, out of the cache or create a new one. */
    if((cacheObject = (Private) DXGetCacheEntry(cacheId, 0, 0)) != NULL) {
        globals = (tdmChildGlobalP) DXGetPrivateData(cacheObject) ;

        /* Create a reference so this doesn't get deleted while I'm using it */
        DXReference ((Pointer)cacheObject);

        /* associate cacheId with cacheObject, set to permanent status */
        if(! DXSetCacheEntry((Pointer)cacheObject, CACHE_PERMANENT,
                             cacheId, 0, 0)) {
            /* Can't set cache entry for tdm globals */
            DXErrorGoto (ERROR_INTERNAL, "#13300") ;
        }

        /* save the cacheId to allow cache deletion upon DestroyNotify event */
        if(! (globals->cacheId = tdmAllocate(strlen(cacheId)+1))) {
            DXErrorGoto (ERROR_NO_MEMORY, "") ;
        }

        /* save cacheId */
        strcpy(globals->cacheId,cacheId) ;
    } else {
    	DXErrorGoto(ERROR_INTERNAL, "object must be previously rendered");
    }

    /* Now that we have a global store, use it */
    {
        int needInit = 0;
        DEFGLOBALDATA(globals);

        if (!OBJECT || (OBJECT && OBJECT_TAG != DXGetObjectTag(r)))
        {
            if (OBJECT)
                DXDelete(OBJECT);

            OBJECT = DXReference(r);
            OBJECT_TAG = DXGetObjectTag(r);
            needInit = 1;
        }

        if (!CAMERA || (CAMERA && CAMERA_TAG != DXGetObjectTag((dxObject)c)))
        {
            if (CAMERA)
                DXDelete(CAMERA);

            CAMERA = DXReference((dxObject)c);
            CAMERA_TAG = DXGetObjectTag((dxObject)c);
            needInit = 1;
        }

        if(CAMERA && needInit)
        {
            if(!_dxfInitRenderObject(LWIN)) {
                /* unable to set up for rendering */
                DXErrorGoto(ERROR_NO_HARDWARE_RENDERING, "#13350");
            }
        }
    }

    {
	DEFWINDATA(&(globals->win));        
    _dxfDrawMonoInCurrentContext(globals, OBJECT, CAMERA, 1);
    }

    if(cacheObject) {
        /* delete the working reference  */
        DXDelete((Pointer)cacheObject) ;
        cacheObject = NULL;
    }

    if (cacheId)
        tdmFree(cacheId);
    if (pFormat)
        _dxfDeleteParsedDisplayString(pFormat);


	return OK;

error:

    if(cacheObject) {
        /* delete the working reference  */
        DXDelete((Pointer)cacheObject) ;
        cacheObject = NULL;
    }

    if (cacheId)
        tdmFree(cacheId);
    if (pFormat)
        _dxfDeleteParsedDisplayString(pFormat);

    EXIT(("ERROR"));
    DEBUG_MARKER("_dxfAsyncRender EXIT");
    return ERROR ;
}
Exemplo n.º 6
0
DBTransactionContext::~DBTransactionContext() {
  DEBUG_MARKER(UDEB_DETAIL);
  jsWrapper.Dispose();
}
Exemplo n.º 7
0
TransactionImpl::~TransactionImpl() {
  DEBUG_MARKER(UDEB_DETAIL);
  jsWrapper.Dispose();
}
Exemplo n.º 8
0
SessionImpl::~SessionImpl() {
  DEBUG_MARKER(UDEB_DETAIL);
  delete ndb;
}