IASEngine_CreateObject return error(0x10) | developer.brewmp.com IASEngine_CreateObject return error(0x10) | developer.brewmp.com

Developer

IASEngine_CreateObject return error(0x10)

Dear, All

Anyone who met the same issue: when create IASObject in AS Extension, just return 0x10.
sample code as below:

static int sqlExt_dbc_getData(sqlExt* pMe, IASArgs * piArgs)
{
IASObject * piObjDataSet = NULL;
IASArgs *piArgsSet = NULL;
int nErr = AEE_SUCCESS;
int nCount =0;
int nColumn =0;
int32 rqCount =0;

//Make sure AS call with 2 parameters, or query all rows, fix later.
nErr = IASArgs_GetAsObject(piArgs, 0, &piObjDataSet);
nErr |= IASArgs_GetAsInteger(piArgs, 1, &rqCount);

nErr |= dbc_IResultSet_GetColumnCount(pMe->pRltSet,&nColumn);
//dataview[i]= {value1,value2,...};
if(AEE_SUCCESS != nErr)
{
DBGPRINTF("[EX]:sqlExt_dbc_getData failed! Check the input parameter");
nErr = EFAILED;
return 0;
}

if(rqCount > 0)
{
nErr = IASEngine_CreateArgs(pMe->piEngine,rqCount, &piArgsSet);
}
else
{
DBGPRINTF("[EX]:sqlExt_dbc_getData failed! check your second param!");
nErr = EFAILED;
return 0;
}
dbc_IResultSet_Reset(pMe->pRltSet);
while(dbc_ROW == dbc_IResultSet_Next(pMe->pRltSet))
{
IASArgs *piArgsLocal = NULL;
IASObject *piObjectLocal = NULL;
//const char test[32] = {0};
int i;
dbc_ColDataType dType;
//Here will reture 0x10, if I Add an temp IASArgs * piTempArgs like, it also return error
//nErr |= IASEngine_CreateObject(pMe->piEngine,"temp",piTempArgs,&piObjectLocal); //-> return 0x10
nErr |= IASEngine_CreateObject(pMe->piEngine,"temp",NULL,&piObjectLocal);//-> return 0x10

nErr |= IASEngine_CreateArgs(pMe->piEngine,nColumn, &piArgsLocal);

for(i =0;i < nColumn;i++)
{
nErr |= dbc_IResultSet_GetColumnDataType(pMe->pRltSet,i,&dType);
if(dType == dbc_COL_DT_INTEGER)
{
int nCValue;
nErr |= dbc_IResultSet_GetInt(pMe->pRltSet,i,&nCValue);
nErr |= IASArgs_SetToInteger(piArgsLocal,i,nCValue);
}
else if(dType == dbc_COL_DT_FLOAT)
{
double nCValue;
nErr |= dbc_IResultSet_GetDouble(pMe->pRltSet,i,&nCValue);
nErr |= IASArgs_SetToInteger(piArgsLocal,i,(int)nCValue);
}
else if(dType == dbc_COL_DT_TEXT)
{
char *pCValue;
int lenReq;;
nErr = dbc_IResultSet_GetText(pMe->pRltSet, i, NULL, 0, &lenReq);
if(AEE_SUCCESS != nErr)
{
DBGPRINTF("dbc_IResultSet_GetText failed");
continue;
}
pCValue = (char *)MALLOC((uint32)lenReq);
if(pCValue == NULL)
{
DBGPRINTF("dbc_IResultSet_GetText failed");
continue;
}
nErr = dbc_IResultSet_GetText(pMe->pRltSet, i, pCValue, lenReq, &lenReq);
nErr |= IASArgs_SetToString(piArgsLocal,i,pCValue);

if(AEE_SUCCESS != nErr)
{
DBGPRINTF("dbc_IResultSet_GetText failed");
continue;
}

}
else
{
continue;
}

}
nErr |= IASObject_PushArgsToArray(piObjectLocal,piArgsLocal);
nErr |= IASArgs_SetToObject(piArgsSet,nCount,piObjectLocal);

//release piArgsLocal and piObjectLocal
IQI_RELEASEIF(piArgsLocal);
IQI_RELEASEIF(piObjectLocal);
if(AEE_SUCCESS == nErr)
{
nCount ++;
}
}

nErr |= IASObject_PushArgsToArray(piObjDataSet,piArgsSet);
//release piArgsSet
IQI_RELEASEIF(piArgsSet);
IQI_RELEASEIF(piObjDataSet);
return nCount;

Help!!!!!!!!!

The reason you are getting AEE_EBADITEM is because "temp" is not the name of a valid ActionScript class. You need to use a class name, e.g. "Array". If you want to just create a generic object, use "Object".
A few other points to consider about the code snippet below:
1. It's dangerous to use the "nErr |= foo()" style since you can forget to check for nErr != AEE_SUCCESS. For example, the following code could crash if IASEngine_CreateArgs() fails:
nErr |= IASEngine_CreateArgs(pMe->piEngine,nColumn, &piArgsLocal);
for(i =0;i < nColumn;i++)
{
nErr |= dbc_IResultSet_GetColumnDataType(pMe->pRltSet,i,&dType);
if(dType == dbc_COL_DT_INTEGER)
{
int nCValue;
nErr |= dbc_IResultSet_GetInt(pMe->pRltSet,i,&nCValue);
// the following could crash since IASEngine_CreateArgs() return code isn't checked
nErr |= IASArgs_SetToInteger(piArgsLocal,i,nCValue);
}
...

2. The code snippet contains the potential for reference leaks - there are several 'continue' statements that can be executed without properly releasing piArgsLocal and piObjectLocal.
Hope this helps,
Mike

The reason you are getting AEE_EBADITEM is because "temp" is not the name of a valid ActionScript class. You need to use a class name, e.g. "Array". If you want to just create a generic object, use "Object".
A few other points to consider about the code snippet below:
1. It's dangerous to use the "nErr |= foo()" style since you can forget to check for nErr != AEE_SUCCESS. For example, the following code could crash if IASEngine_CreateArgs() fails:
nErr |= IASEngine_CreateArgs(pMe->piEngine,nColumn, &piArgsLocal);
for(i =0;i < nColumn;i++)
{
nErr |= dbc_IResultSet_GetColumnDataType(pMe->pRltSet,i,&dType);
if(dType == dbc_COL_DT_INTEGER)
{
int nCValue;
nErr |= dbc_IResultSet_GetInt(pMe->pRltSet,i,&nCValue);
// the following could crash since IASEngine_CreateArgs() return code isn't checked
nErr |= IASArgs_SetToInteger(piArgsLocal,i,nCValue);
}
...

2. The code snippet contains the potential for reference leaks - there are several 'continue' statements that can be executed without properly releasing piArgsLocal and piObjectLocal.
Hope this helps,
Mike

Hi,Mike
Thanks for your kindly support. I still have two questions about AS Extension.
1.
[AS code]
var mydata = new Array(1,2,3); // new Array with initialize value
mydbc = new mySqlExt();
mydbc.openConnect("dbc.db","rwc");
mydbc.runQuery("Select * from mytable", "s");
...
mydbc.getNextRowData(mydata); //Here will get next row data from dbc.
[C ASE code]
IASObject * piObjtmp = NULL;
IASArgs_GetAsObject(piArgs, 0, &piObjtmp ); // get mydata pointer
//Fill piArgsLocal ...
IASObject_PushArgsToArray(piObjtmp ,piArgsLocal); //Put data to mydata( a, b,c)
Then I get the result:
mydata[0] = 1
mydata[1] = 2
mydata[2] = 3
mydata[3] = a
mydata[4] = b
mydata[5] = c
Actually I want update mydata from index 0,like
mydata[0] = a
mydata[1] = b
mydata[2] = c
Any other interfaces support :empty the Object before update use IASObject_PushArgsToArray ?
2.
I create a local IASObject in ASExtension. then put IASArgs to it like:
ret = IASObject_PushArgsToArray(piObjectLocal,piArgsLocal);
on my BrewMobilePlatform Simulator.
AMC : Success(ret = 0x0)
FlashLite 3.1 : Error(ret =0x1)
Why AMC and FlashLite are different?

Hi,Mike
Thanks for your kindly support. I still have two questions about AS Extension.
1.
[AS code]
var mydata = new Array(1,2,3); // new Array with initialize value
mydbc = new mySqlExt();
mydbc.openConnect("dbc.db","rwc");
mydbc.runQuery("Select * from mytable", "s");
...
mydbc.getNextRowData(mydata); //Here will get next row data from dbc.
[C ASE code]
IASObject * piObjtmp = NULL;
IASArgs_GetAsObject(piArgs, 0, &piObjtmp ); // get mydata pointer
//Fill piArgsLocal ...
IASObject_PushArgsToArray(piObjtmp ,piArgsLocal); //Put data to mydata( a, b,c)
Then I get the result:
mydata[0] = 1
mydata[1] = 2
mydata[2] = 3
mydata[3] = a
mydata[4] = b
mydata[5] = c
Actually I want update mydata from index 0,like
mydata[0] = a
mydata[1] = b
mydata[2] = c
Any other interfaces support :empty the Object before update use IASObject_PushArgsToArray ?
2.
I create a local IASObject in ASExtension. then put IASArgs to it like:
ret = IASObject_PushArgsToArray(piObjectLocal,piArgsLocal);
on my BrewMobilePlatform Simulator.
AMC : Success(ret = 0x0)
FlashLite 3.1 : Error(ret =0x1)
Why AMC and FlashLite are different?

For #1, there is no way to remove elements from an array (at least from the ASE itself). Remember that initializing the Array object in ActionScript with values is the equivalent to calling IASObject_PushArgsToArray(), so the behavior you are seeing is expected (the values added by your ASE get added after the ones in the initializer).
Can you refactor your code such that you call the ASE first, then add other values in ActionScript if the ASE hasn't added them?
For #2, is it the same code snippet as in #1 that is failing when using FL3? Or is the code different? And what version of the SDK are you using?
Thanks,
Mike

For #1, there is no way to remove elements from an array (at least from the ASE itself). Remember that initializing the Array object in ActionScript with values is the equivalent to calling IASObject_PushArgsToArray(), so the behavior you are seeing is expected (the values added by your ASE get added after the ones in the initializer).
Can you refactor your code such that you call the ASE first, then add other values in ActionScript if the ASE hasn't added them?
For #2, is it the same code snippet as in #1 that is failing when using FL3? Or is the code different? And what version of the SDK are you using?
Thanks,
Mike

Hi Derek,
An update on #2 - we have been able to duplicate the failure in FlashLite on our end. We will try to work with Adobe to fix this, but in the mean time a work-around is to add the args to the array one at a time.
Hope this helps,
Mike

Hi Derek,
An update on #2 - we have been able to duplicate the failure in FlashLite on our end. We will try to work with Adobe to fix this, but in the mean time a work-around is to add the args to the array one at a time.
Hope this helps,
Mike