This non-provisional application is based on Japanese Patent Application No. 2022-110523 filed on Jul. 8, 2022 with the Japan Patent Office, the entire contents of which are hereby incorporated by reference.
The present disclosure relates to an application program development environment and more specifically to data serialization and deserialization.
Processing for writing out (perpetuating) data managed by a running application program to a storage which is referred to as serialization has conventionally been known. Serialized (or later serialized) data is referred to as asset data.
For example, a serialization and data processing apparatus capable of readily achieving storage/recovery of classes and instances of a plurality of versions has been known.
In serialization of an object managed by a running application program, data having a data structure corresponding a type of the object is written out. In a stage of development of the application program, the type of the object may be changed. When the type of the object is changed, it is difficult to use again the previously written-out data in application software.
One object of the present disclosure is to implement serialization and/or deserialization processing not affected by change or the like of a type of a target object or the like.
(Configuration 1) According to one embodiment, a development program for development of an application program with a programming language in which an object is generated based on a type is provided. The development program causes a computer of an information processing apparatus to function as an identification module that identifies a type definition in a source code of the application program and a code addition module that generates a first code that generates an intermediate object for asset data corresponding to each of objects generated based on the identified type definition and adds the generated first code to the source code of the application program. The intermediate object is stored as the asset data.
According to Configuration 1, the first code for generation of the intermediate object corresponding to the object generated based on the type definition in the source code of the application program can automatically be generated. The intermediate object can be stored as the asset data. Since the intermediate object different from the object of the application program can thus be used, serialization and/or deserialization processing not affected by change or the like of the type of the target object or the like can be implemented.
(Configuration 2) In the development program described in Configuration 1, the code addition module may add a second code which is the type definition of the intermediate object to the source code of the application program. The intermediate object may be generated in accordance with the type definition of the second code. According to Configuration 2, since the type of the intermediate object can be defined with the use of the second code, the intermediate object in accordance with the asset data to be outputted can be generated.
(Configuration 3) In the development program described in Configuration 1 or 2, in the second code, the type of the intermediate object may be defined independently of the type definition in a corresponding source code. According to Configuration 3, the type of the intermediate object can be independent of the type of the object of the application program. Therefore, even when the type of the object of the application program may be changed, the asset data cannot be affected thereby.
(Configuration 4) In the development program described in any one of Configurations 1 to 3, in the second code, the type of the intermediate object may be defined to inherit a common type definition. According to Configuration 4, the type definition of the intermediate object can be simplified by inclusion of a definition of a common member function or the like in the common type definition.
(Configuration 5) In the development program described in any one of Configurations 1 to 4, the second code may include a code for performing processing for calling processing for holding in the intermediate object, a value obtained by a function designated in advance or a value designated in advance. According to Configuration 5, not only the data held by the object of the application is held as it is in the intermediate object, but a value obtained by the function designated in advance or a value designated in advance can be held in the intermediate object. Therefore, flexibility and/or convenience of program development can be improved.
(Configuration 6) In the development program described in any one of Configurations 1 to 5, the second code may include a code for performing processing for calling processing for passing a value of a property held in the intermediate object to a function designated in advance. According to Configuration 6, the value of the property held in the intermediate object can be passed to the function designated in advance. For example, by designation of the function that sets data for the object of an application as the function designated in advance, setting of the data from the intermediate object to the object of the application can readily be made.
(Configuration 7) In the development program described in any one of Configurations 1 to 6, the second code may include a code for performing processing for calling processing for outputting a value of a property of the intermediate object in a predetermined format for each type of the intermediate object. According to Configuration 7, since processing for outputting the value of the property held in the intermediate object in a predetermined format can be called from the intermediate object, processing for writing out the asset data in the application program or the like can readily be implemented.
(Configuration 8) In the development program according to any one of Configurations 1 to 7, the identification module may extract, from the source code of the application program, a predetermined description including a first description that designates a name of a property and a second description that designates a function or a variable for obtaining a value. According to Configuration 8, the first code can be generated based on the first description and the second description.
(Configuration 9) In the development program according to any one of Configurations 1 to 8, the code addition module may further add a third code that performs processing for holding a history of the intermediate object to the source code of the application program. According to Configuration 9, such an edition operation as Undo or Redo onto the value of the property held in the intermediate object can be performed.
(Configuration 10) According to another embodiment, an information processing system that develops an application program with a programming language in which an object is generated based on a type is provided. The information processing system includes an identification module that identifies a type definition in a source code of the application program and a code addition module that generates a first code that generates an intermediate object for asset data corresponding to each of objects generated based on the identified type definition and adds the generated first code to the source code of the application program. The intermediate object is stored as the asset data.
(Configuration 11) According to another embodiment, an information processing apparatus including one or more processors and a memory where a program is stored is provided. The information processing apparatus is configured to perform, by execution of the program by the one or more processors, identifying a type definition in a source code of an application program described in a programming language in which an object is generated based on a type and generating a first code that generates an intermediate object for asset data corresponding to each of objects generated based on the identified type definition and adding the generated first code to the source code of the application program. The intermediate object is stored as the asset data.
(Configuration 12) According to another embodiment, an information processing method performed by a computer for development of an application program with a programming language in which an object is generated based on a type is provided. The information processing method includes identifying a type definition in a source code of the application program described in the programming language based on a type and generating a first code that generates an intermediate object for asset data corresponding to each of objects generated based on the identified type definition and adding the generated first code to the source code of the application program. The intermediate object is stored as the asset data.
The foregoing and other objects, features, aspects and advantages of the present invention will become more apparent from the following detailed description of the present invention when taken in conjunction with the accompanying drawings.
The present embodiment will be described in detail with reference to the drawings. The same or corresponding elements in the drawings have the same reference characters allotted and description thereof will not be repeated.
[A. Overview]
In the present embodiment, a development program and an information processing apparatus for development of an application program with a programming language (typically, an object-oriented language) in which an object (instance) is generated based on a type are exemplified. A source code of the application program is described in the programming language in which the object is generated based on the type.
The information processing apparatus according to the present embodiment does not output data held by the object (instance) generated by the application program (run-time program) in a type definition of that object in serialization of the data but additionally generates a code such that asset data can be outputted in a data structure independent of the type definition. The application program that is developed may be a game program, a practical application program, or a development tool program.
According to this configuration, asset data of any data structure (type) can be outputted independently of the type definition of the object to be serialized, and hence flexibility and/or convenience of program development can be improved. For example, even when the type definition is changed (a member is added or deleted, a name of a property is changed, or a data type of a property is changed) in the middle of development of the application program or even when an expression of a type is different depending on a program environment, outputted asset data can be used for general purposes. In addition, data that is not present in a type of an object to be serialized or data of a data type different from that of an object to be serialized can be included in the asset data.
[B. Exemplary Hardware Configuration]
Any exemplary hardware configuration may be adopted in the information processing apparatus according to the present embodiment. The information processing apparatus may be implemented by a single computer that executes one or more programs. The computer may be stationary or portable. Alternatively, the information processing apparatus may be implemented by a plurality of computers. When the plurality of computers are used, computing resources provided by a cloud environment on a network may be used. Therefore, the term “information processing apparatus” herein encompasses an “information processing system” including a plurality of computers or computing resources.
In the description below, for simplification of description, an exemplary configuration in which an information processing apparatus is implemented by a single computer will be described. The technical scope of the subject application, however, is not limited to the configuration where the information processing apparatus is implemented by a single computer.
Referring to
Memory 104 is a volatile storage where a machine code for execution of instructions by processor 102 or various types of work data are temporarily stored, and it is implemented, for example, by a dynamic random access memory (DRAM) or a static random access memory (SRAM).
Display 106 shows image information generated by computing processing in processor 102, and it is implemented, for example, by a display device such as a liquid crystal display (LCD) or an organic electroluminescent (EL) display.
Input portion 108 is implemented, for example, by an input device such as a mouse and/or a keyboard that accepts an operation by a user.
Storage 110 is a non-volatile storage where data generated and used in information processing apparatus 100 is stored in a non-volatile manner, and it is implemented, for example, by a solid state drive (SSD) or a hard disk drive (HDD). Typically, a system program 112 including an operating system (OS) or a driver, a development program 114 for development of an application program, and a project 116 including a source code are stored in storage 110. An application program 118 (executable file) generated from project 116 may be stored in storage 110.
Development program 114 is a program for development of application program 118, and provides a function necessary for development of application program 118 such as creation and edition of a source code of application program 118, compilation of a source code, link of an object generated by compilation. Development program 114 further provides a function and processing as will be described later.
Development program 114 may be stored in storage 110 in a stage of manufacturing of information processing apparatus 100 or may be provided by downloading from a distribution server (not shown). Furthermore, a computer readable storage medium (for example, a universal serial bus (USB) memory or a memory card) (not shown) where development program 114 is stored may be attached to information processing apparatus 100, and development program 114 may be read from the attached computer readable storage medium and installed in storage 110.
Though a single development program 114 is shown for the sake of convenience of the description, the development program may be configured with a plurality of programs. For example, a module or a library for performing the function and the processing as will be described later may be added (add-on) to a program that provides a basic development environment. Therefore, not only a single development program that implements all of the function and the processing as will be described later but also one or more modules or libraries for performing the function and the processing as will be described later are within the technical scope of the present invention.
Communication module 122 is a module for wireless communication with an external apparatus, and it is implemented, for example, by a module for Ethernet™ wireless LAN, or the like.
Though
[C. Serialization and Deserialization]
Serialization and deserialization will now be described.
Serialization refers to processing for writing out (perpetuating) data managed by a program (which is normally arranged on a memory) to a storage or the like. In the description below, perpetuated data and data to be perpetuated are referred to as “asset data.”
Deserialization refers to processing for reading (developing on a memory) data (asset data) perpetuated on the storage or the like, so as to be processible by a program. The asset data may be stored not only in the storage but also in a read only memory (ROM) or a server on a network.
An exemplary data structure generated and managed by a program will be described in connection with serialization and deserialization.
A type and an object generated based on the type will be described with reference to
The definition of the type can thus include definitions of a data structure handled by the program and a behavior (the data type of the property).
When the data on the object arranged on the memory as shown in
Even for values of a similar data type, binary expressions may be different depending on the OS, an architecture of the processor, a programing language, or a version of the programming language. Therefore, even when the binary expression generated in a specific environment is stored as it is, the binary expression may not appropriately be read as it is in a different environment.
In order to address the problem as described above, an approach to serialization in a general-purpose format (for example, in a JSON format) is employed.
Exemplary asset data 300 generated by serialization will be described with reference to
In the example shown in
Asset data 300 generated by serialization may be, for example, in an XML format where a tag is used, in addition to the JSON format. Furthermore, any other format may be adopted.
Data can be handled for general purposes by generation of asset data 300 composed of a pair of a name and a value as shown in
Since processing can be performed in units of the pair of the name and the value, asset data 300 can be made use of. For example, when there is no property corresponding to the type that has been changed, reading of data included in asset data 300 should only be skipped.
Information processing apparatus 100 according to the present embodiment provides a scheme to allow asset data 300 as shown in
[D. Support for Serialization and Deserialization]
A function and processing for support for serialization and deserialization by information processing apparatus 100 according to the present embodiment will now be described.
Information processing apparatus 100 according to the present embodiment supports serialization and deserialization of a program described in a statically typed language (for example, C++). In other words, the kind of a programming language of interest is not limited so long as the programming language falls under the statically typed language.
In the statically typed language, a type of an object generated by execution of a program is defined in advance with a source code. A function is based on the premise that only an object of a predetermined type is processed. Therefore, serialization for general purposes with the function is difficult. Some dynamically typed languages may perform a function to easily serialize an object.
In the present embodiment, a code for implementation of serialization and deserialization which characterizes the present embodiment is automatically generated by addition of a predetermined description to a source code of application program 118. For the sake of convenience of description, this added predetermined description is referred to as a “serialization definition description” and an automatically generated code is referred to as an “additional code.” A user (a developer of application program 118) creates a source code (a source code 160 shown in
The additional code is executed as processing for holding data on a target object of application program 118 (serialization). The additional code may be executed as processing for holding a target value as a value of a member variable of the target object of application program 118 (deserialization).
The serialization definition description is a description that defines contents of serialization (and deserialization). This description designates a type (definition) of an object to be serialized among objects of application program 118. In the present embodiment, by designation of a type to be serialized among types defined in the source code of application program 118, an object generated in the designated type is serialized (a type designated to be serialized in the description below is referred to as a “serialization target type”). In the present embodiment, when there are a plurality of objects (instances) generated with the use of the serialization target type, each object is serialized. The serialization definition description is described in the source code of application program 118 by the user (developer of application program 118).
The serialization definition description in one embodiment includes (1) to (4) below.
(1) A description designating a serialization target type (which is referred to as a “type designation description” below)
A type designation description designates a type of an object, data on which is to be held. A name of the type of the object to be serialized may be described as the type designation description. Alternatively, by arranging the serialization definition description in the type definition to be serialized (or at a proximate position), that type may be designated as a type to be serialized.
(2) A description designating a function for serialization and deserialization (which is referred to as a “function designation description” below)
As a function designation description, a member function of a type to be serialized may be designated, however, any function different therefrom may be designated. In the present embodiment, each of a function used for serialization (a description designating the function is referred to as a “serialization function designation description” below) and a function used for deserialization (a description designating the function is referred to as a “deserialization function designation description” below) is designated.
The serialization function designation description designates a function and/or any variable for obtaining a value. A function designated in connection with the serialization function designation description is a function to obtain a value to be held in a property of asset data. Though a function that returns a value of a property of an object to be serialized as it is may be designated, any function may be applicable without being limited. A function that returns a value of a result of some computation with the use of a value of the property of the object to be serialized or a function that uses no value of the property of the object to be serialized (a constant value, a character string, a value of the property of a member of another type, or a result of computation with the use of the value) may be applicable.
The function designated in the serialization function designation description may thus be a function that obtains (as it is) a value of the property of the object to be serialized or a function that obtains a result of predetermined computation with the use of the value of the property of the object to be serialized. Furthermore, the function designated in the serialization function designation description may be a function that obtains a predetermined constant.
A deserialization function designation description also designates a function. A function designated in connection with the deserialization function designation description is a function that sets a value of the property of the object of application program 118 with the use of a value of a property of asset data. Though this function may be a function that sets the value of the property of the asset data as it is as the value of the object of application program 118, any function may be applicable without being limited. A function that sets a value of a result of some computation with the use of a value of the property of the asset data as the value of the object of application data 118 or a function that uses no value of the property of the asset data (a constant value, a character string, a value of the property of asset data of another type, or a result of computation with the use of the value) may be applicable.
The function designated in the deserialization function designation description may thus be a function that obtains (as it is) a value of the property of the asset data or a function that obtains a result of predetermined computation with the use of the value of the property of the asset data. Furthermore, the function designated in the deserialization function designation description may be a function that obtains a predetermined constant.
(3) A description designating a name of a property in asset data (which is referred to as a “name designation description” below)
The name designation description designates a data name which is a property name. The property name designated as the name designation description is also a property name in an intermediate object which will be described later.
(4) A description designating a data type of a property in asset data (which is referred to as a “data type designation description” below)
The data type designated as the data type designation description is also a data type of a property in an intermediate object which will be described later.
In the present embodiment, the object is held as the intermediate object before the object is held as asset data. Thereafter, this intermediate object is serialized and held as the asset data. In this case, a section explained in connection with “asset data” in the description above is understood as the explanation about the “intermediate object.” In other words, the intermediate object may be stored as the asset data.
As processing described in the additional code is performed while application program 118 is running, the type definition of the object to be serialized in the original source code and the data structure in the asset data can be independent of each other.
For example, in the serialization function designation description, by designation of a function that outputs a value (itself) of a property (a name of which is a “property A”) which is a member of the object of application program 118 and designation of a name (for example, a “property B”) different from the name of property A in the name designation description, the value of the property (the value of “property A”) of the object of application program 118 can be stored in the asset data (or the intermediate object, to be understood similarly below) under a different name (“property B”).
In contrast, by designation of a function that sets the value of the property of the asset data as it is as the value of “property A” of the object of application program 118 in the deserialization function designation description and designation of “property B” in the name designation description, the asset data can also be deserialized under a name different from the property name of the asset data in reading of the asset data.
By designation of a data type (for example, the string type) different from the data type (for example, the int type) of “property A” in the data type designation description, the value of the property of the object of application program 118 can be stored in the asset data in the different data type.
By designation of a function that outputs a value resulting from some computation with the use of the value of property A of the object of application program 118 in the serialization function designation description, not the value itself of the property of the object of application program 118 but the value resulting from computation can be stored in the asset data.
Furthermore, by designation of a function that outputs data irrelevant to the member of the object of application program 118 in the serialization function designation description, any data that is not present in the object of application program 118 can be stored in the asset data.
In the present embodiment, a function for serialization and deserialization is designated. Since any code can be written in these functions, in serialization, a degree of freedom of a value held by the property of the asset data can be higher, and in deserialization, a degree of freedom of a value held by the property on an application program side can be higher.
Instead of the function, however, (a name of) a variable or (a name of) a constant may be designated for at least one of serialization and deserialization. In that case, the value held by the property of the asset data is a value of the variable or a value of the constant (serialization), and the value held by the property on the application program side is a value of the variable or a value of the constant (deserialization).
These variables or constants may each be a member variable of the object to be serialized, or an external variable or an external constant.
In the present embodiment, in designation of a serialization target, a type of the original source code is designated. Though all of objects generated in the designated type are to be serialized in that case, only at least one of the objects may be designated as the serialization target.
A specific example of the serialization definition description will be described later.
The term “procedure” herein means a description for performing specific processing in a program. The “procedure” includes, for example, a function, a member function, a method, a command, a sub routine, a sub program, and the like. In the description below, the function or the member function will mainly be described as an exemplary “procedure”.
As will be described later, the additional code is added to the source code (included in project 116) of application program 118 described by the developer of application program 118, and then application program 118 is generated (built). As the additional code is added, while application program 118 is running, the intermediate object (an object expected to be stored as asset data, details of which will be described later) for writing (serialization) and reading (deserialization) of asset data 300 is automatically generated.
An exemplary state of execution of application program 118 generated by information processing apparatus 100 according to the present embodiment will be described with reference to
Referring to
The data structure (type) of intermediate object 130 can be defined in any manner. Data held by intermediate object 130 can also freely be edited.
More specifically, the additional code includes (1) to (5) below.
(1) (One or more) type definitions of intermediate object 130
Intermediate object 130 is generated in accordance with a code in (1). More specifically, (1) is a code that defines a type of intermediate object 130 to hold a property below as a member.
Thus, (1) refers to a code that defines the type having the member variable of the designated property name based on the property name (data name) designated in the name designation description. In addition, (1) refers also to a code that defines the type having the member variable of the data type designated in the type designation description. In the code of (1), the type of intermediate object 130 may be defined independently of the type definition within corresponding source code 160.
When there are a plurality of serialization definition descriptions for one type, the member is generated for each of them, and consequently the type of intermediate object 130 is in such a structure as having a plurality of properties.
A name of the type of intermediate object 130 is automatically set, for example, by addition of an auxiliary name to the serialization target type (though any name may be given, for example, in an example where the type name to be serialized is “MyData”, the name of the type of intermediate object 130 may automatically be determined as “MyData_IntermediateObject”).
For intermediate object 130, for example, a member function as below may be implemented.
The type of intermediate object 130 may be defined to inherit a common type definition. In this case, the type definition of intermediate object 130 included in the additional code defines the type so as to inherit the common type having at least one member function. For example, when the common type definition has the general-purpose member function, any intermediate object 130 can also have that member function. All or at least one of the functions shown in (A) to (O) described above may be the member function of the common type definition.
When there are a plurality of serialization target types, the type of intermediate object 130 is generated for each serialization target type.
Information processing apparatus 100 thus generates the type definition of intermediate object 130 from source code 160 of application program 118. The type definition of intermediate object 130 corresponds to the type definition for storage as the asset data, of data corresponding to the object generated based on the type definition to be serialized included in source code 160.
The type definition of intermediate object 130 may be extracted (as it is) from the type definition included in source code 160 of application program 118.
(2) A code where a function for generation (instantiation) of intermediate object 130 is described
The code in (2) refers to a code that performs processing for generating an intermediate object based on the type (type definition) defined in the code in (1). Specifically, the code in (2) is for generating intermediate object 130 for the asset data corresponding to each of objects of application program 118 generated based on the type definition in source code 160 of application program 118. The code in (2) refers also to a code that performs processing for generating an intermediate object when processing for holding data of the target object is performed (serialization).
When there are a plurality of objects (instances) generated with the use of the serialization target type, intermediate object 130 is individually generated for each of them.
Intermediate object 130 is actually generated at timing of execution of this code. For example, this code is executed when a certain object is serialized (for the first time), and corresponding intermediate object 130 is generated. When the object to be serialized is generated, at that timing, corresponding intermediate object 130 may be generated.
(3) A code where a function (which is referred to as a “serialization code” below, a specific example of which is shown as DEFINE_SERIALIZE_VALUE( ) in
The serialization code included in the additional code is for performing processing for holding, as data corresponding to a target object, a value obtained by a function designated in the serialization function designation description or a value of a variable designated in the serialization function designation description under the data name (property name) designated in the name designation description. At this time, the serialization code is a code that performs processing for holding the value obtained by the function or the value of the designated variable, as the value of the member variable of intermediate object 130 generated by the code in (2). The serialization code may be a code for performing processing for holding a value obtained by a function designated in advance or a value designated in advance in intermediate object 130.
The data corresponding to the target object may be asset data corresponding to the target object or data expected to be held as the asset data (the value of the corresponding property of the intermediate object).
(4) A code where a function (which is referred to as a “deserialization code” below, a specific example of which is shown as DEFINE_DESERIALIZE_VALUE( ) in
The deserialization code included in the additional code is for performing processing for passing the value of the data name (property name) designated in the name designation description held by the asset data to the function designated in the deserialization function designation description. For example, with the function designated in the deserialization function designation description, the value of the property of the name designated in the (passed) name designated description is used to set the value of the corresponding property of the object of the serialization target type. The deserialization code may be a code for performing processing for passing the value of the property held by intermediate object 130 to the function designated in advance.
(5) A code that performs processing for registering a pointer of a generated function
By automatic addition of the additional code composed of a code group as described above to the original source code, the type of intermediate object 130 is defined ((1) above), intermediate object 130 is generated ((2) above), the code that sets the value of the property of intermediate object 130 with the use of any function (a function designated in the serialization function designation description) is added ((3) above), and a code that passes the value of the property of intermediate object 130 to any function (a function designated in the deserialization function designation description) can be added ((4) above).
The additional code may further include (6) to (8) below.
(6) A code where a function (an interface 133) for writing out a value held by intermediate object 130 to asset data 300 (serialization) is described
(7) A code where a function (an interface 134) for reading asset data 300 to intermediate object 130 (deserialization) is described
The functions in (6) and (7) may be implemented as the member functions of intermediate object 130.
A GenerateJSON function may be implemented in intermediate object 130 by way of example of (6).
As the GenerateJSON function is called, a pair of a property name (variable name) held by intermediate object 130 and a corresponding value may be generated as data in the JSON format.
Alternatively, a GenerateXML function may be implemented in intermediate object 130. As the GenerateXML function is called, a pair of a property name (variable name) held by intermediate object 130 and a corresponding value may be generated as data in the XML format.
The format for output of the name and the value of the property held by intermediate object 130 may be such a general-purpose format as the JSON format and the XML format.
Thus, (6) is for performing processing for output of the value of the property of intermediate object 130 in a predetermine format for each type of intermediate object 130. The type definition (the code in (1) described above) of intermediate object 130 may include a code for performing processing for calling such processing.
An ExtractJSON function may be implemented in intermediate object 130 by way of example of (7). In this case, empty intermediate object 130 is generated (instantiated), asset data 300 to be read is designated, and the ExtractJSON function is called. A pair of a property name (variable name) described in asset data 300 and a corresponding value is thus read in intermediate object 130.
Alternatively, a Deserialize function for reading data from asset data 300 may be prepared. The Deserialize function is called, with asset data 300 to be read being designated and a type ID indicating a type of intermediate object 130 into which asset data 300 is to be read being designated. The Deserialize function parses designated asset data 300 to be read and reads the pair of the property name (variable name) described in asset data 300 and the corresponding value. In succession, intermediate object 130 corresponding to the designated type ID is generated (instantiated), and data read from asset data 300 is set in generated intermediate object 130.
Any library or the like can also be used for exchange of data between intermediate object 130 and asset data 300 (serialization (writing) and deserialization (reading)).
When the codes in (6) and (7) are not automatically generated as the additional codes, the developer of application program 118 describes these codes.
Depending on application program 118, only one of serialization and deserialization may be required, or partial processing of serialization or deserialization may be required.
Therefore, the additional code may be generated so as to implement at least only one of interfaces 131 and 132 shown in
(8) A code that performs processing for holding a history of intermediate object 130
Intermediate object 130 may hold not only a current value but also one or more past values as the value (data) of the property. For example, a function for execution of Undo/Redo may be implemented as the member function of intermediate object 130.
Information processing apparatus 100 may automatically generate a schema file in addition to the additional code. The schema file describes a data structure of the type definition of intermediate object 130 (or asset data 300). In other words, the schema file describes the data structure of the type definition for storage as the asset data. Details of the schema file will be described later.
[E. Functional Configuration and Processing Procedure]
A functional configuration and a processing procedure of information processing apparatus 100 according to the present embodiment will now be described.
Referring to
The user (developer of application program 118) operates a not-shown editor or the like to create project 116 including source code 160, a list of files 162 of source code 160 to be built, and setting information 164.
Additional code generation module 150 generates an additional code 170 from project 116. Additional code generation module 150 may generate a schema file 180 in addition to additional code 170. More specifically, additional code generation module 150 includes an analysis module 152 and an addition module 154.
Analysis module 152 analyzes source code 160 included in project 116, finds a serialization definition description, and constructs information for generating additional code 170 based thereon. Analysis module 152 thus identifies the type definition (the type designation description included in the serialization definition description) within source code 160 of application program 118. More specifically, analysis module 152 extracts from source code 160 of application program 118, a serialization definition description (an exemplary predetermined description) including a name designation description (an exemplary first description) designating a data name (property name) and a serialization function designation description (an exemplary second description) that designates a function or a variable for obtaining a value. Analysis module 152 then generates the type definition of intermediate object 130 based on the serialization definition description included in source code 160.
Addition module 154 generates additional code 170 based on the extracted serialization definition description and adds generated additional code 170 to source code 160 of application program 118.
Addition module 154 generates schema file 180.
Setting information 164 includes a designation as to where additional code 170 is to be stored and where schema file 180 generated together with additional code 170 is to be stored. Generated additional code 170 and schema file 180 are outputted to the designated storage.
Update module 140 adds additional code 170 generated by additional code generation module 150 to source code 160 of project 116 and adds the file name or the like of additional code 170 to list of files 162, to thereby update the list of files to a list of files 162A.
Builder 142 generates application program 118 by compiling source code 160 and additional code 170. Builder 142 generates application program 118 (executable file) from a project 116A updated by update module 140. More specifically, builder 142 includes an analysis module 144, a compiler 146, and a linker 148.
Analysis module 144 analyzes source code 160 and additional code 170 included in project 116A updated by update module 140. At this time, processing for developing a macro described in source code 160 and additional code 170 is performed. A macro definition corresponding to the serialization definition description in source code 160, however, is set to be developed on a null string. Consequently, analysis module 144 replaces the serialization definition description in source code 160 with the null string.
Compiler 146 compiles source code 160 and additional code 170 based on a result of analysis by analysis module 144 to generate an object code.
Linker 148 links the generated object code to generate application program 118 (executable file).
Though the analysis module generates information for generation of additional code 170 and thereafter the addition module generates the additional code based on that information in the example described above, the additional code may directly be generated at the time of analysis of the serialization definition description.
An exemplary processing procedure in build processing in information processing apparatus 100 according to the present embodiment will be described with reference to
When information processing apparatus 100 receives a request for build of a library or application program 118 (YES in step S2), it initially performs processing designated to be performed before build as pre-build. It is assumed that processing for generating additional code 170 is designated as processing to be performed as pre-build.
Information processing apparatus 100 obtains information necessary for generation of additional code 170 (for example, (1) a list of files of source code 160 to be built, (2) where additional code 170 is stored, and (3) where schema file 180 generated together with additional code 170 is stored) (step S4), and performs processing for generating additional code 170 as will be described later (step S6).
Information processing apparatus 100 adds generated additional code 170 to the source code to be built to generate a list of files of a new source code to be built (step S8) and compiles a target source code (step S10). Information processing apparatus 100 then generates an executable file (application program 118) by linking an object code generated by compilation (step S12). The process thus ends.
An exemplary processing procedure in processing for generating additional code 170 (step S6) shown in
More specifically, in lexical analysis, information processing apparatus 100 extracts from source code 160, the serialization definition description including a name of the property included in asset data 300 and a function name for obtaining a value of the property. Information processing apparatus 100 recognizes a type to be serialized among types defined in original source code 160 based on a result of analysis of such source code 160 and generates an additional code for generation of intermediate object 130 corresponding thereto. Details of the additional code are as described above.
In succession, information processing apparatus 100 (addition module 154 shown in
More specifically, in step S62, information processing apparatus 100 extracts from source code 160 of application program 118, a serialization definition description (an exemplary predetermined description) including a name designation description (an exemplary first description) designating a data name (property name) and a serialization function designation description (an exemplary second description) designating a function or a variable for obtaining a value.
Finally, information processing apparatus 100 (addition module 154 shown in
Concurrently, information processing apparatus 100 outputs schema file 180 from the character string for generation of schema file 180 (step S66). Schema file 180 includes information for identifying the data structure of asset data 300 including one or more properties. The process then returns.
[F. Serialization Definition Description and Additional Code] Exemplary serialization definition description and additional code in information processing apparatus 100 according to the present embodiment will now be described. The user (developer of application program 118) can also edit automatically generated additional code 170 as necessary.
(f1: Example where Data is Held in Asset Data Under Property Name the Same as Property Name of Type Definition of Application Program)
Exemplary serialization definition description and additional code 170 generated based thereon will be described with reference to
Referring to
A serialization definition description 410 is added in type definition 40A, which characterizes the present embodiment. In the example shown in
By way of example, serialization definition description 410 includes a macro name 411 “BIND_VALUE”. Macro name 411 is a character string indicating that it will be replaced with an object-like macro.
Serialization definition description 410 includes as arguments, a property name 412 (an exemplary “name designation description”) designating the name of the property in asset data 300, a data type definition 413 (an exemplary “data type designation description”) designating the data type of the property, a function name 414 (an exemplary “serialization function designation description”) designating the function to be used for serialization, and a function name 415 (an exemplary “deserialization function designation description”) designating the function to be used for deserialization.
Type definition 40A includes a function definition 404 that defines a function corresponding to function name 414 designated as the argument of serialization definition description 410 and a function definition 405 that defines a function corresponding to function name 415 designated as the argument of serialization definition description 42.
Additional code 170 shown in
Serialization code 50A includes as arguments, a type name 416 designating the serialization target type, property name 412, and data type definition 413.
Additional code 170 shown in
Deserialization code 52A includes as arguments, a type name 416 designating the serialization target type, property name 412, and data type definition 413.
As application program 118 generated from project 116A including original source code 160 and additional code 170 shown in
A function to be used for serialization designated by function name 414 and a function to be used for deserialization designated by function name 415 are implemented in intermediate object 130. The function may be implemented as being explicitly read, or another procedure (for example, the member functions as shown in
(f2: Example in which Data is Held in Asset Data Under Property Name Different from Property Name of Type Definition of Application Program)
Another exemplary serialization definition description and additional code 170 generated based thereon will be described with reference to
Referring to
In type definition 40B, a serialization definition description 430 is added, and designation of the MyData type as the serialization target type is made.
By way of example, serialization definition description 430 includes a macro name 431 “BIND_VALUE”. Serialization definition description 430 includes as arguments, a property name 432, a data type definition 433, a function name 434 that designates a function to be used for serialization, and a function name 435 that designates a function to be used for deserialization.
In the example shown in
Type definition 40B includes a function definition 424 that defines a function corresponding to function name 434 designated as the argument of serialization definition description 430 and a function definition 425 that defines a function corresponding to function name 435 designated as the argument of serialization definition description 430.
In function definition 424, a function that outputs a value of property m_Distance of the object of application program 118 is defined. In function definition 425, a function that sets a value designated as the argument as a value of property m_Distance of the object of application program 118 is defined.
Additional code 170 shown in
Additional code 170 shown in
“propertyValue” in serialization code 50B and deserialization code 52B is a provisional argument name indicating “reference” to a type defined by data type definition 433 (the float type in this example).
Thus, in the present embodiment, data can be held in asset data 300 under any property name independent of the property name of the object of application program 118. With such processing, advantages as below are obtained.
Such needs that use of a property name (variable name) having any prefix (for example, “m_” indicating a member variable) is desired under rules for creation of a source code, however, prefixing of asset data 300 outputted by serialization with such a prefix as “m_” is not desired can be met.
Such needs that the meaning of the property had changed in a stage in the middle of development of application program 118 and hence the property name (variable name) was changed in source code 160, however, the property name included in asset data 300 to be written out is desirably maintained as it is can be met. Such needs that a name representing the data structure is provided as the name of the member variable of the object generated by a run-time program, however, the name representing the data structure is desirably not exposed to asset data 300 (desirably hidden) can be met. For example, though the member variable under the name “childElementLinkedList” is used on a run-time program side, the property name outputted as asset data 300 can be a name “children”.
Even when a specific data structure is changed in a stage in the middle of development of application program 118, the property name included in asset data 300 can be maintained as it is.
(f3: Example where Data is Held by Asset Data in Data Type Different from Data Type of Application Program)
Yet another exemplary serialization definition description and additional code 170 generated based thereon will be described with reference to
Referring to
In type definition 40C, a serialization definition description 450 is added, and designation of the MyData type as the serialization target type is made.
By way of example, serialization definition description 450 includes a macro name 451 “BIND_VALUE”. Serialization definition description 450 includes as arguments, a property name 452, a data type definition 453, a function name 454 that designates a function to be used for serialization, and a function name 455 that designates a function to be used for deserialization.
In the example shown in
Type definition 40C includes a function definition 444 that defines a function corresponding to function name 454 designated as the argument of serialization definition description 450 and a function definition 445 that defines a function corresponding to function name 455 designated as the argument of serialization definition description 450.
In function definition 444, a function that converts the hash value held by property m_TagHash of the object of application program 118 into a character string and outputs the character string is defined. A function GetTagString is defined in a not-shown code. In function definition 445, a function that converts a value (character string) included in the asset data designated as the argument into the hash value and sets the hash value as a value of property m_TagHash of the object of application program 118 is defined.
Additional code 170 shown in
Serialization code 50C of additional code 170 shown in
Additional code 170 shown in
Thus, in the present embodiment, data can be held by asset data 300 in any data type independent of the data type of the property of the object of application program 118. With such processing, advantages as below are obtained.
For example, correspondence between a character string and a hash value is defined in advance, and then only the hash value of the character string is held in a run-time program. By adopting such a form of implementation, information held by the run-time program can be minimum necessary and a necessary amount of memory can be saved. This form of implementation is effective when a size of an object should be reduced due to restrictions on hardware or when information itself on the character string is not necessary for processing.
Alternatively, such processing as holding information in an encrypted binary string in asset data 300 and holding the binary string in a decrypted character string in a run-time program can also be performed. By including the encrypted character string in the asset data, information held by the run-time program can be kept secret. In addition, a data size can be made smaller by binarization of a long character string.
(f4: Example where Data not Held by Application Program is Held by Asset Data)
In the present embodiment, data not held by application program 118 (run-time program) can also be held by asset data 300.
Yet another exemplary serialization definition description and additional code 170 generated based thereon will be described with reference to
Referring to
By way of example, serialization definition description 470 includes a macro name 471 “BIND_VALUE”. Serialization definition description 470 includes as arguments, a property name 472, a data type definition 473, a function name 474 that designates a function to be used for serialization, and a function name 475 that designates a function to be used for deserialization.
In the example shown in
Type definition 40D includes a function definition 464 that defines a function corresponding to function name 474 designated as the argument of serialization definition description 470 and a function definition 465 that defines a function corresponding to function name 475 designated as the argument of serialization definition description 470.
In function definition 464, a function that outputs “2” described in source code 160 is defined.
In function definition 465, a function that evaluates a value designated as the argument is defined. More specifically, when a value read from asset data 300 (a value indicating a version) is not “2” but “1”, reading of a function EnableOldAssetBehavior is defined. Function EnableOldAssetBehavior is defined in a not-shown code, and it typically performs processing for switching an operation of a run-time program.
Additional code 170 shown in
Additional code 170 shown in
Thus, in the present embodiment, even data not held by application program 118 can be held by asset data 300. With such processing, advantages as below are obtained.
For example, as shown in
In an example where there are a plurality of values independent of each other in application program 118, such processing as bringing the plurality of values together in one matrix or vector and writing out the same to asset data 300 can be performed.
(f5: Edition of Automatically Generated Additional Code)
The user (developer of application program 118) can also freely edit automatically generated additional code 170. Exemplary edition of additional code 170 will be described below.
Exemplary edition of automatically generated additional code 170 will be described with reference to
Specifically, in serialization code 50B, “*2.0f” (a description 501 for doubling the value) is added. Specifically, processing for returning a value calculated by multiplying a value obtained from the object of the MyData type to be serialized by two is defined.
To the deserialization code, “*0.5f” (a description 502 for multiplying a value by 0.5) is added. Specifically, processing for returning a value calculated by multiplying a value read from asset data 300 by 0.5 is defined.
Without being limited to the examples shown in
(f6: Exemplary Serialization Definition Description Explicitly Including Type Designation Description)
An exemplary serialization definition description explicitly including a type designation description will be described with reference to
In the example shown in
By way of example, serialization definition descriptions 63 and 64 include macro names 631 and 641 “BIND_VALUE_EXTERNAL”, respectively.
Serialization definition descriptions 63 and 64 include as arguments, property names 632 and 642 (exemplary “name designation description”), data type definitions 633 and 643 (exemplary “data type designation description”), function names 634 and 644 (exemplary “serialization function designation description”) that designate functions to be used for serialization, and function names 635 and 645 (exemplary “deserialization function designation description”) that designate functions to be used for deserialization, respectively.
Serialization definition descriptions 63 and 64 further include type names 636 and 646 (exemplary “type designation description”) that designate types to be serialized, respectively.
In the example shown in
In the present embodiment, the serialization definition description is not added to the defined type and property itself, but the serialization definition description that designates the name of the property included in asset data 300, the data type definition of the value of the property, the function for obtaining the value of the property, and the function for setting the value of the property is added.
Therefore, even the object of the type defined in the external library can freely be serialized and deserialized. Though the description above shows exemplary processing for adding the serialization definition description as a part of the type definition, the serialization definition description can also be arranged on the outside of the type definition.
The description that designates the type of the object to be serialized thus does not necessarily have to be arranged in the type definition. Consequently, any type of the object can be designated as a serialization target.
(f7: Handling of Source Code to which Serialization Definition Description is Added)
Handling of the source code to which the serialization definition description is added will now be described. As described above, in the present embodiment, by addition of the serialization definition description including such a macro name as “BIND_VALUE” (see
Such a serialization definition description is handled differently between processing for generating additional code 170 and build processing for generating application program 118.
Handling of the serialization definition description in build in information processing apparatus 100 according to the present embodiment will be described with reference to
A type definition 40E of the MyData type shown in
Serialization definition description 410 includes macro name 411 “BIND_VALUE” and serialization definition description 490 includes a macro name 491 “BIND_VALUE”.
Serialization definition description 410 includes as arguments, property name 412, data type definition 413, function name 414, and function name 415. Serialization definition description 490 includes as arguments, a property name 492, a data type definition 493, a function name 494, and a function name 495.
A type definition 40F shown in
The first lines of codes 410A and 490A are described with an attribute syntax “_attribute)(( ))” and designate contents of the arguments of serialization definition descriptions 410 and 490 as the attribute. The second lines of codes 410A and 490A define the data structure of a union and define a member.
Information processing apparatus 100 generates additional code 170 based on contents described in codes 410A and 490A.
Builder 142 (addition module 154) of information processing apparatus 100 thus interprets the serialization definition description included in source code 160 as being invalid, and then generates application program 118. More specifically, builder 142 (addition module 154) of information processing apparatus 100 replaces the macro name with the null string.
Consequently, in build for generation of application program 118, there is substantially no influence by the serialization definition description described in the source. Aa handling is thus different between processing for generation of additional code 170 and compilation thereof for the same source, additional code 170 can automatically be generated substantially without influence a portion of the original source code.
A method of adding an attribute or the like to the type itself or the variable itself may be available as a general method of automatically generating a source code for serialization. In this method, an attribute or the like cannot be added to a type defined in the source code that cannot be changed by the builder, and cannot be serialized. In contrast, in the present embodiment, additional code 170 can be generated simply by analysis of the character string (the serialization definition description or the like) of the source code. Therefore, any type can be designated as a serialization target and deserialization target. In other words, any type can be serialized and deserialized.
In the present embodiment, the serialization definition description designates each of the function (for serialization) for obtaining a value to be held as a property value of the asset data (or the intermediate object) and a function (for deserialization) for passing the property value of the asset data (or the intermediate object) (the passed value is used in this function and set as the property value of the original source code). Therefore, the type of object 120 generated in running application program 118 does not have to match with the data structure of asset data 300 but they can be set independently of each other.
For example, by appropriate definition of a function for obtaining the value to be held in the property of the asset data (or the intermediate object) in serialization, a value that is not present as the property of object 120 can be written out to asset data 300. By appropriate definition of a function for passing the property value of the asset data (or the intermediate object) in deserialization, the type of object 120 can be changed without change of the data structure of asset data 300. In other words, the type of object 120 and the data structure of asset data 300 can be defined and changed independently of each other without affecting each other.
[G. Intermediate Object]
Intermediate object 130 generated while application program 118 generated by information processing apparatus 100 according to the present embodiment is running will now be described.
Processing of the member function of intermediate object 130 generated while application program 118 generated by information processing apparatus 100 according to the present embodiment is running will be described with reference to
Referring to
Referring to
Though
When the member function (the LoadTo function, the ExtractFrom function, and the like) of generated intermediate object 130 is thus executed, the function designated in the serialization definition description added at the time of generation of additional code 170 is called. Since the function designated in the serialization definition description can freely be defined, highly flexible serialization and deserialization can be achieved.
In order to implement the member function as shown in
In order to implement the member function as shown in
In the present embodiment, since intermediate object 130 is generated in correspondence with object 120 to be serialized and deserialized, reading and writing of data from and into object 120 and reading and writing of data from and into asset data 300 can independently be carried out. Therefore, more flexible serialization and deserialization can be achieved.
[H. Schema File 180]
Schema file 180 generated by information processing apparatus 100 according to the present embodiment will now be described.
Schema file 180 includes information that identifies the data structure of serialized and deserialized asset data 300. More specifically, schema file 180 includes information that identifies the data structure of the name and the value of the property. With schema file 180, asset data 300 can be generated and edited independently of application program 118.
Exemplary schema file 180 generated by information processing apparatus 100 according to the present embodiment will be described with reference to
Referring to
Information processing apparatus 100 generates schema file 180 for the property to which the serialization definition description is added in the source code. More specifically, information processing apparatus 100 (analysis module 152) obtains the data type of the name and the value of one or more properties included in asset data 300 based on the serialization definition description that designates data to be outputted as asset data 300, of data held by running application program 118.
Information processing apparatus 100 (addition module 154) generates schema file 180 including information that identifies the data structure of asset data 300 including one or more properties based on a result of analysis of source code 160. When intermediate object 130 as described above is used, data held by intermediate object 130 is outputted as asset data 300. Therefore, information processing apparatus 100 (addition module 154) may generate schema file 180 based on the type of intermediate object 130 that holds data generated while application program 118 is running and is outputted as asset data 300.
In this case, information processing apparatus 100 (addition module 154) generates schema file 180 and generates additional code 170 for implementation of intermediate object 130 that holds data outputted as asset data 300.
With schema file 180, coordination between an edition tool and application program 118 (executable file) can be facilitated. Schema file 180 may be outputted in the general-purpose format such as the JSON format or the XML format. With schema file 180 in the general-purpose format, schema file 180 can be used by various edition tools.
For example, the edition tool creates asset data 300, edits asset data 300, and has asset data 300 shown based on schema file 180.
The user performs an operation on the edition tool to generate asset data 300 (for example, test data) that can be read by application program 118 corresponding to schema file 180. The user performs an operation on the edition tool to edit asset data 300 (for example, change the value for debugging) that can be read by application program 118 corresponding to schema file 180. The edition tool adds information on corresponding schema file 180 to asset data 300 outputted from application program 118 corresponding to schema file 180 and presents the resultant data to the user.
Exemplary use of schema file 180 generated by information processing apparatus 100 according to the present embodiment will be described with reference to
It is assumed that schema files 180A and 180B corresponding to asset data 300A and asset data 300B, respectively, are generated in advance.
An edition tool 400 can generate and edit asset data 300A and asset data 300B by referring to schema files 180A and 180B, respectively. The user performs an operation onto edition tool 400 to freely generate and edit asset data 300A and asset data 300B. For example, test data for debugging of application program 118 can readily be prepared. By checking asset data 300 written out of application program 118, a cause of a failure can readily be identified.
Edition tool 400 may be incorporated in a part of development program 114 or it may be a general-purpose application program independent of development program 114. Edition tool 400 may use a library group 480 for writing out and reading of asset data 300 in accordance with schema file 180.
Edition tool 400 may thus create or edit asset data 300 outputted from running application program 118 in accordance with an operation by the user.
Referring to
Edition tool 400 may thus create asset data 300 available to application program 118 in accordance with an operation by the user.
As shown in
Edition tool 400 may thus receive asset data 300 outputted from running application program 118 and transmit asset data 300 to running application program 118.
With the use of schema file 180 and edition tool 400 as shown in
In the present embodiment, additional code 170 and schema file 180 can be generated from the source code to which the serialization definition description is added. In other words, schema file 180 corresponding to the type defined in the source code for generation of application program 118 is generated. Therefore, application program 118 generated from the source code and edition tool 400 can readily be in coordination based on schema file 180.
Since schema file 180 is automatically generated, the user does not have to create schema file 180 from scratch.
[I. Modification]
Though the description above exemplifies exemplary processing in which an object-like macro which is the general-purpose function is used to add the serialization definition description (and an exclusion designation description) indicating a serialization and deserialization target to the source code, another method may be adopted.
For example, the serialization definition description (and the exclusion designation description) may be arranged in source code 160 as a comment. In other words, the serialization definition description may be added as the comment (for example, in C++, a character string started with two slash signs) in the source code. For example, a comment including a specific keyword “//[BIND_VALUE]” may be added to a variable to be serialized and deserialized.
In processing for generating additional code 170, a comment including a specific keyword may be extracted by lexical analysis and a variable described in a line from which the comment including the specific keyword has been extracted may be identified as a serialization and deserialization target. In compilation during build, on the other hand, the comment is ignored, and hence the application program can be generated substantially without influence on a portion of the original source code.
A variable to be serialized and deserialized should only be designated with any method other than the macro name and the comment.
While certain example systems, methods, devices, and apparatuses have been described herein, it is to be understood that the appended claims are not to be limited to the systems, methods, devices, and apparatuses disclosed, but on the contrary, are intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims.
Number | Date | Country | Kind |
---|---|---|---|
2022-110523 | Jul 2022 | JP | national |