Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007957opensim[REGION] Scripting Enginepublic2016-07-05 03:372016-08-03 14:27
ReporterLotek 
Assigned ToBlueWall 
PrioritynormalSeverityminorReproducibilityalways
Statuspatch includedResolutionopen 
PlatformLinuxOSUbuntuOS Version14.04LTS
Product Versionmaster (dev code) 
Target VersionFixed in Version 
Summary0007957: Using LSL constants in a list with llList2Json returns JSON_INVALID
DescriptionUsing LSL constants such as INVENTORY_BODYPART (which is defined as 13) like this:
llList2Json(JSON_ARRAY, [INVENTORY_BODYPART]) will return JSON_INVALID

See code to reproduce
Steps To Reproducedefault
{
    state_entry()
    {
        list list_LSLConstantList = [
            CAMERA_FOCUS_LOCKED, // 22
            VEHICLE_ANGULAR_MOTOR_DIRECTION, // 18
            INVENTORY_CLOTHING // 5
        ];

        integer MY_CAMERA_FOCUS_LOCKED = 22;
        integer MY_VEHICLE_ANGULAR_MOTOR_DIRECTION = 18;
        integer MY_INVENTORY_CLOTHING = 5;

        list list_MyConstantList = [
            MY_CAMERA_FOCUS_LOCKED, // 22
            MY_VEHICLE_ANGULAR_MOTOR_DIRECTION, // 18
            MY_INVENTORY_CLOTHING // 5
        ];

        string sJsonArray;

        sJsonArray = llList2Json(JSON_ARRAY, list_LSLConstantList);
        llOwnerSay("Json test with list_LSLConstantList: "+sJsonArray);
        llOwnerSay("CSV test with list_LSLConstantList: "+llList2CSV(list_LSLConstantList));

        sJsonArray = llList2Json(JSON_ARRAY, list_MyConstantList);
        llOwnerSay("Json test with list_MyConstantList: "+sJsonArray);
        llOwnerSay("CSV test with list_MyConstantList: "+llList2CSV(list_MyConstantList));
    }
}
TagsNo tags attached.
Git Revision or version number
Run Mode Grid (1 Region per Sim)
Physics EngineBulletSim
Script Engine
EnvironmentMono / Linux64
Mono VersionOther
ViewerCool VL Viewer
Attached Filespatch file icon 0001-Provide-tests-for-native-datatypes-where-LSL-Constan.patch [^] (2,528 bytes) 2016-08-03 07:51 [Show Content]

- Relationships

-  Notes
(0030972)
BlueWall (administrator)
2016-08-02 13:56

default
{
    state_entry()
    {
        llSay(0, "Script running");
    }
    
    touch_start(integer det)
    {
        list list_LSLConstantList = [
            CAMERA_FOCUS_LOCKED, // 22
            VEHICLE_ANGULAR_MOTOR_DIRECTION, // 19
            INVENTORY_CLOTHING // 5
        ];
        
        list list_LSLIntegerList = [
            22,
            19,
            5
        ];
        
        list list_LSLStringList = [
            "a",
            "b",
            "c"
        ];
        
        string sJsonArray;
        
        sJsonArray = llList2Json(JSON_ARRAY, list_LSLConstantList);
        llOwnerSay("Json test with list_LSLConstantList: "+sJsonArray);
        
        sJsonArray = llList2Json(JSON_ARRAY, list_LSLIntegerList);
        llOwnerSay("Json test with list_LSLIntegerList: "+sJsonArray);
        
        sJsonArray = llList2Json(JSON_ARRAY, list_LSLStringList);
        llOwnerSay("Json test with list_LSLStringList: "+sJsonArray);
    }
}

Script running
[13:39] Constant Test: Json test with list_LSLConstantList: [22,19,5]
[13:39] Constant Test: Json test with list_LSLIntegerList: [22,19,5]
[13:39] Constant Test: Json test with list_LSLStringList: ["a","b","c"]

I fixed some another issue with these functions, so took care of this as well. I will test it a little further before committing the work.
(0030975)
BlueWall (administrator)
2016-08-02 14:25

Made sure to catch instances of the constants being used in Json objects as well ...

default
{
    state_entry()
    {
        llSay(0, "Script running");
    }
    
    touch_start(integer det)
    {
        list list_LSLConstantList = [
            CAMERA_FOCUS_LOCKED, // 22
            VEHICLE_ANGULAR_MOTOR_DIRECTION, // 19
            INVENTORY_CLOTHING // 5
        ];
        
        list list_LSLIntegerList = [
            22,
            19,
            5
        ];
        
        list list_LSLStringList = [
            "a",
            "b",
            "c"
        ];
        
        string sJsonArray;
        string sJsonObject;
        
        sJsonArray = llList2Json(JSON_ARRAY, list_LSLConstantList);
        llOwnerSay("Json test with list_LSLConstantList: "+sJsonArray);
        
        sJsonArray = llList2Json(JSON_ARRAY, list_LSLIntegerList);
        llOwnerSay("Json test with list_LSLIntegerList: "+sJsonArray);
        
        sJsonArray = llList2Json(JSON_ARRAY, list_LSLStringList);
        llOwnerSay("Json test with list_LSLStringList: "+sJsonArray);
        
        list list_LSLConstantDirectory = [
            "CAMERA_FOCUS_LOCKED", CAMERA_FOCUS_LOCKED,
            "VEHICLE_ANGULAR_MOTOR_DIRECTION", VEHICLE_ANGULAR_MOTOR_DIRECTION,
            "INVENTORY_CLOTHING", INVENTORY_CLOTHING
        ];
        
        list list_JsonObjectList = [
            "lsl_constant", llList2Json(JSON_ARRAY, list_LSLConstantList),
            "lsl_integer", llList2Json(JSON_ARRAY, list_LSLIntegerList),
            "lsl_string", llList2Json(JSON_ARRAY, list_LSLStringList),
            "lsl_constant_directory", llList2Json(JSON_OBJECT, list_LSLConstantDirectory)
        ];
        
        
        sJsonArray = llList2Json(JSON_OBJECT, list_JsonObjectList);
        llOwnerSay("Json test with list_LSLStringList: "+sJsonArray);
    }
}

Script running
[14:09] Constant Test: Json test with list_LSLConstantList: [22,19,5]
[14:09] Constant Test: Json test with list_LSLIntegerList: [22,19,5]
[14:09] Constant Test: Json test with list_LSLStringList: ["a","b","c"]
[14:09] Constant Test: Json test with list_LSLStringList: {"lsl_constant":[22,19,5],"lsl_integer":[22,19,5],"lsl_string":["a","b","c"],"lsl_constant_directory":{"CAMERA_FOCUS_LOCKED":22,"VEHICLE_ANGULAR_MOTOR_DIRECTION":19,"INVENTORY_CLOTHING":5}}
(0030978)
BlueWall (administrator)
2016-08-03 08:17

See attached
(0030979)
UbitUmarov (administrator)
2016-08-03 14:27

22:25] <cia-opensim> opensim: jamesh * re15dc7211311 OpenSim/Region/ScriptEngine/Shared/Api/Implementation (LSL_Api.cs):
[22:25] <cia-opensim> Provide tests for native datatypes where LSL Constants are used in lists as JSON elements. Namely: LSL_Float/double, LSL_String/string, LSL_Integer/int. Fixes http://opensimulator.org/mantis/view.php?id=7957 [^]
[22:25] <cia-opensim>
[22:25] <cia-opensim> Signed-off-by: UbitUmarov <ajlduarte@sapo.pt>

patch applied on master

- Issue History
Date Modified Username Field Change
2016-07-05 03:37 Lotek New Issue
2016-08-02 13:54 BlueWall Assigned To => BlueWall
2016-08-02 13:54 BlueWall Status new => assigned
2016-08-02 13:56 BlueWall Note Added: 0030972
2016-08-02 14:25 BlueWall Note Added: 0030975
2016-08-03 07:51 BlueWall File Added: 0001-Provide-tests-for-native-datatypes-where-LSL-Constan.patch
2016-08-03 08:17 BlueWall Note Added: 0030978
2016-08-03 08:17 BlueWall Status assigned => patch included
2016-08-03 14:27 UbitUmarov Note Added: 0030979


Copyright © 2000 - 2012 MantisBT Group
Powered by Mantis Bugtracker