1 /*
2 * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 * Copyright (C) 2004-2006 - INRIA - Fabrice Leray
4 * Copyright (C) 2006 - INRIA - Allan Cornet
5 * Copyright (C) 2006 - INRIA - Jean-Baptiste Silvy
6 * Copyright (C) 2010 - DIGITEO - Manuel Juliachs
7 * Copyright (C) 2011 - DIGITEO - Vincent Couvert
8 *
9 * Copyright (C) 2012 - 2016 - Scilab Enterprises
10 *
11 * This file is hereby licensed under the terms of the GNU GPL v2.0,
12 * pursuant to article 5.3.4 of the CeCILL v.2.1.
13 * This file was originally licensed under the terms of the CeCILL v2.1,
14 * and continues to be available under such terms.
15 * For more information, see the COPYING file which you should have received
16 * along with this program.
17 *
18 */
19
20 /*------------------------------------------------------------------------*/
21 /* file: get_user_data_property.c */
22 /* desc : function to retrieve in Scilab the user_data field of */
23 /* a handle */
24 /*------------------------------------------------------------------------*/
25
26 #include <stdio.h>
27 #include "getHandleProperty.h"
28 #include "GetProperty.h"
29 #include "returnProperty.h"
30 #include "sci_malloc.h"
31 #include "api_scilab.h"
32
33 #include "getGraphicObjectProperty.h"
34 #include "graphicObjectProperties.h"
35 #include "setGraphicObjectProperty.h"
36
37
38 /*------------------------------------------------------------------------*/
get_user_data_property(void * _pvCtx,int iObjUID)39 void* get_user_data_property(void* _pvCtx, int iObjUID)
40 {
41 int iUserDataSize = 0;
42 int *piUserDataSize = &iUserDataSize;
43 int *piUserData = NULL;
44
45 void* status = NULL;
46
47 getGraphicObjectProperty(iObjUID, __GO_USER_DATA_SIZE__, jni_int, (void **)&piUserDataSize);
48
49 getGraphicObjectProperty(iObjUID, __GO_USER_DATA__, jni_int_vector, (void **)&piUserData);
50
51 if ((piUserData == NULL) || (piUserDataSize == NULL))
52 {
53 int iSize = sizeof(void*) / sizeof(int);
54 status = sciReturnEmptyMatrix();
55 //force user_data to have something and not create each time a new variable
56 setGraphicObjectProperty(iObjUID, __GO_USER_DATA__, &status, jni_int_vector, iSize);
57 increaseValRef(_pvCtx, (int*)status);
58 }
59 else
60 {
61 status = sciReturnUserData(piUserData, iUserDataSize);
62 }
63
64 return status;
65 }
66
67 /*------------------------------------------------------------------------*/
68