Login| Sign Up| Help| Contact|

Patent Searching and Data


Title:
A COMPUTER-IMPLEMENTED METHOD OF EXECUTING A METHOD CODE, WRITTEN IN C#, FROM ANOTHER C LANGUAGE
Document Type and Number:
WIPO Patent Application WO/2024/005808
Kind Code:
A1
Abstract:
A computer-implemented method of executing a method code, written in C#, from another C language is provided. The computer-implemented method includes identifying an attribution written in C# script, and identifying a method corresponding to the attribute. The method is written in the C# script. The computer-implemented method includes calling the C# method from C. In this way, legacy source code written in another language such as C or C++ may be modified by a user in C#.

Inventors:
BONES GEOFF (GB)
Application Number:
PCT/US2022/035610
Publication Date:
January 04, 2024
Filing Date:
June 29, 2022
Export Citation:
Click for automatic bibliography generation   Help
Assignee:
SIEMENS IND SOFTWARE INC (US)
International Classes:
G06F9/445; G06F8/30; G06F9/455
Foreign References:
US20190073430A12019-03-07
Attorney, Agent or Firm:
WEBB, Tyler (US)
Download PDF:
Claims:
CLAIMS

1. A computer-implemented method of executing a method code, written in C#, from another C language, the computer-implemented method comprising: identifying an attribution written in C# script; identifying a method corresponding to the attribute, the method written in the C# script; and calling the C# method from C.

2. The computer-implemented method of Claim 1 , wherein the method is a customization of a section of source code written in C.

3. The computer-implemented method of Claim 2, wherein the section of source code comprises an application programming interface (API).

4. The computer-implemented method of any preceding claim, wherein calling the C# method from C# to C comprises executing Pinvoke on the method from C#.

5. The computer-implemented method of any of Claims 1 to 4, further comprising retrieving the C# script from a NuGet server.

6. The computer-implemented method of any preceding claim, further comprising retrieving C# source code from disk.

7. The computer-implemented method of any of Claims 2 to 6, further comprising hosting the section of source code in a .NET environment. 8. The computer-implemented method of any preceding claim, further comprising executing the method from C.

9. The computer-implemented method of any of Claims 1 to 7, further comprising converting C++ types into C types prior to the calling the C# method from C.

10. The computer-implemented method of Claim 9, wherein the C++ types comprise a pool, a std: :string, a std::vector, a std::map, and a std::set.

11 . The computer-implemented method of Claim 10, wherein the converting of C++ types into C types comprises: converting a std::string to a char point in C; converting a std:: vector to an array in C, wherein the array is associated with a length; converting a std::map to a key array and a value array in C, wherein each array is associated with a length; and converting a std::set to an array, wherein the array is associated with a length.

12. The computer-implemented method of Claim 11 , further comprising providing a parameter label and the method with each conversion as metadata, wherein the parameter label describes the C++ type.

13. The computer-implemented method of any of Claims 9 to 13, wherein the method is a customization of a section of source code written in C++.

14. The computer-implemented method Claim 13, wherein the section of source code comprises an application programming interface (API).

15. The computer-implemented method of any of Claims 9 to 14, further comprising executing the method from C++.

16. A transitory, or non-transitory, computer-readable medium, having instructions stored thereon that, when executed by a processor, cause the processor to perform the computer-implemented method of any preceding claim.

Description:
A COMPUTER-IMPLEMENTED METHOD OF EXECUTING A METHOD CODE, WRITTEN IN C#, FROM ANOTHER C LANGUAGE

FIELD

[0001] The present disclosure relates to a computer-implemented method of executing a method written in C# from another C language, and a transitory, or non- transitory, computer-readable medium.

BACKGROUND

[0002] Many legacy applications have been written in a comparatively old programming language, such as C. Applications written in C are often difficult and time consuming for end users to customize, for example, by writing a method code to replace a method within the original C code. In addition, C is not very compatible for applications running over the cloud. More modern languages such as C# are more easily customizable but are not directly compatible with C source codes. Therefore, it is difficult for applications written in C to be customizable by an end user.

SUMMARY

[0003] It is an aim of the present invention to improve on the prior art by addressing the problems discussed above.

[0004] According to an aspect of the present invention, a computer-implemented method of executing a method coded using C# in another C language is provided. The computer-implemented method includes identifying an attribution written in C# script, identifying a method corresponding to the attribute, the method written in the C# script, and calling the C# method from C.

SUBSTITUTE SHEET (RULE 26) [0005] C# has an ability to be used for cloud based applications, whereas C is much more difficult for such purposes. In addition, C# is easier and much quicker for end users to customize. Therefore, allowing end users to customize applications in another C language using C# improves customizability of applications for the end user.

[0006] In an embodiment, the method may be a customization of a section of source code written in C.

[0007] In an embodiment, the section of source code may include an application programming interface (API).

[0008] In an embodiment, the translating the method from C# to C may include executing Pinvoke on the method from C#.

[0009] In an embodiment, the computer-implemented method may further include retrieving the C# script from a NuGet server.

[0010] A NuGet server allows C# custom izations to be loaded into a running service on the fly.

[0011 ] In an embodiment, the computer-implemented method may further include retrieving C# source code from disk.

[0012] Disk-resident source code enables a user to perform custom izations in a development environment.

[0013] In an embodiment, the computer-implemented method may further include hosting the section of source code in a .NET environment.

[0014] In an embodiment, the computer-implemented method may further include executing the method from C.

[0015] In an embodiment, the computer-implemented method may further include converting C++ types into C types prior to the calling the C# method from C. [0016] In this way, the conversion between C++ and C enables custom izations to be made using C# for applications written in C++. C++ is an augmented language compared to C.

[0017] In an embodiment, the C++ types may include a bool, a std::string, a std::vector, a std::map, and a std::set.

[0018] In an embodiment, the converting C++ types into C types may include: converting a std::string to a char point in C; converting a std::vector to an array in C, where the array is associated with a length; converting a std::map to a key array and a value array in C, where each array is associated with a length; and converting a std::set to an array, where the array is associated with a length.

[0019] In an embodiment, the computer-implemented method may further include providing a parameter label and the method with each conversion as metadata, where the parameter label describes the C++ type.

[0020] In an embodiment, the method may be a customization of a section of source code written in C++.

[0021 ] In an embodiment, the section of source code may include an application programming interface (AP)I.

[0022] In an embodiment, the computer-implemented method may further include executing the method in C++.

[0023] According to an aspect of the present invention, a transitory, or non- transitory, computer-readable medium, having instructions stored thereon that, when executed by a processor, cause the processor to perform the computer-implemented method of the foregoing aspect or embodiments is provided.

BRIEF DESCRIPTION OF DRAWINGS

[0024] The present invention is best understood with reference to the accompanying figures, in which: [0025] Figure 1 shows a block diagram of a server system; and

[0026] Figure 2 shows a computer-implemented method of executing a method code, written in C#, in another C language.

DESCRIPTION OF EMBODIMENTS

[0027] Any methods described herein may be computer-implemented methods. The computer-implemented methods may be provided on a transitory, or non- transitory, computer-readable medium having instructions stored thereon that, when executed by a processor, cause the processor to perform the method. The processor may be a processor of a computer that also includes storage. The non-transitory computer readable medium may be store in the storage.

[0028] With reference to Figure 1 , a server system includes a back-end server 12, a client server 14, and a client device 16. The client device 16 may be any type of computer device and acts as an interface with a user. The client server 14 is configured to serve an editing interface for a user to edit an application. The editing interface is written in C#. The back-end server 12 includes storage including a source code of one or more applications written in C or C++. The languages C and C++ may be considered another C language.

[0029] With reference to Figure 2, in an embodiment, a computer-implemented method of executing a method code, written in C#, in another C language is provided. The method includes identifying 100 an attribute written in C# script. The method includes identifying 102 a method corresponding to the attribute, the method being written in the C# script. The method includes translating 104 the method from C# to C.

[0030] In more detail, a user may wish to customize an application written in a source code in C. To customize the code, a user may wish to write a method code using the client device 16. The method code may be written in C#. When writing the method code, the user may include an attribute to signify the existence and location of the corresponding method code.

[0031] The section of source code that the user is customizing may be an application programmable interface (API).

[0032] In one or more embodiments, the client server 14 is a web server. In this way, real-time custom izations may be written by a user. In one or more other embodiments, the client server 14 is a NuGet server. A NuGet server may be for development programs.

[0033] Once the client server 14 has the C# customization written by the user, the back-end server 12 is configured to translate the method from C# to C. To achieve this, the back end server 12 uses Pinvoke on the method written in C#.

[0034] The application or section of the source code that is being edited is hosted in a .NET environment. The .NET environment enables Pinvoke to be processed.

[0035] The computer-implemented method may further include editing the method in C. For example, the C source code is edited to replicate the method written in C#. Once the C code has been edited, the edited C code is translated to C#, where the C# code resides on the client server 14. In this way, the new method code, or customization, will load upon start-up and exist in the executing software.

[0036] There are some source code applications that are written in C++. C++ is desirable for applications because of its expanded definition of types. Those additional types not being available in C provides that equivalent commands in C# do not map directly to C++ via C.

[0037] Therefore, the method may further include converting C++ types into C types. This may be done prior to translating the method from C# to C.

[0038] The C++ types include a std::string, a std::vector, a std::map, and a std::set. Converting C++ types into C types includes converting a std::string to a char point in C and converting a std:: vector to an array in C. The array is associated with a length. Converting C++ types into C types includes converting a std:: map to a key array and a value array in C, where each array is associated with a length, and converting a std::set to an array, where the array is associated with a length.

[0039] In addition to the conversion, metadata is added in C for each parameter. This is so the correct parameter type may be constructed in C++. The metadata may include a parameter label and the method written in C#. The parameter label may be a description of the parameter type that may be used to replicate the method in C++.

[0040] Again, the source code in C++ may be edited to include the method written in C#, in the same, or in a similar way to how the source code in C has been edited.

[0041 ] Attention is directed to all papers and documents that are filed concurrently with or previous to this specification in connection with this application and that are open to public inspection with this specification, and the contents of all such papers and documents are incorporated herein by reference.

[0042] All of the features disclosed in this specification (including any accompanying claims, abstract, and drawings), and/or all of the steps of any method or process so disclosed, may be combined in any combination, except combinations where at least some of such features and/or steps are mutually exclusive.

[0043] Each feature disclosed in this specification including any accompanying claims, abstract, and drawings may be replaced by alternative features serving the same, equivalent, or similar purpose, unless expressly stated otherwise. Thus, unless expressly stated otherwise, each feature disclosed is one example only of a generic series of equivalent or similar features.

[0044] The invention is not restricted to the details of the foregoing embodiment(s). The invention extends to any novel one, or any novel combination, of the features disclosed in this specification including any accompanying claims, abstract, and drawings, or to any novel one, or any novel combination, of the steps of any method or process so disclosed.